javax.swing.tree.TreePath.isDescendant()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(85)

本文整理了Java中javax.swing.tree.TreePath.isDescendant()方法的一些代码示例,展示了TreePath.isDescendant()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreePath.isDescendant()方法的具体详情如下:
包路径:javax.swing.tree.TreePath
类名称:TreePath
方法名:isDescendant

TreePath.isDescendant介绍

暂无

代码示例

代码示例来源:origin: pentaho/mondrian

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);
}

代码示例来源:origin: pentaho/mondrian

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);
    }
  }
}

代码示例来源:origin: org.apache.tapestry/tapestry-contrib

/**
 * @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;
}

代码示例来源:origin: triplea-game/triplea

/**
 * 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;
}

代码示例来源:origin: com.jidesoft/jide-oss

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);
}

代码示例来源:origin: in.jlibs/org-netbeans-swing-outline

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);
}

代码示例来源:origin: in.jlibs/org-netbeans-swing-outline

parent.isDescendant(path) && isVisible(path)) {
if (results == null) {
  results = new ArrayList<TreePath>();

代码示例来源:origin: Vhati/Slipstream-Mod-Manager

for ( Iterator<TreePath> childIt = childPaths.iterator(); childIt.hasNext(); ) {
  TreePath childPath = childIt.next();
  if ( ancestorPath.isDescendant( childPath ) ) {
    childIt.remove();

代码示例来源:origin: triplea-game/triplea

while (expandedDescendants.hasMoreElements()) {
 final TreePath currentDescendant = expandedDescendants.nextElement();
 if (!currentDescendant.isDescendant(newPath)
   && (selectedPath == null || !currentDescendant.isDescendant(selectedPath))) {
  collapsePaths.add(currentDescendant);

代码示例来源:origin: triplea-game/triplea

/**
 * 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();
 }
}

代码示例来源:origin: org.netbeans.api/org-openide-explorer

TreePath path = new TreePath(vn.getPathToRoot());
for(TreePath tp : selPaths) {
  if (path.isDescendant(tp)) {
    if (remSel == null) {
      remSel = new ArrayList<TreePath>();

代码示例来源:origin: javax.help/javahelp

if ( dropper.isDescendant(destination))
  return "Destination node cannot be a descendant.";

代码示例来源:origin: link-intersystems/blog

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);
}

代码示例来源:origin: org.activecomponents.jadex/jadex-commons-gui

if(path!=null)
  if(root.isDescendant(path))

代码示例来源:origin: com.jidesoft/jide-oss

if (removedPath.isDescendant(path)) {
  findAncestor = true;
  break;
if (path.isDescendant(pathToAdded)) {
  pathToRemoved.add(pathToAdded);
if (pathToAdded.isDescendant(path)) {
  upperMostSelectedAncestor = pathToAdded;
  break;

代码示例来源:origin: uk.org.mygrid.taverna.scufl.scufl-ui-components/iteration-strategy-editor

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;
}

代码示例来源:origin: uk.org.mygrid.taverna.scufl.scufl-ui-components/iteration-strategy-editor

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;
}

代码示例来源:origin: stackoverflow.com

TreePath tp = jt.getPathForRow (row);
jt.expandRow (row);
if (tp.isDescendant (jt.getPathForRow (row + 1)))
  openSubnodes (row + 1, jt);

代码示例来源:origin: in.jlibs/org-netbeans-swing-outline

if (tp1.isDescendant(tp2)) {
  return -1;
if (tp2.isDescendant(tp1)) {
  return 1;

代码示例来源:origin: com.jidesoft/jide-oss

if (addPath.isDescendant(path)) {
  findAncestor = true;
  break;

相关文章