|
org.netbeans.modules.editor.mimelookup/1 1.3.22 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.openide.util.Lookup org.netbeans.api.editor.mimelookup.MimeLookup
public final class MimeLookup
Mime Lookup provides lookup mechanism for mime specific objects. It can be used for example for retrieving mime specific editor settings, actions, etc.
For obtaining mime-type specific lookup
getMimeLookup(String mimeType)
static method can be used.
Because embeded languages (like JSP) can contain embeded mime types, the mime lookup also provides the functionality of lookup over these embeded mime types.
For obtaining mime-type specific embeded lookup
childLookup(String mimeType)
method can be used.
Clients can listen on the lookup result for lookup changes. Because lookup results are held weakly, client is responsible for reference holding during life-time frame. Listeners added to lookup result should be weak. As a pattern for that requirements, following code snippet can be used:
public class MyClass { private Lookup.Result result; private LookupListener weakLookupListener; private LookupListener lookupListener public MyClass(){ MimeLookup lookup = MimeLookup.getMimeLookup("text/x-java"); //use your content type here result = lookup.lookup(new Lookup.Template(YourObjectHere.class)); result.allInstances(); // allInstances should be called, otherwise event will // not be fired - optimalization in ProxyLookup lookupListener = new LookupListener(){ public void resultChanged(LookupEvent ev) { // handle your code } }; weakLookupListener = (LookupListener) WeakListeners.create( LookupListener.class, lookupListener, result); result.addLookupListener(weakLookupListener); } }
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.openide.util.Lookup |
---|
Lookup.Item, Lookup.Provider, Lookup.Result, Lookup.Template |
Field Summary |
---|
Fields inherited from class org.openide.util.Lookup |
---|
EMPTY |
Method Summary | |
---|---|
MimeLookup |
childLookup(String mimeType)
Gets mime-type specific child (embeded) lookup. |
static MimeLookup |
getMimeLookup(String mimeType)
Gets mime-type specific lookup. |
Object |
lookup(Class clazz)
Look up an object matching a given interface. |
Lookup.Result |
lookup(Lookup.Template template)
The general lookup method. |
Methods inherited from class org.openide.util.Lookup |
---|
getDefault, lookupItem |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static MimeLookup getMimeLookup(String mimeType)
mimeType
- non-null mime-type string representation, e.g. "text/x-java"
public MimeLookup childLookup(String mimeType)
mimeType
- non-null mime-type string representation
public Object lookup(Class clazz)
clazz
- class of the object we are searching for
null
if no such
implementation is foundpublic Lookup.Result lookup(Lookup.Template template)
template
and attach a listener to
this be notified about changes. The general interface does not
specify whether subsequent calls with the same template produce new
instance of the Lookup.Result
or return shared instance. The
prefered behaviour however is to return shared one.
template
- a template describing the services to look for
|
org.netbeans.modules.editor.mimelookup/1 1.3.22 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |