本文整理了Java中javax.swing.tree.TreePath.equals()
方法的一些代码示例,展示了TreePath.equals()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TreePath.equals()
方法的具体详情如下:
包路径:javax.swing.tree.TreePath
类名称:TreePath
方法名:equals
暂无
代码示例来源:origin: de.sciss/jtreetable
public boolean equals(DropLocation o) {
return o != null
&& row == o.row
&& column == o.column
&& isInsertRow == o.isInsertRow
&& isInsertColumn == o.isInsertColumn
&& index == o.index
&& (path == null ? o.path == null : path.equals(o.path));
}
代码示例来源:origin: org.gephi/directory-chooser
private boolean isSelectionKept (TreePath selPath) {
if (curSelPath != null) {
TreePath oldSel = curSelPath.get();
if (oldSel != null && oldSel.equals(selPath)) {
return true;
}
}
return false;
}
代码示例来源:origin: javax.help/javahelp
if (destination.equals(dropper))
return "Destination cannot be same as source";
if ( dropper.getParentPath().equals(destination))
return "Destination node cannot be a parent.";
代码示例来源:origin: com.mgmtp.jfunk/jfunk-core
@Override
public void mousePressed(final MouseEvent e) {
if (e.isPopupTrigger()) {
TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
TreePath[] paths = tree.getSelectionPaths();
boolean newPath = true;
for (TreePath path : paths) {
if (selPath.equals(path)) {
newPath = false;
break;
}
}
if (newPath) {
tree.setSelectionPath(selPath);
}
popup.show((Component) e.getSource(), e.getX(), e.getY());
}
}
代码示例来源:origin: tulskiy/musique
@Override
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
TreePath path = directoryChooser.getPathForLocation(e.getX(), e.getY());
if (path != null && path.equals(directoryChooser.getSelectionPath()) &&
directoryChooser.getSelectedFiles().length > 0) {
TreeNode o = (TreeNode) path.getLastPathComponent();
if (o.isLeaf() || !o.children().hasMoreElements())
actionListener.actionPerformed(new ActionEvent(directoryChooser, 0, null));
}
}
}
});
代码示例来源:origin: com.mgmtp.jfunk/jfunk-core
@Override
public void mouseReleased(final MouseEvent e) {
if (e.isPopupTrigger()) {
TreePath selPath = tree.getPathForLocation(e.getX(), e.getY());
TreePath[] paths = tree.getSelectionPaths();
boolean newPath = true;
for (TreePath path : paths) {
if (selPath.equals(path)) {
newPath = false;
break;
}
}
if (newPath) {
tree.setSelectionPath(selPath);
}
popup.show((Component) e.getSource(), e.getX(), e.getY());
}
}
});
代码示例来源:origin: de.sciss/jtreetable
void setMouseOverSortIndicator(TreePath path, int col) {
TreePath oldPath = mouseOverSortPath;
int oldColumn = mouseOverSortColumn;
if (col != oldColumn ||
(path == null ? oldPath != null : !path.equals(oldPath))) {
mouseOverSortColumn = col;
mouseOverSortPath = path;
paintMouseOverSortPath = true;
if (oldPath != null)
repaint(oldPath, oldColumn);
if (path != null)
repaint(path, col);
}
}
代码示例来源:origin: icza/scelight
@Override
public void actionPerformed( final ActionEvent event ) {
final int maxDepth = Env.APP_SETTINGS.get( Settings.RAW_TREE_EXPAND_DEPTH ) - 1;
final TreePath[] selectionPaths = tree.getSelectionPaths();
for ( final TreePath tp : selectionPaths ) {
if ( tp.equals( gameEventsTreePath ) || tp.equals( trackerEventsTreePath ) ) {
if ( maxDepth >= 0 )
tree.expandPathRecursive( tp, maxDepth );
} else
tree.expandPathRecursive( tp );
}
}
};
代码示例来源:origin: org.nuiton.jaxx/jaxx-runtime-swing
@Override
public void valueChanged(TreeSelectionEvent event) {
if (event.getOldLeadSelectionPath() != null && event.getOldLeadSelectionPath().equals(event.getPath())) {
// do not treate this if no path changed
return;
}
NavigationTreeNode node = (NavigationTreeNode) event.getPath().getLastPathComponent();
selectNodeUI(node);
}
});
代码示例来源:origin: icza/scelight
@Override
public void actionPerformed( final ActionEvent event ) {
// Max expand depth for game events and tracker events
final int maxDepth = Env.APP_SETTINGS.get( Settings.RAW_TREE_EXPAND_DEPTH ) - 1;
tree.expandRow( 0 );
for ( int i = 0; i < root.getChildCount(); i++ ) {
final TreePath tp = new TreePath(
( (DefaultMutableTreeNode) root.getChildAt( i ) ).getPath() );
if ( tp.equals( gameEventsTreePath ) || tp.equals( trackerEventsTreePath ) ) {
if ( maxDepth >= 0 )
tree.expandPathRecursive( tp, maxDepth );
} else
tree.expandPathRecursive( tp );
}
}
};
代码示例来源:origin: com.jalalkiswani/jk-desktop
/**
* Checks if is descendant.
*
* @param path1
* the path 1
* @param path2
* the path 2
* @return true, if is descendant
*/
public static boolean isDescendant(TreePath path1, final TreePath path2) {
int count1 = path1.getPathCount();
final int count2 = path2.getPathCount();
if (count1 <= count2) {
return false;
}
while (count1 != count2) {
path1 = path1.getParentPath();
count1--;
}
return path1.equals(path2);
}
代码示例来源:origin: javax.help/javahelp
private void maybeShowPopup(MouseEvent e) {
TreePath path = tree.getSelectionPath();
TreePath clickPath = tree.getPathForLocation(e.getX(),e.getY());
if (e.isPopupTrigger()) {
if (path != null && path.equals(clickPath)) {
separatorMI.setVisible(true);
cutMI.setVisible(true);
copyMI.setVisible(true);
pasteMI.setVisible(true);
removeMI.setVisible(true);
} else {
separatorMI.setVisible(false);
cutMI.setVisible(false);
copyMI.setVisible(false);
pasteMI.setVisible(false);
removeMI.setVisible(false);
}
popup.show(e.getComponent(), e.getX(), e.getY());
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
public void treeStructureChanged(TreeModelEvent e) {
// bugfix #23757, store selection paths
tps = tree.getSelectionPaths ();
// bugfix #30355, don't restore selection when the tree root changed
// (see javadoc TreeModelListener.treeStructureChanged)
if (e.getPath ().length == 1 && !e.getTreePath ().equals (e.getPath ()[0])) {
tps = null;
}
delayedUpdateNodes(e);
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
public void treeStructureChanged(TreeModelEvent e) {
// bugfix #23757, store selection paths
tps = tree.getSelectionPaths();
// bugfix #30355, don't restore selection when the tree root changed
// (see javadoc TreeModelListener.treeStructureChanged)
if ((e.getPath().length == 1) && !e.getTreePath().equals(e.getPath()[0])) {
tps = null;
}
delayedUpdateNodes(e);
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
public void treeStructureChanged(TreeModelEvent e) {
// bugfix #23757, store selection paths
tps = tree.getSelectionPaths ();
// bugfix #30355, don't restore selection when the tree root changed
// (see javadoc TreeModelListener.treeStructureChanged)
if (e.getPath ().length == 1 && !e.getTreePath ().equals (e.getPath ()[0])) {
tps = null;
}
delayedUpdateNodes(e);
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
/** Configures a tree cell renderer and sets up sizing and the
* backing image from it */
public boolean configure (Object nd, JScrollPane tv, JTree tree, TreePath path, int row) {
boolean sameVn = setLastRendereredObject(nd);
boolean sameComp = setLastRenderedScrollPane (tv);
Component renderer = null;
bg = tree.getBackground();
boolean sel = tree.isSelectionEmpty() ? false :
tree.getSelectionModel().isPathSelected(path);
boolean exp = tree.isExpanded(path);
boolean leaf = !exp && tree.getModel().isLeaf(nd);
boolean lead = path.equals(tree.getSelectionModel().getLeadSelectionPath());
renderer = tree.getCellRenderer().getTreeCellRendererComponent(tree, nd, sel, exp, leaf, row, lead);
if (renderer != null) {
setComponent (renderer);
}
return true;
}
代码示例来源:origin: jpcsp/jpcsp
/** Configures a tree cell renderer and sets up sizing and the
* backing image from it */
public boolean configure (Object nd, JScrollPane tv, JTree tree, TreePath path, int row) {
setLastRendereredObject(nd);
setLastRenderedScrollPane (tv);
Component renderer = null;
bg = tree.getBackground();
boolean sel = tree.isSelectionEmpty() ? false :
tree.getSelectionModel().isPathSelected(path);
boolean exp = tree.isExpanded(path);
boolean leaf = !exp && tree.getModel().isLeaf(nd);
boolean lead = path.equals(tree.getSelectionModel().getLeadSelectionPath());
renderer = tree.getCellRenderer().getTreeCellRendererComponent(tree, nd, sel, exp, leaf, row, lead);
if (renderer != null) {
setComponent (renderer);
}
return true;
}
代码示例来源:origin: org.zaproxy/zap
@Override
public void show(Component invoker, int x, int y) {
// Select context list item on right click
TreePath tp = treeContext.getPathForLocation(x, y);
if ( tp != null ) {
boolean select = true;
// Only select a new item if the current item is not
// already selected - this is to allow multiple items
// to be selected
if (treeContext.getSelectionPaths() != null) {
for (TreePath t : treeContext.getSelectionPaths()) {
if (t.equals(tp)) {
select = false;
break;
}
}
}
if (select) {
treeContext.getSelectionModel().setSelectionPath(tp);
}
}
View.getSingleton().getPopupMenu().show(treeContext, x, y);
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
public void treeNodesRemoved (TreeModelEvent e) {
// called to removed from JTree.expandedState
super.treeNodesRemoved (e);
// part of bugfix #37279, if DnD is active then is useless select a nearby node
if (ExplorerDnDManager.getDefault ().isDnDActive ()) {
return ;
}
if (storeSelectedPaths == null || storeSelectedPaths.size () == tree.getSelectionCount ()) {
// selection not changed => it's redundant to change selection
return ;
}
if (tree.getSelectionCount () == 0) {
TreePath path = findSiblingTreePath (e.getTreePath (), e.getChildIndices ());
// bugfix #39564, don't select again the same object
if (path == null || path.equals (e.getTreePath ())) {
return ;
} else if (path.getPathCount () > 0) {
tree.setSelectionPath (path);
}
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
public void treeNodesRemoved (TreeModelEvent e) {
// called to removed from JTree.expandedState
super.treeNodesRemoved (e);
// part of bugfix #37279, if DnD is active then is useless select a nearby node
if (ExplorerDnDManager.getDefault ().isDnDActive ()) {
return ;
}
if (storeSelectedPaths == null || storeSelectedPaths.size () == tree.getSelectionCount ()) {
// selection not changed => it's redundant to change selection
return ;
}
if (tree.getSelectionCount () == 0) {
TreePath path = findSiblingTreePath (e.getTreePath (), e.getChildIndices ());
// bugfix #39564, don't select again the same object
if (path == null || path.equals (e.getTreePath ())) {
return ;
} else if (path.getPathCount () > 0) {
tree.setSelectionPath (path);
}
}
}
}
内容来源于网络,如有侵权,请联系作者删除!