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

This commit is contained in:
dragonmacher 2023-08-11 17:14:28 -04:00
parent 960fc2d06f
commit 0699376759
30 changed files with 98 additions and 127 deletions

View File

@ -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");

View File

@ -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();

View File

@ -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();

View File

@ -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));

View File

@ -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;
}

View File

@ -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();
}

View File

@ -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());

View File

@ -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");

View File

@ -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));

View File

@ -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();

View File

@ -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");

View File

@ -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();

View File

@ -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();

View File

@ -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();
}

View File

@ -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"));

View File

@ -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());

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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();
}

View File

@ -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));

View File

@ -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();
}

View File

@ -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();
}

View File

@ -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();

View File

@ -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

View File

@ -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);
}

View File

@ -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);
.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());
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));
}

View File

@ -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;
}

View File

@ -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);