Java Code Examples for org.openide.nodes.Node

The following are top voted examples for showing how to use org.openide.nodes.Node. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: incubator-netbeans   File: TableChildren.java   View source code 6 votes vote down vote up
protected Node[] createNodes (final Object key) {
        if (key instanceof ColumnElement)
            return new Node[] {factory.createColumnNode((ColumnElement) key)};
            
        if (key instanceof ColumnPairElement)
            return new Node[] {factory.createColumnPairNode((ColumnPairElement) key)};

        if (element instanceof TableElement) {
            boolean viewSupport = isViewSupport((TableElement) element);
            if (((TableElement) element).isTableOrView() || viewSupport) {
//            if (((TableElement) element).isTableOrView()) {
                if (key instanceof IndexElement)
                    return new Node[] { factory.createIndexNode((IndexElement)key) };
                if (key instanceof ForeignKeyElement)
                    return new Node[] { factory.createForeignKeyNode((ForeignKeyElement)key) };
            }
        }
            
        // ?? unknown type
        return new Node[0];
    }
 
Example 2
Project: incubator-netbeans   File: MoveClassesUI.java   View source code 6 votes vote down vote up
private final Vector getNodes() {
    Vector<Node> result = new Vector(javaObjects.size());
    LinkedList<FileObject> q = new LinkedList<FileObject>(javaObjects);
    while (!q.isEmpty()) {
        FileObject f = q.removeFirst();
        if (!VisibilityQuery.getDefault().isVisible(f)) {
            continue;
        }
        DataObject d = null;
        try {
            d = DataObject.find(f);
        } catch (DataObjectNotFoundException ex) {
            ex.printStackTrace();
        }
        if (d instanceof DataFolder) {
            for (DataObject o:((DataFolder) d).getChildren()) {
                q.addLast(o.getPrimaryFile());
            }
        } else {
            result.add(d.getNodeDelegate());
        }
    }
    return result;
}
 
Example 3
Project: incubator-netbeans   File: ExternalReferenceDataNode.java   View source code 6 votes vote down vote up
/**
 * Creates a node property of the given key (same as the column keys)
 * and specific getter/setter methods on the given object.
 *
 * @param  key     property name (same as matching column).
 * @param  type    Class of the property (e.g. String.class).
 * @param  inst    object on which to reflect.
 * @param  getter  name of getter method for property value.
 * @param  setter  name of setter method for property value (may be null).
 * @return  new property.
 */
private Node.Property createProperty(String key, Class type, Object inst,
        String getter, String setter) {
    Property prop = null;
    try {
        prop = new Reflection(inst, type, getter, setter);
        prop.setName(key);
        prop.setDisplayName(NbBundle.getMessage(
                ExternalReferenceDataNode.class,
                "CTL_SchemaPanel_Column_Name_" + key));
        prop.setShortDescription(NbBundle.getMessage(
                ExternalReferenceDataNode.class,
                "CTL_SchemaPanel_Column_Desc_" + key));
    }  catch (NoSuchMethodException nsme) {
        ErrorManager.getDefault().notify(nsme);
    }
    return prop;
}
 
Example 4
Project: incubator-netbeans   File: ExplorerManagerTest.java   View source code 6 votes vote down vote up
private int computeEqualsCount(int size) throws Exception {
    Integer [] arr = new Integer[size];
    for (int i = 0; i<arr.length; i++) {
        arr[i] = i;
    }
    ExplorerManager myem = new ExplorerManager();
    IntKeys mykeys = new IntKeys();
    mykeys.keys(arr);
    Node myroot = new AbstractNode(mykeys);
    myem.setRootContext(myroot);
    
    Node[] ch = myroot.getChildren().getNodes(true);
    
    Node[] neuCh = new Node[ch.length-1];
    System.arraycopy(ch, 0, neuCh, 0, neuCh.length);
    myem.setSelectedNodes(neuCh);
    IntKeys.eqCounter = 0;
    myem.setSelectedNodes(ch);
    myem.setSelectedNodes(neuCh);

    return IntKeys.eqCounter;
}
 
Example 5
Project: incubator-netbeans   File: UpdateResultsTable.java   View source code 6 votes vote down vote up
public int compare(Object o1, Object o2) {
    Node.Property p1 = (Node.Property) o1;
    Node.Property p2 = (Node.Property) o2;
    String sk1 = (String) p1.getValue("sortkey"); // NOI18N
    if (sk1 != null) {
        String sk2 = (String) p2.getValue("sortkey"); // NOI18N
        return sk1.compareToIgnoreCase(sk2);
    } else {
        try {
            String s1 = (String) p1.getValue();
            String s2 = (String) p2.getValue();
            return s1.compareToIgnoreCase(s2);
        } catch (Exception e) {
            Subversion.LOG.log(Level.SEVERE, null, e);
            return 0;
        }
    }
}
 
Example 6
Project: incubator-netbeans   File: TreeViewDragSupport.java   View source code 6 votes vote down vote up
/** Utility method. Returns either selected nodes in tree
* (if cursor hotspot is above some selected node) or the node
* the cursor points to.
* @return Node array or null if position of the cursor points
* to no node.
*/
Node[] obtainNodes(DragGestureEvent dge) {
    TreePath[] tps = tree.getSelectionPaths();

    if (tps == null) {
        return null;
    }

    Node[] result = new Node[tps.length];

    int cnt = 0;

    for (int i = 0; i < tps.length; i++) {
        Rectangle r = tree.getPathBounds(tps[i]);
        if (r != null && r.contains(dge.getDragOrigin())) {
            cnt++;
        }

        result[i] = DragDropUtilities.secureFindNode(tps[i].getLastPathComponent());
    }

    // #41954:
    // if the drag source is not at all in path location, do not return
    // any nodes
    return (cnt == 0) ? null : result;
}
 
Example 7
Project: incubator-netbeans   File: BasicAbstractResultsPanel.java   View source code 6 votes vote down vote up
private void toggleView(boolean flat) {
    FindDialogMemory memory = FindDialogMemory.getDefault();
    if (flat) {
        resultsOutlineSupport.setFlatMode();
        memory.setResultsViewMode(MODE_FLAT);
    } else {
        resultsOutlineSupport.setFolderTreeMode();
        memory.setResultsViewMode(MODE_TREE);
    }
    btnTreeView.setSelected(!flat);
    btnFlatView.setSelected(flat);
    try {
        getExplorerManager().setSelectedNodes(new Node[]{
                    resultsOutlineSupport.getResultsNode()});
    } catch (PropertyVetoException ex) {
    }
}
 
Example 8
Project: incubator-netbeans   File: DiffResultsView.java   View source code 6 votes vote down vote up
@Override
public Collection<Setup> getSetups() {
    Node [] nodes = TopComponent.getRegistry().getActivatedNodes();
    if (nodes.length == 0) {
        return parent.getSetups(results.toArray(new RepositoryRevision[results.size()]), new RepositoryRevision.Event[0]);
    }
    
    Set<RepositoryRevision.Event> events = new HashSet<RepositoryRevision.Event>();
    Set<RepositoryRevision> revisions = new HashSet<RepositoryRevision>();
    for (Node n : nodes) {
        RevisionNode node = (RevisionNode) n;
        if (node.getEvent() != null) {
            events.add(node.getEvent());
        } else {
            revisions.add(node.getContainer());
        }
    }
    return parent.getSetups(revisions.toArray(new RepositoryRevision[revisions.size()]), events.toArray(new RepositoryRevision.Event[events.size()]));
}
 
Example 9
Project: incubator-netbeans   File: FolderChildrenTest.java   View source code 6 votes vote down vote up
public void testChildrenCanGC () throws Exception {
    Filter filter = new Filter();
    holder = filter;

    String pref = getName() + '/';
    FileObject bb = FileUtil.createFolder(FileUtil.getConfigRoot(), pref + "/BB");
    bb.createData("Ahoj.txt");
    bb.createData("Hi.txt");
    DataFolder folder = DataFolder.findFolder(bb);

    Children ch = folder.createNodeChildren(filter);
    LOG.info("children created: " + ch);
    Node[] arr = ch.getNodes(true);
    LOG.info("nodes obtained" + arr);
    assertEquals("Accepts only Ahoj", 1, arr.length);
    LOG.info("The one node" + arr[0]);

    WeakReference<Children> ref = new WeakReference<Children>(ch);
    ch = null;
    arr = null;

    assertGC("Children can disappear even we hold the filter", ref);
}
 
Example 10
Project: incubator-netbeans   File: FileTreeView.java   View source code 6 votes vote down vote up
@Override
public void propertyChange (PropertyChangeEvent evt) {
    if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName()) && !internalTraverse) {
        Node[] selectedNodes = em.getSelectedNodes();
        final TopComponent tc = (TopComponent) SwingUtilities.getAncestorOfClass(TopComponent.class, view);
        if (tc != null) {
            tc.setActivatedNodes(selectedNodes);
        }
        if (selectedNodes.length == 1) {
            // single selection
            T node = convertNode(selectedNodes[0]);
            if (node != null) {
                nodeSelected(node);
                return;
            }
        }
        nodeSelected(null);
    }
}
 
Example 11
Project: incubator-netbeans   File: VisualizerNodeEventsOrderTest.java   View source code 6 votes vote down vote up
public void testForToStrictAssertsInVisualizerChildren() throws InterruptedException, InvocationTargetException {
    // block AWT thread
    Block b = new Block();
    b.block();
    Node n = lch.getNodeAt(0);
    final TreeNode tn = Visualizer.findVisualizer(n);
    SwingUtilities.invokeLater(new Runnable() {

        public void run() {
            try {
                int idx = ta.getIndex(tn);
            } catch (Throwable ex) {
                e = ex;
            }
        }
    });
    lch.keys("x", "y", "y");
    b.unblock();
    waitForAwtQueue();
    if (e != null) {
        fail();
    }
}
 
Example 12
Project: Pogamut3   File: LogProxy.java   View source code 6 votes vote down vote up
public Sheet.Set getPropSet() {
    Sheet.Set props = super.getPropSet();

    Node.Property p = new PropertySupport.ReadWrite("loglevel", Integer.class, "Log level", "") {

        public void setValue(Object val) {
            filter = replaceFilter(filter, new LogProxy.FilterLog(levels[(Integer) val]));
        }

        public Object getValue() {
            Integer i = levelToIndex.get(((LogProxy.FilterLog) filter).getLevel());
            return i;
        }
    };

    p.setValue("intValues", levelVals);
    p.setValue("stringKeys", levelNames);
    props.put(p);

    return props;
}
 
Example 13
Project: incubator-netbeans   File: POMModelPanel.java   View source code 6 votes vote down vote up
private static String getText(org.w3c.dom.Element el) {
    NodeList nl = el.getChildNodes();
    if (nl.getLength() > 0) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < nl.getLength(); i++) {
            org.w3c.dom.Node nd = nl.item(i);
            if (nd instanceof org.w3c.dom.Text) {
                org.w3c.dom.Text txt = (org.w3c.dom.Text)nd;
                String s = txt.getNodeValue();
                if (s != null) {
                    sb.append(s);
                }
            }
        }
        return sb.toString();
    }
    return null;
}
 
Example 14
Project: incubator-netbeans   File: PaletteFactoryTest.java   View source code 6 votes vote down vote up
public void testCreatePaletteFolder() throws Exception {
    try {
        PaletteFactory.createPalette( "non_existent_folder", new DummyActions() );
        fail( "Palette factory accepts non-existent folders." );
    } catch( FileNotFoundException fnfE ) {
        //that's what we want
    } catch( Throwable e ) {
        fail( "Invalid exception thrown." );
    }
    
    PaletteActions actions = new DummyActions();
    PaletteController controller = PaletteFactory.createPalette( PALETTE_ROOT_FOLDER_NAME, actions );
    Node rootNode = (Node)controller.getRoot().lookup( Node.class );
    assertNotNull( rootNode );
    assertEquals( actions, controller.getRoot().lookup( PaletteActions.class ) );
}
 
Example 15
Project: incubator-netbeans   File: DesignParentAction.java   View source code 6 votes vote down vote up
private void createSubmenu(JMenu menu) {
    Node[] nodes = getActivatedNodes();
    if (nodes != null && nodes.length == 1) {
        RADComponentCookie radCookie = nodes[0].getCookie(RADComponentCookie.class);
        RADComponent comp = (radCookie != null) ? radCookie.getRADComponent() : null;
        if (comp != null) {
            List<JMenuItem> list = new ArrayList<JMenuItem>();
            RADComponent topComp = comp.getFormModel().getTopRADComponent();
            boolean topCompIncluded = false;
            RADComponent parent = comp.getParentComponent();
            while (parent != null) {
                list.add(new DesignParentMenuItem(parent, parent == topComp, getMenuItemListener()));
                if (parent == topComp) {
                    topCompIncluded = true;
                }
                parent = parent.getParentComponent();
            }
            if (!topCompIncluded && topComp != null) {
                list.add(new DesignParentMenuItem(topComp, true, getMenuItemListener()));
            }
            for (ListIterator<JMenuItem> it=list.listIterator(list.size()); it.hasPrevious(); ) {
                menu.add(it.previous());
            }
        }
    }
}
 
Example 16
Project: incubator-netbeans   File: PasteAction.java   View source code 6 votes vote down vote up
/** @param em explorer manager to work with
 * @param n nodes to attach to or null if em's nodes should be used
 */
public NodeSelector(ExplorerManager em, Node[] n) {
    this.em = em;

    if ((n != null) && (n.length > 0)) {
        this.node = n[0];
    } else {
        Node[] arr = em.getSelectedNodes();

        if (arr.length != 0) {
            this.node = arr[0];
        } else {
            // do not initialize
            return;
        }
    }

    // XXX [FindBugs] is this field good for something (never read)? needed to hold hard ref, perhaps?
    this.children = node.getChildren().getNodes(true);

    this.added = new ArrayList<Node>();
    this.node.addNodeListener(this);
}
 
Example 17
Project: incubator-netbeans   File: ASTBrowserTopComponent.java   View source code 6 votes vote down vote up
private void mark () {
    if (tree.isFocusOwner ()) {
        Node[] ns = TopComponent.getRegistry ().getActivatedNodes ();
        if (ns.length == 1) {
            EditorCookie editorCookie = ns [0].getLookup ().
                lookup (EditorCookie.class);
            if (editorCookie != null) {
                TNode tn = (TNode) tree.getLastSelectedPathComponent ();
                if (tn != null) {
                    ASTItem item = tn.getASTItem ();
                    if (item == null) return;
                    highlighting.highlight (
                        editorCookie.getDocument (), 
                        item.getOffset (),
                        item.getEndOffset ()
                    );
                    return;
                }
            }
        }
    }
    highlighting.removeHighlight ();
}
 
Example 18
Project: incubator-netbeans   File: ExplorerPanelTest.java   View source code 5 votes vote down vote up
@RandomlyFails // NB-Core-Build #8351 (from ExplorerActionsCompatTest): Now it gets enabled
public void testDeleteAction () throws Exception {
    TestNode enabledNode = new TestNode(true, true, true);
    TestNode enabledNode2 = new TestNode(true, true, true);
    TestNode disabledNode = new TestNode(false, false, false);

    manager.setRootContext(new TestRoot(
        new Node[] {enabledNode, enabledNode2, disabledNode}));

    Action delete = ((ContextAwareAction)SystemAction.get(org.openide.actions.DeleteAction.class)).createContextAwareInstance(context);
    
    assertTrue ("By default delete is disabled", !delete.isEnabled());
    
    manager.setSelectedNodes(new Node[] { enabledNode });
    manager.waitActionsFinished();
    assertTrue ("Now it gets enabled", delete.isEnabled ());
    
    manager.setSelectedNodes (new Node[] { disabledNode });
    manager.waitActionsFinished();
    assertTrue ("Is disabled", !delete.isEnabled ());

    manager.setSelectedNodes(new Node[] { manager.getRootContext() });
    manager.waitActionsFinished();
    assertTrue ("Delete is enabled on root", delete.isEnabled ());
    
    manager.setSelectedNodes(new Node[] { manager.getRootContext(), enabledNode });
    manager.waitActionsFinished();
    assertTrue ("But is disabled on now, as one selected node is child of another", !delete.isEnabled ());
    
    manager.setSelectedNodes (new Node[] { enabledNode, enabledNode2 });
    manager.waitActionsFinished();
    assertTrue ("It gets enabled", delete.isEnabled ());
    
    delete.actionPerformed(new java.awt.event.ActionEvent (this, 0, "waitFinished"));
    
    assertEquals ("Destoy was called", 1, enabledNode.countDelete);
    assertEquals ("Destoy was called", 1, enabledNode2.countDelete);
    
    
}
 
Example 19
Project: incubator-netbeans   File: NodeTableModel.java   View source code 5 votes vote down vote up
private int rowForNode(Node node) {
    for (int i = 0; i < nodeRows.length; i++) {
        if (node.equals(nodeRows[i])) {
            return i;
        }
    }

    return -1;
}
 
Example 20
Project: incubator-netbeans   File: TreeTableView.java   View source code 5 votes vote down vote up
private void sortNodes() {
    Node[] origNodes = original.getChildren().getNodes();
    if (isSortingActive()) {
        Node[] sortedNodes = new Node[origNodes.length];
        System.arraycopy(origNodes, 0, sortedNodes, 0, origNodes.length);
        Collections.sort(Arrays.asList(sortedNodes), getRowComparator());
        setKeys(sortedNodes);
    } else {
        setKeys(origNodes);
    }
}
 
Example 21
Project: incubator-netbeans   File: JAXBWizardRootNode.java   View source code 5 votes vote down vote up
protected Node[] createNodes(Object key) {
    Node[] nodes = null;
    if ( key instanceof String ) {
        Schema schema = this.nameSchemaMap.get((String)key);                
        JAXBWizardSchemaNode bindingNode = new JAXBWizardSchemaNode(
                project, schema );
        nodes = new Node[] {
            bindingNode,
        };
    }
    
    return nodes;
}
 
Example 22
Project: incubator-netbeans   File: NavigatorController.java   View source code 5 votes vote down vote up
private DataObject obtainNodeDO(Node node) {
    DataObject dObj = node.getLookup().lookup(DataObject.class);
    // #64871: Follow DataShadows to their original
    while (dObj instanceof DataShadow) {
        dObj = ((DataShadow) dObj).getOriginal();
    }
    return dObj;
}
 
Example 23
Project: incubator-netbeans   File: DuplicateAction.java   View source code 5 votes vote down vote up
public static void performAction(Node[] nodes, int keyCode) {
    int dimension = (keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_RIGHT)
            ? LayoutConstants.HORIZONTAL : LayoutConstants.VERTICAL;
    int direction = (keyCode == KeyEvent.VK_LEFT || keyCode == KeyEvent.VK_UP)
            ? LayoutConstants.LEADING : LayoutConstants.TRAILING;
    duplicate(nodes, dimension, direction);
}
 
Example 24
Project: incubator-netbeans   File: ImportantFilesNodeFactory.java   View source code 5 votes vote down vote up
@Override
protected Node[] createNodes(String key) {
    if (LAYER.equals(key)) {
        Node nd = NodeFactoryUtils.createLayersNode(project);
        if (nd != null) {
            DataObject dobj = nd.getLookup().lookup(DataObject.class);
            if (dobj != null) {
                FileObject fo = dobj.getPrimaryFile();
                fo.addFileChangeListener(FileUtil.weakFileChangeListener(layerfcl, fo));
            }
            return new Node[] {nd };
        }
        return new Node[0];
    }
    else {
        FileObject file = project.getProjectDirectory().getFileObject(key);
        if (file != null) {
            try {
                Node orig = DataObject.find(file).getNodeDelegate();
                return new Node[] {NodeFactoryUtils.createSpecialFileNode(orig, FILES.get(key))};
            } catch (DataObjectNotFoundException e) {
                throw new AssertionError(e);
            }
        }
        return new Node[0];
    } 
}
 
Example 25
Project: incubator-netbeans   File: ContextAnalyzer.java   View source code 5 votes vote down vote up
/**
 * utility method to perform enable/disable logic for refactoring actions
 * @param lookup
 * @param notOnlyFile action is disabled when the selection is on File
 * @param onlyFromEditor action is enabled only in editor
 * @return 
 */
public static boolean canRefactorSingle(Lookup lookup, boolean notOnlyFile, boolean onlyFromEditor) {
    Collection<? extends Node> nodes = new HashSet<Node>(lookup.lookupAll(Node.class));
    if(nodes.size() != 1) {
        return false;
    }
    Node node = nodes.iterator().next();
    TreePathHandle tph = node.getLookup().lookup(TreePathHandle.class);
    if (tph != null) {
        if(JavaRefactoringUtils.isRefactorable(tph.getFileObject())) {
            return !onlyFromEditor || RefactoringUtils.isFromEditor(lookup.lookup(EditorCookie.class));
        } else {
            return false;
        }
    }
    DataObject dObj = node.getLookup().lookup(DataObject.class);
    if(null == dObj) {
        return false;
    }
    FileObject fileObj = dObj.getPrimaryFile();
    if(null == fileObj || !JavaRefactoringUtils.isRefactorable(fileObj)) {
        return false;
    }

    EditorCookie ec = lookup.lookup(EditorCookie.class);
    if (RefactoringUtils.isFromEditor(ec)) {
        return true;
    }
    return !notOnlyFile;
}
 
Example 26
Project: incubator-netbeans   File: BrowseFolders.java   View source code 5 votes vote down vote up
@Override
protected Node[] createNodes(FileObject folder) {
    FilterNode fn = new FilterNode(
            DataFolder.findFolder(folder).getNodeDelegate(),
            new SourceGroupChildren(folder, group));
    return new Node[] { fn };
}
 
Example 27
Project: incubator-netbeans   File: SafeDeleteAction.java   View source code 5 votes vote down vote up
private boolean doConfirm(Node[] sel) {
    String message;
    String title;
    boolean customDelete = true;

    for (int i = 0; i < sel.length; i++) {
        if (!Boolean.TRUE.equals(sel[i].getValue("customDelete"))) { // NOI18N
            customDelete = false;

            break;
        }
    }

    if (customDelete) {
        return true;
    }

    if (sel.length == 1) {
        message = NbBundle.getMessage(SafeDeleteAction.class, "MSG_ConfirmDeleteObject", sel[0].getDisplayName() //NOI18N
                );
        title = NbBundle.getMessage(SafeDeleteAction.class, "MSG_ConfirmDeleteObjectTitle"); //NOI18N
    } else {
        message = NbBundle.getMessage(SafeDeleteAction.class, "MSG_ConfirmDeleteObjects", Integer.valueOf(sel.length) //NOI18N
                );
        title = NbBundle.getMessage(SafeDeleteAction.class, "MSG_ConfirmDeleteObjectsTitle"); //NOI18N
    }

    NotifyDescriptor desc = new NotifyDescriptor.Confirmation(message, title, NotifyDescriptor.YES_NO_OPTION);

    return NotifyDescriptor.YES_OPTION.equals(DialogDisplayer.getDefault().notify(desc));
}
 
Example 28
Project: incubator-netbeans   File: SlowNodeDelegateTest.java   View source code 5 votes vote down vote up
@Override
protected Node createNodeDelegate() {
    assertEquals("Only one call to createNodeDelegate for " + getPrimaryFile(), 1, beingCreated.incrementAndGet());
    
    if (getPrimaryFile().hasExt("a")) {
        synchronized (this) {
            try {
                wait();
            } catch (InterruptedException ex) {
                throw new IllegalStateException(ex);
            }
        }
    }
    return super.createNodeDelegate();
}
 
Example 29
Project: incubator-netbeans   File: ExpandFolderTest.java   View source code 5 votes vote down vote up
public void testGetNodesForAFolderExtxml() throws Exception {
    CountingSecurityManager.initialize(getWorkDirPath());
    long now = System.currentTimeMillis();
    DataFolder f = DataFolder.findFolder(root);
    Node n = f.getNodeDelegate();
    Node[] arr = n.getChildren().getNodes(true);
    
    assertEquals("1000 nodes", 1000, arr.length);
    
    CountingSecurityManager.assertCounts("About 1000 * 11?", 11000, len);
}
 
Example 30
Project: incubator-netbeans   File: ShowListenersAction.java   View source code 5 votes vote down vote up
@Override
protected void performAction(Node[] activatedNodes) {
    for (Node n : activatedNodes) {
        JavaComponentInfo ci = n.getLookup().lookup(JavaComponentInfo.class);
        if (ci != null) {
            TopComponent tc = WindowManager.getDefault().findTopComponent("eventsView");
            if (tc == null) {
                throw new IllegalArgumentException("eventsView");
            }
            tc.open();
            tc.requestActive();
        }
    }
}
 
Example 31
Project: incubator-netbeans   File: MultiModuleNodeFactory.java   View source code 5 votes vote down vote up
@NonNull
private Node getDataFolderNodeDelegate() {
    final DataFolder df = getLookup().lookup(DataFolder.class);
    try {
        if (df.isValid()) {
            return df.getNodeDelegate();
        }
    } catch (IllegalStateException e) {
        if (df.isValid()) {
            throw e;
        }
    }
    return new AbstractNode(Children.LEAF);
}
 
Example 32
Project: incubator-netbeans   File: ConnectUsingDriverAction.java   View source code 5 votes vote down vote up
@Override
public void performAction(Node[] activatedNodes) {
    Lookup lookup = activatedNodes[0].getLookup();
    DriverNode node = lookup.lookup(DriverNode.class);
    
    if (node != null) {
        JDBCDriver driver = node.getDatabaseDriver().getJDBCDriver();
        new NewConnectionDialogDisplayer().showDialog(driver, null, null, null);
    }
}
 
Example 33
Project: NBANDROID-V2   File: ImportantFilesNodeFactory.java   View source code 5 votes vote down vote up
@Override
protected Node[] createNodes(Object key) {
    if (key instanceof String) {
        String loc = (String) key;
        FileObject file = project.getProjectDirectory().getFileObject(loc);
        try {
            Node orig = DataObject.find(file).getNodeDelegate();
            return new Node[]{new AndroidFileNode(orig, FILES.get(loc))};
        } catch (DataObjectNotFoundException e) {
            throw new AssertionError(e);
        }
    } else {
        throw new AssertionError(key);
    }
}
 
Example 34
Project: incubator-netbeans   File: OptionsAction.java   View source code 5 votes vote down vote up
private void setNewSet (Node.Property[] set) {
    // change columns
    setProperties (set);
    // set preferred colunm sizes
    setTreePreferredWidth(set.length == 1 ? 480 : 300);
    setTableColumnPreferredWidth (0, 20);
    for (int i = 1; i < set.length; i++) {
        setTableColumnPreferredWidth (i, 60);
    }
}
 
Example 35
Project: incubator-netbeans   File: TemplatesPanel.java   View source code 5 votes vote down vote up
private Index getIndexSupport (Node n) {
    Node parent = n.getParentNode ();
    assert parent != null : "Node " + n + " has a parent.";

    Index index = parent.getLookup ().lookup (Index.class);
    assert index != null : "Node " + parent + " has Index cookie.";
    
    return index;
}
 
Example 36
Project: incubator-netbeans   File: PropertySetModelImpl.java   View source code 5 votes vote down vote up
public void setComparator(Comparator<Node.Property> c) {
    if (c != comparator) {
        firePendingChange(true);
        comparator = c;
        fds.clear();
        init();
        fireChange(true);
    }
}
 
Example 37
Project: incubator-netbeans   File: ShowJavadocAction.java   View source code 5 votes vote down vote up
protected boolean enable(Node[] activatedNodes) {
    if (activatedNodes.length!=1) {
        return false;
    }
    JavadocProvider jd = activatedNodes[0].getLookup().lookup(JavadocProvider.class);
    if (jd == null) {
        return false;
    }
    return jd.hasJavadoc();
}
 
Example 38
Project: incubator-netbeans   File: UpdateAction.java   View source code 5 votes vote down vote up
private String getContextDisplayName (List<File> files) {
    Node[] nodes = new Node[files.size()];
    for (int i = 0; i < files.size(); ++i) {
        final File file = files.get(i);
        nodes[i] = new AbstractNode(Children.LEAF, Lookups.fixed(file)) {

            @Override
            public String getName () {
                return file.getName();
            }
            
        };
    }
    return getContextDisplayName(nodes);
}
 
Example 39
Project: incubator-netbeans   File: ViewTest.java   View source code 5 votes vote down vote up
public void testViewItemBasic() throws Exception {
    Node root = extsrcroot.getLookup().lookup(LogicalViewProvider.class).createLogicalView();
    assertEquals("lookup has project", extsrcroot, root.getLookup().lookup(Project.class));
    Children ch = root.getChildren();
    Node[] kids = ch.getNodes(true);
    assertEquals("two child nodes", 2, kids.length);
    // Do not check anything about #1, since it is provided by java/freeform.
    assertEquals("correct code name #2", "nbproject/project.xml", kids[1].getName());
    assertEquals("correct display name #2", "project.xml", kids[1].getDisplayName());
    assertEquals("correct cookie #2",
            DataObject.find(egdirFO.getFileObject("extsrcroot/proj/nbproject/project.xml")),
            kids[1].getLookup().lookup(DataObject.class));
}
 
Example 40
Project: incubator-netbeans   File: HgUtils.java   View source code 5 votes vote down vote up
public static VCSContext buildVCSContext (File[] roots) {
    List<Node> nodes = new ArrayList<Node>(roots.length);
    for (File root : roots) {
        nodes.add(new AbstractNode(Children.LEAF, Lookups.fixed(root)));
    }
    return VCSContext.forNodes(nodes.toArray(new Node[nodes.size()]));
}