Package javax.swing.tree

Examples of javax.swing.tree.TreeModel


    return count;
  }

  public void expandAll(TreePath path) {
    expandPath(path);
    TreeModel model = getModel();
    if (path != null && model != null) {
      Object comp = path.getLastPathComponent();
      int cnt = model.getChildCount(comp);
      for (int i = 0; i < cnt; i++) {
        Object node = model.getChild(comp, i);
        expandAll(path.pathByAddingChild(node));
      }
    }
  }
View Full Code Here


      }
    }
  }

  public void collapseAll(TreePath path) {
    TreeModel model = getModel();
    if (path != null && model != null) {
      Object comp = path.getLastPathComponent();
      int cnt = model.getChildCount(comp);
      for (int i = 0; i < cnt; i++) {
        Object node = model.getChild(comp, i);
        collapseAll(path.pathByAddingChild(node));
      }
      if (!path.getLastPathComponent().equals(model.getRoot())) {
        collapsePath(path);
      }
    }
  }
View Full Code Here

        public void treeWillCollapse(TreeExpansionEvent event) throws ExpandVetoException {
        }

        private void notifyChange(final RepoTreeNode pNode) {
            synchronized (RepoTree.this) {
                final TreeModel model = getModel();
                if (!(model instanceof RepoTreeModel))
                    return;

                //
                //make sure the node that fired this change still belongs
                //to our model (if the model was swapped in the middle of
                //a fetch operation, this can happen)
                //
                TreeNode parent = pNode;
                while (parent != null && parent.getParent() != null) parent = parent.getParent();
                if (parent == null || !parent.equals(model.getRoot()))
                    return;

                //
                //notify that the structure of the given node has been changed
                //
View Full Code Here

    public RepositoryTreeExpander(final JTree pTree) {
        tree = pTree;
    }

    public boolean canCollapse() {
        final TreeModel model = tree.getModel();

        final Object root = model.getRoot();
        if (tree.isCollapsed(new TreePath(root)))
            return false;

        final Object[] treePath = new Object[2];
        treePath[0] = root;

        final int childCount = model.getChildCount(root);
        for (int i = 0; i < childCount; i++) {
            treePath[1] = model.getChild(root, i);
            if (tree.isExpanded(new TreePath(treePath)))
                return true;
        }

        return false;
View Full Code Here

    public boolean canExpand() {
        return false;
    }

    public void collapseAll() {
        final TreeModel model = tree.getModel();

        final Object root = model.getRoot();
        final Object[] treePath = new Object[2];
        treePath[0] = root;

        final int childCount = model.getChildCount(root);
        for (int i = 0; i < childCount; i++) {
            treePath[1] = model.getChild(root, i);
            tree.collapsePath(new TreePath(treePath));
        }
    }
View Full Code Here


  public TreeModel getTreeModel() {
    ValueBinding valueBinding = getValueBinding("value");
    if(valueBinding != null){
      TreeModel treeModel = (TreeModel) valueBinding.getValue(getFacesContext());
      return treeModel;
    }
    return null;
  }
View Full Code Here

    // 4. Check alphabetical order of categories and furniture in tree
    assertTreeIsSorted(tree);
  }
 
  public void assertTreeIsSorted(JTree tree) {
    TreeModel model = tree.getModel();
    Object    root  = model.getRoot();
    Collator  comparator = Collator.getInstance();
    // For each category
    for (int i = 0, n = model.getChildCount(root); i < n; i++) {
      Object rootChild = model.getChild(root, i);
      if (i < n - 1) {
        Object nextChild = model.getChild(root, i + 1);
        // Check alphatical order of categories nodes in tree
        assertTrue("Categories not sorted", comparator.compare(
            getNodeText(tree, rootChild),
            getNodeText(tree, nextChild)) <= 0);
      }
      // For each piece of furniture of a category
      for (int j = 0, m = model.getChildCount(rootChild) - 1;
           j < m; j++) {
        Object child = model.getChild(rootChild, j);
        if (j < m - 1) {
          Object nextChild = model.getChild(rootChild, j + 1);
          // Check alphatical order of furniture nodes in tree
          assertTrue("Furniture not sorted", comparator.compare(
              getNodeText(tree, child),
              getNodeText(tree, nextChild)) <= 0);
        }
        assertTrue("Piece not a leaf", model.isLeaf(child));
      }
    }
  }
View Full Code Here

        treesCardLayout.show(treesPanel, repoName);

        //
        //later on, start fetching the root node
        //
        final TreeModel model = repoTree.getModel();
        if (model instanceof RepoTreeModel) {
            final RepoTreeModel repoModel = (RepoTreeModel) model;
            repoTree.fetchNode(repoModel.getRoot());
        }
        return repoTree;
View Full Code Here

        if (currentRepo == null)
            return null;

        final Collection<RepoTree> trees = repos.values();
        for (RepoTree tree : trees) {
            final TreeModel treeModel = tree.getModel();
            if (!(treeModel instanceof RepoTreeModel))
                continue;

            final RepoTreeModel model = (RepoTreeModel) treeModel;
            final RepoTreeNode root = model.getRoot();
View Full Code Here

        for (Category category : categories) {
          DefaultMutableTreeNode categoryNode = new DefaultMutableTreeNode(category);
          rootNode.add(categoryNode);
        }

        TreeModel treeModel = new DefaultTreeModel(rootNode);
        _categoryTree.setModel(treeModel);
      }
    }.start();
  }
View Full Code Here

TOP

Related Classes of javax.swing.tree.TreeModel

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.