From 34099f37e13e1e1e415c0a88db76043c10f3a22f Mon Sep 17 00:00:00 2001 From: Tobias Holenstein Date: Tue, 12 Jul 2022 15:03:46 +0200 Subject: [PATCH] JDK-8290069: IGV: Highlight both graphs of difference in outline --- .../IdealGraphVisualizer/Coordinator/pom.xml | 5 ++++ .../igv/coordinator/OutlineTopComponent.java | 25 +++++++++++++------ .../com/sun/hotspot/igv/data/InputGraph.java | 11 ++++++++ .../hotspot/igv/difference/Difference.java | 2 +- .../hotspot/igv/view/DiagramViewModel.java | 2 +- 5 files changed, 36 insertions(+), 9 deletions(-) diff --git a/src/utils/IdealGraphVisualizer/Coordinator/pom.xml b/src/utils/IdealGraphVisualizer/Coordinator/pom.xml index 5bdd2391302c8..e93c6d20a40e1 100644 --- a/src/utils/IdealGraphVisualizer/Coordinator/pom.xml +++ b/src/utils/IdealGraphVisualizer/Coordinator/pom.xml @@ -71,6 +71,11 @@ Util ${project.version} + + com.sun.hotspot.igv + View + ${project.version} + org.netbeans.api org-openide-util diff --git a/src/utils/IdealGraphVisualizer/Coordinator/src/main/java/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java b/src/utils/IdealGraphVisualizer/Coordinator/src/main/java/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java index db1e0e5a6f4ae..5d8c6b02c3274 100644 --- a/src/utils/IdealGraphVisualizer/Coordinator/src/main/java/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java +++ b/src/utils/IdealGraphVisualizer/Coordinator/src/main/java/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java @@ -27,9 +27,11 @@ import com.sun.hotspot.igv.coordinator.actions.*; import com.sun.hotspot.igv.data.GraphDocument; import com.sun.hotspot.igv.data.Group; +import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.services.GroupCallback; import com.sun.hotspot.igv.data.services.InputGraphProvider; import com.sun.hotspot.igv.util.LookupHistory; +import com.sun.hotspot.igv.view.EditorTopComponent; import java.awt.BorderLayout; import java.io.IOException; import java.io.ObjectInput; @@ -133,13 +135,22 @@ public void started(Group g) { // Fetch and select the latest active graph. private void updateGraphSelection() { final InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class); - if (p == null) { - return; - } - try { - manager.setSelectedNodes(new GraphNode[]{FolderNode.getGraphNode(p.getGraph())}); - } catch (Exception e) { - Exceptions.printStackTrace(e); + if (p != null) { + try { + InputGraph graph = p.getGraph(); + if (graph.isDiffGraph()) { + EditorTopComponent editor = EditorTopComponent.getActive(); + if (editor != null) { + InputGraph firstGraph = editor.getModel().getFirstGraph(); + InputGraph secondGraph = editor.getModel().getSecondGraph(); + manager.setSelectedNodes(new GraphNode[]{FolderNode.getGraphNode(firstGraph), FolderNode.getGraphNode(secondGraph)}); + } + } else { + manager.setSelectedNodes(new GraphNode[]{FolderNode.getGraphNode(graph)}); + } + } catch (Exception e) { + Exceptions.printStackTrace(e); + } } } diff --git a/src/utils/IdealGraphVisualizer/Data/src/main/java/com/sun/hotspot/igv/data/InputGraph.java b/src/utils/IdealGraphVisualizer/Data/src/main/java/com/sun/hotspot/igv/data/InputGraph.java index c218b10002d1a..f49e9d007f8e8 100644 --- a/src/utils/IdealGraphVisualizer/Data/src/main/java/com/sun/hotspot/igv/data/InputGraph.java +++ b/src/utils/IdealGraphVisualizer/Data/src/main/java/com/sun/hotspot/igv/data/InputGraph.java @@ -38,6 +38,12 @@ public class InputGraph extends Properties.Entity implements FolderElement { private Map blocks; private List blockEdges; private Map nodeToBlock; + private boolean isDiffGraph; + + public InputGraph(String name, boolean isDiffGraph) { + this(name); + this.isDiffGraph = isDiffGraph; + } public InputGraph(String name) { setName(name); @@ -46,6 +52,11 @@ public InputGraph(String name) { blocks = new LinkedHashMap<>(); blockEdges = new ArrayList<>(); nodeToBlock = new LinkedHashMap<>(); + isDiffGraph = false; + } + + public boolean isDiffGraph() { + return this.isDiffGraph; } @Override diff --git a/src/utils/IdealGraphVisualizer/Difference/src/main/java/com/sun/hotspot/igv/difference/Difference.java b/src/utils/IdealGraphVisualizer/Difference/src/main/java/com/sun/hotspot/igv/difference/Difference.java index 0b2f01c47e82a..de4e5d686a444 100644 --- a/src/utils/IdealGraphVisualizer/Difference/src/main/java/com/sun/hotspot/igv/difference/Difference.java +++ b/src/utils/IdealGraphVisualizer/Difference/src/main/java/com/sun/hotspot/igv/difference/Difference.java @@ -105,7 +105,7 @@ private static InputGraph createDiff(InputGraph a, InputGraph b, Set p } } g.getProperties().setProperty("name", "Difference"); - InputGraph graph = new InputGraph(a.getName() + ", " + b.getName()); + InputGraph graph = new InputGraph(a.getName() + ", " + b.getName(), true); g.addElement(graph); Map blocksMap = new HashMap<>(); diff --git a/src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/DiagramViewModel.java b/src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/DiagramViewModel.java index 0e2e5c888a4ec..30a494abe39b2 100644 --- a/src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/DiagramViewModel.java +++ b/src/utils/IdealGraphVisualizer/View/src/main/java/com/sun/hotspot/igv/view/DiagramViewModel.java @@ -468,7 +468,7 @@ public Diagram getDiagramToView() { Settings.get().get(Settings.NODE_SHORT_TEXT, Settings.NODE_SHORT_TEXT_DEFAULT), Settings.get().get(Settings.NODE_TINY_TEXT, Settings.NODE_TINY_TEXT_DEFAULT)); getFilterChain().apply(diagram, getSequenceFilterChain()); - if (getFirstPosition() != getSecondPosition()) { + if (graph.isDiffGraph()) { ColorFilter f = new ColorFilter(""); f.addRule(stateColorRule("same", Color.white)); f.addRule(stateColorRule("changed", Color.orange));