blob: f2c0318ac2692714385eb554942064f344dbea3d [file] [log] [blame]
//
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
//
= DevFaqEditorWhatIsMimeLookup
:jbake-type: wiki
:jbake-tags: wiki, devfaq, needsreview
:jbake-status: published
:keywords: Apache NetBeans wiki DevFaqEditorWhatIsMimeLookup
:description: Apache NetBeans wiki DevFaqEditorWhatIsMimeLookup
:toc: left
:toc-title:
:syntax: true
=== 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
[source,xml]
----
# 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
See also:
link:DevFaqLookup.asciidoc[What is Lookup?],
link:http://www.netbeans.org/download/dev/javadoc/org-netbeans-modules-editor-mimelookup/index.html[MimeLookup API]
=== Apache Migration Information
The content in this page was kindly donated by Oracle Corp. to the
Apache Software Foundation.
This page was exported from link:http://wiki.netbeans.org/DevFaqEditorWhatIsMimeLookup[http://wiki.netbeans.org/DevFaqEditorWhatIsMimeLookup] ,
that was last modified by NetBeans user Dbell
on 2010-09-30T10:33:17Z.
*NOTE:* This document was automatically converted to the AsciiDoc format on 2018-02-07, and needs to be reviewed.