示例#1
0
 public TreeNavigatorNode getCategoryNode(String category) {
   for (TreeNavigatorNode node : root.getChildren()) {
     if (node.getTitle().equals(category)) {
       return node;
     }
   }
   return null;
 }
示例#2
0
 public void removeChild(TreeNavigatorNode parent, TreeNavigatorNode child) {
   int i = getIndexOfChild(parent, child);
   parent.removeChild(child);
   TreeModelEvent tme =
       new TreeModelEvent(this, parent.getTreePath(), new int[] {i}, new Object[] {child});
   for (TreeModelListener l : listeners) {
     l.treeNodesRemoved(tme);
   }
 }
示例#3
0
 public void addChild(
     TreeNavigatorNode parent, TreeNavigatorNode child, TreeNavigatorNode previousSibling) {
   // int i = parent.getChildCount();
   int p = parent.addChild(child, previousSibling);
   TreeModelEvent tme =
       new TreeModelEvent(this, parent.getTreePath(), new int[] {p}, new Object[] {child});
   for (TreeModelListener l : listeners) {
     l.treeNodesInserted(tme);
   }
 }
示例#4
0
 public List<String> getAllTitles() {
   List<String> result = new LinkedList<String>();
   BreadthFirstSearch bfs = new BreadthFirstSearch(this);
   TreePath path;
   do {
     path = bfs.next();
     if (path != null) {
       TreeNavigatorNode node = (TreeNavigatorNode) path.getLastPathComponent();
       result.add(node.getTitle());
     }
   } while (path != null);
   return result;
 }
示例#5
0
 protected void fireNodeChanged(TreeNavigatorNode node) {
   TreePath pathToParent;
   if (node.getParent() == null) {
     pathToParent = new TreePath(getRoot());
   } else {
     pathToParent = node.getParent().getTreePath();
   }
   int[] c = new int[] {getIndexOfChild(pathToParent.getLastPathComponent(), node)};
   TreeModelEvent tme = new TreeModelEvent(this, pathToParent, c, new Object[] {node});
   for (TreeModelListener l : listeners) {
     l.treeNodesChanged(tme);
   }
 }
示例#6
0
  public TreeNavigatorNode find(JComponent comp) {
    BreadthFirstSearch bfs = new BreadthFirstSearch(this);
    TreePath path;

    do {
      path = bfs.next();
      if (path != null) {
        TreeNavigatorNode node = (TreeNavigatorNode) path.getLastPathComponent();
        if (node.getComponent() == comp) {
          return node;
        }
      }
    } while (path != null);
    return null;
  }
示例#7
0
  /**
   * Returns the components managed by this <tt>TreeNavigatorModel</tt> in reverse BFS order
   *
   * @return
   */
  public List<JComponent> getComponents() {
    LinkedList<JComponent> result = new LinkedList<JComponent>();
    BreadthFirstSearch bfs = new BreadthFirstSearch(this);
    TreePath path;
    do {
      path = bfs.next();
      if (path != null) {
        TreeNavigatorNode node = (TreeNavigatorNode) path.getLastPathComponent();
        if (node.getComponent() != null) {
          result.addFirst(node.getComponent());
        }
      }

    } while (path != null);
    return result;
  }
示例#8
0
 public void setTitle(TreeNavigatorNode node, String title) {
   node.setTitle(title);
   fireNodeChanged(node);
 }