Re: Different icons for the files with same mime and different extensions.
"Ingleby, Graeme" <[email protected]>
| Newsgroups | gmane.comp.java.netbeans.modules.openide.devel |
|---|---|
| Message-ID | <45F55A2F088AA84FB3FBCEAE1C8EE99319D8A9@SATLRCCDLMB514.delta.rl.delta.com> |
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: [X] 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]<mailto:[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]<mailto:[email protected]>>: It depends. Do you use annotations to register your editor tabs? Boris Am 08.07.2016 14:27 schrieb "Volodymyr" <[email protected]<mailto:[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]<mailto:[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.