Java Code Examples for org.openide.util.lookup.AbstractLookup

The following examples show how to use org.openide.util.lookup.AbstractLookup. These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: constellation   Source File: GraphNode.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Private constructor: recommended pattern for using InstanceContent.
 *
 * @param content This object's Lookup.
 * @param graph The Graph.
 * @param gdo The GraphDataObject.
 * @param visual The visual interface to the graph.
 * @param tc The graph's TopComponent.
 */
private GraphNode(final InstanceContent content, final Graph graph, final GraphDataObject gdo, final TopComponent tc, final VisualManager visualManager) {
    super(Children.LEAF, new AbstractLookup(content));
    content.add(graph);
    content.add(this);
    this.graph = graph;
    this.visualManager = visualManager;
    this.gdo = gdo;
    this.undoRedoManager = new UndoRedo.Manager();
    this.tc = tc;

    graph.setUndoManager(undoRedoManager);

    GRAPHS.put(graph.getId(), GraphNode.this);

    for (GraphManagerListener listener : LISTENERS) {
        listener.graphOpened(graph);
    }

    MemoryManager.newObject(GraphNode.class);
}
 
Example 2
Source Project: netbeans   Source File: SessionNode.java    License: Apache License 2.0 6 votes vote down vote up
private SessionNode(InstanceContent instanceContent, EjbViewController controller, String ejbName) {
    super(new SessionChildren(controller), new AbstractLookup(instanceContent));
    ejbViewController = controller;
    setIconBaseWithExtension("org/netbeans/modules/j2ee/ejbcore/ui/logicalview/ejb/session/SessionNodeIcon.gif");
    setName(ejbName + "");
    setDisplayName();
    instanceContent.add(this);
    ElementHandle<TypeElement> beanClassHandle = ejbViewController.getBeanClass();
    if (beanClassHandle != null) {
        instanceContent.add(beanClassHandle);
    }
    DataObject dataObject = ejbViewController.getBeanDo();
    if (dataObject != null && dataObject.getPrimaryFile() != null) {
        instanceContent.add(dataObject.getPrimaryFile());
    }
    try {
        instanceContent.add(ejbViewController.createEjbReference());
    } catch (IOException ioe) {
        Exceptions.printStackTrace(ioe);
    }
}
 
Example 3
Source Project: netbeans   Source File: CMPFieldNode.java    License: Apache License 2.0 6 votes vote down vote up
private CMPFieldNode(CmpField field, EntityMethodController controller, FileObject ddFile, InstanceContent instanceContent) {
        super(Children.LEAF, new AbstractLookup(instanceContent));
        instanceContent.add(this); // for enabling Open action
        
        //TODO: RETOUCHE
//        try {
//            ic.add(DataObject.find(JavaModel.getFileObject(controller.getBeanClass().getResource()))); // for enabling SafeDelete action
//        } catch (DataObjectNotFoundException ex) {
//            // ignore
//        }
//        Method getterMethod = controller.getGetterMethod(controller.getBeanClass(), field.getFieldName());
//        if (getterMethod != null) {
//            ic.add(getterMethod); // for SafeDelete refactoring to find Method element
//        }
        this.field = field;
        this.ddFile = ddFile;
        this.controller = controller;
        field.addPropertyChangeListener(WeakListeners.propertyChange(this, field));
    }
 
Example 4
Source Project: TencentKona-8   Source File: FilterNode.java    License: GNU General Public License v2.0 6 votes vote down vote up
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>() {

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

    update();

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

    FilterTopComponent.findInstance().getFilterSettingsChangedEvent().addListener(this);
    resultChanged(null);
}
 
Example 5
Source Project: netbeans   Source File: JaxWsClientNode.java    License: Apache License 2.0 6 votes vote down vote up
private JaxWsClientNode(JaxWsModel jaxWsModel, Client client, FileObject srcRoot, InstanceContent content) {
    super(new JaxWsClientChildren(client, srcRoot),new AbstractLookup(content));
    this.jaxWsModel=jaxWsModel;
    this.client=client;
    this.srcRoot=srcRoot;
    this.content = content;
    setName(client.getName());
    setDisplayName(client.getName());
    content.add(this);
    content.add(client);
    content.add(srcRoot);
    WsdlModeler modeler = getWsdlModeler();
    if (modeler!=null) {
        changeIcon();
        modeler.generateWsdlModel(new WsdlModelListener(){
            public void modelCreated(WsdlModel model) {
                modelGenerationFinished=true;
                changeIcon();
            }
        });
    }
    content.add(new EditWSAttributesCookieImpl(this, jaxWsModel));
    setValue("wsdl-url",client.getWsdlUrl());
}
 
Example 6
Source Project: jdk8u60   Source File: GraphNode.java    License: GNU General Public License v2.0 6 votes vote down vote up
private GraphNode(final 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 OpenCookie() {

            public void open() {
                viewer.view(graph);
            }
        });
    }

    // Action for removing a graph
    content.add(new RemoveCookie() {

        public void remove() {
            graph.getGroup().removeGraph(graph);
        }
    });
}
 
Example 7
Source Project: openjdk-jdk8u   Source File: GraphNode.java    License: GNU General Public License v2.0 6 votes vote down vote up
private GraphNode(final 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 OpenCookie() {

            public void open() {
                viewer.view(graph);
            }
        });
    }

    // Action for removing a graph
    content.add(new RemoveCookie() {

        public void remove() {
            graph.getGroup().removeGraph(graph);
        }
    });
}
 
Example 8
Source Project: jeddict   Source File: JPQLExternalEditorController.java    License: Apache License 2.0 6 votes vote down vote up
public void init() {
    JPQLEditorTopComponent editorTopComponent = new JPQLEditorTopComponent(this);
    editorTopComponent.open();
    editorTopComponent.requestActive();
    editorTopComponent.setFocusToEditor();

    try {
        InstanceContent lookupContent = new InstanceContent();
        lookupContent.add(pud);
        AbstractLookup lookup = new AbstractLookup(lookupContent);
        AbstractNode node = new AbstractNode(Children.LEAF, lookup);
        editorTopComponent.fillPersistenceConfigurations(new Node[]{node});
    } catch (Exception ex) {
        modelerFile.handleException(ex);
    }
}
 
Example 9
Source Project: netbeans   Source File: ActionInvocationTest.java    License: Apache License 2.0 6 votes vote down vote up
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.");
            }
        }
    });
}
 
Example 10
Source Project: netbeans   Source File: ContextManagerTest.java    License: Apache License 2.0 6 votes vote down vote up
@RandomlyFails
public void testListenerGCedAfterActionGCed () 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 lsetRef = new WeakReference<Object>(cm.findLSet(Integer.class));

    // both delegate and delegating actions are GCed before WeakListenerSupport is triggered in ActiveRefQueue:
    // fallbackAction.removePropertyChangeListener(delegating.weakL);
    fallbackAction = null;
    action = null;
    assertGC("Action should be GCed", clone);

    assertGC("Fallback action should be GCed", fallbackActionRef);
    assertGC("Action LSet Should be GCed", lsetRef);
    lookupResult.allInstances();
}
 
Example 11
Source Project: netbeans   Source File: ActionProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testContextAction() throws Exception {
    Action a = Actions.forID("Tools", "on.int");
    assertTrue("It is context aware action", a instanceof ContextAwareAction);

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

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

    ic.remove(ten);
    clone.actionPerformed(new ActionEvent(this, 200, ""));
    assertEquals("Global Action stays same", 10, Context.cnt);
}
 
Example 12
Source Project: netbeans   Source File: StatefulActionProcessorTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testCustomContextAwareInstance() {
    Action a = Actions.forID("Foo", "test.ListAction");
    DefaultListSelectionModel model = new DefaultListSelectionModel();
    
    InstanceContent localContent1 = new InstanceContent();
    AbstractLookup localLookup1 = new AbstractLookup(localContent1);
    
    Action la = ((ContextAwareAction)a).createContextAwareInstance(localLookup1);
    
    assertFalse(a.isEnabled());
    assertFalse(la.isEnabled());
    
    localContent1.add(model);
    
    assertFalse(a.isEnabled());
    assertTrue(la.isEnabled());
    assertFalse((Boolean)la.getValue(Action.SELECTED_KEY));
    
    // checks that the context-bound instance changes its selected state
    // if the model changes (relevant property change event is fired)
    model.setSelectionInterval(1, 2);
    assertTrue((Boolean)la.getValue(Action.SELECTED_KEY));
}
 
Example 13
Source Project: netbeans   Source File: ClassPathProviderMergerTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testMissingEvents() throws Exception {
    InstanceContent ic = new InstanceContent();
    Lookup lookup = new AbstractLookup(ic);
    ProviderImpl defaultCP = new ProviderImpl();

    final URL root1 = FileUtil.urlForArchiveOrDir(FileUtil.normalizeFile(new File(getWorkDir(),"root1")));
    final URL root2 = FileUtil.urlForArchiveOrDir(FileUtil.normalizeFile(new File(getWorkDir(),"root2")));
    final MutableCPImpl cpImpl = new MutableCPImpl(root1);

    defaultCP.paths.put(ClassPath.COMPILE, ClassPathFactory.createClassPath(cpImpl));
    ClassPathProviderMerger instance = new ClassPathProviderMerger(defaultCP);
    ClassPathProvider result = instance.merge(lookup);

    ClassPath compile = result.findClassPath(null, ClassPath.COMPILE);
    assertNotNull(compile);
    assertEquals(1, compile.entries().size());

    cpImpl.add(root2);
    assertEquals(2, compile.entries().size());
}
 
Example 14
Source Project: netbeans   Source File: FolderRenameHandlerImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void handleRename(DataFolder folder, String newName) {
    InstanceContent ic = new InstanceContent();
    ic.add(folder.getNodeDelegate());
    ExplorerContext d = new ExplorerContext();
    d.setNewName(newName);
    ic.add(d);
    final Lookup l = new AbstractLookup(ic);
    if (ActionsImplementationFactory.canRename(l)) {
        SwingUtilities.invokeLater(new Runnable() {
            @Override
            public void run() {
                Action a = RefactoringActionsFactory.renameAction().createContextAwareInstance(l);
                a.actionPerformed(RefactoringActionsFactory.DEFAULT_EVENT);
            }
        });
    } else {
        FileObject fo = folder.getPrimaryFile();
        try {
            folder.rename(newName);
        } catch (IOException ioe) {
            ErrorManager.getDefault().notify(ioe);
        }
    }
}
 
Example 15
Source Project: netbeans   Source File: CompilerOptionsQueryMergerTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testLkpEvents() {
    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());
    final MockChangeListener listener = new MockChangeListener();
    res.addChangeListener(listener);
    ic.add(impl2);
    listener.assertEventCount(1);
    assertEquals(
            Arrays.asList("a1","a2","b1","b2"), //NOI18N
            res.getArguments());
}
 
Example 16
Source Project: netbeans   Source File: RestServiceNode.java    License: Apache License 2.0 6 votes vote down vote up
private RestServiceNode(Project project, RestServicesModel model,
        final RestServiceDescription desc, InstanceContent content) {
    super(new RestServiceChildren(project, model, desc.getName()), new AbstractLookup(content));
    this.serviceName = desc.getName();
    this.uriTemplate = desc.getUriTemplate();
    this.className = desc.getClassName();
    
    content.add(this);
    content.add(desc);
    content.add(new ResourceUriProvider() {
        public String getResourceUri() {
            return desc.getUriTemplate();
        }           
    });
    content.add(project);
    content.add(OpenCookieFactory.create(project, className));
    editorDrop = new ResourceToEditorDrop(this);
}
 
Example 17
Source Project: netbeans   Source File: ContextActionInjectTest.java    License: Apache License 2.0 6 votes vote down vote up
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);
}
 
Example 18
Source Project: netbeans   Source File: ContextManagerTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testSurviveFocusChange() throws Exception {
    InstanceContent ic = new InstanceContent();
    Lookup lkp = new AbstractLookup(ic);

    Action clone = ((ContextAwareAction) Actions.forID("cat", "survive")).createContextAwareInstance(lkp);
    L listener = new L();
    clone.addPropertyChangeListener(listener);

    assertFalse("Disabled", clone.isEnabled());
    Object val = Integer.valueOf(1);
    ic.add(val);
    assertTrue("Enabled now", clone.isEnabled());
    assertEquals("One change", 1, listener.cnt);
    ic.remove(val);
    assertTrue("Still Enabled", clone.isEnabled());

    Survival.value = 0;
    clone.actionPerformed(new ActionEvent(this, 0, ""));
    assertEquals("Added one", 1, Survival.value);
}
 
Example 19
private FolderNode(String name, GroupOrganizer organizer, List<String> oldSubFolders, final List<Group> groups, FolderChildren children, InstanceContent content) {
    super(children, new AbstractLookup(content));
    children.setParent(this);
    this.content = content;
    this.children = children;
    content.add(new RemoveCookie() {

        public void remove() {
            for (Group g : groups) {
                if (g.getDocument() != null) {
                    g.getDocument().removeGroup(g);
                }
            }
        }
    });
    init(name, organizer, oldSubFolders, groups);
}
 
Example 20
@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>();
}
 
Example 21
@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>();
}
 
Example 22
Source Project: netbeans   Source File: CallbackActionTest.java    License: Apache License 2.0 5 votes vote down vote up
public void testWithFallback() throws Exception {
    MyAction myAction = new MyAction();
    MyAction fallAction = new MyAction();
    
    ActionMap other = new ActionMap();
    ActionMap tc = new ActionMap();
    tc.put("somekey", myAction);
    
    InstanceContent ic = new InstanceContent();
    AbstractLookup al = new AbstractLookup(ic);
    ic.add(tc);
    
    ContextAwareAction a = callback("somekey", fallAction, al, false);
    CntListener l = new CntListener();
    a.addPropertyChangeListener(l);

    assertTrue("My action is on", myAction.isEnabled());
    assertTrue("Callback is on", a.isEnabled());
    
    l.assertCnt("No change yet", 0);
    
    ic.remove(tc);
    assertTrue("fall is on", fallAction.isEnabled());
    assertTrue("My is on as well", a.isEnabled());

    l.assertCnt("Still enabled, so no change", 0);
    
    fallAction.setEnabled(false);
    
    l.assertCnt("Now there was one change", 1);
    
    assertFalse("fall is off", fallAction.isEnabled());
    assertFalse("My is off as well", a.isEnabled());
    
    
    Action a2 = a.createContextAwareInstance(Lookup.EMPTY);
    assertEquals("Both actions are equal", a, a2);
    assertEquals("and have the same hash", a.hashCode(), a2.hashCode());
}
 
Example 23
Source Project: constellation   Source File: SimpleGraphTopComponent.java    License: Apache License 2.0 5 votes vote down vote up
public SimpleGraphTopComponent(final GraphDataObject gdo, final Graph graph) {
    initComponents();
    setName(gdo.getName());
    setToolTipText(gdo.getToolTipText());

    this.graph = graph;
    graphText.setText(gdo.getPrimaryFile().getName());
    schemaText.setText(graph.getSchema().getFactory().getName());

    graphChanged(null);

    graphNode = new GraphNode(graph, gdo, this, null);

    content = new InstanceContent();
    content.add(getActionMap());
    content.add(graphNode.getDataObject());
    content.add(graph);
    content.add(graphNode);

    associateLookup(new AbstractLookup(content));

    setActivatedNodes(new Node[]{
        graphNode
    });

    graph.addGraphChangeListener(SimpleGraphTopComponent.this);
}
 
Example 24
Source Project: netbeans   Source File: NavigatorTCTest.java    License: Apache License 2.0 5 votes vote down vote up
public ActNodeLookupProvider () {
    this.node1 = new AbstractNode(Children.LEAF);
    this.node1.setDisplayName(FIRST_NAME);
    this.node2 = new AbstractNode(Children.LEAF);
    this.node2.setDisplayName(SECOND_NAME);
    
    ic = new InstanceContent();
    ic.add(node1);
    lookup = new AbstractLookup(ic);
}
 
Example 25
public DocumentTopComponent(D document) {
    if (document == null) {
        throw new NullPointerException("document");
    }
    this.document = document;
    this.dynamicContent = new InstanceContent();
    associateLookup(new ProxyLookup(Lookups.fixed(document), new AbstractLookup(dynamicContent)));
}
 
Example 26
Source Project: netbeans   Source File: GlobalSharabilityQueryImplTest.java    License: Apache License 2.0 5 votes vote down vote up
private Lookup getInstanceLookup() {
    InstanceContent instanceContent = new InstanceContent();
    instanceContent.add(sq);
    instanceContent.add(vq);
    Lookup instanceLookup = new AbstractLookup(instanceContent);
    return instanceLookup;
}
 
Example 27
Source Project: netbeans   Source File: ResourceBundleBrandingPanel.java    License: Apache License 2.0 5 votes vote down vote up
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();
}
 
Example 28
Source Project: netbeans   Source File: MultiModuleNodeFactory.java    License: Apache License 2.0 5 votes vote down vote up
ContentLkp(
        @NonNull final ModuleNode node,
        @NonNull final Object... fixedContent) {
    Parameters.notNull("node", node);                 //NOI18N
    Parameters.notNull("fixedContent", fixedContent); //NOI18N
    this.node = node;
    this.fos = new AtomicReference<>(Pair.of(new InstanceContent(),Collections.emptyList()));
    this.dos = new AtomicReference<>(Pair.of(new InstanceContent(),Collections.emptyList()));
    this.setLookups(
            new AbstractLookup(fos.get().first()),
            new AbstractLookup(dos.get().first()),
            Lookups.fixed(fixedContent));
}
 
Example 29
Source Project: netbeans   Source File: HtmlRefactoringGlobalAction.java    License: Apache License 2.0 5 votes vote down vote up
protected Lookup getLookup(Node[] n) {
    InstanceContent ic = new InstanceContent();
    for (Node node:n)
        ic.add(node);
    if (n.length>0) {
        EditorCookie tc = getTextComponent(n[0]);
        if (tc != null) {
            ic.add(tc);
        }
    }
    ic.add(new Hashtable(0));
    return new AbstractLookup(ic);
}
 
Example 30
Source Project: netbeans   Source File: Nodes.java    License: Apache License 2.0 5 votes vote down vote up
@NonNull
private static Lookup createLookup (@NonNull Description desc) {
    final InstanceContent ic = new InstanceContent();
    ic.add(desc);
    ic.add(desc, ConvertDescription2TreePathHandle);
    ic.add(desc, ConvertDescription2FileObject);
    ic.add(desc, ConvertDescription2DataObject);
    return new AbstractLookup(ic);
}