mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GT-3323 - GTree - fix bug in restoring tree state after a filter where
the user did not click the tree
This commit is contained in:
parent
5feab045d2
commit
e346736e5f
4 changed files with 77 additions and 11 deletions
|
@ -310,15 +310,31 @@ public class GTree extends JPanel implements BusyListener {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: doc on how to override to extend listener stuff
|
||||
protected JTreeMouseListenerDelegate createMouseListenerDelegate() {
|
||||
return new GTreeMouseListenerDelegate(tree, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tree state that should be used when clearing a tree filter. This state
|
||||
* is tracked by the tree. It allows the tree to remember the users tree selection
|
||||
* before, during and after filter operations.
|
||||
*
|
||||
* @return the state
|
||||
*/
|
||||
public GTreeState getRestoreTreeState() {
|
||||
return restoreTreeState;
|
||||
}
|
||||
|
||||
/**
|
||||
* This allows the filter task to tell the this tree when to save its initial state
|
||||
* @see #getRestoreTreeState()
|
||||
*/
|
||||
void initializeRestoreTreeState() {
|
||||
if (restoreTreeState == null) {
|
||||
restoreTreeState = new GTreeState(this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a state object that allows this tree to later restore its expanded and selected
|
||||
* state.
|
||||
|
|
|
@ -31,8 +31,22 @@ public class GTreeFilterTask extends GTreeTask {
|
|||
super(tree);
|
||||
this.filter = filter;
|
||||
|
||||
// save this now, before we modify the tree
|
||||
defaultRestoreState = tree.getTreeState();
|
||||
defaultRestoreState = getDefaultRestoreState();
|
||||
}
|
||||
|
||||
private GTreeState getDefaultRestoreState() {
|
||||
|
||||
GTreeState state = tree.getRestoreTreeState();
|
||||
if (filter == null) {
|
||||
// clearing the filter; no need to initialize the restore state
|
||||
return state;
|
||||
}
|
||||
|
||||
if (state == null) {
|
||||
tree.initializeRestoreTreeState();
|
||||
state = tree.getRestoreTreeState();
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -81,8 +95,9 @@ public class GTreeFilterTask extends GTreeTask {
|
|||
|
||||
private void restoreInSameTask(TaskMonitor monitor) {
|
||||
|
||||
GTreeState existingState = tree.getRestoreTreeState();
|
||||
GTreeState state = (existingState == null) ? defaultRestoreState : existingState;
|
||||
GTreeState treesPreferredState = tree.getRestoreTreeState();
|
||||
GTreeState state =
|
||||
(treesPreferredState == null) ? defaultRestoreState : treesPreferredState;
|
||||
GTreeRestoreTreeStateTask restoreTask = new GTreeRestoreTreeStateTask(tree, state);
|
||||
restoreTask.run(monitor);
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ package docking.widgets.tree.tasks;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.JTree;
|
||||
import javax.swing.tree.TreePath;
|
||||
|
||||
import docking.widgets.tree.*;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue