org.openide.util.ContextGlobalProvider Java Examples

The following examples show how to use org.openide.util.ContextGlobalProvider. 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: ContextActionTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Before
@Override
public void setUp() {
    //This will cause ContextAction instances to invoke notifyAll()
    //when their enablement changes
    ContextAction.unitTest = true;
    MockServices.setServices(Provider.class);
    ContextGlobalProvider x = Lookup.getDefault().lookup(ContextGlobalProvider.class);
    assertNotNull(x);
    assertTrue(x instanceof Provider);
    Provider p = (Provider) x;
    content = p.content;
    lkp = p.lkp;
    //some sanity checks
    setContent("hello");
    assertEquals("hello", lkp.lookupAll(String.class).iterator().next());
    assertEquals("hello", Utilities.actionsGlobalContext().lookupAll(String.class).iterator().next());
    clearContent();
    assertEquals(null, lkp.lookup(String.class));
    assertEquals(null, Utilities.actionsGlobalContext().lookup(String.class));
    assertEquals(0, Utilities.actionsGlobalContext().lookupAll(Object.class).size());
}
 
Example #2
Source File: ActionsInfraHid.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void install() {
    MockLookup.setInstances(new ContextGlobalProvider() {
        public Lookup createGlobalContext() {
            return amLookup;
        }
    });
    amResult = Utilities.actionsGlobalContext().lookupResult(ActionMap.class);
    Assert.assertEquals(Collections.singleton(EMPTY_MAP), new HashSet<ActionMap>(amResult.allInstances()));
}
 
Example #3
Source File: NodeActionsInfraHid.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void install() {
    MockLookup.setInstances(new ContextGlobalProvider() {
        public Lookup createGlobalContext() {
            return nodeLookup;
        }
    });
    nodeResult = Utilities.actionsGlobalContext().lookupResult(Node.class);
    Assert.assertEquals(Collections.emptySet(), new HashSet<Node>(nodeResult.allInstances()));
}