Merge remote-tracking branch 'origin/GP-153_ghidravore_actions--SQUASHED' into Ghidra_9.2

This commit is contained in:
ghidravore 2020-10-07 18:03:43 -04:00
commit b8a71a2ea2
24 changed files with 1142 additions and 533 deletions

View file

@ -34,4 +34,9 @@ public class DummyGraphDisplayListener implements GraphDisplayListener {
// I'm a dummy
}
@Override
public GraphDisplayListener cloneWith(GraphDisplay graphDisplay) {
return new DummyGraphDisplayListener();
}
}

View file

@ -0,0 +1,45 @@
/* ###
* 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.service.graph;
import java.util.Set;
import docking.ComponentProvider;
/**
* GraphActionContext for when user invokes a popup action on a graph edge.
*/
public class EdgeGraphActionContext extends GraphActionContext {
private AttributedEdge clickedEdge;
public EdgeGraphActionContext(ComponentProvider componentProvider,
AttributedGraph graph, Set<AttributedVertex> selectedVertices,
AttributedVertex locatedVertex, AttributedEdge clickedEdge) {
super(componentProvider, graph, selectedVertices, locatedVertex);
this.clickedEdge = clickedEdge;
}
/**
* Returns the edge from where the popup menu was launched
* @return the edge from where the popup menu was launched
*/
public AttributedEdge getClickedEdge() {
return clickedEdge;
}
}

View file

@ -0,0 +1,65 @@
/* ###
* 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.service.graph;
import java.util.Set;
import docking.ActionContext;
import docking.ComponentProvider;
/**
* The base ActionContext for the GraphDisplay instances.
*/
public class GraphActionContext extends ActionContext {
private final AttributedGraph graph;
private final Set<AttributedVertex> selectedVertices;
private final AttributedVertex focusedVertex;
public GraphActionContext(ComponentProvider componentProvider,
AttributedGraph graph, Set<AttributedVertex> selectedVertices,
AttributedVertex locatedVertex) {
super(componentProvider);
this.graph = graph;
this.selectedVertices = selectedVertices;
this.focusedVertex = locatedVertex;
}
/**
* Returns the graph
* @return the graph
*/
public AttributedGraph getGraph() {
return graph;
}
/**
* Returns the set of selectedVertices in the graph
* @return the set of selectedVertices in the graph
*/
public Set<AttributedVertex> getSelectedVertices() {
return selectedVertices;
}
/**
* Returns the focused vertex (similar concept to the cursor in a text document)
* @return the focused vertex
*/
public AttributedVertex getFocusedVertex() {
return focusedVertex;
}
}

View file

@ -16,7 +16,9 @@
package ghidra.service.graph;
import java.util.List;
import java.util.Set;
import docking.action.DockingAction;
import docking.widgets.EventTrigger;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor;
@ -55,6 +57,12 @@ public interface GraphDisplay {
*/
public void setLocationFocus(String vertexID, EventTrigger eventTrigger);
/**
* Returns the currently focused vertexID or null if no vertex is focussed.
* @return the currently focused vertexID or null if no vertex is focussed.
*/
public String getFocusedVertexId();
/**
* Tells the graph display window to select the vertices with the given ids
*
@ -68,6 +76,12 @@ public interface GraphDisplay {
*/
public void selectVertices(List<String> vertexList, EventTrigger eventTrigger);
/**
* Returns a list of vertex ids for all the currently selected vertices
* @return a list of vertex ids for all the currently selected vertices
*/
public Set<String> getSelectedVertexIds();
/**
* Closes this graph display window.
*/
@ -127,4 +141,11 @@ public interface GraphDisplay {
* @return the description of the current graph
*/
public String getGraphDescription();
/**
* Adds the action to the graph display. Not all GraphDisplays support adding custom
* actions, so this may have no effect.
* @param action the action to add.
*/
public void addAction(DockingAction action);
}

View file

@ -18,7 +18,7 @@ package ghidra.service.graph;
import java.util.List;
/**
* Interface for being notified when the user interacts with a visual graph display.
* Interface for being notified when the user interacts with a visual graph display
*/
public interface GraphDisplayListener {
/**
@ -29,18 +29,24 @@ public interface GraphDisplayListener {
/**
* Notification that the list of selected vertices has changed
*
* @param vertexIds the list of vertex ids for the currently selected vertices.
* @param vertexIds the list of vertex ids for the currently selected vertices
*/
public void selectionChanged(List<String> vertexIds);
/**
* Notification that the "focused" (active) vertex has changed.
* Notification that the "focused" (active) vertex has changed
* @param vertexId the vertex id of the currently "focused" vertex
*/
public void locationFocusChanged(String vertexId);
default boolean updateVertexName(String vertexId, String oldName, String newName) {
// no op
return false;
}
/**
* Makes a new GraphDisplayListener of the same type as the specific
* instance of this GraphDisplayListener
*
* @param graphDisplay the new {@link GraphDisplay} the new listener will support
* @return A new instance of a GraphDisplayListener that is the same type as as the instance
* on which it is called
*/
public GraphDisplayListener cloneWith(GraphDisplay graphDisplay);
}

View file

@ -0,0 +1,45 @@
/* ###
* 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.service.graph;
import java.util.Set;
import docking.ComponentProvider;
/**
* GraphActionContext for when user invokes a popup action on a graph vertex.
*/
public class VertexGraphActionContext extends GraphActionContext {
private AttributedVertex clickedVertex;
public VertexGraphActionContext(ComponentProvider componentProvider,
AttributedGraph graph, Set<AttributedVertex> selectedVertices,
AttributedVertex locatedVertex, AttributedVertex clickedVertex) {
super(componentProvider, graph, selectedVertices, locatedVertex);
this.clickedVertex = clickedVertex;
}
/**
* Returns the vertex from where the popup menu was launched
* @return the vertex from where the popup menu was launched
*/
public AttributedVertex getClickedVertex() {
return clickedVertex;
}
}