changeset 10726:c78097171701

made the "Remove selected graphs and groups" action work in IGV for binary graphs
author Doug Simon <doug.simon@oracle.com>
date Fri, 12 Jul 2013 14:48:30 +0200
parents 867588b3ecb4
children 9d079661cbcd
files src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Client.java src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Server.java
diffstat 5 files changed, 19 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java	Fri Jul 12 12:48:06 2013 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java	Fri Jul 12 14:48:30 2013 +0200
@@ -118,8 +118,8 @@
             }
         };
         
-        server = new Server(callback, false);
-        binaryServer = new Server(callback, true);
+        server = new Server(getDocument(), callback, false);
+        binaryServer = new Server(getDocument(), callback, true);
     }
 
     public void clear() {
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java	Fri Jul 12 12:48:06 2013 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/ImportAction.java	Fri Jul 12 14:48:30 2013 +0200
@@ -110,14 +110,14 @@
                     }
                 };
                 final GraphParser parser;
+                final OutlineTopComponent component = OutlineTopComponent.findInstance();
                 if (file.getName().endsWith(".xml")) {
                     parser = new Parser(channel, monitor, null);
                 } else if (file.getName().endsWith(".bgv")) {
-                    parser = new BinaryParser(channel, monitor, null);
+                    parser = new BinaryParser(channel, monitor, component.getDocument(), null);
                 } else {
                     parser = null;
                 }
-                final OutlineTopComponent component = OutlineTopComponent.findInstance();
                 RequestProcessor.getDefault().post(new Runnable() {
                     @Override
                     public void run() {
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java	Fri Jul 12 12:48:06 2013 +0200
+++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/BinaryParser.java	Fri Jul 12 14:48:30 2013 +0200
@@ -69,6 +69,7 @@
     private final List<Object> constantPool;
     private final ByteBuffer buffer;
     private final ReadableByteChannel channel;
+    private final GraphDocument rootDocument;
     private final Deque<Folder> folderStack;
     private final ParseMonitor monitor;
     
@@ -240,12 +241,13 @@
         }
     }
 
-    public BinaryParser(ReadableByteChannel channel, ParseMonitor monitor, GroupCallback callback) {
+    public BinaryParser(ReadableByteChannel channel, ParseMonitor monitor, GraphDocument rootDocument, GroupCallback callback) {
         this.callback = callback;
         constantPool = new ArrayList<>();
         buffer = ByteBuffer.allocateDirect(256 * 1024);
         buffer.flip();
         this.channel = channel;
+        this.rootDocument = rootDocument;
         folderStack = new LinkedList<>();
         this.monitor = monitor;
     }
@@ -527,8 +529,7 @@
 
     @Override
     public GraphDocument parse() throws IOException {
-        GraphDocument doc = new GraphDocument();
-        folderStack.push(doc);
+        folderStack.push(rootDocument);
         if (monitor != null) {
             monitor.setState("Starting parsing");
         }
@@ -542,7 +543,7 @@
         if (monitor != null) {
             monitor.setState("Finished parsing");
         }
-        return doc;
+        return rootDocument;
     }
 
     private void parseRoot() throws IOException {
--- a/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Client.java	Fri Jul 12 12:48:06 2013 +0200
+++ b/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Client.java	Fri Jul 12 14:48:30 2013 +0200
@@ -24,6 +24,7 @@
  */
 package com.sun.hotspot.igv.connection;
 
+import com.sun.hotspot.igv.data.GraphDocument;
 import com.sun.hotspot.igv.data.serialization.BinaryParser;
 import com.sun.hotspot.igv.data.serialization.Parser;
 import com.sun.hotspot.igv.data.services.GroupCallback;
@@ -34,12 +35,14 @@
 public class Client implements Runnable {
     private final boolean binary;
     private final SocketChannel socket;
+    private final GraphDocument rootDocument;
     private final GroupCallback callback;
 
-    public Client(SocketChannel socket, GroupCallback callback, boolean  binary) {
+    public Client(SocketChannel socket, GraphDocument rootDocument, GroupCallback callback, boolean  binary) {
         this.callback = callback;
         this.socket = socket;
         this.binary = binary;
+        this.rootDocument = rootDocument;
     }
 
     @Override
@@ -49,7 +52,7 @@
             final SocketChannel channel = socket;
             channel.configureBlocking(true);
             if (binary) {
-                new BinaryParser(channel, null, callback).parse();
+                new BinaryParser(channel, null, rootDocument, callback).parse();
             } else {
                 new Parser(channel, null, callback).parse();
             }
--- a/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Server.java	Fri Jul 12 12:48:06 2013 +0200
+++ b/src/share/tools/IdealGraphVisualizer/NetworkConnection/src/com/sun/hotspot/igv/connection/Server.java	Fri Jul 12 14:48:30 2013 +0200
@@ -24,6 +24,7 @@
  */
 package com.sun.hotspot.igv.connection;
 
+import com.sun.hotspot.igv.data.GraphDocument;
 import com.sun.hotspot.igv.data.services.GroupCallback;
 import com.sun.hotspot.igv.settings.Settings;
 import java.io.IOException;
@@ -43,12 +44,14 @@
 public class Server implements PreferenceChangeListener {
     private final boolean binary;
     private ServerSocketChannel serverSocket;
+    private final GraphDocument rootDocument;
     private final GroupCallback callback;
     private int port;
     private Runnable serverRunnable;
 
-    public Server(GroupCallback callback, boolean binary) {
+    public Server(GraphDocument rootDocument, GroupCallback callback, boolean binary) {
         this.binary = binary;
+        this.rootDocument = rootDocument;
         this.callback = callback;
         initializeNetwork();
         Settings.get().addPreferenceChangeListener(this);
@@ -87,7 +90,7 @@
                             clientSocket.close();
                             return;
                         }
-                        RequestProcessor.getDefault().post(new Client(clientSocket, callback, binary), 0, Thread.MAX_PRIORITY);
+                        RequestProcessor.getDefault().post(new Client(clientSocket, rootDocument, callback, binary), 0, Thread.MAX_PRIORITY);
                     } catch (IOException ex) {
                         serverSocket = null;
                         NotifyDescriptor message = new NotifyDescriptor.Message("Error during listening for incoming connections. Listening for incoming binary data is disabled.", NotifyDescriptor.ERROR_MESSAGE);