public int getChildCount(java.lang.Object parent) { int superCnt = super.getChildCount (parent); int myCnt = 0; for (int i = 0; i < superCnt; i++) { Node n = Visualizer.findNode (super.getChild (parent, i)); if (!n.isLeaf ()) { myCnt++; } } return myCnt; }
/** Create a new model. * The default implementation creates a {@link NodeTreeModel}. * @return the model */ protected NodeTreeModel createModel() { return new NodeTreeModel (); }
TreePath getTreePath(Node node) { return new TreePath(treeModel.getPathToRoot(VisualizerNode.getVisualizer(null, node))); }
/** Creates new NodeTreeModel * @param root the root of the model */ public NodeTreeModel (Node root) { super (VisualizerNode.EMPTY, true); setNode (root); }
/** Notification about large change in the sub tree */ public void structuralChange(VisualizerNode v) { NodeTreeModel m = get (null); if (m == null) return; m.nodeStructureChanged(v); }
/** * This sets the user object of the TreeNode identified by path * and posts a node changed. If you use custom user objects in * the TreeModel you'returngoing to need to subclass this and * set the user object of the changed node to something meaningful. */ public void valueForPathChanged(TreePath path, Object newValue) { if (path == null) return; Object o = path.getLastPathComponent(); if (o instanceof VisualizerNode) { nodeChanged ((VisualizerNode)o); return; } MutableTreeNode aNode = (MutableTreeNode)o; aNode.setUserObject(newValue); nodeChanged(aNode); }
public int getChildCount (Object o) { Node n = Visualizer.findNode(o); DataObject obj = (DataObject)n.getCookie (DataObject.class); return obj == null || obj.isTemplate () ? 0 : super.getChildCount (o); }
/** Notification that children has been removed. Modifies the list of nodes * and fires info to all listeners. */ public void removed (VisualizerEvent.Removed ev) { NodeTreeModel m = get (ev); if (m == null) return; m.nodesWereRemoved (ev.getVisualizer (), ev.getArray (), ev.removed.toArray ()); }
public void setRoot(TreeNode root) { super.setRoot (root); if (root instanceof VisualizerNode && isSortingActive ()) { sortChildren ((VisualizerNode)root, false); } }
/** Changes the root of the model. This is thread safe method. * @param root the root of the model */ public void setNode(final Node root) { setNode(root, null); }
/** Notification about large change in the sub tree */ @Override public void structuralChange(VisualizerNode v) { NodeTreeModel m = get(null); if (m == null) { return; } m.nodeStructureChanged(v); } }
/** * This sets the user object of the TreeNode identified by path * and posts a node changed. If you use custom user objects in * the TreeModel you'returngoing to need to subclass this and * set the user object of the changed node to something meaningful. */ public void valueForPathChanged(TreePath path, Object newValue) { if (path == null) return; Object o = path.getLastPathComponent(); if (o instanceof VisualizerNode) { nodeChanged ((VisualizerNode)o); return; } MutableTreeNode aNode = (MutableTreeNode)o; aNode.setUserObject(newValue); nodeChanged(aNode); }
/** Notification that children has been removed. Modifies the list of nodes * and fires info to all listeners. */ public void removed (VisualizerEvent.Removed ev) { NodeTreeModel m = get (ev); if (m == null) return; m.nodesWereRemoved (ev.getVisualizer (), ev.getArray (), ev.removed.toArray ()); }
public void setRoot(TreeNode root) { super.setRoot (root); if (root instanceof VisualizerNode && isSortingActive ()) { sortChildren ((VisualizerNode)root, false); } }
public int getChildCount(java.lang.Object parent) { int superCnt = super.getChildCount(parent); int myCnt = 0; for (int i = 0; i < superCnt; i++) { Node n = Visualizer.findNode(super.getChild(parent, i)); if (!n.isLeaf()) { myCnt++; } } return myCnt; }
/** Collapses the tree under given node. * * @param n node to collapse */ public void collapseNode (Node n) { TreePath treePath = new TreePath ( treeModel.getPathToRoot ( VisualizerNode.getVisualizer (null, n) ) ); tree.collapsePath (treePath); }
@Override public void run() { VisualizerNode v = (VisualizerNode) getRoot(); VisualizerNode nr = VisualizerNode.getVisualizer(null, root); if (v == nr) { // no change return; } v.removeNodeModel(listener()); nr.addNodeModel(listener()); setRoot(nr); if (visHolder != null) { visHolder.add(nr.getChildren()); visHolder.removeRecur(v.getChildren()); } } }
/** Creates new NodeTreeModel * @param root the root of the model */ public NodeTreeModel (Node root) { super (VisualizerNode.EMPTY, true); setNode (root); }