Search in sources :

Example 51 with TreeNode

use of javax.swing.tree.TreeNode in project intellij-plugins by JetBrains.

the class FoundUsersModelTest method testUserInProject.

public void testUserInProject() throws Exception {
    MockUser bob = new MockUser("BobName", null);
    bob.setProjects(new String[] { "bobProject" });
    FoundUsersModel model = createModel(Arrays.asList(new User[] { bob }));
    assertEquals("One project expected", 1, getRoot(model).getChildCount());
    TreeNode projectNode = getRoot(model).getChildAt(0);
    assertEquals("Invalid project node", "bobProject", projectNode.toString());
    assertEquals("One user in group expected", 1, projectNode.getChildCount());
    assertEquals("Invalid user node", bob.getName(), projectNode.getChildAt(0).toString());
}
Also used : User(jetbrains.communicator.core.users.User) MockUser(jetbrains.communicator.mock.MockUser) TreeNode(javax.swing.tree.TreeNode) MockUser(jetbrains.communicator.mock.MockUser)

Example 52 with TreeNode

use of javax.swing.tree.TreeNode in project intellij-plugins by JetBrains.

the class SelectionProcessor method removeSelectionOfGroupUsers.

private void removeSelectionOfGroupUsers(TreePath path) {
    TreeNode treeNode = ((TreeNode) path.getLastPathComponent());
    Enumeration children = treeNode.children();
    while (children.hasMoreElements()) {
        TreeNode node = (TreeNode) children.nextElement();
        myUserTree.removeSelectionPath(TreeUtils.getPathFromRoot(node));
    }
}
Also used : TreeNode(javax.swing.tree.TreeNode) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode)

Example 53 with TreeNode

use of javax.swing.tree.TreeNode in project intellij-plugins by JetBrains.

the class FlexBuildConfigurationsExtension method getFlexModuleForNode.

@Nullable
private static Module getFlexModuleForNode(@Nullable MasterDetailsComponent.MyNode node) {
    while (node != null) {
        final NamedConfigurable configurable = node.getConfigurable();
        final Object editableObject = configurable == null ? null : configurable.getEditableObject();
        if (editableObject instanceof Module && ModuleType.get((Module) editableObject) instanceof FlexModuleType) {
            return (Module) editableObject;
        }
        final TreeNode parent = node.getParent();
        node = parent instanceof MasterDetailsComponent.MyNode ? (MasterDetailsComponent.MyNode) parent : null;
    }
    return null;
}
Also used : FlexModuleType(com.intellij.lang.javascript.flex.FlexModuleType) NamedConfigurable(com.intellij.openapi.ui.NamedConfigurable) TreeNode(javax.swing.tree.TreeNode) Module(com.intellij.openapi.module.Module) Nullable(org.jetbrains.annotations.Nullable)

Example 54 with TreeNode

use of javax.swing.tree.TreeNode in project processdash by dtuma.

the class CheckboxTree method toggleCheck.

protected void toggleCheck(TreePath selPath) {
    TreeNode node = (TreeNode) selPath.getLastPathComponent();
    // toggle current checked status.
    boolean isChecked = uncheckedNodes.contains(node);
    setCheckedStatusRecursive(node, isChecked);
    if (!isChecked) {
        while (true) {
            node = node.getParent();
            if (node == null)
                break;
            setCheckedStatus(node, false);
        }
    }
    fireListSelectionEvent(false);
}
Also used : TreeNode(javax.swing.tree.TreeNode)

Example 55 with TreeNode

use of javax.swing.tree.TreeNode in project processdash by dtuma.

the class HierarchyEditor method copyTemplate.

public TreeNode copyTemplate(DefaultMutableTreeNode destParent, String templateName) {
    //recursive copy of node, children and properties
    PropertyKey parent = treeModel.getPropKey(useProps, destParent.getPath());
    PropertyKey templateKey = templates.getRootChildByName(templateName);
    int newIndex = useProps.getNumChildren(parent);
    // See if should be adding at other index...
    // if parent specifies allowed children
    Prop val = useProps.pget(parent);
    String status, allowedChild;
    if ((val != null) && ((status = val.getStatus()) != null)) {
        int idx1 = status.indexOf(ALLOWED_CHILD);
        int idx2 = status.indexOf(REQUIRED_PARENT);
        if (idx1 >= 0) {
            if (idx2 < 0)
                idx2 = status.length();
            StringTokenizer st = new StringTokenizer(status.substring(idx1 + 1, idx2), String.valueOf(ALLOWED_CHILD));
            while (st.hasMoreTokens()) {
                allowedChild = st.nextToken();
                // if parent specifies THIS child
                if (allowedChild.startsWith(templateName)) {
                    idx1 = allowedChild.indexOf("(");
                    idx2 = allowedChild.indexOf(")");
                    // if parent specifies index
                    if (idx1 >= 0 && idx2 >= 0) {
                        // change index
                        idx1 = Integer.valueOf(allowedChild.substring(idx1 + 1, idx2)).intValue();
                        newIndex = ((idx1 < 0) ? (newIndex + idx1) : idx1);
                    }
                    // exit while loop
                    break;
                }
            }
        }
    }
    // now add it
    useProps.addChildKey(parent, useProps.pget(parent).uniqueChildName(templateName), newIndex);
    useProps.copyFrom(templates, templateKey, useProps.getChildKey(parent, newIndex));
    // clear and reload the tree (NEEDS WORK)
    treeModel.useTreeModelListener(false);
    treeModel.reload(useProps);
    expandRoot();
    treeModel.useTreeModelListener(true);
    treeModel.nodeStructureChanged(destParent);
    return (TreeNode) treeModel.getChild(destParent, newIndex);
}
Also used : StringTokenizer(java.util.StringTokenizer) Prop(net.sourceforge.processdash.hier.Prop) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) TreeNode(javax.swing.tree.TreeNode) PropertyKey(net.sourceforge.processdash.hier.PropertyKey)

Aggregations

TreeNode (javax.swing.tree.TreeNode)313 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)146 TreePath (javax.swing.tree.TreePath)125 FilteredTreeModel (gov.sandia.n2a.ui.eq.FilteredTreeModel)31 Enumeration (java.util.Enumeration)30 PanelEquationTree (gov.sandia.n2a.ui.eq.PanelEquationTree)28 MPart (gov.sandia.n2a.eqset.MPart)27 ArrayList (java.util.ArrayList)27 NodeBase (gov.sandia.n2a.ui.eq.tree.NodeBase)25 JTree (javax.swing.JTree)23 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)23 Nullable (org.jetbrains.annotations.Nullable)23 MutableTreeNode (javax.swing.tree.MutableTreeNode)19 CannotRedoException (javax.swing.undo.CannotRedoException)18 NodePart (gov.sandia.n2a.ui.eq.tree.NodePart)16 CannotUndoException (javax.swing.undo.CannotUndoException)14 NodeVariable (gov.sandia.n2a.ui.eq.tree.NodeVariable)12 MouseEvent (java.awt.event.MouseEvent)11 NotNull (org.jetbrains.annotations.NotNull)11 PanelEquations (gov.sandia.n2a.ui.eq.PanelEquations)10