mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-03 17:59:46 +02:00
GT-2925 - Key Bindings - Support Window Menu Provider Key Bindings -
Step 3 - removed old plugin pattern of creating special actions to show their respective providers; updated inception information for new action
This commit is contained in:
parent
f510ddf338
commit
fa75f7dff6
32 changed files with 296 additions and 425 deletions
|
@ -25,6 +25,7 @@ import javax.swing.*;
|
|||
import org.junit.*;
|
||||
|
||||
import docking.action.DockingActionIf;
|
||||
import docking.action.KeyBindingData;
|
||||
import docking.actions.KeyEntryDialog;
|
||||
import docking.tool.util.DockingToolConstants;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
|
@ -91,6 +92,59 @@ public class ComponentProviderActionsTest extends AbstractGhidraHeadedIntegratio
|
|||
assertWindowMenuActionHasIcon(Icons.EMPTY_ICON);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetKeyBinding_DirectlyOnProvider() {
|
||||
//
|
||||
// This is how clients set key bindings on providers, as desired, when constructing them
|
||||
//
|
||||
|
||||
KeyStroke defaultKs = CONTROL_T;
|
||||
setDefaultKeyBinding(defaultKs);
|
||||
|
||||
showProvider();
|
||||
|
||||
assertProviderKeyStroke(defaultKs);
|
||||
assertOptionsKeyStroke(defaultKs);
|
||||
assertMenuItemHasKeyStroke(defaultKs);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetKeyBinding_DirectlyOnProvider_TransientProvider() {
|
||||
//
|
||||
// Transient providers cannot have key bindings
|
||||
//
|
||||
switchToTransientProvider();
|
||||
|
||||
setErrorsExpected(true);
|
||||
setDefaultKeyBinding(CONTROL_T);
|
||||
setErrorsExpected(false);
|
||||
|
||||
showProvider();
|
||||
|
||||
spyLogger.assertLogMessage("Transient", "cannot", "key", "binding");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetTransientAfterSettingKeyBinding() {
|
||||
|
||||
setDefaultKeyBinding(CONTROL_T);
|
||||
|
||||
setErrorsExpected(true);
|
||||
switchToTransientProvider();
|
||||
setErrorsExpected(false);
|
||||
|
||||
showProvider();
|
||||
|
||||
spyLogger.assertLogMessage("Transient", "not", "key", "binding");
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void testSetTransientAfterAddedProviderToTheTool() {
|
||||
|
||||
showProvider();
|
||||
switchToTransientProvider(); // exception
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetKeyBinding_ViaDialog_FromWindowMenu() {
|
||||
|
||||
|
@ -177,21 +231,6 @@ public class ComponentProviderActionsTest extends AbstractGhidraHeadedIntegratio
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testChangeActionRelatedStateAfterConstruction_setTransient() {
|
||||
|
||||
setToolbarIcon(ICON);
|
||||
showProvider(); // this creates the 'Show Provider' action
|
||||
assertShowProviderActionIsInToolbar();
|
||||
|
||||
setErrorsExpected(true);
|
||||
switchToTransientProvider();
|
||||
setErrorsExpected(false);
|
||||
|
||||
assertShowProviderActionNotInToolbar();
|
||||
spyLogger.assertLogMessage("Transient", "not", "toolbar");
|
||||
}
|
||||
|
||||
//==================================================================================================
|
||||
// Private Methods
|
||||
//==================================================================================================
|
||||
|
@ -215,6 +254,10 @@ public class ComponentProviderActionsTest extends AbstractGhidraHeadedIntegratio
|
|||
waitForSwing();
|
||||
}
|
||||
|
||||
private void setDefaultKeyBinding(KeyStroke defaultKs) {
|
||||
runSwing(() -> provider.setDefaultKeyBinding(new KeyBindingData(defaultKs)));
|
||||
}
|
||||
|
||||
private void setIcon(Icon icon) {
|
||||
runSwing(() -> provider.setIcon(icon));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue