javax.swing.JTree.getExpandedDescendants()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.6k)|赞(0)|评价(0)|浏览(129)

本文整理了Java中javax.swing.JTree.getExpandedDescendants()方法的一些代码示例,展示了JTree.getExpandedDescendants()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTree.getExpandedDescendants()方法的具体详情如下:
包路径:javax.swing.JTree
类名称:JTree
方法名:getExpandedDescendants

JTree.getExpandedDescendants介绍

暂无

代码示例

代码示例来源:origin: sdedit/sdedit

public List<TreePath> getVisibleNodes() {
  List<TreePath> result = new LinkedList<TreePath>();
  Enumeration<TreePath> paths = tree.getExpandedDescendants(new TreePath(
      tree.getModel().getRoot()));
  if (paths != null) {
    while (paths.hasMoreElements()) {
      result.add(paths.nextElement());
    }
  }
  return result;
}

代码示例来源:origin: tinyMediaManager/tinyMediaManager

private List<TreePath> getCurrExpandedPaths(JTree tree) {
 List<TreePath> paths = new ArrayList<>();
 Enumeration<TreePath> expandEnum = tree.getExpandedDescendants(new TreePath(root.getPath()));
 if (expandEnum == null) {
  return null;
 }
 while (expandEnum.hasMoreElements()) {
  paths.add(expandEnum.nextElement());
 }
 return paths;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-lib-profiler-ui

/**
 * Returns a list of open paths in the tree, can be used to
 * re-open the paths in a tree after a call to 'treeStructureChanged'
 * (which causes all open paths to collapse)
 */
public List getExpandedPaths() {
  Enumeration expanded = tree.getExpandedDescendants(getRootPath());
  List paths = new ArrayList();
  if (expanded != null) {
    while (expanded.hasMoreElements()) {
      paths.add(expanded.nextElement());
    }
  }

  return paths;
}

代码示例来源:origin: net.sf.taverna.t2.ui-components/results-view

private void rememberPaths() {
expandedPaths.clear();
for (Enumeration e = resultsTree.getExpandedDescendants(new TreePath(filteredTreeModel.getRoot())); (e != null) && e.hasMoreElements();) {
  expandedPaths.add((TreePath) e.nextElement());
}
selectionPath = resultsTree.getSelectionPath();
}

代码示例来源:origin: net.sf.taverna.t2.ui-components/results-view

private void rememberPaths() {
expandedPaths.clear();
for (Enumeration e = processorEnactmentsTree.getExpandedDescendants(new TreePath(filteredTreeModel.getRoot())); (e != null) && e.hasMoreElements();) {
  expandedPaths.add((TreePath) e.nextElement());
}
selectionPath = processorEnactmentsTree.getSelectionPath();
}

代码示例来源:origin: net.sf.taverna.t2.ui-components/results-view

private void rememberPaths() {
expandedPaths.clear();
for (Enumeration e = tree.getExpandedDescendants(new TreePath(filteredTreeModel.getRoot())); (e != null) && e.hasMoreElements();) {
  expandedPaths.add((TreePath) e.nextElement());
}
selectionPath = tree.getSelectionPath();
}

代码示例来源:origin: net.sf.sfac/sfac-core

private static void collapseNodesOfLevels(JTree tree, TreePath basePath, int fromLevel) {
  TreePath path;
  int level;
  Enumeration<TreePath> expandedEnum = tree.getExpandedDescendants(basePath);
  if (expandedEnum != null) {
    List<TreePath> expandedList = new ArrayList<TreePath>();
    for (; expandedEnum.hasMoreElements();)
      expandedList.add(expandedEnum.nextElement());
    Collections.sort(expandedList, PATH_SORTER);
    int len = expandedList.size();
    for (int i = 0; i < len; i++) {
      path = expandedList.get(i);
      level = path.getPathCount();
      if (level > fromLevel) {
        tree.collapsePath(path);
      }
    }
  }
}

代码示例来源:origin: net.sf.ingenias/editor

public void reload(){
 Enumeration expanded=arbolObjetos.getExpandedDescendants(new TreePath(root.getPath()));
 ((DefaultTreeModel)arbolObjetos.getModel()).reload();
 while (expanded!=null && expanded.hasMoreElements()){
  TreePath tp=(TreePath)expanded.nextElement();
  arbolObjetos.expandPath(tp);
 }
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

void sortingChanged() {
  // PENDING: remember the last sorting to avoid multiple sorting
  // remenber expanded folders
  TreeNode tn = (TreeNode) (this.getRoot());
  java.util.List<TreePath> list = new ArrayList<TreePath>();
  Enumeration<TreePath> en = TreeTableView.this.tree.getExpandedDescendants(new TreePath(tn));
  while ((en != null) && en.hasMoreElements()) {
    TreePath path = en.nextElement();
    // bugfix #32328, don't sort whole subtree but only expanded folders
    Node n = ((VisualizerNode) path.getLastPathComponent ()).node;
    ((SortedChildren) n.getChildren ()).sortNodes ();
    list.add(path);
  }
  // expand again folders
  for (int i = 0; i < list.size(); i++) {
    TreeTableView.this.tree.expandPath(list.get(i));
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

void sortingChanged() {
  // PENDING: remember the last sorting to avoid multiple sorting
  
  // remenber expanded folders
  TreeNode tn = (TreeNode)(this.getRoot());
  java.util.List list = new ArrayList();
  Enumeration en = TreeTableView.this.tree.getExpandedDescendants( new TreePath( tn ) );
  while ( en != null && en.hasMoreElements() ) {
    TreePath path = (TreePath)en.nextElement();
    // bugfix #32328, don't sort whole subtree but only expanded folders
    sortChildren ((VisualizerNode)path.getLastPathComponent (), true);
    list.add( path );
  }
  
  // expand again folders
  for (int i=0; i<list.size(); i++) {
    TreeTableView.this.tree.expandPath( (TreePath)list.get( i ) );
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

void sortingChanged() {
  // PENDING: remember the last sorting to avoid multiple sorting
  
  // remenber expanded folders
  TreeNode tn = (TreeNode)(this.getRoot());
  java.util.List list = new ArrayList();
  Enumeration en = TreeTableView.this.tree.getExpandedDescendants( new TreePath( tn ) );
  while ( en != null && en.hasMoreElements() ) {
    TreePath path = (TreePath)en.nextElement();
    // bugfix #32328, don't sort whole subtree but only expanded folders
    sortChildren ((VisualizerNode)path.getLastPathComponent (), true);
    list.add( path );
  }
  
  // expand again folders
  for (int i=0; i<list.size(); i++) {
    TreeTableView.this.tree.expandPath( (TreePath)list.get( i ) );
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

public void treeExpanded (TreeExpansionEvent event) {
  TreePath path = event.getPath ();
  if (path != null) {
    // bugfix $32480, store and recover currently expanded subnodes
    // store expanded paths
    Enumeration en = TreeTableView.this.tree.getExpandedDescendants (path);
    // sort children
    getSortedNodeTreeModel ().sortChildren ((VisualizerNode)path.getLastPathComponent (), true);
    // expand again folders
    while (en.hasMoreElements ()) {
      TreeTableView.this.tree.expandPath ((TreePath)en.nextElement ());
    }
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

public void treeExpanded (TreeExpansionEvent event) {
  TreePath path = event.getPath ();
  if (path != null) {
    // bugfix $32480, store and recover currently expanded subnodes
    // store expanded paths
    Enumeration en = TreeTableView.this.tree.getExpandedDescendants (path);
    // sort children
    getSortedNodeTreeModel ().sortChildren ((VisualizerNode)path.getLastPathComponent (), true);
    // expand again folders
    while (en.hasMoreElements ()) {
      TreeTableView.this.tree.expandPath ((TreePath)en.nextElement ());
    }
  }
}

代码示例来源:origin: nl.cloudfarming.client/nbtaskfocus-core

public List<String[]> getExpandedPaths() {
  List<String[]> result = new ArrayList<String[]>();
  TreeNode rtn = Visualizer.findVisualizer(getRootContext());
  TreePath tp = new TreePath(rtn); // Get the root
  Enumeration<TreePath> paths = tree.getExpandedDescendants(tp);
  if (null != paths) {
    while (paths.hasMoreElements()) {
      TreePath ep = paths.nextElement();
      Node en = Visualizer.findNode(ep.getLastPathComponent());
      String[] path = NodeOp.createPath(en, getRootContext());  
      result.add(path);
    }
  }
  return result;
}

代码示例来源:origin: triplea-game/triplea

root = root.getParentPath();
final Enumeration<TreePath> expandedDescendants = tree.getExpandedDescendants(root);
final TreePath selectedPath = tree.getSelectionPath();

代码示例来源:origin: RPTools/maptool

Enumeration<TreePath> expandedPaths = tree.getExpandedDescendants(new TreePath(root));

代码示例来源:origin: org.orbisgis/orbisgis-view

protected void fireEvent() {
  TreePath root = new TreePath(getRoot());
  Enumeration<TreePath> paths = tree.getExpandedDescendants(root);
  TreePath[] selection = tree.getSelectionPaths();
  TreeModelEvent e = new TreeModelEvent(this, root);
  for (TreeModelListener tml : treeModelListeners){
    tml.treeStructureChanged(e);
  }
  if (paths != null) {
    while (paths.hasMoreElements()) {
      tree.expandPath(paths.nextElement());
    }
  }
  if (selection != null) {
    tree.addSelectionPaths(selection);
  }
}

代码示例来源:origin: orbisgis/orbisgis

protected void fireEvent() {
  TreePath root = new TreePath(getRoot());
  Enumeration<TreePath> paths = tree.getExpandedDescendants(root);
  TreePath[] selection = tree.getSelectionPaths();
  TreeModelEvent e = new TreeModelEvent(this, root);
  for (TreeModelListener tml : treeModelListeners){
    tml.treeStructureChanged(e);
  }
  if (paths != null) {
    while (paths.hasMoreElements()) {
      tree.expandPath(paths.nextElement());
    }
  }
  if (selection != null) {
    tree.addSelectionPaths(selection);
  }
}

代码示例来源:origin: net.sourceforge.jadex/jadex-tools-base-swing

: NodePath.createNodePath((ISwingTreeNode)getTree().getSelectionPath().getLastPathComponent()));
List    expanded    = new ArrayList();
Enumeration exp = getTree().getExpandedDescendants(new TreePath(root));
if(exp!=null)

代码示例来源:origin: triplea-game/triplea

root = root.getParentPath();
 final Enumeration<TreePath> expandedDescendants = tree.getExpandedDescendants(root);
 addToStayExpanded(expandedDescendants);
} else {

相关文章

JTree类方法