當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。