From d307623f67f10598a7b787c480b337cde7907fca Mon Sep 17 00:00:00 2001 From: dragonmacher <48328597+dragonmacher@users.noreply.github.com> Date: Wed, 15 Jan 2020 17:39:21 -0500 Subject: [PATCH] GT-3455 - Update action key binding collision dialog to allow for mouse double-click --- ...{ActionDialog.java => MultiActionDialog.java} | 16 ++++++++++++++-- .../java/docking/action/MultipleKeyAction.java | 4 ++-- 2 files changed, 16 insertions(+), 4 deletions(-) rename Ghidra/Framework/Docking/src/main/java/docking/{ActionDialog.java => MultiActionDialog.java} (90%) diff --git a/Ghidra/Framework/Docking/src/main/java/docking/ActionDialog.java b/Ghidra/Framework/Docking/src/main/java/docking/MultiActionDialog.java similarity index 90% rename from Ghidra/Framework/Docking/src/main/java/docking/ActionDialog.java rename to Ghidra/Framework/Docking/src/main/java/docking/MultiActionDialog.java index 84245ae71f..81f7d80c89 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/ActionDialog.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/MultiActionDialog.java @@ -22,6 +22,7 @@ import java.util.List; import javax.swing.*; import docking.action.DockingActionIf; +import docking.event.mouse.GMouseListenerAdapter; import docking.widgets.label.GIconLabel; import docking.widgets.label.GLabel; @@ -29,7 +30,7 @@ import docking.widgets.label.GLabel; * Dialog to show multiple actions that are mapped to the same keystroke; * allows the user to select which action to do. */ -public class ActionDialog extends DialogComponentProvider { +public class MultiActionDialog extends DialogComponentProvider { private String keystrokeName; private List list; @@ -41,7 +42,7 @@ public class ActionDialog extends DialogComponentProvider { * @param keystrokeName keystroke name * @param list list of actions */ - public ActionDialog(String keystrokeName, List list) { + public MultiActionDialog(String keystrokeName, List list) { super("Select Action", true); this.keystrokeName = keystrokeName; init(); @@ -53,6 +54,10 @@ public class ActionDialog extends DialogComponentProvider { */ @Override protected void okCallback() { + maybeDoAction(); + } + + private void maybeDoAction() { int index = actionList.getSelectedIndex(); if (index < 0) { return; @@ -123,6 +128,13 @@ public class ActionDialog extends DialogComponentProvider { } }); + actionList.addMouseListener(new GMouseListenerAdapter() { + @Override + public void doubleClickTriggered(MouseEvent e) { + maybeDoAction(); + } + }); + actionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); actionList.setVisibleRowCount(5); JScrollPane listScrollPane = new JScrollPane(actionList); diff --git a/Ghidra/Framework/Docking/src/main/java/docking/action/MultipleKeyAction.java b/Ghidra/Framework/Docking/src/main/java/docking/action/MultipleKeyAction.java index 6701bf673a..4541fb7044 100644 --- a/Ghidra/Framework/Docking/src/main/java/docking/action/MultipleKeyAction.java +++ b/Ghidra/Framework/Docking/src/main/java/docking/action/MultipleKeyAction.java @@ -30,7 +30,7 @@ import ghidra.util.Swing; public class MultipleKeyAction extends DockingKeyBindingAction { private List actions = new ArrayList<>(); - private ActionDialog dialog; + private MultiActionDialog dialog; /** * Creates new MultipleKeyAction @@ -133,7 +133,7 @@ public class MultipleKeyAction extends DockingKeyBindingAction { if (list.size() > 1) { // popup dialog to show multiple actions if (dialog == null) { - dialog = new ActionDialog(KeyBindingUtils.parseKeyStroke(keyStroke), list); + dialog = new MultiActionDialog(KeyBindingUtils.parseKeyStroke(keyStroke), list); } else { dialog.setActionList(list);