mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 18:29:37 +02:00
Test fixes
This commit is contained in:
parent
f546c8828c
commit
2f2a07c671
5 changed files with 35 additions and 8 deletions
|
@ -111,6 +111,11 @@ class ExportAttributedGraphDisplay implements GraphDisplay {
|
||||||
// do nothing, actions are not supported by this display
|
// do nothing, actions are not supported by this display
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<DockingActionIf> getActions() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AttributedVertex getFocusedVertex() {
|
public AttributedVertex getFocusedVertex() {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -601,7 +601,7 @@ public class DefaultGraphDisplay implements GraphDisplay {
|
||||||
display.setGraph(createSubGraph(), graphRenderer.getGraphDisplayOptions(),
|
display.setGraph(createSubGraph(), graphRenderer.getGraphDisplayOptions(),
|
||||||
title + " - Sub-graph", false, TaskMonitor.DUMMY);
|
title + " - Sub-graph", false, TaskMonitor.DUMMY);
|
||||||
display.setGraphDisplayListener(listener.cloneWith(display));
|
display.setGraphDisplayListener(listener.cloneWith(display));
|
||||||
copyActionsToNewGraph((DefaultGraphDisplay) display);
|
copyActionsToNewGraph(display);
|
||||||
}
|
}
|
||||||
catch (CancelledException e) {
|
catch (CancelledException e) {
|
||||||
// using Dummy, so can't happen
|
// using Dummy, so can't happen
|
||||||
|
@ -1277,10 +1277,11 @@ public class DefaultGraphDisplay implements GraphDisplay {
|
||||||
return vv;
|
return vv;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copyActionsToNewGraph(DefaultGraphDisplay display) {
|
private void copyActionsToNewGraph(GraphDisplay display) {
|
||||||
|
|
||||||
|
Collection<DockingActionIf> defaultActions = display.getActions();
|
||||||
for (DockingActionIf action : addedActions) {
|
for (DockingActionIf action : addedActions) {
|
||||||
if (display.containsAction(action)) {
|
if (defaultActions.contains(action)) {
|
||||||
// ignore actions added by the graph itself and any actions that the end user may
|
// ignore actions added by the graph itself and any actions that the end user may
|
||||||
// accidentally add more than once
|
// accidentally add more than once
|
||||||
continue;
|
continue;
|
||||||
|
@ -1288,7 +1289,6 @@ public class DefaultGraphDisplay implements GraphDisplay {
|
||||||
|
|
||||||
display.addAction(new DockingActionProxy(action));
|
display.addAction(new DockingActionProxy(action));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean containsAction(DockingActionIf action) {
|
private boolean containsAction(DockingActionIf action) {
|
||||||
|
@ -1314,6 +1314,11 @@ public class DefaultGraphDisplay implements GraphDisplay {
|
||||||
componentProvider.addLocalAction(action);
|
componentProvider.addLocalAction(action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<DockingActionIf> getActions() {
|
||||||
|
return new ArrayList<>(addedActions);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AttributedVertex getFocusedVertex() {
|
public AttributedVertex getFocusedVertex() {
|
||||||
return focusedVertex;
|
return focusedVertex;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.graph.visualization;
|
package ghidra.graph.visualization;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import docking.action.DockingActionIf;
|
import docking.action.DockingActionIf;
|
||||||
|
@ -108,6 +109,11 @@ public class DefaultGraphDisplayWrapper
|
||||||
Swing.runNow(() -> delegate.addAction(action));
|
Swing.runNow(() -> delegate.addAction(action));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<DockingActionIf> getActions() {
|
||||||
|
return Swing.runNow(() -> delegate.getActions());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(DefaultGraphDisplayWrapper other) {
|
public int compareTo(DefaultGraphDisplayWrapper other) {
|
||||||
// note: no need for call to Swing, assuming ID is immutable
|
// note: no need for call to Swing, assuming ID is immutable
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.service.graph;
|
package ghidra.service.graph;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import docking.action.DockingActionIf;
|
import docking.action.DockingActionIf;
|
||||||
|
@ -147,4 +148,11 @@ public interface GraphDisplay {
|
||||||
* @param action the action to add
|
* @param action the action to add
|
||||||
*/
|
*/
|
||||||
public void addAction(DockingActionIf action);
|
public void addAction(DockingActionIf action);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets all actions that have been added to this graph display. If this display does not
|
||||||
|
* support actions, then an empty collection will be returned.
|
||||||
|
* @return the actions
|
||||||
|
*/
|
||||||
|
public Collection<DockingActionIf> getActions();
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package ghidra.graph;
|
package ghidra.graph;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.*;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import docking.action.DockingActionIf;
|
import docking.action.DockingActionIf;
|
||||||
import docking.widgets.EventTrigger;
|
import docking.widgets.EventTrigger;
|
||||||
|
@ -62,8 +61,7 @@ public class TestGraphDisplay implements GraphDisplay {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGraph(AttributedGraph graph, String title, boolean append,
|
public void setGraph(AttributedGraph graph, String title, boolean append, TaskMonitor monitor)
|
||||||
TaskMonitor monitor)
|
|
||||||
throws CancelledException {
|
throws CancelledException {
|
||||||
if (append) {
|
if (append) {
|
||||||
this.graph = mergeGraphs(graph, this.graph);
|
this.graph = mergeGraphs(graph, this.graph);
|
||||||
|
@ -113,6 +111,11 @@ public class TestGraphDisplay implements GraphDisplay {
|
||||||
// do nothing, actions are not supported by this display
|
// do nothing, actions are not supported by this display
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<DockingActionIf> getActions() {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
private AttributedGraph mergeGraphs(AttributedGraph newGraph, AttributedGraph oldGraph) {
|
private AttributedGraph mergeGraphs(AttributedGraph newGraph, AttributedGraph oldGraph) {
|
||||||
for (AttributedVertex vertex : oldGraph.vertexSet()) {
|
for (AttributedVertex vertex : oldGraph.vertexSet()) {
|
||||||
newGraph.addVertex(vertex);
|
newGraph.addVertex(vertex);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue