org.netbeans.api.editor.mimelookup
MimeLookupSPI in org.netbeans.spi.editor.mimelookup
See: Description
Package | Description |
---|---|
org.netbeans.api.editor.mimelookup | |
org.netbeans.spi.editor.mimelookup |
The SPI allows registering providers of mime type specific
Lookup s. |
It consists of
org.netbeans.api.editor.mimelookup
org.netbeans.spi.editor.mimelookup
API contains only two classes:
1. org.netbeans.api.editor.mimelookup.MimeLookup with public methods: static MimeLookup getMimeLookup(String mime)
- gets mime specific lookup. static Lookup getLookup(MimePath mimePath)
- gets the lookup for the particular mime-path. MimeLookup childLookup(String mime)
- gets mime specific child (embeded) lookup. The method was deprecated in favour of
static Lookup getLookup(MimePath mimePath) Object lookup(Class clazz)
- Look up an object matching a given interface. Result lookup(Lookup.Template template)
- The general lookup method. Callers can get list of all instances and classes
that match the given template
and attach a listener to
this be notified about changes. static MimePath get(String mimeType)
- gets root mime-path for the given mime-type. static MimePath get(MimePath prefix, String mimeType)
- gets mime-path corresponding to the mime-type used in the given context
mime-path. static MimePath parse(String path)
- parses the given mime-path string
e.g. "text/x-jsp/text/x-java" and get the corresponding mime-path. String getPath()
- gets string path represented by this mime-path. int size()
-gets total number of mime-types in the mime-path. String getMimeType(int index)
- gets mime type of this mime-path at the given index. MimePath getPrefix(int size)
- returns prefix mime-path with the given number of mime-type components
ranging from zero till the size of this mime-path. MimeLookup
is represented via ProxyLookup that collects registered lookups. Particular lookups,
responsible for looking up their objects can be registered using interface MimeDataProvider
into default lookup
by META-INF/services registration. Previously used registration via interface MimeLookupInitializer
was deprecated.
In addition to this basic registration, xml layer folder registration is also available.
It is provided by registering implemented interface Class2LayerFolder
into default lookup
via META-INF/services registration.
This approach provides a mapping of class to specific subfolder.
Using this mapping one can achieve the convenient way of using MimeLookup
e.g.
MimeLookup.getMimeLookup("text/x-java").lookup(FoldManagerFactory.class);
Using this, an instance of FoldManagerFactory is retrieved from the folder with path
"Editors/text/x-java/FoldManager" provided that FoldManagerFactory.class is registered to
a subfolder "FoldManager" via Class2LayerFolder
registration.
InstanceProvider
can be used if there are files
of various types in the layer folder that need additional handling
before becoming and instance of certain class.
For more details look at use case of PopupActions creation.
The Javadoc documentation can be generated by using
cd /cvs/editor/mimelookup ant javadoc
getIncludedPaths
can be now used to compute all MimePaths that should
be considered for the content. In the past, reflection was used to access this functionality.
getInheritedType
provides generalized or parent MIME type for the content,
which allows to search settings (services) fallbacks.
Class2LayerFolder
has been deprecated and is ignored.
Added @MimeLocation
, @MimeRegistration
and @MimeRegistrations
that allow to register services to the MimeLookup.
MimeLookup.getLookup(String mimePath)
converts
the (usually held) string mimePath to the MimePath
object automatically.
The validate(CharSequence path)
and
validate(CharSequence type, CharSequence subtype)
methods
were added to the MimePath
class to allow validating
mime paths and mime type components.
org.openide.util.Lookup
allowing to provide
the registered instances as a Lookup.Result
allowing to listen for changes (e.g. caused by the module enabling/disabling).
class MimeLookup extends Lookup
containing
static MimeLookup getMimeLookup(String mimeType)
.
static Lookup getLookup(MimePath mimePath)
method in MimeLookup
.
org.netbeans.spi.editor.fold.FoldManagerFactory
classes).
org.netbeans.spi.editor.completion.CompletionProvider
classes).
javax.swing.Action
classes or names of actions
(i.e. value of Action.NAME attribute) present in editor kit e.g. "goto-source").
org.netbeans.editor.SideBarFactory
classes).
org.netbeans.lib.editor.hyperlink.spi.HyperlinkProvider
classes).
org.netbeans.lib.editor.codetemplates.spi.CodeTemplateProcessorFactory
classes).
org.netbeans.modules.editor.hints.spi.HintsProvider
classes).
MimeLookup lookup = MimeLookup.getMimeLookup("text/x-java");
can be used for getting the mime specific lookup. Having this we can lookup class
or template:
Object obj = lookup.lookup(LookedUpClass.class);
or
Lookup.Result result = lookup.lookup(new Lookup.Template(LookedUpClass.class));
MimePath scriptletPath = MimePath.parse("text/x-jsp/text/x-java"); Lookup lookup = MimeLookup.getLookup(scriptletPath);
MimeLookup
. Implementation of MimeLookupInitializer
should be created and
registered to default lookup via META-INF/services
registration.
For details, please look at the simplified
TestMimeLookupInitializer
in mimelookup/test/unit
or LayerMimeLookupInitializer
.
Usage of MimeLookupInitializer is deprecated, please use MimeDataProvider instead in similar way
|
|
The default answer to this question is:
The sources for the module are in the Apache Git repositories or in the GitHub repositories.
Read more about the implementation in the answers to architecture questions.