mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
GT-2925 - Key Bindings - Support Window Menu Provider Key Bindings -
Step 7 - Untangled and removed the key binding management from the ActionToGuiMapper; fixed bugs and tests
This commit is contained in:
parent
d684ee3ce6
commit
3946a05ded
27 changed files with 515 additions and 345 deletions
|
@ -22,7 +22,6 @@ import javax.swing.ToolTipManager;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import docking.DockingWindowManager;
|
||||
import docking.framework.SplashScreen;
|
||||
import ghidra.base.help.GhidraHelpService;
|
||||
import ghidra.framework.Application;
|
||||
|
@ -86,7 +85,6 @@ public class GhidraRun implements GhidraLaunchable {
|
|||
updateSplashScreenStatusMessage("Populating Ghidra help...");
|
||||
GhidraHelpService.install();
|
||||
|
||||
DockingWindowManager.enableDiagnosticActions(SystemUtilities.isInDevelopmentMode());
|
||||
ExtensionUtils.cleanupUninstalledExtensions();
|
||||
|
||||
// Allows handling of old content which did not have a content type property
|
||||
|
|
|
@ -32,7 +32,7 @@ public class TestTool extends GhidraTool {
|
|||
@Override
|
||||
protected DockingWindowManager createDockingWindowManager(boolean isDockable, boolean hasStatus,
|
||||
boolean isModal) {
|
||||
return new DockingWindowManager("EMPTY", null, this, isModal, isDockable, hasStatus, null);
|
||||
return new DockingWindowManager(this, null, this, isModal, isDockable, hasStatus, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,6 +27,7 @@ import org.junit.*;
|
|||
import docking.action.DockingActionIf;
|
||||
import docking.action.KeyBindingData;
|
||||
import docking.actions.KeyEntryDialog;
|
||||
import docking.actions.ToolActions;
|
||||
import docking.tool.util.DockingToolConstants;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.framework.plugintool.PluginTool;
|
||||
|
@ -235,15 +236,6 @@ public class ComponentProviderActionsTest extends AbstractGhidraHeadedIntegratio
|
|||
// Private Methods
|
||||
//==================================================================================================
|
||||
|
||||
private void assertShowProviderActionIsInToolbar() {
|
||||
assertNotNull("The 'Show Provider' action is not in the toolbar",
|
||||
getToolbarShowProviderAction());
|
||||
}
|
||||
|
||||
private void assertShowProviderActionNotInToolbar() {
|
||||
assertNull("The 'Show Provider' action is in the toolbar", getToolbarShowProviderAction());
|
||||
}
|
||||
|
||||
private void switchToTransientProvider() {
|
||||
provider.setTransient();
|
||||
}
|
||||
|
@ -390,9 +382,8 @@ public class ComponentProviderActionsTest extends AbstractGhidraHeadedIntegratio
|
|||
}
|
||||
|
||||
private void performLaunchKeyStrokeDialogAction() {
|
||||
DockingWindowManager dwm = tool.getWindowManager();
|
||||
ActionToGuiMapper actionMapper = dwm.getActionToGuiMapper();
|
||||
Action action = actionMapper.getDockingKeyAction(KeyStroke.getKeyStroke("F4"));
|
||||
ToolActions toolActions = ((AbstractDockingTool) tool).getToolActions();
|
||||
Action action = toolActions.getAction(KeyStroke.getKeyStroke("F4"));
|
||||
assertNotNull(action);
|
||||
runSwing(() -> action.actionPerformed(new ActionEvent(this, 0, "")), false);
|
||||
}
|
||||
|
|
|
@ -32,12 +32,11 @@ import org.junit.Test;
|
|||
import docking.test.AbstractDockingTest;
|
||||
import docking.widgets.label.GDLabel;
|
||||
import ghidra.framework.plugintool.ComponentProviderAdapter;
|
||||
import ghidra.test.DummyTool;
|
||||
|
||||
public class DockingWindowManagerTest extends AbstractDockingTest {
|
||||
|
||||
public DockingWindowManagerTest() {
|
||||
super();
|
||||
}
|
||||
private DockingTool tool = new DummyTool();
|
||||
|
||||
@Test
|
||||
public void testDefaultGroupWindowPosition() {
|
||||
|
@ -46,7 +45,7 @@ public class DockingWindowManagerTest extends AbstractDockingTest {
|
|||
// default window position.
|
||||
//
|
||||
|
||||
DockingWindowManager dwm = new DockingWindowManager("test", (List<Image>) null, null);
|
||||
DockingWindowManager dwm = new DockingWindowManager(tool, (List<Image>) null, null);
|
||||
|
||||
ComponentProvider providerA = addProvider(dwm, "A", "a", RIGHT);
|
||||
ComponentProvider providerB = addProvider(dwm, "B", "b", BOTTOM);
|
||||
|
@ -66,7 +65,7 @@ public class DockingWindowManagerTest extends AbstractDockingTest {
|
|||
// intragroup window position. Note: 'Stacked' is the default.
|
||||
//
|
||||
|
||||
DockingWindowManager dwm = new DockingWindowManager("test", (List<Image>) null, null);
|
||||
DockingWindowManager dwm = new DockingWindowManager(tool, (List<Image>) null, null);
|
||||
|
||||
ComponentProvider providerA1 = addProvider(dwm, "A1", "a", RIGHT, STACK);
|
||||
ComponentProvider providerA2 = addProvider(dwm, "A2", "a", BOTTOM, STACK);
|
||||
|
@ -84,7 +83,7 @@ public class DockingWindowManagerTest extends AbstractDockingTest {
|
|||
// intragroup window position.
|
||||
//
|
||||
|
||||
DockingWindowManager dwm = new DockingWindowManager("test", (List<Image>) null, null);
|
||||
DockingWindowManager dwm = new DockingWindowManager(tool, (List<Image>) null, null);
|
||||
|
||||
ComponentProvider providerA1 = addProvider(dwm, "A1", "a", RIGHT, STACK);
|
||||
ComponentProvider providerA2 = addProvider(dwm, "A2", "a", LEFT, BOTTOM);
|
||||
|
@ -101,7 +100,7 @@ public class DockingWindowManagerTest extends AbstractDockingTest {
|
|||
// intragroup window position.
|
||||
//
|
||||
|
||||
DockingWindowManager dwm = new DockingWindowManager("test", (List<Image>) null, null);
|
||||
DockingWindowManager dwm = new DockingWindowManager(tool, (List<Image>) null, null);
|
||||
|
||||
ComponentProvider providerA1 = addProvider(dwm, "A1", "a", RIGHT, WINDOW);
|
||||
ComponentProvider providerA2 = addProvider(dwm, "A2", "a", LEFT, WINDOW);
|
||||
|
@ -122,7 +121,7 @@ public class DockingWindowManagerTest extends AbstractDockingTest {
|
|||
//
|
||||
|
||||
// note: the positions specified here are for default positions, not intragroup positions
|
||||
DockingWindowManager dwm = new DockingWindowManager("test", (List<Image>) null, null);
|
||||
DockingWindowManager dwm = new DockingWindowManager(tool, (List<Image>) null, null);
|
||||
|
||||
ComponentProvider providerA = addProvider(dwm, "A", "a", RIGHT, STACK);
|
||||
ComponentProvider providerAB = addProvider(dwm, "AB", "a.b", BOTTOM, STACK);
|
||||
|
@ -143,7 +142,7 @@ public class DockingWindowManagerTest extends AbstractDockingTest {
|
|||
//
|
||||
|
||||
// note: the positions specified here are for default positions, not intragroup positions
|
||||
DockingWindowManager dwm = new DockingWindowManager("test", (List<Image>) null, null);
|
||||
DockingWindowManager dwm = new DockingWindowManager(tool, (List<Image>) null, null);
|
||||
|
||||
ComponentProvider providerA = addProvider(dwm, "A", "a", RIGHT, BOTTOM);
|
||||
ComponentProvider providerAB = addProvider(dwm, "AB", "a.b", BOTTOM, TOP);
|
||||
|
@ -181,8 +180,7 @@ public class DockingWindowManagerTest extends AbstractDockingTest {
|
|||
// Test that, for unrelated groups, the layout info stored in XML is re-used when providers
|
||||
// are shown after that XML is restored--even if the window positioning changes
|
||||
//
|
||||
final DockingWindowManager dwm1 =
|
||||
new DockingWindowManager("test", (List<Image>) null, null);
|
||||
final DockingWindowManager dwm1 = new DockingWindowManager(tool, (List<Image>) null, null);
|
||||
|
||||
ComponentProvider providerA = addProvider(dwm1, "A", "a", RIGHT);
|
||||
ComponentProvider providerB = addProvider(dwm1, "B", "b", BOTTOM);
|
||||
|
@ -217,7 +215,7 @@ public class DockingWindowManagerTest extends AbstractDockingTest {
|
|||
// Test that, for related groups, the layout info stored in XML is re-used when providers
|
||||
// are shown after that XML is restored--even if the window positioning changes
|
||||
//
|
||||
DockingWindowManager dwm1 = new DockingWindowManager("test", (List<Image>) null, null);
|
||||
DockingWindowManager dwm1 = new DockingWindowManager(tool, (List<Image>) null, null);
|
||||
|
||||
ComponentProvider providerA = addProvider(dwm1, "A", "a", RIGHT);
|
||||
ComponentProvider providerAB = addProvider(dwm1, "AB", "a.b", BOTTOM);
|
||||
|
@ -253,7 +251,7 @@ public class DockingWindowManagerTest extends AbstractDockingTest {
|
|||
// and that a subgroup 'a.b' will open relative to the parent. **Make sure that this
|
||||
// works when the parent is the first provider open.
|
||||
//
|
||||
DockingWindowManager dwm = new DockingWindowManager("test", (List<Image>) null, null);
|
||||
DockingWindowManager dwm = new DockingWindowManager(tool, (List<Image>) null, null);
|
||||
|
||||
ComponentProvider providerA = addProvider(dwm, "A", "a", TOP, RIGHT);
|
||||
ComponentProvider providerAB = addProvider(dwm, "AB", "a.b", RIGHT, BOTTOM);
|
||||
|
@ -270,7 +268,7 @@ public class DockingWindowManagerTest extends AbstractDockingTest {
|
|||
// and that a subgroup 'a.b' will open relative to the parent. **Make sure that this
|
||||
// works when the subgroup is the first provider open.
|
||||
//
|
||||
DockingWindowManager dwm = new DockingWindowManager("test", (List<Image>) null, null);
|
||||
DockingWindowManager dwm = new DockingWindowManager(tool, (List<Image>) null, null);
|
||||
|
||||
ComponentProvider providerAB = addProvider(dwm, "AB", "a.b", RIGHT, BOTTOM);
|
||||
ComponentProvider providerA = addProvider(dwm, "A", "a", TOP, RIGHT);
|
||||
|
@ -288,7 +286,7 @@ public class DockingWindowManagerTest extends AbstractDockingTest {
|
|||
// Test that two providers that don't share an owner (the plugin) can share a group and
|
||||
// open relative to each other.
|
||||
//
|
||||
DockingWindowManager dwm = new DockingWindowManager("test", (List<Image>) null, null);
|
||||
DockingWindowManager dwm = new DockingWindowManager(tool, (List<Image>) null, null);
|
||||
|
||||
ComponentProvider p1 = addProvider(dwm, "Owner_1", "Name_1", "group", TOP, TOP);
|
||||
ComponentProvider p2 = addProvider(dwm, "Owner_2", "Name_2", "group", BOTTOM, RIGHT);
|
||||
|
@ -337,7 +335,7 @@ public class DockingWindowManagerTest extends AbstractDockingTest {
|
|||
|
||||
*/
|
||||
|
||||
DockingWindowManager dwm = new DockingWindowManager("test", (List<Image>) null, null);
|
||||
DockingWindowManager dwm = new DockingWindowManager(tool, (List<Image>) null, null);
|
||||
|
||||
ComponentProvider pA = addProvider(dwm, "Owner_1", "A", "a", LEFT, LEFT);
|
||||
ComponentProvider pB = addProvider(dwm, "Owner_2", "B", "b", RIGHT, RIGHT);
|
||||
|
@ -410,7 +408,7 @@ public class DockingWindowManagerTest extends AbstractDockingTest {
|
|||
|
||||
private DockingWindowManager createNewDockingWindowManagerFromXML(final Element element) {
|
||||
final DockingWindowManager dwm2 =
|
||||
new DockingWindowManager("text2", (List<Image>) null, null);
|
||||
new DockingWindowManager(new DummyTool("Tool2"), (List<Image>) null, null);
|
||||
|
||||
runSwing(() -> {
|
||||
dwm2.setVisible(true);
|
||||
|
|
|
@ -30,10 +30,12 @@ import org.junit.Test;
|
|||
import docking.DockingWindowManager;
|
||||
import docking.test.AbstractDockingTest;
|
||||
import docking.widgets.textfield.IntegerTextField;
|
||||
import ghidra.test.DummyTool;
|
||||
|
||||
public class NumberInputDialogTest extends AbstractDockingTest {
|
||||
|
||||
private DockingWindowManager dwm = new DockingWindowManager("test", (List<Image>) null, null);
|
||||
private DockingWindowManager dwm =
|
||||
new DockingWindowManager(new DummyTool(), (List<Image>) null, null);
|
||||
private NumberInputDialog dialog;
|
||||
private JButton okButton;
|
||||
private JTextField textField;
|
||||
|
|
|
@ -28,6 +28,7 @@ import docking.widgets.filter.*;
|
|||
import docking.widgets.table.model.DirData;
|
||||
import docking.widgets.table.model.TestDataModel;
|
||||
import ghidra.test.AbstractGhidraHeadedIntegrationTest;
|
||||
import ghidra.test.DummyTool;
|
||||
import ghidra.util.table.GhidraTable;
|
||||
|
||||
public class GhidraTableFilterTest extends AbstractGhidraHeadedIntegrationTest {
|
||||
|
@ -50,7 +51,7 @@ public class GhidraTableFilterTest extends AbstractGhidraHeadedIntegrationTest {
|
|||
filteredModel = filterPanel.getTableFilterModel();
|
||||
table.setAutoLookupColumn(4);
|
||||
|
||||
winMgr = new DockingWindowManager("Tests", null, null);
|
||||
winMgr = new DockingWindowManager(new DummyTool(), null, null);
|
||||
winMgr.addComponent(new TestTableComponentProvider());
|
||||
winMgr.setVisible(true);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@ import org.jdom.Element;
|
|||
|
||||
import docking.*;
|
||||
import docking.action.DockingActionIf;
|
||||
import docking.actions.DockingToolActions;
|
||||
import ghidra.framework.model.*;
|
||||
import ghidra.framework.options.ToolOptions;
|
||||
import ghidra.framework.plugintool.PluginEvent;
|
||||
|
@ -42,6 +43,8 @@ public class DummyTool implements Tool {
|
|||
private ToolIconURL iconURL;
|
||||
private Project project;
|
||||
|
||||
private DockingToolActions toolActions = new DummyToolActions();
|
||||
|
||||
public DummyTool() {
|
||||
this(DEFAULT_NAME);
|
||||
}
|
||||
|
@ -305,6 +308,11 @@ public class DummyTool implements Tool {
|
|||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ComponentProvider getActiveComponentProvider() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showComponentProvider(ComponentProvider componentProvider, boolean visible) {
|
||||
//do nothing
|
||||
|
@ -345,6 +353,11 @@ public class DummyTool implements Tool {
|
|||
//do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionContext getGlobalContext() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatusInfo(String text) {
|
||||
//do nothing
|
||||
|
@ -389,4 +402,9 @@ public class DummyTool implements Tool {
|
|||
public void removeContextListener(DockingContextListener listener) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public DockingToolActions getToolActions() {
|
||||
return toolActions;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/* ###
|
||||
* IP: GHIDRA
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package ghidra.test;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import docking.ComponentProvider;
|
||||
import docking.action.DockingActionIf;
|
||||
import docking.actions.DockingToolActions;
|
||||
|
||||
public class DummyToolActions implements DockingToolActions {
|
||||
|
||||
@Override
|
||||
public void addLocalAction(ComponentProvider provider, DockingActionIf action) {
|
||||
// stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addGlobalAction(DockingActionIf action) {
|
||||
// stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeGlobalAction(DockingActionIf action) {
|
||||
// stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeActions(String owner) {
|
||||
// stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<DockingActionIf> getActions(String owner) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<DockingActionIf> getAllActions() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeLocalAction(ComponentProvider provider, DockingActionIf action) {
|
||||
// stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeActions(ComponentProvider provider) {
|
||||
// stub
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue