changeset 3604:e4175b8b85d3

IdealGraphVisualizer: work around a Swing/NetBeans tree UI problem that occurs when mouse events are handled while the tree model is changing, e.g. when using IGV while it still receives graphs from a compiler. BasicTreeUI attempts to get the boundaries for the node associated with the location on screen, but fails and tries to access a null Rectangle, causing a user-visible NullPointerException. By implementing equals() for GraphNode, nodes for graphs that are already in the tree are not removed and re-added when updating groups, and the exception can no longer be reproduced. This potentially also resolves some redraw issues.
author Peter Hofer <peter.hofer@jku.at>
date Mon, 31 Oct 2011 15:55:13 +0100
parents 9f38ef8e075f
children 6d6a90dc12d0
files src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java
diffstat 1 files changed, 17 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java	Mon Oct 31 12:24:43 2011 +0100
+++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java	Mon Oct 31 15:55:13 2011 +0100
@@ -27,7 +27,6 @@
 import com.sun.hotspot.igv.coordinator.actions.DiffGraphCookie;
 import com.sun.hotspot.igv.coordinator.actions.GraphOpenCookie;
 import com.sun.hotspot.igv.coordinator.actions.GraphRemoveCookie;
-import com.sun.hotspot.igv.coordinator.actions.RemoveCookie;
 import com.sun.hotspot.igv.data.InputGraph;
 import com.sun.hotspot.igv.data.Properties;
 import com.sun.hotspot.igv.data.services.GraphViewer;
@@ -35,7 +34,6 @@
 import java.awt.Image;
 import javax.swing.Action;
 import org.openide.actions.OpenAction;
-import org.openide.cookies.OpenCookie;
 import org.openide.nodes.AbstractNode;
 import org.openide.nodes.Children;
 import org.openide.nodes.Sheet;
@@ -50,7 +48,7 @@
  */
 public class GraphNode extends AbstractNode {
 
-    private InputGraph graph;
+    private final InputGraph graph;
 
     /** Creates a new instance of GraphNode */
     public GraphNode(InputGraph graph) {
@@ -107,4 +105,20 @@
     public Action getPreferredAction() {
         return (Action) OpenAction.findObject(OpenAction.class, true);
     }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj instanceof GraphNode) {
+            return (graph == ((GraphNode) obj).graph);
+        }
+        return false;
+    }
+
+    @Override
+    public int hashCode() {
+        return graph.hashCode();
+    }
 }