Java Code Examples for org.openide.nodes.Children#findChild()
The following examples show how to use
org.openide.nodes.Children#findChild() .
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: SelectPathAction.java From netbeans with Apache License 2.0 | 6 votes |
private Node[] getSelectionNodes() { if(selectionNodes == null) { String[] segments = selectionUrl.getPathSegments(); Node node = (RepositoryPathNode) browser.getExplorerManager().getRootContext(); for (int i = 0; i < segments.length; i++) { Children children = node.getChildren(); node = children.findChild(segments[i]); if(node==null) { break; } } if(node == null) { selectionNodes = EMPTY_NODES; } else { selectionNodes = new Node[] {node}; } } return selectionNodes; }
Example 2
Source File: PackageRenameHandlerTest.java From netbeans with Apache License 2.0 | 5 votes |
public @Override void setUp() throws Exception { final FileObject root = TestUtil.makeScratchDir(this); root.createFolder("testproject"); MockLookup.setInstances(TestUtil.testProjectFactory()); SourceGroup group = GenericSources.group(ProjectManager.getDefault().findProject(root), root.createFolder("src"), "testGroup", "Test Group", null, null); Children ch = PackageView.createPackageView(group).getChildren(); // Create folder FileUtil.createFolder(root, "src/foo"); n = ch.findChild("foo"); assertNotNull(n); }
Example 3
Source File: TreeViewDropSupport.java From netbeans with Apache License 2.0 | 5 votes |
private Node[] findDropedNodes(Node folder, Node[] dragNodes) { if ((folder == null) || (dragNodes.length == 0)) { return null; } Node[] dropNodes = new Node[dragNodes.length]; Children children = folder.getChildren(); for (int i = 0; i < dragNodes.length; i++) { dropNodes[i] = children.findChild(dragNodes[i].getName()); } return dropNodes; }
Example 4
Source File: OutlineViewDropSupport.java From netbeans with Apache License 2.0 | 5 votes |
private Node[] findDropedNodes(Node folder, Node[] dragNodes) { if ((folder == null) || (dragNodes.length == 0)) { return null; } Node[] dropNodes = new Node[dragNodes.length]; Children children = folder.getChildren(); for (int i = 0; i < dragNodes.length; i++) { dropNodes[i] = children.findChild(dragNodes[i].getName()); } return dropNodes; }
Example 5
Source File: PackageViewTest.java From netbeans with Apache License 2.0 | 4 votes |
@RandomlyFails public void testRename() throws Exception { assertNull( "source folder should not exist yet", root.getFileObject( "src" ) ); // Create children SourceGroup group = new SimpleSourceGroup( FileUtil.createFolder( root, "src" ) ); Children ch = PackageView.createPackageView( group ).getChildren(); // Create folder FileUtil.createFolder( root, "src/a" ); assertNodes( ch, new String[] { "a", }, new int[] { 0, }, true ); Node n = ch.findChild( "a" ); n.setName( "b" ); assertNodes( ch, new String[] { "b", }, new int[] { 0, } ); FileUtil.createFolder( root, "src/b/c" ); assertNodes( ch, new String[] { "b.c", }, new int[] { 0, } ); n = ch.findChild( "b.c" ); n.setName( "b.d" ); assertNodes( ch, new String[] { "b.d", }, new int[] { 0, } ); n = ch.findChild( "b.d" ); n.setName( "a.d" ); assertNodes( ch, new String[] { "a.d", }, new int[] { 0, } ); FileUtil.createFolder( root, "src/a/e" ); assertNodes( ch, new String[] { "a.d", "a.e" }, new int[] { 0, 0 } ); n = ch.findChild( "a.e" ); n.setName( "a.f" ); assertNodes( ch, new String[] { "a.d", "a.f" }, new int[] { 0, 0 } ); n = ch.findChild( "a.d" ); n.setName( "c.d" ); assertNodes( ch, new String[] { "a.f", "c.d"}, new int[] { 0, 0 } ); n = ch.findChild( "a.f" ); n.setName( "c.f" ); assertNodes( ch, new String[] { "c.d", "c.f" }, new int[] { 0, 0 } ); FileUtil.createFolder( root, "src/x/y/z" ); assertNodes( ch, new String[] { "c.d", "c.f", "x.y.z" }, new int[] { 0, 0, 0 } ); n = ch.findChild( "x.y.z" ); n.setName( "x.y" ); assertNodes( ch, new String[] { "c.d", "c.f", "x.y" }, new int[] { 0, 0, 0 } ); n = ch.findChild( "x.y" ); n.setName( "p.me.tools" ); assertNodes( ch, new String[] { "c.d", "c.f", "p.me.tools" }, new int[] { 0, 0, 0 } ); n = ch.findChild( "p.me.tools" ); n.setName( "p.metools" ); assertNodes( ch, new String[] { "c.d", "c.f", "p.metools" }, new int[] { 0, 0, 0 } ); n = ch.findChild( "p.metools" ); n.setName( "p.me.tools" ); assertNodes( ch, new String[] { "c.d", "c.f", "p.me.tools" }, new int[] { 0, 0, 0 } ); n = ch.findChild( "p.me.tools" ); n.setName( "p.me.toolsx" ); assertNodes( ch, new String[] { "c.d", "c.f", "p.me.toolsx" }, new int[] { 0, 0, 0 }, true); n = ch.findChild( "p.me.toolsx" ); n.setName( "p.me.tools" ); assertNodes( ch, new String[] { "c.d", "c.f", "p.me.tools" }, new int[] { 0, 0, 0 } ); }