GP-808 Added Display as Graph action to the Datatype Manager

This commit is contained in:
ghidra42 2021-02-26 19:10:08 +00:00
parent 22675e9f39
commit ae40102420
7 changed files with 523 additions and 3 deletions

View file

@ -1,123 +0,0 @@
/* ###
* 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.graph.program;
import java.util.HashSet;
import java.util.Set;
import docking.action.DockingActionIf;
import docking.widgets.EventTrigger;
import ghidra.service.graph.*;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor;
public class TestGraphDisplay implements GraphDisplay {
private Set<String> definedVertexAttributes = new HashSet<>();
private Set<String> definedEdgeAttributes = new HashSet<>();
private AttributedGraph graph;
private String title;
private GraphDisplayListener listener;
private AttributedVertex focusedVertex;
private Set<AttributedVertex> currentSelection;
@Override
public void setGraphDisplayListener(GraphDisplayListener listener) {
this.listener = listener;
}
@Override
public void setFocusedVertex(AttributedVertex vertex, EventTrigger eventTrigger) {
focusedVertex = vertex;
}
@Override
public AttributedVertex getFocusedVertex() {
return focusedVertex;
}
@Override
public void selectVertices(Set<AttributedVertex> vertexList, EventTrigger eventTrigger) {
currentSelection = vertexList;
}
@Override
public Set<AttributedVertex> getSelectedVertices() {
return currentSelection;
}
@Override
public void close() {
// nothing
}
@Override
public void defineVertexAttribute(String name) {
definedVertexAttributes.add(name);
}
@Override
public void defineEdgeAttribute(String name) {
definedEdgeAttributes.add(name);
}
@Override
public void setVertexLabelAttribute(String attributeName, int alignment, int size,
boolean monospace,
int maxLines) {
// nothing
}
@Override
public void setGraph(AttributedGraph graph, String title, boolean append,
TaskMonitor monitor)
throws CancelledException {
this.graph = graph;
this.title = title;
}
@Override
public void clear() {
// nothing
}
@Override
public void updateVertexName(AttributedVertex vertex, String newName) {
// nothing
}
@Override
public String getGraphTitle() {
return title;
}
@Override
public AttributedGraph getGraph() {
return graph;
}
public void focusChanged(AttributedVertex vertex) {
listener.locationFocusChanged(vertex);
}
public void selectionChanged(Set<AttributedVertex> vertices) {
listener.selectionChanged(vertices);
}
@Override
public void addAction(DockingActionIf action) {
// do nothing, actions are not supported by this display
}
}

View file

@ -1,62 +0,0 @@
/* ###
* 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.graph.program;
import ghidra.framework.options.Options;
import ghidra.framework.plugintool.PluginTool;
import ghidra.service.graph.GraphDisplay;
import ghidra.service.graph.GraphDisplayProvider;
import ghidra.util.HelpLocation;
import ghidra.util.exception.GraphException;
import ghidra.util.task.TaskMonitor;
public class TestGraphService implements GraphDisplayProvider {
private TestGraphDisplay testDisplay = new TestGraphDisplay();
@Override
public String getName() {
return "Test Graph Service";
}
@Override
public GraphDisplay getGraphDisplay(boolean reuseGraph,
TaskMonitor monitor) throws GraphException {
return testDisplay;
}
@Override
public void initialize(PluginTool tool, Options options) {
// nothing
}
@Override
public void optionsChanged(Options options) {
// nothing
}
@Override
public void dispose() {
// nothing
}
@Override
public HelpLocation getHelpLocation() {
return null;
}
}