mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
commit
b23c8ca435
11 changed files with 60 additions and 31 deletions
|
@ -222,7 +222,8 @@ public abstract class AddressBasedGraphDisplayListener
|
||||||
graphDisplay.updateVertexName(vertex, displayName);
|
graphDisplay.updateVertexName(vertex, displayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dispose() {
|
@Override
|
||||||
|
public void dispose() {
|
||||||
Swing.runLater(() -> tool.removeListenerForAllPluginEvents(this));
|
Swing.runLater(() -> tool.removeListenerForAllPluginEvents(this));
|
||||||
program.removeListener(this);
|
program.removeListener(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,8 +125,15 @@ public abstract class AbstractGraphExporterFactory<V, E> {
|
||||||
return exporter;
|
return exporter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String getQuotedId(V vertex) {
|
||||||
|
String id = vertexIdProvider.apply(vertex);
|
||||||
|
return "\"" + id + "\"";
|
||||||
|
}
|
||||||
|
|
||||||
private GraphExporter<V, E> createDotExporter() {
|
private GraphExporter<V, E> createDotExporter() {
|
||||||
DOTExporter<V, E> exporter = new DOTExporter<>(vertexIdProvider);
|
// DOT format is picky about its identifiers, so pass in a vertex id supplier
|
||||||
|
// that wraps the vertex ids in quotes
|
||||||
|
DOTExporter<V, E> exporter = new DOTExporter<>(this::getQuotedId);
|
||||||
setupExporter(exporter);
|
setupExporter(exporter);
|
||||||
return exporter;
|
return exporter;
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,6 +39,7 @@ class ExportAttributedGraphDisplay implements GraphDisplay {
|
||||||
|
|
||||||
private final PluginTool pluginTool;
|
private final PluginTool pluginTool;
|
||||||
private String title;
|
private String title;
|
||||||
|
private AttributedGraph graph;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the initial display, the graph-less visualization viewer, and its controls
|
* Create the initial display, the graph-less visualization viewer, and its controls
|
||||||
|
@ -55,7 +56,8 @@ class ExportAttributedGraphDisplay implements GraphDisplay {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGraphDisplayListener(GraphDisplayListener listener) {
|
public void setGraphDisplayListener(GraphDisplayListener listener) {
|
||||||
// This display is not interactive, so N/A
|
// This display is not interactive, so just dispose the listener
|
||||||
|
listener.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -86,10 +88,11 @@ class ExportAttributedGraphDisplay implements GraphDisplay {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGraph(AttributedGraph graphData, String title, boolean append,
|
public void setGraph(AttributedGraph graph, String title, boolean append,
|
||||||
TaskMonitor monitor) {
|
TaskMonitor monitor) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
doSetGraphData(graphData);
|
this.graph = graph;
|
||||||
|
doSetGraphData(graph);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -132,7 +135,7 @@ class ExportAttributedGraphDisplay implements GraphDisplay {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AttributedGraph getGraph() {
|
public AttributedGraph getGraph() {
|
||||||
return null;
|
return graph;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -276,14 +276,14 @@ public class GraphExporterDialog extends DialogComponentProvider {
|
||||||
GraphExportFormat exporterFormat = getSelectedExporter();
|
GraphExportFormat exporterFormat = getSelectedExporter();
|
||||||
File outputFile = getSelectedOutputFile();
|
File outputFile = getSelectedOutputFile();
|
||||||
|
|
||||||
try {
|
if (outputFile.exists() &&
|
||||||
if (outputFile.exists() &&
|
|
||||||
OptionDialog.showOptionDialog(getComponent(), "Overwrite Existing File?",
|
OptionDialog.showOptionDialog(getComponent(), "Overwrite Existing File?",
|
||||||
"The file " + outputFile + " already exists.\nDo you want to overwrite it?",
|
"The file " + outputFile + " already exists.\nDo you want to overwrite it?",
|
||||||
"Overwrite", OptionDialog.QUESTION_MESSAGE) != OptionDialog.OPTION_ONE) {
|
"Overwrite", OptionDialog.QUESTION_MESSAGE) != OptionDialog.OPTION_ONE) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Writer writer = new FileWriter(outputFile);
|
|
||||||
|
try (Writer writer = new FileWriter(outputFile)) {
|
||||||
|
|
||||||
GraphExporter<AttributedVertex, AttributedEdge> exporter =
|
GraphExporter<AttributedVertex, AttributedEdge> exporter =
|
||||||
AttributedGraphExporterFactory.getExporter(exporterFormat);
|
AttributedGraphExporterFactory.getExporter(exporterFormat);
|
||||||
|
|
|
@ -167,6 +167,10 @@ public class DockableHeader extends GenericHeader
|
||||||
|
|
||||||
private Animator emphasizeDockableComponent() {
|
private Animator emphasizeDockableComponent() {
|
||||||
|
|
||||||
|
if (!AnimationUtils.isAnimationEnabled()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
ComponentPlaceholder placeholder = dockComp.getComponentWindowingPlaceholder();
|
ComponentPlaceholder placeholder = dockComp.getComponentWindowingPlaceholder();
|
||||||
ComponentNode node = placeholder.getNode();
|
ComponentNode node = placeholder.getNode();
|
||||||
WindowNode windowNode = node.getTopLevelNode();
|
WindowNode windowNode = node.getTopLevelNode();
|
||||||
|
|
|
@ -26,6 +26,7 @@ import org.jdesktop.animation.timing.TimingTargetAdapter;
|
||||||
import org.jdesktop.animation.timing.interpolation.PropertySetter;
|
import org.jdesktop.animation.timing.interpolation.PropertySetter;
|
||||||
|
|
||||||
import docking.action.DockingActionIf;
|
import docking.action.DockingActionIf;
|
||||||
|
import docking.util.AnimationUtils;
|
||||||
import docking.widgets.VariableHeightPanel;
|
import docking.widgets.VariableHeightPanel;
|
||||||
import docking.widgets.label.GDLabel;
|
import docking.widgets.label.GDLabel;
|
||||||
|
|
||||||
|
@ -100,6 +101,7 @@ public class GenericHeader extends JPanel {
|
||||||
/**
|
/**
|
||||||
* Signals whether or not to break the toolbar actions into multiple rows. The default is
|
* Signals whether or not to break the toolbar actions into multiple rows. The default is
|
||||||
* to wrap as necessary.
|
* to wrap as necessary.
|
||||||
|
* @param noWrap true signals not to break the actions into multiple rows
|
||||||
*/
|
*/
|
||||||
public void setNoWrapToolbar(boolean noWrap) {
|
public void setNoWrapToolbar(boolean noWrap) {
|
||||||
useSingleLineLayoutOverride = noWrap;
|
useSingleLineLayoutOverride = noWrap;
|
||||||
|
@ -254,6 +256,10 @@ public class GenericHeader extends JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Animator createEmphasizingAnimator() {
|
protected Animator createEmphasizingAnimator() {
|
||||||
|
if (!AnimationUtils.isAnimationEnabled()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
TitleFlasher titleFlasher = new TitleFlasher();
|
TitleFlasher titleFlasher = new TitleFlasher();
|
||||||
return titleFlasher.animator;
|
return titleFlasher.animator;
|
||||||
}
|
}
|
||||||
|
@ -262,10 +268,6 @@ public class GenericHeader extends JPanel {
|
||||||
return titlePanel.isSelected();
|
return titlePanel.isSelected();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the title displayed within the header
|
|
||||||
* @param title
|
|
||||||
*/
|
|
||||||
public void setTitle(String title) {
|
public void setTitle(String title) {
|
||||||
titlePanel.setTitle(title);
|
titlePanel.setTitle(title);
|
||||||
}
|
}
|
||||||
|
@ -389,10 +391,6 @@ public class GenericHeader extends JPanel {
|
||||||
titleLabel.setToolTipText(s);
|
titleLabel.setToolTipText(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the Icon for this header
|
|
||||||
* @param icon
|
|
||||||
*/
|
|
||||||
void setIcon(Icon icon) {
|
void setIcon(Icon icon) {
|
||||||
|
|
||||||
icon = DockingUtils.scaleIconAsNeeded(icon);
|
icon = DockingUtils.scaleIconAsNeeded(icon);
|
||||||
|
|
|
@ -257,16 +257,7 @@ public class JungPickingGraphMousePlugin<V, E> extends AbstractGraphMousePlugin
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void mouseReleased(MouseEvent e) {
|
public void mouseReleased(MouseEvent e) {
|
||||||
VisualizationViewer<V, E> vv = (VisualizationViewer<V, E>) e.getSource();
|
VisualizationViewer<V, E> vv = (VisualizationViewer<V, E>) e.getSource();
|
||||||
if (e.getModifiersEx() == modifiers) {
|
if (e.getModifiersEx() == this.addToSelectionModifiers) {
|
||||||
if (down != null) {
|
|
||||||
Point2D out = e.getPoint();
|
|
||||||
|
|
||||||
if (vertex == null && heyThatsTooClose(down, out, 5) == false) {
|
|
||||||
pickContainedVertices(vv, down, out, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (e.getModifiersEx() == this.addToSelectionModifiers) {
|
|
||||||
if (down != null) {
|
if (down != null) {
|
||||||
Point2D out = e.getPoint();
|
Point2D out = e.getPoint();
|
||||||
|
|
||||||
|
@ -275,6 +266,19 @@ public class JungPickingGraphMousePlugin<V, E> extends AbstractGraphMousePlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
// Mouse released without the 'add to selection' modifiers. See if we have been dragging
|
||||||
|
if (down != null) {
|
||||||
|
// check to see if we were dragging (no vertex picked and a large enough rectangle)
|
||||||
|
Point2D out = e.getPoint();
|
||||||
|
if (vertex == null && heyThatsTooClose(down, out, 5) == false) {
|
||||||
|
pickContainedVertices(vv, down, out, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
down = null;
|
down = null;
|
||||||
vertex = null;
|
vertex = null;
|
||||||
edge = null;
|
edge = null;
|
||||||
|
|
|
@ -151,9 +151,6 @@ public class VisualGraphPickingGraphMousePlugin<V extends VisualVertex, E extend
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void mouseReleased(MouseEvent e) {
|
public void mouseReleased(MouseEvent e) {
|
||||||
if (!checkModifiers(e)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// We overrode this method here to clear the picked state of edges and vertices if we
|
// We overrode this method here to clear the picked state of edges and vertices if we
|
||||||
// ever get a released event when the user is clicking somewhere that is not an edge or
|
// ever get a released event when the user is clicking somewhere that is not an edge or
|
||||||
|
|
|
@ -39,4 +39,9 @@ public class DummyGraphDisplayListener implements GraphDisplayListener {
|
||||||
// I'm a dummy
|
// I'm a dummy
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
// I'm a dummy
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,4 +49,9 @@ public interface GraphDisplayListener {
|
||||||
*/
|
*/
|
||||||
public GraphDisplayListener cloneWith(GraphDisplay graphDisplay);
|
public GraphDisplayListener cloneWith(GraphDisplay graphDisplay);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tells the listener that it is no longer needed and it can release any listeners/resources
|
||||||
|
*/
|
||||||
|
public void dispose();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -500,6 +500,11 @@ public class GraphActionTest extends AbstractGhidraHeadedIntegrationTest {
|
||||||
return new TestGraphDisplayListener("clone");
|
return new TestGraphDisplayListener("clone");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dispose() {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class GraphSpy {
|
class GraphSpy {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue