Search in sources :

Example 31 with TreeNode

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

the class IdeFrameFixture method debuggerTreeRootToChildrenTexts.

@NotNull
private static String[] debuggerTreeRootToChildrenTexts(XDebuggerTreeNode treeRoot) {
    List<? extends TreeNode> children = treeRoot.getChildren();
    String[] childrenTexts = new String[children.size()];
    int i = 0;
    for (TreeNode child : children) {
        childrenTexts[i] = ((XDebuggerTreeNode) child).getText().toString();
        ++i;
    }
    return childrenTexts;
}
Also used : TreeNode(javax.swing.tree.TreeNode) XDebuggerTreeNode(com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode) XDebuggerTreeNode(com.intellij.xdebugger.impl.ui.tree.nodes.XDebuggerTreeNode) Assert.assertNotNull(junit.framework.Assert.assertNotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 32 with TreeNode

use of javax.swing.tree.TreeNode in project android by JetBrains.

the class ClassesTreeView method restoreViewState.

private void restoreViewState(@NotNull final SelectionModel selectionModel) {
    ClassObj classToSelect = selectionModel.getClassObj();
    TreeNode nodeToSelect = null;
    if (classToSelect != null) {
        nodeToSelect = findClassObjNode(classToSelect);
    }
    sortTree(myRoot);
    myTreeModel.nodeStructureChanged(myRoot);
    final TreeNode targetNode = nodeToSelect;
    if (targetNode != null) {
        // If the new heap has the selected class (from a previous heap), then select it and scroll to it.
        myColumnTree.revalidate();
        final TreePath pathToSelect = new TreePath(myTreeModel.getPathToRoot(targetNode));
        myTree.setSelectionPath(pathToSelect);
        // This is kind of clunky, but the viewport doesn't know how big the tree is until it repaints.
        // We need to do this because the contents of this tree has been more or less completely replaced.
        // Unfortunately, calling repaint() only queues it, so we actually need an extra frame to select the node.
        ApplicationManager.getApplication().invokeLater(() -> myTree.scrollPathToVisible(pathToSelect));
    } else {
        selectionModel.setClassObj(null);
        if (myTree.getRowCount() > 0) {
            myTree.scrollRowToVisible(0);
        }
    }
}
Also used : ClassObj(com.android.tools.perflib.heap.ClassObj) TreePath(javax.swing.tree.TreePath) TreeNode(javax.swing.tree.TreeNode)

Example 33 with TreeNode

use of javax.swing.tree.TreeNode in project android by JetBrains.

the class PackageNode method getQualifiedName.

@NotNull
public String getQualifiedName() {
    TreeNode parent = getParent();
    String pkg = parent instanceof PackageNode ? ((PackageNode) parent).getQualifiedName() : "";
    return pkg.isEmpty() ? myName : pkg + "." + myName;
}
Also used : TreeNode(javax.swing.tree.TreeNode) NotNull(org.jetbrains.annotations.NotNull)

Example 34 with TreeNode

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

the class GradleProjectCompositeSelectorDialog method createTree.

private CheckboxTree createTree() {
    final CheckedTreeNode root = new CheckedTreeNode();
    if (myCompositeRootSettings != null) {
        List<TreeNode> nodes = ContainerUtil.newArrayList();
        for (GradleProjectSettings projectSettings : GradleSettings.getInstance(myProject).getLinkedProjectsSettings()) {
            if (projectSettings == myCompositeRootSettings)
                continue;
            if (projectSettings.getCompositeBuild() != null && projectSettings.getCompositeBuild().getCompositeDefinitionSource() == CompositeDefinitionSource.SCRIPT) {
                continue;
            }
            GradleProjectSettings.CompositeBuild compositeBuild = myCompositeRootSettings.getCompositeBuild();
            boolean added = compositeBuild != null && compositeBuild.getCompositeParticipants().stream().anyMatch(participant -> pathsEqual(participant.getRootPath(), projectSettings.getExternalProjectPath()));
            String representationName = myExternalSystemUiAware.getProjectRepresentationName(projectSettings.getExternalProjectPath(), projectSettings.getExternalProjectPath());
            CheckedTreeNode treeNode = new CheckedTreeNode(Pair.create(representationName, projectSettings.getExternalProjectPath()));
            treeNode.setChecked(added);
            nodes.add(treeNode);
        }
        TreeUtil.addChildrenTo(root, nodes);
    }
    final CheckboxTree tree = new CheckboxTree(new CheckboxTree.CheckboxTreeCellRenderer(true, false) {

        @Override
        public void customizeRenderer(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
            if (!(value instanceof CheckedTreeNode))
                return;
            CheckedTreeNode node = (CheckedTreeNode) value;
            if (!(node.getUserObject() instanceof Pair))
                return;
            Pair pair = (Pair) node.getUserObject();
            ColoredTreeCellRenderer renderer = getTextRenderer();
            renderer.setIcon(myExternalSystemUiAware.getProjectIcon());
            String projectName = (String) pair.first;
            renderer.append(projectName, SimpleTextAttributes.REGULAR_ATTRIBUTES);
            String projectPath = StringUtil.trimMiddle((String) pair.second, MAX_PATH_LENGTH);
            renderer.append(" (" + projectPath + ")", SimpleTextAttributes.GRAY_ATTRIBUTES);
            setToolTipText((String) pair.second);
        }
    }, root);
    TreeUtil.expand(tree, 1);
    return tree;
}
Also used : AllIcons(com.intellij.icons.AllIcons) TreeNode(javax.swing.tree.TreeNode) TreeModel(javax.swing.tree.TreeModel) GradleProjectSettings(org.jetbrains.plugins.gradle.settings.GradleProjectSettings) ContainerUtil(com.intellij.util.containers.ContainerUtil) JBLabel(com.intellij.ui.components.JBLabel) ActionToolbarPosition(com.intellij.openapi.actionSystem.ActionToolbarPosition) BuildParticipant(org.jetbrains.plugins.gradle.model.data.BuildParticipant) GradleSettings(org.jetbrains.plugins.gradle.settings.GradleSettings) DialogWrapper(com.intellij.openapi.ui.DialogWrapper) Project(com.intellij.openapi.project.Project) ExternalSystemUiUtil(com.intellij.openapi.externalSystem.util.ExternalSystemUiUtil) CompositeDefinitionSource(org.jetbrains.plugins.gradle.settings.CompositeDefinitionSource) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) TreeUtil(com.intellij.util.ui.tree.TreeUtil) StringUtil(com.intellij.openapi.util.text.StringUtil) ExternalSystemUiAware(com.intellij.openapi.externalSystem.ExternalSystemUiAware) com.intellij.ui(com.intellij.ui) FileUtil.pathsEqual(com.intellij.openapi.util.io.FileUtil.pathsEqual) Nullable(org.jetbrains.annotations.Nullable) List(java.util.List) AnActionEvent(com.intellij.openapi.actionSystem.AnActionEvent) Pair(com.intellij.openapi.util.Pair) GradleConstants(org.jetbrains.plugins.gradle.util.GradleConstants) NotNull(org.jetbrains.annotations.NotNull) Consumer(com.intellij.util.Consumer) javax.swing(javax.swing) GradleProjectSettings(org.jetbrains.plugins.gradle.settings.GradleProjectSettings) TreeNode(javax.swing.tree.TreeNode) Pair(com.intellij.openapi.util.Pair)

Example 35 with TreeNode

use of javax.swing.tree.TreeNode in project jmeter by apache.

the class Move method moveAndSelectNode.

private static void moveAndSelectNode(JMeterTreeNode currentNode, JMeterTreeNode parentNode, int newIndx) {
    GuiPackage guiInstance = GuiPackage.getInstance();
    guiInstance.getTreeModel().removeNodeFromParent(currentNode);
    guiInstance.getTreeModel().insertNodeInto(currentNode, parentNode, newIndx);
    // select the node
    TreeNode[] nodes = guiInstance.getTreeModel().getPathToRoot(currentNode);
    JTree jTree = guiInstance.getMainFrame().getTree();
    jTree.setSelectionPath(new TreePath(nodes));
}
Also used : JTree(javax.swing.JTree) TreePath(javax.swing.tree.TreePath) GuiPackage(org.apache.jmeter.gui.GuiPackage) JMeterTreeNode(org.apache.jmeter.gui.tree.JMeterTreeNode) TreeNode(javax.swing.tree.TreeNode)

Aggregations

TreeNode (javax.swing.tree.TreeNode)183 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)77 TreePath (javax.swing.tree.TreePath)64 JTree (javax.swing.JTree)25 Nullable (org.jetbrains.annotations.Nullable)20 FilteredTreeModel (gov.sandia.n2a.ui.eq.FilteredTreeModel)18 MPart (gov.sandia.n2a.eqset.MPart)15 NodeBase (gov.sandia.n2a.ui.eq.tree.NodeBase)15 PanelModel (gov.sandia.n2a.ui.eq.PanelModel)14 ArrayList (java.util.ArrayList)13 Enumeration (java.util.Enumeration)13 DefaultTreeModel (javax.swing.tree.DefaultTreeModel)12 NodePart (gov.sandia.n2a.ui.eq.tree.NodePart)11 CannotRedoException (javax.swing.undo.CannotRedoException)10 NotNull (org.jetbrains.annotations.NotNull)10 CannotUndoException (javax.swing.undo.CannotUndoException)9 FontMetrics (java.awt.FontMetrics)8 MutableTreeNode (javax.swing.tree.MutableTreeNode)8 BioModelNode (cbit.vcell.desktop.BioModelNode)7 JMeterTreeNode (org.apache.jmeter.gui.tree.JMeterTreeNode)6