Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-3870 - Data Types - Added more filterable types

dragonmacherba15d9368dd3
diff --git a/Ghidra/Features/Base/src/main/help/help/topics/ConsolePlugin/console.html b/Ghidra/Features/Base/src/main/help/help/topics/ConsolePlugin/console.html
index 8f9f58291b..37cec964ae 100644
--- a/Ghidra/Features/Base/src/main/help/help/topics/ConsolePlugin/console.html
+++ b/Ghidra/Features/Base/src/main/help/help/topics/ConsolePlugin/console.html
@@ -29,18 +29,26 @@
<P align="center"><IMG border="0" src="images/Console.png"></P>
<H2><A name="Scroll_Lock"></A>Scroll Lock <IMG border="0" src="images/lock.png"></H2>
-
<BLOCKQUOTE>
- <P align="left">This command stops the console from automatically scrolling as new output is
+ <P align="left">This action stops the console from automatically scrolling as new output is
appended.</P>
</BLOCKQUOTE>
<H2><A name="Clear_Console"></A>Clear <IMG border="0" src="images/erase16.png"></H2>
-
<BLOCKQUOTE>
- <P align="left">This command clears all content in the <I>Console</I> component.</P>
+ <P align="left">This action clears all content in the <I>Console</I> component.</P>
</BLOCKQUOTE>
+ <H2><A name="Console_Find"></A>Find</H2>
+ <BLOCKQUOTE>
+ <P align="left">This action shows a dialog that allows you to search for all occurrences
+ of some text. The dialog supports
+ <A href="help/topics/Search/Regular_Expressions.htm#Regex_Syntax">Regular Expressions</A>.
+ While the dialog is open, all matching text is highlighted. If the cursor is in a match,
+ then the highlight color for that match will be different than the rest.
+ </P>
+ </BLOCKQUOTE>
+
<H2 align="left">Navigation</H2>
<BLOCKQUOTE>
@@ -53,5 +61,11 @@
<P align="left" class="providedbyplugin">Provided by: <I>ConsolePlugin</I></P>
+ <P class="relatedtopic">Related Topics</P>
+ <UL>
+ <LI><A href="help/topics/Tables/GhidraTableHeaders.html">Table Sorting</A></LI>
+ <LI><A href="help/topics/Search/Regular_Expressions.htm">Regular Expressions</A></LI>
+ </UL>
+
</BODY>
</HTML>
diff --git a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/data_type_manager_window.html b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/data_type_manager_window.html
index 45cc545521..f458d47028 100644
--- a/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/data_type_manager_window.html
+++ b/Ghidra/Features/Base/src/main/help/help/topics/DataTypeManagerPlugin/data_type_manager_window.html
@@ -383,15 +383,9 @@
<P><IMG alt="" src="images/collapse_all.png"> - Collapses all open
tree nodes, except for the root node.</P>
- <P><A name="Filter_Arrays"></A><IMG alt="" src="images/Array.png"> -
- Toggles the array filter on or off. If the filter is on, array data types
- are not shown in
- the data type tree.</P>
-
- <P><A name="Filter_Pointers"></A><IMG alt="" src="images/fingerPointer.png"> -
- Toggles the pointer filter on or off. If the filter is on, pointer data types
- are not shown in the data type tree.</P>
- </BLOCKQUOTE>
+ <P><A name="Show_Filter"></A><IMG alt="" src="Icons.CONFIGURE_FILTER_ICON"> -
+ Shows the filter dialog that allows you to filter certain data types from the tree.
+ </P>
<H2>Local Menu Actions</H2>
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 6af95de1ee..992314ece6 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
@@ -553,6 +553,7 @@
<UL>
<LI><A href="help/topics/Tables/GhidraTableHeaders.html">Table Sorting</A></LI>
+ <LI><A href="help/topics/Search/Regular_Expressions.htm">Regular Expressions</A></LI>
</UL>
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/console/ConsoleComponentProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/console/ConsoleComponentProvider.java
index 5bec699d6b..a898297c02 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/console/ConsoleComponentProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/console/ConsoleComponentProvider.java
@@ -30,6 +30,7 @@ import docking.widgets.TextComponentSearcher;
import generic.theme.GIcon;
import generic.theme.Gui;
import ghidra.app.services.*;
+import ghidra.app.util.HelpTopics;
import ghidra.framework.main.ConsoleTextPane;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.ComponentProviderAdapter;
@@ -175,6 +176,7 @@ public class ConsoleComponentProvider extends ComponentProviderAdapter implement
new ActionBuilder("Find", getOwner())
.keyBinding("Ctrl F")
.sharedKeyBinding()
+ .helpLocation(new HelpLocation(HelpTopics.CONSOLE, "Console_Find"))
.popupMenuPath("Find...")
.onAction(c -> {
showFindDialog();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPlugin.java
index eae97887ba..4844c7cb35 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPlugin.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.
@@ -44,6 +44,7 @@ import ghidra.app.plugin.core.datamgr.actions.associate.*;
import ghidra.app.plugin.core.datamgr.archive.*;
import ghidra.app.plugin.core.datamgr.editor.DataTypeEditorManager;
import ghidra.app.plugin.core.datamgr.tree.ArchiveNode;
+import ghidra.app.plugin.core.datamgr.tree.DtFilterState;
import ghidra.app.plugin.core.datamgr.util.DataDropOnBrowserHandler;
import ghidra.app.plugin.core.datamgr.util.DataTypeChooserDialog;
import ghidra.app.services.*;
@@ -369,8 +370,8 @@ public class DataTypeManagerPlugin extends ProgramPlugin
DataTypesProvider newProvider = new DataTypesProvider(this, SEARCH_PROVIDER_NAME, true);
newProvider.setIncludeDataTypeMembersInFilter(provider.isIncludeDataMembersInSearch());
- newProvider.setFilteringArrays(provider.isFilteringArrays());
- newProvider.setFilteringPointers(provider.isFilteringPointers());
+ DtFilterState filterState = provider.getFilterState();
+ newProvider.setFilterState(filterState.copy());
return newProvider;
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypesProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypesProvider.java
index cfd8c57280..c056c579e4 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypesProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/DataTypesProvider.java
@@ -60,8 +60,6 @@ import util.HistoryList;
public class DataTypesProvider extends ComponentProviderAdapter {
private static final String TITLE = "Data Type Manager";
- private static final String POINTER_FILTER_STATE = "PointerFilterState";
- private static final String ARRAY_FILTER_STATE = "ArrayFilterState";
private static final String CONFLICT_RESOLUTION_MODE = "ConflictResolutionMode";
private static final String PREVIEW_WINDOW_STATE = "PreviewWindowState";
private static final String INCLUDE_DATA_MEMBERS_IN_SEARCH = "DataMembersInSearchState";
@@ -73,7 +71,6 @@ public class DataTypesProvider extends ComponentProviderAdapter {
private int defaultDividerSize;
private JScrollPane previewScrollPane;
private JTextPane previewPane;
-
private GTreeNode lastPreviewNode;
private SwingUpdateManager previewUpdateManager =
new SwingUpdateManager(100, () -> updatePreviewPane());
@@ -90,13 +87,13 @@ public class DataTypesProvider extends ComponentProviderAdapter {
private MultiActionDockingAction previousAction;
private ConflictHandlerModesAction conflictHandlerModesAction;
- private ToggleDockingAction filterArraysAction;
- private ToggleDockingAction filterPointersAction;
+ private DtFilterAction filterAction;
private ToggleDockingAction previewWindowAction;
private ToggleDockingAction includeDataMembersInSearchAction;
private FilterOnNameOnlyAction filterOnNameOnlyAction;
private boolean includeDataMembersInFilter;
private boolean filterOnNameOnly;
+ private DtFilterState filterState = new DtFilterState();
public DataTypesProvider(DataTypeManagerPlugin plugin, String providerName) {
this(plugin, providerName, false);
@@ -217,8 +214,8 @@ public class DataTypesProvider extends ComponentProviderAdapter {
addLocalAction(previousAction);
nextAction = new NextPreviousDataTypeAction(this, plugin.getName(), true);
addLocalAction(nextAction);
- addLocalAction(getFilterArraysAction());
- addLocalAction(getFilterPointersAction());
+ filterAction = new DtFilterAction(plugin);
+ addLocalAction(filterAction);
addLocalAction(getConflictHandlerModesAction());
// toolbar menu
@@ -300,30 +297,13 @@ public class DataTypesProvider extends ComponentProviderAdapter {
return archiveGTree.isFiltered();
}
- public boolean isFilteringPointers() {
- return filterPointersAction.isSelected();
- }
-
- public boolean isFilteringArrays() {
- return filterArraysAction.isSelected();
+ public DtFilterState getFilterState() {
+ return filterState;
}
- private ToggleDockingAction getFilterPointersAction() {
- if (filterPointersAction == null) {
- filterPointersAction = new FilterPointersAction(plugin);
- archiveGTree.enablePointerFilter(filterPointersAction.isSelected());
- }
-
- return filterPointersAction;
- }
-
- private ToggleDockingAction getFilterArraysAction() {
- if (filterArraysAction == null) {
- filterArraysAction = new FilterArraysAction(plugin);
- archiveGTree.enableArrayFilter(filterArraysAction.isSelected());
- }
-
- return filterArraysAction;
+ public void setFilterState(DtFilterState filterState) {
+ this.filterState = filterState;
+ archiveGTree.setFilterState(filterState);
}
private ConflictHandlerModesAction getConflictHandlerModesAction() {
@@ -645,8 +625,7 @@ public class DataTypesProvider extends ComponentProviderAdapter {
}
void restore(SaveState saveState) {
- boolean filterPointers = saveState.getBoolean(POINTER_FILTER_STATE, true);
- boolean filterArrays = saveState.getBoolean(ARRAY_FILTER_STATE, true);
+
ConflictResolutionPolicy conflictMode;
try {
conflictMode =
@@ -656,12 +635,12 @@ public class DataTypesProvider extends ComponentProviderAdapter {
catch (IllegalArgumentException e) {
conflictMode = ConflictResolutionPolicy.RENAME_AND_ADD;
}
- getFilterPointersAction().setSelected(filterPointers);
- getFilterArraysAction().setSelected(filterArrays);
+
getConflictHandlerModesAction().setCurrentActionStateByUserData(conflictMode);
- archiveGTree.enableArrayFilter(filterArrays);
- archiveGTree.enablePointerFilter(filterPointers);
+ filterState = new DtFilterState();
+ filterState.restore(saveState);
+ archiveGTree.setFilterState(filterState);
boolean previewWindowVisible = saveState.getBoolean(PREVIEW_WINDOW_STATE, false);
getPreviewWindowAction().setSelected(previewWindowVisible);
@@ -671,8 +650,9 @@ public class DataTypesProvider extends ComponentProviderAdapter {
}
void save(SaveState saveState) {
- saveState.putBoolean(POINTER_FILTER_STATE, getFilterPointersAction().isSelected());
- saveState.putBoolean(ARRAY_FILTER_STATE, getFilterArraysAction().isSelected());
+
+ filterState.save(saveState);
+
saveState.putString(CONFLICT_RESOLUTION_MODE,
getConflictHandlerModesAction().getCurrentUserData().toString());
saveState.putBoolean(PREVIEW_WINDOW_STATE, getPreviewWindowAction().isSelected());
@@ -840,14 +820,6 @@ public class DataTypesProvider extends ComponentProviderAdapter {
filterOnNameOnlyAction.setSelected(newValue);
}
- public void setFilteringArrays(boolean b) {
- archiveGTree.enableArrayFilter(b);
- }
-
- public void setFilteringPointers(boolean b) {
- archiveGTree.enablePointerFilter(b);
- }
-
public boolean isIncludeDataMembersInSearch() {
return includeDataMembersInFilter;
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/CreatePointerAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/CreatePointerAction.java
index f4132c1554..cf35d16fe3 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/CreatePointerAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/CreatePointerAction.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.
@@ -57,7 +57,8 @@ public class CreatePointerAction extends DockingAction {
createNewDataType(gTree, pointerDataType, categoryPath, dataTypeManager);
DataTypesProvider provider = plugin.getProvider();
- if (provider.isFilteringPointers()) {
+ DtFilterState filterState = provider.getFilterState();
+ if (!filterState.isShowPointers()) {
DataTypePath newPath = new DataTypePath(categoryPath, newDataType.getName());
DataTypeManager newManager = newDataType.getDataTypeManager();
Msg.showInfo(getClass(), gTree, "Pointers Filter Enabled",
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FilterArraysAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/DtFilterAction.java
similarity index 51%
rename from Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FilterArraysAction.java
rename to Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/DtFilterAction.java
index 95253ccff3..a91704c5f6 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FilterArraysAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/DtFilterAction.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.
@@ -17,57 +17,61 @@ package ghidra.app.plugin.core.datamgr.actions;
import java.util.List;
-import javax.swing.Icon;
import javax.swing.tree.TreePath;
import docking.ActionContext;
-import docking.action.ToggleDockingAction;
+import docking.ComponentProvider;
+import docking.action.DockingAction;
import docking.action.ToolBarData;
-import generic.theme.GIcon;
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
-import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
-import ghidra.app.plugin.core.datamgr.tree.DataTypeArchiveGTree;
-import ghidra.util.HTMLUtilities;
+import ghidra.app.plugin.core.datamgr.DataTypesProvider;
+import ghidra.app.plugin.core.datamgr.tree.*;
+import resources.Icons;
-public class FilterArraysAction extends ToggleDockingAction {
+public class DtFilterAction extends DockingAction {
- //@formatter:off
- private static final Icon FILTER_ON_ICON = new GIcon("icon.plugin.datatypes.filter.arrays.on");
- private static final Icon FILTER_OFF_ICON = new GIcon("icon.plugin.datatypes.filter.arrays.off");
- //@formatter:on
+ private DataTypeManagerPlugin plugin;
- public FilterArraysAction(DataTypeManagerPlugin plugin) {
- super("Filter Arrays", plugin.getName());
+ public DtFilterAction(DataTypeManagerPlugin plugin) {
+ super("Show Filter", plugin.getName());
+ this.plugin = plugin;
- this.setToolBarData(new ToolBarData(FILTER_ON_ICON, "filters"));
+ setToolBarData(new ToolBarData(Icons.CONFIGURE_FILTER_ICON, "filters"));
- setDescription(HTMLUtilities.toHTML(
- "Toggle whether or not Arrays are\n" + "displayed in the Data Type Manager tree."));
- setSelected(true);
- setEnabled(true);
+ setDescription("Shows the Data Types filter");
}
@Override
public boolean isEnabledForContext(ActionContext context) {
- if (!(context instanceof DataTypesActionContext)) {
- return false;
- }
- return true;
+ ComponentProvider provider = context.getComponentProvider();
+ return provider instanceof DataTypesProvider;
}
@Override
public void actionPerformed(ActionContext context) {
+
DataTypeArchiveGTree gtree = (DataTypeArchiveGTree) context.getContextObject();
List<TreePath> expandedPaths = gtree.getExpandedPaths(gtree.getViewRoot());
TreePath[] selectionPaths = gtree.getSelectionPaths();
- gtree.enableArrayFilter(isSelected());
+
+ DataTypesProvider provider = (DataTypesProvider) context.getComponentProvider();
+ DtFilterState currentFilterState = provider.getFilterState();
+ DtFilterDialog dialog = new DtFilterDialog(currentFilterState);
+ plugin.getTool().showDialog(dialog);
+
+ // if not cancelled
+ if (dialog.isCancelled()) {
+ return;
+ }
+
+ DtFilterState newFilterState = dialog.getFilterState();
+ if (currentFilterState.equals(newFilterState)) {
+ return;
+ }
+
+ provider.setFilterState(newFilterState);
+
gtree.expandPaths(expandedPaths);
gtree.setSelectionPaths(selectionPaths);
}
-
- @Override
- public void setSelected(boolean selected) {
- getToolBarData().setIcon(selected ? FILTER_ON_ICON : FILTER_OFF_ICON);
- super.setSelected(selected);
- }
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FilterPointersAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FilterPointersAction.java
deleted file mode 100644
index e3f587aa77..0000000000
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/actions/FilterPointersAction.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/* ###
- * IP: GHIDRA
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.app.plugin.core.datamgr.actions;
-
-import java.util.List;
-
-import javax.swing.Icon;
-import javax.swing.tree.TreePath;
-
-import docking.ActionContext;
-import docking.action.ToggleDockingAction;
-import docking.action.ToolBarData;
-import generic.theme.GIcon;
-import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
-import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
-import ghidra.app.plugin.core.datamgr.tree.DataTypeArchiveGTree;
-import ghidra.util.HTMLUtilities;
-
-public class FilterPointersAction extends ToggleDockingAction {
-
- //@formatter:off
- private static final Icon FILTER_ON_ICON = new GIcon("icon.plugin.datatypes.filter.pointers.on");
- private static final Icon FILTER_OFF_ICON = new GIcon("icon.plugin.datatypes.filter.pointers.off");
- //@formatter:on
-
- public FilterPointersAction(DataTypeManagerPlugin plugin) {
- super("Filter Pointers", plugin.getName());
-
- this.setToolBarData(new ToolBarData(FILTER_ON_ICON, "filters"));
-
- setDescription(HTMLUtilities.toHTML(
- "Toggle whether or not Pointers are\n" + "displayed in the Data Type Manager tree."));
- setSelected(true);
- setEnabled(true);
- }
-
- @Override
- public boolean isEnabledForContext(ActionContext context) {
- if (!(context instanceof DataTypesActionContext)) {
- return false;
- }
- return true;
- }
-
- @Override
- public void actionPerformed(ActionContext context) {
- // this doesn't actually cause a filter task to happen, so we need to save and restore the state here
- DataTypeArchiveGTree gtree = (DataTypeArchiveGTree) context.getContextObject();
- List<TreePath> expandedPaths = gtree.getExpandedPaths(gtree.getViewRoot());
- TreePath[] selectionPaths = gtree.getSelectionPaths();
- gtree.enablePointerFilter(isSelected());
- gtree.expandPaths(expandedPaths);
- gtree.setSelectionPaths(selectionPaths);
-
- }
-
- @Override
- public void setSelected(boolean selected) {
- getToolBarData().setIcon(selected ? FILTER_ON_ICON : FILTER_OFF_ICON);
- super.setSelected(selected);
- }
-}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/archive/DataTypeManagerHandler.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/archive/DataTypeManagerHandler.java
index 3449a803f9..b2d2372137 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/archive/DataTypeManagerHandler.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/archive/DataTypeManagerHandler.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.
@@ -1481,7 +1481,7 @@ public class DataTypeManagerHandler {
dialog.addOkActionListener(listener);
dialog.setHelpLocation(
- new HelpLocation(HelpTopics.DATA_MANAGER, "Create_Data_Type_Archive"));
+ new HelpLocation(HelpTopics.DATA_MANAGER, "New_Project_Data_Type_Archive"));
return dialog;
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/ArchiveNode.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/ArchiveNode.java
index df03d15268..2ad9e21eda 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/ArchiveNode.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/ArchiveNode.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.
@@ -39,7 +39,7 @@ public class ArchiveNode extends CategoryNode {
protected ArchiveNodeCategoryChangeListener listener;
private DataTypeManager dataTypeManager; // may be null
- public ArchiveNode(Archive archive, ArrayPointerFilterState filterState) {
+ public ArchiveNode(Archive archive, DtFilterState filterState) {
this(archive, archive.getDataTypeManager() == null ? null
: archive.getDataTypeManager().getRootCategory(),
filterState);
@@ -48,7 +48,7 @@ public class ArchiveNode extends CategoryNode {
}
protected ArchiveNode(Archive archive, Category rootCategory,
- ArrayPointerFilterState filterState) {
+ DtFilterState filterState) {
super(rootCategory, filterState);
this.archive = archive;
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/ArchiveRootNode.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/ArchiveRootNode.java
index 7b72a2e3b9..555bcd3413 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/ArchiveRootNode.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/ArchiveRootNode.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.
@@ -29,10 +29,10 @@ import ghidra.util.exception.AssertException;
public class ArchiveRootNode extends DataTypeTreeNode {
private static final String NAME = "Data Types";
- private final DataTypeManagerHandler archiveManager;
+ private DataTypeManagerHandler archiveManager;
private RootNodeListener archiveListener;
- private ArrayPointerFilterState filterState = new ArrayPointerFilterState();
+ private DtFilterState dtFilterState = new DtFilterState();
ArchiveRootNode(DataTypeManagerHandler archiveManager) {
this.archiveManager = archiveManager;
@@ -48,6 +48,10 @@ public class ArchiveRootNode extends DataTypeTreeNode {
return archiveManager;
}
+ public void setFilterState(DtFilterState dtFilterState) {
+ this.dtFilterState = dtFilterState;
+ }
+
@Override
public void dispose() {
archiveManager.removeArchiveManagerListener(archiveListener);
@@ -80,22 +84,21 @@ public class ArchiveRootNode extends DataTypeTreeNode {
}
// a factory method to isolate non-OO inheritance checks
- private static final GTreeNode createArchiveNode(Archive archive,
- ArrayPointerFilterState filterState) {
+ private static final GTreeNode createArchiveNode(Archive archive, DtFilterState dtFilterState) {
if (archive instanceof FileArchive) {
- return new FileArchiveNode((FileArchive) archive, filterState);
+ return new FileArchiveNode((FileArchive) archive, dtFilterState);
}
else if (archive instanceof ProjectArchive) {
- return new ProjectArchiveNode((ProjectArchive) archive, filterState);
+ return new ProjectArchiveNode((ProjectArchive) archive, dtFilterState);
}
else if (archive instanceof InvalidFileArchive) {
return new InvalidArchiveNode((InvalidFileArchive) archive);
}
else if (archive instanceof ProgramArchive) {
- return new ProgramArchiveNode((ProgramArchive) archive, filterState);
+ return new ProgramArchiveNode((ProgramArchive) archive, dtFilterState);
}
else if (archive instanceof BuiltInArchive) {
- return new BuiltInArchiveNode((BuiltInArchive) archive, filterState);
+ return new BuiltInArchiveNode((BuiltInArchive) archive, dtFilterState);
}
return null;
}
@@ -140,9 +143,7 @@ public class ArchiveRootNode extends DataTypeTreeNode {
}
public CategoryNode findCategoryNode(Category category) {
- Iterator<GTreeNode> iterator = getChildren().iterator();
- while (iterator.hasNext()) {
- GTreeNode node = iterator.next();
+ for (GTreeNode node : getChildren()) {
ArchiveNode archiveNode = (ArchiveNode) node;
CategoryNode categoryNode = archiveNode.findCategoryNode(category);
if (categoryNode != null) {
@@ -153,9 +154,7 @@ public class ArchiveRootNode extends DataTypeTreeNode {
}
public ArchiveNode getNodeForManager(DataTypeManager dtm) {
- Iterator<GTreeNode> iterator = getChildren().iterator();
- while (iterator.hasNext()) {
- GTreeNode node = iterator.next();
+ for (GTreeNode node : getChildren()) {
ArchiveNode archiveNode = (ArchiveNode) node;
Archive archive = archiveNode.getArchive();
DataTypeManager manager = archive.getDataTypeManager();
@@ -169,9 +168,8 @@ public class ArchiveRootNode extends DataTypeTreeNode {
@Override
public List<GTreeNode> generateChildren() {
List<GTreeNode> list = new ArrayList<>();
- Iterator<Archive> iterator = archiveManager.getAllArchives().iterator();
- while (iterator.hasNext()) {
- list.add(createArchiveNode(iterator.next(), filterState));
+ for (Archive element : archiveManager.getAllArchives()) {
+ list.add(createArchiveNode(element, dtFilterState));
}
Collections.sort(list);
return list;
@@ -202,9 +200,7 @@ public class ArchiveRootNode extends DataTypeTreeNode {
return;
}
List<GTreeNode> allChildrenList = getChildren();
- Iterator<GTreeNode> iterator = allChildrenList.iterator();
- while (iterator.hasNext()) {
- GTreeNode node = iterator.next();
+ for (GTreeNode node : allChildrenList) {
ArchiveNode archiveNode = (ArchiveNode) node;
if (archive == archiveNode.getArchive()) {
removeNode(archiveNode);
@@ -217,7 +213,7 @@ public class ArchiveRootNode extends DataTypeTreeNode {
@Override
public void archiveOpened(Archive archive) {
if (isLoaded()) {
- GTreeNode node = createArchiveNode(archive, filterState);
+ GTreeNode node = createArchiveNode(archive, dtFilterState);
List<GTreeNode> allChildrenList = getChildren();
int index = Collections.binarySearch(allChildrenList, node);
if (index < 0) {
@@ -243,13 +239,4 @@ public class ArchiveRootNode extends DataTypeTreeNode {
}
}
}
-
- public void setFilterArray(boolean enabled) {
- filterState.setFilterArrays(enabled);
- }
-
- public void setFilterPointer(boolean enabled) {
- filterState.setFilterPointers(enabled);
- }
-
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/ArrayPointerFilterState.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/ArrayPointerFilterState.java
deleted file mode 100644
index 83962e721d..0000000000
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/ArrayPointerFilterState.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/* ###
- * IP: GHIDRA
- *
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.app.plugin.core.datamgr.tree;
-
-/**
- * Class to maintain the state of whether or not the Data Type Manager Tree is showing
- * pointers and/or arrays.
- *
- * Note: Not sure if this needs to be synchronized or not. The set methods are called
- * from the awt thread, but the getter methods are often called by a background worker
- * thread. The theory is that we don't need to synchronize this because if the state
- * of this object changes, the tree will later be rebuilt in a follow-up task.
- */
-public class ArrayPointerFilterState {
- private boolean filterArrays;
- private boolean filterPointers;
-
- /**
- * Returns true if the tree should NOT show arrays
- * @return true if the tree should NOT show arrays
- */
- public boolean filterArrays() {
- return filterArrays;
- }
-
- /**
- * Sets whether the tree should show arrays.
- * @param filterArrays if true the tree will NOT show arrays.
- */
- public void setFilterArrays(boolean filterArrays) {
- this.filterArrays = filterArrays;
- }
-
- /**
- * Returns true if the tree should NOT show pointers
- * @return true if the tree should NOT show pointers
- */
- public boolean filterPointers() {
- return filterPointers;
- }
-
- /**
- * Sets whether the tree should show pointers.
- * @param filterPointers if true the tree will NOT show pointers.
- */
- public void setFilterPointers(boolean filterPointers) {
- this.filterPointers = filterPointers;
- }
-
-}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/BuiltInArchiveNode.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/BuiltInArchiveNode.java
index 56379b9302..85a120cd3b 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/BuiltInArchiveNode.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/BuiltInArchiveNode.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.
@@ -23,7 +23,7 @@ import resources.MultiIcon;
public class BuiltInArchiveNode extends ArchiveNode {
- public BuiltInArchiveNode(BuiltInArchive archive, ArrayPointerFilterState filterState) {
+ public BuiltInArchiveNode(BuiltInArchive archive, DtFilterState filterState) {
super(archive, filterState);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/CategoryNode.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/CategoryNode.java
index f9abbf89ab..11af543e08 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/CategoryNode.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/CategoryNode.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.
@@ -22,6 +22,8 @@ import javax.swing.Icon;
import docking.widgets.tree.GTreeNode;
import ghidra.app.plugin.core.datamgr.util.DataTypeUtils;
import ghidra.program.model.data.*;
+import ghidra.program.model.data.Enum;
+import ghidra.program.model.listing.Function;
import ghidra.util.*;
import ghidra.util.exception.AssertException;
import ghidra.util.exception.DuplicateNameException;
@@ -32,9 +34,9 @@ public class CategoryNode extends DataTypeTreeNode {
private String name;
private boolean isCut;
- private ArrayPointerFilterState filterState;
+ private DtFilterState filterState;
- public CategoryNode(Category category, ArrayPointerFilterState filterState) {
+ public CategoryNode(Category category, DtFilterState filterState) {
this.filterState = filterState;
setCategory(category);
}
@@ -70,15 +72,31 @@ public class CategoryNode extends DataTypeTreeNode {
}
private boolean isFilteredType(DataType dataType) {
- if (filterState.filterArrays() && dataType instanceof Array) {
+ if (!filterState.isShowArrays() && dataType instanceof Array) {
return true;
}
- if (filterState.filterPointers() && (dataType instanceof Pointer) &&
+ if (!filterState.isShowPointers() && (dataType instanceof Pointer) &&
!(dataType.getDataTypeManager() instanceof BuiltInDataTypeManager)) {
return true;
}
+ if (!filterState.isShowEnums() && (dataType instanceof Enum)) {
+ return true;
+ }
+
+ if (!filterState.isShowFunctions() && (dataType instanceof Function)) {
+ return true;
+ }
+
+ if (!filterState.isShowStructures() && (dataType instanceof Structure)) {
+ return true;
+ }
+
+ if (!filterState.isShowUnions() && (dataType instanceof Union)) {
+ return true;
+ }
+
return false;
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/DataTypeArchiveGTree.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/DataTypeArchiveGTree.java
index fb02de139c..154ff3f00d 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/DataTypeArchiveGTree.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/DataTypeArchiveGTree.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.
@@ -148,15 +148,9 @@ public class DataTypeArchiveGTree extends GTree {
super.dispose();
}
- public void enableArrayFilter(boolean enabled) {
- ArchiveRootNode root = (ArchiveRootNode) getModelRoot();
- root.setFilterArray(enabled);
- reloadTree();
- }
-
- public void enablePointerFilter(boolean enabled) {
+ public void setFilterState(DtFilterState filterState) {
ArchiveRootNode root = (ArchiveRootNode) getModelRoot();
- root.setFilterPointer(enabled);
+ root.setFilterState(filterState);
reloadTree();
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/DomainFileArchiveNode.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/DomainFileArchiveNode.java
index 251f9d3c85..6129a13563 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/DomainFileArchiveNode.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/DomainFileArchiveNode.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.
@@ -46,7 +46,7 @@ public abstract class DomainFileArchiveNode extends ArchiveNode {
private String domainFileInfoString;
- public DomainFileArchiveNode(DomainFileArchive archive, ArrayPointerFilterState filterState) {
+ public DomainFileArchiveNode(DomainFileArchive archive, DtFilterState filterState) {
super(archive, filterState);
updateDomainFileInfo();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/DtFilterDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/DtFilterDialog.java
new file mode 100644
index 0000000000..13280cae53
--- /dev/null
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/DtFilterDialog.java
@@ -0,0 +1,108 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.datamgr.tree;
+
+import javax.swing.JPanel;
+
+import docking.DialogComponentProvider;
+import docking.widgets.checkbox.GCheckBox;
+import ghidra.app.util.HelpTopics;
+import ghidra.util.HelpLocation;
+import ghidra.util.layout.PairLayout;
+
+/**
+ * Data Types provider dialog to allow users to change the types that are filtered.
+ */
+public class DtFilterDialog extends DialogComponentProvider {
+
+ private GCheckBox arraysCheckBox = new GCheckBox("Show Arrays");
+ private GCheckBox enumsCheckBox = new GCheckBox("Show Enums");
+ private GCheckBox functionsCheckBox = new GCheckBox("Show Functions");
+ private GCheckBox pointersCheckBox = new GCheckBox("Show Pointers");
+ private GCheckBox structuresCheckBox = new GCheckBox("Show Structures");
+ private GCheckBox unionsCheckBox = new GCheckBox("Show Unions");
+
+ private DtFilterState filterState;
+ private boolean isCancelled;
+
+ public DtFilterDialog(DtFilterState filterState) {
+ super("Data Types Filter");
+ this.filterState = filterState;
+
+ addWorkPanel(buildWorkPanel());
+
+ addOKButton();
+ addCancelButton();
+
+ setHelpLocation(new HelpLocation(HelpTopics.DATA_MANAGER, "Set Filter"));
+
+ initCheckBoxes();
+ setRememberSize(false);
+ }
+
+ @Override
+ protected void cancelCallback() {
+ super.cancelCallback();
+ isCancelled = true;
+ }
+
+ @Override
+ protected void okCallback() {
+ close();
+ }
+
+ public boolean isCancelled() {
+ return isCancelled;
+ }
+
+ public DtFilterState getFilterState() {
+ DtFilterState newState = new DtFilterState();
+
+ newState.setShowArrays(arraysCheckBox.isSelected());
+ newState.setShowEnums(enumsCheckBox.isSelected());
+ newState.setShowFunctions(functionsCheckBox.isSelected());
+ newState.setShowPointers(pointersCheckBox.isSelected());
+ newState.setShowStructures(structuresCheckBox.isSelected());
+ newState.setShowUnions(unionsCheckBox.isSelected());
+
+ return newState;
+ }
+
+ private JPanel buildWorkPanel() {
+
+ JPanel panel = new JPanel(new PairLayout(5, 10));
+
+ panel.add(arraysCheckBox);
+ panel.add(enumsCheckBox);
+ panel.add(functionsCheckBox);
+ panel.add(pointersCheckBox);
+ panel.add(structuresCheckBox);
+ panel.add(unionsCheckBox);
+
+ return panel;
+ }
+
+ private void initCheckBoxes() {
+
+ arraysCheckBox.setSelected(filterState.isShowArrays());
+ enumsCheckBox.setSelected(filterState.isShowEnums());
+ functionsCheckBox.setSelected(filterState.isShowFunctions());
+ pointersCheckBox.setSelected(filterState.isShowPointers());
+ structuresCheckBox.setSelected(filterState.isShowStructures());
+ unionsCheckBox.setSelected(filterState.isShowUnions());
+ }
+
+}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/DtFilterState.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/DtFilterState.java
new file mode 100644
index 0000000000..547e6c1169
--- /dev/null
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/DtFilterState.java
@@ -0,0 +1,161 @@
+/* ###
+ * IP: GHIDRA
+ *
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package ghidra.app.plugin.core.datamgr.tree;
+
+import java.util.Objects;
+
+import ghidra.framework.options.SaveState;
+
+/**
+ * A simple object to store various filter settings for the data type provider.
+ */
+public class DtFilterState {
+
+ private static final String XML_NAME = "DATA_TYPES_FILTER";
+
+ private boolean showArrays = false;
+ private boolean showEnums = true;
+ private boolean showFunctions = true;
+ private boolean showStructures = true;
+ private boolean showTypedefs = true;
+ private boolean showPointers = false;
+ private boolean showUnions = true;
+
+ public DtFilterState copy() {
+ DtFilterState filterState = new DtFilterState();
+ filterState.setShowArrays(showArrays);
+ filterState.setShowEnums(showEnums);
+ filterState.setShowFunctions(showFunctions);
+ filterState.setShowStructures(showStructures);
+ filterState.setShowTypedefs(showTypedefs);
+ filterState.setShowPointers(showPointers);
+ filterState.setShowUnions(showUnions);
+ return filterState;
+ }
+
+ public boolean isShowPointers() {
+ return showPointers;
+ }
+
+ public void setShowPointers(boolean showPointers) {
+ this.showPointers = showPointers;
+ }
+
+ public boolean isShowStructures() {
+ return showStructures;
+ }
+
+ public void setShowStructures(boolean showStructures) {
+ this.showStructures = showStructures;
+ }
+
+ public boolean isShowTypedefs() {
+ return showStructures;
+ }
+
+ public void setShowTypedefs(boolean showTypedefs) {
+ this.showTypedefs = showTypedefs;
+ }
+
+ public boolean isShowEnums() {
+ return showEnums;
+ }
+
+ public void setShowEnums(boolean showEnums) {
+ this.showEnums = showEnums;
+ }
+
+ public boolean isShowFunctions() {
+ return showFunctions;
+ }
+
+ public void setShowFunctions(boolean showFunctions) {
+ this.showFunctions = showFunctions;
+ }
+
+ public boolean isShowUnions() {
+ return showUnions;
+ }
+
+ public void setShowUnions(boolean showUnions) {
+ this.showUnions = showUnions;
+ }
+
+ public boolean isShowArrays() {
+ return showArrays;
+ }
+
+ public void setShowArrays(boolean showArrays) {
+ this.showArrays = showArrays;
+ }
+
+ public void setshowPointers(boolean showPointers) {
+ this.showPointers = showPointers;
+ }
+
+ public void save(SaveState parentSaveState) {
+
+ SaveState saveState = new SaveState(XML_NAME);
+ saveState.putBoolean("SHOW_ARRAYS", showArrays);
+ saveState.putBoolean("SHOW_ENUMS", showEnums);
+ saveState.putBoolean("SHOW_FUNCTIONS", showFunctions);
+ saveState.putBoolean("SHOW_POINTERS", showPointers);
+ saveState.putBoolean("SHOW_STRUCTURES", showStructures);
+ saveState.putBoolean("SHOW_TYPEDEFS", showTypedefs);
+ saveState.putBoolean("SHOW_UNIONS", showUnions);
+
+ parentSaveState.putSaveState(XML_NAME, saveState);
+ }
+
+ public void restore(SaveState parentSaveState) {
+
+ parentSaveState.getSaveState(XML_NAME);
+ SaveState saveState = new SaveState();
+
+ showArrays = saveState.getBoolean("SHOW_ARRAYS", false);
+ showEnums = saveState.getBoolean("SHOW_ENUMS", true);
+ showFunctions = saveState.getBoolean("SHOW_FUNCTIONS", true);
+ showPointers = saveState.getBoolean("SHOW_POINTERS", false);
+ showStructures = saveState.getBoolean("SHOW_STRUCTURES", true);
+ showTypedefs = saveState.getBoolean("SHOW_TYPEDEFS", true);
+ showUnions = saveState.getBoolean("SHOW_UNIONS", true);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(showArrays, showEnums, showFunctions, showPointers, showStructures,
+ showTypedefs, showUnions);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ DtFilterState other = (DtFilterState) obj;
+ return showArrays == other.showArrays && showEnums == other.showEnums &&
+ showFunctions == other.showFunctions && showPointers == other.showPointers &&
+ showStructures == other.showStructures && showTypedefs == other.showTypedefs &&
+ showUnions == other.showUnions;
+ }
+
+}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/FileArchiveNode.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/FileArchiveNode.java
index bae0a4393e..b01983f62f 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/FileArchiveNode.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/FileArchiveNode.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.
@@ -30,7 +30,7 @@ public class FileArchiveNode extends ArchiveNode {
FileArchive fileArchive; // casted reference for easy access
- public FileArchiveNode(FileArchive archive, ArrayPointerFilterState filterState) {
+ public FileArchiveNode(FileArchive archive, DtFilterState filterState) {
super(archive, filterState);
this.fileArchive = archive;
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/InvalidArchiveNode.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/InvalidArchiveNode.java
index 1babc27c02..88772e9259 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/InvalidArchiveNode.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/InvalidArchiveNode.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.
@@ -26,7 +26,7 @@ import ghidra.util.HTMLUtilities;
public class InvalidArchiveNode extends ArchiveNode {
public InvalidArchiveNode(InvalidFileArchive archive) {
- super(archive, new ArrayPointerFilterState());
+ super(archive, new DtFilterState());
}
@Override
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/ProgramArchiveNode.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/ProgramArchiveNode.java
index 61f27055f1..e49c290d87 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/ProgramArchiveNode.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/ProgramArchiveNode.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.
@@ -22,7 +22,7 @@ import ghidra.util.HTMLUtilities;
public class ProgramArchiveNode extends DomainFileArchiveNode {
- public ProgramArchiveNode(ProgramArchive archive, ArrayPointerFilterState filterState) {
+ public ProgramArchiveNode(ProgramArchive archive, DtFilterState filterState) {
super(archive, filterState);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/ProjectArchiveNode.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/ProjectArchiveNode.java
index ae0671ac33..53c3054a73 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/ProjectArchiveNode.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/tree/ProjectArchiveNode.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.
@@ -20,7 +20,7 @@ import ghidra.framework.model.DomainFile;
public class ProjectArchiveNode extends DomainFileArchiveNode {
- public ProjectArchiveNode(ProjectArchive archive, ArrayPointerFilterState filterState) {
+ public ProjectArchiveNode(ProjectArchive archive, DtFilterState filterState) {
super(archive, filterState);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/InterpreterComponentProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/InterpreterComponentProvider.java
index a5fd7ab553..8db744f37a 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/InterpreterComponentProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/interpreter/InterpreterComponentProvider.java
@@ -27,6 +27,7 @@ import docking.action.ToolBarData;
import docking.action.builder.ActionBuilder;
import docking.widgets.*;
import generic.theme.GIcon;
+import ghidra.app.util.HelpTopics;
import ghidra.framework.plugintool.ComponentProviderAdapter;
import ghidra.util.HelpLocation;
import resources.Icons;
@@ -81,6 +82,7 @@ public class InterpreterComponentProvider extends ComponentProviderAdapter
new ActionBuilder("Find", getOwner())
.keyBinding("Ctrl F")
.sharedKeyBinding()
+ .helpLocation(new HelpLocation(HelpTopics.CONSOLE, "Console_Find"))
.popupMenuPath("Find...")
.onAction(c -> {
showFindDialog();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/symtable/FilterDialog.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/symtable/FilterDialog.java
index 71a9f247fc..a994da484a 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/symtable/FilterDialog.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/symtable/FilterDialog.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.
@@ -18,7 +18,8 @@ package ghidra.app.plugin.core.symtable;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Map;
import javax.swing.*;
@@ -58,7 +59,6 @@ public class FilterDialog extends ReusableDialogComponentProvider {
setHelpLocation(new HelpLocation(HelpTopics.SYMBOL_TABLE, "Set Filter"));
initCheckBoxes();
setRememberSize(false);
-
}
@Override
@@ -86,9 +86,7 @@ public class FilterDialog extends ReusableDialogComponentProvider {
private void initCheckBoxes() {
setChanged(false);
ignoreCallbacks = true;
- Iterator<String> it = checkBoxMap.keySet().iterator();
- while (it.hasNext()) {
- String filterName = it.next();
+ for (String filterName : checkBoxMap.keySet()) {
JCheckBox cb = checkBoxMap.get(filterName);
cb.setSelected(filter.isActive(filterName));
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/util/HelpTopics.java b/Ghidra/Features/Base/src/main/java/ghidra/app/util/HelpTopics.java
index fc505e5e9f..20b19cc3e0 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/util/HelpTopics.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/util/HelpTopics.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.
@@ -52,6 +52,11 @@ public interface HelpTopics {
*/
public final static String CODE_BROWSER = "CodeBrowserPlugin";
+ /**
+ * Help Topic for the Console Plugin.
+ */
+ public final static String CONSOLE = "ConsolePlugin";
+
/**
* Help Topic for comments.
*/
@@ -64,7 +69,7 @@ public interface HelpTopics {
/**
* Help Topic for the data manager.
*/
- public final static String DATA_MANAGER = "DataManagerPlugin";
+ public final static String DATA_MANAGER = "DataTypeManagerPlugin";
/**
* Help Topic for the data type editors.
diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPluginTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPluginTest.java
index 0a267ef31b..daf57fa82f 100644
--- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPluginTest.java
+++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/datamgr/DataTypeManagerPluginTest.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.
@@ -55,7 +55,6 @@ import ghidra.app.services.DataTypeManagerService;
import ghidra.app.services.ProgramManager;
import ghidra.app.util.datatype.DataTypeSelectionEditor;
import ghidra.framework.options.ToolOptions;
-import ghidra.framework.plugintool.Plugin;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.database.ProgramBuilder;
import ghidra.program.database.ProgramDB;
@@ -121,7 +120,7 @@ public class DataTypeManagerPluginTest extends AbstractGhidraHeadedIntegrationTe
// cleanup the display a bit
ProgramTreePlugin ptp = env.getPlugin(ProgramTreePlugin.class);
- tool.removePlugins(new Plugin[] { ptp });
+ tool.removePlugins(List.of(ptp));
}
private ProgramDB buildProgram() throws Exception {
@@ -676,31 +675,6 @@ public class DataTypeManagerPluginTest extends AbstractGhidraHeadedIntegrationTe
checkNodesCollapsed(rootNode);
}
- @Test
- public void testSaveRestoreFilterStates() throws Exception {
- final ToggleDockingActionIf arraysAction =
- (ToggleDockingActionIf) getAction(plugin, "Filter Arrays");
- assertTrue(arraysAction.isSelected());
- arraysAction.setSelected(false);
- DataTypeTestUtils.performAction(arraysAction, tree);
-
- // state is off
- final ToggleDockingActionIf pointerAction =
- (ToggleDockingActionIf) getAction(plugin, "Filter Pointers");
- assertTrue(pointerAction.isSelected());
-
- pointerAction.setSelected(false);
- DataTypeTestUtils.performAction(pointerAction, tree, false);
-
- // state is off
- env.saveRestoreToolState();
- plugin = env.getPlugin(DataTypeManagerPlugin.class);
- ToggleDockingActionIf action = (ToggleDockingActionIf) getAction(plugin, "Filter Arrays");
- assertFalse(action.isSelected());
- action = (ToggleDockingActionIf) getAction(plugin, "Filter Pointers");
- assertFalse(action.isSelected());
- }
-
@Test
public void testDataTypePreviewCopyHtmlText() throws Exception {
@@ -918,9 +892,123 @@ public class DataTypeManagerPluginTest extends AbstractGhidraHeadedIntegrationTe
assertTrue(selectedDatatypes.contains(dt2));
}
+ @Test
+ public void testFilter() {
+
+ // press the filter button
+ DockingActionIf action = getAction(plugin, "Show Filter");
+ performAction(action, provider, false);
+
+ assertStructures(true);
+
+ DtFilterDialog dialog = waitForDialogComponent(DtFilterDialog.class);
+ setToggleButtonSelected(dialog.getComponent(), "Show Structures", false);
+ pressButtonByText(dialog, "OK");
+ waitForTree();
+
+ assertStructures(false);
+ }
+
+ @Test
+ public void testFilter_ClonedProvider() {
+
+ // press filter
+ // press the filter button
+ DtFilterDialog mainDialog = showFilterDialog(provider);
+ boolean isShowingStructures = false;
+ updateFilter(mainDialog, "Show Structures", isShowingStructures);
+
+ //
+ // Launch a new data types provider window to verify it has the same settings as the main
+ // provider's filter
+ //
+ DataTypesProvider otherProvider = showClonedProvider();
+ DtFilterDialog otherFilterDialog = showFilterDialog(otherProvider);
+
+ // verify the state for the structure filter matches the state we changed above (this shows
+ // the cloned provider is correctly getting the main provider's filter state)
+ boolean otherIsShowStructures = runSwing(() -> {
+ DtFilterState newFilterState = otherFilterDialog.getFilterState();
+ return newFilterState.isShowStructures();
+ });
+ assertEquals(isShowingStructures, otherIsShowStructures);
+
+ // now change the new provider's filter for a different option and then make sure that the
+ // main provider is not changed
+ updateFilter(otherFilterDialog, "Show Functions", false);
+
+ DtFilterState mainFilterState = runSwing(() -> provider.getFilterState());
+ DtFilterState otherFilterState = runSwing(() -> otherProvider.getFilterState());
+ boolean mainShowFunctions = runSwing(() -> mainFilterState.isShowFunctions());
+ boolean otherShowFunctions = runSwing(() -> otherFilterState.isShowFunctions());
+ assertNotEquals(mainShowFunctions, otherShowFunctions);
+ }
+
+ @Test
+ public void testSaveRestoreFilterStates() throws Exception {
+
+ DtFilterDialog dialog = showFilterDialog(provider);
+ boolean isShowingEnums = getFilterState(dialog, "Show Enums");
+ boolean isShowingUnions = getFilterState(dialog, "Show Unions");
+
+ setToggleButtonSelected(dialog.getComponent(), "Show Enums", !isShowingEnums);
+ setToggleButtonSelected(dialog.getComponent(), "Show Unions", !isShowingUnions);
+ pressButtonByText(dialog, "OK");
+ waitForSwing();
+
+ env.saveRestoreToolState();
+ plugin = env.getPlugin(DataTypeManagerPlugin.class);
+ provider = plugin.getProvider();
+
+ DtFilterState filterState = getFilterState(provider);
+ assertEquals(!isShowingEnums, filterState.isShowEnums());
+ assertEquals(!isShowingUnions, filterState.isShowUnions());
+ }
+
//==================================================================================================
// Private methods
//==================================================================================================
+
+ private boolean getFilterState(DtFilterDialog dialog, String optionName) {
+ return isToggleButttonSelected(dialog.getComponent(), optionName);
+ }
+
+ private void updateFilter(DtFilterDialog dialog, String optionName, boolean state) {
+ setToggleButtonSelected(dialog.getComponent(), optionName, state);
+ pressButtonByText(dialog, "OK");
+ waitForSwing();
+ }
+
+ private DataTypesProvider showClonedProvider() {
+ DockingActionIf findAction = getAction(plugin, FindStructuresBySizeAction.NAME);
+ performAction(findAction, provider, false);
+ NumberRangeInputDialog numberDialog = waitForDialogComponent(NumberRangeInputDialog.class);
+ setText(numberDialog, "10");
+ pressButtonByText(numberDialog, "OK");
+
+ return waitForComponentProvider(DataTypesProvider.class, FindStructuresBySizeAction.NAME);
+ }
+
+ private DtFilterDialog showFilterDialog(DataTypesProvider dtProvider) {
+ DockingActionIf otherFilterAction = getLocalAction(dtProvider, "Show Filter");
+ performAction(otherFilterAction, dtProvider, false);
+ return waitForDialogComponent(DtFilterDialog.class);
+ }
+
+ private DtFilterState getFilterState(DataTypesProvider dtProvider) {
+ return runSwing(() -> dtProvider.getFilterState());
+ }
+
+ private void assertStructures(boolean structuresExpected) {
+ Map<String, Structure> structures = getStructures(provider);
+ if (!structuresExpected) {
+ assertEquals(0, structures.size());
+ }
+ else {
+ assertTrue(structures.size() > 0);
+ }
+ }
+
private void selectDataTypes(DataType dt1, DataType dt2) {
String catName1 = dt1.getCategoryPath().getName(); // assumes path is only 1 level
CategoryNode cat1 = (CategoryNode) programNode.getChild(catName1);
@@ -1152,9 +1240,14 @@ public class DataTypeManagerPluginTest extends AbstractGhidraHeadedIntegrationTe
}
private void disablePointerFilter() {
- DockingActionIf filterPointersAction = getAction(plugin, "Filter Pointers");
- ToggleDockingActionIf toggleAction = (ToggleDockingActionIf) filterPointersAction;
- setToggleActionSelected(toggleAction, treeContext, false);
+
+ // press the filter button
+ DockingActionIf action = getAction(plugin, "Show Filter");
+ performAction(action, provider, false);
+
+ DtFilterDialog dialog = waitForDialogComponent(DtFilterDialog.class);
+ setToggleButtonSelected(dialog.getComponent(), "Show Pointers", true);
+ pressButtonByText(dialog, "OK");
waitForTree();
}
diff --git a/Ghidra/Features/DecompilerDependent/src/main/help/help/topics/DecompilerTextFinderPlugin/Decompiler_Text_Finder.html b/Ghidra/Features/DecompilerDependent/src/main/help/help/topics/DecompilerTextFinderPlugin/Decompiler_Text_Finder.html
index c6a52eb4f0..b20fd4f58e 100644
--- a/Ghidra/Features/DecompilerDependent/src/main/help/help/topics/DecompilerTextFinderPlugin/Decompiler_Text_Finder.html
+++ b/Ghidra/Features/DecompilerDependent/src/main/help/help/topics/DecompilerTextFinderPlugin/Decompiler_Text_Finder.html
@@ -189,8 +189,8 @@
<UL>
<LI><A href="help/topics/DecompilePlugin/DecompilerIntro.html">Decompiler</A></LI>
-
<LI><A href="help/topics/Search/Search_Program_Text.htm">Search Program Text</A></LI>
+ <LI><A href="help/topics/Search/Regular_Expressions.htm">Regular Expressions</A></LI>
</UL><BR>
<BR>
</BODY>
diff --git a/Ghidra/Framework/Docking/src/main/java/docking/test/AbstractDockingTest.java b/Ghidra/Framework/Docking/src/main/java/docking/test/AbstractDockingTest.java
index 9aff2982cd..6219a23074 100644
--- a/Ghidra/Framework/Docking/src/main/java/docking/test/AbstractDockingTest.java
+++ b/Ghidra/Framework/Docking/src/main/java/docking/test/AbstractDockingTest.java
@@ -984,6 +984,43 @@ public abstract class AbstractDockingTest extends AbstractGuiTest {
pressButtonByText(provider.getComponent(), buttonText, waitForCompletion);
}
+ /**
+ * Finds the toggle button with the given name inside of the given container and then
+ * gets the selected state of the button.
+ * <p>
+ * Note: this works for any instanceof {@link JToggleButton}, such as:
+ * <ul>
+ * <li>{@link JCheckBox}</li>
+ * <li>{@link JRadioButton}</li>
+ * </ul>
+ * as well as {@link EmptyBorderToggleButton}s.
+ *
+ * @param container a container that has the desired button as a descendant
+ * @param buttonName the name of the button (you must set this on the button when it is
+ * constructed; if there is no button with the given name found, then this
+ * method will search for a button with the given text
+ * @return true if the button is selected
+ */
+ public static boolean isToggleButttonSelected(Container container, String buttonName) {
+ AbstractButton button = findAbstractButtonByName(container, buttonName);
+ if (button == null) {
+ button = findAbstractButtonByText(container, buttonName);
+ }
+ if (button == null) {
+ throw new AssertionError("Could not find button by name or text '" + buttonName + "'");
+ }
+
+ boolean isToggle =
+ (button instanceof JToggleButton) || (button instanceof EmptyBorderToggleButton);
+ if (!isToggle) {
+ throw new AssertionError(
+ "Found a button, but it is not a toggle button. Text: '" + buttonName + "'");
+ }
+
+ AbstractButton finalButton = button;
+ return runSwing(() -> finalButton.isSelected());
+ }
+
/**
* Finds the toggle button with the given name inside of the given container and then
* ensures that the selected state of the button matches <code>selected</code>.
@@ -1037,7 +1074,7 @@ public abstract class AbstractDockingTest extends AbstractGuiTest {
* @param selected true to toggle the button to selected; false for de-selected
*/
public static void setToggleButtonSelected(AbstractButton button, boolean selected) {
- boolean isSelected = button.isSelected();
+ boolean isSelected = runSwing(() -> button.isSelected());
if (isSelected != selected) {
pressButton(button);
}