Merge remote-tracking branch 'origin/patch'

This commit is contained in:
ghidravore 2020-11-30 16:52:08 -05:00
commit b23c8ca435
11 changed files with 60 additions and 31 deletions

View file

@ -222,7 +222,8 @@ public abstract class AddressBasedGraphDisplayListener
graphDisplay.updateVertexName(vertex, displayName);
}
private void dispose() {
@Override
public void dispose() {
Swing.runLater(() -> tool.removeListenerForAllPluginEvents(this));
program.removeListener(this);
}

View file

@ -125,8 +125,15 @@ public abstract class AbstractGraphExporterFactory<V, E> {
return exporter;
}
String getQuotedId(V vertex) {
String id = vertexIdProvider.apply(vertex);
return "\"" + id + "\"";
}
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);
return exporter;
}

View file

@ -39,6 +39,7 @@ class ExportAttributedGraphDisplay implements GraphDisplay {
private final PluginTool pluginTool;
private String title;
private AttributedGraph graph;
/**
* Create the initial display, the graph-less visualization viewer, and its controls
@ -55,7 +56,8 @@ class ExportAttributedGraphDisplay implements GraphDisplay {
@Override
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
public void setGraph(AttributedGraph graphData, String title, boolean append,
public void setGraph(AttributedGraph graph, String title, boolean append,
TaskMonitor monitor) {
this.title = title;
doSetGraphData(graphData);
this.graph = graph;
doSetGraphData(graph);
}
/**
@ -132,7 +135,7 @@ class ExportAttributedGraphDisplay implements GraphDisplay {
@Override
public AttributedGraph getGraph() {
return null;
return graph;
}
@Override

View file

@ -276,14 +276,14 @@ public class GraphExporterDialog extends DialogComponentProvider {
GraphExportFormat exporterFormat = getSelectedExporter();
File outputFile = getSelectedOutputFile();
try {
if (outputFile.exists() &&
OptionDialog.showOptionDialog(getComponent(), "Overwrite Existing File?",
"The file " + outputFile + " already exists.\nDo you want to overwrite it?",
"Overwrite", OptionDialog.QUESTION_MESSAGE) != OptionDialog.OPTION_ONE) {
return false;
}
Writer writer = new FileWriter(outputFile);
try (Writer writer = new FileWriter(outputFile)) {
GraphExporter<AttributedVertex, AttributedEdge> exporter =
AttributedGraphExporterFactory.getExporter(exporterFormat);

View file

@ -167,6 +167,10 @@ public class DockableHeader extends GenericHeader
private Animator emphasizeDockableComponent() {
if (!AnimationUtils.isAnimationEnabled()) {
return null;
}
ComponentPlaceholder placeholder = dockComp.getComponentWindowingPlaceholder();
ComponentNode node = placeholder.getNode();
WindowNode windowNode = node.getTopLevelNode();

View file

@ -26,6 +26,7 @@ import org.jdesktop.animation.timing.TimingTargetAdapter;
import org.jdesktop.animation.timing.interpolation.PropertySetter;
import docking.action.DockingActionIf;
import docking.util.AnimationUtils;
import docking.widgets.VariableHeightPanel;
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
* to wrap as necessary.
* @param noWrap true signals not to break the actions into multiple rows
*/
public void setNoWrapToolbar(boolean noWrap) {
useSingleLineLayoutOverride = noWrap;
@ -254,6 +256,10 @@ public class GenericHeader extends JPanel {
}
protected Animator createEmphasizingAnimator() {
if (!AnimationUtils.isAnimationEnabled()) {
return null;
}
TitleFlasher titleFlasher = new TitleFlasher();
return titleFlasher.animator;
}
@ -262,10 +268,6 @@ public class GenericHeader extends JPanel {
return titlePanel.isSelected();
}
/**
* Sets the title displayed within the header
* @param title
*/
public void setTitle(String title) {
titlePanel.setTitle(title);
}
@ -389,10 +391,6 @@ public class GenericHeader extends JPanel {
titleLabel.setToolTipText(s);
}
/**
* Sets the Icon for this header
* @param icon
*/
void setIcon(Icon icon) {
icon = DockingUtils.scaleIconAsNeeded(icon);

View file

@ -257,16 +257,7 @@ public class JungPickingGraphMousePlugin<V, E> extends AbstractGraphMousePlugin
@SuppressWarnings("unchecked")
public void mouseReleased(MouseEvent e) {
VisualizationViewer<V, E> vv = (VisualizationViewer<V, E>) e.getSource();
if (e.getModifiersEx() == modifiers) {
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 (e.getModifiersEx() == this.addToSelectionModifiers) {
if (down != null) {
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;
vertex = null;
edge = null;

View file

@ -151,9 +151,6 @@ public class VisualGraphPickingGraphMousePlugin<V extends VisualVertex, E extend
@Override
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
// ever get a released event when the user is clicking somewhere that is not an edge or

View file

@ -39,4 +39,9 @@ public class DummyGraphDisplayListener implements GraphDisplayListener {
// I'm a dummy
}
@Override
public void dispose() {
// I'm a dummy
}
}

View file

@ -49,4 +49,9 @@ public interface GraphDisplayListener {
*/
public GraphDisplayListener cloneWith(GraphDisplay graphDisplay);
/**
* Tells the listener that it is no longer needed and it can release any listeners/resources
*/
public void dispose();
}

View file

@ -500,6 +500,11 @@ public class GraphActionTest extends AbstractGhidraHeadedIntegrationTest {
return new TestGraphDisplayListener("clone");
}
@Override
public void dispose() {
// do nothing
}
}
class GraphSpy {