Java Code Examples for org.openide.nodes.Children#getNodes()
The following examples show how to use
org.openide.nodes.Children#getNodes() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TemplateChooserPanelGUITest.java From netbeans with Apache License 2.0 | 6 votes |
private static void representationOf(Children c, StringBuilder b) { boolean first = true; for (Node n : c.getNodes(true)) { if (first) { first = false; } else { b.append(", "); } b.append(n.getDisplayName()); if (!n.isLeaf()) { b.append('['); representationOf(n.getChildren(), b); b.append(']'); } } }
Example 2
Source File: FolderChildrenTest.java From netbeans with Apache License 2.0 | 6 votes |
@RandomlyFails // NB-Core-Build #1049 (in FolderChildrenLazyTest), #1051 (in this) public void testChangeableDataFilterOnNodeDelegate() throws Exception { String pref = getName() + "/"; FileUtil.createData (FileUtil.getConfigRoot(), pref + "BB/A.txt"); FileUtil.createData (FileUtil.getConfigRoot(), pref + "BB/B.txt"); FileUtil.createData (FileUtil.getConfigRoot(), pref + "BB/AA.txt"); FileUtil.createData (FileUtil.getConfigRoot(), pref + "BB/BA.txt"); FileObject bb = FileUtil.getConfigFile(pref + "BB"); Filter filter = new Filter(); DataFolder folder = DataFolder.findFolder (bb); Node n = folder.getClonedNodeDelegate(filter); Children ch = n.getChildren(); Node[] arr = ch.getNodes (true); assertNodes( arr, new String[] { "A.txt", "AA.txt" } ); filter.fire(); arr = ch.getNodes (true); assertNodes( arr, new String[] { "B.txt", "BA.txt" } ); }
Example 3
Source File: ElementNode.java From netbeans with Apache License 2.0 | 6 votes |
public ElementNode getNodeForElement(ElementHandle<Element> eh) { if (getDescritption().elementHandle != null && eh.signatureEquals(getDescritption().elementHandle)) { return this; } Children ch = getChildren(); if (ch instanceof ElementChilren) { for (Node sub : ch.getNodes()) { ElementNode result = ((ElementNode) sub).getNodeForElement(eh); if (result != null) { return result; } } } return null; }
Example 4
Source File: FolderChildrenTest.java From netbeans with Apache License 2.0 | 6 votes |
@RandomlyFails // NB-Core-Build #1058 (in FolderChildrenLazyTest) public void testChangeableDataFilter() throws Exception { String pref = getName() + "/"; FileUtil.createData (FileUtil.getConfigRoot(), pref + "BB/A.txt"); FileUtil.createData (FileUtil.getConfigRoot(), pref + "BB/B.txt"); FileUtil.createData (FileUtil.getConfigRoot(), pref + "BB/AA.txt"); FileUtil.createData (FileUtil.getConfigRoot(), pref + "BB/BA.txt"); FileObject bb = FileUtil.getConfigFile(pref + "/BB"); Filter filter = new Filter(); DataFolder folder = DataFolder.findFolder (bb); Children ch = folder.createNodeChildren( filter ); Node[] arr = ch.getNodes (true); assertNodes( arr, new String[] { "A.txt", "AA.txt" } ); filter.fire(); arr = ch.getNodes (true); assertNodes( arr, new String[] { "B.txt", "BA.txt" } ); }
Example 5
Source File: TemplatesPanel.java From netbeans with Apache License 2.0 | 6 votes |
private static Node getTemplateNode(FileObject fo, FileObject rootFO) { if (rootFO.equals(fo)) { return getTemplateRootNode(); } Node parent = getTemplateNode(fo.getParent(), rootFO); if (parent == null) { return null; } Children ch = parent.getChildren(); for (Node node : ch.getNodes(true)) { if (fo.equals(node.getLookup().lookup(FileObject.class))) { return node; } } return null; }
Example 6
Source File: CategoryView.java From netbeans with Apache License 2.0 | 6 votes |
private Node findNode( ProjectCustomizer.Category category, Node node ) { Children ch = node.getChildren(); if ( ch != null && ch != Children.LEAF ) { Node nodes[] = ch.getNodes( true ); if ( nodes != null ) { for (Node child : nodes) { ProjectCustomizer.Category cc = child.getLookup().lookup(ProjectCustomizer.Category.class); if ( cc == category ) { return child; } else { Node n = findNode(category, child); if ( n != null ) { return n; } } } } } return null; }
Example 7
Source File: SectionNode.java From netbeans with Apache License 2.0 | 6 votes |
/** * Recursively refreshes view of the associated inner panel of this node and * all its children nodes. */ public void refreshSubtree() { if (sectionPanel != null) { SectionInnerPanel innerPanel = sectionPanel.getInnerPanel(); if (innerPanel != null) { innerPanel.refreshView(); } } Children children = getChildren(); if (children != null) { Node[] nodes = children.getNodes(); for (int i = 0; i < nodes.length; i++) { Node node = nodes[i]; if (node instanceof SectionNode) { ((SectionNode) node).refreshSubtree(); } } } }
Example 8
Source File: SdksCustomizer.java From NBANDROID-V2 with Apache License 2.0 | 6 votes |
private static void expandAllNodes(BeanTreeView btv, Node node, ExplorerManager mgr, AndroidSdk platform) { btv.expandNode(node); Children ch = node.getChildren(); if (ch == Children.LEAF) { if (platform != null && platform.equals(node.getLookup().lookup(AndroidSdk.class))) { try { mgr.setSelectedNodes(new Node[]{node}); } catch (PropertyVetoException e) { //Ignore it } } return; } Node nodes[] = ch.getNodes(true); for (int i = 0; i < nodes.length; i++) { expandAllNodes(btv, nodes[i], mgr, platform); } }
Example 9
Source File: BiNode.java From netbeans with Apache License 2.0 | 5 votes |
/** refresh icons after get from introspection change */ public void iconChanged(){ fireIconChange(); fireOpenedIconChange(); Children ch = getChildren(); Node[] nodes = ch.getNodes(); if ( nodes == null ) return; for( int i = 0; i < nodes.length; i++ ) { ((BiFeatureNode)nodes[i]).iconChanged(); } }
Example 10
Source File: ExplorerTopComponent.java From opensim-gui with Apache License 2.0 | 5 votes |
public void selectNodeForObject(OpenSimObject oObject) { Children children = getExplorerManager().getRootContext().getChildren(); Node[] nodes = children.getNodes(); for (int i = 0; i < nodes.length; i++) { if (nodes[i] instanceof OneModelNode) { OneModelNode modelNode = ((OneModelNode) (nodes[i])); Node objectNode = findObjectNode(modelNode, oObject); // Hack to select Muscle based on selected PathPoint if (oObject instanceof AbstractPathPoint){ AbstractPathPoint ppt = (AbstractPathPoint)oObject; GeometryPath ppath = GeometryPath.safeDownCast(ppt.getOwner()); OpenSimObject pathOwner = ppath.getOwner(); objectNode = findObjectNode(modelNode,pathOwner); } if (objectNode != null) { try { // Node[] previouslySelectedNodes = findInstance().getExplorerManager().getSelectedNodes(); // Node[] newSelectedNodes = new Node[previouslySelectedNodes.length+1]; // System.arraycopy(previouslySelectedNodes, 0, newSelectedNodes, 0, previouslySelectedNodes.length); // newSelectedNodes[previouslySelectedNodes.length] = objectNode; findInstance().getExplorerManager().setSelectedNodes(new Node[]{objectNode}); this.setActivatedNodes(new Node[]{objectNode}); ((OpenSimNode)objectNode).refreshNode(); requestActive(); } catch (PropertyVetoException ex) { Exceptions.printStackTrace(ex); } break; } } } //return ret; }
Example 11
Source File: ProductGroupNodeTest.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
@Test public void testDefaultTree() throws Exception { ProductManager productManager = new ProductManager(); ProductGroupNode rootNode = new ProductGroupNode(productManager); Product product1 = TestProducts.createProduct1(); productManager.addProduct(product1); assertEquals(1, rootNode.getChildren().getNodesCount()); assertEquals(PNode.class, rootNode.getChildren().getNodeAt(0).getClass()); PNode pNode = (PNode) rootNode.getChildren().getNodeAt(0); assertSame(product1, pNode.getProduct()); assertEquals("[1] Test_Product_1", pNode.getDisplayName()); Children children = pNode.getChildren(); assertNotNull(children); Node[] groupNodes = children.getNodes(); assertNotNull(groupNodes); assertEquals(5, groupNodes.length); assertEquals("Metadata", groupNodes[0].getDisplayName()); assertEquals("Vector Data", groupNodes[1].getDisplayName()); assertEquals("Tie-Point Grids", groupNodes[2].getDisplayName()); assertEquals("Bands", groupNodes[3].getDisplayName()); assertEquals("Masks", groupNodes[4].getDisplayName()); //assertEquals("Flag-Codings", groupNodes[2].getDisplayName()); //assertEquals("Index-Codings", groupNodes[3].getDisplayName()); for (Node groupNode : groupNodes) { assertTrue(groupNode instanceof UndoRedo.Provider); } }
Example 12
Source File: CSSStylesSelectionPanel.java From netbeans with Apache License 2.0 | 5 votes |
/** * Updates the {@code resourceCache} map for the children of the given node. * * @param parent parent of the nodes for which the {@code resourceCache} * should be updated. */ void updateResourceCache(Node parent) { Children children = parent.getChildren(); for (Node node : children.getNodes(true)) { Resource ruleOrigin = node.getLookup().lookup(Resource.class); if (ruleOrigin != null) { resourceCache.put(ruleOrigin, ruleOrigin.toFileObject()); } } }
Example 13
Source File: ViewTest.java From netbeans with Apache License 2.0 | 5 votes |
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 14
Source File: DDTestCase.java From netbeans with Apache License 2.0 | 5 votes |
protected InnerTablePanel getDetailPanel() { ToolBarMultiViewElement toolBar = ddObj.getActiveMVElement(); assertNotNull("ToolBarMultiViewElement is null", toolBar); SectionNodeView sectionView = (SectionNodeView) toolBar.getSectionView(); Children nodes = sectionView.getRootNode().getChildren(); Node[] n = nodes.getNodes(); if (n[0] instanceof CmpRelationShipsNode) { CmpRelationShipsNode detailNode = (CmpRelationShipsNode) n[0]; return (InnerTablePanel) detailNode.getSectionNodePanel().getInnerPanel(); } return null; }
Example 15
Source File: ProjectsRootNode.java From netbeans with Apache License 2.0 | 5 votes |
static void checkNoLazyNode(Children children) { for (Node n : children.getNodes()) { if (n instanceof BadgingNode) { ((BadgingNode)n).replaceProject(null); } if (n.getLookup().lookup(LazyProject.class) != null) { OpenProjectList.LOGGER.warning("LazyProjects remain visible"); } } }
Example 16
Source File: ElementNode.java From netbeans with Apache License 2.0 | 5 votes |
public void refreshRecursively() { Children ch = getChildren(); if ( ch instanceof ElementChilren ) { ((ElementChilren)ch).resetKeys(description.subs, filters); for( Node sub : ch.getNodes() ) { ((ElementNode)sub).refreshRecursively(); } } }
Example 17
Source File: ViewTest.java From netbeans with Apache License 2.0 | 5 votes |
public void testViewItemBasic() throws Exception { Node root = lvp.createLogicalView(); Children ch = root.getChildren(); Node[] kids = ch.getNodes(true); assertEquals("two child nodes", 2, kids.length); assertEquals("correct code name #1", "../src", kids[0].getName()); assertEquals("correct display name #1", "External Sources", kids[0].getDisplayName()); assertEquals("correct cookie #1", DataObject.find(egdirFO.getFileObject("extsrcroot/src")), kids[0].getLookup().lookup(DataObject.class)); Node[] kids2 = kids[0].getChildren().getNodes(true); assertEquals("one child of ../src", 1, kids2.length); assertEquals("correct name of #1's kid", "org.foo", kids2[0].getName()); // Do not test node #2; supplied by ant/freeform. }
Example 18
Source File: ComponentNode.java From netbeans with Apache License 2.0 | 5 votes |
ComponentNode findNodeFor(ComponentInfo ci) { if (ci.equals(this.ci)) { return this; } Children ch = getChildren(); Node[] subNodes = ch.getNodes(); for (Node n : subNodes) { ComponentNode cn = (ComponentNode) n; ComponentNode node = cn.findNodeFor(ci); if (node != null) { return node; } } return null; }
Example 19
Source File: TransactionView.java From netbeans with Apache License 2.0 | 5 votes |
void openTransactionNodes() { NavigateNode root = controller.getRoot(); Children ch = root.getChildren(); Node [] nodes = ch.getNodes(); CurrNode cn = (CurrNode)nodes[0]; SavedNode sn = (SavedNode)nodes[1]; // If there are any current nodes, then select the most // recent (i.e. the last?) one. Children currCh = cn.getChildren(); Node [] currChNodes = currCh.getNodes(); int numCN = currChNodes.length; if (numCN > 0) { int selectThisOne = 0; if (timeAButton.isSelected()) { selectThisOne = numCN - 1; } selectNode(currChNodes[selectThisOne]); } else { Children savedCh = sn.getChildren(); Node [] savedChNodes = savedCh.getNodes(); int numSN = savedChNodes.length; if (numSN > 0) { selectNode(savedChNodes[0]); } } }
Example 20
Source File: BiNode.java From netbeans with Apache License 2.0 | 3 votes |
void includeAll( boolean value) { Children ch = getChildren(); Node[] nodes = ch.getNodes(); if ( nodes == null ) return; for( int i = 0; i < nodes.length; i++ ) { ((BiFeatureNode)nodes[i]).include( value ); } }