mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 10:49:34 +02:00
Tests - fixes related to recent dialog actions update
This commit is contained in:
parent
cd084aee7b
commit
6b468e196a
9 changed files with 55 additions and 43 deletions
|
@ -31,9 +31,7 @@ import docking.widgets.OptionDialog;
|
|||
import docking.widgets.dialogs.InputDialog;
|
||||
import docking.widgets.pathmanager.PathnameTablePanel;
|
||||
import generic.jar.ResourceFile;
|
||||
import ghidra.app.plugin.core.codebrowser.CodeBrowserPlugin;
|
||||
import ghidra.app.plugin.core.datamgr.DataTypeManagerPlugin;
|
||||
import ghidra.app.plugin.core.programtree.ProgramTreePlugin;
|
||||
import ghidra.framework.Application;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
import ghidra.test.AbstractGhidraHeadedIntegrationTest;
|
||||
|
@ -59,19 +57,19 @@ public class ParseDialogTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
public void setUp() throws Exception {
|
||||
env = new TestEnv();
|
||||
tool = env.getTool();
|
||||
tool.addPlugin(ProgramTreePlugin.class.getName());
|
||||
tool.addPlugin(CodeBrowserPlugin.class.getName());
|
||||
tool.addPlugin(DataTypeManagerPlugin.class.getName());
|
||||
tool.addPlugin(CParserPlugin.class.getName());
|
||||
plugin = getPlugin(tool, CParserPlugin.class);
|
||||
|
||||
env.showTool();
|
||||
|
||||
String tempPath = createTempFilePath(getClass().getSimpleName());
|
||||
plugin.setUserProfileDir(tempPath);
|
||||
parseAction = getAction(plugin, CParserPlugin.PARSE_ACTION_NAME);
|
||||
readDefaultParseProfileFile();
|
||||
removeAllProfiles();
|
||||
|
||||
dialog = getDialog();
|
||||
dialog = showDialog();
|
||||
profilesComboBox = findComponent(dialog, JComboBox.class);
|
||||
assertNotNull(profilesComboBox);
|
||||
profilesComboBoxModel = (DefaultComboBoxModel<?>) profilesComboBox.getModel();
|
||||
|
@ -339,7 +337,7 @@ public class ParseDialogTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
runSwing(() -> pathPanel.setPaths(new String[] { paths.get(0), path }));
|
||||
}
|
||||
|
||||
private ParseDialog getDialog() {
|
||||
private ParseDialog showDialog() {
|
||||
performAction(parseAction, true);
|
||||
return waitForDialogComponent(ParseDialog.class);
|
||||
}
|
||||
|
|
|
@ -206,14 +206,13 @@ public class KeyBindingUtilsTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
|
||||
debug("d");
|
||||
|
||||
// now repeat the above test with changing some values before writing
|
||||
// out
|
||||
// now repeat the above test with changing some values before writing out
|
||||
invokeInstanceMethod("putObject", defaultKeyBindings,
|
||||
new Class[] { String.class, Object.class },
|
||||
new Object[] { "test1", KeyStroke.getKeyStroke(65, 0) });
|
||||
new Object[] { "TestAction1 (Owner1)", KeyStroke.getKeyStroke(65, 0) });
|
||||
invokeInstanceMethod("putObject", defaultKeyBindings,
|
||||
new Class[] { String.class, Object.class },
|
||||
new Object[] { "test2", KeyStroke.getKeyStroke(66, 0) });
|
||||
new Object[] { "TestAction2 (Owner 2)", KeyStroke.getKeyStroke(66, 0) });
|
||||
|
||||
debug("e");
|
||||
|
||||
|
|
|
@ -1199,10 +1199,20 @@ public class DialogComponentProvider
|
|||
dialogActions.add(action);
|
||||
addToolbarAction(action);
|
||||
popupManager.addAction(action);
|
||||
addKeyBindingAction(action);
|
||||
}
|
||||
|
||||
private void addKeyBindingAction(DockingActionIf action) {
|
||||
|
||||
// add the action to the tool in order get key event management (key bindings
|
||||
// options and key event processing)
|
||||
DockingWindowManager dwm = DockingWindowManager.getActiveInstance();
|
||||
if (dwm == null) {
|
||||
// This implies the client dialog has been shown outside of the plugin framework. In
|
||||
// that case, the client will not get key event processing for dialog actions.
|
||||
return;
|
||||
}
|
||||
|
||||
Tool tool = dwm.getTool();
|
||||
tool.addAction(new DialogActionProxy(action));
|
||||
}
|
||||
|
|
|
@ -226,6 +226,6 @@ public class DockingActionProxy
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
return dockingAction.getName();
|
||||
return dockingAction.toString();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1710,10 +1710,10 @@ public class DockingWindowManager implements PropertyChangeListener, Placeholder
|
|||
};
|
||||
|
||||
if (provider.isModal()) {
|
||||
SystemUtilities.runSwingNow(r);
|
||||
Swing.runNow(r);
|
||||
}
|
||||
else {
|
||||
SystemUtilities.runIfSwingOrPostSwingLater(r);
|
||||
Swing.runIfSwingOrRunLater(r);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,13 +17,14 @@ package docking;
|
|||
|
||||
import docking.action.DockingActionIf;
|
||||
import docking.action.ToggleDockingActionIf;
|
||||
import generic.json.Json;
|
||||
|
||||
public class ExecutableKeyActionAdapter {
|
||||
|
||||
DockingActionIf action;
|
||||
ActionContext context;
|
||||
|
||||
public ExecutableKeyActionAdapter( DockingActionIf action, ActionContext context ) {
|
||||
public ExecutableKeyActionAdapter(DockingActionIf action, ActionContext context) {
|
||||
this.action = action;
|
||||
this.context = context;
|
||||
}
|
||||
|
@ -32,15 +32,20 @@ public class ExecutableKeyActionAdapter {
|
|||
public void execute() {
|
||||
// Toggle actions do not toggle its state directly therefor we have to do it for
|
||||
// them before we execute the action.
|
||||
if ( action instanceof ToggleDockingActionIf ) {
|
||||
if (action instanceof ToggleDockingActionIf) {
|
||||
ToggleDockingActionIf toggleAction = (ToggleDockingActionIf) action;
|
||||
toggleAction.setSelected( !toggleAction.isSelected() );
|
||||
toggleAction.setSelected(!toggleAction.isSelected());
|
||||
}
|
||||
|
||||
action.actionPerformed( context );
|
||||
action.actionPerformed(context);
|
||||
}
|
||||
|
||||
public DockingActionIf getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Json.toString(action);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1188,7 +1188,7 @@ public abstract class AbstractDockingTest extends AbstractGenericTest {
|
|||
if (actions.size() > 1) {
|
||||
// This shouldn't happen
|
||||
throw new AssertionFailedError(
|
||||
"Found more than one action for name '" + name + " (" + owner + ")'");
|
||||
"Found more than one action for name '" + name + " (" + owner + ")'\n\t" + actions);
|
||||
}
|
||||
|
||||
return CollectionUtils.any(actions);
|
||||
|
|
|
@ -110,7 +110,7 @@ public class ManagePluginsDialog extends DialogComponentProvider implements Chan
|
|||
addAction(configureAllPluginsAction);
|
||||
|
||||
if (addSaveActions) {
|
||||
saveAction = new DockingAction("Save Tool", ToolConstants.TOOL_OWNER) {
|
||||
saveAction = new DockingAction("Save New Tool", ToolConstants.TOOL_OWNER) {
|
||||
@Override
|
||||
public void actionPerformed(ActionContext context) {
|
||||
save();
|
||||
|
@ -125,7 +125,7 @@ public class ManagePluginsDialog extends DialogComponentProvider implements Chan
|
|||
saveAction.setDescription("Save tool to tool chest");
|
||||
addAction(saveAction);
|
||||
|
||||
saveAsAction = new DockingAction("Save Tool As", ToolConstants.TOOL_OWNER) {
|
||||
saveAsAction = new DockingAction("Save New Tool As", ToolConstants.TOOL_OWNER) {
|
||||
@Override
|
||||
public void actionPerformed(ActionContext context) {
|
||||
saveAs();
|
||||
|
|
|
@ -690,7 +690,7 @@ public class ToolActionManagerTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
DockingActionIf createAction = getAction("Create Tool");
|
||||
performAction(createAction, true);
|
||||
PluginTool[] tools = frontEndTool.getProject().getToolManager().getRunningTools();
|
||||
final PluginTool tool = (PluginTool) tools[0];
|
||||
final PluginTool tool = tools[0];
|
||||
runSwing(() -> {
|
||||
try {
|
||||
tool.addPlugin(CodeBrowserPlugin.class.getName());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue