GP-3349 added support for mulitple default action context providers. Previously, all default (non-focused) context was provided by the Listing. Now the default provider is registered for each ActionContext class.

This commit is contained in:
ghidragon 2023-05-08 12:30:01 -04:00
parent 8aa9c8be3a
commit 5da5af23fb
149 changed files with 1354 additions and 1232 deletions

View file

@ -24,8 +24,7 @@ import javax.swing.JPanel;
import org.jdom.Element;
import docking.ActionContext;
import docking.DialogComponentProvider;
import docking.*;
import docking.action.*;
import docking.widgets.OptionDialog;
import ghidra.app.util.viewer.format.*;
@ -122,7 +121,7 @@ public class SetFormatDialogComponentProvider extends DialogComponentProvider {
FieldHeader headerPanel = listingPanel.getFieldHeader();
if (headerPanel != null && headerPanel.isAncestorOf(event.getComponent())) {
FieldHeaderLocation fhLoc = headerPanel.getFieldHeaderLocation(event.getPoint());
return new ActionContext().setContextObject(fhLoc);
return new DefaultActionContext().setContextObject(fhLoc);
}
return null;
}

View file

@ -15,11 +15,11 @@
*/
package ghidra.app.plugin.core.functiongraph.action;
import docking.ActionContext;
import docking.DefaultActionContext;
import ghidra.app.plugin.core.functiongraph.FGProvider;
import ghidra.graph.viewer.actions.VisualGraphSatelliteActionContext;
public class FunctionGraphSatelliteViewerActionContext extends ActionContext
public class FunctionGraphSatelliteViewerActionContext extends DefaultActionContext
implements VisualGraphSatelliteActionContext {
public FunctionGraphSatelliteViewerActionContext(FGProvider functionGraphProvider) {

View file

@ -172,12 +172,12 @@ public abstract class AbstractFunctionGraphTest extends AbstractGhidraHeadedInte
// 01002239
/*
A
|->B
C
*/
// A
@ -212,7 +212,7 @@ public abstract class AbstractFunctionGraphTest extends AbstractGhidraHeadedInte
private void build_ghidra(ToyProgramBuilder builder) throws MemoryAccessException {
/*
Originally from notepad 'ghidra'
A
|-> B
|-> C
@ -224,7 +224,7 @@ public abstract class AbstractFunctionGraphTest extends AbstractGhidraHeadedInte
|-> G
|
H
*/
// A -
@ -311,7 +311,7 @@ public abstract class AbstractFunctionGraphTest extends AbstractGhidraHeadedInte
private void build_sscanf(ToyProgramBuilder builder) throws MemoryAccessException {
/*
Originally from notepad 'sscanf'
A
|-> B
|
@ -322,7 +322,7 @@ public abstract class AbstractFunctionGraphTest extends AbstractGhidraHeadedInte
F
|
G
*/
// A - 9 code units
@ -455,7 +455,7 @@ public abstract class AbstractFunctionGraphTest extends AbstractGhidraHeadedInte
Object actionManager = getInstanceField("actionManager", graphProvider);
final MultiStateDockingAction<?> action =
(MultiStateDockingAction<?>) getInstanceField("layoutAction", actionManager);
runSwing(() -> action.actionPerformed(new ActionContext()));
runSwing(() -> action.actionPerformed(new DefaultActionContext()));
// wait for the threaded graph layout code
FGController controller = getFunctionGraphController();
@ -1450,14 +1450,14 @@ public abstract class AbstractFunctionGraphTest extends AbstractGhidraHeadedInte
//
/*
0) Initial Graph
1 -> 2 -> 3 -> 4
|
*
5
*/
create12345Graph();
@ -1481,12 +1481,12 @@ public abstract class AbstractFunctionGraphTest extends AbstractGhidraHeadedInte
/*
1) Create two separate group vertices (A and B), such that A has an edge to B.
A (v:{1,2} e:{1->2, 2->3}) -> B (v:{3,4} e:{2->3,3->4,3->5})
|
*
5
*/
GroupedFunctionGraphVertex groupA = group("A", v1, v2);
@ -1499,12 +1499,12 @@ public abstract class AbstractFunctionGraphTest extends AbstractGhidraHeadedInte
/*
2) Create a third group vertex (Z) that contains a non-grouped vertex *and* one
of the other groups (B).
A (v:{1,2} e:{1->2, 2->3}) -> Z (
v:{B (v:{3,4} e:{2->3,3->4,3->5}), 5}
e:{2->3, 3->5}
)
*/
GroupedFunctionGraphVertex groupZ = group("Z", groupB, v5);
@ -1514,12 +1514,12 @@ public abstract class AbstractFunctionGraphTest extends AbstractGhidraHeadedInte
/*
3) Now, ungroup the 1 remaining originally grouped vertex (A).
1 -> 2 -> Z (
v:{B (v:{3,4} e:{2->3,3->4,3->5}), 5}
e:{2->3, 3->5}
)
*/
ungroup(groupA);
@ -1529,14 +1529,14 @@ public abstract class AbstractFunctionGraphTest extends AbstractGhidraHeadedInte
verifyEdgeCount(2);
/*
4) Now, ungroup Z and go back to having one remaining group vertex (B)
1 -> 2 -> -> B (v:{3,4} e:{2->3,3->4,3->5})
|
*
5
*/
ungroup(groupZ);
@ -1548,12 +1548,12 @@ public abstract class AbstractFunctionGraphTest extends AbstractGhidraHeadedInte
/*
5) Finally, ungroup the last group and make sure the graph is restored
1 -> 2 -> 3 -> 4
|
*
5
*/
ungroup(groupB);
@ -2297,7 +2297,7 @@ public abstract class AbstractFunctionGraphTest extends AbstractGhidraHeadedInte
DockingActionIf action = getAction(tool, "FunctionGraphPlugin", name);
ToggleDockingAction displayAction = (ToggleDockingAction) action;
setToggleActionSelected(displayAction, new ActionContext(), expectedVisible);
setToggleActionSelected(displayAction, new DefaultActionContext(), expectedVisible);
//
// // make sure the action is not already in the state we expect
// assertEquals(name + " action is not selected as expected", !expectedVisible,