diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorAction.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorAction.java deleted file mode 100644 index 697b73b375..0000000000 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorAction.java +++ /dev/null @@ -1,159 +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; - -import ghidra.framework.plugintool.Plugin; -import ghidra.framework.plugintool.PluginTool; -import ghidra.util.HelpLocation; - -import java.awt.event.ActionListener; - -import javax.swing.*; - -import docking.action.*; - -/** - * CompositeEditorAction is an abstract class that should be extended for any - * action that is to be associated with a composite editor. - */ -abstract public class CompositeEditorAction extends DockingAction implements EditorAction { - - protected CompositeEditorProvider provider; - protected CompositeEditorModel model; - protected String tooltip; - protected ImageIcon icon; - protected ActionListener listener; - protected String displayString; - protected String actionCommand; - protected JButton button; // corresponding JButton for this action - protected KeyStroke keystroke; - protected Plugin plugin; - protected PluginTool tool; - - public static final String EDIT_ACTION_PREFIX = "Editor: "; - - /** - * Defines an Action object with the specified - * description string and a the specified icon. - */ - public CompositeEditorAction(CompositeEditorProvider provider, String name, String group, - String[] popupPath, String[] menuPath, ImageIcon icon) { - super(name, provider.plugin.getName()); - this.provider = provider; - model = provider.getModel(); - if (menuPath != null) { - setMenuBarData(new MenuData(menuPath, icon, group)); - } - if (popupPath != null) { - setPopupMenuData(new MenuData(popupPath, icon, group)); - } - if (icon != null) { - setToolBarData(new ToolBarData(icon, group)); - } - this.plugin = provider.plugin; - this.tool = plugin.getTool(); - model.addCompositeEditorModelListener(this); - String helpAnchor = provider.getHelpName() + "_" + getHelpName(); - setHelpLocation(new HelpLocation(provider.getHelpTopic(), helpAnchor)); - } - - /* (non-Javadoc) - * @see ghidra.framework.plugintool.PluginAction#dispose() - */ - @Override - public void dispose() { - model.removeCompositeEditorModelListener(this); - super.dispose(); - provider = null; - model = null; - plugin = null; - tool = null; - } - - protected void requestTableFocus() { - JTable table = ((CompositeEditorPanel) provider.getComponent()).getTable(); - if (table.isEditing()) { - table.getEditorComponent().requestFocus(); - } - else { - table.requestFocus(); - } - } - - abstract public void adjustEnablement(); - - public String getHelpName() { - String actionName = getName(); - if (actionName.startsWith(CompositeEditorAction.EDIT_ACTION_PREFIX)) { - actionName = actionName.substring(CompositeEditorAction.EDIT_ACTION_PREFIX.length()); - } - return actionName; - } - - /* (non-Javadoc) - * @see ghidra.app.plugin.stackeditor.EditorModelListener#selectionChanged() - */ - public void selectionChanged() { - adjustEnablement(); - } - - /* (non-Javadoc) - * @see ghidra.app.plugin.stackeditor.EditorModelListener#editStateChanged(int) - */ - public void editStateChanged(int i) { - adjustEnablement(); - } - - /* (non-Javadoc) - * @see ghidra.app.plugin.compositeeditor.CompositeEditorModelListener#compositeEditStateChanged(int) - */ - public void compositeEditStateChanged(int type) { - adjustEnablement(); - } - - /* (non-Javadoc) - * @see ghidra.app.plugin.compositeeditor.CompositeEditorModelListener#endFieldEditing() - */ - public void endFieldEditing() { - adjustEnablement(); - } - - /* (non-Javadoc) - * @see ghidra.app.plugin.compositeeditor.CompositeEditorModelListener#componentDataChanged() - */ - public void componentDataChanged() { - adjustEnablement(); - } - - /* (non-Javadoc) - * @see ghidra.app.plugin.compositeeditor.CompositeEditorModelListener#compositeInfoChanged() - */ - public void compositeInfoChanged() { - adjustEnablement(); - } - - /* (non-Javadoc) - * @see ghidra.app.plugin.compositeeditor.CompositeEditorModelListener#statusChanged(java.lang.String, boolean) - */ - public void statusChanged(String message, boolean beep) { - } - - public void showUndefinedStateChanged(boolean showUndefinedBytes) { - adjustEnablement(); - } - -} diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorActionManager.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorActionManager.java index 19338f9d49..c58a4cc462 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorActionManager.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorActionManager.java @@ -32,9 +32,9 @@ import docking.action.KeyBindingData; */ public class CompositeEditorActionManager { private CompositeEditorProvider provider; - private ArrayList editorActions = new ArrayList(); - private ArrayList favoritesActions = - new ArrayList(); + private ArrayList editorActions = new ArrayList(); + private ArrayList favoritesActions = + new ArrayList(); private ArrayList cycleGroupActions = new ArrayList(); private ArrayList listeners = new ArrayList(); @@ -103,24 +103,24 @@ public class CompositeEditorActionManager { * manager created by default are not part of the actions returned. * @return the composite editor actions */ - public CompositeEditorAction[] getEditorActions() { - return editorActions.toArray(new CompositeEditorAction[editorActions.size()]); + public CompositeEditorTableAction[] getEditorActions() { + return editorActions.toArray(new CompositeEditorTableAction[editorActions.size()]); } /** * Gets the cycle group actions that the manager created by default. * @return the cycle group actions */ - public CompositeEditorAction[] getFavoritesActions() { - return favoritesActions.toArray(new CompositeEditorAction[favoritesActions.size()]); + public CompositeEditorTableAction[] getFavoritesActions() { + return favoritesActions.toArray(new CompositeEditorTableAction[favoritesActions.size()]); } /** * Gets the favorites actions that the manager created by default. * @return the favorites actions */ - public CompositeEditorAction[] getCycleGroupActions() { - return cycleGroupActions.toArray(new CompositeEditorAction[cycleGroupActions.size()]); + public CompositeEditorTableAction[] getCycleGroupActions() { + return cycleGroupActions.toArray(new CompositeEditorTableAction[cycleGroupActions.size()]); } /** @@ -128,9 +128,9 @@ public class CompositeEditorActionManager { * action manager. This includes the favorites and cycle groups actions. * @return all composite editor actions */ - public CompositeEditorAction[] getAllActions() { + public CompositeEditorTableAction[] getAllActions() { int numActions = getActionCount(); - CompositeEditorAction[] allActions = new CompositeEditorAction[numActions]; + CompositeEditorTableAction[] allActions = new CompositeEditorTableAction[numActions]; int index = 0; int length; length = editorActions.size(); @@ -153,8 +153,8 @@ public class CompositeEditorActionManager { * @param actionName the name of the action to find. * @return the action or null */ - public CompositeEditorAction getNamedAction(String actionName) { - CompositeEditorAction action; + public CompositeEditorTableAction getNamedAction(String actionName) { + CompositeEditorTableAction action; int length = editorActions.size(); for (int i = 0; i < length; i++) { action = editorActions.get(i); @@ -190,7 +190,7 @@ public class CompositeEditorActionManager { * setting the new actions. * @param actions the composite editor actions. */ - public void setEditorActions(CompositeEditorAction[] actions) { + public void setEditorActions(CompositeEditorTableAction[] actions) { editorActions.clear(); for (int i = 0; i < actions.length; i++) { editorActions.add(actions[i]); @@ -225,21 +225,21 @@ public class CompositeEditorActionManager { cycleGroupActions.clear(); } - private void notifyActionsAdded(ArrayList actions) { + private void notifyActionsAdded(ArrayList actions) { if (actions.size() <= 0) return; int length = listeners.size(); - CompositeEditorAction[] cea = actions.toArray(new CompositeEditorAction[actions.size()]); + CompositeEditorTableAction[] cea = actions.toArray(new CompositeEditorTableAction[actions.size()]); for (int i = 0; i < length; i++) { listeners.get(i).actionsAdded(cea); } } - private void notifyActionsRemoved(ArrayList actions) { + private void notifyActionsRemoved(ArrayList actions) { if (actions.size() <= 0) return; int length = listeners.size(); - CompositeEditorAction[] cea = actions.toArray(new CompositeEditorAction[actions.size()]); + CompositeEditorTableAction[] cea = actions.toArray(new CompositeEditorTableAction[actions.size()]); for (int i = 0; i < length; i++) { listeners.get(i).actionsRemoved(cea); } @@ -251,7 +251,7 @@ public class CompositeEditorActionManager { public void optionsChanged(Options options, String name, Object oldValue, Object newValue) { // Update the editor actions here. // The favorites and cycle groups get handled by stateChanged() and cyclegroupChanged(). - CompositeEditorAction[] actions = getEditorActions(); + CompositeEditorTableAction[] actions = getEditorActions(); for (int i = 0; i < actions.length; i++) { String actionName = actions[i].getFullName(); if (actionName.equals(name)) { diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorPanel.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorPanel.java index b5ff867d5a..ac36db02f2 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorPanel.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorPanel.java @@ -535,8 +535,8 @@ public abstract class CompositeEditorPanel extends JPanel table.putClientProperty("JTable.autoStartsEdit", Boolean.FALSE); table.addMouseListener(new CompositeTableMouseListener()); - CompositeEditorAction action = provider.actionMgr.getNamedAction( - CompositeEditorAction.EDIT_ACTION_PREFIX + EditFieldAction.ACTION_NAME); + CompositeEditorTableAction action = provider.actionMgr.getNamedAction( + CompositeEditorTableAction.EDIT_ACTION_PREFIX + EditFieldAction.ACTION_NAME); Action swingAction = KeyBindingUtils.adaptDockingActionToNonContextAction(action); InputMap map = table.getInputMap(); map.put(action.getKeyBinding(), "StartEditing"); diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorProvider.java index 4da928023c..ad8107e3e3 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorProvider.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/CompositeEditorProvider.java @@ -104,26 +104,26 @@ public abstract class CompositeEditorProvider extends ComponentProviderAdapter } protected void addActionsToTool() { - CompositeEditorAction[] allActions = actionMgr.getAllActions(); - for (CompositeEditorAction allAction : allActions) { + CompositeEditorTableAction[] allActions = actionMgr.getAllActions(); + for (CompositeEditorTableAction allAction : allActions) { tool.addLocalAction(this, allAction); } } - protected CompositeEditorAction[] getActions() { + protected CompositeEditorTableAction[] getActions() { return actionMgr.getAllActions(); } @Override - public void actionsAdded(CompositeEditorAction[] actions) { - for (CompositeEditorAction action : actions) { + public void actionsAdded(CompositeEditorTableAction[] actions) { + for (CompositeEditorTableAction action : actions) { tool.addLocalAction(this, action); } } @Override - public void actionsRemoved(CompositeEditorAction[] actions) { - for (CompositeEditorAction action : actions) { + public void actionsRemoved(CompositeEditorTableAction[] actions) { + for (CompositeEditorTableAction action : actions) { tool.removeLocalAction(this, action); } } @@ -206,8 +206,8 @@ public abstract class CompositeEditorProvider extends ComponentProviderAdapter @Override public void dispose() { - CompositeEditorAction[] allActions = actionMgr.getAllActions(); - for (CompositeEditorAction allAction : allActions) { + CompositeEditorTableAction[] allActions = actionMgr.getAllActions(); + for (CompositeEditorTableAction allAction : allActions) { tool.removeLocalAction(this, allAction); } tool.showComponentProvider(this, false); @@ -254,8 +254,8 @@ public abstract class CompositeEditorProvider extends ComponentProviderAdapter tool.setStatusInfo(msg); } - protected CompositeEditorAction[] createActions() { - return new CompositeEditorAction[0]; + protected CompositeEditorTableAction[] createActions() { + return new CompositeEditorTableAction[0]; } protected boolean applyChanges() { 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 13522e150b..ff66131da2 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 @@ -1,6 +1,5 @@ /* ### * 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. @@ -16,14 +15,144 @@ */ package ghidra.app.plugin.core.compositeeditor; -import javax.swing.ImageIcon; +import ghidra.framework.plugintool.Plugin; +import ghidra.framework.plugintool.PluginTool; +import ghidra.util.HelpLocation; -abstract public class CompositeEditorTableAction extends CompositeEditorAction { +import java.awt.event.ActionListener; + +import javax.swing.*; + +import docking.action.*; + +/** + * CompositeEditorAction is an abstract class that should be extended for any + * action that is to be associated with a composite editor. + */ +abstract public class CompositeEditorTableAction extends DockingAction implements EditorAction { + + protected CompositeEditorProvider provider; + protected CompositeEditorModel model; + protected String tooltip; + protected ImageIcon icon; + protected ActionListener listener; + protected String displayString; + protected String actionCommand; + protected JButton button; // corresponding JButton for this action + protected KeyStroke keystroke; + protected Plugin plugin; + protected PluginTool tool; + + public static final String EDIT_ACTION_PREFIX = "Editor: "; + + /** + * Defines an Action object with the specified + * description string and a the specified icon. + */ + public CompositeEditorTableAction(CompositeEditorProvider provider, String name, String group, + String[] popupPath, String[] menuPath, ImageIcon icon) { + super(name, provider.plugin.getName()); + this.provider = provider; + model = provider.getModel(); + if (menuPath != null) { + setMenuBarData(new MenuData(menuPath, icon, group)); + } + if (popupPath != null) { + setPopupMenuData(new MenuData(popupPath, icon, group)); + } + if (icon != null) { + setToolBarData(new ToolBarData(icon, group)); + } + this.plugin = provider.plugin; + this.tool = plugin.getTool(); + model.addCompositeEditorModelListener(this); + String helpAnchor = provider.getHelpName() + "_" + getHelpName(); + setHelpLocation(new HelpLocation(provider.getHelpTopic(), helpAnchor)); + } + + /* (non-Javadoc) + * @see ghidra.framework.plugintool.PluginAction#dispose() + */ + @Override + public void dispose() { + model.removeCompositeEditorModelListener(this); + super.dispose(); + provider = null; + model = null; + plugin = null; + tool = null; + } + + protected void requestTableFocus() { + JTable table = ((CompositeEditorPanel) provider.getComponent()).getTable(); + if (table.isEditing()) { + table.getEditorComponent().requestFocus(); + } + else { + table.requestFocus(); + } + } + + abstract public void adjustEnablement(); + + public String getHelpName() { + String actionName = getName(); + if (actionName.startsWith(CompositeEditorTableAction.EDIT_ACTION_PREFIX)) { + actionName = actionName.substring(CompositeEditorTableAction.EDIT_ACTION_PREFIX.length()); + } + return actionName; + } + + /* (non-Javadoc) + * @see ghidra.app.plugin.stackeditor.EditorModelListener#selectionChanged() + */ + public void selectionChanged() { + adjustEnablement(); + } + + /* (non-Javadoc) + * @see ghidra.app.plugin.stackeditor.EditorModelListener#editStateChanged(int) + */ + public void editStateChanged(int i) { + adjustEnablement(); + } + + /* (non-Javadoc) + * @see ghidra.app.plugin.compositeeditor.CompositeEditorModelListener#compositeEditStateChanged(int) + */ + public void compositeEditStateChanged(int type) { + adjustEnablement(); + } + + /* (non-Javadoc) + * @see ghidra.app.plugin.compositeeditor.CompositeEditorModelListener#endFieldEditing() + */ + public void endFieldEditing() { + adjustEnablement(); + } + + /* (non-Javadoc) + * @see ghidra.app.plugin.compositeeditor.CompositeEditorModelListener#componentDataChanged() + */ + public void componentDataChanged() { + adjustEnablement(); + } + + /* (non-Javadoc) + * @see ghidra.app.plugin.compositeeditor.CompositeEditorModelListener#compositeInfoChanged() + */ + public void compositeInfoChanged() { + adjustEnablement(); + } + + /* (non-Javadoc) + * @see ghidra.app.plugin.compositeeditor.CompositeEditorModelListener#statusChanged(java.lang.String, boolean) + */ + public void statusChanged(String message, boolean beep) { + } + + public void showUndefinedStateChanged(boolean showUndefinedBytes) { + adjustEnablement(); + } - public CompositeEditorTableAction(CompositeEditorProvider provider, - String name, String group, - String[] popupPath, String[] menuPath, - ImageIcon icon) { - super(provider, name, group, popupPath, menuPath, icon); - } } diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditorActionListener.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditorActionListener.java index 9870c77b5b..f549970838 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditorActionListener.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/EditorActionListener.java @@ -1,6 +1,5 @@ /* ### * 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. @@ -22,11 +21,11 @@ public interface EditorActionListener { * Notification that the indicated actions were added. * @param actions the composite editor actions. */ - public void actionsAdded(CompositeEditorAction[] actions); + public void actionsAdded(CompositeEditorTableAction[] actions); /** * Notification that the indicated actions were removed. * @param actions the composite editor actions. */ - public void actionsRemoved(CompositeEditorAction[] actions); + public void actionsRemoved(CompositeEditorTableAction[] actions); } 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 a403afd29f..09a391f35a 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 @@ -1,6 +1,5 @@ /* ### * 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. @@ -27,7 +26,7 @@ import docking.menu.DockingCheckboxMenuItemUI; * Action for use in the composite data type editor. * This action has help associated with it. */ -public class HexNumbersAction extends CompositeEditorAction implements ToggleDockingActionIf { +public class HexNumbersAction extends CompositeEditorTableAction implements ToggleDockingActionIf { private final static String ACTION_NAME = "Show Numbers In Hex"; private final static String GROUP_NAME = BASIC_ACTION_GROUP; @@ -69,10 +68,12 @@ public class HexNumbersAction extends CompositeEditorAction implements ToggleDoc // Always enabled. } + @Override public boolean isSelected() { return isSelected; } + @Override public void setSelected(boolean newValue) { isSelected = newValue; firePropertyChanged(SELECTED_STATE_PROPERTY, !isSelected, isSelected); diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/StructureEditorProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/StructureEditorProvider.java index 3bf78a01fd..35163715a5 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/StructureEditorProvider.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/StructureEditorProvider.java @@ -57,8 +57,8 @@ public class StructureEditorProvider extends CompositeEditorProvider { * @see ghidra.app.plugin.compositeeditor.CompositeEditorProvider#createActions() */ @Override - protected CompositeEditorAction[] createActions() { - return new CompositeEditorAction[] { + protected CompositeEditorTableAction[] createActions() { + return new CompositeEditorTableAction[] { new ApplyAction(this), // new ToggleLockAction(this), new InsertUndefinedAction(this), new MoveUpAction(this), new MoveDownAction(this), diff --git a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/UnionEditorProvider.java b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/UnionEditorProvider.java index 9e78b01808..b129c645d8 100644 --- a/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/UnionEditorProvider.java +++ b/Ghidra/Features/Base/src/main/java/ghidra/app/plugin/core/compositeeditor/UnionEditorProvider.java @@ -53,8 +53,8 @@ public class UnionEditorProvider extends CompositeEditorProvider { * @see ghidra.app.plugin.compositeeditor.CompositeEditorProvider#createActions() */ @Override - protected CompositeEditorAction[] createActions() { - return new CompositeEditorAction[] { new ApplyAction(this), new MoveUpAction(this), + protected CompositeEditorTableAction[] createActions() { + return new CompositeEditorTableAction[] { new ApplyAction(this), new MoveUpAction(this), new MoveDownAction(this), new DuplicateAction(this), new DuplicateMultipleAction(this), new DeleteAction(this), new PointerAction(this), new ArrayAction(this), new ShowComponentPathAction(this), new EditComponentAction(this), 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 f19ceaae16..3f2046424b 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 @@ -88,8 +88,8 @@ public class StackEditorProvider extends CompositeEditorProvider implements Doma } @Override - protected CompositeEditorAction[] createActions() { - return new CompositeEditorAction[] { new ApplyAction(this), new ClearAction(this), + protected CompositeEditorTableAction[] createActions() { + return new CompositeEditorTableAction[] { new ApplyAction(this), new ClearAction(this), new DeleteAction(this), new PointerAction(this), new ArrayAction(this), new ShowComponentPathAction(this), new EditComponentAction(this), new EditFieldAction(this), new HexNumbersAction(this) }; @@ -133,7 +133,7 @@ public class StackEditorProvider extends CompositeEditorProvider implements Doma } @Override - protected CompositeEditorAction[] getActions() { + protected CompositeEditorTableAction[] getActions() { return actionMgr.getAllActions(); } diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractEditorTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractEditorTest.java index 7559569f89..b82e737d3d 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractEditorTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractEditorTest.java @@ -79,7 +79,7 @@ public abstract class AbstractEditorTest extends AbstractGhidraHeadedIntegration protected int txId; protected StatusListener listener; - protected CompositeEditorAction[] actions; + protected CompositeEditorTableAction[] actions; protected ArrayList favorites = new ArrayList<>(); protected ArrayList cycles = new ArrayList<>(); @@ -799,7 +799,7 @@ public abstract class AbstractEditorTest extends AbstractGhidraHeadedIntegration } } - protected void checkEnablement(CompositeEditorAction action, boolean expectedEnablement) { + protected void checkEnablement(CompositeEditorTableAction action, boolean expectedEnablement) { AtomicBoolean result = new AtomicBoolean(); runSwing(() -> result.set(action.isEnabledForContext(provider.getActionContext(null)))); boolean actionEnablement = result.get(); diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractStructureEditorTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractStructureEditorTest.java index 879ad40b38..7eeb35c5c5 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractStructureEditorTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractStructureEditorTest.java @@ -111,7 +111,7 @@ public abstract class AbstractStructureEditorTest extends AbstractEditorTest { void getActions() { actions = provider.getActions(); - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if (action instanceof FavoritesAction) { favorites.add((FavoritesAction) action); } diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractUnionEditorTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractUnionEditorTest.java index 08674d61a5..95bbb2f446 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractUnionEditorTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/AbstractUnionEditorTest.java @@ -107,7 +107,7 @@ public abstract class AbstractUnionEditorTest extends AbstractEditorTest { void getActions() { actions = provider.getActions(); - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if (action instanceof FavoritesAction) { favorites.add((FavoritesAction) action); } diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorAlignmentTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorAlignmentTest.java index ae5d24d02a..047ae6923d 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorAlignmentTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorAlignmentTest.java @@ -122,7 +122,7 @@ public class StructureEditorAlignmentTest extends AbstractStructureEditorTest { addDataType(arrayDt); // Check enablement. - CompositeEditorAction[] pActions = provider.getActions(); + CompositeEditorTableAction[] pActions = provider.getActions(); for (int i = 0; i < pActions.length; i++) { if ((pActions[i] instanceof FavoritesAction) || (pActions[i] instanceof CycleGroupAction) || diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedEnablementTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedEnablementTest.java index 5e8cf2ec11..4cd8361243 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedEnablementTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorLockedEnablementTest.java @@ -101,7 +101,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor getModel().getOriginalCategoryPath().getPath()); assertEquals(getModel().getTypeName(), "Structure"); - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if ((action instanceof EditFieldAction) || (action instanceof InsertUndefinedAction) || (action instanceof PointerAction) || (action instanceof HexNumbersAction) || (action instanceof ApplyAction)) { @@ -151,7 +151,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor assertEquals(pgmBbCat.getCategoryPathName(), getModel().getOriginalCategoryPath().getPath()); - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if ((action instanceof EditFieldAction) || (action instanceof InsertUndefinedAction) || (action instanceof PointerAction) || (action instanceof HexNumbersAction)) { checkEnablement(action, true); @@ -187,7 +187,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor // Check enablement on first component selected. setSelection(new int[] { 0 }); - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if (action instanceof FavoritesAction) { FavoritesAction fav = (FavoritesAction) action; int len = fav.getDataType().getLength(); @@ -216,7 +216,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor // Check enablement on central component selected. setSelection(new int[] { 3 }); - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if (action instanceof FavoritesAction) { FavoritesAction fav = (FavoritesAction) action; int len = fav.getDataType().getLength(); @@ -246,7 +246,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor // Check enablement on last component selected. setSelection(new int[] { last }); - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if (action instanceof FavoritesAction) { checkEnablement(action, true); } @@ -272,7 +272,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor // Check enablement on a contiguous multi-component selection. setSelection(new int[] { 2, 3, 4 }); - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if (action instanceof FavoritesAction) { FavoritesAction fav = (FavoritesAction) action; int len = fav.getDataType().getLength(); @@ -300,7 +300,7 @@ public class StructureEditorLockedEnablementTest extends AbstractStructureEditor // Check enablement on a non-contiguous multi-component selection. setSelection(new int[] { 2, 3, 6, 7 }); - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if (action instanceof FavoritesAction) { FavoritesAction fav = (FavoritesAction) action; int len = fav.getDataType().getLength(); diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedEnablementTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedEnablementTest.java index 663fdce945..e9b234773b 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedEnablementTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/StructureEditorUnlockedEnablementTest.java @@ -80,7 +80,7 @@ public class StructureEditorUnlockedEnablementTest extends AbstractStructureEdit assertEquals(model.getTypeName(), "Structure"); // Check enablement. - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if ((action instanceof FavoritesAction) || (action instanceof CycleGroupAction) || (action instanceof EditFieldAction) || (action instanceof InsertUndefinedAction) || (action instanceof PointerAction) || (action instanceof HexNumbersAction) || @@ -114,7 +114,7 @@ public class StructureEditorUnlockedEnablementTest extends AbstractStructureEdit assertEquals(pgmBbCat.getCategoryPathName(), model.getOriginalCategoryPath().getPath()); // Check enablement on blank line selected. - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if ((action instanceof FavoritesAction) || (action instanceof CycleGroupAction) || (action instanceof EditFieldAction) || (action instanceof InsertUndefinedAction) || (action instanceof PointerAction) || (action instanceof HexNumbersAction)) { @@ -141,7 +141,7 @@ public class StructureEditorUnlockedEnablementTest extends AbstractStructureEdit // Check enablement on first component selected. setSelection(new int[] { 0 }); - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if ((action instanceof EditFieldAction) || (action instanceof ShowComponentPathAction) || (action instanceof InsertUndefinedAction) || (action instanceof MoveDownAction) || @@ -180,7 +180,7 @@ public class StructureEditorUnlockedEnablementTest extends AbstractStructureEdit // Check enablement on central component selected. runSwing(() -> setSelection(new int[] { 1 })); - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if ((action instanceof EditFieldAction) || (action instanceof ShowComponentPathAction) || (action instanceof InsertUndefinedAction) || (action instanceof MoveDownAction) || @@ -218,7 +218,7 @@ public class StructureEditorUnlockedEnablementTest extends AbstractStructureEdit // Check enablement on last component selected. setSelection(new int[] { model.getNumComponents() - 1 }); - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if ((action instanceof EditFieldAction) || (action instanceof ShowComponentPathAction) || (action instanceof InsertUndefinedAction) || (action instanceof MoveUpAction) || @@ -261,7 +261,7 @@ public class StructureEditorUnlockedEnablementTest extends AbstractStructureEdit // Check enablement on last component selected. setSelection(new int[] { model.getNumComponents() }); - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if ((action instanceof FavoritesAction) || (action instanceof CycleGroupAction) || (action instanceof EditFieldAction) || (action instanceof InsertUndefinedAction) || (action instanceof PointerAction) || (action instanceof HexNumbersAction)) { diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/UnionEditorActions1Test.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/UnionEditorActions1Test.java index b45a14322b..2df9cf8966 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/UnionEditorActions1Test.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/UnionEditorActions1Test.java @@ -54,7 +54,7 @@ public class UnionEditorActions1Test extends AbstractUnionEditorTest { assertEquals(model.getTypeName(), "Union"); // Check enablement. - CompositeEditorAction[] pActions = provider.getActions(); + CompositeEditorTableAction[] pActions = provider.getActions(); for (int i = 0; i < pActions.length; i++) { if ((pActions[i] instanceof FavoritesAction) || (pActions[i] instanceof CycleGroupAction) || @@ -92,7 +92,7 @@ public class UnionEditorActions1Test extends AbstractUnionEditorTest { assertEquals(pgmBbCat.getCategoryPathName(), model.getOriginalCategoryPath().getPath()); // Check enablement on blank line selected. - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if ((action instanceof FavoritesAction) || (action instanceof CycleGroupAction) || (action instanceof EditFieldAction) || (action instanceof PointerAction) || (action instanceof HexNumbersAction)) { @@ -111,7 +111,7 @@ public class UnionEditorActions1Test extends AbstractUnionEditorTest { // Check enablement on first component selected. setSelection(new int[] { 0 }); - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if ((action instanceof FavoritesAction) || (action instanceof CycleGroupAction) || (action instanceof EditFieldAction) || (action instanceof ShowComponentPathAction) || (action instanceof MoveDownAction) || @@ -134,7 +134,7 @@ public class UnionEditorActions1Test extends AbstractUnionEditorTest { // Check enablement on central component selected. setSelection(new int[] { 1 }); - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if ((action instanceof FavoritesAction) || (action instanceof CycleGroupAction) || (action instanceof EditFieldAction) || (action instanceof ShowComponentPathAction) || (action instanceof MoveUpAction) || @@ -157,7 +157,7 @@ public class UnionEditorActions1Test extends AbstractUnionEditorTest { // Check enablement on last component selected. setSelection(new int[] { model.getNumComponents() - 1 }); - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if ((action instanceof FavoritesAction) || (action instanceof CycleGroupAction) || (action instanceof EditFieldAction) || (action instanceof ShowComponentPathAction) || (action instanceof MoveUpAction) || @@ -180,7 +180,7 @@ public class UnionEditorActions1Test extends AbstractUnionEditorTest { // Check enablement on a contiguous multi-component selection. setSelection(new int[] { 2, 3, 4 }); - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if ((action instanceof FavoritesAction) || (action instanceof CycleGroupAction)// enabled to show message || (action instanceof MoveDownAction) || (action instanceof MoveUpAction) || (action instanceof DeleteAction) || (action instanceof PointerAction) || @@ -201,7 +201,7 @@ public class UnionEditorActions1Test extends AbstractUnionEditorTest { // Check enablement on a non-contiguous multi-component selection. setSelection(new int[] { 2, 3, 6, 7 }); - for (CompositeEditorAction action : actions) { + for (CompositeEditorTableAction action : actions) { if ((action instanceof FavoritesAction) || (action instanceof CycleGroupAction) || (action instanceof DeleteAction) || (action instanceof HexNumbersAction)) { checkEnablement(action, true); diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/UnionEditorAlignmentTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/UnionEditorAlignmentTest.java index 4001db9bbc..3e99c43f12 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/UnionEditorAlignmentTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/compositeeditor/UnionEditorAlignmentTest.java @@ -111,7 +111,7 @@ public class UnionEditorAlignmentTest extends AbstractUnionEditorTest { addDataType(arrayDt); // Check enablement. - CompositeEditorAction[] pActions = provider.getActions(); + CompositeEditorTableAction[] pActions = provider.getActions(); for (int i = 0; i < pActions.length; i++) { if ((pActions[i] instanceof FavoritesAction) || (pActions[i] instanceof CycleGroupAction) || diff --git a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/stackeditor/AbstractStackEditorTest.java b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/stackeditor/AbstractStackEditorTest.java index c23b4aa897..a9af233182 100644 --- a/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/stackeditor/AbstractStackEditorTest.java +++ b/Ghidra/Features/Base/src/test.slow/java/ghidra/app/plugin/core/stackeditor/AbstractStackEditorTest.java @@ -279,7 +279,7 @@ public abstract class AbstractStackEditorTest extends AbstractEditorTest { void getActions() { actions = ((StackEditorProvider) provider).getActions(); - for (CompositeEditorAction element : actions) { + for (CompositeEditorTableAction element : actions) { if (element instanceof FavoritesAction) { favorites.add((FavoritesAction) element); } diff --git a/Ghidra/Framework/Docking/src/main/java/docking/KeyBindingOverrideKeyEventDispatcher.java b/Ghidra/Framework/Docking/src/main/java/docking/KeyBindingOverrideKeyEventDispatcher.java index 249e7ed900..59ff49f7f4 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/KeyBindingOverrideKeyEventDispatcher.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/KeyBindingOverrideKeyEventDispatcher.java @@ -256,12 +256,12 @@ class KeyBindingOverrideKeyEventDispatcher implements KeyEventDispatcher { // We've made the executive decision to allow all keys to go through to the text component // unless they are modified with the 'Alt'/'Ctrl'/etc keys, unless they directly used // by the text component - if (!isNonTextModifierOn(event)) { + if (!isModified(event)) { return true; // unmodified keys will be given to the text component } // the key is modified; let it through if the component has a mapping for the key - return hasComponentKeyToActionMapping((JTextComponent) destination, event); + return hasRegisteredKeyBinding((JTextComponent) destination, event); } /** @@ -270,11 +270,11 @@ class KeyBindingOverrideKeyEventDispatcher implements KeyEventDispatcher { * @param e the event * @return true if modified */ - private boolean isNonTextModifierOn(KeyEvent e) { + private boolean isModified(KeyEvent e) { return e.isAltDown() || e.isAltGraphDown() || e.isMetaDown() || e.isControlDown(); } - private boolean hasComponentKeyToActionMapping(JComponent c, KeyEvent event) { + private boolean hasRegisteredKeyBinding(JComponent c, KeyEvent event) { KeyStroke keyStroke = KeyStroke.getKeyStrokeForEvent(event); Action action = getJavaActionForComponent(c, keyStroke); return action != null;