Apache NetBeans
Apache NetBeans
Latest release

Apache NetBeans 23

Download

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 of these 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 these features is different for particular file types.

The editor insfrastructure provides many SPI interfaces that can be implemented by modules providing specific implementations of editor features, and the MimeLookup is the way that 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 of 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 the 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