Java Code Examples for org.openide.nodes.Children#getNodesCount()

The following examples show how to use org.openide.nodes.Children#getNodesCount() . 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: ResultsOutlineSupport.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void expandOnlyChilds(Node parent) {
    setExpansionListenerEnabled(false);
    try {
        Node node = parent;
        while (node != null) {
            Children children = node.getChildren();
            if (children.getNodesCount(true) == 1) {
                node = children.getNodeAt(0);
                outlineView.expandNode(node);
            } else {
                node = null;
            }
        }
    } finally {
        setExpansionListenerEnabled(true);
    }
}
 
Example 2
Source File: SecurityMultiViewElement.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void repaintView() {
    webApp = dObj.getWebApp();
    view = new SecurityView(webApp);
    editor.setContentView(view);
    
    Object lastActive = editor.getLastActive();
    if (lastActive != null) {
        ((SectionView)view).openPanel(lastActive);
    } else {
        SecurityView securityView = (SecurityView)view;
        
        Node initialNode = view.getRolesNode();
        Children ch = initialNode.getChildren();
        if (ch.getNodesCount() > 0)
            initialNode = ch.getNodes()[0];
        view.selectNode(initialNode);
    }
    view.checkValidity();
    dObj.checkParseable();
    
}
 
Example 3
Source File: BookmarksView.java    From netbeans with Apache License 2.0 6 votes vote down vote up
void requestFocusTreeOrTable() {
    if (treeViewShowing) {
        treeView.requestFocusInWindow();
    } else if (tableView != null) {
        tableView.getTable().requestFocusInWindow();
    }
    Node selectedNode = getTreeSelectedNode();
    if (selectedNode == null) {
        Children rootChildren = explorerManager.getRootContext().getChildren();
        if (rootChildren.getNodesCount() > 0) {
            try {
                explorerManager.setSelectedNodes(new Node[] { rootChildren.getNodeAt(0) });
            } catch (PropertyVetoException ex) {
                // Ignored
            }
        }
    }
}
 
Example 4
Source File: ExplorerTopComponent.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
private Node findObjectNode(Node topNode, OpenSimObject openSimObject) {
    if (topNode instanceof OpenSimObjectNode){
        if (((OpenSimObjectNode)topNode).getOpenSimObject().equals(openSimObject))
            return topNode;
    }
    if (topNode instanceof ExperimentalDataNode){
        ExperimentalDataNode edn = (ExperimentalDataNode) topNode;
        if (openSimObject.equals(edn.getDataObject()))
            return topNode;
    }
    if (topNode.isLeaf()) return null;
    boolean found = false;
    Children chden= topNode.getChildren();
    Node fndNode=null;
    for(int ch=0; ch < chden.getNodesCount() && !found; ch++){
        fndNode = findObjectNode(chden.getNodeAt(ch), openSimObject);
        found = (fndNode != null);
    }
    return fndNode;
}
 
Example 5
Source File: ObjectAppearanceChangeAction.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
protected Vector<OneComponentNode> collectAffectedComponentNodes() {
    Vector<OneComponentNode> objectNodes = new Vector<OneComponentNode>();
    Vector<OpenSimObject> opensimObjects = new Vector<OpenSimObject>();
    Node[] selected = ExplorerTopComponent.findInstance().getExplorerManager().getSelectedNodes();
    for (int i = 0; i < selected.length; i++) {
        if (!selected[i].isLeaf()){
            Children ch = selected[i].getChildren();
            for (int chNum = 0; chNum < ch.getNodesCount(); chNum++) {
                collectDescendentNodes((OpenSimNode) ch.getNodeAt(chNum), objectNodes, opensimObjects);
            }
        }
        if (selected[i] instanceof OneComponentNode && selected[i].isLeaf()) {
            if (!(opensimObjects.contains(((OneComponentNode)selected[i]).getOpenSimObject()))){
                objectNodes.add((OneComponentNode)selected[i]);
                opensimObjects.add(((OneComponentNode)selected[i]).getOpenSimObject());
            }
        } 
    }
    return objectNodes;
}
 
Example 6
Source File: OneBodyNode.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
public OneBodyNode(OpenSimObject b) {
   super(Frame.safeDownCast(b));
   // Create children for wrap objects associated with body
   Body bdy = (Body) b;
   setShortDescription(bdy.getAbsolutePathString());
   Children children = getChildren();
   // Create nodes for wrap objects      
   WrapObjectSet wrapObjects = bdy.getWrapObjectSet();
   for (int index=0; index < wrapObjects.getSize(); index++ ){
      WrapObject wrapObject = wrapObjects.get(index);
      OneWrapObjectNode node = new OneWrapObjectNode(wrapObject);
      Node[] arrNodes = new Node[1];
      arrNodes[0] = node;
      children.add(arrNodes);
      
   }
   OpenSimNodeHelper.createFrameNodes(children, comp);
   if(children.getNodesCount()==0) setChildren(Children.LEAF);      
   addDisplayOption(displayOption.Colorable);
   addDisplayOption(displayOption.Isolatable);
   addDisplayOption(displayOption.Showable);
}
 
Example 7
Source File: GroundNode.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
public GroundNode(Ground b) {
   super(Frame.safeDownCast(b));
   // Create children for wrap objects associated with body
   setShortDescription(b.getAbsolutePathString());
   Children children = getChildren();
   // Create nodes for wrap objects      
   WrapObjectSet wrapObjects = b.getWrapObjectSet();
   for (int index=0; index < wrapObjects.getSize(); index++ ){
      WrapObject wrapObject = wrapObjects.get(index);
      OneWrapObjectNode node = new OneWrapObjectNode(wrapObject);
      Node[] arrNodes = new Node[1];
      arrNodes[0] = node;
      children.add(arrNodes);
      
   }
   OpenSimNodeHelper.createFrameNodes(children, comp);
   if(children.getNodesCount()==0) setChildren(Children.LEAF);      
   addDisplayOption(displayOption.Colorable);
   addDisplayOption(displayOption.Isolatable);
   addDisplayOption(displayOption.Showable);
}
 
Example 8
Source File: ClientExplorerPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected Node getRootContext() {
    for (int i=0;i<projects.length;i++) {
        Project srcFileProject = FileOwnerQuery.getOwner(getTargetFile());
        if (srcFileProject!=null && JaxWsUtils.isProjectReferenceable(projects[i], srcFileProject)) {
            LogicalViewProvider logicalProvider = (LogicalViewProvider)projects[i].getLookup().lookup(LogicalViewProvider.class);
            if (logicalProvider!=null) {
                Node rootNode = logicalProvider.createLogicalView();
                Node[] servicesNodes = ProjectClientView.createClientView(projects[i]);
                if (servicesNodes!=null && servicesNodes.length>0) {
                    Children children = new Children.Array();
                    for(Node servicesNode:servicesNodes) {
                        Node[] nodes= servicesNode.getChildren().getNodes();
                        if (nodes!=null && nodes.length>0) {
                            Node[] filterNodes = new Node[nodes.length];
                            for (int j=0;j<nodes.length;j++) filterNodes[j] = new FilterNode(nodes[j]);
                            children.add(filterNodes);
                        }
                    }
                    if(children.getNodesCount()>0)
                        projectNodeList.add(new ProjectNode(children, rootNode));
                }
            }
        }

    }
    if (projectNodeList.size() > 0) {
        Node[] projectNodes = new Node[projectNodeList.size()];
        projectNodeList.<Node>toArray(projectNodes);
        rootChildren.add(projectNodes);
    } else {
        Node noClients = new NoServicesNode();
        rootChildren.add(new Node[]{noClients});
    }
    return explorerClientRoot;
}
 
Example 9
Source File: ClientExplorerPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected Node getRootContext() {
    for (int i = 0; i < sourceProjects.length; i++) {
        Project targetProject = FileOwnerQuery.getOwner(getTargetFile());
        if (targetProject != null
                && WSUtils.isProjectReferenceable(sourceProjects[i], targetProject)) {
            LogicalViewProvider logicalProvider =
                    (LogicalViewProvider) sourceProjects[i].getLookup().lookup(LogicalViewProvider.class);
            if (logicalProvider != null) {
                Node rootNode = logicalProvider.createLogicalView();
                Node[] servicesNodes = getClientNodes(sourceProjects[i]);
                if (servicesNodes.length > 0) {
                    Children children = new Children.Array();
                    children.add(servicesNodes);
                    if (children.getNodesCount() > 0) {
                        projectNodeList.add(new ProjectNode(children, rootNode));
                    }
                }
            }
        }

    }
    Node[] projectNodes = new Node[projectNodeList.size()];
    projectNodeList.<Node>toArray(projectNodes);
    rootChildren.add(projectNodes);
    return explorerClientRoot;
}
 
Example 10
Source File: SectionNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates an inner panel for this and populates
 * it with the children of this node (if there are any).
 */
public SectionNodeInnerPanel createInnerPanel() {
    Children children = getChildren();
    if (children.getNodesCount() == 0) {
        return createNodeInnerPanel();
    } else {
        BoxPanel boxPanel = new BoxPanel(sectionNodeView);
        populateBoxPanel(boxPanel);
        return boxPanel;
    }
}
 
Example 11
Source File: FolderChildrenTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public void testNodesHaveDataObjectInLookup() throws Exception {
    FileObject fa = FileUtil.createData(FileUtil.getConfigRoot(), "FK/A");
    FileObject fb = FileUtil.createData(FileUtil.getConfigRoot(), "FK/B");

    FileObject bb = FileUtil.getConfigFile("/FK");

    DataFolder folder = DataFolder.findFolder(bb);
    final CountDownLatch latch = new CountDownLatch(1);
    FormKitDataLoader.waiter = latch;
    // wake up in 3s
    RequestProcessor.getDefault().post(new Runnable() {
        @Override
        public void run() {
            latch.countDown();
        }
    }, 3000);
    
    Pool.setLoader(FormKitDataLoader.class);
    final Children ch = folder.getNodeDelegate().getChildren();
    int cnt = ch.getNodesCount(true);
    assertEquals("Two children", 2, cnt);

    FileObject af = ch.getNodeAt(0).getLookup().lookup(FileObject.class);
    assertEquals("The right file a", fa, af);
    FileObject bf = ch.getNodeAt(1).getLookup().lookup(FileObject.class);
    assertEquals("The right file b", fb, bf);

    FormKitDataLoader.assertMode = false;
    DataObject a = ch.getNodeAt(0).getLookup().lookup(DataObject.class);
    DataObject b = ch.getNodeAt(1).getLookup().lookup(DataObject.class);

    assertSame("Node is there #0", ch.getNodeAt(0), ch.getNodeAt(0).getLookup().lookup(Node.class));
    assertSame("Node is there #1", ch.getNodeAt(1), ch.getNodeAt(1).getLookup().lookup(Node.class));
    
    latch.countDown();
    
    assertNotNull("Obj A found", a);
    assertNotNull("Obj B found", b);
    
    assertEquals("Right primary File A", fa, a.getPrimaryFile());
    assertEquals("Right primary File B", fb, b.getPrimaryFile());
}