本文整理汇总了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;
}
示例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);
}
示例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());
}
示例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();
}
示例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();
}
示例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
}
示例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);
}
示例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;
}
示例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);
}
示例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));
}
示例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);
}
示例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());
}
示例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);
}
示例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]);
}