Re: Different icons for the files with same mime and different extensions.

Volodymyr <[email protected]>
Newsgroups gmane.comp.java.netbeans.modules.openide.devel
Message-ID <[email protected]>
The extension signifies a metadata type, which have a meaning in the system. Also for some extensions there may be additional keywords, but to have a beta version of the plugin faster, we did not want to spend time on this at the moment, since it is considered to be low-priority. So I thought there might be a way for icons to be set correctly, leaving the rest as it is. 

Will try the topcomponent thing you suggest, if it will be difficult, will create different mime-types now, I will have to do it at some point anyway. 

Thanks, 
 Vova 

15 липня 2016, 08:40:25, від "Tim Boudreau" < [email protected] >: 

You probably need to provide your own editor TopComponent or something similar - stuff that's normally provided automatically for you.  Or fish around in TopComponent.getRegistry(), find the editor component for your file and change it after you're *sure* it's been opened (which may happen asynchronously) - you should be able to get the DataObject from it's lookup and see if it's yours. 
That said, I too question the design here - why two extensions for the same data format?  Something smells badly thought-out here.  What does the extension signify? 
-Tim 

On Mon, Jul 11, 2016 at 9:40 AM, Ingleby, Graeme < [email protected] > wrote: 
Your example appears to be working correctly according to the API design.   Have you read this page: http://wiki.netbeans.org/DevFaqFileRecognition ?   Is there a reason you need to have a single Mime type?  I’m not sure you can have the “same” but “different” functionality you are requesting using a single type.  I cannot see the image below where you ask how NetBeans displays different icons for XML files but I will assume you are looking at XSLT, XSD, XJB, etc.   They are all subtypes (separate mime types) e.g. “text/xsd+xml”, “text/xsl+xml”   I would change your github example to register two  File Types (in your case even the extensions are different).  Then all will work as you expect.   If you want a single extension and two different media-types that is possible by registering a MimeResolver that looks at the file content to determine which type the file is.    Either way you will end up with two MimeTypes, two DataObjects, etc. and you’ll know
  exactly what file type you are working with.   When I was working on custom projects/file types I found these resources helpful:   https://platform.netbeans.org/tutorials/nbm-filetype.html http://bits.netbeans.org/dev/javadoc/org-openide-filesystems/org/openide/filesystems/doc-files/HOWTO-MIME.html http://forums.netbeans.org/post-142744.html http://bits.netbeans.org/dev/javadoc/org-openide-filesystems/org/openide/filesystems/doc-files/resolverDocumentation.html       From: Volodymyr [mailto: [email protected] ] 
Sent: Monday, July 11, 2016 8:15 AM 
To: [email protected] 
Subject: [platform-dev] Re: Different icons for the files with same mime and different extensions.   
I have set up a small example on github: 
https://github.com/complier/IcoExample 

By this setup I want to have files with "ax" extension to be opened with AxIcon.png and "bx" to be opened with BxIcon.png in editor tab. 

Now it works this way: 


I need the highlighted icons to be different, for different extensions, even though they are using same mime type. 

Can anybody have a look what am I missing? 

Thanks. 08 липня 2016, 17:14:15, від "Volodymyr" < [email protected] >:   Yes, I've been using this annotation: 
@DataObject.Registration( 
        mimeType = MyLanguage.MIME_TYPE, 
        iconBase = "com/my/resources/AIcon.png", 
        displayName = "#LBL_My_LOADER", 
        position = 300 
) 

Of course it doesn't allow to specify different icos for different files extensions. 08 липня 2016, 16:38:06, від "Boris Heithecker" < [email protected] >:   It depends. Do you use annotations to register your editor tabs? 
Boris Am 08.07.2016 14:27 schrieb "Volodymyr" < [email protected] >: Does anybody know? Please). 

E.g. how does NetBeans know which icon to show here: 


3 different icons for .xml file. 

Thanks. 07 липня 2016, 16:51:59, від "Volodymyr" < [email protected] >:   Hello, 

I've got files with .a and .b extensions. They contain source code with the same language, e.g. 
@MIMEResolver.ExtensionRegistration( 
        displayName = "#LBL_My_LOADER", 
        mimeType = MyLanguage.MIME_TYPE, 
        extension = {"a","b"} 
) 

I have a leaf node as follows: 
public class MyLeafNode extends FilterNode { 
....... 
    @Override 
    public Image getIcon(int type) { 
        switch(file.getExt()) { 
            case "a": 
                return ImageUtilities.loadImageIcon("com/my/resources/AIcon.png", false).getImage(); 
       &nbs p;    case "b": 
                return ImageUtilities.loadImageIcon("com/my/resources/BIcon.png", false).getImage(); 
            default : 
                return super.getIcon(type); 
        } 
    } 
....... 
} 

In project view everything works perfect, the icons are displayed correctly. But when the files are opened, the icons do not get used to display the tab with file editor. What should I do? 

Thanks. 


-- 
http://timboudreau.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.