@Override public void treeNodesRemoved(TreeModelEvent e) { if (tree.getSelectionCount() == 0) { TreePath path = TreeView.findSiblingTreePath(e.getTreePath(), e.getChildIndices()); if ((path != null) && (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); } } } }
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); } } } }
@Override public void treeNodesRemoved(TreeModelEvent e) { // called to removed from JTree.expandedState super.treeNodesRemoved(e); boolean wasSelected = removedNodeWasSelected; removedNodeWasSelected = false; // part of bugfix #37279, if DnD is active then is useless select a nearby node if (ExplorerDnDManager.getDefault().isDnDActive()) { return; } if (wasSelected && tree.getSelectionCount() == 0) { TreePath path = findSiblingTreePath(e.getTreePath(), e.getChildIndices()); // bugfix #39564, don't select again the same object if ((path == null) || e.getChildIndices().length == 0) { return; } else if (path.getPathCount() > 0) { tree.setSelectionPath(path); } } } }