Minor event mask refactor

This commit is contained in:
dragonmacher
2025-10-22 13:00:12 -04:00
parent c0978e538c
commit 04ef00b4a3
60 changed files with 283 additions and 225 deletions

View File

@@ -17,7 +17,8 @@ package ghidra.examples;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.*;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import javax.swing.*;
@@ -66,7 +67,8 @@ public class HelloWorldComponentProvider extends ComponentProviderAdapter {
Icon icon = new GIcon("icon.sample.action.hello.world");
action.setMenuBarData(new MenuData(new String[] { "Misc", "Hello World" }, icon));
action.setKeyBindingData(
new KeyBindingData(KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK)));
new KeyBindingData(
KeyStroke.getKeyStroke(KeyEvent.VK_W, DockingUtils.CONTROL_KEY_MODIFIER_MASK)));
// puts the action on the local toolbar.
action.setToolBarData(new ToolBarData(icon));

View File

@@ -4,9 +4,9 @@
* 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.
@@ -23,6 +23,7 @@ import java.awt.event.KeyEvent;
import javax.swing.*;
import docking.DialogComponentProvider;
import docking.DockingUtils;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import docking.widgets.fieldpanel.FieldPanel;
@@ -45,7 +46,7 @@ public class ViewInstructionDetailsAction extends ListingContextAction {
this.listingMergePanelPlugin = listingMergePanelPlugin;
setPopupMenuData(new MenuData(new String[] { "View Instruction Details..." }, null,
"ViewInstructionDetails"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK |
setKeyBindingData(new KeyBindingData(KeyEvent.VK_R, DockingUtils.CONTROL_KEY_MODIFIER_MASK |
InputEvent.SHIFT_DOWN_MASK));
setEnabled(true);
setDescription("Display a dialog indicating details, such as references, for the " +

View File

@@ -15,10 +15,10 @@
*/
package ghidra.app.plugin.core.bookmark;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import docking.ActionContext;
import docking.DockingUtils;
import docking.action.*;
import ghidra.app.context.ListingActionContext;
import ghidra.program.model.address.Address;
@@ -44,7 +44,8 @@ class AddBookmarkAction extends DockingAction {
setDescription("Add Notes bookmark to current location");
// ACTIONS - auto generated
setPopupMenuData(new MenuData(new String[] { "Bookmark..." }, null, "Bookmark"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK));
setKeyBindingData(
new KeyBindingData(KeyEvent.VK_D, DockingUtils.CONTROL_KEY_MODIFIER_MASK));
}

View File

@@ -17,7 +17,6 @@ package ghidra.app.plugin.core.clipboard;
import java.awt.Window;
import java.awt.datatransfer.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.util.*;
@@ -402,7 +401,8 @@ public class ClipboardPlugin extends ProgramPlugin
setPopupMenuData(new MenuData(new String[] { "Copy" }, "Clipboard"));
setToolBarData(new ToolBarData(new GIcon("icon.plugin.clipboard.copy"),
"Clipboard"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK));
setKeyBindingData(
new KeyBindingData(KeyEvent.VK_C, DockingUtils.CONTROL_KEY_MODIFIER_MASK));
setHelpLocation(new HelpLocation("ClipboardPlugin", "Copy"));
clipboardService.customizeClipboardAction(this);
}
@@ -436,7 +436,8 @@ public class ClipboardPlugin extends ProgramPlugin
setPopupMenuData(new MenuData(new String[] { "Paste" }, "Clipboard"));
setToolBarData(
new ToolBarData(new GIcon("icon.plugin.clipboard.paste"), "Clipboard"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_V, InputEvent.CTRL_DOWN_MASK));
setKeyBindingData(
new KeyBindingData(KeyEvent.VK_V, DockingUtils.CONTROL_KEY_MODIFIER_MASK));
setHelpLocation(new HelpLocation("ClipboardPlugin", "Paste"));
clipboardService.customizeClipboardAction(this);
}

View File

@@ -4,9 +4,9 @@
* 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.
@@ -21,6 +21,7 @@ import java.awt.event.KeyEvent;
import javax.swing.Icon;
import docking.ActionContext;
import docking.DockingUtils;
import docking.action.*;
import generic.theme.GIcon;
import ghidra.app.context.ProgramActionContext;
@@ -40,7 +41,7 @@ public class CloneCodeViewerAction extends DockingAction {
setDescription("Create a snapshot (disconnected) copy of this Listing window ");
setHelpLocation(new HelpLocation("Snapshots", "Snapshots_Start"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_T,
InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.SHIFT_DOWN_MASK));
}
@Override

View File

@@ -4,9 +4,9 @@
* 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.
@@ -15,11 +15,11 @@
*/
package ghidra.app.plugin.core.codebrowser.actions;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import docking.DockingUtils;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import docking.tool.ToolConstants;
@@ -47,7 +47,8 @@ public class GotoNextFunctionAction extends NavigatableContextAction {
null, "GoTo");
menuData.setMenuSubGroup("za");
setMenuBarData(menuData);
KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, InputEvent.CTRL_DOWN_MASK);
KeyStroke keyStroke =
KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, DockingUtils.CONTROL_KEY_MODIFIER_MASK);
setKeyBindingData(new KeyBindingData(keyStroke));
setHelpLocation(new HelpLocation(HelpTopics.NAVIGATION, "Next_Previous_Function"));
addToWindowWhen(NavigatableActionContext.class);

View File

@@ -4,9 +4,9 @@
* 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.
@@ -15,11 +15,11 @@
*/
package ghidra.app.plugin.core.codebrowser.actions;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import docking.DockingUtils;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import docking.tool.ToolConstants;
@@ -47,7 +47,8 @@ public class GotoPreviousFunctionAction extends NavigatableContextAction {
null, "GoTo");
menuData.setMenuSubGroup("zb");
setMenuBarData(menuData);
KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_DOWN_MASK);
KeyStroke keyStroke =
KeyStroke.getKeyStroke(KeyEvent.VK_UP, DockingUtils.CONTROL_KEY_MODIFIER_MASK);
setKeyBindingData(new KeyBindingData(keyStroke));
setHelpLocation(new HelpLocation(HelpTopics.NAVIGATION, "Next_Previous_Function"));
addToWindowWhen(NavigatableActionContext.class);

View File

@@ -480,7 +480,8 @@ public class CommentsDialog extends ReusableDialogComponentProvider implements K
return;
}
if ((modifiers & InputEvent.CTRL_DOWN_MASK) == InputEvent.CTRL_DOWN_MASK) {
if ((modifiers &
DockingUtils.CONTROL_KEY_MODIFIER_MASK) == DockingUtils.CONTROL_KEY_MODIFIER_MASK) {
okCallback(); // Control-Enter allows closes the dialog
e.consume();
return;

View File

@@ -15,13 +15,9 @@
*/
package ghidra.app.plugin.core.datamgr.actions;
import static docking.KeyBindingPrecedence.ActionMapLevel;
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
import ghidra.app.plugin.core.datamgr.tree.*;
import static docking.KeyBindingPrecedence.*;
import java.awt.datatransfer.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.List;
@@ -30,11 +26,15 @@ import javax.swing.KeyStroke;
import javax.swing.tree.TreePath;
import docking.ActionContext;
import docking.DockingUtils;
import docking.action.*;
import docking.widgets.tree.GTree;
import docking.widgets.tree.GTreeNode;
import docking.widgets.tree.support.GTreeNodeTransferable;
import docking.widgets.tree.support.GTreeTransferHandler;
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
import ghidra.app.plugin.core.datamgr.DataTypesActionContext;
import ghidra.app.plugin.core.datamgr.tree.*;
public class CopyAction extends DockingAction {
private Clipboard clipboard;
@@ -46,7 +46,7 @@ public class CopyAction extends DockingAction {
setPopupMenuData(new MenuData(new String[] { "Copy" }, group));
setKeyBindingData(new KeyBindingData(KeyStroke.getKeyStroke(KeyEvent.VK_C,
InputEvent.CTRL_DOWN_MASK), ActionMapLevel));
DockingUtils.CONTROL_KEY_MODIFIER_MASK), ActionMapLevel));
setEnabled(true);
}
@@ -109,7 +109,8 @@ public class CopyAction extends DockingAction {
* @param clipboard clipboard in which to place our contents
* @param list list of nodes to place into the clipboard
*/
private void setClipboardContents(GTree gTree, Clipboard clipboard, final List<GTreeNode> list) {
private void setClipboardContents(GTree gTree, Clipboard clipboard,
final List<GTreeNode> list) {
GTreeTransferHandler dragNDropHandler = gTree.getDragNDropHandler();
Transferable contents = new GTreeNodeTransferable(dragNDropHandler, list);

View File

@@ -4,9 +4,9 @@
* 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.
@@ -16,7 +16,6 @@
package ghidra.app.plugin.core.datamgr.actions;
import java.awt.datatransfer.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.List;
@@ -24,8 +23,7 @@ import java.util.List;
import javax.swing.KeyStroke;
import javax.swing.tree.TreePath;
import docking.ActionContext;
import docking.KeyBindingPrecedence;
import docking.*;
import docking.action.*;
import docking.widgets.tree.GTree;
import docking.widgets.tree.GTreeNode;
@@ -44,7 +42,7 @@ public class CutAction extends DockingAction {
clipboard = plugin.getClipboard();
setPopupMenuData(new MenuData(new String[] { "Cut" }, "Edit"));
setKeyBindingData(new KeyBindingData(KeyStroke.getKeyStroke(KeyEvent.VK_X,
InputEvent.CTRL_DOWN_MASK), KeyBindingPrecedence.ActionMapLevel));
DockingUtils.CONTROL_KEY_MODIFIER_MASK), KeyBindingPrecedence.ActionMapLevel));
setEnabled(true);
clipboardOwner = new ClipboardOwner() {

View File

@@ -4,9 +4,9 @@
* 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.
@@ -17,15 +17,13 @@ package ghidra.app.plugin.core.datamgr.actions;
import java.awt.datatransfer.*;
import java.awt.dnd.DnDConstants;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.*;
import javax.swing.KeyStroke;
import javax.swing.tree.TreePath;
import docking.ActionContext;
import docking.KeyBindingPrecedence;
import docking.*;
import docking.action.*;
import docking.widgets.tree.GTree;
import docking.widgets.tree.GTreeNode;
@@ -48,7 +46,8 @@ public class PasteAction extends DockingAction {
this.tool = plugin.getTool();
setPopupMenuData(new MenuData(new String[] { "Paste" }, "Edit"));
setKeyBindingData(
new KeyBindingData(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_DOWN_MASK),
new KeyBindingData(
KeyStroke.getKeyStroke(KeyEvent.VK_V, DockingUtils.CONTROL_KEY_MODIFIER_MASK),
KeyBindingPrecedence.ActionMapLevel));
}

View File

@@ -15,9 +15,9 @@
*/
package ghidra.app.plugin.core.highlight;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import docking.DockingUtils;
import docking.action.*;
import docking.tool.ToolConstants;
import ghidra.app.CorePluginPackage;
@@ -101,7 +101,7 @@ public class SetHighlightPlugin extends Plugin {
setHighlightFromSelectionAction.setPopupMenuData(new MenuData(SET_HIGHLIGHT_POPUPPATH,
HIGHLIGHT_GROUP));
setHighlightFromSelectionAction.setKeyBindingData(new KeyBindingData(KeyEvent.VK_H,
InputEvent.CTRL_DOWN_MASK));
DockingUtils.CONTROL_KEY_MODIFIER_MASK));
setHighlightFromSelectionAction
.addToWindowWhen(NavigatableActionContext.class);
tool.addAction(setHighlightFromSelectionAction);

View File

@@ -4,9 +4,9 @@
* 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.
@@ -16,16 +16,17 @@
package ghidra.app.plugin.core.interpreter;
import java.awt.AWTKeyStroke;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
import docking.DockingUtils;
public enum CompletionWindowTrigger {
//@formatter:off
TAB(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0, false)),
CONTROL_SPACE(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, InputEvent.CTRL_DOWN_MASK, false));
CONTROL_SPACE(KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, DockingUtils.CONTROL_KEY_MODIFIER_MASK, false));
//@formatter:on
private KeyStroke keyStroke;

View File

@@ -25,6 +25,7 @@ import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
import docking.ActionContext;
import docking.DockingUtils;
import docking.action.*;
import docking.action.builder.ActionBuilder;
import docking.action.builder.ToggleActionBuilder;
@@ -565,7 +566,7 @@ class MemoryMapProvider extends ComponentProviderAdapter {
setStatusText("");
if (!e.isPopupTrigger()) {
if ((e.getModifiersEx() &
(InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)) == 0) {
(DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.SHIFT_DOWN_MASK)) == 0) {
navigateToAddress();
}
}

View File

@@ -4,9 +4,9 @@
* 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.
@@ -22,6 +22,7 @@ import javax.swing.Icon;
import javax.swing.KeyStroke;
import docking.ActionContext;
import docking.DockingUtils;
import docking.action.*;
import docking.menu.ActionState;
import docking.menu.MultiStateDockingAction;
@@ -376,7 +377,7 @@ public class NextPreviousBookmarkAction extends MultiStateDockingAction<String>
private KeyStroke getKeyStroke() {
return KeyStroke.getKeyStroke(KeyEvent.VK_B,
InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK);
DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.ALT_DOWN_MASK);
}
//==================================================================================================

View File

@@ -4,9 +4,9 @@
* 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.
@@ -21,6 +21,7 @@ import java.awt.event.KeyEvent;
import javax.swing.Icon;
import javax.swing.KeyStroke;
import docking.DockingUtils;
import generic.theme.GIcon;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.Address;
@@ -48,7 +49,7 @@ public class NextPreviousDefinedDataAction extends AbstractNextPreviousAction {
@Override
protected KeyStroke getKeyStroke() {
return KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK |
return KeyStroke.getKeyStroke(KeyEvent.VK_D, DockingUtils.CONTROL_KEY_MODIFIER_MASK |
InputEvent.ALT_DOWN_MASK);
}

View File

@@ -21,6 +21,7 @@ import java.awt.event.KeyEvent;
import javax.swing.Icon;
import javax.swing.KeyStroke;
import docking.DockingUtils;
import generic.theme.GIcon;
import ghidra.app.nav.Navigatable;
import ghidra.app.services.GoToService;
@@ -48,7 +49,7 @@ public class NextPreviousFunctionAction extends AbstractNextPreviousAction {
@Override
protected KeyStroke getKeyStroke() {
return KeyStroke.getKeyStroke(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK |
return KeyStroke.getKeyStroke(KeyEvent.VK_F, DockingUtils.CONTROL_KEY_MODIFIER_MASK |
InputEvent.ALT_DOWN_MASK);
}

View File

@@ -22,6 +22,7 @@ import javax.help.UnsupportedOperationException;
import javax.swing.Icon;
import javax.swing.KeyStroke;
import docking.DockingUtils;
import generic.theme.GIcon;
import ghidra.app.context.NavigatableActionContext;
import ghidra.framework.plugintool.PluginTool;
@@ -47,7 +48,7 @@ public class NextPreviousInstructionAction extends AbstractNextPreviousAction {
@Override
protected KeyStroke getKeyStroke() {
return KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_DOWN_MASK |
return KeyStroke.getKeyStroke(KeyEvent.VK_I, DockingUtils.CONTROL_KEY_MODIFIER_MASK |
InputEvent.ALT_DOWN_MASK);
}

View File

@@ -4,9 +4,9 @@
* 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.
@@ -21,6 +21,7 @@ import java.awt.event.KeyEvent;
import javax.swing.Icon;
import javax.swing.KeyStroke;
import docking.DockingUtils;
import generic.theme.GIcon;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.Address;
@@ -45,7 +46,7 @@ public class NextPreviousLabelAction extends AbstractNextPreviousAction {
@Override
protected KeyStroke getKeyStroke() {
return KeyStroke.getKeyStroke(KeyEvent.VK_L, InputEvent.CTRL_DOWN_MASK |
return KeyStroke.getKeyStroke(KeyEvent.VK_L, DockingUtils.CONTROL_KEY_MODIFIER_MASK |
InputEvent.ALT_DOWN_MASK);
}

View File

@@ -4,9 +4,9 @@
* 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.
@@ -22,6 +22,7 @@ import java.util.Iterator;
import javax.swing.Icon;
import javax.swing.KeyStroke;
import docking.DockingUtils;
import generic.theme.GIcon;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.Address;
@@ -55,7 +56,7 @@ public class NextPreviousSameBytesAction extends AbstractNextPreviousAction {
@Override
protected KeyStroke getKeyStroke() {
return KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_DOWN_MASK |
return KeyStroke.getKeyStroke(KeyEvent.VK_V, DockingUtils.CONTROL_KEY_MODIFIER_MASK |
InputEvent.ALT_DOWN_MASK);
}

View File

@@ -4,9 +4,9 @@
* 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.
@@ -21,6 +21,7 @@ import java.awt.event.KeyEvent;
import javax.swing.Icon;
import javax.swing.KeyStroke;
import docking.DockingUtils;
import generic.theme.GIcon;
import ghidra.framework.plugintool.PluginTool;
import ghidra.program.model.address.Address;
@@ -43,7 +44,7 @@ public class NextPreviousUndefinedAction extends AbstractNextPreviousAction {
@Override
protected KeyStroke getKeyStroke() {
return KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.CTRL_DOWN_MASK |
return KeyStroke.getKeyStroke(KeyEvent.VK_U, DockingUtils.CONTROL_KEY_MODIFIER_MASK |
InputEvent.ALT_DOWN_MASK);
}

View File

@@ -15,7 +15,6 @@
*/
package ghidra.app.plugin.core.progmgr;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import javax.swing.*;
@@ -127,7 +126,8 @@ public class MultiTabPlugin extends Plugin implements DomainObjectListener, Opti
new MenuData(new String[] { ToolConstants.MENU_NAVIGATION, "Go To Program..." }, null,
ToolConstants.MENU_NAVIGATION_GROUP_WINDOWS, MenuData.NO_MNEMONIC, firstGroup));
goToProgramAction
.setKeyBindingData(new KeyBindingData(KeyEvent.VK_F7, InputEvent.CTRL_DOWN_MASK));
.setKeyBindingData(
new KeyBindingData(KeyEvent.VK_F7, DockingUtils.CONTROL_KEY_MODIFIER_MASK));
goToProgramAction.setEnabled(false);
goToProgramAction.setDescription(
@@ -177,7 +177,8 @@ public class MultiTabPlugin extends Plugin implements DomainObjectListener, Opti
new String[] { ToolConstants.MENU_NAVIGATION, "Go To Last Active Program" }, null,
ToolConstants.MENU_NAVIGATION_GROUP_WINDOWS, MenuData.NO_MNEMONIC, secondGroup));
goToLastActiveProgramAction
.setKeyBindingData(new KeyBindingData(KeyEvent.VK_F6, InputEvent.CTRL_DOWN_MASK));
.setKeyBindingData(
new KeyBindingData(KeyEvent.VK_F6, DockingUtils.CONTROL_KEY_MODIFIER_MASK));
goToLastActiveProgramAction.setEnabled(false);
goToLastActiveProgramAction
.setDescription("Activates the last program used before the current program");

View File

@@ -25,6 +25,7 @@ import javax.swing.JComponent;
import org.jdom.Element;
import docking.ComponentProvider;
import docking.DockingUtils;
import docking.action.*;
import docking.widgets.OptionDialog;
import ghidra.app.CorePluginPackage;
@@ -180,7 +181,7 @@ public class ReferencesPlugin extends Plugin {
new String[] { SUBMENU_NAME, CreateDefaultReferenceAction.DEFAULT_MENU_ITEM_NAME },
null, SHOW_REFS_GROUP));
createAction.setKeyBindingData(new KeyBindingData(KeyEvent.VK_R,
InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK));
DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.ALT_DOWN_MASK));
createAction.setDescription("Create default forward reference");
tool.addAction(createAction);
@@ -733,8 +734,10 @@ public class ReferencesPlugin extends Plugin {
path, addr, label, editRef.getReferenceType());
if (tool.execute(cmd, p)) {
if (!p.getReferenceManager().getReferencesTo(
oldExtLoc.getExternalSpaceAddress()).hasNext() &&
if (!p.getReferenceManager()
.getReferencesTo(
oldExtLoc.getExternalSpaceAddress())
.hasNext() &&
OptionDialog.YES_OPTION == OptionDialog.showYesNoDialog(tool.getActiveWindow(),
"Delete Unused External Location?",
"Remove unused external location symbol '" + oldExtLoc.toString() + "'?")) {
@@ -804,8 +807,10 @@ public class ReferencesPlugin extends Plugin {
Reference oldRef) {
if (oldRef == null) {
Reference[] refs = fromCodeUnit.getProgram().getReferenceManager().getReferencesFrom(
fromCodeUnit.getMinAddress(), opIndex);
Reference[] refs = fromCodeUnit.getProgram()
.getReferenceManager()
.getReferencesFrom(
fromCodeUnit.getMinAddress(), opIndex);
if (refs.length != 0) {
oldRef = refs[0];
}

View File

@@ -15,12 +15,14 @@
*/
package ghidra.app.plugin.core.register;
import java.awt.event.*;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
import docking.ActionContext;
import docking.DockingUtils;
import docking.action.*;
import ghidra.app.CorePluginPackage;
import ghidra.app.cmd.register.SetRegisterCmd;
@@ -110,7 +112,7 @@ public class RegisterPlugin extends ProgramPlugin {
setRegisterAction.setPopupMenuData(
new MenuData(new String[] { "Set Register Values..." }, null, "Registers"));
setRegisterAction.setKeyBindingData(
new KeyBindingData(KeyEvent.VK_R, InputEvent.CTRL_DOWN_MASK));
new KeyBindingData(KeyEvent.VK_R, DockingUtils.CONTROL_KEY_MODIFIER_MASK));
setRegisterAction.setDescription("Set register values in a program.");
setRegisterAction.setHelpLocation(new HelpLocation("RegisterPlugin", "SetRegisterValues"));
@@ -159,8 +161,10 @@ public class RegisterPlugin extends ProgramPlugin {
Address addr = loc.getAddress();
Register reg = loc.getRegister();
RegisterValue regVal =
context.getProgram().getProgramContext().getNonDefaultValue(reg,
addr);
context.getProgram()
.getProgramContext()
.getNonDefaultValue(reg,
addr);
return regVal != null && regVal.hasValue();
}
}
@@ -191,8 +195,10 @@ public class RegisterPlugin extends ProgramPlugin {
Address addr = loc.getAddress();
Register reg = loc.getRegister();
RegisterValue regVal =
context.getProgram().getProgramContext().getNonDefaultValue(reg,
addr);
context.getProgram()
.getProgramContext()
.getNonDefaultValue(reg,
addr);
return regVal != null && regVal.hasValue();
}
}

View File

@@ -4,9 +4,9 @@
* 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.
@@ -18,7 +18,6 @@ package ghidra.app.plugin.core.symboltree.actions;
import static docking.KeyBindingPrecedence.*;
import java.awt.datatransfer.*;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.List;
@@ -27,6 +26,7 @@ import javax.swing.Icon;
import javax.swing.KeyStroke;
import javax.swing.tree.TreePath;
import docking.DockingUtils;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import docking.widgets.tree.GTree;
@@ -47,7 +47,8 @@ public class CutAction extends SymbolTreeContextAction {
this.provider = provider;
setEnabled(false);
setPopupMenuData(new MenuData(new String[] { "Cut" }, CUT_ICON, "cut/paste"));
KeyStroke keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_DOWN_MASK);
KeyStroke keyStroke =
KeyStroke.getKeyStroke(KeyEvent.VK_X, DockingUtils.CONTROL_KEY_MODIFIER_MASK);
setKeyBindingData(new KeyBindingData(keyStroke, ActionMapLevel));
clipboardOwner = (currentClipboard, transferable) -> {

View File

@@ -4,9 +4,9 @@
* 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.
@@ -18,13 +18,13 @@ package ghidra.app.plugin.core.symboltree.actions;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DnDConstants;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import javax.swing.Icon;
import javax.swing.KeyStroke;
import javax.swing.tree.TreePath;
import docking.DockingUtils;
import docking.KeyBindingPrecedence;
import docking.action.KeyBindingData;
import docking.action.MenuData;
@@ -42,7 +42,8 @@ public class PasteAction extends SymbolTreeContextAction {
super("Paste Symbols", plugin.getName());
setPopupMenuData(new MenuData(new String[] { "Paste" }, PASTE_ICON, "cut/paste"));
setKeyBindingData(
new KeyBindingData(KeyStroke.getKeyStroke(KeyEvent.VK_V, InputEvent.CTRL_DOWN_MASK),
new KeyBindingData(
KeyStroke.getKeyStroke(KeyEvent.VK_V, DockingUtils.CONTROL_KEY_MODIFIER_MASK),
KeyBindingPrecedence.ActionMapLevel));
}

View File

@@ -4,9 +4,9 @@
* 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.
@@ -28,8 +28,7 @@ import javax.swing.event.ChangeListener;
import org.apache.commons.lang3.ArrayUtils;
import docking.ActionContext;
import docking.ComponentProvider;
import docking.*;
import docking.action.DockingAction;
import docking.action.KeyBindingData;
import docking.dnd.StringTransferable;
@@ -182,11 +181,11 @@ public class TerminalClipboardProvider implements ClipboardContentProviderServic
switch (action.getName()) {
case "Copy":
action.setKeyBindingData(new KeyBindingData(KeyEvent.VK_C,
InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.SHIFT_DOWN_MASK));
break;
case "Paste":
action.setKeyBindingData(new KeyBindingData(KeyEvent.VK_V,
InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.SHIFT_DOWN_MASK));
break;
}
}

View File

@@ -235,7 +235,7 @@ public class TerminalProvider extends ComponentProviderAdapter {
.menuPath("Find")
.menuGroup("Find")
.keyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_F,
InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK))
DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.SHIFT_DOWN_MASK))
.helpLocation(new HelpLocation(helpPlugin.getName(), "find"))
.onAction(this::activatedFind)
.buildAndInstallLocal(this);
@@ -243,7 +243,7 @@ public class TerminalProvider extends ComponentProviderAdapter {
.menuPath("Find Next")
.menuGroup("Find")
.keyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_H,
InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK))
DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.SHIFT_DOWN_MASK))
.helpLocation(new HelpLocation(helpPlugin.getName(), "find_next"))
.enabledWhen(this::isEnabledFindStep)
.onAction(this::activatedFindNext)
@@ -252,7 +252,7 @@ public class TerminalProvider extends ComponentProviderAdapter {
.menuPath("Find Previous")
.menuGroup("Find")
.keyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_G,
InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK))
DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.SHIFT_DOWN_MASK))
.helpLocation(new HelpLocation(helpPlugin.getName(), "find_previous"))
.enabledWhen(this::isEnabledFindStep)
.onAction(this::activatedFindPrevious)
@@ -261,7 +261,7 @@ public class TerminalProvider extends ComponentProviderAdapter {
.menuPath("Select All")
.menuGroup("Select")
.keyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_A,
InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK))
DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.SHIFT_DOWN_MASK))
.helpLocation(new HelpLocation(helpPlugin.getName(), "select_all"))
.onAction(this::activatedSelectAll)
.buildAndInstallLocal(this);
@@ -269,21 +269,23 @@ public class TerminalProvider extends ComponentProviderAdapter {
.menuPath("Increase Font Size")
.menuGroup("View")
.keyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS,
InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK))
DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.SHIFT_DOWN_MASK))
.helpLocation(new HelpLocation(helpPlugin.getName(), "increase_font_size"))
.onAction(this::activatedIncreaseFontSize)
.buildAndInstallLocal(this);
actionDecreaseSize = new ActionBuilder("Decrease Font Size", plugin.getName())
.menuPath("Decrease Font Size")
.menuGroup("View")
.keyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, InputEvent.CTRL_DOWN_MASK))
.keyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS,
DockingUtils.CONTROL_KEY_MODIFIER_MASK))
.helpLocation(new HelpLocation(helpPlugin.getName(), "decrease_font_size"))
.onAction(this::activatedDecreaseFontSize)
.buildAndInstallLocal(this);
actionResetSize = new ActionBuilder("Reset Font Size", plugin.getName())
.menuPath("Reset Font Size")
.menuGroup("View")
.keyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_0, InputEvent.CTRL_DOWN_MASK))
.keyBinding(
KeyStroke.getKeyStroke(KeyEvent.VK_0, DockingUtils.CONTROL_KEY_MODIFIER_MASK))
.helpLocation(new HelpLocation(helpPlugin.getName(), "decrease_font_size"))
.onAction(this::activatedResetFontSize)
.buildAndInstallLocal(this);

View File

@@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.List;
import docking.ActionContext;
import docking.DockingUtils;
import docking.action.*;
import docking.tool.ToolConstants;
import docking.widgets.filechooser.GhidraFileChooser;
@@ -400,7 +401,7 @@ public class ImporterPlugin extends Plugin
importSelectionAction.setPopupMenuData(new MenuData(new String[] { title + "..." }, null,
IMPORT_MENU_GROUP, MenuData.NO_MNEMONIC, "d"));
importSelectionAction.setKeyBindingData(new KeyBindingData(KeyEvent.VK_I,
InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK));
DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.ALT_DOWN_MASK));
importSelectionAction.setDescription(IMPORTER_PLUGIN_DESC);
importSelectionAction.setEnabled(tool.getProject() != null);

View File

@@ -16,7 +16,6 @@
package ghidra.plugins.fsbrowser;
import java.awt.Component;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.IOException;
@@ -24,6 +23,7 @@ import java.util.*;
import javax.swing.KeyStroke;
import docking.DockingUtils;
import docking.action.DockingAction;
import docking.action.builder.ActionBuilder;
import docking.tool.ToolConstants;
@@ -101,7 +101,8 @@ public class FileSystemBrowserPlugin extends Plugin
.enabledWhen(ac -> tool.getProject() != null)
.menuPath(ToolConstants.MENU_FILE, "Open File System...")
.menuGroup("Import", "z")
.keyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_I, InputEvent.CTRL_DOWN_MASK))
.keyBinding(
KeyStroke.getKeyStroke(KeyEvent.VK_I, DockingUtils.CONTROL_KEY_MODIFIER_MASK))
.onAction(ac -> doOpenFileSystem())
.buildAndInstall(tool);
}

View File

@@ -28,6 +28,7 @@ import javax.swing.table.*;
import org.junit.*;
import docking.DockingUtils;
import docking.DockingWindowManager;
import docking.action.*;
import docking.actions.KeyBindingUtils;
@@ -152,8 +153,9 @@ public class KeyBindingsTest extends AbstractGhidraHeadedIntegrationTest {
// set a key binding on an action that does not have a key binding
selectRowForAction(action1);
JTextField keyField = getKeyField();
triggerActionKey(keyField, InputEvent.CTRL_DOWN_MASK, KeyEvent.VK_X);
KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_DOWN_MASK);
triggerActionKey(keyField, DockingUtils.CONTROL_KEY_MODIFIER_MASK, KeyEvent.VK_X);
KeyStroke ks =
KeyStroke.getKeyStroke(KeyEvent.VK_X, DockingUtils.CONTROL_KEY_MODIFIER_MASK);
assertKeyFieldText(KeyBindingUtils.parseKeyStroke(ks));
apply();
@@ -176,8 +178,9 @@ public class KeyBindingsTest extends AbstractGhidraHeadedIntegrationTest {
public void testSetKeyBinding3() throws Exception {
selectRowForAction(action1);
typeKeyStroke(InputEvent.CTRL_DOWN_MASK, KeyEvent.VK_HOME);
KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_HOME, InputEvent.CTRL_DOWN_MASK);
typeKeyStroke(DockingUtils.CONTROL_KEY_MODIFIER_MASK, KeyEvent.VK_HOME);
KeyStroke ks =
KeyStroke.getKeyStroke(KeyEvent.VK_HOME, DockingUtils.CONTROL_KEY_MODIFIER_MASK);
assertKeyFieldText(ks);
apply();
@@ -281,7 +284,8 @@ public class KeyBindingsTest extends AbstractGhidraHeadedIntegrationTest {
setUpDialog();
selectRowForAction(action1);
KeyStroke validKeyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_X, InputEvent.CTRL_DOWN_MASK);
KeyStroke validKeyStroke =
KeyStroke.getKeyStroke(KeyEvent.VK_X, DockingUtils.CONTROL_KEY_MODIFIER_MASK);
typeKeyStroke(validKeyStroke);
assertKeyFieldText(validKeyStroke);

View File

@@ -35,8 +35,7 @@ import javax.swing.tree.TreePath;
import org.apache.commons.lang3.StringUtils;
import org.junit.*;
import docking.DialogComponentProvider;
import docking.KeyEntryPanel;
import docking.*;
import docking.action.DockingActionIf;
import docking.actions.KeyBindingUtils;
import docking.options.editor.*;
@@ -468,7 +467,7 @@ public class OptionsDialogTest extends AbstractGhidraHeadedIntegrationTest {
MouseBinding newMouseBinding = setMouseBinding(actionName, actionOwner, modifiers, button);
int keyCode = KeyEvent.VK_Q;
modifiers = InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK;
modifiers = DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.ALT_DOWN_MASK;
KeyStroke newKeyStroke = setKeyBinding(actionName, actionOwner, modifiers, keyCode, 'Q');
apply();
@@ -498,7 +497,7 @@ public class OptionsDialogTest extends AbstractGhidraHeadedIntegrationTest {
assertNull(defaultMouseBinding);
int keyCode = KeyEvent.VK_Q;
int modifiers = InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK;
int modifiers = DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.ALT_DOWN_MASK;
KeyStroke newKeyStroke = setKeyBinding(actionName, actionOwner, modifiers, keyCode, 'Q');
int button = 4;
@@ -560,7 +559,7 @@ public class OptionsDialogTest extends AbstractGhidraHeadedIntegrationTest {
assertOptionsKeyStroke(tool, actionName, actionOwner, defaultKeyStroke);
int keyCode = KeyEvent.VK_Q;
int modifiers = InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK;
int modifiers = DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.ALT_DOWN_MASK;
KeyStroke newKeyStroke = setKeyBinding(actionName, actionOwner, modifiers, keyCode, 'Q');
apply();
@@ -587,7 +586,7 @@ public class OptionsDialogTest extends AbstractGhidraHeadedIntegrationTest {
assertOptionsKeyStroke(frontEndTool, actionName, actionOwner, defaultKeyStroke);
int keyCode = KeyEvent.VK_Q;
int modifiers = InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK;
int modifiers = DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.ALT_DOWN_MASK;
KeyStroke newKeyStroke = setKeyBinding(actionName, actionOwner, modifiers, keyCode, 'Q');
apply();

View File

@@ -4,9 +4,9 @@
* 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.
@@ -19,7 +19,6 @@ import static org.junit.Assert.*;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyEditorSupport;
@@ -31,6 +30,7 @@ import javax.swing.KeyStroke;
import org.junit.*;
import docking.DockingUtils;
import docking.test.AbstractDockingTest;
import generic.theme.GThemeDefaults.Colors.Palette;
import generic.theme.ThemeManager;
@@ -239,7 +239,7 @@ public class OptionsDBTest extends AbstractDockingTest {
@Test
public void testSaveActionTrigger_MouseBinding() {
MouseBinding mb = new MouseBinding(1, InputEvent.CTRL_DOWN_MASK);
MouseBinding mb = new MouseBinding(1, DockingUtils.CONTROL_KEY_MODIFIER_MASK);
ActionTrigger trigger = new ActionTrigger(mb);
options.setActionTrigger("Foo", trigger);
saveAndRestoreOptions();
@@ -249,7 +249,7 @@ public class OptionsDBTest extends AbstractDockingTest {
@Test
public void testSaveActionTrigger_KeyStrokeAndMouseBinding() {
KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_A, 0);
MouseBinding mb = new MouseBinding(1, InputEvent.CTRL_DOWN_MASK);
MouseBinding mb = new MouseBinding(1, DockingUtils.CONTROL_KEY_MODIFIER_MASK);
ActionTrigger trigger = new ActionTrigger(ks, mb);
options.setActionTrigger("Foo", trigger);
saveAndRestoreOptions();

View File

@@ -19,7 +19,6 @@ import static org.junit.Assert.*;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyEditorSupport;
@@ -34,6 +33,7 @@ import javax.swing.KeyStroke;
import org.jdom.Element;
import org.junit.*;
import docking.DockingUtils;
import generic.test.AbstractGuiTest;
import generic.theme.GThemeDefaults.Colors.Palette;
import ghidra.util.*;
@@ -182,7 +182,7 @@ public class OptionsTest extends AbstractGuiTest {
@Test
public void testSaveActionTrigger_MouseBinding() {
MouseBinding mb = new MouseBinding(1, InputEvent.CTRL_DOWN_MASK);
MouseBinding mb = new MouseBinding(1, DockingUtils.CONTROL_KEY_MODIFIER_MASK);
ActionTrigger trigger = new ActionTrigger(mb);
options.setActionTrigger("Foo", trigger);
saveAndRestoreOptions();
@@ -192,7 +192,7 @@ public class OptionsTest extends AbstractGuiTest {
@Test
public void testSaveActionTrigger_KeyStrokeAndMouseBinding() {
KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_A, 0);
MouseBinding mb = new MouseBinding(1, InputEvent.CTRL_DOWN_MASK);
MouseBinding mb = new MouseBinding(1, DockingUtils.CONTROL_KEY_MODIFIER_MASK);
ActionTrigger trigger = new ActionTrigger(ks, mb);
options.setActionTrigger("Foo", trigger);
saveAndRestoreOptions();

View File

@@ -26,6 +26,7 @@ import java.util.Set;
import javax.swing.*;
import docking.ActionContext;
import docking.DockingUtils;
import docking.action.*;
import docking.widgets.fieldpanel.support.ViewerPosition;
import generic.theme.GIcon;
@@ -773,7 +774,7 @@ public class ProgramByteViewerComponentProvider extends ByteViewerComponentProvi
setDescription("Create a snapshot (disconnected) copy of this Bytes window ");
setHelpLocation(new HelpLocation("Snapshots", "Snapshots_Start"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_T,
InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.SHIFT_DOWN_MASK));
}
@Override

View File

@@ -4,9 +4,9 @@
* 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.
@@ -19,6 +19,7 @@ import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import docking.ActionContext;
import docking.DockingUtils;
import docking.action.*;
import generic.theme.GIcon;
import ghidra.framework.plugintool.Plugin;
@@ -31,7 +32,7 @@ class ToggleEditAction extends ToggleDockingAction {
this.provider = provider;
setToolBarData(new ToolBarData(new GIcon("icon.base.edit.bytes"), "Byteviewer"));
setKeyBindingData(new KeyBindingData(
KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK));
KeyEvent.VK_E, DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.ALT_DOWN_MASK));
setDescription("Enable/Disable editing of bytes in Byte Viewer panels.");
setSelected(false);

View File

@@ -4,9 +4,9 @@
* 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.
@@ -20,6 +20,7 @@ import java.awt.event.KeyEvent;
import javax.swing.Icon;
import docking.DockingUtils;
import docking.action.KeyBindingData;
import docking.action.ToolBarData;
import generic.theme.GIcon;
@@ -36,7 +37,7 @@ public class CloneDecompilerAction extends AbstractDecompilerAction {
setDescription("Create a snapshot (disconnected) copy of this Decompiler window ");
setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ToolBarSnapshot"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_T,
InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.SHIFT_DOWN_MASK));
}
@Override

View File

@@ -15,11 +15,11 @@
*/
package ghidra.app.plugin.core.decompile.actions;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import org.apache.commons.lang3.StringUtils;
import docking.DockingUtils;
import docking.action.*;
import docking.widgets.FindDialog;
import ghidra.app.decompiler.component.DecompilerFindDialog;
@@ -35,7 +35,8 @@ public class FindAction extends AbstractDecompilerAction {
super("Find");
setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionFind"));
setPopupMenuData(new MenuData(new String[] { "Find..." }, "Decompile"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_F, InputEvent.CTRL_DOWN_MASK));
setKeyBindingData(
new KeyBindingData(KeyEvent.VK_F, DockingUtils.CONTROL_KEY_MODIFIER_MASK));
setEnabled(true);
}

View File

@@ -4,9 +4,9 @@
* 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.
@@ -15,9 +15,9 @@
*/
package ghidra.app.plugin.core.decompile.actions;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import docking.DockingUtils;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import ghidra.app.decompiler.ClangFieldToken;
@@ -43,7 +43,8 @@ public class RetypeFieldAction extends AbstractDecompilerAction {
super("Retype Field");
setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionRetypeField"));
setPopupMenuData(new MenuData(new String[] { "Retype Field" }, "Decompile"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_L, InputEvent.CTRL_DOWN_MASK));
setKeyBindingData(
new KeyBindingData(KeyEvent.VK_L, DockingUtils.CONTROL_KEY_MODIFIER_MASK));
}
@Override

View File

@@ -4,9 +4,9 @@
* 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.
@@ -15,9 +15,9 @@
*/
package ghidra.app.plugin.core.decompile.actions;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import docking.DockingUtils;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import ghidra.app.decompiler.*;
@@ -48,7 +48,8 @@ public class RetypeGlobalAction extends AbstractDecompilerAction {
super("Retype Global");
setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionRetypeGlobal"));
setPopupMenuData(new MenuData(new String[] { "Retype Global" }, "Decompile"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_L, InputEvent.CTRL_DOWN_MASK));
setKeyBindingData(
new KeyBindingData(KeyEvent.VK_L, DockingUtils.CONTROL_KEY_MODIFIER_MASK));
}
@Override

View File

@@ -4,9 +4,9 @@
* 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.
@@ -15,9 +15,9 @@
*/
package ghidra.app.plugin.core.decompile.actions;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import docking.DockingUtils;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import ghidra.app.decompiler.*;
@@ -57,7 +57,8 @@ public class RetypeLocalAction extends AbstractDecompilerAction {
super("Retype Variable");
setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionRetypeVariable"));
setPopupMenuData(new MenuData(new String[] { "Retype Variable" }, "Decompile"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_L, InputEvent.CTRL_DOWN_MASK));
setKeyBindingData(
new KeyBindingData(KeyEvent.VK_L, DockingUtils.CONTROL_KEY_MODIFIER_MASK));
}
protected RetypeLocalAction(String name) {

View File

@@ -4,9 +4,9 @@
* 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.
@@ -15,9 +15,9 @@
*/
package ghidra.app.plugin.core.decompile.actions;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import docking.DockingUtils;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import docking.widgets.OptionDialog;
@@ -51,7 +51,8 @@ public class RetypeReturnAction extends AbstractDecompilerAction {
super("Retype Return");
setHelpLocation(new HelpLocation(HelpTopics.DECOMPILER, "ActionRetypeReturn"));
setPopupMenuData(new MenuData(new String[] { "Retype Return" }, "Decompile"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_L, InputEvent.CTRL_DOWN_MASK));
setKeyBindingData(
new KeyBindingData(KeyEvent.VK_L, DockingUtils.CONTROL_KEY_MODIFIER_MASK));
}
@Override

View File

@@ -4,9 +4,9 @@
* 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.
@@ -15,10 +15,10 @@
*/
package ghidra.app.plugin.core.decompile.actions;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import docking.ActionContext;
import docking.DockingUtils;
import docking.action.DockingAction;
import docking.action.KeyBindingData;
import docking.widgets.EventTrigger;
@@ -35,7 +35,8 @@ public class SelectAllAction extends DockingAction {
public SelectAllAction(String owner, DecompilerPanel panel) {
super("Select All", owner);
this.panel = panel;
setKeyBindingData(new KeyBindingData(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK));
setKeyBindingData(
new KeyBindingData(KeyEvent.VK_A, DockingUtils.CONTROL_KEY_MODIFIER_MASK));
setHelpLocation(new HelpLocation(HelpTopics.SELECTION, getName()));
}

View File

@@ -15,9 +15,9 @@
*/
package ghidra.app.plugin.core.decompiler.taint.actions;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import docking.DockingUtils;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import ghidra.app.plugin.core.decompile.DecompilerActionContext;
@@ -37,7 +37,8 @@ public class TaintClearAction extends TaintAbstractDecompilerAction {
super("Clear Markers");
setHelpLocation(new HelpLocation(TaintPlugin.HELP_LOCATION, "TaintClear"));
setPopupMenuData(new MenuData(new String[] { "Taint", "Clear" }, "Decompile"));
setKeyBindingData(new KeyBindingData(KeyEvent.VK_S, InputEvent.CTRL_DOWN_MASK));
setKeyBindingData(
new KeyBindingData(KeyEvent.VK_S, DockingUtils.CONTROL_KEY_MODIFIER_MASK));
this.plugin = plugin;
}

View File

@@ -15,9 +15,9 @@
*/
package ghidra.app.plugin.core.decompiler.taint.actions;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import docking.DockingUtils;
import docking.action.KeyBindingData;
import ghidra.app.plugin.core.decompiler.taint.TaintPlugin;
import ghidra.app.plugin.core.decompiler.taint.TaintState.QueryType;
@@ -27,7 +27,8 @@ public class TaintQueryCustomAction extends TaintAbstractQueryAction {
public TaintQueryCustomAction(TaintPlugin plugin) {
super(plugin, "CustomQuery", "Custom Taint Query", "Run custom taint query");
queryType = QueryType.CUSTOM;
setKeyBindingData(new KeyBindingData(KeyEvent.VK_Y, InputEvent.CTRL_DOWN_MASK));
setKeyBindingData(
new KeyBindingData(KeyEvent.VK_Y, DockingUtils.CONTROL_KEY_MODIFIER_MASK));
}
}

View File

@@ -15,7 +15,6 @@
*/
package ghidra.app.plugin.core.functiongraph;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.util.*;
@@ -784,7 +783,7 @@ public class FGActionManager {
}
};
selectAllAction
.setKeyBindingData(new KeyBindingData(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK));
.setKeyBindingData(new KeyBindingData(KeyEvent.VK_A, DockingUtils.CONTROL_KEY_MODIFIER_MASK));
selectAllAction.setPopupMenuData(new MenuData(
new String[] { selectionMenuName, "Select All Code Units" }, popupSelectionGroup3));
selectAllAction

View File

@@ -170,7 +170,7 @@ public class FGProvider extends VisualGraphComponentProvider<FGVertex, FGEdge, F
cloneAction.setHelpLocation(
new HelpLocation("FunctionGraphPlugin", "Function_Graph_Action_Snapshot"));
cloneAction.setKeyBindingData(new KeyBindingData(KeyEvent.VK_T,
InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK));
DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.SHIFT_DOWN_MASK));
DockingAction optionsAction =
new DockingAction("Function Graph Options", owner) {

View File

@@ -4,9 +4,9 @@
* 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.
@@ -21,6 +21,7 @@ import java.awt.event.KeyEvent;
import javax.swing.Icon;
import docking.ActionContext;
import docking.DockingUtils;
import docking.action.*;
import docking.tool.ToolConstants;
import docking.widgets.OptionDialog;
@@ -300,7 +301,8 @@ class DiffActionManager {
};
icon = Icons.DOWN_ICON;
nextDiffAction.setKeyBindingData(
new KeyBindingData('N', InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK));
new KeyBindingData('N',
DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.ALT_DOWN_MASK));
nextDiffAction.setPopupMenuData(
new MenuData(new String[] { "Next Difference" }, icon, DIFF_NAVIGATE_GROUP));
nextDiffAction.setToolBarData(new ToolBarData(icon, DIFF_NAVIGATE_GROUP));
@@ -314,7 +316,8 @@ class DiffActionManager {
};
icon = Icons.UP_ICON;
previousDiffAction.setKeyBindingData(
new KeyBindingData('P', InputEvent.CTRL_DOWN_MASK | InputEvent.ALT_DOWN_MASK));
new KeyBindingData('P',
DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.ALT_DOWN_MASK));
previousDiffAction.setPopupMenuData(
new MenuData(new String[] { "Previous Difference" }, icon, DIFF_NAVIGATE_GROUP));
previousDiffAction.setToolBarData(new ToolBarData(icon, DIFF_NAVIGATE_GROUP));

View File

@@ -719,7 +719,8 @@ public class KeyBindingUtils {
// deprecated InputEvent mask types
@SuppressWarnings("deprecation")
private static boolean isControl(int mask) {
return (mask & InputEvent.CTRL_DOWN_MASK) != 0 || (mask & InputEvent.CTRL_MASK) != 0;
return (mask & InputEvent.CTRL_DOWN_MASK) != 0 || (mask & InputEvent.CTRL_MASK) != 0 ||
(mask & DockingUtils.CONTROL_KEY_MODIFIER_MASK) != 0;
}
// ignore the deprecated; remove when we are confident that all tool actions no longer use the

View File

@@ -963,7 +963,7 @@ public class TextFieldAutocompleter<T> {
}
}
else if (e.getKeyCode() == KeyEvent.VK_SPACE &&
(e.getModifiersEx() & InputEvent.CTRL_DOWN_MASK) != 0) {
(e.getModifiersEx() & DockingUtils.CONTROL_KEY_MODIFIER_MASK) != 0) {
startCompletion((JTextField) e.getComponent());
e.consume();
}

View File

@@ -102,10 +102,11 @@ public class FieldPanel extends JPanel
// initialize the focus traversal keys to control Tab to free up the tab key for internal
// field panel use. This is the same behavior that text components use.
KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.CTRL_DOWN_MASK);
KeyStroke ks =
KeyStroke.getKeyStroke(KeyEvent.VK_TAB, DockingUtils.CONTROL_KEY_MODIFIER_MASK);
setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, Set.of(ks));
ks = KeyStroke.getKeyStroke(KeyEvent.VK_TAB,
InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK);
DockingUtils.CONTROL_KEY_MODIFIER_MASK | InputEvent.SHIFT_DOWN_MASK);
setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, Set.of(ks));
addKeyListener(new FieldPanelKeyAdapter());

View File

@@ -19,13 +19,15 @@ import static org.junit.Assert.*;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.*;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import javax.swing.JList;
import javax.swing.JWindow;
import org.junit.Test;
import docking.DockingUtils;
import docking.widgets.DropDownTextFieldDataModel.SearchMode;
/**
@@ -639,7 +641,7 @@ public class DropDownTextFieldTest extends AbstractDropDownTextFieldTest<String>
Point p = searchModeBounds.getLocation();
long when = System.currentTimeMillis();
int mods = useControlKey ? InputEvent.CTRL_DOWN_MASK : 0;
int mods = useControlKey ? DockingUtils.CONTROL_KEY_MODIFIER_MASK : 0;
int x = p.x + 3; // add some fudge
int y = p.y + 3; // add some fudge
int clickCount = 1;
@@ -650,11 +652,13 @@ public class DropDownTextFieldTest extends AbstractDropDownTextFieldTest<String>
}
private void toggleSearchModeViaKeyBinding() {
triggerKey(textField, InputEvent.CTRL_DOWN_MASK, KeyEvent.VK_DOWN, KeyEvent.CHAR_UNDEFINED);
triggerKey(textField, DockingUtils.CONTROL_KEY_MODIFIER_MASK, KeyEvent.VK_DOWN,
KeyEvent.CHAR_UNDEFINED);
}
private void toggleSearchModeViaKeyBinding_Backwards() {
triggerKey(textField, InputEvent.CTRL_DOWN_MASK, KeyEvent.VK_UP, KeyEvent.CHAR_UNDEFINED);
triggerKey(textField, DockingUtils.CONTROL_KEY_MODIFIER_MASK, KeyEvent.VK_UP,
KeyEvent.CHAR_UNDEFINED);
}
private void showMatchingList() {

View File

@@ -4,9 +4,9 @@
* 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.
@@ -20,7 +20,6 @@ import static java.awt.event.KeyEvent.*;
import static javax.swing.KeyStroke.*;
import java.awt.Toolkit;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import javax.swing.KeyStroke;
@@ -54,8 +53,7 @@ public class SystemKeyBindings {
public static final KeyStroke COMPONENT_THEME_INFO_KEY = getKeyStroke(VK_F9, CTRL_ALT_SHIFT);
public static final KeyStroke ACTION_CHOOSER_KEY =
KeyStroke.getKeyStroke(KeyEvent.VK_3, InputEvent.CTRL_DOWN_MASK);
public static final KeyStroke ACTION_CHOOSER_KEY = getKeyStroke(KeyEvent.VK_3, CTRL);
private SystemKeyBindings() {
// utils class

View File

@@ -4,9 +4,9 @@
* 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.
@@ -17,6 +17,7 @@ package gui.event;
import static org.apache.commons.lang3.StringUtils.*;
import java.awt.Toolkit;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
import java.util.*;
@@ -143,7 +144,8 @@ public class MouseBinding {
iterator.remove();
}
else if (indexOfIgnoreCase(piece, CTRL) != -1) {
modifiers |= InputEvent.CTRL_DOWN_MASK;
// This is the cross platform way to get the control key
modifiers |= Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx();
iterator.remove();
}
else if (indexOfIgnoreCase(piece, ALT) != -1) {

View File

@@ -4,9 +4,9 @@
* 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.
@@ -17,6 +17,7 @@ package gui.event;
import static org.junit.Assert.*;
import java.awt.Toolkit;
import java.awt.event.InputEvent;
import java.awt.event.MouseEvent;
@@ -26,7 +27,7 @@ import org.junit.Test;
public class MouseBindingTest {
private static final int CTRL = InputEvent.CTRL_DOWN_MASK;
private static final int CTRL = Toolkit.getDefaultToolkit().getMenuShortcutKeyMaskEx();
private static final int SHIFT = InputEvent.SHIFT_DOWN_MASK;
@Test

View File

@@ -4,9 +4,9 @@
* 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.
@@ -17,12 +17,12 @@ package ghidra.framework.main.logviewer.ui;
import java.awt.event.*;
import java.io.IOException;
import java.util.Iterator;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import docking.DockingUtils;
import ghidra.framework.main.logviewer.event.*;
import ghidra.framework.main.logviewer.event.FVEvent.EventType;
import ghidra.framework.main.logviewer.model.*;
@@ -100,7 +100,6 @@ public class FVSlider extends JSlider
createKeyBindings(table, model, reader, eventListener);
}
/**
* Sets the value of the slider based on the given file position.
*
@@ -143,11 +142,7 @@ public class FVSlider extends JSlider
// Once we have that byte value, just set the slider to be the same.
//
int chunkRowStart = 0;
Iterator<Chunk> iter = model.iterator();
while (iter.hasNext()) {
Chunk chunk = iter.next();
for (Chunk chunk : model) {
// Figure out the starting row of the next chunk. If the row we want is less than
// that, then we know we've found the chunk that contains our row.
chunkRowStart += chunk.linesInChunk;
@@ -208,7 +203,7 @@ public class FVSlider extends JSlider
FVEvent tailOffEvt = new FVEvent(EventType.SCROLL_LOCK_ON, null);
eventListener.send(tailOffEvt);
FVEvent sliderChangedEvt = new FVEvent(EventType.SLIDER_CHANGED, filePosition);
eventListener.send(sliderChangedEvt);
@@ -257,7 +252,7 @@ public class FVSlider extends JSlider
public void mouseExited(MouseEvent e) {
// do nothing
}
/**
* Returns the file position (long) for the given slider position (int). This is calculated by
* computing the position of the slider as a percentage of its maximum, and applying the same
@@ -325,7 +320,7 @@ public class FVSlider extends JSlider
*/
private void createKeyBindings(FVTable table, ChunkModel model, ChunkReader reader,
FVEventListener eventListener) {
// These key bindings are identical to the ones set in the FVTable class. These are
// necessary for cases where the user hits a key that should manipulate the table, but
// keyboard focus is on the slider.
@@ -343,37 +338,41 @@ public class FVSlider extends JSlider
am_table.put("Home", new HomeAction(eventListener));
im_table.put(KeyStroke.getKeyStroke(KeyEvent.VK_END, 0), "End");
am_table.put("End", new EndAction(eventListener));
// Recognize when the shift key has been pressed and released, so we know how to handle
// selection.
im_table.put(KeyStroke.getKeyStroke(KeyEvent.VK_SHIFT, InputEvent.SHIFT_DOWN_MASK, false), "ShiftPressed");
im_table.put(KeyStroke.getKeyStroke(KeyEvent.VK_SHIFT, InputEvent.SHIFT_DOWN_MASK, false),
"ShiftPressed");
am_table.put("ShiftPressed", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
table.setShiftDown(true);
}
table.setShiftDown(true);
}
});
im_table.put(KeyStroke.getKeyStroke("released SHIFT"), "ShiftReleased");
am_table.put("ShiftReleased", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
table.setShiftDown(false);
}
table.setShiftDown(false);
}
});
// Now create a binding for the CTRL-A, select all action.
im_table.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK, false), "SelectAll");
im_table.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.META_DOWN_MASK, false), "SelectAll");
im_table.put(
KeyStroke.getKeyStroke(KeyEvent.VK_A, DockingUtils.CONTROL_KEY_MODIFIER_MASK, false),
"SelectAll");
im_table.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.META_DOWN_MASK, false),
"SelectAll");
am_table.put("SelectAll", new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
try {
model.selectedByteStart = 0;
model.selectedByteEnd = reader.getFileSize()-1;
model.selectedByteEnd = reader.getFileSize() - 1;
FVEvent copyEvt = new FVEvent(EventType.COPY_SELECTION, null);
eventListener.send(copyEvt);
}
@@ -383,5 +382,5 @@ public class FVSlider extends JSlider
}
});
}
}

View File

@@ -27,6 +27,7 @@ import javax.swing.event.ListSelectionEvent;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import docking.DockingUtils;
import docking.widgets.table.GTable;
import ghidra.framework.main.logviewer.event.*;
import ghidra.framework.main.logviewer.event.FVEvent.EventType;
@@ -92,8 +93,9 @@ public class FVTable extends GTable
// Set the cell renderer that will set the background color of the row based
// on the log level.
getColumnModel().getColumn(FVTableModel.LEVEL_COL).setCellRenderer(
new LogLevelTableCellRenderer());
getColumnModel().getColumn(FVTableModel.LEVEL_COL)
.setCellRenderer(
new LogLevelTableCellRenderer());
// The selection listener is kicked off whenever the table selection has been changed. We
// need to know this so we can store the selection in the viewport utility.
@@ -282,7 +284,7 @@ public class FVTable extends GTable
return;
}
((FVTableModel) getModel()).removeRowsFromTop(chunk.linesInChunk);
// Now slide the viewport back up to account for what we just read in.
viewportUtility.moveViewportUp(chunk.linesInChunk, false);
}
@@ -354,7 +356,7 @@ public class FVTable extends GTable
return;
}
((FVTableModel) getModel()).removeRowsFromTop(chunk.linesInChunk);
// Now slide the viewport back up to account for what we just read in.
viewportUtility.moveViewportUp(chunk.linesInChunk, false);
}
@@ -413,7 +415,7 @@ public class FVTable extends GTable
// Now slide the viewport back up to account for what we just read in.
viewportUtility.moveViewportDown(lines.size(), false);
if (model.getSize() > model.MAX_VISIBLE_CHUNKS) {
Chunk chunk = model.remove(model.getSize() - 1);
if (chunk == null) {
@@ -488,7 +490,7 @@ public class FVTable extends GTable
// Now slide the viewport back up to account for what we just read in.
viewportUtility.moveViewportDown(lines.size(), false);
// And remove chunks if necessary.
if (model.getSize() > model.MAX_VISIBLE_CHUNKS) {
Chunk chunk = model.remove(model.getSize() - 1);
@@ -499,7 +501,6 @@ public class FVTable extends GTable
}
});
}
catch (IOException e) {
Msg.error(this, "Error reading previous chunk of data", e);
@@ -545,8 +546,9 @@ public class FVTable extends GTable
else {
Pair filePosFirstRow = model.getFilePositionForRow(selectedRows[0]);
Pair filePosLastRow = model.getFilePositionForRow(selectedRows[selectedRows.length - 1]);
Pair filePosLastRow =
model.getFilePositionForRow(selectedRows[selectedRows.length - 1]);
if (filePosFirstRow == null || filePosLastRow == null) {
return;
}
@@ -625,7 +627,8 @@ public class FVTable extends GTable
am_table.put("PageUpSelection", new PageUpSelectionAction(eventListener));
// Set up a key binding for copying selected rows to the clipboard.
im_table.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.CTRL_DOWN_MASK), "copyText");
im_table.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DockingUtils.CONTROL_KEY_MODIFIER_MASK),
"copyText");
im_table.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, InputEvent.META_DOWN_MASK), "copyText");
am_table.put("copyText", new AbstractAction() {
@@ -658,7 +661,8 @@ public class FVTable extends GTable
});
// Now create a binding for the CTRL-A, select all action.
im_table.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK, false),
im_table.put(
KeyStroke.getKeyStroke(KeyEvent.VK_A, DockingUtils.CONTROL_KEY_MODIFIER_MASK, false),
"SelectAll");
im_table.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.META_DOWN_MASK, false),
"SelectAll");

View File

@@ -15,16 +15,16 @@
*/
package ghidra.framework.main.projectdata.actions;
import java.awt.event.InputEvent;
import javax.swing.Icon;
import javax.swing.tree.TreePath;
import docking.DockingUtils;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import generic.theme.GIcon;
import ghidra.framework.main.AppInfo;
import ghidra.framework.main.datatree.*;
import ghidra.framework.main.datatree.DataTreeClipboardUtils;
import ghidra.framework.main.datatree.FrontEndProjectTreeContext;
import ghidra.framework.model.Project;
import ghidra.util.HelpLocation;
@@ -34,7 +34,7 @@ public class ProjectDataCopyAction extends ProjectDataCopyCutBaseAction {
public ProjectDataCopyAction(String owner, String group) {
super("Copy", owner);
setPopupMenuData(new MenuData(new String[] { "Copy" }, icon, group));
setKeyBindingData(new KeyBindingData('C', InputEvent.CTRL_DOWN_MASK));
setKeyBindingData(new KeyBindingData('C', DockingUtils.CONTROL_KEY_MODIFIER_MASK));
setHelpLocation(new HelpLocation("FrontEndPlugin", "Copy"));
}

View File

@@ -15,11 +15,10 @@
*/
package ghidra.framework.main.projectdata.actions;
import java.awt.event.InputEvent;
import javax.swing.Icon;
import javax.swing.tree.TreePath;
import docking.DockingUtils;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import docking.widgets.tree.GTreeNode;
@@ -34,7 +33,7 @@ public class ProjectDataCutAction extends ProjectDataCopyCutBaseAction {
public ProjectDataCutAction(String owner, String group) {
super("Cut", owner);
setPopupMenuData(new MenuData(new String[] { "Cut" }, ICON, group));
setKeyBindingData(new KeyBindingData('X', InputEvent.CTRL_DOWN_MASK));
setKeyBindingData(new KeyBindingData('X', DockingUtils.CONTROL_KEY_MODIFIER_MASK));
setHelpLocation(new HelpLocation("FrontEndPlugin", "Cut"));
}

View File

@@ -15,13 +15,13 @@
*/
package ghidra.framework.main.projectdata.actions;
import java.awt.event.InputEvent;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.swing.Icon;
import docking.DockingUtils;
import docking.action.KeyBindingData;
import docking.action.MenuData;
import docking.widgets.tree.GTreeNode;
@@ -39,7 +39,7 @@ public class ProjectDataPasteAction extends ProjectDataCopyCutBaseAction {
public ProjectDataPasteAction(String owner, String group) {
super("Paste", owner);
setPopupMenuData(new MenuData(new String[] { "Paste" }, ICON, group));
setKeyBindingData(new KeyBindingData('V', InputEvent.CTRL_DOWN_MASK));
setKeyBindingData(new KeyBindingData('V', DockingUtils.CONTROL_KEY_MODIFIER_MASK));
setHelpLocation(new HelpLocation("FrontEndPlugin", "Paste"));
}