public TreeModelEvent refactorEvent(TreeModelEvent event) { if (visibleNodes != null) { List<Object> children = new ArrayList<Object>(event.getChildren().length); List<Integer> indicieList = new ArrayList<Integer>(event.getChildIndices().length); for (Object node : event.getChildren()) { visibleNodes.add(node); } Object parent = event.getTreePath().getLastPathComponent(); for (Object node : event.getChildren()) { children.add(node); indicieList.add(getIndexOfChild(parent, node)); } int[] indicies = new int[indicieList.size()]; for (int i = 0; i < indicies.length; i++) { indicies[i] = indicieList.get(i); } event = new TreeModelEvent( event.getSource(), event.getTreePath(), indicies, children.toArray(new Object[0])); } return event; }
@Override public void treeNodesInserted(TreeModelEvent e) { Category c = (Category) e.getTreePath().getLastPathComponent(); dispatchEvent(MenuToolbar.SYNCUPLOAD, c); final TreePath path = e.getTreePath(); SwingUtilities.invokeLater( new Runnable() { public void run() { mainFrame.tree.expandPath(path); // tree.setSelectionPath(path); } }); }
@Override public void treeNodesChanged(TreeModelEvent e) { if (adjusting) { return; } adjusting = true; TreePath parent = e.getTreePath(); Object[] children = e.getChildren(); DefaultTreeModel model = (DefaultTreeModel) e.getSource(); DefaultMutableTreeNode node; CheckBoxNode c; // = (CheckBoxNode)node.getUserObject(); if (children != null && children.length == 1) { node = (DefaultMutableTreeNode) children[0]; c = (CheckBoxNode) node.getUserObject(); onCheckboxStatusChanged(node); DefaultMutableTreeNode n = (DefaultMutableTreeNode) parent.getLastPathComponent(); while (n != null) { updateParentUserObject(n); DefaultMutableTreeNode tmp = (DefaultMutableTreeNode) n.getParent(); if (tmp == null) { break; } else { n = tmp; } } model.nodeChanged(n); } else { node = (DefaultMutableTreeNode) model.getRoot(); c = (CheckBoxNode) node.getUserObject(); } updateAllChildrenUserObject(node, c.status); model.nodeChanged(node); adjusting = false; }
@Override public void treeNodesInserted(TreeModelEvent e) { if (isExpanded) { return; } isExpanded = true; subjectExplorer.expandPath(e.getTreePath()); }
public void treeStructureChanged(TreeModelEvent event) { if (!isVisible(event.getTreePath().getLastPathComponent())) { return; } for (TreeModelListener listener : listeners) { listener.treeStructureChanged(event); } }
public void treeNodesInserted(TreeModelEvent event) { if (!isVisible(event.getTreePath().getLastPathComponent())) { return; } event = refactorEvent(event); for (TreeModelListener listener : listeners) { listener.treeNodesInserted(event); } }
public void treeNodesChanged(TreeModelEvent e) { DefaultMutableTreeNode node; node = (DefaultMutableTreeNode) (e.getTreePath().getLastPathComponent()); int index = e.getChildIndices()[0]; node = (DefaultMutableTreeNode) (node.getChildAt(index)); System.out.println("The user has finished editing the node."); System.out.println("New value: " + node.getUserObject()); }
public void treeNodesChanged(TreeModelEvent e) { DefaultMutableTreeNode node; node = (DefaultMutableTreeNode) (e.getTreePath().getLastPathComponent()); /* * If the event lists children, then the changed * node is the child of the node we've already * gotten. Otherwise, the changed node and the * specified node are the same. */ int index = e.getChildIndices()[0]; node = (DefaultMutableTreeNode) (node.getChildAt(index)); System.out.println("The user has finished editing the node."); System.out.println("New value: " + node.getUserObject()); }
@Override public void treeStructureChanged(TreeModelEvent e) { Category c = (Category) e.getTreePath().getLastPathComponent(); dispatchEvent(MenuToolbar.SYNCUPLOAD, c.parent); }
@Override public void treeStructureChanged(TreeModelEvent event) { DefaultMutableTreeNode node = (DefaultMutableTreeNode) event.getTreePath().getLastPathComponent(); if (node.getUserObject() instanceof PeakList) rebuildPeakListSelector(); }