private static List<TreePath> getPaths(BreakpointTree tree, final Object[] userObjects) { final List<TreePath> paths = new ArrayList<TreePath>(userObjects.length); for (Object descriptor : userObjects) { final CheckedTreeNode node = tree.myDescriptorToNodeMap.get(descriptor); if (node != null) { paths.add(new TreePath(node.getPath())); } } return paths; }
protected boolean toggleNode(CheckedTreeNode node) { boolean checked = !node.isChecked(); checkNode(node, checked); // notify model listeners about model change final TreeModel model = getTree().getModel(); model.valueForPathChanged(new TreePath(node.getPath()), node.getUserObject()); return checked; }
public void selectBreakpoints(Breakpoint[] breakpoints) { final List<CheckedTreeNode> nodes = new ArrayList<CheckedTreeNode>(breakpoints.length); for (Breakpoint breakpoint : breakpoints) { final CheckedTreeNode node = myDescriptorToNodeMap.get(new BreakpointDescriptor(breakpoint)); if (node != null) { nodes.add(node); } } clearSelection(); for (CheckedTreeNode node : nodes) { addSelectionPath(new TreePath(node.getPath())); } }
private void insertNewTool(final Tool newTool, boolean setSelection) { CheckedTreeNode groupNode = findGroupNode(newTool.getGroup()); if (groupNode == null) { groupNode = insertNewGroup(new ToolsGroup(newTool.getGroup())); nodeWasInserted(groupNode); } CheckedTreeNode tool = insertNewTool(groupNode, newTool); if (setSelection) { TreePath treePath = new TreePath(tool.getPath()); myTree.expandPath(treePath); myTree.getSelectionModel().setSelectionPath(treePath); } myIsModified = true; }
private void moveNode(final Direction direction) { CheckedTreeNode node = getSelectedNode(); if (node != null) { if (isMovingAvailable(node, direction)) { moveNode(node, direction); if (node.getUserObject() instanceof Tool) { ToolsGroup group = (ToolsGroup) (((CheckedTreeNode) node.getParent()).getUserObject()); Tool tool = (Tool) node.getUserObject(); moveElementInsideGroup(tool, group, direction); } TreePath path = new TreePath(node.getPath()); myTree.getSelectionModel().setSelectionPath(path); myTree.expandPath(path); myTree.requestFocus(); } } }
/** * @param parentDescriptor a descriptor of the childNode (possibly not existing) to attach to * @param childNode the childNode to be attached * @return either parent node if it has just been created or null, if the node has been attached * to already existing childNode */ private CheckedTreeNode attachNodeToParent( final TreeDescriptor parentDescriptor, final CheckedTreeNode childNode) { CheckedTreeNode parentNode = myDescriptorToNodeMap.get(parentDescriptor); try { if (parentNode != null) { parentNode.add(childNode); return null; // added to already existing, so stop iteration over appenders } parentNode = createNode(parentDescriptor); parentNode.add(childNode); return parentNode; } finally { if (parentNode != null && parentNode.getChildCount() == 1) { expandPath(new TreePath(parentNode.getPath())); } } }