mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Merge remote-tracking branch
'origin/GT-3427-dragonmacher-gtree-f2-edit-key' (fixes #1356)
This commit is contained in:
commit
9d66900025
2 changed files with 47 additions and 5 deletions
|
@ -401,6 +401,36 @@ public class KeyBindingUtils {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears the currently assigned Java key binding for the action by the given name. This
|
||||
* method will find the currently assigned key binding, if any, and then remove it.
|
||||
*
|
||||
* @param component the component for which to clear the key binding
|
||||
* @param actionName the name of the action that should not have a key binding
|
||||
* @see LookAndFeel
|
||||
*/
|
||||
public static void clearKeyBinding(JComponent component, String actionName) {
|
||||
|
||||
InputMap inputMap = component.getInputMap(JComponent.WHEN_FOCUSED);
|
||||
if (inputMap == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
KeyStroke keyStroke = null;
|
||||
KeyStroke[] keys = inputMap.allKeys();
|
||||
for (KeyStroke ks : keys) {
|
||||
Object object = inputMap.get(ks);
|
||||
if (actionName.equals(object)) {
|
||||
keyStroke = ks;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (keyStroke != null) {
|
||||
clearKeyBinding(component, keyStroke);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the registered action for the given keystroke, or null of no
|
||||
* action is bound to that keystroke.
|
||||
|
@ -906,5 +936,4 @@ public class KeyBindingUtils {
|
|||
|
||||
return selectedFile;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import javax.swing.tree.*;
|
|||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import docking.DockingWindowManager;
|
||||
import docking.actions.KeyBindingUtils;
|
||||
import docking.widgets.JTreeMouseListenerDelegate;
|
||||
import docking.widgets.filter.FilterTextField;
|
||||
import docking.widgets.table.AutoscrollAdapter;
|
||||
|
@ -228,10 +229,6 @@ public class GTree extends JPanel implements BusyListener {
|
|||
});
|
||||
|
||||
tree = new AutoScrollTree(model);
|
||||
tree.setRowHeight(-1);// variable size rows
|
||||
tree.setSelectionModel(new GTreeSelectionModel());
|
||||
tree.setInvokesStopCellEditing(true);// clicking outside the cell editor will trigger a save, not a cancel
|
||||
ToolTipManager.sharedInstance().registerComponent(tree);
|
||||
|
||||
setLayout(new BorderLayout());
|
||||
|
||||
|
@ -1233,6 +1230,22 @@ public class GTree extends JPanel implements BusyListener {
|
|||
public AutoScrollTree(TreeModel model) {
|
||||
super(model);
|
||||
scroller = new AutoscrollAdapter(this, 5);
|
||||
|
||||
setRowHeight(-1);// variable size rows
|
||||
setSelectionModel(new GTreeSelectionModel());
|
||||
setInvokesStopCellEditing(true);// clicking outside the cell editor will trigger a save, not a cancel
|
||||
|
||||
updateDefaultKeyBindings();
|
||||
|
||||
ToolTipManager.sharedInstance().registerComponent(this);
|
||||
}
|
||||
|
||||
private void updateDefaultKeyBindings() {
|
||||
|
||||
// Remove the edit keybinding, as the GTree triggers editing via a task, since it
|
||||
// is multi-threaded. Doing this allows users to assign their own key bindings to
|
||||
// the edit task.
|
||||
KeyBindingUtils.clearKeyBinding(this, "startEditing");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue