DevFaqEditorWhatIsMimeLookup

(Difference between revisions)
m (Examples)
Line 51: Line 51:
--------
--------
-
Applies to: NetBeans 5.0, 5.5, 6.0 <br>
+
Applies to: NetBeans 5.x, 6.x
-
Platforms: All <br>
+
 
 +
Platforms: All
 +
 
See also:
See also:
[[DevFaqLookup| What is Lookup?]],  
[[DevFaqLookup| What is Lookup?]],  
[http://www.netbeans.org/download/dev/javadoc/org-netbeans-modules-editor-mimelookup/index.html MimeLookup API]
[http://www.netbeans.org/download/dev/javadoc/org-netbeans-modules-editor-mimelookup/index.html MimeLookup API]

Revision as of 14:04, 16 June 2010

What is MimeLookup?

The MimeLookup is a mechanism for extending editor functionality provided by NetBeans modules.

Most of the editor functionality in NetBeans is organized by mime types of documents that are edited. There are special modules that provide support for editing java, xml, jsp, c++ and many other file types. All those modules need to provide more or less the same features such as syntax coloring, code completion, code folding, popup menu, etc. However, the implementation of those features is different for particular file types.

The editor insfrastructure provides many SPI interfaces that can be implemented by modules providing specific implementation of editor features and the MimeLookup is the way how these implementations can be plugged in to the system.

As its name suggests MimeLookup is a mime-type specific Lookup. This means that modules can register instances in the Lookup dedicated to the mime type of files that they support. For example there are different Lookups for text/x-java and text/xml mime types and both contain FoldManager implementations specific for java and XML languages respectively.

The MimeLookup implementation is split in two parts. The first part is pretty much independent on most of the other NetBeans libraries and provides a simple API and SPI for accessing contents of MimeLookup. The second part is a NetBeans specific implementation of the MimeLookup's registry based on the modules XML layers. This registry is in fact a hierarchical structure of folders under the Editors/ folder on the system filesystem.


Examples

# How to get Lookup for java files?
MimePath mimePath = MimePath.parse("text/x-java");
Lookup lookup = MimeLookup.getLookup(mimePath);

# How to register instances (e.g. EditorKit) in the Lookup for java files?
<folder name="Editors>
  <folder name="text">
    <folder name="x-java">
      <file name="org-netbeans-modules-java-JavaEditorKitImpl.instance"/>
    </folder>
  </folder>
</folder>

Applies to: NetBeans 5.x, 6.x

Platforms: All

See also: What is Lookup?, MimeLookup API

Not logged in. Log in, Register

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo