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)); }
private boolean isSelectionKept (TreePath selPath) { if (curSelPath != null) { TreePath oldSel = curSelPath.get(); if (oldSel != null && oldSel.equals(selPath)) { return true; } } return false; }
@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()); } }
@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)); } } } });
@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()); } } });
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); } }
@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 ); } } };
@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); } });
@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 ); } } };
/** * 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); }
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()); } } }
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); }
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); }
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); }
/** 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; }
/** 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; }
@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); }
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); } } } }
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); } } } }