From b62b8f680dfc5e3f392d27e2e256875f551313d7 Mon Sep 17 00:00:00 2001
From: dragonmacher <48328597+dragonmacher@users.noreply.github.com>
Date: Mon, 28 Oct 2024 18:10:06 -0400
Subject: [PATCH] GP-5052 - Moved some context menu actions into sub-menus
---
.../topics/DisassemblerPlugin/Disassembly.htm | 10 ++---
.../app/plugin/core/clear/ClearPlugin.java | 11 +++---
.../core/disassembler/ContextAction.java | 28 +++++++-------
.../core/disassembler/DisassembleAction.java | 37 +++++++++----------
.../RestrictedDisassembleAction.java | 10 ++---
.../disassembler/StaticDisassembleAction.java | 10 ++---
6 files changed, 51 insertions(+), 55 deletions(-)
diff --git a/Ghidra/Features/Base/src/main/help/help/topics/DisassemblerPlugin/Disassembly.htm b/Ghidra/Features/Base/src/main/help/help/topics/DisassemblerPlugin/Disassembly.htm
index 0584cf8045..40520563f8 100644
--- a/Ghidra/Features/Base/src/main/help/help/topics/DisassemblerPlugin/Disassembly.htm
+++ b/Ghidra/Features/Base/src/main/help/help/topics/DisassemblerPlugin/Disassembly.htm
@@ -53,7 +53,7 @@
Right-mouse-click
- Select Disassembly
+ Select Disassemble
Disassemble
The disassembly progress is displayed in the progress status area (bottom right) of the
@@ -124,7 +124,7 @@
Right-mouse-click
- Select Disassemble (Static).
+ Select Disassemble
Disassemble (Static).
The disassembly progress is displayed in the progress status area (bottom right) of the
@@ -152,7 +152,7 @@
- Place the cursor in the Code Browser on an undefined byte.
- - Right-mouse-click, and select Disassemble (Restricted).
+ - Right-mouse-click, and select Disassemble
Disassemble (Restricted).
The disassembly progress is displayed in the progress status area (bottom right) of the
@@ -231,9 +231,7 @@
To changes the default processor options:
- - Place the cursor in the Code Browser.
-
- - Right-mouse-click, and select the "Processor Options" menu item.
+ - Select Tools
Processor Options...
- Enter the values and press the "Ok" button.
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/clear/ClearPlugin.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/clear/ClearPlugin.java
index 0fd2387c14..5207b5e0e8 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/clear/ClearPlugin.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/clear/ClearPlugin.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.
@@ -42,6 +42,7 @@ import ghidra.program.util.*;
)
//@formatter:on
public class ClearPlugin extends Plugin {
+ private static final String CLEAR_MENU = "Clear";
private static final String CLEAR_WITH_OPTIONS_NAME = "Clear With Options";
private static final String CLEAR_CODE_BYTES_NAME = "Clear Code Bytes";
private static final String CLEAR_FLOW_AND_REPAIR = "Clear Flow and Repair";
@@ -181,7 +182,7 @@ public class ClearPlugin extends Plugin {
new ActionBuilder(CLEAR_CODE_BYTES_NAME, getName())
.menuPath(ToolConstants.MENU_EDIT, CLEAR_CODE_BYTES_NAME)
.menuGroup(CLEAR_CODE_BYTES_NAME, "1")
- .popupMenuPath(CLEAR_CODE_BYTES_NAME)
+ .popupMenuPath(CLEAR_MENU, CLEAR_CODE_BYTES_NAME)
.popupMenuGroup(CLEAR_CODE_BYTES_NAME, "1")
.keyBinding("C")
.withContext(ListingActionContext.class)
@@ -193,7 +194,7 @@ public class ClearPlugin extends Plugin {
new ActionBuilder(CLEAR_WITH_OPTIONS_NAME, getName())
.menuPath(ToolConstants.MENU_EDIT, CLEAR_WITH_OPTIONS_NAME + "...")
.menuGroup(CLEAR_CODE_BYTES_NAME, "2")
- .popupMenuPath(CLEAR_WITH_OPTIONS_NAME + "...")
+ .popupMenuPath(CLEAR_MENU, CLEAR_WITH_OPTIONS_NAME + "...")
.popupMenuGroup(CLEAR_CODE_BYTES_NAME, "2")
.withContext(ListingActionContext.class)
.inWindow(ActionBuilder.When.CONTEXT_MATCHES)
@@ -203,7 +204,7 @@ public class ClearPlugin extends Plugin {
new ActionBuilder(CLEAR_FLOW_AND_REPAIR, getName())
.menuPath(ToolConstants.MENU_EDIT, CLEAR_FLOW_AND_REPAIR + "...")
.menuGroup(CLEAR_CODE_BYTES_NAME, "3")
- .popupMenuPath(CLEAR_FLOW_AND_REPAIR + "...")
+ .popupMenuPath(CLEAR_MENU, CLEAR_FLOW_AND_REPAIR + "...")
.popupMenuGroup(CLEAR_CODE_BYTES_NAME, "3")
.withContext(ListingActionContext.class)
.inWindow(ActionBuilder.When.CONTEXT_MATCHES)
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/ContextAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/ContextAction.java
index 3c6701896e..d1b9d53b22 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/ContextAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/ContextAction.java
@@ -1,13 +1,12 @@
/* ###
* IP: GHIDRA
- * REVIEWED: YES
*
* 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.
@@ -16,35 +15,34 @@
*/
package ghidra.app.plugin.core.disassembler;
+import docking.action.MenuData;
import ghidra.app.context.ListingActionContext;
import ghidra.app.context.ListingContextAction;
import ghidra.util.HelpLocation;
-import docking.action.MenuData;
public class ContextAction extends ListingContextAction {
private DisassemblerPlugin plugin;
-
public ContextAction(DisassemblerPlugin plugin, String groupName) {
super("Processor Options", plugin.getName());
-
+
this.plugin = plugin;
-
- setPopupMenuData( new MenuData(
- new String[]{"Processor Options..." },
- null,
- groupName ) );
+
+ setMenuBarData(new MenuData(
+ new String[] { "Tools", "Processor Options..." },
+ null,
+ groupName));
setHelpLocation(new HelpLocation("DisassemblerPlugin", "ProcessorOptions"));
}
-
+
@Override
- public void actionPerformed(ListingActionContext context) {
+ public void actionPerformed(ListingActionContext context) {
plugin.setDefaultContext(context);
}
-
+
@Override
- public boolean isEnabledForContext(ListingActionContext context) {
+ public boolean isEnabledForContext(ListingActionContext context) {
return plugin.hasContextRegisters(context.getProgram());
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/DisassembleAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/DisassembleAction.java
index 4f02e90835..155e3de055 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/DisassembleAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/DisassembleAction.java
@@ -1,13 +1,12 @@
/* ###
* IP: GHIDRA
- * REVIEWED: YES
*
* 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.
@@ -16,39 +15,39 @@
*/
package ghidra.app.plugin.core.disassembler;
-import ghidra.app.context.ListingActionContext;
-import ghidra.app.context.ListingContextAction;
-import ghidra.program.model.address.Address;
-
import java.awt.event.KeyEvent;
import docking.action.KeyBindingData;
import docking.action.MenuData;
+import ghidra.app.context.ListingActionContext;
+import ghidra.app.context.ListingContextAction;
+import ghidra.program.model.address.Address;
class DisassembleAction extends ListingContextAction {
private DisassemblerPlugin plugin;
public DisassembleAction(DisassemblerPlugin plugin, String groupName) {
super("Disassemble", plugin.getName());
-
+
this.plugin = plugin;
-
- setPopupMenuData( new MenuData( new String[]{"Disassemble" }, null, groupName ) );
- setKeyBindingData( new KeyBindingData( KeyEvent.VK_D, 0 ) );
+
+ setPopupMenuData(
+ new MenuData(new String[] { "Disassemble", "Disassemble" }, null, groupName));
+ setKeyBindingData(new KeyBindingData(KeyEvent.VK_D, 0));
}
-
+
@Override
- public void actionPerformed(ListingActionContext context) {
+ public void actionPerformed(ListingActionContext context) {
plugin.disassembleCallback(context);
}
-
+
@Override
- public boolean isEnabledForContext(ListingActionContext context) {
+ public boolean isEnabledForContext(ListingActionContext context) {
Address address = context.getAddress();
- if ( address == null ) {
- return false;
+ if (address == null) {
+ return false;
}
- return plugin.checkDisassemblyEnabled(context, address, true);
+ return plugin.checkDisassemblyEnabled(context, address, true);
}
-
+
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/RestrictedDisassembleAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/RestrictedDisassembleAction.java
index 2d16e46587..f6dd572026 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/RestrictedDisassembleAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/RestrictedDisassembleAction.java
@@ -1,13 +1,12 @@
/* ###
* IP: GHIDRA
- * REVIEWED: YES
*
* 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,9 +19,9 @@
*/
package ghidra.app.plugin.core.disassembler;
+import docking.action.MenuData;
import ghidra.app.context.ListingActionContext;
import ghidra.app.context.ListingContextAction;
-import docking.action.MenuData;
/**
*
@@ -38,7 +37,8 @@ class RestrictedDisassembleAction extends ListingContextAction {
this.plugin = plugin;
- setPopupMenuData(new MenuData(new String[] { "Disassemble (Restricted)" }, null, groupName));
+ setPopupMenuData(new MenuData(new String[] { "Disassemble", "Disassemble (Restricted)" },
+ null, groupName));
}
@Override
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/StaticDisassembleAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/StaticDisassembleAction.java
index 8c380b14c8..fda4f68ddc 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/StaticDisassembleAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/disassembler/StaticDisassembleAction.java
@@ -1,13 +1,12 @@
/* ###
* IP: GHIDRA
- * REVIEWED: YES
*
* 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,9 +19,9 @@
*/
package ghidra.app.plugin.core.disassembler;
+import docking.action.MenuData;
import ghidra.app.context.ListingActionContext;
import ghidra.app.context.ListingContextAction;
-import docking.action.MenuData;
/**
* Action for static disassembly
@@ -36,7 +35,8 @@ class StaticDisassembleAction extends ListingContextAction {
this.plugin = plugin;
- setPopupMenuData(new MenuData(new String[] { "Disassemble (Static)" }, null, groupName));
+ setPopupMenuData(
+ new MenuData(new String[] { "Disassemble", "Disassemble (Static)" }, null, groupName));
}
@Override