GT-2894 - Key Bindings - review fixes

This commit is contained in:
dragonmacher
2019-06-03 17:44:44 -04:00
parent 28c5218f18
commit 9737653be6
20 changed files with 213 additions and 243 deletions
@@ -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 <code>Action</code> 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();
}
}
@@ -32,9 +32,9 @@ import docking.action.KeyBindingData;
*/
public class CompositeEditorActionManager {
private CompositeEditorProvider provider;
private ArrayList<CompositeEditorAction> editorActions = new ArrayList<CompositeEditorAction>();
private ArrayList<CompositeEditorAction> favoritesActions =
new ArrayList<CompositeEditorAction>();
private ArrayList<CompositeEditorTableAction> editorActions = new ArrayList<CompositeEditorTableAction>();
private ArrayList<CompositeEditorTableAction> favoritesActions =
new ArrayList<CompositeEditorTableAction>();
private ArrayList<CycleGroupAction> cycleGroupActions = new ArrayList<CycleGroupAction>();
private ArrayList<EditorActionListener> listeners = new ArrayList<EditorActionListener>();
@@ -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<? extends CompositeEditorAction> actions) {
private void notifyActionsAdded(ArrayList<? extends CompositeEditorTableAction> 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<? extends CompositeEditorAction> actions) {
private void notifyActionsRemoved(ArrayList<? extends CompositeEditorTableAction> 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)) {
@@ -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");
@@ -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() {
@@ -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 <code>Action</code> 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);
}
}
@@ -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);
}
@@ -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);
@@ -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),
@@ -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),
@@ -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();
}
@@ -79,7 +79,7 @@ public abstract class AbstractEditorTest extends AbstractGhidraHeadedIntegration
protected int txId;
protected StatusListener listener;
protected CompositeEditorAction[] actions;
protected CompositeEditorTableAction[] actions;
protected ArrayList<FavoritesAction> favorites = new ArrayList<>();
protected ArrayList<CycleGroupAction> 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();
@@ -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);
}
@@ -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);
}
@@ -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) ||
@@ -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();
@@ -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)) {
@@ -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);
@@ -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) ||
@@ -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);
}
@@ -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;