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

The following examples show how to use org.openide.nodes.Children#add() . 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: ControllersNode.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
public ControllersNode(OpenSimObjectSet ControllerSet) {
    super(ControllerSet);
    setDisplayName(NbBundle.getMessage(ControllersNode.class, "CTL_Controllers"));

    for (int index=0; index < ControllerSet.getSize(); index++ ){

        Controller controller = Controller.safeDownCast(ControllerSet.get(index));
        Children children = getChildren();

        OneControllerNode node = new OneControllerNode(controller);
        Node[] arrNodes = new Node[1];
        arrNodes[0] = node;
        children.add(arrNodes);
    }
    if (getChildren().getNodesCount()==0) setChildren(Children.LEAF);
  //addDisplayOption(displayOption.Isolatable);
  //addDisplayOption(displayOption.Showable);
}
 
Example 2
Source File: RESTExplorerPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public void addNotify() {
    super.addNotify();
    manager.addPropertyChangeListener(this);
    Project[] projects = OpenProjects.getDefault().getOpenProjects();
    Children rootChildren = new Children.Array();
    AbstractNode explorerResourcesRoot = new AbstractNode(rootChildren);
    List<Node> projectNodeList = new ArrayList<Node>();
    for (Project prj : projects) {
        Node node = factory.createNode(prj);
        if ( node != null ){
            projectNodeList.add(node);
        }
    }
    Node[] projectNodes = new Node[projectNodeList.size()];
    projectNodeList.<Node>toArray(projectNodes);
    rootChildren.add(projectNodes);
    manager.setRootContext(explorerResourcesRoot);
    
    // !PW If we preselect a node, this can go away.
    descriptor.setValid(false);

    treeView.requestFocusInWindow();
}
 
Example 3
Source File: OneFrameNode.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
protected final void createGeometryNodes() {
    // attached_geometry doesn't reach geometry mounted on 
    // offset frames, use iterator instead
    // Caveat if nested bodies or components have geometry 
    // it may appear multiple times
    ComponentsList compList = frame.getComponentsList();
    ComponentIterator compIter = compList.begin();
    Children children = getChildren();
    while (!compIter.equals(compList.end())) {
        Component comp = compIter.__deref__();
        Geometry oneG = Geometry.safeDownCast(comp);
        if (oneG != null && FrameGeometry.safeDownCast(oneG) == null) {
            Frame gFrame = oneG.getFrame();
            if (gFrame.equals(frame)){
                OneGeometryNode node = new OneGeometryNode(oneG);
                Node[] arrNodes = new Node[1];
                arrNodes[0] = node;
                children.add(arrNodes);
            }
        }
        compIter.next();
    }
}
 
Example 4
Source File: OtherComponentsNode.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
public OtherComponentsNode(ComponentSet componentSet) {
    super(componentSet);
    setDisplayName(NbBundle.getMessage(OtherComponentsNode.class, "CTL_ModelComponents"));

    for (int index=0; index < componentSet.getSize(); index++ ){

        ModelComponent component = componentSet.get(index);
        Children children = getChildren();

        OneOtherModelComponentNode node = new OneOtherModelComponentNode(component);
        Node[] arrNodes = new Node[1];
        arrNodes[0] = node;
        children.add(arrNodes);
    }
    if (getChildren().getNodesCount()==0) setChildren(Children.LEAF);
  //addDisplayOption(displayOption.Isolatable);
  //addDisplayOption(displayOption.Showable);
}
 
Example 5
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 6
Source File: ActuatorsNode.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance of ActuatorsNode
 */
public ActuatorsNode(OpenSimObjectSet as) {
   super(as);
   setDisplayName(NbBundle.getMessage(ActuatorsNode.class, "CTL_Actuators"));
   Children children = getChildren();

   // Add all of the Actuators that are not Muscles directly under the Actuators node.
   for (int forceNum=0; forceNum < as.getSize(); forceNum++ ) {
      Force nextForce = Force.safeDownCast(as.get(forceNum));
      Actuator act = Actuator.safeDownCast(nextForce);
      Muscle msl = Muscle.safeDownCast(nextForce);
      if (act != null && msl == null) {
         OneActuatorNode node = new OneActuatorNode(nextForce);
         Node[] arrNodes = new Node[1];
         arrNodes[0] = node;
         children.add(arrNodes);
      }
   }

   if (getChildren().getNodesCount() == 0)
      setChildren(children.LEAF);
}
 
Example 7
Source File: CustomScopePanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static Children createChildren(ProjectData data, CustomScopePanel panel) {
    Children childs = new Children.Array();
    for (SourceData sourceData : data.getSources()) {
        childs.add(new Node[]{new SourceGroupNode(sourceData, panel)});
    }
    return childs;
}
 
Example 8
Source File: TasksPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void run() {
    if (currentP != null) {

        GradleBaseProject prj = GradleBaseProject.get(currentP);
        if (prj != null) {
            final Children ch = new Children.Array();
            ArrayList<String> glist = new ArrayList<>(prj.getTaskGroups());
            glist.remove(GradleBaseProject.PRIVATE_TASK_GROUP);
            Collections.sort(glist, String.CASE_INSENSITIVE_ORDER);

            for (String group : glist) {
                ch.add(new Node[]{new TaskGroupNode(group, prj)});
            }
            ch.add(new Node[]{new TaskGroupNode(GradleBaseProject.PRIVATE_TASK_GROUP, prj)});

            SwingUtilities.invokeLater(() -> {
                treeView.setRootVisible(false);
                manager.setRootContext(new AbstractNode(ch));
                treeView.expandAll();
            });
            return;
        }

    }
    SwingUtilities.invokeLater(() -> {
        treeView.setRootVisible(false);
        manager.setRootContext(createEmptyNode());
    });
}
 
Example 9
Source File: FindHelpTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void setUp() throws Exception {
    Children kids = new Children.Array();
    nodes = new Node[] {
        new NoHelpNode(),
        new WithHelpNode("foo"),
        new WithHelpNode("bar"),
        new WithHelpNode("foo"),
    };
    kids.add(nodes);
    root = new AbstractNode(kids);
}
 
Example 10
Source File: OtherForcesNode.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance of OtherForcesNode
 */
public OtherForcesNode(OpenSimObjectSet as) {
   super(as);
   setDisplayName(NbBundle.getMessage(OtherForcesNode.class, "CTL_OtherForces"));
   Children children = getChildren();

      // Add all of the forces that are not Muscles, Actuators, or ContactForces directly under the Actuators node.
      for (int forceNum=0; forceNum < as.getSize(); forceNum++ ) {
         Force nextForce = Force.safeDownCast(as.get(forceNum));
         Muscle msl = Muscle.safeDownCast(nextForce);
         if (msl != null)
            continue;
         if (nextForce.getConcreteClassName().equalsIgnoreCase("ElasticFoundationForce") ||
           nextForce.getConcreteClassName().equalsIgnoreCase("HuntCrossleyForce"))
            continue;
         Actuator act = Actuator.safeDownCast(nextForce);
         if (act != null)
            continue;
         OneForceNode node = new OneForceNode(nextForce);
         Node[] arrNodes = new Node[1];
         arrNodes[0] = node;
         children.add(arrNodes);
      }

   if (getChildren().getNodesCount() == 0)
      setChildren(children.LEAF);
}
 
Example 11
Source File: SecurityMultiViewElement.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public SecurityView(WebApp webApp) {
    super(factory);
    
    configNode = new LoginConfigNode();
    addSection(new SectionPanel(this, configNode, "login_config")); //NOI18N
    
    rolesNode = new SecurityRolesNode();
    addSection(new SectionPanel(this, rolesNode, "security_roles")); //NOI18N
    
    SecurityConstraint[] constraints = webApp.getSecurityConstraint();
    Node[] nodes = new Node[constraints.length];
    Children ch = new Children.Array();
    
    for (int i=0; i < nodes.length;i++) {
        nodes[i] = new SecurityConstraintNode(constraints[i]);
    }
    
    ch.add(nodes);
    constraintsNode = new SectionContainerNode(ch);
    constraintsContainer = new SectionContainer(this, constraintsNode,
            NbBundle.getMessage(ServletsMultiViewElement.class,"TTL_SecurityConstraints"),false);
    
    constraintsContainer.setHeaderActions(new javax.swing.Action[]{addConstraintAction});
    
    SectionPanel[] pan = new SectionPanel[constraints.length];
    
    for (int i=0; i < nodes.length;i++) {
        pan[i] = new SectionPanel(this, nodes[i], constraints[i]);
        pan[i].setHeaderActions(new javax.swing.Action[]{removeConstraintAction});
        constraintsContainer.addSection(pan[i]);
    }
    
    addSection(constraintsContainer);
    constraintsNode.setDisplayName(NbBundle.getMessage(ServletsMultiViewElement.class,"TTL_SecurityConstraints"));
    
    ch = new Children.Array();
    ch.add(new Node[] {configNode, rolesNode, constraintsNode});
    AbstractNode root = new AbstractNode(ch);
    setRoot(root);
}
 
Example 12
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 13
Source File: TreeTableView126560Test.java    From netbeans with Apache License 2.0 5 votes vote down vote up
static Children prepareChildren(int nodesCount, int subnodesCount) {
    Children ch = new Children.Array();
    Node[] nodes = new Node[nodesCount];
    for (int i = 0; i < nodes.length; i++) {
        nodes[i] = createNodes(subnodesCount);
    }
    ch.add(nodes);
    return ch;
}
 
Example 14
Source File: MarkersNode.java    From opensim-gui with Apache License 2.0 5 votes vote down vote up
public void updateChildNodes(OpenSimObjectSet markerSet) {
    for (int markerNum=0; markerNum < markerSet.getSize(); markerNum++ ){

        Marker marker = Marker.safeDownCast(markerSet.get(markerNum));
        Children children = getChildren();

        OneMarkerNode node = new OneMarkerNode(marker);
        Node[] arrNodes = new Node[1];
        arrNodes[0] = node;
        children.add(arrNodes);
    }
}
 
Example 15
Source File: ListViewTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Creates two nodes. Selects one and tries to remove it
 * and replace with the other one (several times).
 */
public void testNodeAddingAndRemoving() {
    final Children c = new Array();
    Node n = new AbstractNode (c);
    final PListView lv = new PListView();
    final ExplorerPanel p = new ExplorerPanel();
    p.add(lv, BorderLayout.CENTER);
    p.getExplorerManager().setRootContext(n);
    p.open();

    final Node c1 = new AbstractNode(Children.LEAF);
    c1.setDisplayName("First");
    c1.setName("First");
    c.add(new Node[] { c1 });
    Node c2 = new AbstractNode(Children.LEAF);
    c2.setDisplayName("Second");
    c2.setName("Second");
    //Thread.sleep(500);

    for (int i = 0; i < 5; i++) {
        c.remove(new Node[] { c1 });
        c.add(new Node[] { c2 });
        
        // Waiting for until the view is updated.
        // This should not be necessary
        try {
            SwingUtilities.invokeAndWait( new EmptyRunnable() );
        } catch (InterruptedException ie) {
            fail ("Caught InterruptedException:" + ie.getMessage ());
        } catch (InvocationTargetException ite) {
            fail ("Caught InvocationTargetException: " + ite.getMessage ());
        }
        
        try {
            p.getExplorerManager().setSelectedNodes(new Node[] {c2} );
        } catch (PropertyVetoException  pve) {
            fail ("Caught the PropertyVetoException when set selected node " + c2.getName ()+ ".");
        }
        
        c.remove(new Node[] { c2 });
        c.add(new Node[] { c1 });
        
        //Thread.sleep(350);
    }
}
 
Example 16
Source File: ListViewTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Removes selected node by calling Children.Array.remove
 */
public void testRemoveAndAddNodes() {
    final Children c = new Array();
    Node n = new AbstractNode (c);
    final PListView lv = new PListView();
    final ExplorerPanel p = new ExplorerPanel();
    p.add(lv, BorderLayout.CENTER);
    p.getExplorerManager().setRootContext(n);
    p.open();
    Node[] children = new Node[NO_OF_NODES];

    for (int i = 0; i < NO_OF_NODES; i++) {
        children[i] = new AbstractNode(Children.LEAF);
        children[i].setDisplayName(Integer.toString(i));
        children[i].setName(Integer.toString(i));
        c.add(new Node[] { children[i] } );
    }
    //Thread.sleep(2000);
    
    try {
        // Waiting for until the view is updated.
        // This should not be necessary
        try {
            SwingUtilities.invokeAndWait( new EmptyRunnable() );
        } catch (InterruptedException ie) {
            fail ("Caught InterruptedException:" + ie.getMessage ());
        } catch (InvocationTargetException ite) {
            fail ("Caught InvocationTargetException: " + ite.getMessage ());
        }
        p.getExplorerManager().setSelectedNodes(new Node[] {children[0]} );
    } catch (PropertyVetoException  pve) {
        fail ("Caught the PropertyVetoException when set selected node " + children[0].getName ()+ ".");
    }
    
    for (int i = 0; i < NO_OF_NODES; i++) {
        c.remove(new Node [] { children[i] } );
        children[i] = new AbstractNode(Children.LEAF);
        children[i].setDisplayName(Integer.toString(i));
        children[i].setName(Integer.toString(i));
        c.add(new Node[] { children[i] } );
        //Thread.sleep(350);
    }
    assertEquals(NO_OF_NODES, c.getNodesCount());
}
 
Example 17
Source File: TTVTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private void replaceTTVContent () {
    Children children = new Children.Array();
    children.add(new Node[] { new TestNode("Not held node") });
    
    ep.getExplorerManager().setRootContext(new AbstractNode (children));
}
 
Example 18
Source File: ServiceView.java    From netbeans with Apache License 2.0 4 votes vote down vote up
private ArrayList<Node> initOperationView(SectionContainer bindingCont, Binding binding, boolean serviceOnly) {
    ArrayList<Node> nodes = new ArrayList<Node>();

    Node bindingNode = new BindingNode(binding);
    nodes.add(bindingNode);
    SectionPanel bindingPanel = new SectionPanel(this, bindingNode, binding, true);
    if (bindingCont != null) {
        bindingCont.addSection(bindingPanel, false);
    } else {
        addSection(bindingPanel, false);
    }
    
    if (!serviceOnly) {
        Collection<BindingOperation> operations = binding.getBindingOperations();
        for (BindingOperation op : operations) {
            Children opChildren = new Children.Array();
            Node opNodeContainer = new OperationContainerServiceNode(opChildren);
            SectionContainer opCont = new SectionContainer(this, opNodeContainer, op.getName() + " Operation"); //NOI18N
            if (bindingCont != null) {
                bindingCont.addSection(opCont, false);
            } else {
                addSection(opCont, false);
            }

            ArrayList<Node> subNodes = new ArrayList<Node>();

            Node opNode = new OperationNode(op);
            subNodes.add(opNode);
            SectionPanel opPanel = new SectionPanel(this, opNode, op, false);
            opCont.addSection(opPanel, false);

            BindingInput bi = op.getBindingInput();
            if (bi != null) {
                Node biNode = new BindingInputNode(bi);
                subNodes.add(biNode);
                SectionPanel biPanel = new SectionPanel(this, biNode, bi, false);
                opCont.addSection(biPanel, false);
            }
            BindingOutput bo = op.getBindingOutput();
            if (bo != null) {
                Node boNode = new BindingOutputNode(bo);
                subNodes.add(boNode);
                SectionPanel boPanel = new SectionPanel(this, boNode, bo, false);
                opCont.addSection(boPanel, false);
            }
            Collection<BindingFault> bfs = op.getBindingFaults();
            for (BindingFault bf : bfs) {
                Node bfNode = new BindingFaultNode(bf);
                subNodes.add(bfNode);
                SectionPanel bfPanel = new SectionPanel(this, bfNode, bf, false);
                opCont.addSection(bfPanel, false);
            }
            opChildren.add(subNodes.toArray(new Node[subNodes.size()]));
            nodes.add(opNodeContainer);
        }
    }
    //bindingPanel.open();
    return nodes;
}
 
Example 19
Source File: ListViewTopComponentTest.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Removes selected node by calling Children.Array.remove
 */
public void testRemoveAndAddNodes() {
    final Children c = new Array();
    Node n = new AbstractNode (c);
    final PListView lv = new PListView();
    final ExplorerPanel p = new ExplorerPanel();
    p.add(lv, BorderLayout.CENTER);
    p.getExplorerManager().setRootContext(n);
    p.open();
    Node[] children = new Node[NO_OF_NODES];

    for (int i = 0; i < NO_OF_NODES; i++) {
        children[i] = new AbstractNode(Children.LEAF);
        children[i].setDisplayName(Integer.toString(i));
        children[i].setName(Integer.toString(i));
        c.add(new Node[] { children[i] } );
    }
    //Thread.sleep(2000);
    
    try {
        // Waiting for until the view is updated.
        // This should not be necessary
        try {
            SwingUtilities.invokeAndWait( new EmptyRunnable() );
        } catch (InterruptedException ie) {
            fail ("Caught InterruptedException:" + ie.getMessage ());
        } catch (InvocationTargetException ite) {
            fail ("Caught InvocationTargetException: " + ite.getMessage ());
        }
        p.getExplorerManager().setSelectedNodes(new Node[] {children[0]} );
    } catch (PropertyVetoException  pve) {
        fail ("Caught the PropertyVetoException when set selected node " + children[0].getName ()+ ".");
    }
    
    for (int i = 0; i < NO_OF_NODES; i++) {
        c.remove(new Node [] { children[i] } );
        children[i] = new AbstractNode(Children.LEAF);
        children[i].setDisplayName(Integer.toString(i));
        children[i].setName(Integer.toString(i));
        c.add(new Node[] { children[i] } );
        //Thread.sleep(350);
    }
    assertEquals(NO_OF_NODES, c.getNodesCount());
}
 
Example 20
Source File: LayoutLaunchingPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
@NbBundle.Messages({
    "LBL_NoModesFound=No layout definition found",
    "MSG_NoModesFound=Is everything OK? Did your application compile and run?"
})
public void taskFinished(Task task) {
    handle.finish();
    FileObject modeDir = userDir.get().getFileObject("config/Windows2Local/Modes");
    boolean one = false;
    final Children ch = getExplorerManager().getRootContext().getChildren();
    if (modeDir != null) {
        try {
            FileSystem layer = DesignSupport.findLayer(data.getProject());
            if (layer == null) {
                throw new IOException("Cannot find layer in " + data.getProject()); // NOI18N
            }
            data.setSFS(layer);
            for (FileObject m : modeDir.getChildren()) {
                if (m.isData() && "wsmode".equals(m.getExt())) {
                    ModeNode mn = new ModeNode(m, data);
                    ch.add(new Node[] { mn });
                    one = true;
                }
            }
        } catch (IOException ex) {
            Exceptions.printStackTrace(ex);
        }
    }
    if (!one) {
        AbstractNode empty = new AbstractNode(Children.LEAF);
        empty.setName("empty"); // NOI18N
        empty.setDisplayName(Bundle.LBL_NoModesFound());
        empty.setShortDescription(Bundle.MSG_NoModesFound());
        ch.add(new Node[] { empty });
        markInvalid();
    } else {
        markValid();
    }
    
    EventQueue.invokeLater(this);
}