public void treeExpanded(TreeExpansionEvent treeExpansionEvent) { TreePath expandedPath = treeExpansionEvent.getPath(); // remove all ancestors of eventpath from expandedpaths set. Object[] paths = expandedTreePaths.toArray(); for (int i = 0; i < paths.length; i++) { TreePath path = (TreePath) paths[i]; // Path is a descendant of event path if path contains all // components that make eventpath. For example, if eventpath = [a,b] // path=[a,b,c] then path is descendant of eventpath. if (path.isDescendant(expandedPath)) { expandedTreePaths.remove(path); } } expandedTreePaths.add(expandedPath); }
public void treeCollapsed(TreeExpansionEvent treeExpansionEvent) { TreePath collapsedPath = treeExpansionEvent.getPath(); expandedTreePaths.remove(collapsedPath); // remove all descendants from expandedpaths set. Object[] paths = expandedTreePaths.toArray(); for (int i = 0; i < paths.length; i++) { TreePath path = (TreePath) paths[i]; // Path is a descendant of event path if path contains all // components that make eventpath. For example, if eventpath = [a,b] // path=[a,b,c] then path is descendant of eventpath. if (collapsedPath.isDescendant(path)) { expandedTreePaths.remove(path); } } }
/** * @see org.apache.tapestry.contrib.tree.model.ITreeDataModel#isAncestorOf(Object, * Object) */ public boolean isAncestorOf(Object objTargetUniqueKey, Object objParentUniqueKey) { TreePath objParentPath = (TreePath) objParentUniqueKey; TreePath objTargetPath = (TreePath) objTargetUniqueKey; boolean bResult = objParentPath.isDescendant(objTargetPath); return bResult; }
/** * Indicates whether the expanded path list contains a descendant of parentPath. * * @param parentPath tree path for which descendants should be check. */ private boolean stayExpandedContainsDescendantOf(final TreePath parentPath) { for (final TreePath currentPath : stayExpandedPaths) { if (parentPath.isDescendant(currentPath)) { return true; } } return false; }
private void addToExistingSet(Set<TreePath> pathHasOperated, TreePath pathToOperate) { if (pathHasOperated.contains(pathToOperate)) { return; // it is already removed } for (TreePath path : pathHasOperated) { if (path.isDescendant(pathToOperate)) { return; // its parent is removed, no need to add it } } // remove all children path exists in the set Set<TreePath> duplicatePathToErase = new HashSet<TreePath>(); for (TreePath path : pathHasOperated) { if (pathToOperate.isDescendant(path)) { duplicatePathToErase.add(path); } } pathHasOperated.removeAll(duplicatePathToErase); pathHasOperated.add(pathToOperate); }
protected TreePath[] getDescendantToggledPaths(TreePath parent) { if(parent == null) return null; ArrayList<TreePath> descendants = new ArrayList<TreePath>(); Iterator<TreePath> nodes = expandedPaths.keySet().iterator(); TreePath path; while (nodes.hasNext()) { path = nodes.next(); if (parent.isDescendant(path)) { descendants.add(path); } } TreePath[] result = new TreePath[descendants.size()]; return descendants.toArray(result); }
parent.isDescendant(path) && isVisible(path)) { if (results == null) { results = new ArrayList<TreePath>();
for ( Iterator<TreePath> childIt = childPaths.iterator(); childIt.hasNext(); ) { TreePath childPath = childIt.next(); if ( ancestorPath.isDescendant( childPath ) ) { childIt.remove();
while (expandedDescendants.hasMoreElements()) { final TreePath currentDescendant = expandedDescendants.nextElement(); if (!currentDescendant.isDescendant(newPath) && (selectedPath == null || !currentDescendant.isDescendant(selectedPath))) { collapsePaths.add(currentDescendant);
/** * collapses parents of last path if it is not in the list of expanded path until the new path is a descendant. * * @param newPath new path */ private void collapseUpFromLastParent(final TreePath newPath) { TreePath currentParent = lastParent; while (currentParent != null && !currentParent.isDescendant(newPath) && !stayExpandedContainsDescendantOf(currentParent)) { tree.collapsePath(currentParent); currentParent = currentParent.getParentPath(); } }
TreePath path = new TreePath(vn.getPathToRoot()); for(TreePath tp : selPaths) { if (path.isDescendant(tp)) { if (remSel == null) { remSel = new ArrayList<TreePath>();
if ( dropper.isDescendant(destination)) return "Destination node cannot be a descendant.";
public void update(Observable o, Object arg) { Person selection = listModelSelection.getSelection(); if (selection == null) { return; } TreePath treePath = personTreeModel.getTreePath(selection); TreePath selectionPath = getSelectionPath(); if (treePath != null && treePath.isDescendant(selectionPath)) { return; } setSelectionPath(treePath); }
if(path!=null) if(root.isDescendant(path))
if (removedPath.isDescendant(path)) { findAncestor = true; break; if (path.isDescendant(pathToAdded)) { pathToRemoved.add(pathToAdded); if (pathToAdded.isDescendant(path)) { upperMostSelectedAncestor = pathToAdded; break;
public boolean isDragAcceptable(DropTargetDragEvent e) { // Only accept MOVE gestures (ie LINK is not supported) if ((e.getDropAction() & DnDConstants.ACTION_MOVE) == 0) { return false; } // Only accept this particular flavor if (!e.isDataFlavorSupported(CTransferableTreePath.TREEPATH_FLAVOR)) { return false; } // Do this if you want to prohibit dropping onto the drag source... Point pt = e.getLocation(); TreePath path = getClosestPathForLocation(pt.x, pt.y); if (path.equals(pathSource)) { return false; } // Check whether we're dragging an ancestor into a descendent (not // allowed for move) if (pathSource.isDescendant(path)) { return false; } /* * // Do this if you want to select the best flavor on offer... * DataFlavor[] flavors = e.getCurrentDataFlavors(); for (int i = 0; * i < flavors.length; i++ ) { DataFlavor flavor = flavors[i]; if * (flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType)) * return true; } */ return true; }
public boolean isDropAcceptable(DropTargetDropEvent e) { // Only accept MOVE gestures (ie LINK is not supported) if ((e.getDropAction() & DnDConstants.ACTION_MOVE) == 0) { return false; } // Only accept this particular flavor if (!e.isDataFlavorSupported(CTransferableTreePath.TREEPATH_FLAVOR)) { return false; } // Do this if you want to prohibit dropping onto the drag source... Point pt = e.getLocation(); TreePath path = getClosestPathForLocation(pt.x, pt.y); System.out.println(path.toString() + " " + pathSource.toString()); if (path.equals(pathSource)) { return false; } // Check whether we're dragging an ancestor into a descendent (not // allowed for move) if (pathSource.isDescendant(path)) { return false; } /* * // Do this if you want to select the best flavor on offer... * DataFlavor[] flavors = e.getCurrentDataFlavors(); for (int i = 0; * i < flavors.length; i++ ) { DataFlavor flavor = flavors[i]; if * (flavor.isMimeTypeEqual(DataFlavor.javaJVMLocalObjectMimeType)) * return true; } */ return true; }
TreePath tp = jt.getPathForRow (row); jt.expandRow (row); if (tp.isDescendant (jt.getPathForRow (row + 1))) openSubnodes (row + 1, jt);
if (tp1.isDescendant(tp2)) { return -1; if (tp2.isDescendant(tp1)) { return 1;
if (addPath.isDescendant(path)) { findAncestor = true; break;