Package javax.swing.tree

Examples of javax.swing.tree.TreeNode


  @Override
  public void reset() {
    this.mapping.clear();
    this.back.clear();
    TreeNode current = data;
    for (int counter = back.size(); current != null; counter++) {

      mapping.put(counter, new Data(current));
      back.put(current, counter);

      // if the node has children and is expanded, go to the children
      if (current.getChildCount() > 0 && expandedState.isExpanded(current)) {
        current = current.getChildAt(0);
      } else {
        current = getNextNodeButNoChild(current);
      }
    }
  }
View Full Code Here


  }

  @Override
  public void update(ExpandedState expandedState) {
    this.expandedState = expandedState;
    TreeNode current = data;
    int counter = back.size();
    while (current != null) {

      if (!back.containsKey(current)) {
        mapping.put(counter, new Data(current));
        back.put(current, counter);
        counter++;
      }

      // if the node has children and is expanded, go to the children
      if (current.getChildCount() > 0 && expandedState.isExpanded(current)) {
        current = current.getChildAt(0);
      } else {
        current = getNextNodeButNoChild(current);
      }
    }
  }
View Full Code Here

      }
    }
  }

  private TreeNode getNextNodeButNoChild(TreeNode node) {
    TreeNode next;
    while (true) {
      next = nextSibling(node);
      if (next != null) {
        break;
      }
View Full Code Here

    }
    return next;
  }

  private TreeNode nextSibling(TreeNode node) {
    TreeNode parent = node.getParent();
    if (parent == null) {
      return null;
    }
    for (int i = 0; i < parent.getChildCount() - 1; i++) {
      if (parent.getChildAt(i) == node) { // == is okay in this case
        return parent.getChildAt(i + 1);
      }
    }
    return null;
  }
View Full Code Here

  @Override
  public boolean isRowVisible() {
    if (!isRowAvailable()) {
      return false;
    }
    final TreeNode start = getRowData();
    if (start.getParent() == null) {
      return showRoot;
    }
    TreeNode node = start.getParent();
    while (node != null && back.get(node) != null) {
      final Data data = mapping.get(back.get(node));
      if (data.getNode().getParent() == null && !showRoot) {
        return true;
      }
      if (!expandedState.isExpanded(new TreePath(node))) {
        return false;
      }
      node = node.getParent();
    }
    return true;
  }
View Full Code Here

    }
  }

  public String getRowParentClientId() {
    if (isRowAvailable()) {
      final TreeNode parent = mapping.get(rowIndex).getNode().getParent();
      if (parent != null && back.get(parent) != null) {
        return mapping.get(back.get(parent)).getClientId();
      } else {
        return null;
      }
View Full Code Here

      return null;
    }
  }

  public List<Integer> getRowIndicesOfChildren() {
    final TreeNode node = getRowData();
    final int n = node.getChildCount();
    final List<Integer> children = new ArrayList<Integer>(n);
    for (int i = 0; i < n; i++) {
      final Integer integer = back.get(node.getChildAt(i));
      if (integer != null) { // integer == null happens, when the node is not expanded
        children.add(integer); // XXX is this a good way to handle that case?
      }
    }
    return children;
View Full Code Here

    return children;
  }

  @Override
  public List<Boolean> getJunctions() {
    TreeNode node = getRowData();
    final List<Boolean> junctions = new Stack<Boolean>();
    while (node != null) {
      junctions.add(hasNextSibling(node));
      node = node.getParent();
    }
    Collections.reverse(junctions);
    return junctions;
  }
View Full Code Here

    Collections.reverse(junctions);
    return junctions;
  }

  private boolean hasNextSibling(TreeNode node) {
    final TreeNode parent = node.getParent();
    return parent != null && parent.getChildAt(parent.getChildCount() - 1) != node;
  }
View Full Code Here

        buf.append( "filter:\n" );
        buf.append( filter );
        buf.append( "\n" );
        results.setFilter( buf.toString() );

        TreeNode astRoot = new ASTNode( null, root );
        TreeModel treeModel = new DefaultTreeModel( astRoot, true );
        results.setTreeModel( treeModel );
        results.setTableModel( tableModel );
        centerOnScreen( results );
        results.setVisible( true );
View Full Code Here

TOP

Related Classes of javax.swing.tree.TreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.