Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-5115 - Trees/Tables - Added actions to focus the filter and toggle filter visibility

dragonmachere2da1609d925
diff --git a/Ghidra/Features/Base/src/main/help/help/topics/Tables/GhidraTableHeaders.html b/Ghidra/Features/Base/src/main/help/help/topics/Tables/GhidraTableHeaders.html
index 22ad048284..de4ce4bab0 100644
--- a/Ghidra/Features/Base/src/main/help/help/topics/Tables/GhidraTableHeaders.html
+++ b/Ghidra/Features/Base/src/main/help/help/topics/Tables/GhidraTableHeaders.html
@@ -1,14 +1,14 @@
<!DOCTYPE doctype PUBLIC "-//W3C//DTD HTML 4.0 Frameset//EN">
<html>
<head>
- <title>Ghidra Table Headers</title>
+ <title>Ghidra Tables</title>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<link rel="stylesheet" type="text/css" href="help/shared/DefaultStyle.css">
</head>
<body lang="EN-US">
- <h1><a name="GhidraTableHeaders"></a>Ghidra Table Headers</h1>
+ <h1><a name="GhidraTableHeaders"></a>Ghidra Tables</h1>
<blockquote>
<p>
Most table headers in Ghidra support some or all of the following features:
diff --git a/Ghidra/Features/Base/src/main/help/help/topics/Trees/GhidraTreeFilter.html b/Ghidra/Features/Base/src/main/help/help/topics/Trees/GhidraTreeFilter.html
index f6052a8550..6af95de1ee 100644
--- a/Ghidra/Features/Base/src/main/help/help/topics/Trees/GhidraTreeFilter.html
+++ b/Ghidra/Features/Base/src/main/help/help/topics/Trees/GhidraTreeFilter.html
@@ -5,13 +5,13 @@
<META name="generator" content=
"HTML Tidy for Java (vers. 2009-12-01), see jtidy.sourceforge.net">
- <TITLE>Ghidra Tree Filters</TITLE>
+ <TITLE>Ghidra Tree and Table Filters</TITLE>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<LINK rel="stylesheet" type="text/css" href="help/shared/DefaultStyle.css">
</HEAD>
<BODY>
- <H1><A name="Filters" id="Filters"></A>Ghidra Tree and Table Filters</H1>
+ <H1><A name="Filters"></A>Ghidra Tree and Table Filters</H1>
<BLOCKQUOTE>
<P>Most trees and tables in Ghidra support filtering and have a text filter located at the
@@ -40,9 +40,39 @@
actually it is also using some other related text for the match, such as a node
description.</P>
</BLOCKQUOTE>
+
+ <BLOCKQUOTE>
+ <P><IMG alt="" src="help/shared/tip.png">While focus is in the filter you can press the
+ up and down arrow keys to change focus to the tree or table. This allows you to enter
+ a filter and arrow through the results without using the mouse. To get back to the
+ filter easily, press the <A HREF="#Activate_Filter">activate filter</A> action (the
+ default key binding is <CODE>Ctrl-F</CODE>) to transfer focus back to the filter.</P>
+ </BLOCKQUOTE>
</BLOCKQUOTE><BR>
<BR>
-
+
+
+ <H2><A name="Activate_Filter"></A>Activate Filter</H2>
+ <BLOCKQUOTE>
+ <P>
+ The <B>Activate Filter</B> action will transfer focus to the filter field when you are
+ using the tree or table. If the filter is not visible, it will first be made visible.
+ The default key binding for this action is <CODE>Ctrl-F</CODE>.
+ </P>
+ </BLOCKQUOTE>
+
+
+ <H2><A name="Toggle_Filter"></A>Toggle Filter</H2>
+ <BLOCKQUOTE>
+ <P>
+ The <B>Toggle Filter</B> action will hide and show the filter field of the tree or table.
+ To use this action you must first assign it a key binding from the tool options.
+ </P>
+ </BLOCKQUOTE>
+
+
+
+
<H2>Clear Filter</H2>
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FindDataTypesByNameAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FindDataTypesByNameAction.java
index ec3c4a6c72..cd1b4ecd1b 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FindDataTypesByNameAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FindDataTypesByNameAction.java
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,11 +15,9 @@
*/
package ghidra.app.plugin.core.datamgr.actions;
-import java.awt.event.KeyEvent;
-
import docking.ActionContext;
-import docking.DockingUtils;
-import docking.action.*;
+import docking.action.DockingAction;
+import docking.action.MenuData;
import docking.widgets.dialogs.InputDialog;
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
import ghidra.app.plugin.core.datamgr.DataTypesProvider;
@@ -38,8 +36,6 @@ public class FindDataTypesByNameAction extends DockingAction {
setMenuBarData(new MenuData(new String[] { NAME + "..." }, null,
"VeryLast", -1, menuSubGroup));
- setKeyBindingData(
- new KeyBindingData(KeyEvent.VK_F, DockingUtils.CONTROL_KEY_MODIFIER_MASK));
setHelpLocation(new HelpLocation("DataTypeManagerPlugin", "Find_Data_Types_By_Name"));
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/util/DataTypeChooserDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/util/DataTypeChooserDialog.java
index 681fac8452..a0425ad577 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/util/DataTypeChooserDialog.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/util/DataTypeChooserDialog.java
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -222,7 +222,7 @@ public class DataTypeChooserDialog extends DialogComponentProvider {
GTreeFilterProvider filterProvider = tree.getFilterProvider();
if (filterProvider instanceof DefaultGTreeFilterProvider) {
DefaultGTreeFilterProvider provider = (DefaultGTreeFilterProvider) filterProvider;
- provider.setFilterOptions(
+ provider.setPreferredFilterOptions(
new FilterOptions(TextFilterStrategy.MATCHES_EXACTLY, false, false, false));
}
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/util/table/AbstractSelectionNavigationAction.java b/Ghidra/Features/Base/src/main/java/ghidra/util/table/AbstractSelectionNavigationAction.java
index 60debb86ed..606d709550 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/util/table/AbstractSelectionNavigationAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/util/table/AbstractSelectionNavigationAction.java
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -162,7 +162,8 @@ public abstract class AbstractSelectionNavigationAction extends ToggleDockingAct
PreferenceState preferenceState = new PreferenceState();
preferenceState.putBoolean(SELECTED_STATE, isSelected());
- dockingWindowManager.putPreferenceState(getOwner(), preferenceState);
+ String key = getOwner() + '_' + getName();
+ dockingWindowManager.putPreferenceState(key, preferenceState);
}
protected void restoreState() {
@@ -171,7 +172,8 @@ public abstract class AbstractSelectionNavigationAction extends ToggleDockingAct
return;
}
- PreferenceState preferenceState = dockingWindowManager.getPreferenceState(getOwner());
+ String key = getOwner() + '_' + getName();
+ PreferenceState preferenceState = dockingWindowManager.getPreferenceState(key);
// restore any previously saved settings
if (preferenceState != null) {
diff --git a/Ghidra/Features/Base/src/test.slow/java/docking/widgets/table/GhidraTableFilterTest.java b/Ghidra/Features/Base/src/test.slow/java/docking/widgets/table/GhidraTableFilterTest.java
index b376f3fa63..21ddf6cad4 100644
--- a/Ghidra/Features/Base/src/test.slow/java/docking/widgets/table/GhidraTableFilterTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/docking/widgets/table/GhidraTableFilterTest.java
@@ -17,10 +17,13 @@ package docking.widgets.table;
import static org.junit.Assert.*;
+import java.awt.BorderLayout;
import java.util.List;
import javax.swing.JComponent;
+import javax.swing.JPanel;
+import org.jdom.Element;
import org.junit.*;
import docking.*;
@@ -38,23 +41,32 @@ public class GhidraTableFilterTest extends AbstractGhidraHeadedIntegrationTest {
private GhidraTable table;
private GTableFilterPanel<DirData> filterPanel;
private DockingWindowManager winMgr;
-
- public GhidraTableFilterTest() {
- super();
- }
+ private DummyTool tool;
+ private TestTableComponentProvider provider;
@Before
public void setUp() throws Exception {
- model = new TestDataModel("filterTestDirList.txt");
- table = new GhidraTable(model);
- filterPanel = new GTableFilterPanel<>(table, model);
- filteredModel = filterPanel.getTableFilterModel();
- table.setAutoLookupColumn(4);
- DummyTool tool = new DummyTool();
+ tool = new DummyTool();
winMgr = new DockingWindowManager(tool, null);
- winMgr.addComponent(new TestTableComponentProvider(tool));
winMgr.setVisible(true);
+
+ buildTable();
+ }
+
+ private void buildTable() throws Exception {
+
+ runSwingWithException(() -> {
+ model = new TestDataModel("filterTestDirList.txt");
+ table = new GhidraTable(model);
+ filterPanel = new GTableFilterPanel<>(table, model);
+ filteredModel = filterPanel.getTableFilterModel();
+ table.setAutoLookupColumn(4);
+ provider = new TestTableComponentProvider(tool);
+ });
+
+ winMgr.addComponent(provider);
+ waitForSwing();
}
@After
@@ -65,7 +77,7 @@ public class GhidraTableFilterTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testContains() {
- setFilterOptions(TextFilterStrategy.CONTAINS, false);
+ setFilterOptions(TextFilterStrategy.CONTAINS);
// no filter text - make sure all 5 nodes are there
assertEquals(TOTAL_TABLE_ROWS, filteredModel.getRowCount());
@@ -147,7 +159,7 @@ public class GhidraTableFilterTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testStartsWith() {
- setFilterOptions(TextFilterStrategy.STARTS_WITH, false);
+ setFilterOptions(TextFilterStrategy.STARTS_WITH);
assertEquals(TOTAL_TABLE_ROWS, filteredModel.getRowCount());
@@ -183,7 +195,7 @@ public class GhidraTableFilterTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testExactMatch() {
- setFilterOptions(TextFilterStrategy.MATCHES_EXACTLY, false);
+ setFilterOptions(TextFilterStrategy.MATCHES_EXACTLY);
assertEquals(TOTAL_TABLE_ROWS, filteredModel.getRowCount());
setFilterText("ABC");
@@ -215,7 +227,7 @@ public class GhidraTableFilterTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testRegExMatch() {
- setFilterOptions(TextFilterStrategy.REGULAR_EXPRESSION, false);
+ setFilterOptions(TextFilterStrategy.REGULAR_EXPRESSION);
assertEquals(TOTAL_TABLE_ROWS, filteredModel.getRowCount());
@@ -246,17 +258,17 @@ public class GhidraTableFilterTest extends AbstractGhidraHeadedIntegrationTest {
@Test
public void testSwitchFilterTypes() {
- setFilterOptions(TextFilterStrategy.STARTS_WITH, false);
+ setFilterOptions(TextFilterStrategy.STARTS_WITH);
setFilterText("ABC");
checkContainsName("ABC");
checkContainsName("ABCX");
assertEquals(2, filteredModel.getRowCount());
- setFilterOptions(TextFilterStrategy.MATCHES_EXACTLY, false);
+ setFilterOptions(TextFilterStrategy.MATCHES_EXACTLY);
checkContainsName("ABC");
assertEquals(1, filteredModel.getRowCount());
- setFilterOptions(TextFilterStrategy.CONTAINS, false);
+ setFilterOptions(TextFilterStrategy.CONTAINS);
assertEquals(4, filteredModel.getRowCount());
checkContainsName("ABC");
checkContainsName("XABC");
@@ -266,27 +278,39 @@ public class GhidraTableFilterTest extends AbstractGhidraHeadedIntegrationTest {
}
@Test
- public void testSavingSelectedFilterType() {
- waitForSwing();
- setFilterOptions(TextFilterStrategy.MATCHES_EXACTLY, false);
+ public void testFilterPersistence() throws Exception {
+
+ // default configuration
+ assertFilterOptions(TextFilterStrategy.CONTAINS);
+
+ setFilterOptions(TextFilterStrategy.MATCHES_EXACTLY);
+ setFilterText("ABC");
setFilterText("ABC");
- checkContainsName("ABC");
- assertEquals(1, filteredModel.getRowCount());
- Object originalValue = getInstanceField("uniquePreferenceKey", filterPanel);
+ setFilterOptions(TextFilterStrategy.STARTS_WITH);
+ setFilterText("ABC");
+ checkContainsName("ABC");
+ checkContainsName("ABCX");
- setUniqueKey("XYZ");
+ // close and reopen the table to verify that the new tree uses the last used filter
+ triggerSaveAndReload();
- setFilterOptions(TextFilterStrategy.STARTS_WITH, false);
+ assertFilterOptions(TextFilterStrategy.STARTS_WITH);
+ setFilterText("ABC");
checkContainsName("ABC");
checkContainsName("ABCX");
- assertEquals(2, filteredModel.getRowCount());
- setUniqueKey(originalValue);
- restorePreferences();
+ // put back, test, and then make sure the updated filter is restored
+ setFilterOptions(TextFilterStrategy.MATCHES_EXACTLY);
+ setFilterText("ABC");
checkContainsName("ABC");
- assertEquals(1, filteredModel.getRowCount());
+ // close and reopen the table to verify that the new tree uses the last used filter
+ triggerSaveAndReload();
+
+ assertFilterOptions(TextFilterStrategy.MATCHES_EXACTLY);
+ setFilterText("ABC");
+ checkContainsName("ABC");
}
@Test
@@ -368,22 +392,42 @@ public class GhidraTableFilterTest extends AbstractGhidraHeadedIntegrationTest {
assertEquals(1, filteredModel.getRowCount());
}
- private void setUniqueKey(final Object value) {
- runSwing(() -> setInstanceField("uniquePreferenceKey", filterPanel, value));
+//=================================================================================================
+// Private Methods
+//=================================================================================================
- }
+ private void triggerSaveAndReload() throws Exception {
+
+ // trigger the window manager to save the table filter preferences to xml
+ Element xml = new Element("TOOL");
+ winMgr.saveToXML(xml);
- private void restorePreferences() {
runSwing(() -> {
- Class<?>[] classes = new Class[] { DockingWindowManager.class };
- Object[] objs = new Object[] { winMgr };
- invokeInstanceMethod("loadFilterPreference", filterPanel, classes, objs);
+ winMgr.removeComponent(provider);
+ filterPanel.dispose();
});
- waitForSwing();
+
+ // put the state back in the window manager
+ winMgr.restoreFromXML(xml);
+
+ // load the new table and let it pull the preferences from the window manager
+ buildTable();
+ }
+
+ private void assertFilterOptions(TextFilterStrategy expectedStrategy) {
+ FilterOptions filterOptions = runSwing(() -> filterPanel.getFilterOptions());
+ TextFilterStrategy actualStrategy = filterOptions.getTextFilterStrategy();
+ assertEquals(expectedStrategy, actualStrategy);
+ }
+
+ private void setFilterOptions(TextFilterStrategy filterStrategy) {
+ setFilterOptions(filterStrategy, false);
}
private void setFilterOptions(TextFilterStrategy filterStrategy, boolean inverted) {
- filterPanel.setFilterOptions(new FilterOptions(filterStrategy, false, false, inverted));
+ runSwing(() -> {
+ filterPanel.setFilterOptions(new FilterOptions(filterStrategy, false, false, inverted));
+ });
waitForSwing();
}
@@ -422,15 +466,21 @@ public class GhidraTableFilterTest extends AbstractGhidraHeadedIntegrationTest {
private class TestTableComponentProvider extends ComponentProvider {
+ private JPanel panel;
+
public TestTableComponentProvider(DummyTool tool) {
super(tool, "Test", "Test");
setDefaultWindowPosition(WindowPosition.STACK);
setTabText("Test");
+
+ panel = new JPanel(new BorderLayout());
+ panel.add(table, BorderLayout.CENTER);
+ panel.add(filterPanel, BorderLayout.SOUTH);
}
@Override
public JComponent getComponent() {
- return table;
+ return panel;
}
@Override
diff --git a/Ghidra/Features/Base/src/test.slow/java/docking/widgets/tree/GTreeFilterTest.java b/Ghidra/Features/Base/src/test.slow/java/docking/widgets/tree/GTreeFilterTest.java
index e6c48779f9..c0a2861800 100644
--- a/Ghidra/Features/Base/src/test.slow/java/docking/widgets/tree/GTreeFilterTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/docking/widgets/tree/GTreeFilterTest.java
@@ -21,6 +21,7 @@ import java.util.List;
import javax.swing.tree.TreePath;
+import org.jdom.Element;
import org.junit.*;
import docking.DockingWindowManager;
@@ -31,6 +32,8 @@ import ghidra.util.StringUtilities;
public class GTreeFilterTest extends AbstractDockingTest {
+ private DummyTool tool;
+ private TestTreeComponentProvider provider;
private GTree gTree;
private FilterTextField filterField;
@@ -38,15 +41,21 @@ public class GTreeFilterTest extends AbstractDockingTest {
@Before
public void setUp() throws Exception {
+
+ tool = new DummyTool();
+ winMgr = new DockingWindowManager(tool, null);
+ winMgr.setVisible(true);
+
+ buildTree();
+ }
+
+ private void buildTree() {
GTreeNode root = new TestRootNode();
gTree = new GTree(root);
filterField = (FilterTextField) gTree.getFilterField();
-
- DummyTool tool = new DummyTool();
- winMgr = new DockingWindowManager(tool, null);
- winMgr.addComponent(new TestTreeComponentProvider(tool, gTree));
- winMgr.setVisible(true);
+ provider = new TestTreeComponentProvider(tool, gTree);
+ winMgr.addComponent(provider);
waitForTree();
}
@@ -77,10 +86,6 @@ public class GTreeFilterTest extends AbstractDockingTest {
assertEquals("Expected all 5 nodes to be back", 5, viewRoot().getChildCount());
}
- private GTreeNode viewRoot() {
- return gTree.getViewRoot();
- }
-
@Test
public void testMultiWordContains() {
setFilterOptions(TextFilterStrategy.CONTAINS, false);
@@ -434,25 +439,128 @@ public class GTreeFilterTest extends AbstractDockingTest {
}
@Test
- public void testSavingSelectedFilterType() {
- setFilterOptions(TextFilterStrategy.MATCHES_EXACTLY, false);
+ public void testFilterPersistence() {
+
+ // default configuration
+ assertFilterOptions(TextFilterStrategy.CONTAINS);
+
+ setFilterOptions(TextFilterStrategy.MATCHES_EXACTLY);
setFilterText("ABC");
- checkContainsNode("ABC");
- assertEquals(1, viewRoot().getChildCount());
+ assertNodesByName(viewRoot(), "ABC");
- Object originalValue = getInstanceField("uniquePreferenceKey", gTree);
- setInstanceField("uniquePreferenceKey", gTree, "XYZ");
- setFilterOptions(TextFilterStrategy.STARTS_WITH, false);
- checkContainsNode("ABC");
- checkContainsNode("ABCX");
- assertEquals(2, viewRoot().getChildCount());
+ setFilterOptions(TextFilterStrategy.STARTS_WITH);
+ setFilterText("ABC");
+ assertNodesByName(viewRoot(), "ABC", "ABCX");
- setInstanceField("uniquePreferenceKey", gTree, originalValue);
- setInstanceField("optionsSet", gTree.getFilterProvider(), false);
- restorePreferences();
- checkContainsNode("ABC");
- assertEquals(1, viewRoot().getChildCount());
+ // close and reopen the tree so we know the preferences are saved
+ triggerSaveAndReload();
+
+ assertFilterOptions(TextFilterStrategy.STARTS_WITH);
+ setFilterText("ABC");
+ assertNodesByName(viewRoot(), "ABC", "ABCX");
+
+ // put back, test, and then make sure the updated filter is restored
+ setFilterOptions(TextFilterStrategy.MATCHES_EXACTLY);
+ setFilterText("ABC");
+ assertNodesByName(viewRoot(), "ABC");
+
+ // close and reopen the tree to verify that the new tree uses the last used filter
+ triggerSaveAndReload();
+
+ assertFilterOptions(TextFilterStrategy.MATCHES_EXACTLY);
+ setFilterText("ABC");
+ assertNodesByName(viewRoot(), "ABC");
+ }
+
+ @Test
+ public void testFilterOptionsOverride() {
+
+ //
+ // This is testing the special case of setting preferred options on the
+ // DefaultGTreeFilterProvider. When an API client sets the preferred options on that class,
+ // we have chosen to not save or restore user preferences for that filter. It is not clear
+ // why we do that, but it is probably based on the assumption that the API client wants the
+ // filter to always start in the preferred state. The prevents filter from being restored
+ // with a previous user filter that does not make sense for the general case.
+ //
+
+ // default configuration
+ assertFilterOptions(TextFilterStrategy.CONTAINS);
+
+ //
+ // Change the options and reload the tree so we know the preferences are saved
+ //
+ setFilterOptions(TextFilterStrategy.STARTS_WITH);
+ triggerSaveAndReload();
+ assertFilterOptions(TextFilterStrategy.STARTS_WITH);
+
+ // set the filter settings manually via the API
+ FilterOptions newOptions =
+ new FilterOptions(TextFilterStrategy.MATCHES_EXACTLY, false, false, false);
+ rebuildTreeWithPreferredFilter(newOptions);
+
+ // verify after building the tree with the preferred options that the previous persisted
+ // options are not applied
+ assertFilterOptions(TextFilterStrategy.MATCHES_EXACTLY);
+ }
+
+ private GTreeNode viewRoot() {
+ return gTree.getViewRoot();
+ }
+
+ private void assertFilterOptions(TextFilterStrategy expectedStrategy) {
+
+ GTreeFilterProvider filterProvider = runSwing(() -> gTree.getFilterProvider());
+ DefaultGTreeFilterProvider defaultProvider =
+ (DefaultGTreeFilterProvider) filterProvider;
+ FilterOptions filterOptions = defaultProvider.getFilterOptions();
+ TextFilterStrategy actualStrategy = filterOptions.getTextFilterStrategy();
+ assertEquals(expectedStrategy, actualStrategy);
+ }
+
+ private void triggerSaveAndReload() {
+
+ // trigger the window manager to save the table filter preferences to xml
+ Element xml = new Element("TOOL");
+ winMgr.saveToXML(xml);
+ runSwing(() -> {
+ winMgr.removeComponent(provider);
+ gTree.dispose();
+ });
+
+ // put the state back in the window manager
+ winMgr.restoreFromXML(xml);
+
+ // load the new table and let it pull the preferences from the window manager
+ buildTree();
+ }
+
+ private void rebuildTreeWithPreferredFilter(FilterOptions newOptions) {
+
+ winMgr.removeComponent(provider);
+ gTree.dispose();
+
+ GTreeNode root = new TestRootNode();
+ gTree = new GTree(root);
+
+ setPreferredFilter(newOptions);
+
+ filterField = (FilterTextField) gTree.getFilterField();
+ provider = new TestTreeComponentProvider(tool, gTree);
+ winMgr.addComponent(provider);
+
+ waitForTree();
+ }
+
+ private void setPreferredFilter(FilterOptions newOptions) {
+ runSwing(() -> {
+ GTreeFilterProvider filterProvider = gTree.getFilterProvider();
+ DefaultGTreeFilterProvider defaultProvider =
+ (DefaultGTreeFilterProvider) filterProvider;
+ defaultProvider.setPreferredFilterOptions(
+ new FilterOptions(TextFilterStrategy.MATCHES_EXACTLY, false, false, false));
+ });
}
@Test
@@ -566,6 +674,27 @@ public class GTreeFilterTest extends AbstractDockingTest {
assertEquals(0, viewRoot().getChildCount());
}
+ private void assertNodesByName(GTreeNode parent, String... nodes) {
+
+ int count = 0;
+ int rows = gTree.getRowCount();
+ for (int i = 0; i < rows; i++) {
+ TreePath path = gTree.getPathForRow(i);
+ GTreeNode node = (GTreeNode) path.getLastPathComponent();
+ if (node.isLeaf()) {
+ if (node.isLeaf()) {
+ count++;
+ }
+ }
+ }
+
+ assertEquals(nodes.length, count);
+ for (String nodeName : nodes) {
+ GTreeNode child = parent.getChild(nodeName);
+ assertNotNull("No child found by name '%s'".formatted(nodeName), child);
+ }
+ }
+
private void assertNodes(GTreeNode... nodes) {
int count = 0;
@@ -597,16 +726,6 @@ public class GTreeFilterTest extends AbstractDockingTest {
waitForTree();
}
- private void restorePreferences() {
- runSwing(() -> {
- GTreeFilterProvider filterProvider = gTree.getFilterProvider();
- Class<?>[] classes = new Class[] { DockingWindowManager.class };
- Object[] objs = new Object[] { winMgr };
- invokeInstanceMethod("loadFilterPreference", filterProvider, classes, objs);
- });
- waitForTree();
- }
-
private void checkContainsNode(String string) {
List<GTreeNode> children = viewRoot().getChildren();
for (GTreeNode gTreeNode : children) {
@@ -634,6 +753,10 @@ public class GTreeFilterTest extends AbstractDockingTest {
waitForTree();
}
+ private void setFilterOptions(final TextFilterStrategy filterStrategy) {
+ setFilterOptions(filterStrategy, false);
+ }
+
private void setFilterOptions(final TextFilterStrategy filterStrategy, final boolean inverted) {
runSwing(() -> {
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/DockingWindowManager.java b/Ghidra/Framework/Docking/src/main/java/docking/DockingWindowManager.java
index 682d070f5c..ceaad3c2a0 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/DockingWindowManager.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/DockingWindowManager.java
@@ -23,6 +23,7 @@ import java.beans.PropertyChangeListener;
import java.util.*;
import java.util.List;
import java.util.Map.Entry;
+import java.util.function.Supplier;
import javax.swing.*;
@@ -90,7 +91,7 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
private static Component pendingRequestFocusComponent;
private Map<String, ComponentProvider> providerNameCache = new HashMap<>();
- private Map<String, PreferenceState> preferenceStateMap = new HashMap<>();
+ private Map<String, Supplier<PreferenceState>> preferenceStateMap = new HashMap<>();
private ActionToGuiMapper actionToGuiMapper;
private WeakSet<PopupActionProvider> popupActionProviders =
@@ -909,6 +910,8 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
removeInstance(this);
root = null;
lastActiveWindow = null;
+
+ preferenceStateMap.clear();
}
void showComponent(ComponentProvider provider, boolean visibleState, boolean shouldEmphasize) {
@@ -1638,12 +1641,17 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
}
private Element savePreferencesToXML() {
+
Element toolPreferencesElement = new Element(TOOL_PREFERENCES_XML_NAME);
- Set<Entry<String, PreferenceState>> entrySet = preferenceStateMap.entrySet();
- for (Entry<String, PreferenceState> entry : entrySet) {
+ Set<Entry<String, Supplier<PreferenceState>>> entrySet = preferenceStateMap.entrySet();
+ for (Entry<String, Supplier<PreferenceState>> entry : entrySet) {
String key = entry.getKey();
- PreferenceState state = entry.getValue();
+ Supplier<PreferenceState> supplier = entry.getValue();
+ PreferenceState state = supplier.get();
+ if (state == null) {
+ continue;
+ }
Element preferenceElement = state.saveToXml();
preferenceElement.setAttribute("NAME", key);
toolPreferencesElement.addContent(preferenceElement);
@@ -1663,7 +1671,7 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
for (Object name : children) {
Element preferencesElement = (Element) name;
preferenceStateMap.put(preferencesElement.getAttribute("NAME").getValue(),
- new PreferenceState(preferencesElement));
+ () -> new PreferenceState(preferencesElement));
}
}
@@ -1681,7 +1689,23 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
throw new IllegalArgumentException("Key is null!");
}
- preferenceStateMap.put(key, state);
+ preferenceStateMap.put(key, () -> state);
+ }
+
+ /**
+ * Registers a supplier of the preference state for the given key. Using this method allows the
+ * window manager to query the supplier when the tool is saved. Clients can then decide whether
+ * they have any state that needs saving at that time.
+ *
+ * @param key the key with which to store the preferences.
+ * @param supplier the supplier of the state object to store.
+ */
+ public void registerPreferenceStateSupplier(String key, Supplier<PreferenceState> supplier) {
+ if (key == null) {
+ throw new IllegalArgumentException("Key is null!");
+ }
+
+ preferenceStateMap.put(key, supplier);
}
/**
@@ -1693,7 +1717,11 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
* @see #putPreferenceState(String, PreferenceState)
*/
public PreferenceState getPreferenceState(String key) {
- return preferenceStateMap.get(key);
+ Supplier<PreferenceState> supplier = preferenceStateMap.get(key);
+ if (supplier != null) {
+ return supplier.get();
+ }
+ return null;
}
/**
@@ -1705,6 +1733,20 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
preferenceStateMap.remove(key);
}
+ /**
+ * Removes the supplier of the preference state for the given key.
+ *
+ * @param key the key with which to store the preferences.
+ * @see #registerPreferenceStateSupplier(String, Supplier)
+ */
+ public void removePreferenceStateSupplier(String key) {
+ if (key == null) {
+ throw new IllegalArgumentException("Key is null!");
+ }
+
+ preferenceStateMap.remove(key);
+ }
+
private boolean isMyWindow(Window win) {
if (root == null || win == null) {
return false;
@@ -2531,8 +2573,8 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
component.addHierarchyListener(new HierarchyListener() {
@Override
public void hierarchyChanged(HierarchyEvent e) {
- long changeFlags = e.getChangeFlags();
+ long changeFlags = e.getChangeFlags();
if (HierarchyEvent.DISPLAYABILITY_CHANGED != (changeFlags &
HierarchyEvent.DISPLAYABILITY_CHANGED)) {
return;
@@ -2554,6 +2596,5 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
listener.componentLoaded(dwm, provider);
}
});
-
}
}
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/KeyBindingOverrideKeyEventDispatcher.java b/Ghidra/Framework/Docking/src/main/java/docking/KeyBindingOverrideKeyEventDispatcher.java
index a4e292e5df..6c3c55d2e8 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/KeyBindingOverrideKeyEventDispatcher.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/KeyBindingOverrideKeyEventDispatcher.java
@@ -25,8 +25,7 @@ import java.util.List;
import javax.swing.*;
import javax.swing.text.JTextComponent;
-import docking.action.DockingActionIf;
-import docking.action.MultipleKeyAction;
+import docking.action.*;
import docking.actions.KeyBindingUtils;
import docking.menu.keys.MenuKeyProcessor;
import ghidra.util.bean.GGlassPane;
@@ -246,7 +245,7 @@ public class KeyBindingOverrideKeyEventDispatcher implements KeyEventDispatcher
return false; // no actions; not a valid key stroke for this dialog
}
for (DockingActionIf action : actions) {
- if (!provider.isDialogKeyBindingAction(action)) {
+ if (!isAllowedDialogAction(provider, action)) {
return false;
}
}
@@ -254,6 +253,16 @@ public class KeyBindingOverrideKeyEventDispatcher implements KeyEventDispatcher
return true; // all actions belong to the active dialog; this is a valid action
}
+ private boolean isAllowedDialogAction(DialogComponentProvider provider,
+ DockingActionIf action) {
+
+ if (action instanceof ComponentBasedDockingAction) {
+ return true; // these actions work on low-level components, which may live in dialogs
+ }
+
+ return provider.isDialogKeyBindingAction(action);
+ }
+
private boolean isSettingKeyBindings(KeyEvent event) {
Component destination = event.getComponent();
if (destination == null) {
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/action/MultipleKeyAction.java b/Ghidra/Framework/Docking/src/main/java/docking/action/MultipleKeyAction.java
index 4ac6159670..0bc8585e15 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/action/MultipleKeyAction.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/action/MultipleKeyAction.java
@@ -194,12 +194,10 @@ public class MultipleKeyAction extends DockingKeyBindingAction {
// 2) Check for actions local to the source component
//
for (ActionData actionData : actions) {
- if (!(actionData.action instanceof ComponentBasedDockingAction)) {
+ if (!(actionData.action instanceof ComponentBasedDockingAction componentAction)) {
continue;
}
- ComponentBasedDockingAction componentAction =
- (ComponentBasedDockingAction) actionData.action;
if (componentAction.isValidComponentContext(localContext)) {
hasLocalActionsForKeyBinding = true;
if (isValidAndEnabled(actionData, localContext)) {
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/filter/FilterOptions.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/filter/FilterOptions.java
index 3d290e61a1..bd880e3a77 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/filter/FilterOptions.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/filter/FilterOptions.java
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,8 +15,7 @@
*/
package docking.widgets.filter;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
import java.util.stream.Collectors;
import javax.swing.Icon;
@@ -349,4 +348,28 @@ public class FilterOptions {
return buf.toString();
}
+ @Override
+ public int hashCode() {
+ return Objects.hash(allowGlobbing, caseSensitive, delimitingCharacter, evalMode, inverted,
+ multiTerm, textFilterStrategy, usePath);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ FilterOptions other = (FilterOptions) obj;
+ return allowGlobbing == other.allowGlobbing && caseSensitive == other.caseSensitive &&
+ delimitingCharacter == other.delimitingCharacter && evalMode == other.evalMode &&
+ inverted == other.inverted && multiTerm == other.multiTerm &&
+ textFilterStrategy == other.textFilterStrategy && usePath == other.usePath;
+ }
+
}
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/filter/FilterTextField.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/filter/FilterTextField.java
index 172f3937b2..9753b44555 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/filter/FilterTextField.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/filter/FilterTextField.java
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -298,6 +298,11 @@ public class FilterTextField extends JPanel {
textField.requestFocus();
}
+ @Override
+ public boolean requestFocusInWindow() {
+ return textField.requestFocusInWindow();
+ }
+
private void fireFilterChanged(String text) {
for (FilterListener l : listeners) {
l.filterChanged(text);
@@ -402,30 +407,21 @@ public class FilterTextField extends JPanel {
// Inner Classes
//==================================================================================================
- private class TraversalKeyListener implements KeyListener {
+ private class TraversalKeyListener extends KeyAdapter {
private final Component component;
private TraversalKeyListener(Component component) {
this.component = component;
-
}
@Override
public void keyPressed(KeyEvent e) {
- // don't care
- }
-
- @Override
- public void keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_UP || e.getKeyCode() == KeyEvent.VK_DOWN) {
component.requestFocus();
+ KeyboardFocusManager kfm = KeyboardFocusManager.getCurrentKeyboardFocusManager();
+ kfm.redispatchEvent(component, e);
}
}
-
- @Override
- public void keyTyped(KeyEvent e) {
- // don't care
- }
}
private class FlashFocusListener extends FocusAdapter {
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTable.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTable.java
index 1fe741108b..bdf5000c33 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTable.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTable.java
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -86,6 +86,8 @@ public class GTable extends JTable {
KeyStroke.getKeyStroke(KeyEvent.VK_C, CONTROL_KEY_MODIFIER_MASK | SHIFT_DOWN_MASK);
private static final KeyStroke SELECT_ALL_KEY_STROKE =
KeyStroke.getKeyStroke(KeyEvent.VK_A, CONTROL_KEY_MODIFIER_MASK);
+ private static final KeyStroke ACTIVATE_FILTER_KEY_STROKE =
+ KeyStroke.getKeyStroke(KeyEvent.VK_F, CONTROL_KEY_MODIFIER_MASK);
private static final String LAST_EXPORT_FILE = "LAST_EXPORT_DIR";
private static final KeyStroke ESCAPE = KeyStroke.getKeyStroke("ESCAPE");
@@ -129,6 +131,8 @@ public class GTable extends JTable {
private TableColumnModelListener tableColumnModelListener = null;
private final Map<Integer, GTableCellRenderingData> columnRenderingDataMap = new HashMap<>();
+ private GTableFilterPanel<?> tableFilterPanel;
+
/**
* Constructs a new GTable
*/
@@ -834,6 +838,22 @@ public class GTable extends JTable {
}
}
+ /**
+ * Sets the table filter panel being used for this table.
+ * @param filterPanel the filter panel
+ */
+ public void setTableFilterPanel(GTableFilterPanel<?> filterPanel) {
+ this.tableFilterPanel = filterPanel;
+ }
+
+ /**
+ * Returns the filter panel being used by this table or null.
+ * @return the filter panel or null
+ */
+ public GTableFilterPanel<?> getTableFilterPanel() {
+ return tableFilterPanel;
+ }
+
/**
* Sets the key for saving and restoring column configuration state. Use this if you have
* multiple instances of a table and you want different column settings for each instance.
@@ -1450,12 +1470,79 @@ public class GTable extends JTable {
selectAllAction.setHelpLocation(new HelpLocation("Tables", "SelectAll"));
//@formatter:on
+ GTableAction activateFilterAction = new GTableAction("Table/Tree Activate Filter", owner) {
+
+ @Override
+ public boolean isEnabledForContext(ActionContext context) {
+ if (!super.isEnabledForContext(context)) {
+ return false;
+ }
+
+ GTable gTable = (GTable) context.getSourceComponent();
+ return gTable.getTableFilterPanel() != null;
+ }
+
+ @Override
+ public void actionPerformed(ActionContext context) {
+
+ GTable gTable = (GTable) context.getSourceComponent();
+ GTableFilterPanel<?> filterPanel = gTable.getTableFilterPanel();
+ filterPanel.activate();
+ }
+ };
+ //@formatter:off
+ activateFilterAction.setPopupMenuData(new MenuData(
+ new String[] { "Activate Filter" },
+ null /*icon*/,
+ actionMenuGroup,
+ NO_MNEMONIC,
+ Integer.toString(subGroupIndex++)
+ )
+ );
+ activateFilterAction.setKeyBindingData(new KeyBindingData(ACTIVATE_FILTER_KEY_STROKE));
+ activateFilterAction.setHelpLocation(new HelpLocation("Trees", "Activate_Filter"));
+ //@formatter:on
+
+ GTableAction toggleFilterAction = new GTableAction("Table/Tree Toggle Filter", owner) {
+
+ @Override
+ public boolean isEnabledForContext(ActionContext context) {
+ if (!super.isEnabledForContext(context)) {
+ return false;
+ }
+
+ GTable gTable = (GTable) context.getSourceComponent();
+ return gTable.getTableFilterPanel() != null;
+ }
+
+ @Override
+ public void actionPerformed(ActionContext context) {
+
+ GTable gTable = (GTable) context.getSourceComponent();
+ GTableFilterPanel<?> filterPanel = gTable.getTableFilterPanel();
+ filterPanel.toggleVisibility();
+ }
+ };
+ //@formatter:off
+ toggleFilterAction.setPopupMenuData(new MenuData(
+ new String[] { "Toggle Filter" },
+ null /*icon*/,
+ actionMenuGroup,
+ NO_MNEMONIC,
+ Integer.toString(subGroupIndex++)
+ )
+ );
+ toggleFilterAction.setHelpLocation(new HelpLocation("Trees", "Toggle_Filter"));
+ //@formatter:on
+
toolActions.addGlobalAction(copyAction);
toolActions.addGlobalAction(copyColumnsAction);
toolActions.addGlobalAction(copyCurrentColumnAction);
toolActions.addGlobalAction(exportAction);
toolActions.addGlobalAction(exportColumnsAction);
toolActions.addGlobalAction(selectAllAction);
+ toolActions.addGlobalAction(activateFilterAction);
+ toolActions.addGlobalAction(toggleFilterAction);
}
//==================================================================================================
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTableFilterPanel.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTableFilterPanel.java
index e2eb1c8eb6..8ab0f190e7 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTableFilterPanel.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/table/GTableFilterPanel.java
@@ -25,6 +25,7 @@ import javax.swing.border.BevelBorder;
import javax.swing.event.*;
import javax.swing.table.TableColumnModel;
+import org.jdom.Attribute;
import org.jdom.Element;
import docking.DockingWindowManager;
@@ -112,13 +113,18 @@ public class GTableFilterPanel<ROW_OBJECT> extends JPanel {
private FilterTextField filterField;
private FilterListener filterListener = new GTableFilterListener();
- private FilterOptions filterOptions = new FilterOptions();
+ private static final FilterOptions DEFAULT_OPTIONS = new FilterOptions();
+ private FilterOptions filterOptions = DEFAULT_OPTIONS;
private TableTextFilterFactory<ROW_OBJECT> filterFactory =
new DefaultTableTextFilterFactory<>(filterOptions);
private RowFilterTransformer<ROW_OBJECT> transformer;
private TableFilter<ROW_OBJECT> secondaryTableFilter;
private EmptyBorderButton filterStateButton;
+ // This tracks whether the filter has been configured to be part of the display, whether by the
+ // user or via the API.
+ private boolean isFilterDisplayed = true;
+
private ColumnFilterManager<ROW_OBJECT> columnFilterManager;
private String uniquePreferenceKey;
@@ -231,41 +237,76 @@ public class GTableFilterPanel<ROW_OBJECT> extends JPanel {
table.addPropertyChangeListener(badProgrammingPropertyChangeListener);
DockingWindowManager.registerComponentLoadedListener(this,
- (windowManager, provider) -> loadFilterPreference(windowManager));
- }
+ (windowManager, provider) -> componentLoaded(windowManager));
- private void loadFilterPreference(DockingWindowManager dockingWindowManager) {
- if (dockingWindowManager != null) {
- PreferenceState preferenceState =
- dockingWindowManager.getPreferenceState(uniquePreferenceKey);
- if (preferenceState != null) {
- Element xmlElement = preferenceState.getXmlElement(FILTER_STATE);
- restoreFromXML(xmlElement);
- }
+ if (table instanceof GTable gTable) {
+ gTable.setTableFilterPanel(this);
}
}
- private void doSaveState() {
- PreferenceState preferenceState = new PreferenceState();
- preferenceState.putXmlElement(FILTER_STATE, saveToXML());
+ private void componentLoaded(DockingWindowManager windowManager) {
- DockingWindowManager dockingWindowManager = DockingWindowManager.getInstance(table);
- if (dockingWindowManager != null) {
- dockingWindowManager.putPreferenceState(uniquePreferenceKey, preferenceState);
+ if (windowManager == null) {
+ return;
}
+
+ //
+ // We have just been loaded into the UI. The window manager has the current preference
+ // state if any has been saved. First, load any saved state into this class.
+ //
+ PreferenceState preferenceState =
+ windowManager.getPreferenceState(uniquePreferenceKey);
+ loadFromPreferenceState(preferenceState);
+
+ //
+ // Next, register a preference state supplier so that we will get asked for our current
+ // state when the tool is saved. When asked for our state, we will make the decision as to
+ // whether or not we have anything to save. There is no need to remove our supplier later,
+ // as it will be disposed when the tool is closed.
+ //
+ windowManager.registerPreferenceStateSupplier(uniquePreferenceKey,
+ () -> createPreferenceState());
}
- private Element saveToXML() {
- return filterOptions.toXML();
+ private void loadFromPreferenceState(PreferenceState preferenceState) {
+ if (preferenceState == null) {
+ return;
+ }
+
+ Element element = preferenceState.getXmlElement(FILTER_STATE);
+ if (element == null) {
+ return;
+ }
+
+ filterOptions = FilterOptions.restoreFromXML(element);
+ updateFilterFactory();
+
+ Attribute attribute = element.getAttribute("IS_SHOWING");
+ if (attribute != null) { // null when loading old settings
+ boolean shouldBeDisplayed = Boolean.parseBoolean(attribute.getValue());
+ if (shouldBeDisplayed != isFilterDisplayed) {
+ doToggleVisibility();
+ }
+ }
+
+ filterUpdater.updateLater();
}
- private void restoreFromXML(Element xmlElement) {
- if (xmlElement != null) {
- this.filterOptions = FilterOptions.restoreFromXML(xmlElement);
- updateFilterFactory();
- filterUpdater.updateLater();
+ private PreferenceState createPreferenceState() {
+ if (isDefaultFilterOptions()) {
+ return null;
}
+
+ PreferenceState preferenceState = new PreferenceState();
+ Element xmlElement = filterOptions.toXML();
+ xmlElement.setAttribute("IS_SHOWING", Boolean.toString(isFilterDisplayed));
+ preferenceState.putXmlElement(FILTER_STATE, xmlElement);
+ return preferenceState;
+ }
+
+ private boolean isDefaultFilterOptions() {
+ return isFilterDisplayed && DEFAULT_OPTIONS.equals(filterOptions);
}
protected TableFilter<ROW_OBJECT> getCombinedTableFilter(TableFilter<ROW_OBJECT> filter1,
@@ -343,7 +384,51 @@ public class GTableFilterPanel<ROW_OBJECT> extends JPanel {
this.filterOptions = filterOptions;
updateFilterFactory();
filterUpdater.updateLater();
- doSaveState();
+ }
+
+ /**
+ * Returns the filter options used by the filter factory of this class.
+ * @return the filter options used by the filter factory of this class.
+ */
+ public FilterOptions getFilterOptions() {
+ return filterOptions;
+ }
+
+ /**
+ * Activates this filter by showing it, if not visible, and then requesting focus in the filter
+ * text field.
+ */
+ public void activate() {
+ if (!isFilterDisplayed) {
+ setVisible(true);
+ isFilterDisplayed = true;
+ }
+
+ requestFocus();
+ }
+
+ /**
+ * Changes the visibility of this filter panel, make it not visible it if showing, showing it if
+ * not visible.
+ */
+ public void toggleVisibility() {
+ doToggleVisibility();
+ if (isFilterDisplayed) {
+ requestFocus();
+ }
+ }
+
+ private void doToggleVisibility() {
+ if (isFilterDisplayed) {
+ setFilterText(""); // clear the filter when not showing to avoid confusing the user
+ setVisible(false);
+ isFilterDisplayed = false;
+ return;
+ }
+
+ // make filter displayed and maybe focus it
+ setVisible(true);
+ isFilterDisplayed = true;
}
private void buildPanel(String filterLabel) {
@@ -371,7 +456,6 @@ public class GTableFilterPanel<ROW_OBJECT> extends JPanel {
helpService.registerHelp(filterStateButton, helpLocation);
helpService.registerHelp(searchLabel, helpLocation);
helpService.registerHelp(filterField, helpLocation);
-
}
private JComponent buildFilterStateButton() {
@@ -459,6 +543,12 @@ public class GTableFilterPanel<ROW_OBJECT> extends JPanel {
}
public void dispose() {
+
+ DockingWindowManager dwm = DockingWindowManager.getInstance(this);
+ if (dwm != null) {
+ dwm.removePreferenceStateSupplier(uniquePreferenceKey);
+ }
+
// Unusual Code Alert: we have to remove this particular listener due to a memory leak.
// Removing the listener or null-ing out the reference both allow us to be garbage
// collected. If we do neither, then we are not collected for some strange reason (even
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/DefaultGTreeFilterProvider.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/DefaultGTreeFilterProvider.java
index bddba92fb6..2d42aac0f7 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/DefaultGTreeFilterProvider.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/DefaultGTreeFilterProvider.java
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -21,6 +21,7 @@ import javax.accessibility.AccessibleContext;
import javax.swing.*;
import javax.swing.border.BevelBorder;
+import org.jdom.Attribute;
import org.jdom.Element;
import docking.DockingWindowManager;
@@ -42,6 +43,10 @@ public class DefaultGTreeFilterProvider implements GTreeFilterProvider {
private GTreeFilterFactory filterFactory;
private FilterDocumentListener filterListener = new FilterDocumentListener();
+ // This tracks whether the filter has been configured to be part of the display, whether by the
+ // user or via the API.
+ private boolean isFilterDisplayed = true;
+
private GTree gTree;
private JPanel filterPanel;
private FilterTransformer<GTreeNode> dataTransformer = new DefaultGTreeDataTransformer();
@@ -122,52 +127,154 @@ public class DefaultGTreeFilterProvider implements GTreeFilterProvider {
gTree.filterChanged();
}
- private void saveFilterState() {
- PreferenceState preferenceState = new PreferenceState();
- preferenceState.putXmlElement(FILTER_STATE, filterFactory.getFilterOptions().toXML());
+ private PreferenceState createPreferenceState() {
- DockingWindowManager dwm = DockingWindowManager.getInstance(gTree.getJTree());
- if (dwm != null) {
- dwm.putPreferenceState(gTree.getPreferenceKey(), preferenceState);
+ if (isDefaultFilterOptions()) {
+ return null; // don't save default settings
}
+
+ if (optionsSet) {
+ return null; // don't save custom options (see setPreferredOptions())
+ }
+
+ PreferenceState preferenceState = new PreferenceState();
+ Element element = filterFactory.getFilterOptions().toXML();
+ element.setAttribute("IS_SHOWING", Boolean.toString(isFilterDisplayed));
+ preferenceState.putXmlElement(FILTER_STATE, element);
+ return preferenceState;
}
- public void setFilterOptions(FilterOptions filterOptions) {
+ private boolean isDefaultFilterOptions() {
+ return isFilterDisplayed && filterFactory.isDefault();
+ }
+
+ public FilterOptions getFilterOptions() {
+ return filterFactory.getFilterOptions();
+ }
+
+ /**
+ * A method to allow clients to change the current filter settings to something they would like
+ * for their particular use case. This differs from {@link #setFilterOptions(FilterOptions)} in
+ * that this method will also disable saving any changes the user makes to the filter. If you
+ * do not need to disable preference saving, then call the other method.
+ * <p>
+ * This method disables preference saving with the assumption that some clients always wish the
+ * filter to start in the same preferred state instead of where the user last left it.
+ * It is not clear why we do that, but it is probably based on the assumption that the API
+ * client wants the filter to always start in the preferred state. The prevents filter from
+ * being restored with a previous user filter that does not make sense for the general case.
+ *
+ * @param filterOptions the options
+ * @see #setFilterOptions(FilterOptions)
+ */
+ public void setPreferredFilterOptions(FilterOptions filterOptions) {
optionsSet = true;
filterFactory = new GTreeFilterFactory(filterOptions);
- saveFilterState();
updateModelFilter();
}
- public FilterOptions getFilterOptions() {
- return filterFactory.getFilterOptions();
+ /**
+ * Sets the options for this filter provider.
+ * @param filterOptions the new filter options
+ */
+ public void setFilterOptions(FilterOptions filterOptions) {
+ filterFactory = new GTreeFilterFactory(filterOptions);
+ updateModelFilter();
}
@Override
- public void loadFilterPreference(DockingWindowManager windowManager) {
- if (optionsSet) { // if the options were specifically set, don't restore saved values
+ public void activate() {
+ if (!isFilterDisplayed) {
+ filterPanel.setVisible(true);
+ isFilterDisplayed = true;
+ }
+
+ filterPanel.requestFocus();
+ }
+
+ @Override
+ public void toggleVisibility() {
+ doToggleVisibility();
+ if (isFilterDisplayed) {
+ filterPanel.requestFocus();
+ }
+ }
+
+ private void doToggleVisibility() {
+ if (isFilterDisplayed) {
+ setFilterText(""); // clear the filter when not showing to avoid confusing the user
+ filterPanel.setVisible(false);
+ isFilterDisplayed = false;
return;
}
+ // make filter displayed and maybe focus it
+ filterPanel.setVisible(true);
+ isFilterDisplayed = true;
+ }
+
+ @Override
+ public void loadFilterPreference(DockingWindowManager windowManager) {
+
if (windowManager == null) {
return;
}
- PreferenceState state = windowManager.getPreferenceState(gTree.getPreferenceKey());
- if (state == null) {
+ // Check to see if the options were specifically set via the API. In this case, we do not
+ // save user changes to the filter options. Not sure exactly why at this point, or if this
+ // is even the preferred behavior. Leaving it this way for now.
+ if (optionsSet) {
+ return;
+ }
+
+ //
+ // We have just been loaded into the UI. The window manager has the current preference
+ // state if any has been saved. First, load any saved state into this class.
+ //
+ String key = gTree.getPreferenceKey();
+ PreferenceState preferenceState = windowManager.getPreferenceState(key);
+ loadFromPreferenceState(preferenceState);
+
+ //
+ // Next, register a preference state supplier so that we will get asked for our current
+ // state when the tool is saved. When asked for our state, we will make the decision as to
+ // whether or not we have anything to save. There is no need to remove our supplier later,
+ // as it will be disposed when the tool is closed.
+ //
+ windowManager.registerPreferenceStateSupplier(key, () -> createPreferenceState());
+ }
+
+ private void loadFromPreferenceState(PreferenceState preferenceState) {
+ if (preferenceState == null) {
return;
}
- Element xmlElement = state.getXmlElement(FILTER_STATE);
- if (xmlElement != null) {
- FilterOptions filterOptions = FilterOptions.restoreFromXML(xmlElement);
- filterFactory = new GTreeFilterFactory(filterOptions);
+ Element element = preferenceState.getXmlElement(FILTER_STATE);
+ if (element == null) {
+ return;
}
+
+ FilterOptions filterOptions = FilterOptions.restoreFromXML(element);
+ filterFactory = new GTreeFilterFactory(filterOptions);
+
+ Attribute attribute = element.getAttribute("IS_SHOWING");
+ if (attribute != null) { // null when loading old settings
+ boolean shouldBeDisplayed = Boolean.parseBoolean(attribute.getValue());
+ if (shouldBeDisplayed != isFilterDisplayed) {
+ doToggleVisibility();
+ }
+ }
+
updateModelFilter();
}
private JPanel createFilterPanel() {
- JPanel newFilterPanel = new JPanel(new BorderLayout());
+ JPanel newFilterPanel = new JPanel(new BorderLayout()) {
+ @Override
+ public void requestFocus() {
+ filterField.requestFocus();
+ }
+ };
newFilterPanel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
JLabel filterLabel = new GLabel(" Filter: ");
newFilterPanel.add(filterLabel, BorderLayout.WEST);
@@ -184,7 +291,6 @@ public class DefaultGTreeFilterProvider implements GTreeFilterProvider {
FilterOptions newFilterOptions = dialog.getResultFilterOptions();
if (newFilterOptions != null) {
filterFactory = new GTreeFilterFactory(newFilterOptions);
- saveFilterState();
updateModelFilter();
}
});
@@ -200,21 +306,6 @@ public class DefaultGTreeFilterProvider implements GTreeFilterProvider {
return newFilterPanel;
}
- private class FilterDocumentListener implements FilterListener {
- private boolean processEvents = true;
-
- @Override
- public void filterChanged(String text) {
- if (processEvents) {
- updateModelFilter();
- }
- }
-
- void enableEvents(boolean enable) {
- processEvents = enable;
- }
- }
-
@Override
public GTreeFilter getFilter() {
return filterFactory.getTreeFilter(filterField.getText(), dataTransformer);
@@ -230,4 +321,28 @@ public class DefaultGTreeFilterProvider implements GTreeFilterProvider {
this.dataTransformer = transformer;
}
+ @Override
+ public void dispose() {
+ DockingWindowManager dwm = DockingWindowManager.getInstance(getFilterComponent());
+ if (dwm != null) {
+ String key = gTree.getPreferenceKey();
+ dwm.removePreferenceStateSupplier(key);
+ }
+ }
+
+ private class FilterDocumentListener implements FilterListener {
+ private boolean processEvents = true;
+
+ @Override
+ public void filterChanged(String text) {
+ if (processEvents) {
+ updateModelFilter();
+ }
+ }
+
+ void enableEvents(boolean enable) {
+ processEvents = enable;
+ }
+ }
+
}
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/GTree.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/GTree.java
index 416f717200..054c03cbb8 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/GTree.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/GTree.java
@@ -276,6 +276,7 @@ public class GTree extends JPanel implements BusyListener {
}
public void dispose() {
+
ignoredNodes.clear();
filterUpdateManager.dispose();
worker.dispose();
@@ -283,6 +284,7 @@ public class GTree extends JPanel implements BusyListener {
if (realModelRootNode != null) {
realModelRootNode.dispose();
}
+
// if there is a filter applied, clean up the filtered nodes. Note that filtered nodes
// are expected to be shallow clones of the model nodes, so we don't want to call full
// dispose on the filtered nodes because internal clean-up should happen when the
@@ -290,6 +292,9 @@ public class GTree extends JPanel implements BusyListener {
if (realViewRootNode != null && realViewRootNode != realModelRootNode) {
realViewRootNode.disposeClones();
}
+
+ filterProvider.dispose();
+
model.dispose();
Gui.removeThemeListener(themeListener);
@@ -736,7 +741,7 @@ public class GTree extends JPanel implements BusyListener {
}
public void setFilterProvider(GTreeFilterProvider filterProvider) {
- this.filterProvider = filterProvider;
+ this.filterProvider = Objects.requireNonNull(filterProvider);
removeAll();
add(mainPanel, BorderLayout.CENTER);
JComponent filterComponent = filterProvider.getFilterComponent();
@@ -1786,6 +1791,39 @@ public class GTree extends JPanel implements BusyListener {
expandTreeAction.setHelpLocation(new HelpLocation("Trees", "Expand_Tree"));
//@formatter:on
+ GTreeAction activateFilterAction = new GTreeAction("Table/Tree Activate Filter", owner) {
+ @Override
+ public void actionPerformed(ActionContext context) {
+ GTree gTree = (GTree) context.getSourceComponent();
+ gTree.filterProvider.activate();
+ }
+ };
+ //@formatter:off
+ activateFilterAction.setPopupMenuData(new MenuData(
+ new String[] { "Activate Filter" },
+ null,
+ actionMenuGroup, NO_MNEMONIC,
+ Integer.toString(subGroupIndex++)
+ )
+ );
+ activateFilterAction.setKeyBindingData(new KeyBindingData("Control F"));
+ activateFilterAction.setHelpLocation(new HelpLocation("Trees", "Toggle_Filter"));
+
+ GTreeAction toggleFilterAction = new GTreeAction("Table/Tree Toggle Filter", owner) {
+ @Override
+ public void actionPerformed(ActionContext context) {
+ GTree gTree = (GTree) context.getSourceComponent();
+ gTree.filterProvider.toggleVisibility();
+ }
+ };
+ //@formatter:on
+ toggleFilterAction.setPopupMenuData(new MenuData(
+ new String[] { "Toggle Filter" },
+ null,
+ actionMenuGroup, NO_MNEMONIC,
+ Integer.toString(subGroupIndex++)));
+ toggleFilterAction.setHelpLocation(new HelpLocation("Trees", "Toggle_Filter"));
+
// these actions are self-explanatory and do need help
collapseAction.markHelpUnnecessary();
expandAction.markHelpUnnecessary();
@@ -1796,6 +1834,8 @@ public class GTree extends JPanel implements BusyListener {
toolActions.addGlobalAction(expandAction);
toolActions.addGlobalAction(collapseTreeAction);
toolActions.addGlobalAction(expandTreeAction);
+ toolActions.addGlobalAction(activateFilterAction);
+ toolActions.addGlobalAction(toggleFilterAction);
}
private static String generateFilterPreferenceKey() {
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/GTreeFilterFactory.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/GTreeFilterFactory.java
index 1e20e57fbf..fd9fd63a1e 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/GTreeFilterFactory.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/GTreeFilterFactory.java
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -15,8 +15,7 @@
*/
package docking.widgets.tree;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
import javax.swing.Icon;
import javax.swing.tree.TreePath;
@@ -27,14 +26,15 @@ import ghidra.util.FilterTransformer;
public class GTreeFilterFactory {
+ private static final FilterOptions DEFAULT_OPTIONS = new FilterOptions();
private FilterOptions filterOptions;
public GTreeFilterFactory() {
- this(new FilterOptions());
+ this(DEFAULT_OPTIONS);
}
public GTreeFilterFactory(FilterOptions filterOptions) {
- this.filterOptions = filterOptions;
+ this.filterOptions = Objects.requireNonNull(filterOptions);
}
public FilterOptions getFilterOptions() {
@@ -87,6 +87,10 @@ public class GTreeFilterFactory {
return filterOptions.getFilterStateIcon();
}
+ public boolean isDefault() {
+ return DEFAULT_OPTIONS.equals(filterOptions);
+ }
+
/**
* A class that takes in a client node filter transformer and wraps it so that any text returned
* by the client will have the node path prepended.
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/GTreeFilterProvider.java b/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/GTreeFilterProvider.java
index 1d2bb74e74..58e302b5a0 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/GTreeFilterProvider.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/widgets/tree/GTreeFilterProvider.java
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -63,7 +63,11 @@ public interface GTreeFilterProvider {
public void setDataTransformer(FilterTransformer<GTreeNode> transformer);
/**
- * Loads any filter preferences that have been saved.
+ * Loads any filter preferences that have been saved.
+ * <p>
+ * This is called when the tree is first made visible in the tool. This is the chance for the
+ * filter to load any preferences and to add a preference supplier to the window manager.
+ *
* @param windowManager the {@link DockingWindowManager} to load preferences from
*/
public void loadFilterPreference(DockingWindowManager windowManager);
@@ -94,4 +98,38 @@ public interface GTreeFilterProvider {
public default GTreeFilterProvider copy(GTree gTree) {
return null;
}
+
+ /**
+ * Activates this filter by showing it, if not visible, and then requesting focus in the filter
+ * text field.
+ */
+ public default void activate() {
+ JComponent c = getFilterComponent();
+ if (!c.isShowing()) {
+ c.setVisible(true);
+ }
+ c.requestFocus();
+ }
+
+ /**
+ * Changes the visibility of the filter, make it not visible it if showing, showing it if
+ * not visible.
+ */
+ public default void toggleVisibility() {
+ JComponent c = getFilterComponent();
+ if (c.isShowing()) {
+ c.setVisible(false);
+ }
+ else {
+ c.setVisible(true);
+ c.requestFocus();
+ }
+ }
+
+ /**
+ * A method for subclasses to do any optional cleanup
+ */
+ public default void dispose() {
+ // stub
+ }
}
diff --git a/Ghidra/Framework/Generic/src/main/java/generic/test/ConcurrentTestExceptionStatement.java b/Ghidra/Framework/Generic/src/main/java/generic/test/ConcurrentTestExceptionStatement.java
index 91c8b8705b..b8720a9e43 100644
--- a/Ghidra/Framework/Generic/src/main/java/generic/test/ConcurrentTestExceptionStatement.java
+++ b/Ghidra/Framework/Generic/src/main/java/generic/test/ConcurrentTestExceptionStatement.java
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -197,7 +197,7 @@ public class ConcurrentTestExceptionStatement extends Statement {
}
}
- @SuppressWarnings("deprecation") // Thread.stop()
+ @SuppressWarnings({ "removal" }) // Thread.stop()
private void checkForTestTimeout(TestThread testThread) {
if (timoutMonitor == null || !timoutMonitor.didRun()) {
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatable/ProjectDataTablePanel.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatable/ProjectDataTablePanel.java
index aa12a134e6..454346a554 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatable/ProjectDataTablePanel.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatable/ProjectDataTablePanel.java
@@ -4,9 +4,9 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -208,7 +208,8 @@ public class ProjectDataTablePanel extends JPanel {
public ActionContext getActionContext(ComponentProvider provider, MouseEvent e) {
int[] selectedRows = gTable.getSelectedRows();
if (selectedRows.length == 0) {
- return null;
+ return new ProjectDataContext(provider, projectData, gTable, null, null, gTable,
+ true);
}
List<DomainFile> list = new ArrayList<>();
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/PluginTool.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/PluginTool.java
index 5dd633d397..7823c908e0 100644
--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/PluginTool.java
+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/plugintool/PluginTool.java
@@ -1544,6 +1544,13 @@ public abstract class PluginTool extends AbstractDockingTool {
return isConfigurable;
}
+ /**
+ * This method will be deleted. Preference state should be managed with the
+ * {@link DockingWindowManager}.
+ * @param name the name
+ * @deprecated use the {@link DockingWindowManager}
+ */
+ @Deprecated(since = "11.3", forRemoval = true)
public void removePreferenceState(String name) {
winMgr.removePreferenceState(name);
}