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


Java Lookup.lookupResult方法代碼示例

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


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

示例1: testIssue163315

import org.openide.util.Lookup; //導入方法依賴的package包/類
@RandomlyFails // NB-Core-Build #2892
public void testIssue163315() throws Exception {
    FileObject ioe = FileUtil.createData(fo, "java-io-IOException.instance");
    FileObject iae = FileUtil.createData(fo, "java-lang-IllegalArgumentException.instance");

    @SuppressWarnings("deprecation")
    Lookup lkp = new FolderLookup(DataFolder.findFolder(fo)).getLookup();
    res = lkp.lookupResult(Exception.class);
    assertEquals("Two items found", 2, res.allInstances().size());
    res.addLookupListener(this);

    FileObject ise = FileUtil.createData(fo, "java-lang-IllegalStateException.instance");
    assertEquals("Three now", 3, res.allInstances().size());

    FileObject npe = FileUtil.createData(fo, "java-lang-NullPointerException.instance");
    assertEquals("Four now", 4, res.allInstances().size());

    if (listenerVisited == 0) {
        fail("Listener shall be notified at least once, well only once");
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:FolderLookupBrokenListenersDontPreventQueriesTest.java

示例2: panelActivated

import org.openide.util.Lookup; //導入方法依賴的package包/類
@Override
public void panelActivated(Lookup context) {
    lkp = context.lookupResult(FileObject.class);
    lkp.addLookupListener(lookupL);
    Collection<? extends FileObject> l = lkp.allInstances();
    FileObject file = l.isEmpty()? null : l.iterator().next();
    navigateToFile(file);
    this.context = context;
    INSTANCE = this;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:SnippetNavigationPanel.java

示例3: SearchScopeNodeSelection

import org.openide.util.Lookup; //導入方法依賴的package包/類
public SearchScopeNodeSelection() {
    Lookup lookup = Utilities.actionsGlobalContext();
    lookupResult = lookup.lookupResult(Node.class);
    lookupListener = WeakListeners.create(LookupListener.class,
            this,
            lookupResult);
    lookupResult.addLookupListener(lookupListener);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:SearchScopeNodeSelection.java

示例4: testBeforeLookupIsCalledToInvalidateCaches

import org.openide.util.Lookup; //導入方法依賴的package包/類
public void testBeforeLookupIsCalledToInvalidateCaches() {
    class Before extends ProxyLookup {
        Object toAdd;
        
        Before() {
            super(instanceLookup);
        }

        @Override
        protected void beforeLookup(Template<?> template) {
            if (toAdd != null) {
                ic.add(toAdd);
                toAdd = null;
            }
        }
        
    }
    Before before = new Before();
    
    Lookup query = createLookup(before);
    
    before.toAdd = Integer.valueOf(10);
    
    Lookup.Result<Long> res = query.lookupResult(Long.class);
    assertTrue("empty", res.allItems().isEmpty());
    
    assertNull("beforeLookup called", before.toAdd);
    
    before.toAdd = Long.valueOf(3L);
    
    Collection<? extends Lookup.Item<Long>> c = res.allItems();
    assertEquals("There is One: ", 1, c.size());
    
    assertEquals(Long.valueOf(3L), c.iterator().next().getInstance());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:36,代碼來源:AbstractLookupBaseHid.java

示例5: HtmlPlugins

import org.openide.util.Lookup; //導入方法依賴的package包/類
private HtmlPlugins() {
    Lookup lookup = MimeLookup.getLookup("text/html");
    lookupResult = lookup.lookupResult(HtmlLexerPlugin.class);
    lookupResult.addLookupListener(new LookupListener() {

        @Override
        public void resultChanged(LookupEvent ev) {
            refresh();
        }
    });
    
    refresh();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:HtmlPlugins.java

示例6: FCSInfo

import org.openide.util.Lookup; //導入方法依賴的package包/類
/**
 * @param innerLanguage
 * @param mimePath note it may start with mimeTypeForOptions
 */
public FCSInfo(String mimePath, Language<T> innerLanguage) {
    this.innerLanguage = innerLanguage;
    this.mimePath = mimePath;
    this.listeners = new ListenerList<ChangeListener>();
    Lookup lookup = MimeLookup.getLookup(MimePath.parse(mimePath));
    result = lookup.lookupResult(FontColorSettings.class);
    // Do not listen on font color settings changes in tests
    // since "random" lookup events translate into highlight change events
    // that are monitored by tests and so the tests may then fail
    if (TEST_FALLBACK_COLORING == null) {
        result.addLookupListener(WeakListeners.create(LookupListener.class, this, result));
    }
    updateFCS();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:SyntaxHighlighting.java

示例7: WhitespaceHighlighting

import org.openide.util.Lookup; //導入方法依賴的package包/類
WhitespaceHighlighting(JTextComponent c) {
    // Upon doc change all layers become recreated by infrastructure (no need to listen for doc change)
    this.doc = c.getDocument();
    this.docText = DocumentUtilities.getText(doc);
    doc.addDocumentListener(this);
    String mimeType = (String) doc.getProperty("mimeType"); //NOI18N
    if (mimeType == null) {
        mimeType = "";
    }
    Lookup lookup = MimeLookup.getLookup(mimeType);
    result = lookup.lookupResult(FontColorSettings.class);
    result.addLookupListener(WeakListeners.create(LookupListener.class, this, result));
    resultChanged(null); // Update attrs
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:WhitespaceHighlighting.java

示例8: createActionsLookupResult

import org.openide.util.Lookup; //導入方法依賴的package包/類
public static Lookup.Result<Action> createActionsLookupResult(String mimeType) {
    if (!MimePath.validate(mimeType)) {
        throw new IllegalArgumentException("Ïnvalid mimeType=\"" + mimeType + "\"");
    }
    Lookup lookup = Lookups.forPath(getPath(mimeType, "Actions"));
    return lookup.lookupResult(Action.class);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:EditorActionUtilities.java

示例9: onShowing

import org.openide.util.Lookup; //導入方法依賴的package包/類
private synchronized Lookup.Result<Runnable> onShowing() {
    if (resShow == null) {
        Lookup lkp = lkpShowing != null ? lkpShowing : Lookups.forPath("Modules/UIReady"); // NOI18N
        resShow = lkp.lookupResult(Runnable.class);
        resShow.addLookupListener(this);
    }
    return resShow;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:OnShowingHandler.java

示例10: panelActivated

import org.openide.util.Lookup; //導入方法依賴的package包/類
public void panelActivated (Lookup context) {
    getComponent ();
    Result<DataObject> result = context.<DataObject>lookupResult (DataObject.class);
    DataObject dataObject = result.allInstances ().iterator ().next ();
    
    if (lookupListener != null)
        lookupListener.remove ();
    lookupListener = new MyLookupListener (result);
    
    setDataObject (dataObject);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:LanguagesNavigator.java

示例11: testConvenienceMethods

import org.openide.util.Lookup; //導入方法依賴的package包/類
public void testConvenienceMethods() throws Exception {
    // Just check signatures and basic behavior of #73848.
    Lookup l = Lookups.fixed(new Object[] {1, "hello", 2, "goodbye"});
    Collection<? extends Integer> ints = l.lookupAll(Integer.class);
    assertEquals(Arrays.asList(new Integer[] {1, 2}), new ArrayList<Integer>(ints));
    Lookup.Result<Integer> r = l.lookupResult(Integer.class);
    ints = r.allInstances();
    assertEquals(Arrays.asList(new Integer[] {1, 2}), new ArrayList<Integer>(ints));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:SimpleLookupTest.java

示例12: panelActivated

import org.openide.util.Lookup; //導入方法依賴的package包/類
@Override
public void panelActivated(Lookup context) {
    getNavigatorUI().showWaitNode();
    selection = context.lookupResult(DataObject.class);
    selection.addLookupListener(selectionListener);
    selectionListener.resultChanged(null);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:8,代碼來源:GoalsNavigationPanel.java

示例13: testBuggyIsWrongInFavoritesIssue119727

import org.openide.util.Lookup; //導入方法依賴的package包/類
public void testBuggyIsWrongInFavoritesIssue119727() {
    class ProjectFilterNode extends FilterNode {
        public ProjectFilterNode (Node node, org.openide.nodes.Children children) {
            super (node, children);
        }
    }
    
    CookieSet set = CookieSet.createGeneric(null);
    
    Node pfn = new AbstractNode(Children.LEAF, set.getLookup());
    FilterNode n = new ProjectFilterNode(pfn, Children.LEAF);

    
    Lookup contextLookup = n.getLookup();
    Object o;
    
    o = contextLookup.lookup(ProjectFilterNode.class);
    assertEquals("found self", n, o);
    
    o = contextLookup.lookup(n.getClass());
    assertEquals("found sefl2", n, o);
    
    o = contextLookup.lookup(Node.class);
    assertEquals("found node", n, o);
    
    Result<Node> res = contextLookup.lookupResult(Node.class);
    Collection<? extends Node> all = res.allInstances();
    assertEquals("One found: " + all, 1, all.size());
    assertEquals("It is the filter node", n, all.iterator().next());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:31,代碼來源:FilterNodeTest.java

示例14: registerLookupListenerAndAddSomething

import org.openide.util.Lookup; //導入方法依賴的package包/類
private void registerLookupListenerAndAddSomething(boolean useProxy, boolean callAllInstances, boolean inheritanceTree) {
    called = false;
    InstanceContent aInstanceContent = new InstanceContent();
    Storage<?> s = inheritanceTree ? new InheritanceTree() : new ArrayStorage();
    Lookup aLookup = new AbstractLookup(aInstanceContent, s);
    if (useProxy) {
        aLookup = new ProxyLookup(aLookup);
    }
    Lookup.Result<ObjectInLookup> result = aLookup.lookupResult(ObjectInLookup.class);
    if (callAllInstances) {
        result.allInstances(); // TO GET SUCCESS
    }
    result.addLookupListener(new LookupListener() {

        public void resultChanged(LookupEvent ev) {
            Lookup.Result aResult = (Lookup.Result) ev.getSource();
            Collection c = aResult.allInstances();
            if (!c.isEmpty()) {
                called = true;
            }
        }
    });

    aInstanceContent.set(Collections.singleton(
            new ObjectInLookup("Set Object in Lookup)")), null);
    Assert.assertTrue("Listener was notified", called);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:ProxyLookup173975Test.java

示例15: testLookup

import org.openide.util.Lookup; //導入方法依賴的package包/類
public void testLookup() throws Exception {
    MockModuleInstaller installer = new MockModuleInstaller();
    MockEvents ev = new MockEvents();
    ModuleManager mgr = new ModuleManager(installer, ev);
    mgr.mutexPrivileged().enterWriteAccess();
    Module m1, m2;
    try {
        m2 = mgr.create(new File(jars, "depends-on-simple-module.jar"), null, false, false, false);
        m1 = mgr.create(new File(jars, "simple-module.jar"), null, false, false, false);
    } finally {
        mgr.mutexPrivileged().exitWriteAccess();
    }
    Lookup l = mgr.getModuleLookup();
    assertNull(l.lookup(String.class));
    Object random = l.lookup(ModuleInfo.class);
    assertTrue(random == m1 || random == m2);
    random = l.lookup(Module.class);
    assertTrue(random == m1 || random == m2);
    Lookup.Result<ModuleInfo> resultAll = l.lookupResult(ModuleInfo.class);
    assertEquals("finding all instances works", new HashSet<Module>(Arrays.asList(m1, m2)), new HashSet<ModuleInfo>(resultAll.allInstances()));
    Lookup.Result<Module> resultInstance2 = l.lookup(new Lookup.Template<Module>(null, null, m2));
    assertEquals("finding one specific instance works", Collections.singleton(m2), new HashSet<Module>(resultInstance2.allInstances()));
    Collection<? extends Lookup.Item<Module>> items = resultInstance2.allItems();
    assertTrue(items.size() == 1);
    Lookup.Item<Module> item = items.iterator().next();
    assertEquals(m2, item.getInstance());
    Util.err.log(Level.INFO, "Item ID: {0}", item.getId());
    assertTrue("Item class is OK: " + item.getType(), item.getType().isAssignableFrom(Module.class));
    assertEquals("finding by ID works", Collections.singleton(m2),
            new HashSet<Module>(l.lookup(new Lookup.Template<Module>(null, item.getId(), null)).allInstances()));
    final boolean[] waiter = new boolean[] {false};
    resultAll.addLookupListener(new LookupListener() {
        public @Override void resultChanged(LookupEvent lev) {
            Util.err.log(Level.INFO, "Got event: {0}", lev);
            synchronized (waiter) {
                waiter[0] = true;
                waiter.notify();
            }
        }
    });
    Module m3;
    mgr.mutexPrivileged().enterWriteAccess();
    try {
        m3 = mgr.create(new File(jars, "cyclic-1.jar"), null, false, false, false);
        mgr.delete(m2);
    } finally {
        mgr.mutexPrivileged().exitWriteAccess();
    }
    assertEquals("results changed", new HashSet<ModuleInfo>(Arrays.asList(m1, m3)), new HashSet<ModuleInfo>(resultAll.allInstances()));
    synchronized (waiter) {
        if (! waiter[0]) {
            waiter.wait(5000);
        }
    }
    assertTrue("got lookup changes within 5 seconds", waiter[0]);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:57,代碼來源:ModuleManagerTest.java


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