use of javax.swing.tree.TreePath in project darkFunction-Editor by darkFunction.
the class AddDirNodeCommand method insertNewNode.
public void insertNewNode(CustomNode parentNode, DefaultMutableTreeNode aNewNode) {
int insertIndex = parentNode.getChildCount();
while (insertIndex > 0) {
if (parentNode.getChildAt(insertIndex - 1).isLeaf())
insertIndex--;
else
break;
}
((DefaultTreeModel) nameTree.getModel()).insertNodeInto(newNode, parentNode, insertIndex);
TreePath newPath = new TreePath(newNode.getPath());
nameTree.scrollPathToVisible(newPath);
nameTree.setSelectionPath(newPath);
nameTree.startEditingAtPath(newPath);
}
use of javax.swing.tree.TreePath in project darkFunction-Editor by darkFunction.
the class AddLeafNodeCommand method insertNewNode.
public void insertNewNode(CustomNode parentNode, DefaultMutableTreeNode newNode) {
((DefaultTreeModel) nameTree.getModel()).insertNodeInto(newNode, parentNode, parentNode.getChildCount());
TreePath newPath = new TreePath(newNode.getPath());
nameTree.scrollPathToVisible(newPath);
nameTree.setSelectionPath(newPath);
nameTree.startEditingAtPath(newPath);
}
use of javax.swing.tree.TreePath in project darkFunction-Editor by darkFunction.
the class AddNodeCommand method execute.
public boolean execute() {
if (parentNode != null) {
DefaultMutableTreeNode selectedNode = null;
TreePath treePath = nameTree.getSelectionPath();
if (treePath != null)
selectedNode = (DefaultMutableTreeNode) treePath.getLastPathComponent();
if (selectedNode != null)
this.prevSelectedPath = new TreePath(selectedNode.getPath());
else
this.prevSelectedPath = null;
insertNewNode(parentNode, newNode);
return true;
}
return false;
}
use of javax.swing.tree.TreePath in project intellij-leiningen-plugin by derkork.
the class LeiningenProjectStructure method getSelectedNodes.
private static List<SimpleNode> getSelectedNodes(SimpleTree tree) {
List<SimpleNode> nodes = new ArrayList<SimpleNode>();
TreePath[] treePaths = tree.getSelectionPaths();
if (treePaths != null) {
for (TreePath treePath : treePaths) {
nodes.add(tree.getNodeFor(treePath));
}
}
return nodes;
}
use of javax.swing.tree.TreePath in project buck by facebook.
the class BuckToolWindowFactory method createBuildInfoPanel.
private JComponent createBuildInfoPanel(Project project) {
Tree result = new Tree(BuckUIManager.getInstance(project).getTreeModel());
result.addMouseListener(new MouseListener() {
@Override
public void mouseClicked(MouseEvent e) {
Tree tree = (Tree) e.getComponent();
int selRow = tree.getRowForLocation(e.getX(), e.getY());
TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
if (selRow != -1 && e.getClickCount() == 2) {
TreeNode node = (TreeNode) selPath.getLastPathComponent();
if (node.isLeaf()) {
BuckTreeNodeDetail buckNode = (BuckTreeNodeDetail) node;
if (buckNode instanceof BuckTreeNodeDetailError) {
BuckToolWindowFactory.this.handleClickOnError((BuckTreeNodeDetailError) buckNode);
}
}
}
}
@Override
public void mousePressed(MouseEvent e) {
}
@Override
public void mouseReleased(MouseEvent e) {
}
@Override
public void mouseEntered(MouseEvent e) {
}
@Override
public void mouseExited(MouseEvent e) {
}
});
result.setCellRenderer(new BuckTreeCellRenderer());
result.setShowsRootHandles(false);
result.setRowHeight(0);
JBScrollPane treeView = new JBScrollPane(result);
return treeView;
}
Aggregations