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));
}
}
}
};
}
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();
}
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();
}
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);
}
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();
}
Aggregations