junichi11 / netbeans-color-codes-preview

Show colors in an editor's sidebar
https://netbeans-vm.apache.org/pluginportal/catalogue/?id=24
Apache License 2.0
32 stars 8 forks source link

Add support for other languages and plugins #15

Closed arsi-apli closed 5 years ago

arsi-apli commented 5 years ago

Hi, Thanks for creation of this plugin!

This plugin has a great potential. I would like to use it in the project https://github.com/NBANDROIDTEAM/NBANDROID-V2

But I would like to add support for external plugins. After I create this issue, I add a commit to my copy of the repository. Please look at it.

I added @ServiceProvider with interface ColorCodesProvider which allows integration into other plugins. And I added basic support for Java, Color constants and RGB Color values. Please check your support for css if I did not something wrong.. I have no experience with css. If everything is OK, then I can do PR..

Thanks.

junichi11 commented 5 years ago

I added @Serviceprovider

Maybe, it should be good.

Just create a PR :)

arsi-apli commented 5 years ago

I prepared commit, with some changes.. I added current document to the service methods public void checkVariables(Document document, String mimeType,... Then you can get owning project:

   public static FileObject getPrimaryFile(Document doc) {
        Object o = doc.getProperty(Document.StreamDescriptionProperty);
        if (o instanceof FileObject) {
            return (FileObject) o;
        } else if (o instanceof Lookup.Provider) {
            //Note: DataObject is a Lookup.Provider
            return ((Lookup.Provider) o).getLookup().lookup(FileObject.class);
        } else {
            return null;
        }
    }
            FileObject primaryFile = getPrimaryFile(document);
            if (primaryFile != null) {
                Project project = FileOwnerQuery.getOwner(primaryFile);
                if (project != null) {
                    AndroidResValuesProvider provider = project.getLookup().lookup(AndroidResValuesProvider.class);
                    if (provider != null) {
                        return true;
                    }
                }
            }

And I added the method public boolean isColorEditable(ColorValue colorValue)This turns off color editing, for variables from another file.

obrazok

junichi11 commented 5 years ago

Done.