Ghidra is a software reverse engineering (SRE) framework
GT-3485 review changes
ghidravore6ac9a1d0aa20
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/AbstractNextPreviousAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/AbstractNextPreviousAction.javaindex f937e5d586..a4364e4d2f 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/AbstractNextPreviousAction.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/AbstractNextPreviousAction.java@@ -17,7 +17,8 @@ package ghidra.app.plugin.core.navigation;import javax.swing.*;-import docking.action.*;+import docking.action.KeyBindingData;+import docking.action.ToolBarData;import docking.tool.ToolConstants;import ghidra.app.context.NavigatableActionContext;import ghidra.app.nav.Navigatable;@@ -47,11 +48,6 @@ public abstract class AbstractNextPreviousAction extends CodeViewerContextActionnew ToolBarData(getIcon(), ToolConstants.TOOLBAR_GROUP_FOUR);toolBarData.setToolBarSubGroup(subGroup);setToolBarData(toolBarData);- MenuData menuData =- new MenuData(new String[] { ToolConstants.MENU_NAVIGATION, getMenuName() }, getIcon(),- ToolConstants.MENU_GROUP_NEXT_CODE_UNIT_NAV);- menuData.setMenuSubGroup(subGroup);- setMenuBarData(menuData);setKeyBindingData(new KeyBindingData(getKeyStroke()));setHelpLocation(new HelpLocation(HelpTopics.NAVIGATION, name));setDescription(getDescriptionString());diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/NextPrevCodeUnitPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/NextPrevCodeUnitPlugin.javaindex a5f72a898c..b267fce6cd 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/NextPrevCodeUnitPlugin.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/NextPrevCodeUnitPlugin.java@@ -126,11 +126,6 @@ public class NextPrevCodeUnitPlugin extends Plugin {ToggleDirectionAction(String subGroup) {super("Toggle Search Direction", NextPrevCodeUnitPlugin.this.getName());- MenuData menuData =- new MenuData(new String[] { ToolConstants.MENU_NAVIGATION, getName() },- forwardIcon, ToolConstants.MENU_GROUP_NEXT_CODE_UNIT_NAV);- menuData.setMenuSubGroup(subGroup);- setMenuBarData(menuData);setToolBarData(new ToolBarData(forwardIcon,ToolConstants.TOOLBAR_GROUP_FOUR, subGroup));setKeyBindingData(new KeyBindingData(KeyEvent.VK_T, InputEvent.CTRL_DOWN_MASK |diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/NextPreviousBookmarkAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/NextPreviousBookmarkAction.javaindex d28865858c..78a5e534f1 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/NextPreviousBookmarkAction.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/navigation/NextPreviousBookmarkAction.java@@ -64,12 +64,6 @@ public class NextPreviousBookmarkAction extends MultiStateDockingAction<String>toolBarData.setToolBarSubGroup(subGroup);setToolBarData(toolBarData);- MenuData menuData =- new MenuData(new String[] { ToolConstants.MENU_NAVIGATION, getMenuName() },- bookmarkIcon, ToolConstants.MENU_GROUP_NEXT_CODE_UNIT_NAV);- menuData.setMenuSubGroup(subGroup);- setMenuBarData(menuData);-setKeyBindingData(new KeyBindingData(getKeyStroke()));setHelpLocation(new HelpLocation(HelpTopics.NAVIGATION, getName()));@@ -95,19 +89,6 @@ public class NextPreviousBookmarkAction extends MultiStateDockingAction<String>addActionState(warning);addActionState(custom);- /*BookmarkPlugin bookmarkPlugin = new BookmarkPlugin(tool);- Program program = bookmarkPlugin.getCurrentProgram();- BookmarkManager bookmarkManager = program.getBookmarkManager();- BookmarkType[] bookmarkTypes = bookmarkManager.getBookmarkTypes();-- for (BookmarkType bookmarkType : bookmarkTypes) {- ActionState<String> tempBookmarkType =- new ActionState<String>(bookmarkType.getTypeString(), bookmarkUnknownIcon,- bookmarkType.getTypeString());-- addActionState(tempBookmarkType);- }*/-setCurrentActionState(allBookmarks); // default}diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin.javaindex 8db7ff0bd2..8c81e6a588 100644--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin.java+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/searchtext/SearchTextPlugin.java@@ -398,6 +398,7 @@ public class SearchTextPlugin extends ProgramPlugin implements OptionsChangeList.menuGroup("search", subGroup).keyBinding("ctrl shift F3").description(DESCRIPTION)+ .supportsDefaultToolContext(true).helpLocation(new HelpLocation(HelpTopics.SEARCH, "Repeat Text Search")).withContext(NavigatableActionContext.class).enabledWhen(c -> searchedOnce)diff --git a/Ghidra/Framework/Docking/src/main/java/docking/DockingWindowManager.java b/Ghidra/Framework/Docking/src/main/java/docking/DockingWindowManager.javaindex 7476fb893b..6b9b0b9fe2 100644--- a/Ghidra/Framework/Docking/src/main/java/docking/DockingWindowManager.java+++ b/Ghidra/Framework/Docking/src/main/java/docking/DockingWindowManager.java@@ -2143,8 +2143,8 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder}/**- * Returns the global action context for the tool- * @return the global action context for the tool+ * Returns the default action context for the tool+ * @return the default action context for the tool*/public ActionContext getDefaultToolContext() {return defaultProvider == null ? new ActionContext()diff --git a/Ghidra/Framework/Docking/src/main/java/docking/action/DockingActionIf.java b/Ghidra/Framework/Docking/src/main/java/docking/action/DockingActionIf.javaindex d0daf71a07..0d04189a80 100644--- a/Ghidra/Framework/Docking/src/main/java/docking/action/DockingActionIf.java+++ b/Ghidra/Framework/Docking/src/main/java/docking/action/DockingActionIf.java@@ -34,23 +34,23 @@ import docking.help.HelpDescriptor;* the level of key binding support, you can pass the desired {@link KeyBindingType} to the* base implementation of this interface.*- * <p>ActionContext is a key concept for Ghidra actions so that they can be context sensitive if- * appropriate. They provide a+ * <p>ActionContext is a key concept for tool actions so that they can be context sensitive if+ * appropriate. The context provides a* consistent way for plugins and components to share tool state with actions. Actions can then- * use that context to make decisions such as if they should be enabled or added to a popup menu.+ * use that context to make decisions, such as if they should be enabled or added to a popup menu.* The context information is also typically used when the action is invoked. For example, an* action context from a table element may provide the row in a table component that is selected and* then a "delete table row" action can use that information to be enabled when a table selection* exists and then delete that row if the action is invoked.*- * <p> To make the overall action experience more convenient for the user, Ghidra action processing+ * <p> To make the overall action experience more convenient for the user, action processing* supports the concept of a "default tool context". This allows actions to work on a more global* level than just the component that is focused. The idea is that if an action is not valid for* the current focused context (and it has be declared to work this way using- * the {@link #setSupportsDefaultToolContext(boolean)}) it can be validated against the default- * tool context. The "default tool context" is defined to be the action context of the tools- * primary component. This is primarily intended for "tool" actions which are the ones that appear- * in the tool's main menu bar or tool bar. This allows the tool actions to mostly work on the+ * the {@link #setSupportsDefaultToolContext(boolean)}), then it can be validated against the default+ * tool context. The "default tool context" is defined to be the action context of the tool's+ * primary component. This is primarily intended for tool-level actions which are the ones that appear+ * in the tool's main menu bar or toolbar. This allows the tool actions to mostly work on the* tool's main component context regardless of what has focus, and yet still work on the* focused component if appropriate (such as a snapshot of the main component).*/@@ -160,7 +160,7 @@ public interface DockingActionIf extends HelpDescriptor {/*** Returns the {@link ToolBarData} to be used to put this action in a toolbar. The ToolBarData will be- * null if the action in not set to be in a tool bar.+ * null if the action in not set to be in a toolbar.* @return the {@link ToolBarData} for the popup menu or null if the action is not in a popup menu.*/public ToolBarData getToolBarData();diff --git a/Ghidra/Framework/Docking/src/main/java/docking/action/KeyBindingData.java b/Ghidra/Framework/Docking/src/main/java/docking/action/KeyBindingData.javaindex 8c5a478158..f0cf2a6ad2 100644--- a/Ghidra/Framework/Docking/src/main/java/docking/action/KeyBindingData.java+++ b/Ghidra/Framework/Docking/src/main/java/docking/action/KeyBindingData.java@@ -41,7 +41,7 @@ public class KeyBindingData {}private static KeyStroke parseKeyStrokeString(String keyStrokeString) {- KeyStroke keyStroke = KeyStroke.getKeyStroke(keyStrokeString);+ KeyStroke keyStroke = KeyBindingUtils.parseKeyStroke(keyStrokeString);if (keyStroke == null) {throw new IllegalArgumentException("Invalid keystroke string: " + keyStrokeString);}diff --git a/Ghidra/Framework/Docking/src/main/java/docking/action/builder/AbstractActionBuilder.java b/Ghidra/Framework/Docking/src/main/java/docking/action/builder/AbstractActionBuilder.javaindex 4c8ee6a9fe..e961eee4d8 100644--- a/Ghidra/Framework/Docking/src/main/java/docking/action/builder/AbstractActionBuilder.java+++ b/Ghidra/Framework/Docking/src/main/java/docking/action/builder/AbstractActionBuilder.java@@ -24,6 +24,7 @@ import javax.swing.KeyStroke;import docking.*;import docking.action.*;+import docking.actions.KeyBindingUtils;import ghidra.util.HelpLocation;import ghidra.util.Msg;import resources.ResourceManager;@@ -490,7 +491,7 @@ public abstract class AbstractActionBuilder<T extends DockingActionIf, C extends* @return this builder (for chaining)*/public B keyBinding(String keyStrokeString) {- this.keyBinding = KeyStroke.getKeyStroke(keyStrokeString);+ this.keyBinding = KeyBindingUtils.parseKeyStroke(keyStrokeString);if (keyBinding == null && keyStrokeString != null) {Msg.warn(this, "Can't parse KeyStroke: " + keyStrokeString);}@@ -568,11 +569,12 @@ public abstract class AbstractActionBuilder<T extends DockingActionIf, C extends/*** Sets whether the action will support using the default tool context if the focused provider's- * context is invalid+ * context is invalid.* <P>* By default, actions only work on the current focused provider's context. Setting this- * to true, will cause the action to be evaluated against the default tool context if the+ * to true will cause the action to be evaluated against the default tool context if the* focused context is not valid for this action.+ ** @param b the new value* @return this builder (for chaining)*/