mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
GT-3323 - GTree - review fixes
This commit is contained in:
parent
e346736e5f
commit
a32e20ee90
4 changed files with 30 additions and 43 deletions
|
@ -314,27 +314,6 @@ public class GTree extends JPanel implements BusyListener {
|
|||
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.
|
||||
|
@ -367,6 +346,28 @@ public class GTree extends JPanel implements BusyListener {
|
|||
runTask(new GTreeRestoreTreeStateTask(this, state));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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() {
|
||||
if (restoreTreeState == null) {
|
||||
restoreTreeState = new GTreeState(this);
|
||||
}
|
||||
return restoreTreeState;
|
||||
}
|
||||
|
||||
void treeStateRestored(TaskMonitor taskMonitor) {
|
||||
if (filter == null) {
|
||||
// clear the state so that we will track future user changes upon the next filter
|
||||
restoreTreeState = null;
|
||||
}
|
||||
expandedStateRestored(taskMonitor);
|
||||
}
|
||||
|
||||
/**
|
||||
* A method that subclasses can use to be notified when tree state has been restored. This
|
||||
* method is called after a major structural tree change has happened <b>and</b> the paths
|
||||
|
|
|
@ -31,22 +31,7 @@ public class GTreeFilterTask extends GTreeTask {
|
|||
super(tree);
|
||||
this.filter = filter;
|
||||
|
||||
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;
|
||||
defaultRestoreState = tree.getRestoreTreeState();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -13,15 +13,16 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package docking.widgets.tree.tasks;
|
||||
package docking.widgets.tree;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.tree.TreePath;
|
||||
|
||||
import docking.widgets.tree.*;
|
||||
import docking.widgets.tree.support.GTreeSelectionEvent.EventOrigin;
|
||||
import ghidra.util.SystemUtilities;
|
||||
import docking.widgets.tree.tasks.GTreeExpandPathsTask;
|
||||
import docking.widgets.tree.tasks.GTreeSelectPathsTask;
|
||||
import ghidra.util.Swing;
|
||||
import ghidra.util.task.TaskMonitor;
|
||||
|
||||
public class GTreeRestoreTreeStateTask extends GTreeTask {
|
||||
|
@ -56,7 +57,7 @@ public class GTreeRestoreTreeStateTask extends GTreeTask {
|
|||
selectPathsInThisTask(state, monitor, true);
|
||||
|
||||
// this allows some tress to perform cleanup
|
||||
tree.expandedStateRestored(monitor);
|
||||
tree.treeStateRestored(monitor);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,7 +91,7 @@ public class GTreeRestoreTreeStateTask extends GTreeTask {
|
|||
for (TreePath path : viewPaths) {
|
||||
TreePath currentPath = translatePath(path, monitor);
|
||||
if (currentPath != null) {
|
||||
SystemUtilities.runSwingLater(() -> tree.scrollPathToVisible(currentPath));
|
||||
Swing.runLater(() -> tree.scrollPathToVisible(currentPath));
|
||||
break;
|
||||
}
|
||||
}
|
|
@ -48,7 +48,7 @@ public class GTreeSelectPathsTask extends GTreeTask {
|
|||
*
|
||||
* @param disabled true to disable
|
||||
*/
|
||||
void setExpandingDisabled(boolean disabled) {
|
||||
public void setExpandingDisabled(boolean disabled) {
|
||||
this.expandingDisabled = disabled;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue