Java Code Examples for org.openide.util.Lookup.Result#removeLookupListener()
The following examples show how to use
org.openide.util.Lookup.Result#removeLookupListener() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IssuesTest.java From netbeans with Apache License 2.0 | 5 votes |
/** * Issues of changes in layer */ public void testForChangeInLayer() throws IOException{ // issue #63338 // http://www.netbeans.org/issues/show_bug.cgi?id=63338 // Subj: deadlock during showing annotations // fix: deadlock occured in after inproper firing of lookup changed event. // event was fired even in cases, the lookup listener should be quiet. MimeLookup lookup = MimeLookup.getMimeLookup("text/jsp"); //NOI18N Result result = lookup.lookup(new Template(TestLookupObject.class)); result.allInstances().size(); // remove this line if issue #60010 is fixed LookupListener listener = new LookupListener(){ public void resultChanged(LookupEvent ev){ resultChangedCount[0]++; } }; result.addLookupListener(listener); //simulate module installation, new file will be added createFile("Editors/text/jsp/testLookup/org-openide-actions-PasteAction.instance"); //NOI18N checkResultChange(0); TestUtilities.deleteFile(getWorkDir(), "Editors/text/jsp/testLookup/org-netbeans-modules-editor-mimelookup-impl-TestLookupObject.instance"); checkResultChange(1); result.removeLookupListener(listener); resultChangedCount[0] = 0; // end of issue #63338 ------------------------------------------------ }
Example 2
Source File: SavableTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testEventDeliveredAsynchronously() throws Exception { class L implements LookupListener { int change; Object id = new Object(); @Override public synchronized void resultChanged(LookupEvent ev) { change++; notifyAll(); } public synchronized void createSavable() { assertEquals("No changes yet", 0, change); Savable s = new DoSave(id, null, null); assertEquals("The first", s, Savable.REGISTRY.lookup(Savable.class)); assertEquals("Still no changes", 0, change); } public synchronized void waitForChange() throws InterruptedException { while (change == 0) { wait(); } assertEquals("One change delivered", 1, change); } } L listener = new L(); Result<Savable> res = Savable.REGISTRY.lookupResult(Savable.class); try { res.addLookupListener(listener); listener.createSavable(); listener.waitForChange(); } finally { res.removeLookupListener(listener); } }