mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Updated file chooser to register actions
This commit is contained in:
parent
c99af66f5f
commit
e5e7f0a8ff
4 changed files with 55 additions and 9 deletions
|
@ -18,6 +18,7 @@ package docking.actions;
|
|||
import docking.*;
|
||||
import docking.action.DockingActionIf;
|
||||
import docking.tool.ToolConstants;
|
||||
import docking.widgets.filechooser.GhidraFileChooser;
|
||||
import docking.widgets.table.GTable;
|
||||
import docking.widgets.tree.GTree;
|
||||
|
||||
|
@ -36,11 +37,11 @@ public class SharedActionRegistry {
|
|||
*/
|
||||
public static void installSharedActions(Tool tool, ToolActions toolActions) {
|
||||
GTable.createSharedActions(tool, toolActions, ToolConstants.SHARED_OWNER);
|
||||
|
||||
GTree.createSharedActions(tool, toolActions, ToolConstants.SHARED_OWNER);
|
||||
|
||||
DialogComponentProvider.createSharedActions(tool, toolActions, ToolConstants.SHARED_OWNER);
|
||||
|
||||
DockingWindowManager.createSharedActions(tool, toolActions, ToolConstants.SHARED_OWNER);
|
||||
|
||||
GhidraFileChooser.registerSharedActions(tool, toolActions);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ import docking.*;
|
|||
import docking.action.DockingAction;
|
||||
import docking.action.DockingActionIf;
|
||||
import docking.action.builder.ActionBuilder;
|
||||
import docking.actions.KeyBindingUtils;
|
||||
import docking.actions.*;
|
||||
import docking.menu.DockingToolBarUtils;
|
||||
import docking.widgets.*;
|
||||
import docking.widgets.combobox.GComboBox;
|
||||
|
@ -87,6 +87,10 @@ public class GhidraFileChooser extends ReusableDialogComponentProvider implement
|
|||
*/
|
||||
private static final int BIG_DATA_THRESHOLD = 200;
|
||||
|
||||
private static final String ACTION_NAME_BACK = "Last Folder Visited";
|
||||
private static final String ACTION_NAME_FORWARD = "Previous Folder Visited";
|
||||
private static final String ACTION_NAME_UP = "Up One Level";
|
||||
|
||||
static final String UP_BUTTON_NAME = "UP_BUTTON";
|
||||
private static final Color FOREROUND_COLOR = new GColor("color.fg.filechooser");
|
||||
private static final Color BACKGROUND_COLOR = new GColor("color.bg.filechooser");
|
||||
|
@ -285,16 +289,19 @@ public class GhidraFileChooser extends ReusableDialogComponentProvider implement
|
|||
|
||||
String owner = getClass().getSimpleName();
|
||||
upAction = new ActionBuilder("Up One Level", owner)
|
||||
.sharedKeyBinding()
|
||||
.keyBinding("Alt Up")
|
||||
.onAction(c -> goUp())
|
||||
.build();
|
||||
|
||||
backAction = new ActionBuilder("Last Folder Visited", owner)
|
||||
.sharedKeyBinding()
|
||||
.keyBinding("Alt Left")
|
||||
.onAction(c -> goBack())
|
||||
.build();
|
||||
|
||||
forwardAction = new ActionBuilder("Previous Folder Visited", owner)
|
||||
.sharedKeyBinding()
|
||||
.keyBinding("Alt Right")
|
||||
.onAction(c -> goForward())
|
||||
.build();
|
||||
|
@ -310,6 +317,18 @@ public class GhidraFileChooser extends ReusableDialogComponentProvider implement
|
|||
updateNavigationButtonToolTips();
|
||||
}
|
||||
|
||||
public static void registerSharedActions(Tool tool, ToolActions toolActions) {
|
||||
|
||||
toolActions.registerSharedActionPlaceholder(
|
||||
new GfcActionPlaceholder(ACTION_NAME_BACK, "Alt Left"));
|
||||
|
||||
toolActions.registerSharedActionPlaceholder(
|
||||
new GfcActionPlaceholder(ACTION_NAME_FORWARD, "Alt Right"));
|
||||
|
||||
toolActions.registerSharedActionPlaceholder(
|
||||
new GfcActionPlaceholder(ACTION_NAME_UP, "Alt Up"));
|
||||
}
|
||||
|
||||
private JComponent buildWorkPanel() {
|
||||
buildWaitPanel();
|
||||
|
||||
|
@ -2530,4 +2549,30 @@ public class GhidraFileChooser extends ReusableDialogComponentProvider implement
|
|||
|
||||
}
|
||||
|
||||
// A class that allows us to register actions and keybindings before this dialog is instantiated
|
||||
private static class GfcActionPlaceholder implements SharedDockingActionPlaceholder {
|
||||
|
||||
private String name;
|
||||
private String keyBinding;
|
||||
|
||||
GfcActionPlaceholder(String name, String keyBinding) {
|
||||
this.name = name;
|
||||
this.keyBinding = keyBinding;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public KeyStroke getKeyBinding() {
|
||||
return KeyBindingUtils.parseKeyStroke(keyBinding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwner() {
|
||||
return GhidraFileChooser.class.getSimpleName();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue