/** * A tool group has been added. Batched adds will come through the toolsAdded method. * * @param evt The event that caused this method to be called */ public void toolGroupAdded(ToolGroupEvent evt) { ToolGroup group = (ToolGroup) evt.getSource(); ToolGroup tool = (ToolGroup) evt.getChild(); TreePath path = buildTreePath(group); // System.out.println("group added " + group.getName() + " kid " + tool.getName()); Object[] children = new Object[1]; int[] indicies = new int[1]; int index; ToolGroupTreeNode parent = (ToolGroupTreeNode) path.getLastPathComponent(); ToolGroupTreeNode child = new ToolGroupTreeNode(tool, parent); parent.insert(child, parent.getChildCount()); index = getIndexOfChild(parent, child); indicies[0] = index; children[0] = child; TreeModelEvent treeEvent = new TreeModelEvent(this, path, indicies, children); fireTreeNodesInserted(treeEvent); tool.addToolGroupListener(this); }
/** * A tool has been removed. Batched removes will come through the toolsRemoved method. * * @param evt The event that caused this method to be called */ public void toolRemoved(ToolGroupEvent evt) { ToolGroup group = (ToolGroup) evt.getSource(); SimpleTool tool = (SimpleTool) evt.getChild(); TreePath path = buildTreePath(group); Object[] children = new Object[1]; int[] indicies = new int[1]; int index; ToolGroupTreeNode parent = (ToolGroupTreeNode) path.getLastPathComponent(); ToolGroupTreeNode child = parent.getTreeNodeChild(tool); index = getIndexOfChild(parent, child); indicies[0] = index; children[0] = child; parent.remove(child); TreeModelEvent treeEvent = new TreeModelEvent(this, path, indicies, children); fireTreeNodesRemoved(treeEvent); }