Skip to content

Ghidra is a software reverse engineering (SRE) framework

GP-3708 - Update Enum Editor actions to appear in tool options

dragonmacher069937675972
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/AddBitFieldAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/AddBitFieldAction.java
index 8a7462ba70..27ee48165b 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/AddBitFieldAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/AddBitFieldAction.java
@@ -35,7 +35,7 @@ public class AddBitFieldAction extends CompositeEditorTableAction {
private static String[] POPUP_PATH = new String[] { ACTION_NAME };
public AddBitFieldAction(CompositeEditorProvider provider) {
- super(provider, EDIT_ACTION_PREFIX + ACTION_NAME, GROUP_NAME, POPUP_PATH, null, null);
+ super(provider, ACTION_NAME, GROUP_NAME, POPUP_PATH, null, null);
setDescription(DESCRIPTION);
if (!(model instanceof CompEditorModel)) {
throw new AssertException("unsupported use");
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ApplyAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ApplyAction.java
index 0f4f4fcefb..811dc3a51c 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ApplyAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ApplyAction.java
@@ -33,7 +33,7 @@ public class ApplyAction extends CompositeEditorTableAction {
private final static String[] POPUP_PATH = new String[] { "Apply Edits" };
public ApplyAction(CompositeEditorProvider provider) {
- super(provider, EDIT_ACTION_PREFIX + ACTION_NAME, GROUP_NAME, POPUP_PATH, null, ICON);
+ super(provider, ACTION_NAME, GROUP_NAME, POPUP_PATH, null, ICON);
setDescription("Apply editor changes");
adjustEnablement();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ArrayAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ArrayAction.java
index 124f21eb65..f28973bfc9 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ArrayAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ArrayAction.java
@@ -39,7 +39,7 @@ public class ArrayAction extends CompositeEditorTableAction {
private static String[] POPUP_PATH = new String[] { ACTION_NAME };
public ArrayAction(CompositeEditorProvider provider) {
- super(provider, EDIT_ACTION_PREFIX + ACTION_NAME, GROUP_NAME, POPUP_PATH, null, ICON);
+ super(provider, ACTION_NAME, GROUP_NAME, POPUP_PATH, null, ICON);
setDescription(DESCRIPTION);
setKeyBindingData(new KeyBindingData(KEY_STROKE));
adjustEnablement();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ClearAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ClearAction.java
index a75a0af547..40ed18db98 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ClearAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ClearAction.java
@@ -34,7 +34,7 @@ public class ClearAction extends CompositeEditorTableAction {
private final static KeyStroke KEY_STROKE = KeyStroke.getKeyStroke(KeyEvent.VK_C, 0);
public ClearAction(CompositeEditorProvider provider) {
- super(provider, EDIT_ACTION_PREFIX + ACTION_NAME, GROUP_NAME, POPUP_PATH, null, ICON);
+ super(provider, ACTION_NAME, GROUP_NAME, POPUP_PATH, null, ICON);
setDescription("Clear the selected components");
setKeyBindingData(new KeyBindingData(KEY_STROKE));
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorTableAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorTableAction.java
index 1dae09453b..45c1a01e16 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorTableAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorTableAction.java
@@ -21,16 +21,21 @@ import javax.swing.*;
import docking.action.*;
import docking.widgets.table.GTable;
+import ghidra.app.plugin.core.datamgr.editor.DataTypeEditorManager;
import ghidra.framework.plugintool.Plugin;
import ghidra.framework.plugintool.PluginTool;
import ghidra.util.HelpLocation;
/**
- * CompositeEditorAction is an abstract class that should be extended for any
- * action that is to be associated with a composite editor.
+ * CompositeEditorAction is an abstract class that should be extended for any action that is to be
+ * associated with a composite editor.
+ * <p>
+ * Note: Any new actions must be registered in the editor manager via the actions's name.
*/
abstract public class CompositeEditorTableAction extends DockingAction implements EditorAction {
+ private static final String PREFIX = DataTypeEditorManager.EDIT_ACTION_PREFIX;
+
protected CompositeEditorProvider provider;
protected CompositeEditorModel model;
protected String tooltip;
@@ -43,13 +48,18 @@ abstract public class CompositeEditorTableAction extends DockingAction implement
protected Plugin plugin;
protected PluginTool tool;
- public static final String EDIT_ACTION_PREFIX = "Editor: ";
+ // note: Only call this constructor if you know you do not want to use the shared editor prefix;
+ // If you call this, then you must manage your own menu/popup/toolbar data installation
+ protected CompositeEditorTableAction(CompositeEditorProvider provider, String name) {
+ super(name, provider.plugin.getName());
+ init(provider);
+ }
public CompositeEditorTableAction(CompositeEditorProvider provider, String name, String group,
String[] popupPath, String[] menuPath, Icon icon) {
- super(name, provider.plugin.getName(), KeyBindingType.SHARED);
- this.provider = provider;
- model = provider.getModel();
+ super(PREFIX + name, provider.plugin.getName(),
+ KeyBindingType.SHARED);
+ init(provider);
if (menuPath != null) {
setMenuBarData(new MenuData(menuPath, icon, group));
}
@@ -59,6 +69,11 @@ abstract public class CompositeEditorTableAction extends DockingAction implement
if (icon != null) {
setToolBarData(new ToolBarData(icon, group));
}
+ }
+
+ private void init(CompositeEditorProvider editorProvider) {
+ this.provider = editorProvider;
+ this.model = provider.getModel();
this.plugin = provider.plugin;
this.tool = plugin.getTool();
model.addCompositeEditorModelListener(this);
@@ -100,9 +115,8 @@ abstract public class CompositeEditorTableAction extends DockingAction implement
public String getHelpName() {
String actionName = getName();
- if (actionName.startsWith(CompositeEditorTableAction.EDIT_ACTION_PREFIX)) {
- actionName =
- actionName.substring(CompositeEditorTableAction.EDIT_ACTION_PREFIX.length());
+ if (actionName.startsWith(PREFIX)) {
+ actionName = actionName.substring(PREFIX.length());
}
return actionName;
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CreateInternalStructureAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CreateInternalStructureAction.java
index 5073268877..16ee7d7808 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CreateInternalStructureAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CreateInternalStructureAction.java
@@ -38,7 +38,7 @@ public class CreateInternalStructureAction extends CompositeEditorTableAction {
private static String[] POPUP_PATH = new String[] { ACTION_NAME };
public CreateInternalStructureAction(StructureEditorProvider provider) {
- super(provider, EDIT_ACTION_PREFIX + ACTION_NAME, GROUP_NAME, POPUP_PATH, null, ICON);
+ super(provider, ACTION_NAME, GROUP_NAME, POPUP_PATH, null, ICON);
setDescription(DESCRIPTION);
adjustEnablement();
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CycleGroupAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CycleGroupAction.java
index 234d5becb4..b44e5fb6f5 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CycleGroupAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CycleGroupAction.java
@@ -19,6 +19,7 @@ import javax.swing.KeyStroke;
import docking.ActionContext;
import docking.action.KeyBindingData;
+import docking.action.MenuData;
import ghidra.program.model.data.CycleGroup;
/**
@@ -30,9 +31,13 @@ public class CycleGroupAction extends CompositeEditorTableAction {
private CycleGroup cycleGroup;
public CycleGroupAction(CompositeEditorProvider provider, CycleGroup cycleGroup) {
- super(provider, cycleGroup.getName(), GROUP_NAME,
- new String[] { "Cycle", cycleGroup.getName() },
- new String[] { "Cycle", cycleGroup.getName() }, null);
+ super(provider, cycleGroup.getName());
+
+ setMenuBarData(
+ new MenuData(new String[] { "Cycle", cycleGroup.getName() }, null, GROUP_NAME));
+ setPopupMenuData(
+ new MenuData(new String[] { "Cycle", cycleGroup.getName() }, null, GROUP_NAME));
+
this.cycleGroup = cycleGroup;
getPopupMenuData().setParentMenuGroup(GROUP_NAME);
initKeyStroke(cycleGroup.getDefaultKeyStroke());
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/DeleteAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/DeleteAction.java
index f8c5062b8b..ea9b699e88 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/DeleteAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/DeleteAction.java
@@ -37,7 +37,7 @@ public class DeleteAction extends CompositeEditorTableAction {
private final static KeyStroke KEY_STROKE = KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0);
public DeleteAction(CompositeEditorProvider provider) {
- super(provider, EDIT_ACTION_PREFIX + ACTION_NAME, GROUP_NAME, popupPath, null, ICON);
+ super(provider, ACTION_NAME, GROUP_NAME, popupPath, null, ICON);
setKeyBindingData(new KeyBindingData(KEY_STROKE));
setDescription("Delete the selected components");
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/DuplicateAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/DuplicateAction.java
index fc06774ae9..712843c589 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/DuplicateAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/DuplicateAction.java
@@ -41,7 +41,7 @@ public class DuplicateAction extends CompositeEditorTableAction {
KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.ALT_DOWN_MASK);
public DuplicateAction(CompositeEditorProvider provider) {
- super(provider, EDIT_ACTION_PREFIX + ACTION_NAME, GROUP_NAME, POPUP_PATH, null,
+ super(provider, ACTION_NAME, GROUP_NAME, POPUP_PATH, null,
ICON);
setDescription(DESCRIPTION);
setKeyBindingData(new KeyBindingData(KEY_STROKE));
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/DuplicateMultipleAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/DuplicateMultipleAction.java
index 86a5d5e9ca..50d9df73e3 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/DuplicateMultipleAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/DuplicateMultipleAction.java
@@ -46,7 +46,7 @@ public class DuplicateMultipleAction extends CompositeEditorTableAction {
private KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_M, InputEvent.ALT_DOWN_MASK);
public DuplicateMultipleAction(CompositeEditorProvider provider) {
- super(provider, EDIT_ACTION_PREFIX + ACTION_NAME, GROUP_NAME, POPUP_PATH, null, ICON);
+ super(provider, ACTION_NAME, GROUP_NAME, POPUP_PATH, null, ICON);
setDescription(DESCRIPTION);
setKeyBindingData(new KeyBindingData(keyStroke));
adjustEnablement();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditBitFieldAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditBitFieldAction.java
index 605b6530e6..a4971ca35e 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditBitFieldAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditBitFieldAction.java
@@ -25,10 +25,6 @@ import ghidra.program.model.data.DataTypeComponent;
import ghidra.program.model.data.Structure;
import ghidra.util.exception.AssertException;
-/**
- * Action for use in the composite data type editor.
- * This action has help associated with it.
- */
public class EditBitFieldAction extends CompositeEditorTableAction {
public final static String ACTION_NAME = "Edit Bitfield";
@@ -37,7 +33,7 @@ public class EditBitFieldAction extends CompositeEditorTableAction {
private static String[] POPUP_PATH = new String[] { ACTION_NAME };
public EditBitFieldAction(CompositeEditorProvider provider) {
- super(provider, EDIT_ACTION_PREFIX + ACTION_NAME, GROUP_NAME, POPUP_PATH, null, null);
+ super(provider, ACTION_NAME, GROUP_NAME, POPUP_PATH, null, null);
setDescription(DESCRIPTION);
if (!(model instanceof CompEditorModel)) {
throw new AssertException("unsupported use");
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditComponentAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditComponentAction.java
index e7473be3d0..4a3ccf84d5 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditComponentAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditComponentAction.java
@@ -34,7 +34,7 @@ public class EditComponentAction extends CompositeEditorTableAction {
private DataTypeManagerService dtmService;
public EditComponentAction(CompositeEditorProvider provider) {
- super(provider, EDIT_ACTION_PREFIX + ACTION_NAME, GROUP_NAME, POPUP_PATH, MENU_PATH, null);
+ super(provider, ACTION_NAME, GROUP_NAME, POPUP_PATH, MENU_PATH, null);
this.dtmService = provider.dtmService;
setDescription(DESCRIPTION);
adjustEnablement();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditFieldAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditFieldAction.java
index be82ba70fc..8f6273ec5c 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditFieldAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditFieldAction.java
@@ -38,7 +38,7 @@ public class EditFieldAction extends CompositeEditorTableAction {
private static String[] MENU_PATH = new String[] { ACTION_NAME };
public EditFieldAction(CompositeEditorProvider provider) {
- super(provider, EDIT_ACTION_PREFIX + ACTION_NAME, GROUP_NAME, POPUP_PATH, MENU_PATH, null);
+ super(provider, ACTION_NAME, GROUP_NAME, POPUP_PATH, MENU_PATH, null);
setDescription(DESCRIPTION);
setKeyBindingData(new KeyBindingData(KEY_STROKE));
adjustEnablement();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/FavoritesAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/FavoritesAction.java
index c686e0b2b4..4ffd43f70d 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/FavoritesAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/FavoritesAction.java
@@ -16,6 +16,7 @@
package ghidra.app.plugin.core.compositeeditor;
import docking.ActionContext;
+import docking.action.MenuData;
import ghidra.program.model.data.DataType;
import ghidra.util.exception.UsrException;
@@ -35,10 +36,14 @@ public class FavoritesAction extends CompositeEditorTableAction {
* @param dt the favorite data type
*/
public FavoritesAction(CompositeEditorProvider provider, DataType dt) {
- super(provider, dt.getDisplayName(), GROUP_NAME,
- new String[] { "Favorite", dt.getDisplayName() },
- new String[] { "Favorite", dt.getDisplayName() }, null);
+ super(provider, dt.getDisplayName());
this.dataType = dt;
+
+ setMenuBarData(
+ new MenuData(new String[] { "Favorite", dt.getDisplayName() }, null, GROUP_NAME));
+ setPopupMenuData(
+ new MenuData(new String[] { "Favorite", dt.getDisplayName() }, null, GROUP_NAME));
+
getPopupMenuData().setParentMenuGroup(GROUP_NAME);
adjustEnablement();
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/FindReferencesToField.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/FindReferencesToField.java
index 42f5a3c728..ffcbbc58e6 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/FindReferencesToField.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/FindReferencesToField.java
@@ -34,7 +34,7 @@ public class FindReferencesToField extends CompositeEditorTableAction {
private static String[] popupPath = new String[] { ACTION_NAME };
public FindReferencesToField(CompositeEditorProvider provider) {
- super(provider, EDIT_ACTION_PREFIX + ACTION_NAME, GROUP_NAME, popupPath, null, null);
+ super(provider, ACTION_NAME, GROUP_NAME, popupPath, null, null);
setDescription(DESCRIPTION);
adjustEnablement();
setHelpLocation(new HelpLocation(HelpTopics.FIND_REFERENCES, "Data_Types"));
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/HexNumbersAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/HexNumbersAction.java
index b9c4b7939b..c0a2ce5784 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/HexNumbersAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/HexNumbersAction.java
@@ -36,7 +36,7 @@ public class HexNumbersAction extends CompositeEditorTableAction implements Togg
private boolean isSelected;
public HexNumbersAction(CompositeEditorProvider provider) {
- super(provider, EDIT_ACTION_PREFIX + ACTION_NAME, GROUP_NAME, PATH, PATH, null);
+ super(provider, ACTION_NAME, GROUP_NAME, PATH, PATH, null);
setDescription(DESCRIPTION);
setEnabled(true);
setSelected(model.isShowingNumbersInHex());
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/InsertUndefinedAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/InsertUndefinedAction.java
index 89cdcf2d08..8b353f88ce 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/InsertUndefinedAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/InsertUndefinedAction.java
@@ -43,7 +43,7 @@ public class InsertUndefinedAction extends CompositeEditorTableAction {
KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.ALT_DOWN_MASK);
public InsertUndefinedAction(CompositeEditorProvider provider) {
- super(provider, EDIT_ACTION_PREFIX + ACTION_NAME, GROUP_NAME, POPUP_PATH, null, ICON);
+ super(provider, ACTION_NAME, GROUP_NAME, POPUP_PATH, null, ICON);
setDescription(DESCRIPTION);
setKeyBindingData(new KeyBindingData(KEY_STROKE));
adjustEnablement();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/MoveDownAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/MoveDownAction.java
index 615e7fca54..228d00c821 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/MoveDownAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/MoveDownAction.java
@@ -42,7 +42,7 @@ public class MoveDownAction extends CompositeEditorTableAction {
KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.ALT_DOWN_MASK);
public MoveDownAction(CompositeEditorProvider provider) {
- super(provider, EDIT_ACTION_PREFIX + ACTION_NAME, GROUP_NAME, POPUP_PATH, null, ICON);
+ super(provider, ACTION_NAME, GROUP_NAME, POPUP_PATH, null, ICON);
setDescription(DESCRIPTION);
setKeyBindingData(new KeyBindingData(KEY_STROKE));
adjustEnablement();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/MoveUpAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/MoveUpAction.java
index bf6a913b53..c05e1d58dc 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/MoveUpAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/MoveUpAction.java
@@ -42,7 +42,7 @@ public class MoveUpAction extends CompositeEditorTableAction {
KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.ALT_DOWN_MASK);
public MoveUpAction(CompositeEditorProvider provider) {
- super(provider, EDIT_ACTION_PREFIX + ACTION_NAME, GROUP_NAME, POPUP_PATH, null, ICON);
+ super(provider, ACTION_NAME, GROUP_NAME, POPUP_PATH, null, ICON);
setDescription(DESCRIPTION);
setKeyBindingData(new KeyBindingData(KEY_STROKE));
adjustEnablement();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/PointerAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/PointerAction.java
index 8016580301..5838ef3ac2 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/PointerAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/PointerAction.java
@@ -40,7 +40,7 @@ public class PointerAction extends CompositeEditorTableAction {
private final static KeyStroke KEY_STROKE = KeyStroke.getKeyStroke(KeyEvent.VK_P, 0);
public PointerAction(CompositeEditorProvider provider) {
- super(provider, EDIT_ACTION_PREFIX + ACTION_NAME, GROUP_NAME, null, null, null);
+ super(provider, ACTION_NAME, GROUP_NAME, null, null, null);
setDescription(DESCRIPTION);
setKeyBindingData(new KeyBindingData(KEY_STROKE, DefaultLevel));
adjustEnablement();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ShowComponentPathAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ShowComponentPathAction.java
index a21112a682..2617276a66 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ShowComponentPathAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ShowComponentPathAction.java
@@ -33,7 +33,7 @@ public class ShowComponentPathAction extends CompositeEditorTableAction {
private static String[] MENU_PATH = new String[] { ACTION_NAME };
public ShowComponentPathAction(CompositeEditorProvider provider) {
- super(provider, EDIT_ACTION_PREFIX + ACTION_NAME, GROUP_NAME, POPUP_PATH, MENU_PATH, null);
+ super(provider, ACTION_NAME, GROUP_NAME, POPUP_PATH, MENU_PATH, null);
setDescription(DESCRIPTION);
adjustEnablement();
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ShowDataTypeInTreeAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ShowDataTypeInTreeAction.java
index 6c16f9beba..ee1faf4f5c 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ShowDataTypeInTreeAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/ShowDataTypeInTreeAction.java
@@ -28,13 +28,15 @@ import ghidra.program.model.data.*;
*/
public class ShowDataTypeInTreeAction extends CompositeEditorTableAction {
+ public final static String ACTION_NAME = "Show In Data Type Manager";
+
// This action should go after the row-based actions, which have this group:
// 3_COMPONENT_EDITOR_ACTION
private static final String TOOLBAR_GROUP = "4_COMPONENT_EDITOR_ACTION";
private static final Icon ICON = new GIcon("icon.plugin.composite.editor.show.type");
public ShowDataTypeInTreeAction(CompositeEditorProvider provider) {
- super(provider, "Show In Data Type Manager", TOOLBAR_GROUP, null /*popupPath*/,
+ super(provider, ACTION_NAME, TOOLBAR_GROUP, null /*popupPath*/,
null /*menuPath*/, ICON);
setToolBarData(new ToolBarData(ICON, TOOLBAR_GROUP));
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/StructureEditorOptionManager.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/StructureEditorOptionManager.java
deleted file mode 100644
index 924f30a65b..0000000000
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/StructureEditorOptionManager.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/* ###
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.app.plugin.core.compositeeditor;
-
-public interface StructureEditorOptionManager {
-
- public abstract boolean showStructureNumbersInHex();
-}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/UnionEditorOptionManager.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/UnionEditorOptionManager.java
deleted file mode 100644
index 7cab0db501..0000000000
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/UnionEditorOptionManager.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/* ###
- * 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.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package ghidra.app.plugin.core.compositeeditor;
-
-public interface UnionEditorOptionManager {
-
- public abstract boolean showUnionNumbersInHex();
-}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/UnpackageAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/UnpackageAction.java
index 64b4fb04db..d21be580f0 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/UnpackageAction.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/UnpackageAction.java
@@ -43,7 +43,7 @@ public class UnpackageAction extends CompositeEditorTableAction {
private static String[] POPUP_PATH = new String[] { ACTION_NAME };
public UnpackageAction(StructureEditorProvider provider) {
- super(provider, EDIT_ACTION_PREFIX + ACTION_NAME, GROUP_NAME, POPUP_PATH, null, ICON);
+ super(provider, ACTION_NAME, GROUP_NAME, POPUP_PATH, null, ICON);
setDescription(DESCRIPTION);
setKeyBindingData(new KeyBindingData(KEY_STROKE));
adjustEnablement();
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/DataTypeEditorManager.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/DataTypeEditorManager.java
index 29c8a52a48..61f317b390 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/DataTypeEditorManager.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/DataTypeEditorManager.java
@@ -34,10 +34,11 @@ import ghidra.util.exception.*;
/**
* Manages program and archive data type editors.
*/
-public class DataTypeEditorManager
- implements EditorListener, StructureEditorOptionManager, UnionEditorOptionManager {
+public class DataTypeEditorManager implements EditorListener {
- private ArrayList<EditorProvider> editorList;
+ public static final String EDIT_ACTION_PREFIX = "Editor: ";
+
+ private List<EditorProvider> editorList;
private EditorOptionManager editorOptionMgr; // manages editor tool options
private DataTypeManagerPlugin plugin;
@@ -133,6 +134,7 @@ public class DataTypeEditorManager
private void installEditorActions() {
+ // composite editor actions
registerAction(ApplyAction.ACTION_NAME);
registerAction(InsertUndefinedAction.ACTION_NAME);
registerAction(MoveUpAction.ACTION_NAME);
@@ -152,6 +154,12 @@ public class DataTypeEditorManager
registerAction(ShowComponentPathAction.ACTION_NAME);
registerAction(AddBitFieldAction.ACTION_NAME);
registerAction(EditBitFieldAction.ACTION_NAME);
+ registerAction(ShowDataTypeInTreeAction.ACTION_NAME);
+
+ // enum editor actions
+ registerAction(EnumEditorProvider.ACTION_NAME_ADD);
+ registerAction(EnumEditorProvider.ACTION_NAME_APPLY);
+ registerAction(EnumEditorProvider.ACTION_NAME_DELETE);
}
private void registerAction(String name) {
@@ -356,11 +364,11 @@ public class DataTypeEditorManager
DataTypeManager programDataTypeManager = domainObject.getDataTypeManager();
if (dataTypeManager == programDataTypeManager) {
/*
-
+
It is not clear why this check was added. It seem reasonable to always let the
editor know about the event. With this code enabled, editors with new, unsaved
types will be closed.
-
+
DataTypePath dtPath = editor.getDtPath();
CategoryPath categoryPath = dtPath.getCategoryPath();
String name = dtPath.getDataTypeName();
@@ -451,18 +459,10 @@ public class DataTypeEditorManager
return true;
}
- /* (non-Javadoc)
- * @see ghidra.app.plugin.core.compositeeditor.StructureEditorOptionManager#showStructureCompOffsetInHex()
- */
- @Override
public boolean showStructureNumbersInHex() {
return editorOptionMgr.showStructureNumbersInHex();
}
- /* (non-Javadoc)
- * @see ghidra.app.plugin.core.compositeeditor.UnionEditorOptionManager#showUnionCompLengthInHex()
- */
- @Override
public boolean showUnionNumbersInHex() {
return editorOptionMgr.showUnionNumbersInHex();
}
@@ -617,7 +617,7 @@ public class DataTypeEditorManager
// can't rely on functionDefinition which may be null for new definition
DataTypeManager dtMgr = getDataTypeManager();
if (dtMgr instanceof CompositeViewerDataTypeManager) {
- dtMgr = ((CompositeViewerDataTypeManager)dtMgr).getOriginalDataTypeManager();
+ dtMgr = ((CompositeViewerDataTypeManager) dtMgr).getOriginalDataTypeManager();
}
ArrayList<String> list = new ArrayList<>();
list.add(Function.UNKNOWN_CALLING_CONVENTION_STRING);
@@ -686,7 +686,7 @@ public class DataTypeEditorManager
Msg.error(this, "Unexpected Exception", e);
}
finally {
- manager.endTransaction(id, true);
+ manager.endTransaction(id, true);
}
}
}
@@ -706,7 +706,7 @@ public class DataTypeEditorManager
private String name;
DtSharedActionPlaceholder(String name) {
- this.name = CompositeEditorTableAction.EDIT_ACTION_PREFIX + name;
+ this.name = EDIT_ACTION_PREFIX + name;
}
@Override
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EditorOptionManager.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EditorOptionManager.java
index dadce93f03..b7970c6b6d 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EditorOptionManager.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EditorOptionManager.java
@@ -15,14 +15,12 @@
*/
package ghidra.app.plugin.core.datamgr.editor;
-import ghidra.app.plugin.core.compositeeditor.StructureEditorOptionManager;
-import ghidra.app.plugin.core.compositeeditor.UnionEditorOptionManager;
import ghidra.framework.options.*;
import ghidra.framework.plugintool.Plugin;
import ghidra.util.HelpLocation;
public class EditorOptionManager
- implements OptionsChangeListener, StructureEditorOptionManager, UnionEditorOptionManager {
+ implements OptionsChangeListener {
private final static String STRUCTURE_EDITOR_NAME = "Structure Editor";
private final static String UNION_EDITOR_NAME = "Union Editor";
@@ -63,6 +61,7 @@ public class EditorOptionManager
options.addOptionsChangeListener(this);
}
+ @Override
public void optionsChanged(ToolOptions options, String name, Object oldValue, Object newValue) {
setOptions(options);
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EnumEditorProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EnumEditorProvider.java
index 6826a2de55..3eeda0c708 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EnumEditorProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/datamgr/editor/EnumEditorProvider.java
@@ -55,6 +55,10 @@ import util.CollectionUtils;
public class EnumEditorProvider extends ComponentProviderAdapter
implements ChangeListener, EditorProvider {
+ public static final String ACTION_NAME_ADD = "Add Enum Value";
+ public static final String ACTION_NAME_APPLY = "Apply Enum Changes";
+ public static final String ACTION_NAME_DELETE = "Delete Enum Value";
+
static final Icon EDITOR_ICON = new GIcon("icon.plugin.enum.editor.provider");
private final static Icon APPLY_ICON = new GIcon("icon.plugin.enum.editor.apply");
private final static Icon ADD_ICON = new GIcon("icon.plugin.enum.editor.add");
@@ -278,14 +282,14 @@ public class EnumEditorProvider extends ComponentProviderAdapter
private void createActions() {
hexDisplayAction = new ToggleActionBuilder("Toggle Hex Mode", plugin.getName())
- .menuPath("Show Enum Values in Hex")
- .description("Toggles Enum value column to show values in hex or decimal")
- .keyBinding("Shift-H")
- .selected(true)
- .onAction(c -> editorPanel.setHexDisplayMode(hexDisplayAction.isSelected()))
- .buildAndInstallLocal(this);
-
- addAction = new EnumPluginAction("Add Enum Value", e -> editorPanel.addEntry());
+ .menuPath("Show Enum Values in Hex")
+ .description("Toggles Enum value column to show values in hex or decimal")
+ .keyBinding("Shift-H")
+ .selected(true)
+ .onAction(c -> editorPanel.setHexDisplayMode(hexDisplayAction.isSelected()))
+ .buildAndInstallLocal(this);
+
+ addAction = new EnumPluginAction(ACTION_NAME_ADD, e -> editorPanel.addEntry());
addAction.setEnabled(true);
String editGroup = "Edit";
addAction.setPopupMenuData(new MenuData(new String[] { "Add" }, ADD_ICON, editGroup));
@@ -293,14 +297,14 @@ public class EnumEditorProvider extends ComponentProviderAdapter
addAction.setDescription("Add a new enum entry");
deleteAction =
- new EnumPluginAction("Delete Enum Value", e -> editorPanel.deleteSelectedEntries());
+ new EnumPluginAction(ACTION_NAME_DELETE, e -> editorPanel.deleteSelectedEntries());
deleteAction.setEnabled(false);
deleteAction
- .setPopupMenuData(new MenuData(new String[] { "Delete" }, DELETE_ICON, editGroup));
+ .setPopupMenuData(new MenuData(new String[] { "Delete" }, DELETE_ICON, editGroup));
deleteAction.setToolBarData(new ToolBarData(DELETE_ICON, editGroup));
deleteAction.setDescription("Delete the selected enum entries");
- applyAction = new EnumPluginAction("Apply Enum Changes", e -> applyChanges());
+ applyAction = new EnumPluginAction(ACTION_NAME_APPLY, e -> applyChanges());
applyAction.setEnabled(false);
String firstGroup = "ApplyChanges";
applyAction.setToolBarData(new ToolBarData(APPLY_ICON, firstGroup));
@@ -708,10 +712,11 @@ public class EnumEditorProvider extends ComponentProviderAdapter
}
private class EnumPluginAction extends DockingAction {
- private final ActionListener listener;
+ private ActionListener listener;
EnumPluginAction(String name, ActionListener listener) {
- super(name, plugin.getName());
+ super(DataTypeEditorManager.EDIT_ACTION_PREFIX + name, plugin.getName(),
+ KeyBindingType.SHARED);
this.listener = listener;
setHelpLocation(new HelpLocation(HELP_TOPIC, name));
}
diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/stackeditor/StackEditorProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/stackeditor/StackEditorProvider.java
index 8d8ea5a667..518931e7f7 100644
--- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/stackeditor/StackEditorProvider.java
+++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/stackeditor/StackEditorProvider.java
@@ -113,18 +113,10 @@ public class StackEditorProvider extends CompositeEditorProvider implements Doma
return new ProgramActionContext(this, program);
}
- /**
- * Gets the function name for the function stack frame being edited.
- * @return the name
- */
String getStackName() {
return stackModel.getEditorStack().getDisplayName();
}
- /**
- * Gets the function for the function stack frame being edited.
- * @return the function
- */
Function getFunction() {
StackFrameDataType editorStack = stackModel.getEditorStack();
if (editorStack == null) {
@@ -138,9 +130,6 @@ public class StackEditorProvider extends CompositeEditorProvider implements Doma
return getDtPath().equals(functionPath);
}
- /**
- * Gets the program associated with the stack frame being edited.
- */
protected Program getProgram() {
return program;
}
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 3fe94ff5c6..022a895cfb 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
@@ -45,10 +45,10 @@ import docking.widgets.dialogs.NumberRangeInputDialog;
import docking.widgets.tree.GTreeNode;
import ghidra.app.context.ProgramActionContext;
import ghidra.app.plugin.core.compositeeditor.ApplyAction;
-import ghidra.app.plugin.core.compositeeditor.CompositeEditorTableAction;
import ghidra.app.plugin.core.datamgr.actions.*;
import ghidra.app.plugin.core.datamgr.archive.Archive;
import ghidra.app.plugin.core.datamgr.archive.DataTypeManagerHandler;
+import ghidra.app.plugin.core.datamgr.editor.DataTypeEditorManager;
import ghidra.app.plugin.core.datamgr.tree.*;
import ghidra.app.plugin.core.function.AbstractEditFunctionSignatureDialog;
import ghidra.app.plugin.core.programtree.ProgramTreePlugin;
@@ -777,7 +777,7 @@ public class DataTypeManagerPluginTest extends AbstractGhidraHeadedIntegrationTe
// the owner for the action is the tool, since the registered item is just a placeholder
// because the editor actions are shared actions
String owner = " (" + ToolConstants.SHARED_OWNER + ')';
- String actionName = CompositeEditorTableAction.EDIT_ACTION_PREFIX + ApplyAction.ACTION_NAME;
+ String actionName = DataTypeEditorManager.EDIT_ACTION_PREFIX + ApplyAction.ACTION_NAME;
String optionName = actionName + owner;
ToolOptions options = tool.getOptions(DockingToolConstants.KEY_BINDINGS);