コード例 #1
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;
 }
コード例 #2
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;
  }
コード例 #3
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;
  }