Java 类org.openide.util.lookup.AbstractLookup 实例源码

项目:incubator-netbeans    文件:CompilerOptionsQueryMergerTest.java   
public void testLkpChanges() {
    final CompilerOptionsQueryImpl impl1 = new CompilerOptionsQueryImpl();
    final CompilerOptionsQueryImpl impl2 = new CompilerOptionsQueryImpl();
    impl1.addRoot(root1).addArgs("a1", "a2");   //NOI18N
    impl2.addRoot(root1).addArgs("b1", "b2");   //NOI18N

    final InstanceContent ic = new InstanceContent();
    final Lookup baseLkp = new AbstractLookup(ic);
    final CompilerOptionsQueryImplementation merged =
            LookupMergerSupport.createCompilerOptionsQueryMerger()
            .merge(baseLkp);
    assertNull(merged.getOptions(root1));
    ic.add(impl1);
    final CompilerOptionsQueryImplementation.Result res = merged.getOptions(root1);
    assertEquals(
            Arrays.asList("a1","a2"), //NOI18N
            res.getArguments());
    ic.add(impl2);
    assertEquals(
            Arrays.asList("a1","a2","b1","b2"), //NOI18N
            res.getArguments());
}
项目:MaxSim    文件:FilterNode.java   
private FilterNode(Filter filter, InstanceContent content) {
    super(Children.LEAF, new AbstractLookup(content));
    content.add(filter);

    content.add(filter.getEditor());
    this.filter = filter;
    filter.getChangedEvent().addListener(new ChangedListener<Filter>() {

        @Override
        public void changed(Filter source) {
            update();
        }
    });

    update();

    Lookup.Template<FilterChain> tpl = new Lookup.Template<>(FilterChain.class);
    result = Utilities.actionsGlobalContext().lookup(tpl);
    result.addLookupListener(this);

    FilterTopComponent.findInstance().getFilterSettingsChangedEvent().addListener(this);
    resultChanged(null);

    setShortDescription("Double-click to open filter");
}
项目:incubator-netbeans    文件:MultiViewProcessorTest.java   
public void testLookupInitializedForCloneable() {
    InstanceContent ic = new InstanceContent();
    Lookup lookup = new AbstractLookup(ic);
    ic.add(10);

    CloneableTopComponent cmv = MultiViews.createCloneableMultiView("text/context", new LP(lookup));
    assertEquals("10 now", Integer.valueOf(10), cmv.getLookup().lookup(Integer.class));

    assertNotNull("MultiViewComponent created", cmv);
    TopComponent mvc = cmv.cloneTopComponent();

    assertNotNull("MultiViewComponent cloned", mvc);
    MultiViewHandler handler = MultiViews.findMultiViewHandler(mvc);
    assertNotNull("Handler found", handler);

    assertEquals("10 now", Integer.valueOf(10), mvc.getLookup().lookup(Integer.class));
    ic.remove(10);
    ic.add(1);
    assertEquals("1 now", Integer.valueOf(1), mvc.getLookup().lookup(Integer.class));
}
项目:incubator-netbeans    文件:ContextActionInjectTest.java   
public void testContextAction() throws Exception {
    Context.cnt = 0;

    FileObject fo = FileUtil.getConfigFile(
        "actions/support/test/testInjectContext.instance"
    );
    assertNotNull("File found", fo);
    Object obj = fo.getAttribute("instanceCreate");
    assertNotNull("Attribute present", obj);
    assertTrue("It is context aware action", obj instanceof ContextAwareAction);
    ContextAwareAction a = (ContextAwareAction)obj;

    InstanceContent ic = new InstanceContent();
    AbstractLookup lkp = new AbstractLookup(ic);
    Action clone = a.createContextAwareInstance(lkp);
    ic.add(10);

    assertEquals("Number lover!", clone.getValue(Action.NAME));
    clone.actionPerformed(new ActionEvent(this, 300, ""));
    assertEquals("Global Action not called", 10, Context.cnt);

    ic.remove(10);
    clone.actionPerformed(new ActionEvent(this, 200, ""));
    assertEquals("Global Action stays same", 10, Context.cnt);
}
项目:incubator-netbeans    文件:GlobalManagerTest.java   
public void testActionsUpdatedWhenActionMapChanges() throws Exception {
    ContextAwareAction a = Actions.callback("ahoj", null, true, "Ahoj!", "no/icon.png", true);
    final InstanceContent ic = new InstanceContent();
    Lookup lkp = new AbstractLookup(ic);

    ActionMap a1 = new ActionMap();
    ActionMap a2 = new ActionMap();
    a2.put("ahoj", new Enabled());

    ic.add(a1);
    Action clone = a.createContextAwareInstance(lkp);
    class L implements PropertyChangeListener {
        int cnt;
        public void propertyChange(PropertyChangeEvent evt) {
            cnt++;
        }
    }
    L listener = new L();
    clone.addPropertyChangeListener(listener);
    assertFalse("Not enabled", isEnabled(clone));

    ic.set(Collections.singleton(a2), null);

    assertTrue("Enabled now", isEnabled(clone));
    assertEquals("one change", 1, listener.cnt);
}
项目:incubator-netbeans    文件:ActionInvocationTest.java   
public void testRenameAction() throws InterruptedException, InvocationTargetException, IOException {
    DataObject testdo = DataObject.find(f);
    final Node node = testdo.getNodeDelegate();

    InstanceContent ic = new InstanceContent();
    Lookup lookup = new AbstractLookup(ic);
    ic.add(node);
    final Action rename = RefactoringActionsFactory.renameAction().createContextAwareInstance(lookup);
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            if (rename.isEnabled()) {
                rename.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
                if (!((RenameRefactoring) DD.rui.getRefactoring()).getRefactoringSource().lookup(FileObject.class).equals(f))
                    fail("Rename dialog was opened with wrong data");
            } else {
                fail("Action is not enabled.");
            }
        }
    });
}
项目:incubator-netbeans    文件:ActionInvocationTest.java   
public void testMoveAction() throws InterruptedException, InvocationTargetException, DataObjectNotFoundException, IOException {
    DataObject testdo = DataObject.find(f);
    final Node node = testdo.getNodeDelegate();

    InstanceContent ic = new InstanceContent();
    Lookup lookup = new AbstractLookup(ic);
    ic.add(node);
    final Action move = RefactoringActionsFactory.moveAction().createContextAwareInstance(lookup);
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            if (move.isEnabled()) {
                move.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
                if (!((MoveRefactoring) DD.rui.getRefactoring()).getRefactoringSource().lookup(FileObject.class).equals(f))
                    fail("MoveClass was opened with wrong data");
            } else {
                fail("Action is not enabled.");
            }
        }
    });
}
项目:incubator-netbeans    文件:RequestProcessorLookupGetDefaultTest.java   
public void testChangeOfDefaultLookupAppliedToRPTask() throws Exception {
    Lookup prev = Lookup.getDefault();
    final Lookup my = new AbstractLookup(new InstanceContent());
    final Thread myThread = Thread.currentThread();
    final RequestProcessor.Task[] task = { null };
    final boolean[] ok = { false };

    Lookups.executeWith(my, new Runnable() {
        @Override
        public void run() {
            assertSame("Default lookup has been changed", my, Lookup.getDefault());

            if (task[0] == null) {
                assertSame("We are being executed in the same thread", myThread, Thread.currentThread());
                // once again in the RP
                task[0] = RequestProcessor.getDefault().post(this, 500);
            } else {
                ok[0] = true;
            }
        }
    });
    assertNotNull("In my lookup code executed OK", task[0]);
    assertEquals("Current lookup back to normal", prev, Lookup.getDefault());
    task[0].waitFinished();
    assertTrue("Even RP task had the right lookup", ok[0]);
}
项目:incubator-netbeans    文件:ExternalChangeOfModifiedContentTest.java   
@Override
protected void setUp() throws Exception {
    MockServices.setServices(DD.class);


    clearWorkDir();
    LocalFileSystem fs = new LocalFileSystem();
    fs.setRootDirectory(getWorkDir());

    FileObject fo = fs.getRoot().createData("Ahoj", "txt");

    ic = new InstanceContent();
    support = new CES(this, new AbstractLookup(ic));
    edit = support;
    assertNotNull("we have editor", edit);

    DD.type = -1;
    DD.toReturn = new Stack<Object>();
}
项目:incubator-netbeans    文件:ExternalDeleteOfModifiedContentTest.java   
@Override
protected void setUp () throws Exception {
    MockServices.setServices(DD.class);


    clearWorkDir();
    LocalFileSystem fs = new LocalFileSystem();
    fs.setRootDirectory(getWorkDir());

    FileObject fo = fs.getRoot().createData("Ahoj", "txt");

    ic = new InstanceContent();
    support = new CES(this, new AbstractLookup(ic));
    edit = support;
    assertNotNull("we have editor", edit);

    DD.type = -1;
    DD.toReturn = new Stack<Object>();
}
项目:Pogamut3    文件:MVMapElement.java   
MVMapElement(TLDataObject dataObject) {
    // Hack
    if (Beans.isDesignTime()) {
        Beans.setDesignTime(false);
    }
    this.dataObject = dataObject;

    glPanel = new TLMapGLPanel(dataObject.getDatabase().getMap(), dataObject.getDatabase());

    slider = new TLSlider(dataObject.getDatabase());

    elementPanel = new JPanel(new BorderLayout());
    elementPanel.add(glPanel, BorderLayout.CENTER);
    elementPanel.add(slider, BorderLayout.PAGE_END);

    ActionMap map = new ActionMap();
    map.put("save", SystemAction.get(SaveAction.class));
    elementPanel.setActionMap(map);

    lookupContent = new InstanceContent();
    lookup = new ProxyLookup(dataObject.getLookup(), new AbstractLookup(lookupContent));
}
项目:openjdk-jdk10    文件:FilterNode.java   
private FilterNode(Filter filter, InstanceContent content) {
    super(Children.LEAF, new AbstractLookup(content));
    content.add(filter);

    content.add(filter.getEditor());
    this.filter = filter;
    filter.getChangedEvent().addListener(new ChangedListener<Filter>() {

        @Override
        public void changed(Filter source) {
            update();
        }
    });

    update();

    Lookup.Template<FilterChain> tpl = new Lookup.Template<>(FilterChain.class);
    result = Utilities.actionsGlobalContext().lookup(tpl);
    result.addLookupListener(this);

    FilterTopComponent.findInstance().getFilterSettingsChangedEvent().addListener(this);
    resultChanged(null);

    setShortDescription("Double-click to open filter");
}
项目:incubator-netbeans    文件:RenameHandlerImpl.java   
@Override
public void handleRename(Node node, String newName) {
    InstanceContent ic = new InstanceContent();
    ic.add(node);
    ExplorerContext d = new ExplorerContext();
    d.setNewName(newName);
    ic.add(d);
    Lookup l = new AbstractLookup(ic);
    DataObject dob = node.getCookie(DataObject.class);
    Action a = RefactoringActionsFactory.renameAction().createContextAwareInstance(l);
    if (Boolean.TRUE.equals(a.getValue("applicable"))) {//NOI18N
        a.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
    } else {
        try {
            dob.rename(newName);
        } catch (IOException ioe) {
            ErrorManager.getDefault().notify(ioe);
        }
    }
}
项目:MaxSim    文件:GraphNode.java   
private GraphNode(InputGraph graph, InstanceContent content) {
    super(Children.LEAF, new AbstractLookup(content));
    this.graph = graph;
    this.setDisplayName(graph.getName());
    content.add(graph);

    final GraphViewer viewer = Lookup.getDefault().lookup(GraphViewer.class);

    if (viewer != null) {
        // Action for opening the graph
        content.add(new GraphOpenCookie(viewer, graph));
    }

    // Action for removing a graph
    content.add(new GraphRemoveCookie(graph));

    // Action for diffing to the current graph
    content.add(new DiffGraphCookie(graph));

    // Action for cloning to the current graph
    content.add(new GraphCloneCookie(viewer, graph));
}
项目:incubator-netbeans    文件:Utils.java   
public static String getWebPageMimeType(SyntaxAnalyzerResult result) {
    InstanceContent ic = new InstanceContent();
    ic.add(result);
    WebPageMetadata wpmeta = WebPageMetadata.getMetadata(new AbstractLookup(ic));

    if (wpmeta != null) {
        //get an artificial mimetype for the web page, this doesn't have to be equal
        //to the fileObjects mimetype.
        String mimeType = (String) wpmeta.value(WebPageMetadata.MIMETYPE);
        if (mimeType != null) {
            return mimeType;
        }
    }

    FileObject fo = result.getSource().getSourceFileObject();
    if(fo != null) {
        return fo.getMIMEType();
    } else {
        //no fileobject?
        return result.getSource().getSnapshot().getMimeType();
    }

}
项目:MaxSim    文件:FilterNode.java   
private FilterNode(Filter filter, InstanceContent content) {
    super(Children.LEAF, new AbstractLookup(content));
    content.add(filter);

    content.add(filter.getEditor());
    this.filter = filter;
    filter.getChangedEvent().addListener(new ChangedListener<Filter>() {

        @Override
        public void changed(Filter source) {
            update();
        }
    });

    update();

    Lookup.Template<FilterChain> tpl = new Lookup.Template<>(FilterChain.class);
    result = Utilities.actionsGlobalContext().lookup(tpl);
    result.addLookupListener(this);

    FilterTopComponent.findInstance().getFilterSettingsChangedEvent().addListener(this);
    resultChanged(null);

    setShortDescription("Double-click to open filter");
}
项目:incubator-netbeans    文件:NbLookupBenchmark.java   
/** Fills the lookup with instances */
protected void setUp () {
    Integer integer = (Integer)getArgument ();
    int cnt = integer.intValue ();

    boolean reverse = cnt < 0;
    if (reverse) cnt = -cnt;

    InstanceContent iContent = new InstanceContent();

    lookup = new AbstractLookup(iContent);

    while (cnt-- > 0) {
        for (int i = 0; i < INSTANCES.length; i++) {
            if (reverse) {
                iContent.add (INSTANCES[INSTANCES.length - i - 1]);
            } else {
                iContent.add (INSTANCES[i]);
            }
        }
    }
}
项目:Java-9-Programming-Blueprints    文件:PhotoNode.java   
private PhotoNode(String photo, InstanceContent ic) {
    super(Children.LEAF, new AbstractLookup(ic));
    final String name = new File(photo).getName();
    setName(name);
    setDisplayName(name);
    setShortDescription(photo);

    ic.add((OpenCookie) () -> {
        TopComponent tc = findTopComponent(photo);
        if (tc == null) {
            tc = new PhotoViewerTopComponent(photo);
            tc.open();
        }
        tc.requestActive();
    });
}
项目:incubator-netbeans    文件:CallbackActionTest.java   
public void testCopyLikeProblem() throws Exception {
    FileObject fo = folder.getFileObject("testCopyLike.instance");

    Object obj = fo.getAttribute("instanceCreate");
    if (!(obj instanceof Action)) {
        fail("Shall create an action: " + obj);
    }

    InstanceContent ic = new InstanceContent();
    AbstractLookup l = new AbstractLookup(ic);
    ActionMap map = new ActionMap();
    map.put("copy-to-clipboard", new MyAction());
    ic.add(map);

    CntListener list = new CntListener();
    Action clone = ((ContextAwareAction)obj).createContextAwareInstance(l);
    clone.addPropertyChangeListener(list);
    assertTrue("Enabled", clone.isEnabled());

    ic.remove(map);
    assertFalse("Disabled", clone.isEnabled());
    list.assertCnt("one change", 1);
}
项目:incubator-netbeans    文件:SaveAsActionTest.java   
public void testActionStatusUpdatedOnLookupChange() throws Exception {
    final InstanceContent content = new InstanceContent();
    Lookup lkp = new AbstractLookup( content );
    final SaveAsCapable saveAsImpl = new SaveAsCapable() {
        public void saveAs(FileObject folder, String name) throws IOException {
            throw new UnsupportedOperationException("Not supported yet.");
        }
    };

    TopComponent tc = new TopComponent( lkp );
    editorMode.dockInto( tc );
    tc.open();
    tc.requestActive();
    assertTrue(Arrays.asList(WindowManager.getDefault().getOpenedTopComponents(editorMode)).contains(tc));

    ContextAwareAction action = SaveAsAction.create();
    assertFalse( "action is disabled for editor windows without SaveAsCapable in their Lookup", action.isEnabled() );

    Action a = action.createContextAwareInstance( tc.getLookup() );

    content.add( saveAsImpl );
    assertTrue( "action is enabled for editor windows with SaveAsCapable in their Lookup", a.isEnabled() );
    content.remove( saveAsImpl );
    assertFalse( "action is disabled for editor windows without SaveAsCapable in their Lookup", a.isEnabled() );
}
项目:Java-9-Programming-Blueprints    文件:PhotoManagerImpl.java   
public PhotoManagerImpl() throws ClassNotFoundException {
    Preferences prefs = NbPreferences.forModule(PhotoManager.class);
    setupDatabase();
    setSourceDirs(prefs.get("sourceDirs", ""));
    scanSourceDirs();

    instanceContent = new InstanceContent();
    lookup = new AbstractLookup(instanceContent);

    prefs.addPreferenceChangeListener(evt -> {
        if (evt.getKey().equals("sourceDirs")) {
            setSourceDirs(evt.getNewValue());
            scanSourceDirs();
        }
    });
}
项目:incubator-netbeans    文件:ContextActionInjectTest.java   
public void testMultiContextAction() throws Exception {
    MultiContext.cnt = 0;

    FileObject fo = FileUtil.getConfigFile(
        "actions/support/test/testInjectContextMulti.instance"
    );
    assertNotNull("File found", fo);
    Object obj = fo.getAttribute("instanceCreate");
    assertNotNull("Attribute present", obj);
    assertTrue("It is context aware action", obj instanceof ContextAwareAction);
    ContextAwareAction a = (ContextAwareAction)obj;

    InstanceContent ic = new InstanceContent();
    AbstractLookup lkp = new AbstractLookup(ic);
    Action clone = a.createContextAwareInstance(lkp);
    ic.add(10);
    ic.add(3L);

    assertEquals("Number lover!", clone.getValue(Action.NAME));
    clone.actionPerformed(new ActionEvent(this, 300, ""));
    assertEquals("Global Action not called", 13, MultiContext.cnt);

    ic.remove(10);
    clone.actionPerformed(new ActionEvent(this, 200, ""));
    assertEquals("Adds 3", 16, MultiContext.cnt);

    ic.remove(3L);
    assertFalse("It is disabled", clone.isEnabled());
    clone.actionPerformed(new ActionEvent(this, 200, ""));
    assertEquals("No change", 16, MultiContext.cnt);
}
项目:incubator-netbeans    文件:WsdlPortNode.java   
private WsdlPortNode(WsdlSaasPort port, InstanceContent content) {
    super(new WsdlPortNodeChildren(port), new AbstractLookup(content));
    this.port = port;
    content.add(port);
    transferable = ExTransferable.create(
            new SaasTransferable(port,SaasTransferable.WSDL_PORT_FLAVORS));
}
项目:incubator-netbeans    文件:WadlMethodNode.java   
public WadlMethodNode(WadlSaasMethod method, InstanceContent content) {
    super(Children.LEAF, new AbstractLookup(content));
    this.method = method;
    content.add(method);
    transferable = ExTransferable.create(
        new SaasTransferable<WadlSaasMethod>(method, SaasTransferable.WADL_METHOD_FLAVORS));
}
项目:incubator-netbeans    文件:AlwaysEnabledActionTest.java   
public void testContextAwareActionsShareDelegate() throws Exception {
    myListenerCounter = 0;
    myIconResourceCounter = 0;
    Action a = readAction("testDelegate.instance");

    assertContextAware(a);
    assertNull("No real action created yet", MyAction.last);

    Action cca1 = ((ContextAwareAction)a).createContextAwareInstance(new AbstractLookup(new InstanceContent()));
    Action cca2 = ((ContextAwareAction)a).createContextAwareInstance(new AbstractLookup(new InstanceContent()));

    cca1.actionPerformed(new ActionEvent(this, 0, "kuk"));
    assertEquals("Action not invoked as it is disabled", 0, myListenerCalled);
    assertNotNull("real action created", MyAction.last);
    Action lastCca1 = MyAction.last;

    lastCca1.setEnabled(true);
    cca1.actionPerformed(new ActionEvent(this, 0, "kuk"));
    assertEquals("Action invoked as no longer disabled", 1, myListenerCalled);

    cca2.actionPerformed(new ActionEvent(this, 0, "kuk"));

    Action lastCca2 = MyAction.last;
    assertEquals("MyAction created just once", lastCca1, lastCca2);

    assertEquals("Action invoked as it remains enabled", 2, myListenerCalled);
}
项目:Pogamut3    文件:PoshDataObject.java   
public PoshDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
    super(pf, loader);

    ic = new InstanceContent();
    lookup = new AbstractLookup(ic);
    ic.add(new PoshEditorSupport(this));
    ic.add(this);
}
项目:incubator-netbeans    文件:WsdlMethodNode.java   
protected WsdlMethodNode(WsdlSaasMethod method, InstanceContent content) {
    super(Children.LEAF, new AbstractLookup(content));
    this.method = method;
    content.add(method);
    transferable = ExTransferable.create(
            new SaasTransferable<WsdlSaasMethod>(method, SaasTransferable.WSDL_METHOD_FLAVORS));
}
项目:incubator-netbeans    文件:MultiViewProcessorTest.java   
public void testCloneableMultiViewsSerialize() throws Exception {
    InstanceContent ic = new InstanceContent();
    Lookup lookup = new AbstractLookup(ic);

    CloneableTopComponent cmv = MultiViews.createCloneableMultiView("text/context", new LP(lookup));
    assertPersistence("Always", TopComponent.PERSISTENCE_ALWAYS, cmv);
    assertNotNull("MultiViewComponent created", cmv);
    NbMarshalledObject mar = new NbMarshalledObject(cmv);
    TopComponent mvc = (TopComponent) mar.get();
    doCheck(mvc, ic);
}
项目:incubator-netbeans    文件:MIMESupportTest.java   
private Lookup getInstanceLookup(final Object... instances) {
    InstanceContent instanceContent = new InstanceContent();
    for(Object i : instances) {
        instanceContent.add(i);
    }
    Lookup instanceLookup = new AbstractLookup(instanceContent);
    return instanceLookup;
}
项目:incubator-netbeans    文件:RecognizeInstanceFiles.java   
private OverFiles(String path, List<FOItem> items, AbstractLookup lkp, AbstractLookup.Content cnt) {
    super(computeDelegates(path, items, lkp));
    this.path = path;
    this.lkp = lkp;
    this.content = cnt;
    this.content.setPairs(order(items));
    FileSystem fs = null;
    try {
        fs = FileUtil.getSystemConfigRoot().getFileSystem();
    } catch (FileStateInvalidException ex) {
        Exceptions.printStackTrace(ex);
    }
    this.weakL = FileUtil.weakFileChangeListener(this, fs);
    fs.addFileChangeListener(weakL);
}
项目:incubator-netbeans    文件:SyntaxAnalyzerResult.java   
private static Lookup createLookupFor(final Iterator<Element> elementsIterator) {
    InstanceContent ic = new InstanceContent();
    ic.add(new ElementsIteratorHandle() {
        @Override
        public Iterator<Element> getIterator() {
            return elementsIterator;
        }
    });
    return new AbstractLookup(ic);
}
项目:incubator-netbeans    文件:XmlSyntaxTreeBuilderTest.java   
private Node parse(String code, Object... lookupContent) {
    final HtmlSource source = new HtmlSource(code);
    ElementsIteratorHandle handle = new ElementsIteratorHandle() {
        @Override
        public Iterator<Element> getIterator() {
            return new ElementsIterator(source);
        }
    };
    InstanceContent ic = new InstanceContent();
    ic.add(handle);
    for(Object o : lookupContent) {
        ic.add(o);
    }
    return XmlSyntaxTreeBuilder.makeUncheckedTree(source, null, new AbstractLookup(ic));
}
项目:Pogamut3    文件:PoshDataObject.java   
public PoshDataObject(FileObject pf, MultiFileLoader loader) throws DataObjectExistsException, IOException {
    super(pf, loader);

    ic = new InstanceContent();
    lookup = new AbstractLookup(ic);
    ic.add(support = new PoshEditorSupport(this));
    ic.add(this);

}
项目:incubator-netbeans    文件:ResourceBundleBrandingPanel.java   
public BundleNode(Node orig, String bundlepath, String codenamebase, InstanceContent content) {
    super(orig, new BundleChildren (orig, bundlepath, codenamebase), new AbstractLookup(content));
    content.add(this);

    disableDelegation(DELEGATE_GET_DISPLAY_NAME | DELEGATE_SET_DISPLAY_NAME
            | DELEGATE_GET_SHORT_DESCRIPTION | DELEGATE_SET_SHORT_DESCRIPTION
            | DELEGATE_GET_ACTIONS);

    setDisplayName(bundlepath);
    setShortDescription(codenamebase);

    this.bundlepath = bundlepath;
    this.codenamebase = codenamebase;
    this.bundleChildren = (BundleChildren) getChildren();
}
项目:incubator-netbeans    文件:InternationalizationResourceBundleBrandingPanel.java   
public BundleNode(Node orig, String bundlepath, String codenamebase, InstanceContent content) {
    super(orig, new BundleChildren (orig, bundlepath, codenamebase), new AbstractLookup(content));
    content.add(this);

    disableDelegation(DELEGATE_GET_DISPLAY_NAME | DELEGATE_SET_DISPLAY_NAME
            | DELEGATE_GET_SHORT_DESCRIPTION | DELEGATE_SET_SHORT_DESCRIPTION
            | DELEGATE_GET_ACTIONS);

    setDisplayName(bundlepath);
    setShortDescription(codenamebase);

    this.bundlepath = bundlepath;
    this.codenamebase = codenamebase;
    this.bundleChildren = (BundleChildren) getChildren();
}
项目:incubator-netbeans    文件:CssStylesPanel.java   
public void setContext(FileObject file) {
    InstanceContent ic = new InstanceContent();
    if (file != null) {
        ic.add(file);
    }
    ic.add(getRuleEditorController());
    providersLookup.updateLookup(new AbstractLookup(ic));

    updateToolbar(file);
}
项目:Pogamut3    文件:PureMapTopComponent.java   
public PureMapTopComponent(ServerDefinition<IUnrealServer> serverDef) {
    this.serverDef = serverDef;

    setUpMapPanel();

    // Associate our lookup with this TC
    lookupContent = new InstanceContent();
    associateLookup(new AbstractLookup(lookupContent));

    // set proper name
    handleServerName();

    serverDef.getServerFlag().addListener(this);
}
项目:incubator-netbeans    文件:ContextManagerTest.java   
public void testAllResultListenersRemoved () throws Exception {
    InstanceContent ic = new InstanceContent();
    lkp = new AbstractLookup(ic);
    Lookup.Result<Integer> lookupResult = lkp.lookupResult(Integer.class);

    Action action = ((ContextAwareAction) Actions.forID("cat", "survive")).createContextAwareInstance(lkp);
    Action fallbackAction = ((GeneralAction.DelegateAction) action).fallback;
    WeakReference<Action> fallbackActionRef = new WeakReference<Action>(fallbackAction);
    WeakReference<Action> clone = new WeakReference<Action>(action);
    cm = ContextManager.findManager(lkp, true);
    WeakReference<ContextManager.LSet> lsetRef = new WeakReference<ContextManager.LSet>(cm.findLSet(Integer.class));
    WeakReference<Lookup.Result> lookupResultRef = new WeakReference<Lookup.Result>(lsetRef.get().result);

    action = null;

    assertGC("Action should be GCed", clone);

    fallbackAction = null;

    assertGC("Fallback action should be GCed", fallbackActionRef);
    assertGC("Action LSet Should be GCed", lsetRef);
    if (lookupResultRef.get() == lookupResult) {
        // LSet holds ref to the actual real lookup result, nothing to test
    } else {
        // LSet holds ref to a wrapper class NeverEmptyResult, which should have been GCed
        assertGC("NeverEmptyResult should be GCed", lookupResultRef);
    }
}
项目:incubator-netbeans    文件:WindowSystemCompatibilityTest.java   
public Lkp() {
    super(new Lookup[0]);

    ic = new InstanceContent();
    AbstractLookup al = new AbstractLookup(ic);

    setLookups(new Lookup[] {
        al, Lookups.metaInfServices(Lkp.class.getClassLoader())
    });
}
项目:incubator-netbeans    文件:CallbackSystemActionTest.java   
public void testGlobalChanges() throws Exception {
    class MyAction extends AbstractAction {
        public int cntEnabled;
        public int cntPerformed;

        public MyAction() {
            setEnabled(true);
        }

        @Override
        public boolean isEnabled() {
            cntEnabled++;
            return super.isEnabled();
        }

        public void actionPerformed(ActionEvent ev) {
            cntPerformed++;
        }
    }
    MyAction myAction = new MyAction();

    ActionMap tc = new ActionMap();
    tc.put(DefaultEditorKit.copyAction, myAction);

    InstanceContent ic = new InstanceContent();
    AbstractLookup al = new AbstractLookup(ic);
    ContextAwareAction a = CallbackActionTest.callback(DefaultEditorKit.copyAction, null, al, false);

    ic.add(tc);
    assertTrue("MyAction is enabled", a.isEnabled());
    assertEquals("isEnabled called once", 1, myAction.cntEnabled);

    myAction.setEnabled(false);
    assertEquals("An enabled is not called on property change", 1, myAction.cntEnabled);
    assertFalse("MyAction is disabled", a.isEnabled());
    assertEquals("An enabled is currentlly called again", 2, myAction.cntEnabled);
}