當前位置: 首頁>>代碼示例>>Java>>正文


Java Node.getParentNode方法代碼示例

本文整理匯總了Java中org.openide.nodes.Node.getParentNode方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.getParentNode方法的具體用法?Java Node.getParentNode怎麽用?Java Node.getParentNode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.openide.nodes.Node的用法示例。


在下文中一共展示了Node.getParentNode方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getHelpCtx

import org.openide.nodes.Node; //導入方法依賴的package包/類
public HelpCtx getHelpCtx () {
    HelpCtx defaultHelp = new HelpCtx (HELP_ID);
    HelpCtx help = org.openide.explorer.ExplorerUtils.getHelpCtx (
        getExplorerManager ().getSelectedNodes (),
        defaultHelp
    );
    // bugfix #23551, add help id to subnodes of Templates category
    // this check prevents mixed help ids on more selected nodes
    if (!defaultHelp.equals (help)) {
        // try if selected node isn't template
        Node node = getExplorerManager ().getSelectedNodes ()[0];
        HelpCtx readHelpId = getHelpId (node);
        if (readHelpId != null) return readHelpId;
        
        // next bugfix #23551, children have same helpId as parent if no specific is declared
        while (node != null && !TEMPLATES_DISPLAY_NAME.equals (node.getDisplayName ())) {
            readHelpId = getHelpId (node);
            if (readHelpId != null) return readHelpId;
            node = node.getParentNode ();
        }
        if (node != null && TEMPLATES_DISPLAY_NAME.equals (node.getDisplayName ())) {
            return new HelpCtx ("org.netbeans.core.actions.OptionsAction$TemplatesSubnode"); // NOI18N
        }
    }
    return help;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:OptionsAction.java

示例2: testBehaviourOfProjectsLogicNode

import org.openide.nodes.Node; //導入方法依賴的package包/類
@RandomlyFails // NB-Core-Build #3939: "Can be garbage collected when closed" involving TimedWeakReference
public void testBehaviourOfProjectsLogicNode() throws InterruptedException {
    Node n = doBehaviourOfProjectsNode();
    
    Project p = n.getLookup().lookup(Project.class);
    assertNotNull("Project is in the node", p);
    
    WeakReference<Project> ref = new WeakReference<Project>(p);
    p = null;
    
    // keep just parent
    n = n.getParentNode();
    
    try {
        assertGC("Cannot be garbage collected while open", ref);
        throw new IllegalStateException("Cannot be GCed");
    } catch (AssertionFailedError ok) {
        // ok
    }
    
    OpenProjectList.getDefault().close(new Project[] { ref.get() }, true);
    
    assertGC("Can be garbage collected when closed", ref);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:25,代碼來源:ProjectsRootNodePhysicalViewTest.java

示例3: initExpandCollapseNotify

import org.openide.nodes.Node; //導入方法依賴的package包/類
private Object initExpandCollapseNotify(TreeExpansionEvent event) {
    Node node = Visualizer.findNode(event.getPath ().getLastPathComponent());
    Object obj = node.getLookup().lookup(Object.class);
    Object actOn;
    node = node.getParentNode();
    if (node == null) {
        actOn = new Integer(0);
    } else {
        Children ch = node.getChildren();
        if (ch instanceof TreeModelNode.TreeModelChildren) {
            actOn = ((TreeModelNode.TreeModelChildren) ch).getTreeDepth();
        } else {
            actOn = ch;
        }
    }
    Models.CompoundModel model = getModel();
    if (model != null) {
        DefaultTreeExpansionManager.get(model).setChildrenToActOn(actOn);
    }
    return obj;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:22,代碼來源:TreeModelRoot.java

示例4: hasParentAmongNodes

import org.openide.nodes.Node; //導入方法依賴的package包/類
private static boolean hasParentAmongNodes(final Node[] nodes,
                                           final int idx) {
    Node node;

    node = nodes[idx].getParentNode();
    while (null != node) {
        for (int i = 0; i < nodes.length; i++) {
            if (i == idx) {
                continue;
            }
            if (node == nodes[i]) {
                return true;
            }
        }
        node = node.getParentNode();
    }
    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:19,代碼來源:UICommonUtils.java

示例5: stringPath2TreePath

import org.openide.nodes.Node; //導入方法依賴的package包/類
/** Converts path of strings to TreePath if exists null otherwise
 */
private TreePath stringPath2TreePath (String[] sp) {
    ExplorerManager em = ExplorerManager.find (this);
    try {
        Node n = NodeOp.findPath (em.getRootContext (), sp); 
        
        // Create the tree path
        TreeNode tns[] = new TreeNode [sp.length + 1];
        
        for (int i = sp.length; i >= 0; i--) {
            tns[i] = Visualizer.findVisualizer (n);
            n = n.getParentNode ();
        }                
        return new TreePath (tns);
    } catch (NodeNotFoundException e) {
        return null;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:OutlineTable.java

示例6: getChildrenInDisplayedOrder

import org.openide.nodes.Node; //導入方法依賴的package包/類
private static Node[] getChildrenInDisplayedOrder(Node parent,
        OutlineView outlineView) {

    Outline outline = outlineView.getOutline();
    Node[] unsortedChildren = parent.getChildren().getNodes(true);
    int rows = outlineView.getOutline().getRowCount();
    int start = findRowIndexInOutline(parent, outline, rows);
    if (start == -1 && parent != ExplorerManager.find(outlineView).getRootContext()) {
        return unsortedChildren;
    }
    List<Node> children = new LinkedList<Node>();
    for (int j = start + 1; j < rows; j++) {
        int childModelIndex = outline.convertRowIndexToModel(j);
        if (childModelIndex == -1) {
            continue;
        }
        Object childObject = outline.getModel().getValueAt(
                childModelIndex, 0);
        Node childNode = Visualizer.findNode(childObject);
        if (childNode.getParentNode() == parent) {
            children.add(childNode);
        } else if (children.size() == unsortedChildren.length) {
            break;
        }
    }
    return children.toArray(new Node[children.size()]);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:28,代碼來源:FileTreeView.java

示例7: updateForSelection

import org.openide.nodes.Node; //導入方法依賴的package包/類
private void updateForSelection() {
    Node[] nodes = explorerManager.getSelectedNodes();
    if (nodes.length == 0) {
        displayNoFileSelected();
    } else if (nodes.length == 1) {
        Node n = nodes[0];
        MatchingObject mo = n.getLookup().lookup(MatchingObject.class);
        if (mo != null) {
            displayFile(mo, -1);
        } else {
            Node parent = n.getParentNode();
            TextDetail td = n.getLookup().lookup(TextDetail.class);
            if (td != null && parent != null) {
                mo = parent.getLookup().lookup(
                        MatchingObject.class);
                if (mo != null) {
                    // TODO pass TextDetail directly
                    int index = -1;
                    for (int i = 0; i < mo.getTextDetails().size(); i++) {
                        if (mo.getTextDetails().get(i) == td) {
                            index = i;
                            break;
                        }
                    }
                    displayFile(mo, index);
                }
            } else {
                displayNoFileSelected();
            }
        }
    } else {
        displayMultipleItemsSelected();
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:35,代碼來源:ContextView.java

示例8: isRelevantNode

import org.openide.nodes.Node; //導入方法依賴的package包/類
@Override
public boolean isRelevantNode(Node node) {
    if (node == null) {
        return false;
    } else {
        Node parent = node.getParentNode();
        return node.isLeaf() && parent != null
                && parent.getParentNode() != null;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:11,代碼來源:DefaultSearchResultsDisplayer.java

示例9: getTestMethodNode

import org.openide.nodes.Node; //導入方法依賴的package包/類
/**
 */
public static TestMethodNode getTestMethodNode(Node node) {
    while (!(node instanceof TestMethodNode)) {
        node = node.getParentNode();
    }
    return (TestMethodNode) node;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:UIJavaUtils.java

示例10: isParent

import org.openide.nodes.Node; //導入方法依賴的package包/類
private static boolean isParent(Node parent, Node child) {
    if (NodeOp.isSon(parent, child)) {
        return true;
    }

    Node p = child.getParentNode();

    if (p == null) {
        return false;
    }

    return isParent(parent, p);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:Nodes.java

示例11: valueChanged

import org.openide.nodes.Node; //導入方法依賴的package包/類
public void valueChanged(ListSelectionEvent e) {
    int curSize = model.getSize();
    int[] indices = list.getSelectedIndices();

    // bugfix #24193, check if the nodes in selection are in the view's root context
    List<Node> ll = new ArrayList<Node>(indices.length);

    for (int i = 0; i < indices.length; i++) {
        if (indices[i] < curSize) {
            Node n = Visualizer.findNode(model.getElementAt(indices[i]));

            if ((n == manager.getRootContext()) || (n.getParentNode() != null)) {
                ll.add(n);
            }
        } else {
            // something went wrong?
            updateSelection();

            return;
        }
    }

    Node[] nodes = ll.toArray(new Node[ll.size()]);

    // forwarding TO E.M., so we won't listen to its cries for a while
    manager.removePropertyChangeListener(wlpc);
    manager.removeVetoableChangeListener(wlvc);

    try {
        selectionChanged(nodes, manager);
    } catch (PropertyVetoException ex) {
        // selection vetoed - restore previous selection
        updateSelection();
    } finally {
        manager.addPropertyChangeListener(wlpc);
        manager.addVetoableChangeListener(wlvc);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:39,代碼來源:ListView.java

示例12: getTreeCellRendererComponent

import org.openide.nodes.Node; //導入方法依賴的package包/類
@Override
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    Color background = null;
    if (value instanceof TreeNode) {
        try {
            java.lang.reflect.Field fnode = value.getClass().getDeclaredField("node");
            fnode.setAccessible(true);
            value = fnode.get(value);
        } catch (Exception ex) {
            Exceptions.printStackTrace(ex);
        }
    }
    if (value instanceof Node) {
        Node node = (Node) value;
        DVThread thread;
        do {
            thread = node.getLookup().lookup(DVThread.class);
            if (thread == null) {
                node = node.getParentNode();
            }
        } while (thread == null && node != null);
        if (thread != null) {
            DVThread currentThread = getCurrentThread();
            boolean isHighlighted = focusedThread != null && thread == focusedThread && node == value;
            boolean isCurrent = currentThread == thread;
            if (isHighlighted || isCurrent) {
                background = isHighlighted ? highlightColor : currentThreadColor;
            }
        }
    }
    Component component = super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus);
    if (background != null) {
        component.setBackground(background);
        if (component instanceof JComponent) {
            ((JComponent) component).setOpaque(true);
        }
    }
    return component;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:40,代碼來源:DebugTreeView.java

示例13: hasParent

import org.openide.nodes.Node; //導入方法依賴的package包/類
/** Tests if the node has parent. Helper method. */
private static boolean hasParent(Node node, Node[] nodes) {
    for (Node parent = node.getParentNode(); parent != null; parent = parent.getParentNode()) {
        for (Node n : nodes) {
            if (n.equals(parent)) {
                return true;
            }
        }
    }
    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:FileObjectSearchGroup.java

示例14: isUnderRoot

import org.openide.nodes.Node; //導入方法依賴的package包/類
/** Checks whether given Node is a subnode of rootContext.
* @return true if specified Node is under current rootContext
*/
private boolean isUnderRoot(Node rootContext, Node node) {
    while (node != null) {
        if (node.equals(rootContext)) {
            return true;
        }

        node = node.getParentNode();
    }

    return false;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:TreeView.java

示例15: getTreeDepth

import org.openide.nodes.Node; //導入方法依賴的package包/類
private Integer getTreeDepth() {
    Node p = getParentNode();
    if (p == null) {
        return 0;
    } else if (depth != null) {
        return depth;
    } else {
        int d = 1;
        while ((p = p.getParentNode()) != null) d++;
        depth = new Integer(d);
        return depth;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:TreeModelNode.java


注:本文中的org.openide.nodes.Node.getParentNode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。