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


Java TreePath.getPath方法代码示例

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


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

示例1: hasAsParent

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
/**
 * implementation of JTreeOperator.TreePathChooser
 *
 * @param path TreePath
 * @param indexInParent int
 * @return boolean
 */
@Override
public boolean hasAsParent(TreePath path, int indexInParent) {
    if (path.getPathCount() <= parentPathCount) {
        return path.isDescendant(parentPath);
    }
    if (arr.length + parentPathCount < path.getPathCount()) {
        return (false);
    }
    if (indices.length >= path.getPathCount() - parentPathCount
            && indices[path.getPathCount() - parentPathCount - 1] != indexInParent) {
        return (false);
    }
    Object[] comps = path.getPath();
    for (int i = parentPathCount; i < comps.length; i++) {
        if (!comparator.equals(comps[i].toString(), arr[i - parentPathCount])) {
            return (false);
        }
    }
    return (true);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:Node.java

示例2: getSelectedNodes

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
/**
 * @return {@link List} of the currently selected nodes
 */
public List<String> getSelectedNodes() {
    TreePath[] paths = tree.getSelectionPaths();
    List<String> selectedNodes = new ArrayList<String>();
    if (paths != null) {
        for (TreePath path : paths) {
            StringBuilder sb = new StringBuilder();
            Object[] pathArray = path.getPath();
            for (Object o : pathArray) {
                String nodeName = o.toString();
                if (nodeName.length() > 0) {
                    sb.append("/");
                    sb.append(o.toString());
                }
            }
            selectedNodes.add(sb.toString());
        }
    }
    return selectedNodes;
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:23,代码来源:ZooInspectorTreeViewer.java

示例3: hasAsParent

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
@Override
public boolean hasAsParent(TreePath path, int indexInParent) {
    Object[] comps = path.getPath();
    Object node;
    for (int i = 1; i < comps.length; i++) {
        if (arr.length < path.getPathCount() - 1) {
            return false;
        }
        /*
        if(!comparator.equals(comps[i].toString(), arr[i - 1])) {
            return false;
        }
         */
        if (indices.length >= path.getPathCount() - 1) {
            node = chooseSubnode(comps[i - 1], arr[i - 1], indices[i - 1], comparator);
        } else {
            node = chooseSubnode(comps[i - 1], arr[i - 1], comparator);
        }
        if (node != comps[i]) {
            return false;
        }
    }
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:JTreeOperator.java

示例4: isDescendant

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
private boolean isDescendant(TreePath path1, TreePath path2) {
    Object obj1[] = path1.getPath();
    Object obj2[] = path2.getPath();
    for (int i = 0; i < obj2.length; i++) {
        if (obj1[i] != obj2[i]) {
            return false;
        }
    }
    return true;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:CheckTreeSelectionModel.java

示例5: addObject

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
/**
 * Add child to the currently selected node.
 *
 * @param child the node to be added to the selected node
 * @return the node which was inserted in the tree
 */
public gui.support.CustomTreeNode addObject(String child) {
    gui.support.CustomTreeNode parentNode;
    gui.support.CustomTreeNode childNode;
    TreePath parentPath = tree.getSelectionPath();

    if (parentPath == null) {
        parentNode = rootNode;
    } else // the tree has a limited depth!
    {
        if (parentPath.getPath().length < treeDepth) {
            parentNode = (gui.support.CustomTreeNode) (parentPath.getLastPathComponent());
        } else {
            // Either there was no selection, or the root was selected.
            toolkit.beep();
            return null;
        }
    }

    // add the child to the list of children
    childNode = parentNode.addChild(child);

    // update gui
    treeModel.fireTreeStructureChanged(parentNode,
            new int[]{parentNode.getIndexOfChild(childNode)},
            new Object[]{childNode},
            CustomTreeModel.TreeActions.NODE_INSERTED);

    tree.expandPath(parentNode.getTreePath());
    tree.scrollPathToVisible(childNode.getTreePath());
    return childNode;
}
 
开发者ID:buni-rock,项目名称:Pixie,代码行数:38,代码来源:DynamicTree.java

示例6: ensurePathComputed

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
public static TreePath ensurePathComputed(HeapWalkerNode root, TreePath path, Set<HeapWalkerNode> processed) {
    List p = new ArrayList();
    
    Object[] obj = path.getPath();
    if (root == null || !root.equals(obj[0])) return null;
    p.add(root);

    for (int i = 1; i <= obj.length; i++) {
        HeapWalkerNode[] ch = null;
        if (root instanceof AbstractHeapWalkerNode && !processed.contains(root)) {
            AbstractHeapWalkerNode a = (AbstractHeapWalkerNode)root;
            ChildrenComputer c = a.getChildrenComputer();
            if (c != null) ch = c.computeChildren();
            a.setChildren(ch);
            processed.add(root);
        }
        if (ch == null) ch = root.getChildren();
        
        root = null;
        if (i < obj.length) for (HeapWalkerNode x : ch)
            if (x.equals(obj[i])) {
                root = x;
                p.add(root);
                break;
            }
        if (root == null) break;
    }
    
    return new TreePath(p.toArray());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:BrowserUtils.java

示例7: pathFromRoot

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
private static String pathFromRoot(TreePath path) {
    int m = ((HeapWalkerNode)path.getLastPathComponent()).getMode();
    Object[] nodes = path.getPath();
    StringBuilder b = new StringBuilder();
    int s = nodes.length;
    for (int i = 0; i < s; i++) {
        HeapWalkerNode n = (HeapWalkerNode)nodes[i];
        if (m == HeapWalkerNode.MODE_FIELDS) fieldFromRoot(n, b, i, s);
        else referenceFromRoot(n, b, i, s);
        b.append("\n"); // NOI18N
    }
    return b.toString().replace("].[", ""); // NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:BrowserUtils.java

示例8: getSimilarPath

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
private TreePath getSimilarPath(TreePath oldPath) {
    if (oldPath == null || oldPath.getPathCount() < 1) return null;

    TreeModel currentModel = getModel();
    Object currentRoot = currentModel.getRoot();
    if (!currentRoot.equals(oldPath.getPathComponent(0))) return null;

    TreePath p = new TreePath(currentRoot);
    Object[] op = oldPath.getPath();
    Object n = currentRoot;

    for (int i = 1; i < op.length; i++) {
        Object nn = null;

        for (int ii = 0; ii < currentModel.getChildCount(n); ii++) {
            Object c = currentModel.getChild(n, ii);
            if (c.equals(op[i])) {
                nn = c;
                break;
            }
        }

        if (nn == null) return null;

        n = nn;
        p = p.pathByAddingChild(n);
    }

    return p;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:ProfilerTreeTable.java

示例9: valueChanged

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
public void valueChanged(TreeSelectionEvent e) {
    TreePath[] paths = e.getPaths();
    selectedNodes.clear();
    for (TreePath path : paths) {
        boolean appended = false;
        StringBuilder sb = new StringBuilder();
        Object[] pathArray = path.getPath();
        for (Object o : pathArray) {
            if (o != null) {
                String nodeName = o.toString();
                if (nodeName != null) {
                    if (nodeName.length() > 0) {
                        appended = true;
                        sb.append("/"); //$NON-NLS-1$
                        sb.append(o.toString());
                    }
                }
            }
        }
        if (appended) {
            selectedNodes.add(sb.toString());
        }
    }
    for (int i = 0; i < needsReload.size(); i++) {
        this.needsReload.set(i, true);
    }
    reloadSelectedViewer();
}
 
开发者ID:l294265421,项目名称:ZooKeeper,代码行数:29,代码来源:ZooInspectorNodeViewersPanel.java

示例10: isDescendant

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
private boolean isDescendant(TreePath path1, TreePath path2) {
	Object obj1[] = path1.getPath();
	Object obj2[] = path2.getPath();
	if (obj1.length <= obj2.length) {
		return false;
	}
	for (int i = 0; i < obj2.length; i++) {
		if (obj1[i] != obj2[i]) {
			return false;
		}
	}
	return true;
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:14,代码来源:ExtendedCheckTreeSelectionModel.java

示例11: recordAction

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
private void recordAction(int action) {
    TreePath[] selectionPaths = assertionTree.getSelectionPaths();
    for (TreePath path : selectionPaths) {
        Object[] objects = path.getPath();
        final StringBuffer sb = new StringBuffer();
        RComponent forComponent = rcomponent;
        for (int j = 1; j < objects.length; j++) {
            final AssertionTreeNode node = (AssertionTreeNode) objects[j];
            if (node.getObject() instanceof RComponent) {
                forComponent = (RComponent) node.getObject();
                sb.setLength(0);
                continue;
            }
            sb.append(node.getProperty());
            if (j < objects.length - 1) {
                if (!((AssertionTreeNode) objects[j + 1]).getProperty().startsWith("[")) {
                    sb.append(".");
                }
            } else {
                String property = sb.toString();
                Object value = null;
                if (property.equals("Content")) {
                    value = forComponent.getContent();
                } else {
                    if (property.equals("Text")) {
                        value = forComponent.getText();
                    } else {
                        value = forComponent.getAttribute(property);
                    }
                }
                getRecorder().recordAction(forComponent, action == ASSERT_ACTION ? "assert" : "wait", property, value);
            }
        }
    }
}
 
开发者ID:jalian-systems,项目名称:marathonv5,代码行数:36,代码来源:DefaultContextMenu.java

示例12: getStringPath

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
/**
 * Generates an equivalent String path from a given TreePath
 * 
 * @param treePath
 *          - The path that will be converted to String
 * @return The String path
 */
public static String getStringPath(TreePath treePath) {
	StringBuilder fullPath = new StringBuilder();
	Object[] pathNodes = treePath.getPath();
	for (int j = 1; j < pathNodes.length; j++) {
		if (j == pathNodes.length - 1) {
			fullPath.append(pathNodes[j]);
		} else {
			fullPath.append(pathNodes[j]).append("/");
		}

	}
	return fullPath.toString();
}
 
开发者ID:oxygenxml,项目名称:oxygen-git-plugin,代码行数:21,代码来源:TreeFormatter.java

示例13: createFilePath

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
public static String createFilePath(TreePath treePath) {
	StringBuilder sb = new StringBuilder();
	Object[] nodes = treePath.getPath();
	for (int i = 0; i < nodes.length; i++) {
		sb.append(File.separatorChar).append(nodes[i].toString());
	}
	return sb.toString();
}
 
开发者ID:csanuragjain,项目名称:APKRepatcher,代码行数:9,代码来源:APKRepatcher.java

示例14: jTreeFileSelect_mouseClicked

import javax.swing.tree.TreePath; //导入方法依赖的package包/类
public void jTreeFileSelect_mouseClicked(MouseEvent me) {
  StringWriter writer = new StringWriter();
  try {
	  TreePath tp = ((FileTree)me.getSource()).getPathForLocation(me.getX(), me.getY());
	  PathNode node  = (PathNode)tp.getPath()[tp.getPathCount() -1];
	  String fileName = node.getValue();
	  ExampleDefine define = ReadExample.readExampleDefine(fileName);
	  jTextAreaScript.setText(define.getScript());
	  jTextAreaContext.setText(define.getContext());
} catch (Exception e) {
	  e.printStackTrace(new PrintWriter(writer));
}

 }
 
开发者ID:alibaba,项目名称:QLExpress,代码行数:15,代码来源:ConsoleFrame2.java


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