org.netbeans.spi.editor.mimelookup

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » editor » org.netbeans.spi.editor.mimelookup 
org.netbeans.spi.editor.mimelookup
The SPI allows registering providers of mime type specific Lookups. The MimeDataProvider interface can be used to implement such a provider and register it among the services in the default lookup. The editor/mimelookup module will consult all registered MimeDataProviders when creating a Lookup for a specific MimePath.

Default MimeDataProvider

The module itself provides a default implementation of the MimeDataProvider, which creates Lookups from the data registered in a hierachical structure of folders on the system filesystem.

The hierarchy starts with the 'Editors' folder and then contains subfolders for each mime type that has some registered objects. Since each mime type is uniquely identified by its MimePath the string represantation of the MimePath can be used as a filesystem path to the folder holding objects registered for that mime type. For example the 'text/x-java' mime type embedded in the 'text/x-jsp' mime type is represented by the 'text/x-jsp/text/x-java' mime path and the objects/settings specific for this mime type can be registered in the 'Editors/text/x-jsp/text/x-java' folder.

The empty MimePath refers to the 'Editors' folder iteslf.

The Lookup provided for a mime path is in fact a chain of Lookups for all mime paths that can be created from the original mime path by cutting off its mime type components from the end. So, for example the Lookup for the 'text/x-jsp/text/x-java' mime path is made up of three different Lookups using the following folders:

    Editors/text/x-jsp/text/x-java
    Editors/text/x-jsp
    Editors

The default MimeDataProvider allows registering implementations of the Class2LayerFolder interface in order to supply additional information about the location of instances registered in the mime type folders. Each Class2LayerFolder implementation can specify that instances of a certain class will be registered in a special subfolder. The Lookup created by the default MimeDataProvider will then look into the subfolders rather than to the usual mime type folders when looking for instances of that class. An example can be instances of the FoldManager class that are registered in the foldManager subfolders. The Lookups hierarchy in this case uses the folders below:

    Editors/text/x-jsp/text/x-java/foldManager
    Editors/text/x-jsp/foldManager
    Editors/foldManager

Compound MIME types

The default MimeDataProvider supports compound mime types, which are the mime types that have two parts separated by a plus sign ('+'). The compound mime types are heavily used for describing different types of XML files. For example an Ant build script's mime type is text/x-ant+xml, which means that the file is an XML file, but not an ordinary XML file. It's a build script.

From the editor's point of view a file with a compound mime type should offer the behavior of the default mime type (e.g. text/xml) plus special behaviors specific for its original mime type (e.g. text/x-ant+xml). Therefore a Lookup provided for a mime path that contains a compound mime type will collect settings and services from both the folders belonging to the compound mime type and the folders belonging to its default part. The example below shows the list of folders comprising a Lookup for the 'text/x-ant+xml/text/x-java' mime path.

    Editors/text/x-ant+xml/text/x-java
    Editors/text/x-ant+xml
    Editors/text/xml/text/x-java
    Editors/text/xml
    Editors

Ordering and hiding files

When registering instances in the mime path folders it is possible to use position attributes to order the files the same way as you would do it in any other files in a module XML layer. The attributes however will be resolved after all the folders belonging to a mime path are merged. Therefore it is possible to use attributes that define position relatively to a file in a parent (embedding) mime type.

<folder name="Editors">
  <folder name="Popup">
    <file name="org-openide-actions-CutAction.instance"><attr name="position" intvalue="100"/></file>
    <file name="org-openide-actions-CopyAction.instance"><attr name="position" intvalue="200"/></file>
    <file name="org-openide-actions-PasteAction.instance"><attr name="position" intvalue="300"/></file>
  </folder>
  <folder name="text">
    <folder name="x-java">
      <folder name="Popup">
        <file name="org-netbeans-modules-project-ui-RunSingle"><attr name="position" intvalue="400"/></file>
      </folder>
    </folder>
  </folder>
</folder>

It is also possible to influence the default inheritance of files from folders belonging to a parent (embedding) mime type and mask them out by defining a 'hidden file' in the child mime type folder. Hidden files are marked by a special attribute called hidden with a booleanValue equal to 'true'. The example below hides the editor's global CopyAction in documents with the 'text/x-java' mime type.

<folder name="Editors">
  <folder name="Popup">
    <file name="org-openide-actions-CutAction.instance" />
    <file name="org-openide-actions-CopyAction.instance" />
    <file name="org-openide-actions-PasteAction.instance" />
  </folder>
  <folder name="text">
    <folder name="x-java">
      <file name="org-openide-actions-CopyAction.instance" >
        <attr name="hidden" booleanValue="true" />
      </file>
    </folder>
  </folder>
</folder>

Please note that appending '_hidden' to the name of the file does not work, because such a file is made hidden by the XML filesystem implementation when the module layer is loaded and therefore such a file is not visible to the merging mechanism implemented in the mimelookup module.

Java Source File NameTypeComment
Class2LayerFolder.javaInterface Provides further clasification of objects registered for a mime type.
InstanceProvider.javaInterface Provider of the instance of the given class.
The provider gets a list of files which it transfers into one instance of the class for which it's declared.

For example there can be an instance provider of actions for the editor popup.

MimeDataProvider.javaInterface Provides a Lookup for the specific MimePath.
MimeLookupInitializer.javaInterface Provides an initialization of MimeLookup on either global or mime-type specific level.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.