当前位置: 首页>>代码示例>>Java>>正文


Java JTree.expandPath方法代码示例

本文整理汇总了Java中javax.swing.JTree.expandPath方法的典型用法代码示例。如果您正苦于以下问题:Java JTree.expandPath方法的具体用法?Java JTree.expandPath怎么用?Java JTree.expandPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JTree的用法示例。


在下文中一共展示了JTree.expandPath方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: restoreExpansionState

import javax.swing.JTree; //导入方法依赖的package包/类
/**
 * Expands all repositories and nodes, which have been saved before. Restores selected paths,
 * which have been saved proviously.
 *
 * @param tree
 *            The related tree, containing the path(s)
 */
public void restoreExpansionState(JTree tree) {
	for (int i = 0; i < tree.getRowCount(); i++) {
		TreePath path = tree.getPathForRow(i);
		Object entryObject = path.getLastPathComponent();
		if (entryObject instanceof Entry) {
			Entry entry = (Entry) entryObject;
			String absoluteLocation = entry.getLocation().getAbsoluteLocation();
			if (expandedRepositories.contains(absoluteLocation) || expandedNodes.contains(absoluteLocation)) {
				tree.expandPath(path);
			}
		}
	}

	restoreSelectionPaths(tree);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:23,代码来源:RepositoryTreeUtil.java

示例2: expandAll

import javax.swing.JTree; //导入方法依赖的package包/类
private void expandAll(JTree tree, TreePath path, boolean expand) {
    TreeNode node = (TreeNode) path.getLastPathComponent();

    if (node.getChildCount() >= 0) {
        Enumeration enumeration = node.children();
        while (enumeration.hasMoreElements()) {
            TreeNode n = (TreeNode) enumeration.nextElement();
            TreePath p = path.pathByAddingChild(n);

            expandAll(tree, p, expand);
        }
    }

    if (expand) {
        tree.expandPath(path);
    } else {
        tree.collapsePath(path);
    }
}
 
开发者ID:HML-UnBBayes,项目名称:hml,代码行数:20,代码来源:TreePanel.java

示例3: restoreExpandedNodes

import javax.swing.JTree; //导入方法依赖的package包/类
static void restoreExpandedNodes(JTree tree, UIState uiState) {
    try {
        tree.putClientProperty(UIUtils.PROP_EXPANSION_TRANSACTION, Boolean.TRUE);
        Enumeration<TreePath> paths = uiState.getExpandedPaths();
        if (paths != null) while (paths.hasMoreElements())
            tree.expandPath(paths.nextElement());
    } finally {
        tree.putClientProperty(UIUtils.PROP_EXPANSION_TRANSACTION, null);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ProfilerTreeTable.java

示例4: getPath

import javax.swing.JTree; //导入方法依赖的package包/类
private TreePath getPath(JTree tree, String path) {
    String[] tokens = path.substring(1).split("(?<!\\\\)/");
    TreeModel treeModel = tree.getModel();
    if (treeModel == null) {
        throw new RuntimeException("Could not find model for tree");
    }
    Object rootNode = treeModel.getRoot();
    int start = tree.isRootVisible() ? 1 : 0;
    TreePath treePath = new TreePath(rootNode);
    StringBuilder searchedPath = new StringBuilder();
    if (tree.isRootVisible()) {
        String rootNodeText = unescapeSpecialCharacters(tokens[0]);
        searchedPath.append("/" + rootNodeText);
        assertTrue("JTree does not have a root node!", rootNode != null);
        assertTrue("JTree root node does not match: Expected </" + getPathText(tree, treePath) + "> Actual: <"
                + searchedPath.toString() + ">", searchedPath.toString().equals("/" + getPathText(tree, treePath)));
    }
    for (int i = start; i < tokens.length; i++) {
        String childText = unescapeSpecialCharacters(tokens[i]);
        searchedPath.append("/" + childText);
        boolean matched = false;
        tree.expandPath(treePath);
        for (int j = 0; j < treeModel.getChildCount(treePath.getLastPathComponent()); j++) {
            Object child = treeModel.getChild(treePath.getLastPathComponent(), j);
            TreePath childPath = treePath.pathByAddingChild(child);
            if (childText.equals(getPathText(tree, childPath))) {
                treePath = childPath;
                matched = true;
                break;
            }
        }
        if (!matched) {
            return null;
        }
    }
    return treePath;
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:38,代码来源:JTreeJavaElement.java

示例5: expandAll

import javax.swing.JTree; //导入方法依赖的package包/类
private void expandAll(final JTree tree, final TreePath parent) {
  final TreeNode node = (TreeNode) parent.getLastPathComponent();
  if (node.getChildCount() >= 0) {
    for (@SuppressWarnings("rawtypes")
    final Enumeration e = node.children(); e.hasMoreElements();) {
      final TreeNode n = (TreeNode) e.nextElement();
      final TreePath path = parent.pathByAddingChild(n);
      this.expandAll(tree, path);
    }
  }
  tree.expandPath(parent);
  // tree.collapsePath(parent);
}
 
开发者ID:ModelWriter,项目名称:Tarski,代码行数:14,代码来源:MappingWizard.java

示例6: expandAll

import javax.swing.JTree; //导入方法依赖的package包/类
private void expandAll(JTree tree, TreePath path) {
    tree.expandPath(path);
    TreeModel model = tree.getModel();
    Object lastComponent = path.getLastPathComponent();
    for (int i = 0; i < model.getChildCount(lastComponent); i++) {
        expandAll(tree,
                path.pathByAddingChild(model.getChild(lastComponent, i)));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:GUIBrowser.java

示例7: closeAllPaths

import javax.swing.JTree; //导入方法依赖的package包/类
public void closeAllPaths(JTree tree) {
	TreePath pathToRoot = new TreePath(tree.getModel().getRoot());
	closePaths(tree, pathToRoot);
	if (!tree.isRootVisible())
		tree.expandPath(pathToRoot);
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:7,代码来源:MapPlaces.java

示例8: closeAllPaths

import javax.swing.JTree; //导入方法依赖的package包/类
public static void closeAllPaths(JTree tree) {
	TreePath pathToRoot = new TreePath(tree.getModel().getRoot());
	closePaths(tree, pathToRoot);
	if (!tree.isRootVisible())
		tree.expandPath(pathToRoot);
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:7,代码来源:XML_Menu.java

示例9: expand

import javax.swing.JTree; //导入方法依赖的package包/类
/**
 * Expands stored treepaths in JTree
 * <p>
 * If model has been changed (eg. project change) we
 * still try to expand paths whick do not exist.
 * We just assume that this is not causing problems,
 * and as a side effect it preserved tree expansion status
 * even after project has been changed to some other project 
 * and then back.
 * </p>
 * <p>
 * It is possible that there will be memory leak
 * if expanded paths have been removed from model, but
 * effect of this is quite insignificant.
 * </p>
 */
public void expand(JTree tree){
	Iterator iter = expanded.iterator();
	while(iter.hasNext()){
		tree.expandPath( (TreePath) iter.next() );
	}
	System.out.println(expanded.size());
}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:24,代码来源:TaskTable.java

示例10: expand

import javax.swing.JTree; //导入方法依赖的package包/类
/**
 * Expands stored treepaths in JTree
 * <p>
 * If model has been changed (eg. project change) we
 * still try to expand paths whick do not exist.
 * We just assume that this is not causing problems,
 * and as a side effect it preserved tree expansion status
 * even after project has been changed to some other project 
 * and then back.
 * </p>
 * <p>
 * It is possible that there will be memory leak
 * if expanded paths have been removed from model, but
 * effect of this is quite insignificant.
 * </p>
 */
public void expand(JTree tree){
	Iterator iter = expanded.iterator();
	while(iter.hasNext()){
		tree.expandPath( (TreePath) iter.next() );
	}
	Util.debug(Integer.toString(expanded.size()));
}
 
开发者ID:ser316asu,项目名称:SER316-Dresden,代码行数:24,代码来源:TaskTable.java


注:本文中的javax.swing.JTree.expandPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。