GT-2925 - Key Bindings - Support Window Menu Provider Key Bindings -

Step 5 - cleanup of old key binding support constructor parameter; start
of cleanup of DockingActionProviderIf
This commit is contained in:
dragonmacher 2019-06-27 14:06:47 -04:00
parent ff4b3736b9
commit 115243801e
73 changed files with 574 additions and 682 deletions

View file

@ -176,6 +176,16 @@ public abstract class AbstractDockingTool implements DockingTool {
winMgr.contextChanged(provider);
}
@Override
public void addContextListener(DockingContextListener listener) {
winMgr.addContextListener(listener);
}
@Override
public void removeContextListener(DockingContextListener listener) {
winMgr.removeContextListener(listener);
}
@Override
public DockingWindowManager getWindowManager() {
return winMgr;

View file

@ -165,7 +165,7 @@ public class ActionToGuiMapper {
/**
* Close all menus (includes popup menus)
*/
static void dismissMenus() {
private void dismissMenus() {
MenuSelectionManager.defaultManager().clearSelectedPath();
}

View file

@ -159,7 +159,8 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext
return;
}
showProviderAction = new ShowProviderAction();
boolean supportsKeyBindings = !isTransient;
showProviderAction = new ShowProviderAction(supportsKeyBindings);
}
/**
@ -550,15 +551,14 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext
4) Wire default 'close' action to keybinding
5) Add global action for (show last provider)
--Navigation menu?
6) Revisit all uses of the key binding managed constructor
7) Update table popup actions to be managed
8) Update help locations
Questions:
C) How to wire universal close action (it is focus-dependent)
Fix:
-Update key binding methods to use an enum for: no management / full management / shared management
*/
dockingTool.getWindowManager().setIcon(this, icon);
@ -775,8 +775,9 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext
private class ShowProviderAction extends DockingAction {
ShowProviderAction() {
super(name, owner);
ShowProviderAction(boolean supportsKeyBindings) {
super(name, owner,
supportsKeyBindings ? KeyBindingType.SHARED : KeyBindingType.UNSUPPORTED);
if (isToolbarAction) {
setToolBarData(new ToolBarData(icon, TOOLBAR_GROUP));
@ -796,17 +797,6 @@ public abstract class ComponentProvider implements HelpDescriptor, ActionContext
dockingTool.showComponentProvider(ComponentProvider.this, true);
}
@Override
public boolean isKeyBindingManaged() {
return false;
}
@Override
public boolean usesSharedKeyBinding() {
// we do not allow transient providers to have key bindings
return !isTransient;
}
@Override
protected String getInceptionFromTheFirstClassThatIsNotUs() {
// overridden to show who created the provider, as that is what this action represents

View file

@ -102,7 +102,7 @@ public class DialogComponentProviderPopupActionManager {
Object source = actionContext.getSourceObject();
if (source instanceof DockingActionProviderIf) {
DockingActionProviderIf actionProvider = (DockingActionProviderIf) source;
List<DockingActionIf> dockingActions = actionProvider.getDockingActions(actionContext);
List<DockingActionIf> dockingActions = actionProvider.getDockingActions();
for (DockingActionIf action : dockingActions) {
MenuData popupMenuData = action.getPopupMenuData();
if (popupMenuData != null && action.isValidContext(actionContext) &&

View file

@ -200,8 +200,8 @@ public class DockingActionProxy
}
@Override
public boolean isKeyBindingManaged() {
return dockingAction.isKeyBindingManaged();
public KeyBindingType getKeyBindingType() {
return dockingAction.getKeyBindingType();
}
@Override

View file

@ -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,6 +15,18 @@
*/
package docking;
import docking.action.DockingActionIf;
/**
* A listener to be notified when the tool's context changes. Normally context is used to
* manage {@link DockingActionIf} enablement directly by the system. This class allows
* clients to listen to context change as well.
*/
public interface DockingContextListener {
void contextChanged(ActionContext context);
/**
* Called when the context changes
* @param context the context
*/
public void contextChanged(ActionContext context);
}

View file

@ -209,6 +209,18 @@ public interface DockingTool {
*/
public void contextChanged(ComponentProvider provider);
/**
* Adds the given context listener to this tool
* @param listener the listener to add
*/
public void addContextListener(DockingContextListener listener);
/**
* Removes the given context listener to this tool
* @param listener the listener to add
*/
public void removeContextListener(DockingContextListener listener);
/**
* Returns the DockingWindowManger for this tool.
* @return the DockingWindowManger for this tool.

View file

@ -2089,8 +2089,7 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
contextListeners.remove(listener);
}
public void notifyContextListeners(ComponentPlaceholder placeHolder,
ActionContext actionContext) {
void notifyContextListeners(ComponentPlaceholder placeHolder, ActionContext actionContext) {
if (placeHolder == focusedPlaceholder) {
for (DockingContextListener listener : contextListeners) {

View file

@ -425,7 +425,9 @@ class KeyBindingOverrideKeyEventDispatcher implements KeyEventDispatcher {
}
KeyStroke keyStroke = KeyStroke.getKeyStrokeForEvent(event);
return (DockingKeyBindingAction) activeManager.getActionForKeyStroke(keyStroke);
DockingKeyBindingAction bindingAction =
(DockingKeyBindingAction) activeManager.getActionForKeyStroke(keyStroke);
return bindingAction;
}
private DockingWindowManager getActiveDockingWindowManager() {

View file

@ -101,7 +101,7 @@ public class PopupActionManager implements PropertyChangeListener {
Object source = actionContext.getSourceObject();
if (source instanceof DockingActionProviderIf) {
DockingActionProviderIf actionProvider = (DockingActionProviderIf) source;
List<DockingActionIf> dockingActions = actionProvider.getDockingActions(actionContext);
List<DockingActionIf> dockingActions = actionProvider.getDockingActions();
for (DockingActionIf action : dockingActions) {
MenuData popupMenuData = action.getPopupMenuData();
if (popupMenuData != null && action.isValidContext(actionContext) &&

View file

@ -50,24 +50,26 @@ class ShowComponentAction extends DockingAction implements Comparable<ShowCompon
super(truncateTitleAsNeeded(name), DockingWindowManager.DOCKING_WINDOWS_OWNER);
}
ShowComponentAction(DockingWindowManager winMgr, ComponentPlaceholder info, String subMenuName,
boolean isTransient) {
super(info.getProvider().getName(), DockingWindowManager.DOCKING_WINDOWS_OWNER);
ShowComponentAction(DockingWindowManager winMgr, ComponentPlaceholder placeholder,
String subMenuName, boolean isTransient) {
super(placeholder.getProvider().getName(), DockingWindowManager.DOCKING_WINDOWS_OWNER,
createKeyBindingType(isTransient, placeholder));
this.info = info;
this.info = placeholder;
this.winMgr = winMgr;
this.title = truncateTitleAsNeeded(info.getTitle());
this.title = truncateTitleAsNeeded(placeholder.getTitle());
this.isTransient = isTransient;
String group = isTransient ? "Transient" : "Permanent";
Icon icon = info.getIcon();
Icon icon = placeholder.getIcon();
if (icon == null) {
icon = EMPTY_ICON;
}
if (subMenuName != null) {
setMenuBarData(new MenuData(
new String[] { MENU_WINDOW, subMenuName, info.getFullTitle() }, icon, "Permanent"));
setMenuBarData(
new MenuData(new String[] { MENU_WINDOW, subMenuName, placeholder.getFullTitle() },
icon, "Permanent"));
winMgr.doSetMenuGroup(new String[] { MENU_WINDOW, subMenuName }, group);
}
else {
@ -75,7 +77,7 @@ class ShowComponentAction extends DockingAction implements Comparable<ShowCompon
}
// keybinding data used to show the binding in the menu
ComponentProvider provider = info.getProvider();
ComponentProvider provider = placeholder.getProvider();
DockingActionIf action = provider.getShowProviderAction();
KeyBindingData kbData = action.getKeyBindingData();
if (kbData != null) {
@ -94,19 +96,15 @@ class ShowComponentAction extends DockingAction implements Comparable<ShowCompon
}
}
@Override
public boolean isKeyBindingManaged() {
return false;
}
private static KeyBindingType createKeyBindingType(boolean isTransient,
ComponentPlaceholder placeholder) {
@Override
public boolean usesSharedKeyBinding() {
if (isTransient) {
return false; // temporary window
return KeyBindingType.UNSUPPORTED; // temporary window
}
// 'info' is null when this action is used to 'show all' instances of a given provider
return info != null;
return placeholder == null ? KeyBindingType.UNSUPPORTED : KeyBindingType.SHARED;
}
@Override

View file

@ -96,9 +96,6 @@ public class WindowActionManager {
toolBarMgr.dispose();
}
/**
* Notifies the window manager that an action context update is needed.
*/
synchronized void contextChanged(ComponentPlaceholder placeHolder) {
placeHolderForScheduledActionUpdate = placeHolder;

View file

@ -17,6 +17,7 @@ package docking.action;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.Objects;
import java.util.Set;
import javax.swing.*;
@ -63,8 +64,8 @@ public abstract class DockingAction implements DockingActionIf {
private String inceptionInformation;
private boolean isEnabled = true;
private boolean isKeyBindingManaged = true;
private KeyBindingType keyBindingType = KeyBindingType.INDIVIDUAL;
private KeyBindingData defaultKeyBindingData;
private KeyBindingData keyBindingData;
private MenuBarData menuBarData;
@ -72,19 +73,29 @@ public abstract class DockingAction implements DockingActionIf {
private ToolBarData toolBarData;
public DockingAction(String name, String owner) {
this(name, owner, true);
}
public DockingAction(String name, String owner, boolean isKeyBindingManaged) {
this.name = name;
this.owner = owner;
this.isKeyBindingManaged = isKeyBindingManaged;
recordInception();
HelpLocation location = new HelpLocation(owner, name, inceptionInformation);
setHelpLocation(location);
}
public DockingAction(String name, String owner, KeyBindingType kbType) {
this(name, owner);
this.keyBindingType = Objects.requireNonNull(kbType);
}
public DockingAction(String name, String owner, boolean supportsKeyBindings) {
this(name, owner);
this.keyBindingType =
supportsKeyBindings ? KeyBindingType.INDIVIDUAL : KeyBindingType.UNSUPPORTED;
}
protected KeyBindingType getPreferredKeyBindingType() {
return KeyBindingType.INDIVIDUAL;
}
@Override
public abstract void actionPerformed(ActionContext context);
@ -98,11 +109,6 @@ public abstract class DockingAction implements DockingActionIf {
propertyListeners.remove(listener);
}
@Override
public boolean isKeyBindingManaged() {
return isKeyBindingManaged;
}
@Override
public String getDescription() {
return description;
@ -258,6 +264,11 @@ public abstract class DockingAction implements DockingActionIf {
return menuItem;
}
@Override
public KeyBindingType getKeyBindingType() {
return keyBindingType;
}
@Override
public KeyStroke getKeyBinding() {
return keyBindingData == null ? null : keyBindingData.getKeyBinding();

View file

@ -23,6 +23,17 @@ import javax.swing.*;
import docking.ActionContext;
import docking.help.HelpDescriptor;
/**
* The base interface for clients that wish to create commands to be registered with a tool.
*
* <p>An action may appear in a primary menu, a popup menu or a toolbar. Further, an action
* may have a key binding assigned.
*
* <p>The particular support for key bindings is defined by {@link KeyBindingType}. Almost all
* client actions will use the default setting of {@link KeyBindingType#INDIVIDUAL}. To control
* the level of key binding support, you can pass the desired {@link KeyBindingType} to the
* base implementation of this interface.
*/
public interface DockingActionIf extends HelpDescriptor {
public static final String ENABLEMENT_PROPERTY = "enabled";
public static final String GLOBALCONTEXT_PROPERTY = "globalContext";
@ -248,10 +259,17 @@ public interface DockingActionIf extends HelpDescriptor {
public boolean shouldAddToWindow(boolean isMainWindow, Set<Class<?>> contextTypes);
/**
* Returns true if this action can have its keybinding information changed by the user.
* @return true if this action can have its keybinding information changed by the user.
* Returns this actions level of support for key binding accelerator keys
*
* <p>Actions support key bindings by default. Some reserved actions do not support
* key bindings, while others wish to share the same key bindings with multiple, equivalent
* actions (this allows the user to set one binding that works in many different contexts).
*
* @return the key binding support
*/
public boolean isKeyBindingManaged();
public default KeyBindingType getKeyBindingType() {
return KeyBindingType.INDIVIDUAL;
}
/**
* Sets the {@link KeyBindingData} on an action to either assign a keybinding or remove it
@ -272,22 +290,4 @@ public interface DockingActionIf extends HelpDescriptor {
* @param newKeyBindingData the KeyBindingData to be used to assign this action to a keybinding
*/
public void setUnvalidatedKeyBindingData(KeyBindingData newKeyBindingData);
/**
* Returns true if this action shares a keybinding with other actions. If this returns true,
* then this action, and any action that shares a name with this action, will be updated
* to the same key binding value whenever the key binding options change.
*
* <p>This will be false for the vast majority of actions. If you are unsure if your action
* should use a shared keybinding, then do not set this value to true.
*
* <p>This value is not meant to change over the life of the action. Thus, there is no
* <code>set</code> method to change this value. Rather, you should override this method
* to return <code>true</code> as desired.
*
* @return true to share a shared keybinding
*/
public default boolean usesSharedKeyBinding() {
return false;
}
}

View file

@ -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.
@ -18,8 +17,6 @@ package docking.action;
import java.util.List;
import docking.ActionContext;
/**
* An interface for objects (really Components) to implement that signals they provide actions
* for the Docking environment. This interface will be called when the implementor is the source
@ -32,9 +29,9 @@ import docking.ActionContext;
*/
public interface DockingActionProviderIf {
/**
* Returns actions that are compatible with the given context.
* @param context the current context of the Docking system
*/
public List<DockingActionIf> getDockingActions( ActionContext context );
/**
* Returns actions that are compatible with the given context.
* @return the actions
*/
public List<DockingActionIf> getDockingActions();
}

View file

@ -0,0 +1,82 @@
/* ###
* IP: GHIDRA
*
* 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 docking.action;
/**
* Allows clients to signal their support for the assigning of key binding shortcut keys. Most
* action clients need not be concerned with this class. The default settings of
* {@link DockingAction} work correctly for almost all cases, which is to have the action
* support individual key bindings, which are managed by the system via the UI.
*
* @see DockingActionIf
*/
public enum KeyBindingType {
//@formatter:off
/**
* Indicates the setting of key bindings through the UI is not supported
*/
UNSUPPORTED,
/**
* Supports the assignment of key bindings via the UI. Setting a key binding on an action
* with this type will not affect any other action.
*/
INDIVIDUAL,
/**
* When the key binding is set via the UI, this action, and any action that shares a
* name with this action, will be updated to the same key binding value whenever the key
* binding options change.
*
* <p>Most actions will not be shared. If you are unsure if your action
* should use a shared keybinding, then do not do so.
*/
SHARED;
//@formatter:on
/**
* Returns true if this type supports key bindings. This is a convenience method for
* checking that this type is not {@link #UNSUPPORTED}.
* @return true if key bindings are supported
*/
public boolean supportsKeyBindings() {
return this != UNSUPPORTED;
}
/**
* Convenience method for checking if this type is the {@link #SHARED} type
* @return true if shared
*/
public boolean isShared() {
return this == SHARED;
}
/**
* A convenience method for clients to check whether this key binding type should be
* managed directly by the system.
*
* <p>Shared actions are not managed directly by the system, but are instead managed through
* a proxy action.
*
* @return true if managed directly by the system; false if key binding are not supported
* or are managed through a proxy
*/
public boolean isManaged() {
return this == INDIVIDUAL;
}
}

View file

@ -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.
@ -29,14 +28,16 @@ public abstract class ToggleDockingAction extends DockingAction implements Toggl
super(name, owner);
}
public ToggleDockingAction(String name, String owner, boolean isKeybindingManaged) {
super(name, owner, isKeybindingManaged);
public ToggleDockingAction(String name, String owner, boolean supportsKeyBindings) {
super(name, owner, supportsKeyBindings);
}
@Override
public boolean isSelected() {
return isSelected;
}
@Override
public void setSelected(boolean newValue) {
isSelected = newValue;
firePropertyChanged(SELECTED_STATE_PROPERTY, !isSelected, isSelected);

View file

@ -49,7 +49,7 @@ public class KeyBindingAction extends DockingAction {
action = maybeGetToolLevelAction(action);
if (!action.isKeyBindingManaged()) {
if (!action.getKeyBindingType().supportsKeyBindings()) {
Component parent = windowManager.getActiveComponent();
Msg.showInfo(getClass(), parent, "Unable to Set Keybinding",
"Action \"" + getActionName(action) + "\" is not keybinding managed and thus a " +
@ -68,15 +68,15 @@ public class KeyBindingAction extends DockingAction {
* @return A tool-level action if one is found; otherwise, the original action
*/
private DockingActionIf maybeGetToolLevelAction(DockingActionIf dockingAction) {
if (dockingAction.isKeyBindingManaged()) {
return dockingAction;
}
// It is not key binding managed, which means that it may be a shared key binding
String actionName = dockingAction.getName();
DockingActionIf sharedAction = toolActions.getSharedStubKeyBindingAction(actionName);
if (sharedAction != null) {
return sharedAction;
if (dockingAction.getKeyBindingType().isShared()) {
// It is not key binding managed, which means that it may be a shared key binding
String actionName = dockingAction.getName();
DockingActionIf sharedAction = toolActions.getSharedStubKeyBindingAction(actionName);
if (sharedAction != null) {
return sharedAction;
}
}
return dockingAction;

View file

@ -345,7 +345,7 @@ public class KeyBindingUtils {
/**
* A utility method to get all key binding actions. This method will remove duplicate
* actions and will only return actions that are {@link DockingActionIf#isKeyBindingManaged()}
* actions and will only return actions that support {@link KeyBindingType key bindings}.
*
* @param tool the tool containing the actions
* @return the actions mapped by their full name (e.g., 'Name (OwnerName)')
@ -371,7 +371,7 @@ public class KeyBindingUtils {
/**
* A utility method to get all key binding actions that have the given owner.
* This method will remove duplicate actions and will only return actions
* that are {@link DockingActionIf#isKeyBindingManaged()}
* that support {@link KeyBindingType key bindings}.
*
* @param tool the tool containing the actions
* @param owner the action owner name
@ -718,9 +718,9 @@ public class KeyBindingUtils {
//==================================================================================================
private static boolean isIgnored(DockingActionIf action) {
// not keybinding managed; a shared keybinding implies that this action should not be in
// a shared keybinding implies that this action should not be in
// the UI, as there will be a single proxy in place of all actions sharing that binding
return !action.isKeyBindingManaged() || action.usesSharedKeyBinding();
return action.getKeyBindingType().isShared();
}
private static KeyStroke getKeyStroke(KeyBindingData data) {

View file

@ -22,7 +22,8 @@ import java.util.List;
import javax.swing.*;
import javax.swing.text.*;
import docking.*;
import docking.DialogComponentProvider;
import docking.KeyEntryTextField;
import docking.action.*;
import docking.widgets.label.GIconLabel;
import ghidra.util.HelpLocation;
@ -157,21 +158,7 @@ public class KeyEntryDialog extends DialogComponentProvider {
return;
}
KeyBindingData kbData = new KeyBindingData(newKeyStroke);
if (action instanceof SharedStubKeyBindingAction) {
action.setUnvalidatedKeyBindingData(kbData);
}
else {
Set<DockingActionIf> allActions = toolActions.getAllActions();
Set<DockingActionIf> actions =
KeyBindingUtils.getActions(allActions, action.getOwner(), action.getName());
for (DockingActionIf element : actions) {
if (element.isKeyBindingManaged()) {
element.setUnvalidatedKeyBindingData(kbData);
}
}
}
action.setUnvalidatedKeyBindingData(new KeyBindingData(newKeyStroke));
toolActions.keyBindingsChanged();
@ -248,11 +235,6 @@ public class KeyEntryDialog extends DialogComponentProvider {
}
private boolean shouldAddAction(DockingActionIf dockableAction) {
if (dockableAction.isKeyBindingManaged()) {
return true;
}
// shared key bindings are handled specially
return !dockableAction.usesSharedKeyBinding();
return dockableAction.getKeyBindingType().isManaged();
}
}

View file

@ -22,8 +22,12 @@ import java.util.*;
import javax.swing.Action;
import javax.swing.KeyStroke;
import org.apache.commons.collections4.IteratorUtils;
import org.apache.commons.collections4.Predicate;
import org.apache.commons.collections4.map.LazyMap;
import com.google.common.collect.Iterators;
import docking.*;
import docking.action.*;
import docking.tool.util.DockingToolConstants;
@ -113,12 +117,13 @@ public class ToolActions implements PropertyChangeListener {
private void setKeyBindingOption(DockingActionIf action) {
if (action.usesSharedKeyBinding()) {
installSharedKeyBinding(action);
KeyBindingType type = action.getKeyBindingType();
if (!type.supportsKeyBindings()) {
return;
}
if (!action.isKeyBindingManaged()) {
if (type.isShared()) {
installSharedKeyBinding(action);
return;
}
@ -227,25 +232,47 @@ public class ToolActions implements PropertyChangeListener {
return result;
}
private Iterator<DockingActionIf> getAllActionsIterator() {
// chain all items together, rather than copy the data
Iterator<DockingActionIf> iterator = IteratorUtils.emptyIterator();
Collection<Map<String, Set<DockingActionIf>>> maps = actionsByNameByOwner.values();
for (Map<String, Set<DockingActionIf>> actionsByName : maps) {
for (Set<DockingActionIf> actions : actionsByName.values()) {
Iterator<DockingActionIf> next = actions.iterator();
// Note: do not use apache commons here--the code below degrades exponentially
//iterator = IteratorUtils.chainedIterator(iterator, next);
iterator = Iterators.concat(iterator, next);
}
}
return Iterators.concat(iterator, sharedActionMap.values().iterator());
}
/**
* Get the keybindings for each action so that they are still registered as being used;
* otherwise the options will be removed because they are noted as not being used.
*/
public synchronized void restoreKeyBindings() {
keyBindingOptions = dockingTool.getOptions(DockingToolConstants.KEY_BINDINGS);
Set<DockingActionIf> actions = getAllActions();
for (DockingActionIf action : actions) {
if (!action.isKeyBindingManaged()) {
continue;
}
Iterator<DockingActionIf> it = getKeyBindingActionsIterator();
for (DockingActionIf action : CollectionUtils.asIterable(it)) {
KeyStroke ks = action.getKeyBinding();
KeyStroke newKs = keyBindingOptions.getKeyStroke(action.getFullName(), ks);
if (ks != newKs) {
if (!Objects.equals(ks, newKs)) {
action.setUnvalidatedKeyBindingData(new KeyBindingData(newKs));
}
}
}
// return only actions that allow key bindings
private Iterator<DockingActionIf> getKeyBindingActionsIterator() {
Predicate<DockingActionIf> filter = a -> a.getKeyBindingType() == KeyBindingType.INDIVIDUAL;
return IteratorUtils.filteredIterator(getAllActionsIterator(), filter);
}
/**
* Remove an action that works specifically with a component provider.
* @param provider provider associated with the action
@ -272,11 +299,13 @@ public class ToolActions implements PropertyChangeListener {
private void removeAction(DockingActionIf action) {
getActionStorage(action).remove(action);
if (action.usesSharedKeyBinding()) {
SharedStubKeyBindingAction stub = sharedActionMap.get(action.getName());
if (stub != null) {
stub.removeClientAction(action);
}
if (!action.getKeyBindingType().isShared()) {
return;
}
SharedStubKeyBindingAction stub = sharedActionMap.get(action.getName());
if (stub != null) {
stub.removeClientAction(action);
}
}
@ -293,7 +322,7 @@ public class ToolActions implements PropertyChangeListener {
}
DockingAction action = (DockingAction) evt.getSource();
if (!action.isKeyBindingManaged()) {
if (!action.getKeyBindingType().isManaged()) {
// this reads unusually, but we need to notify the tool to rebuild its 'Window' menu
// in the case that this action is one of the tool's special actions
keyBindingsChanged();

View file

@ -15,9 +15,9 @@
*/
package docking.widgets.table;
import static docking.DockingUtils.*;
import static docking.action.MenuData.*;
import static java.awt.event.InputEvent.*;
import static docking.DockingUtils.CONTROL_KEY_MODIFIER_MASK;
import static docking.action.MenuData.NO_MNEMONIC;
import static java.awt.event.InputEvent.SHIFT_DOWN_MASK;
import java.awt.*;
import java.awt.event.*;
@ -509,23 +509,14 @@ public class GTable extends JTable implements KeyStrokeConsumer, DockingActionPr
return autoLookupKeyStrokeConsumer.isKeyConsumed(keyStroke);
}
/**
* {@inheritDoc}
*/
@Override
public List<DockingActionIf> getDockingActions(ActionContext context) {
Object sourceObject = context.getSourceObject();
if (sourceObject != this) {
// we are only interested in providing actions when we are the source of the event
return Collections.emptyList();
}
public List<DockingActionIf> getDockingActions() {
return getDefaultDockingActions();
}
/**
* Returns the default actions of this table. Normally, the Docking Windows systems uses
* {@link #getDockingActions(ActionContext)} to get the correct actions to show. However,
* {@link #getDockingActions()} to get the correct actions to show. However,
* there are some cases where clients override what appears when you click on a table (such
* as in {@link DialogComponentProvider}s. For those clients that are creating their own
* action building, they need a way to get the default actions, hence this method.
@ -1178,7 +1169,8 @@ public class GTable extends JTable implements KeyStrokeConsumer, DockingActionPr
int subGroupIndex = 1; // order by insertion
String owner = getClass().getSimpleName();
copyAction = new DockingAction("Table Data Copy", owner, false) {
owner = "GTable";
copyAction = new DockingAction("Table Data Copy", owner, KeyBindingType.SHARED) {
@Override
public void actionPerformed(ActionContext context) {
copying = true;
@ -1209,7 +1201,7 @@ public class GTable extends JTable implements KeyStrokeConsumer, DockingActionPr
//@formatter:on
copyCurrentColumnAction =
new DockingAction("Table Data Copy Current Column", owner, false) {
new DockingAction("Table Data Copy Current Column", owner, KeyBindingType.SHARED) {
@Override
public void actionPerformed(ActionContext context) {
@ -1246,17 +1238,18 @@ public class GTable extends JTable implements KeyStrokeConsumer, DockingActionPr
copyCurrentColumnAction.setHelpLocation(new HelpLocation("Tables", "Copy_Current_Column"));
//@formatter:on
copyColumnsAction = new DockingAction("Table Data Copy by Columns", owner, false) {
@Override
public void actionPerformed(ActionContext context) {
int[] userColumns = promptUserForColumns();
if (userColumns == null) {
return; // cancelled
}
copyColumnsAction =
new DockingAction("Table Data Copy by Columns", owner, KeyBindingType.SHARED) {
@Override
public void actionPerformed(ActionContext context) {
int[] userColumns = promptUserForColumns();
if (userColumns == null) {
return; // cancelled
}
copyColumns(userColumns);
}
};
copyColumns(userColumns);
}
};
//@formatter:off
copyColumnsAction.setPopupMenuData(new MenuData(
new String[] { "Copy", "Copy Columns..." },
@ -1269,7 +1262,7 @@ public class GTable extends JTable implements KeyStrokeConsumer, DockingActionPr
copyColumnsAction.setHelpLocation(new HelpLocation("Tables", "Copy_Columns"));
//@formatter:on
exportAction = new DockingAction("Table Data CSV Export", owner, false) {
exportAction = new DockingAction("Table Data CSV Export", owner, KeyBindingType.SHARED) {
@Override
public void actionPerformed(ActionContext context) {
File file = chooseExportFile();
@ -1291,7 +1284,7 @@ public class GTable extends JTable implements KeyStrokeConsumer, DockingActionPr
//@formatter:on
exportColumnsAction =
new DockingAction("Table Data CSV Export (by Columns)", owner, false) {
new DockingAction("Table Data CSV Export (by Columns)", owner, KeyBindingType.SHARED) {
@Override
public void actionPerformed(ActionContext context) {
int[] userColumns = promptUserForColumns();
@ -1323,7 +1316,7 @@ public class GTable extends JTable implements KeyStrokeConsumer, DockingActionPr
exportColumnsAction.setHelpLocation(new HelpLocation("Tables", "ExportCSV_Columns"));
//@formatter:on
selectAllAction = new DockingAction("Table Select All", owner, false) {
selectAllAction = new DockingAction("Table Select All", owner, KeyBindingType.SHARED) {
@Override
public void actionPerformed(ActionContext context) {
selectAll();