當前位置: 首頁>>代碼示例>>Java>>正文


Java Lookup.Item方法代碼示例

本文整理匯總了Java中org.openide.util.Lookup.Item方法的典型用法代碼示例。如果您正苦於以下問題:Java Lookup.Item方法的具體用法?Java Lookup.Item怎麽用?Java Lookup.Item使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openide.util.Lookup的用法示例。


在下文中一共展示了Lookup.Item方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testItemsAndIntances

import org.openide.util.Lookup; //導入方法依賴的package包/類
/** Items are the same as results.
 */
public void testItemsAndIntances () {
    addInstances (INSTANCES);
    
    Lookup.Result<Object> r = lookup.lookupResult(Object.class);
    Collection<? extends Lookup.Item<?>> items = r.allItems();
    Collection<?> insts = r.allInstances();
    
    if (items.size () != insts.size ()) {
        fail ("Different size of sets");
    }

    for (Lookup.Item<?> item : items) {
        if (!insts.contains (item.getInstance ())) {
            fail ("Intance " + item.getInstance () + " is missing in " + insts);
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:AbstractLookupBaseHid.java

示例2: enhancedQueryMode

import org.openide.util.Lookup; //導入方法依賴的package包/類
static void enhancedQueryMode(Lookup lookup, Class<?> clazz) {
    Object type = QUERY_MODE.get();
    if (type != clazz) {
        return;
    }
    Collection<? extends Lookup.Item<?>> items = lookup.lookupResult(clazz).allItems();
    if (items.size() == 0) {
        return;
    }
    AbstractLookup.Pair[] arr = new AbstractLookup.Pair[items.size()];
    Iterator<? extends Lookup.Item> it = items.iterator();
    for (int i = 0; i < arr.length; i++) {
        arr[i] = new PairWrap(it.next());
    }
    QUERY_MODE.set(arr);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:CookieSet.java

示例3: getDescription

import org.openide.util.Lookup; //導入方法依賴的package包/類
private String getDescription (Lookup.Item item) {
    String id = item.getId ();
    String result = null;
    try {
        result = Introspector.getBeanInfo(item.getInstance().getClass()).getBeanDescriptor().getShortDescription();
    } catch (IntrospectionException ie) {
        //do nothing
    }
    String toCheck = item.getInstance().getClass().getName();
    toCheck = toCheck.lastIndexOf('.')!=-1 ? 
        toCheck.substring(toCheck.lastIndexOf('.')+1) : toCheck; //NOI18N
    if (toCheck.equals(result)) {
        result = null;
    } 
    return result;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:ObjectEditor.java

示例4: getToolActions

import org.openide.util.Lookup; //導入方法依賴的package包/類
static List<Action> getToolActions() {
    ActionManager am = ActionManager.getDefault();
    List<Action> arr = new ArrayList<Action>();
    arr.addAll(Arrays.<Action>asList(am.getContextActions()));

    String pref = arr.isEmpty() ? null : "";
    for (Lookup.Item<Action> item : gl().result.allItems()) {
        final Action action = item.getInstance();
        if (action == null) {
            continue;
        }
        String where = item.getId().replaceFirst("[^/]*$", ""); // NOI18N
        if (pref != null && !pref.equals(where)) {
            arr.add(null);
        }
        pref = where;
        arr.add(action);
    }
    return arr;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:ToolsAction.java

示例5: allItems

import org.openide.util.Lookup; //導入方法依賴的package包/類
public Collection<? extends Item<T>> allItems() {
    Collection<? extends Item<T>> c = delegate.allItems();
    List<Item<T>> ret = new ArrayList<Item<T>>(c.size()); // upper bound

    for (Lookup.Item<T> i : c) {
        if (Node.class.isAssignableFrom(i.getType())) 
        {
            if (verboten.containsKey(i.getInstance())) {
                continue;
            }
        }
        ret.add(i);
    }

    return ret;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:DefaultEMLookup.java

示例6: getAsText

import org.openide.util.Lookup; //導入方法依賴的package包/類
@Override
public String getAsText() {
    Object value = getValue ();
    if (value == null) {
        return nullValue == null ? 
            NbBundle.getMessage (ObjectEditor.class, "CTL_NullValue")
        :
            nullValue;
    }
    
    Lookup.Template<Object> t = new Lookup.Template<Object> (
        template ().getType (),
        template ().getId (),
        value // instance to search for
    );
    Lookup.Item item = lookup ().lookupItem (t);
    
    if (item == null) {
        return NbBundle.getMessage (ObjectEditor.class, "CTL_NullItem");
    }
    
    return item.getDisplayName();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:ObjectEditor.java

示例7: readPanels

import org.openide.util.Lookup; //導入方法依賴的package包/類
private void readPanels() {
    Lookup lookup = Lookups.forPath(tabFolder);
    options = lookup.lookup(new Lookup.Template<AdvancedOption>( AdvancedOption.class ));
    tabTitle2controller = new HashMap<String, OptionsPanelController>();
    id2tabTitle = new HashMap<String, String>();
    synchronized (tabTitle2Option) {
        for (Lookup.Item<AdvancedOption> item : options.allItems()) {
            AdvancedOption option = item.getInstance();
            String displayName = option.getDisplayName();
            if (displayName != null) {
                tabTitle2Option.put(displayName, option);
                String id = item.getId().substring(item.getId().lastIndexOf('/') + 1);  //NOI18N
                id2tabTitle.put(id, displayName);
            } else {
                LOGGER.log(Level.WARNING, "Display name not defined: {0}", item.toString());  //NOI18N
            }
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:TabbedController.java

示例8: ItemRadioButton

import org.openide.util.Lookup; //導入方法依賴的package包/類
public ItemRadioButton(Lookup.Item item, Font font) {
    this.item = item;
    setName(item.getId());
    setText(item.getDisplayName());
    setFont(font);
    getAccessibleContext().setAccessibleName(getName());
    getAccessibleContext().setAccessibleDescription(
    getText());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:ObjectEditor.java

示例9: initialize

import org.openide.util.Lookup; //導入方法依賴的package包/類
void initialize() {
    for (Lookup.Item<Runnable> item : onShowing().allItems()) {
        synchronized (onShowing) {
            if (onShowing.add(item.getId())) {
                Runnable r = item.getInstance();
                if (r != null) {
                    wm.invokeWhenUIReady(r);
                }
            }
        }
    }
    
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:OnShowingHandler.java

示例10: getManagerProvider

import org.openide.util.Lookup; //導入方法依賴的package包/類
private CoreManager getManagerProvider() {
    Collection<? extends Lookup.Item<CoreManager>> providers = Lookup.getDefault().lookupResult(CoreManager.class).allItems();
    for (Lookup.Item<CoreManager> provider : providers) {
        if(provider.getDisplayName().endsWith("_".concat(org.netbeans.modules.gsf.testrunner.api.CommonUtils.TESTNG_TF))) {
            return provider.getInstance();
        }
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:TestNGOutputReader.java

示例11: lookupItem

import org.openide.util.Lookup; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public <T> Item<T> lookupItem(Template<T> template) {
    if (template == null) {
        throw new IllegalArgumentException("null");                 //NOI18N
    }

    String templateId = template.getId();
    if (templateId != null) {
        if (id == null) {
            if (!templateId.equals(objectToLookup.toString())) {
                return null;
            }
        } else {
            if (!templateId.equals(id)) {
                return null;
            }
        }
    }

    Object templateInst = template.getInstance();
    if ((templateInst != null) && (objectToLookup != templateInst)) {
        return null;
    }

    Class<T> clazz = template.getType();
    if ((clazz != null) && !clazz.isInstance(objectToLookup)) {
        return null;
    }

    Lookup.Item<T> item;
    if (clazz != null) {
        item = Lookups.lookupItem(clazz.cast(objectToLookup), id);
    } else {
        item = Lookups.lookupItem((T) objectToLookup, id);
    }
    return item;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:39,代碼來源:SingletonLookup.java

示例12: testLookupItem

import org.openide.util.Lookup; //導入方法依賴的package包/類
public void testLookupItem() {
    SomeInst inst = new SomeInst();
    Lookup.Item item = Lookups.lookupItem(inst, "XYZ");
    
    assertTrue("Wrong instance", item.getInstance() == inst);
    assertTrue("Wrong instance class", item.getType() == inst.getClass());
    assertEquals("Wrong id", "XYZ", item.getId());

    item = Lookups.lookupItem(inst, null);
    assertNotNull("Id must never be null", item.getId());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:SimpleLookupTest.java

示例13: isAllJustLookupProviders

import org.openide.util.Lookup; //導入方法依賴的package包/類
private boolean isAllJustLookupProviders(Lookup lkp) {
    for (Lookup.Item<?> item : lkp.lookupResult(Object.class).allItems()) {
        Class<?> clzz = item.getType();
        if (!LookupProvider.class.isAssignableFrom(clzz) && !MetaLookupMerger.class.isAssignableFrom(clzz)) {
            LOG.log(Level.WARNING, "{0} from {1} is not a LookupProvider", new Object[] {clzz.getName(), item.getId()});
        }
    }
    return true; // always just print warnings
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:DelegatingLookupImpl.java

示例14: findResolver

import org.openide.util.Lookup; //導入方法依賴的package包/類
private static MIMEResolver findResolver(String name) {
    final Collection<? extends Item<MIMEResolver>> arr = Lookups.forPath("Services/MIMEResolver").lookupResult(MIMEResolver.class).allItems();
    for (Lookup.Item<MIMEResolver> i : arr) {
        if (i.getDisplayName().equals(name)) {
            return i.getInstance();
        }
    }
    fail("Cannot find resolver name: " + name + " but found " + arr);
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:MIMEResolverProcessorTest.java

示例15: resultChanged

import org.openide.util.Lookup; //導入方法依賴的package包/類
/** Property change listener.
*/
public void resultChanged(LookupEvent ev) {
    Lookup.Result<Node> r = result;

    if (r == null) {
        return;
    }

    chgSFC = true;
    chgNSFC = true;

    Collection<? extends Lookup.Item<Node>> items = result.allItems();
    boolean updateActivatedNodes = true;

    if (items.size() == 1) {
        Lookup.Item<Node> item = items.iterator().next();

        if ("none".equals(item.getId()) && (item.getInstance() == null)) {
            // this is change of selected node to null,
            // do not update activatedNodes
            updateActivatedNodes = false;
        }
    }

    if (updateActivatedNodes) {
        Iterator<? extends Node> it = result.allInstances().iterator();
        ArrayList<Reference<Node>> list = new ArrayList<Reference<Node>>();

        while (it.hasNext()) {
            list.add(new WeakReference<Node>(it.next()));
        }

        activatedNodes = list.toArray(new Reference[list.size()]);
    }

    update();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:39,代碼來源:NodeAction.java


注:本文中的org.openide.util.Lookup.Item方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。