Search in sources :

Example 11 with SimpleNode

use of com.intellij.ui.treeStructure.SimpleNode in project intellij-community by JetBrains.

the class TreeToolbarDecorator method createDefaultTreeActions.

private void createDefaultTreeActions() {
    final EditableTreeModel model = (EditableTreeModel) myTree.getModel();
    myAddAction = new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            final TreePath path = myTree.getSelectionPath();
            final DefaultMutableTreeNode selected = path == null ? (DefaultMutableTreeNode) myTree.getModel().getRoot() : (DefaultMutableTreeNode) path.getLastPathComponent();
            final Object selectedNode = selected.getUserObject();
            myTree.stopEditing();
            Object element;
            if (model instanceof DefaultTreeModel && myProducer != null) {
                element = myProducer.createElement();
                if (element == null)
                    return;
            } else {
                element = null;
            }
            DefaultMutableTreeNode parent = selected;
            if ((selectedNode instanceof SimpleNode && ((SimpleNode) selectedNode).isAlwaysLeaf()) || !selected.getAllowsChildren()) {
                parent = (DefaultMutableTreeNode) selected.getParent();
            }
            if (parent != null) {
                parent.insert(new DefaultMutableTreeNode(element), parent.getChildCount());
            }
            final TreePath createdPath = model.addNode(new TreePath(parent.getPath()));
            if (path != null) {
                TreeUtil.selectPath(myTree, createdPath);
                IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
                    IdeFocusManager.getGlobalInstance().requestFocus(myTree, true);
                });
            }
        }
    };
    myRemoveAction = new AnActionButtonRunnable() {

        @Override
        public void run(AnActionButton button) {
            myTree.stopEditing();
            if (myTree.getSelectionModel().getSelectionMode() == TreeSelectionModel.SINGLE_TREE_SELECTION) {
                final TreePath path = myTree.getSelectionPath();
                if (path != null) {
                    model.removeNode(path);
                }
            } else {
                final TreePath[] paths = myTree.getSelectionPaths();
                if (paths != null && paths.length > 0) {
                    model.removeNodes(Arrays.asList(paths));
                }
            }
        }
    };
}
Also used : EditableTreeModel(com.intellij.util.ui.EditableTreeModel) TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) DefaultTreeModel(javax.swing.tree.DefaultTreeModel) SimpleNode(com.intellij.ui.treeStructure.SimpleNode)

Example 12 with SimpleNode

use of com.intellij.ui.treeStructure.SimpleNode in project intellij-community by JetBrains.

the class SelectMavenGoalDialog method doOKAction.

@Override
protected void doOKAction() {
    SimpleNode node = getSelectedNode();
    if (node instanceof NullNode)
        node = null;
    myResult = node instanceof MavenProjectsStructure.GoalNode ? ((MavenProjectsStructure.GoalNode) node) : null;
    super.doOKAction();
}
Also used : NullNode(com.intellij.ui.treeStructure.NullNode) SimpleNode(com.intellij.ui.treeStructure.SimpleNode)

Example 13 with SimpleNode

use of com.intellij.ui.treeStructure.SimpleNode in project intellij-community by JetBrains.

the class SelectMavenProjectDialog method doOKAction.

@Override
protected void doOKAction() {
    SimpleNode node = getSelectedNode();
    if (node instanceof NullNode)
        node = null;
    myResult = node instanceof MavenProjectsStructure.ProjectNode ? ((MavenProjectsStructure.ProjectNode) node).getMavenProject() : null;
    super.doOKAction();
}
Also used : NullNode(com.intellij.ui.treeStructure.NullNode) SimpleNode(com.intellij.ui.treeStructure.SimpleNode)

Example 14 with SimpleNode

use of com.intellij.ui.treeStructure.SimpleNode in project intellij-community by JetBrains.

the class NodeProgressAnimator method repaintWithParents.

public void repaintWithParents(final SimpleNode element) {
    SimpleNode current = element;
    do {
        DefaultMutableTreeNode node = myTreeBuilder.getNodeForElement(current);
        if (node != null) {
            final AbstractTreeUi treeUi = myTreeBuilder.getUi();
            treeUi.addSubtreeToUpdate(node, false);
        }
        current = current.getParent();
    } while (current != null);
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) AbstractTreeUi(com.intellij.ide.util.treeView.AbstractTreeUi) SimpleNode(com.intellij.ui.treeStructure.SimpleNode)

Example 15 with SimpleNode

use of com.intellij.ui.treeStructure.SimpleNode in project intellij-community by JetBrains.

the class SelectExternalProjectDialog method doOKAction.

@Override
protected void doOKAction() {
    SimpleNode node = getSelectedNode();
    if (node instanceof NullNode)
        node = null;
    myResult = node instanceof ProjectNode ? ((ProjectNode) node).getData() : null;
    super.doOKAction();
}
Also used : ProjectNode(com.intellij.openapi.externalSystem.view.ProjectNode) NullNode(com.intellij.ui.treeStructure.NullNode) SimpleNode(com.intellij.ui.treeStructure.SimpleNode)

Aggregations

SimpleNode (com.intellij.ui.treeStructure.SimpleNode)20 BaseDomElementNode (com.intellij.util.xml.tree.BaseDomElementNode)5 NullNode (com.intellij.ui.treeStructure.NullNode)4 DomElement (com.intellij.util.xml.DomElement)3 TreePath (javax.swing.tree.TreePath)3 NotNull (org.jetbrains.annotations.NotNull)3 DomCollectionChildDescription (com.intellij.util.xml.reflect.DomCollectionChildDescription)2 DomElementsGroupNode (com.intellij.util.xml.tree.DomElementsGroupNode)2 DomFileElementNode (com.intellij.util.xml.tree.DomFileElementNode)2 DomModelTreeView (com.intellij.util.xml.tree.DomModelTreeView)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 AbstractDependencyNode (com.android.tools.idea.gradle.structure.configurables.android.dependencies.treeview.AbstractDependencyNode)1 AbstractTreeUi (com.intellij.ide.util.treeView.AbstractTreeUi)1 Result (com.intellij.openapi.application.Result)1 WriteCommandAction (com.intellij.openapi.command.WriteCommandAction)1 ProjectNode (com.intellij.openapi.externalSystem.view.ProjectNode)1 TaskNode (com.intellij.openapi.externalSystem.view.TaskNode)1 Configurable (com.intellij.openapi.options.Configurable)1 SearchableConfigurable (com.intellij.openapi.options.SearchableConfigurable)1 PackagingElementNode (com.intellij.openapi.roots.ui.configuration.artifacts.nodes.PackagingElementNode)1