public boolean isPathSelected(TreePath path, boolean dig) { if (!dig) { return super.isPathSelected(path); } while (path != null && !super.isPathSelected(path)) { path = path.getParentPath(); } return path != null; }
private void toggleRemoveSelection(TreePath path) { Stack stack = new Stack(); TreePath parent = path.getParentPath(); while (parent != null && !isPathSelected(parent)) { stack.push(parent); parent = parent.getParentPath(); } if (parent != null) { stack.push(parent); } else { super.removeSelectionPaths(new TreePath[]{path}); return; } while (!stack.isEmpty()) { TreePath temp = (TreePath) stack.pop(); TreePath peekPath = stack.isEmpty() ? path : (TreePath) stack.peek(); Object node = temp.getLastPathComponent(); Object peekNode = peekPath.getLastPathComponent(); int childCount = model.getChildCount(node); for (int i = 0; i < childCount; i++) { Object childNode = model.getChild(node, i); if (childNode != peekNode) { super.addSelectionPaths(new TreePath[]{temp.pathByAddingChild(childNode)}); } } } super.removeSelectionPaths(new TreePath[]{parent}); }
private boolean areSiblingsSelected(TreePath path) { TreePath parent = path.getParentPath(); if (parent == null) { return true; } Object node = path.getLastPathComponent(); Object parentNode = parent.getLastPathComponent(); int childCount = model.getChildCount(parentNode); for (int i = 0; i < childCount; i++) { Object childNode = model.getChild(parentNode, i); if (childNode == node) { continue; } if (!isPathSelected(parent.pathByAddingChild(childNode))) { return false; } } return true; }
private void expandSubtree(TreePath path, boolean expand) { if (path == null) { TreePath selectionPath = getSelectionPath(); path = selectionPath == null ? new TreePath(treeModel.getRoot()) : selectionPath; } DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode) path.getLastPathComponent(); Enumeration children = currentNode.children(); while (children.hasMoreElements()) { DefaultMutableTreeNode child = (DefaultMutableTreeNode) children.nextElement(); TreePath expandedPath = path.pathByAddingChild(child); expandSubtree(expandedPath, expand); } if (expand) { expandPath(path); } else if (path.getParentPath() != null) { collapsePath(path); } }
while (areSiblingsSelected(path)) { temp = path; if (path.getParentPath() == null) { break; path = path.getParentPath(); if (temp.getParentPath() != null) { addSelectionPath(temp.getParentPath()); } else { if (!isSelectionEmpty()) {
TreePath parentPath = tp.getParentPath();
public Object getParentObject() { TreePath tPath = tree.getSelectionPath(); if ((tPath != null) && (tPath.getParentPath() != null)) { return tPath.getParentPath().getLastPathComponent(); } return null; }
/** * Constructs a status string from the path. * @param path * @return the status string. */ private String generatePathString(TreePath path) { StringBuilder pathStringBuilder = new StringBuilder(); while (path.getParentPath() != null) { Object object = path.getLastPathComponent(); pathStringBuilder.insert(0, "/" + getObjectName(object)); path = path.getParentPath(); } pathStringBuilder.delete(0, 1); return pathStringBuilder.toString(); }
@Override public void valueChanged(TreeSelectionEvent e) { TreePath path = e.getNewLeadSelectionPath(); if (path.getLastPathComponent() instanceof Name) { Name name = (Name) path.getLastPathComponent(); ProcessFactory factory = (ProcessFactory) path.getParentPath().getLastPathComponent(); updateProcessDesc(factory, name); } } });
public void itemStateChanged(ItemEvent e) { tree.stopEditing(); TreePath tpath = tree.getSelectionPath(); if (tpath != null) { TreePath parentpath = tpath.getParentPath(); if (parentpath != null) { refreshTree(parentpath); } } } });
parentpath = tpath.getParentPath(); int objCnt = 2; while (parentpath != null) { treeObjs[objCnt] = po; objCnt += 1; parentpath = parentpath.getParentPath();
private void showFont(Object selectedNode, TreePath path) { COSName fontName = getNodeKey(selectedNode); COSDictionary resourceDic = (COSDictionary) getUnderneathObject(path.getParentPath().getParentPath().getLastPathComponent()); FontEncodingPaneController fontEncodingPaneController = new FontEncodingPaneController(fontName, resourceDic); JPanel pane = fontEncodingPaneController.getPane(); if (pane == null) { // unsupported font type replaceRightComponent(jScrollPane2); return; } replaceRightComponent(pane); }
protected void arrowButtonUpAction(ActionEvent evt) { TreePath tpath = tree.getSelectionPath(); if (tpath != null) { TreePath parentpath = tpath.getParentPath(); if (parentpath != null) { tree.setSelectionPath(parentpath); refreshTree(parentpath); } } }
tpath.getParentPath().pathByAddingChild( nextSibling)); } else if (prevSibling != null) { tree.setSelectionPath( tpath.getParentPath().pathByAddingChild( prevSibling)); } else if (grandparentAsSibling) { tree.setSelectionPath(tpath.getParentPath().getParentPath()); } else { tree.setSelectionPath(tpath.getParentPath());
COSName parentKey = getNodeKey(path.getParentPath().getLastPathComponent()); COSDictionary resourcesDic = null; Object pageObj = path.getParentPath().getLastPathComponent(); COSDictionary page = (COSDictionary) getUnderneathObject(pageObj); resourcesDic = (COSDictionary) page.getDictionaryObject(COSName.RESOURCES); Object pageObj = path.getParentPath().getParentPath().getLastPathComponent(); COSDictionary page = (COSDictionary) getUnderneathObject(pageObj); resourcesDic = (COSDictionary) page.getDictionaryObject(COSName.RESOURCES); Object resourcesObj = path.getParentPath().getParentPath().getLastPathComponent(); resourcesDic = (COSDictionary) getUnderneathObject(resourcesObj);
return; if (path.getParentPath() != null && isFlagNode(selectedNode, path.getParentPath().getLastPathComponent())) Object parentNode = path.getParentPath().getLastPathComponent(); showFlagPane(parentNode, selectedNode); return;
if (tpath != null) { Object value = tpath.getLastPathComponent(); TreePath parentpath = tpath.getParentPath(); if (parentpath != null) { Object parent = parentpath.getLastPathComponent();
path = path.getParentPath(); temp = path; if(path.getParentPath()==null) path = path.getParentPath(); if(temp.getParentPath()!=null) addSelectionPath(temp.getParentPath()); TreePath parent = path.getParentPath(); TreePath parent = path.getParentPath(); parent = parent.getParentPath();
Object po = null; TreePath parentTpath = tpath.getParentPath(); String parentName = ""; String elementName = "";
instanceof MondrianGuiDef.RelationOrJoin) Object po = path.getParentPath().getLastPathComponent(); if (!(po instanceof MondrianGuiDef.RelationOrJoin) && !(po instanceof MondrianGuiDef.Closure))