/** * Find a result corresponding to a given class. * Equivalent to calling {@link #lookup(Lookup.Template)} but slightly more convenient. * Subclasses may override this method to produce the same semantics more efficiently. * @param clazz the supertype of the result * @return a live object representing instances of that type * @since org.openide.util 6.10 */ public <T> Lookup.Result<T> lookupResult(Class<T> clazz) { return lookup(new Lookup.Template<T>(clazz)); }
loaderQuery = Lookup.getDefault().lookup(new Lookup.Template<ClassLoader>(ClassLoader.class)); loaderQuery.addLookupListener( new LookupListener() {
final Lookup.Result<T> r = Lookup.getDefault().lookup(new Lookup.Template<T>(clazz));
/** Get all registered script types. * @return enumeration of <code>ScriptType</code>s * @deprecated Please use {@link org.openide.util.Lookup} instead. */ public static java.util.Enumeration scriptTypes () { return Collections.enumeration(Lookup.getDefault().lookup(new Lookup.Template(ScriptType.class)).allInstances()); }
public <T> Lookup.Result<T> lookup(Lookup.Template<T> template) { Class<T> clz = template.getType(); if (clz == Node.class) { return Lookup.EMPTY.lookup(new Lookup.Template<T>(clz)); } else { return new ExclusionResult<T>(delegate.lookup(template), verboten); } }
final Lookup.Result<T> r = Lookup.getDefault().lookup(new Lookup.Template<T>(clazz));
Lookup.Result<Factory> r = Lookup.getDefault().lookup(new Lookup.Template<Factory>(Factory.class)); for (Factory f: r.allInstances()) {
loaderQuery = Lookup.getDefault().lookup(new Lookup.Template<ClassLoader>(ClassLoader.class)); loaderQuery.addLookupListener( new LookupListener() {
return false; Lookup.Template<T> template = new Lookup.Template<T>(type); for (Lookup.Provider prov : items.allInstances()) { if (prov.getLookup().lookupItem(template) == null) { return false; Lookup.Template<T> template = new Lookup.Template<T>(type); for (Lookup.Provider prov : items.allInstances()) { if (prov.getLookup().lookupItem(template) == null) {
/** * Implementation of the above method. * * @param activatedNodes gives array of actually activated nodes. * @return number of supported classes */ private int resolveSupported(Node[] activatedNodes) { int ret = 0; Class<?>[] cookies = getCookies(); for (Node n : activatedNodes) { for (Class<?> cookie : cookies) { // test for supported cookies @SuppressWarnings("unchecked") Lookup.Template<?> templ = new Lookup.Template(cookie); if (n.getLookup().lookupItem(templ) != null) { ret++; break; } } } return ret; }
/** Implementation of {@link Savable#save} contract. Calls * {@link #handleSave} and {@link #unregister}. * * @throws IOException if call to {@link #handleSave} throws IOException */ @Override public final void save() throws IOException { Template<AbstractSavable> t = new Template<AbstractSavable>(AbstractSavable.class, null, this); for (Savable s : Savable.REGISTRY.lookup(t).allInstances()) { if (s == this) { handleSave(); unregister(); return; } } LOG.log(Level.WARNING, "Savable {0} is not in Savable.REGISTRY! " // NOI18N + "Have not you forgotten to call register() in constructor?", getClass()); // NOI18N }
@SuppressWarnings("unchecked") // cannot type-check this but ought to be safe private static <T> Lookup.Template<T> wackohacko(String id, T instance) { return new Lookup.Template(Node.class, id, instance); }
private GlobalManager() { result = Utilities.actionsGlobalContext().lookup(new Lookup.Template<ActionMap>(ActionMap.class)); result.addLookupListener(this); resultChanged(null); }
public DelegateAction(CallbackSystemAction a, Lookup actionContext) { this.delegate = a; this.weakL = org.openide.util.WeakListeners.propertyChange(this, null); this.enabled = a.getActionPerformer() != null; this.result = actionContext.lookup(new Lookup.Template<ActionMap>(ActionMap.class)); this.result.addLookupListener(WeakListeners.create(LookupListener.class, this, this.result)); resultChanged(null); }
public final <T> T lookup(Class<T> clazz) { beforeLookup(new Template<T>(clazz)); Lookup[] tmpLkps; synchronized (ProxyLookup.this) { tmpLkps = getData().getLookups(false); } for (int i = 0; i < tmpLkps.length; i++) { T o = tmpLkps[i].lookup(clazz); if (o != null) { return o; } } return null; }
public String toString() { return "SimpleLookup" + lookup(new Template<Object>(Object.class)).allInstances(); }
public final <T> T lookup(Class<T> clazz) { Lookup.Item<T> item = lookupItem(new Lookup.Template<T>(clazz)); return (item == null) ? null : item.getInstance(); }
private GlobalManager() { result = Utilities.actionsGlobalContext().lookup(new Lookup.Template<ActionMap>(ActionMap.class)); result.addLookupListener(this); resultChanged(null); }
public DelegateAction(CallbackSystemAction a, Lookup actionContext) { this.delegate = a; this.weakL = org.openide.util.WeakListeners.propertyChange(this, null); this.enabled = a.getActionPerformer() != null; this.result = actionContext.lookup(new Lookup.Template<ActionMap>(ActionMap.class)); this.result.addLookupListener(WeakListeners.create(LookupListener.class, this, this.result)); resultChanged(null); }
@Override public String toString() { if (tree instanceof Storage) { return "AbstractLookup" + lookup(new Lookup.Template<Object>(Object.class)).allItems(); // NOI18N } else { return super.toString(); } }