changeset 4509:886bd4e4c080

Introduce "sharedactions" project. Share export and zoom actions between cfg and igv visualizer.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Tue, 07 Feb 2012 22:24:29 +0100
parents 7e8c901c0009
children 0f194adee462
files src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/ExportAction.java src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/ShowAllAction.java src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/ZoominAction.java src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/ZoomoutAction.java src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/graph/CfgScene.java src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/icons/autosize.gif src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/icons/zoomin.gif src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/icons/zoomout.gif src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/layer.xml src/share/tools/IdealGraphVisualizer/Editor/src/com/oracle/graal/visualizer/editor/ExportCookie.java src/share/tools/IdealGraphVisualizer/SharedActions/manifest.mf src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/Bundle.properties src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/ExportSVGAction.java src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/ExportSVGCookie.java src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/ShowAllAction.java src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/ZoomCookie.java src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/ZoomInAction.java src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/ZoomOutAction.java src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/images/autosize.gif src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/images/export.png src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/images/zoomin.gif src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/images/zoomout.gif src/share/tools/IdealGraphVisualizer/View/nbproject/project.xml src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ExportAction.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ShowAllAction.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ZoomInAction.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ZoomOutAction.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/images/export.png src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/layer.xml src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/scene/DiagramScene.java src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/scene/GraphCompilationViewer.java src/share/tools/IdealGraphVisualizer/nbproject/project.properties
diffstat 32 files changed, 401 insertions(+), 721 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/ExportAction.java	Tue Feb 07 21:45:06 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,121 +0,0 @@
-package at.ssw.visualizer.cfg.action;
-
-import at.ssw.visualizer.cfg.graph.CfgScene;
-import java.io.File;
-import javax.swing.JComponent;
-import javax.swing.JFileChooser;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import org.openide.DialogDescriptor;
-import org.openide.DialogDisplayer;
-import org.openide.util.HelpCtx;
-
-/**
- * Exports Scene to various Graphics Formats
- * 
- * @author Rumpfhuber Stefan
- */
-public class ExportAction extends AbstractCfgEditorAction {
-    
-    public static final String DESCRIPTION_SVG = "Scaleable Vector Format (.svg)";
-    public static final String DESCRIPTION_EMF = "Extended Meta File (.emf)";
-    public static final String DESCRIPTION_GIF = "Graphics Interchange Format (.gif)";    
-    public static final String EXT_GIF = "gif", EXT_EMF = "emf", EXT_SVG = "svg";
-
-    String lastDirectory = null;
-    
-    @Override
-    public void performAction() {       
-        CfgScene scene = this.getEditor();
-        JComponent view = scene.getView();
-           
-        JFileChooser chooser = new JFileChooser ();
-        chooser.setAcceptAllFileFilterUsed(false);
-        chooser.setDialogTitle (getName());
-        chooser.setDialogType (JFileChooser.SAVE_DIALOG);
-        chooser.setMultiSelectionEnabled (false);
-        chooser.setFileSelectionMode (JFileChooser.FILES_ONLY);              
-        chooser.addChoosableFileFilter(new FileNameExtensionFilter(DESCRIPTION_SVG, EXT_SVG));
-        chooser.addChoosableFileFilter(new FileNameExtensionFilter(DESCRIPTION_EMF, EXT_EMF));
-        chooser.addChoosableFileFilter(new FileNameExtensionFilter(DESCRIPTION_GIF, EXT_GIF));
-        if(lastDirectory != null)
-            chooser.setCurrentDirectory(new File(lastDirectory));
-        // TODO: chose file.
-        chooser.setSelectedFile(new File("output"));
-        
-                              
-        if (chooser.showSaveDialog (scene.getView()) != JFileChooser.APPROVE_OPTION)
-            return;
-
-        File file = chooser.getSelectedFile ();
-                
-        if(file == null)
-            return;
-                
-        FileNameExtensionFilter filter = (FileNameExtensionFilter) chooser.getFileFilter();
-        String fn = file.getAbsolutePath().toLowerCase();
-        String ext = filter.getExtensions()[0];
-        if(!fn.endsWith("." + ext)){
-            file = new File( file.getParentFile(), file.getName() + "." + ext);
-        }
-                        
-        if (file.exists ()) {
-            DialogDescriptor descriptor = new DialogDescriptor (
-                "File (" + file.getAbsolutePath () + ") already exists. Do you want to overwrite it?",
-                "File Exists", true, DialogDescriptor.YES_NO_OPTION, DialogDescriptor.NO_OPTION, null);
-                DialogDisplayer.getDefault ().createDialog (descriptor).setVisible (true);
-                    if (descriptor.getValue () != DialogDescriptor.YES_OPTION)
-                        return;
-        }   
-        
-        lastDirectory = chooser.getCurrentDirectory().getAbsolutePath();
-                        
-        /*if(ext.equals(EXT_SVG)){                   
-            SVGGraphics2D g;
-            try {                  
-                g = new SVGGraphics2D(file, scene.getBounds().getSize());                   
-                g.startExport();                
-                scene.paint(g);
-                g.endExport();
-            } catch(Exception ex){               
-            }
-        } else if (ext.equals(EXT_EMF)) {                 
-            EMFGraphics2D g;   
-            try {                                                                   
-                g = new EMFGraphics2D(file, scene.getBounds().getSize());                       
-                g.startExport();         
-                scene.paint(g);
-                g.endExport();                     
-            } catch(Exception ex){                
-            }
-        } else if (ext.equals(EXT_GIF)) { 
-            GIFGraphics2D g;
-            try {  
-                //use the view as image source to get a image with the current zoomfactor
-                //using the scene.paint() would always return a image with zoomfactor 1.0
-                g = new GIFGraphics2D(file, view);
-                g.startExport();
-                view.print(g);                     
-                g.endExport();   
-            } catch(Exception ex){
-            }
-        }  */
-        // TODO(tw): Add SVG export.
-    }          
-       
-    
-    @Override
-    public String getName() {     
-        return "Export CFG";
-    }
-    
-    @Override
-    public HelpCtx getHelpCtx() {
-        return HelpCtx.DEFAULT_HELP;
-    }
-    
-     @Override
-    protected String iconResource() {
-        return "at/ssw/visualizer/cfg/icons/disk.gif";    
-    }
-
-}
--- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/ShowAllAction.java	Tue Feb 07 21:45:06 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-package at.ssw.visualizer.cfg.action;
-
-import at.ssw.visualizer.cfg.graph.CfgScene;
-import org.openide.util.HelpCtx;
-
-
-/**
- * Adjusts the Zoom factor of the Scene to the bounds of Scroll panel 
- * to get a clean view on the whole graph.
- *
- */
-public class ShowAllAction extends AbstractCfgEditorAction {
-    
-    @Override
-    public void performAction() {    
-        CfgScene tc = getEditor();
-        if (tc != null) {
-            CfgScene scene = tc;  
-            scene.zoomScene();        
-
-        }        
-    }
-    
-    @Override
-    public HelpCtx getHelpCtx() {
-        return HelpCtx.DEFAULT_HELP;
-    }
-    
-    @Override
-    public String getName() {
-        return "Fit Scene to Window";
-    }
-    
-    @Override
-    protected String iconResource() {
-        return "at/ssw/visualizer/cfg/icons/autosize.gif";    
-    }
-          
-}   
--- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/ZoominAction.java	Tue Feb 07 21:45:06 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-package at.ssw.visualizer.cfg.action;
-
-import at.ssw.visualizer.cfg.graph.CfgScene;
-import org.openide.util.HelpCtx;
-
-
-public class ZoominAction extends AbstractCfgEditorAction {
-       
-    @Override
-    public void performAction() {
-        CfgScene tc = getEditor();
-        if (tc != null) {            
-            CfgScene scene = tc;    
-            scene.setZoomFactor(1.1);
-        }
-    }
-    
-    @Override
-    protected String iconResource() {
-        return "at/ssw/visualizer/cfg/icons/zoomin.gif";
-    }
-
-    @Override
-    public String getName() {
-        return "Zoomin";
-    }
-
-    @Override
-    public HelpCtx getHelpCtx() {
-        return HelpCtx.DEFAULT_HELP;
-    }
-}
--- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/ZoomoutAction.java	Tue Feb 07 21:45:06 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-package at.ssw.visualizer.cfg.action;
-
-import at.ssw.visualizer.cfg.graph.CfgScene;
-import org.openide.util.HelpCtx;
-
-public class ZoomoutAction extends AbstractCfgEditorAction {
-
-    @Override
-    public void performAction() {
-        CfgScene tc = getEditor();
-        if (tc != null) {   
-            CfgScene scene = tc;     
-            scene.setZoomFactor(0.9);
-        }
-    }
-    
-    @Override
-    protected String iconResource() {
-        return "at/ssw/visualizer/cfg/icons/zoomout.gif";
-    }
-       
-    @Override
-    public String getName() {
-        return "Zoomout";
-    }
-
-    @Override
-    public HelpCtx getHelpCtx() {
-        return HelpCtx.DEFAULT_HELP;
-    }
-    
-}
--- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/graph/CfgScene.java	Tue Feb 07 21:45:06 2012 +0100
+++ b/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/graph/CfgScene.java	Tue Feb 07 22:24:29 2012 +0100
@@ -15,6 +15,7 @@
 import at.ssw.visualizer.cfg.visual.WidgetCollisionCollector;
 import at.ssw.visualizer.model.cfg.BasicBlock;
 import at.ssw.visualizer.model.cfg.ControlFlowGraph;
+import com.oracle.graal.visualizer.sharedactions.ZoomCookie;
 import java.awt.Color;
 import java.awt.Dimension;
 import java.awt.Point;
@@ -62,7 +63,7 @@
 import org.openide.util.NbPreferences;
 import org.openide.util.actions.SystemAction;
 
-public final class CfgScene extends GraphScene<CfgNode, CfgEdge> implements ChangeListener {
+public final class CfgScene extends GraphScene<CfgNode, CfgEdge> implements ChangeListener, ZoomCookie {
 
     private LayerWidget mainLayer = new LayerWidget(this);
     private LayerWidget connectionLayer = new LayerWidget(this);
@@ -765,6 +766,24 @@
         });
     }
 
+    @Override
+    public void zoomIn() {
+        this.setZoomFactor(1.1);
+        this.validate();
+    }
+
+    @Override
+    public void zoomOut() {
+        this.setZoomFactor(0.9);
+        this.validate();
+    }
+
+    @Override
+    public void showAll() {
+        this.zoomScene();
+        this.validate();
+    }
+
     private class NodeNameComparator implements Comparator<CfgNode> {
 
         public int compare(CfgNode node1, CfgNode node2) {
Binary file src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/icons/autosize.gif has changed
Binary file src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/icons/zoomin.gif has changed
Binary file src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/icons/zoomout.gif has changed
--- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/layer.xml	Tue Feb 07 21:45:06 2012 +0100
+++ b/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/layer.xml	Tue Feb 07 22:24:29 2012 +0100
@@ -24,6 +24,18 @@
                     <attr name="preferencesNode" methodvalue="at.ssw.visualizer.cfg.graph.CfgScene.getPreferences"/>
                     <attr name="preferencesKey" stringvalue="loopClusters"/>
                 </file>
+                <file name="com-oracle-graal-visualizer-sharedactions-ShowAllAction.shadow">
+                    <attr name="originalFile" stringvalue="Actions/View/com-oracle-graal-visualizer-sharedactions-ShowAllAction.instance"/>
+                </file>
+                <file name="com-oracle-graal-visualizer-sharedactions-ZoomInAction.shadow">
+                    <attr name="originalFile" stringvalue="Actions/View/com-oracle-graal-visualizer-sharedactions-ZoomInAction.instance"/>
+                </file>
+                <file name="com-oracle-graal-visualizer-sharedactions-ZoomOutAction.shadow">
+                    <attr name="originalFile" stringvalue="Actions/View/com-oracle-graal-visualizer-sharedactions-ZoomOutAction.instance"/>
+                </file>
+                <file name="com-oracle-graal-visualizer-sharedactions-ExportSVGAction.shadow">
+                    <attr name="originalFile" stringvalue="Actions/File/com-oracle-graal-visualizer-sharedactions-ExportSVGAction.instance"/>
+                </file>
             </folder>
         </folder>
     </folder>
--- a/src/share/tools/IdealGraphVisualizer/Editor/src/com/oracle/graal/visualizer/editor/ExportCookie.java	Tue Feb 07 21:45:06 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package com.oracle.graal.visualizer.editor;
-
-import java.io.File;
-
-/**
- *
- * @author Thomas Wuerthinger
- */
-public interface ExportCookie {
-
-    void export(File f);
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/SharedActions/manifest.mf	Tue Feb 07 22:24:29 2012 +0100
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+OpenIDE-Module: com.oracle.graal.visualizer.sharedactions
+OpenIDE-Module-Localizing-Bundle: com/oracle/graal/visualizer/sharedactions/Bundle.properties
+OpenIDE-Module-Specification-Version: 1.0
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/Bundle.properties	Tue Feb 07 22:24:29 2012 +0100
@@ -0,0 +1,1 @@
+OpenIDE-Module-Name=SharedActions
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/ExportSVGAction.java	Tue Feb 07 22:24:29 2012 +0100
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+package com.oracle.graal.visualizer.sharedactions;
+
+import com.sun.hotspot.igv.svg.BatikSVG;
+import java.awt.Graphics2D;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.*;
+import javax.swing.JFileChooser;
+import org.openide.DialogDisplayer;
+import org.openide.NotifyDescriptor;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionRegistration;
+import org.openide.util.NbPreferences;
+
+@ActionID(id = "com.oracle.graal.visualizer.sharedactions.ExportSVGAction", category = "File")
+@ActionRegistration(displayName = "Export", iconBase = "com/oracle/graal/visualizer/sharedactions/images/export.png")
+@ActionReference(path = "Menu/File", position = 600)
+public class ExportSVGAction implements ActionListener {
+
+    private static final String PREFERENCE_DIR = "dir";
+    private ExportSVGCookie exportCookie;
+
+    public ExportSVGAction(ExportSVGCookie exportCookie) {
+        this.exportCookie = exportCookie;
+    }
+
+    @Override
+    public void actionPerformed(ActionEvent actionEvent) {
+        Graphics2D svgGenerator = BatikSVG.createGraphicsObject();
+        if (svgGenerator == null) {
+            NotifyDescriptor message = new NotifyDescriptor.Message("For export to SVG files the Batik SVG Toolkit must be intalled.", NotifyDescriptor.ERROR_MESSAGE);
+            DialogDisplayer.getDefault().notifyLater(message);
+            return;
+        }
+        
+        File f = selectFile();
+        if (f != null) {
+            exportCookie.paint(svgGenerator);
+            FileOutputStream os = null;
+            try {
+                os = new FileOutputStream(f);
+                Writer out = new OutputStreamWriter(os, "UTF-8");
+                BatikSVG.printToStream(svgGenerator, out, true);
+            } catch (FileNotFoundException e) {
+                NotifyDescriptor message = new NotifyDescriptor.Message("For export to SVG files the Batik SVG Toolkit must be intalled.", NotifyDescriptor.ERROR_MESSAGE);
+                DialogDisplayer.getDefault().notifyLater(message);
+
+            } catch (UnsupportedEncodingException e) {
+            } finally {
+                if (os != null) {
+                    try {
+                        os.close();
+                    } catch (IOException e) {
+                    }
+                }
+            }
+        }
+    }
+
+    private File selectFile() {
+        JFileChooser fc = new JFileChooser();
+        fc.setFileFilter(new javax.swing.filechooser.FileFilter() {
+
+            @Override
+            public boolean accept(File f) {
+                return true;
+            }
+
+            @Override
+            public String getDescription() {
+                return "SVG files (*.svg)";
+            }
+        });
+        fc.setCurrentDirectory(new File(NbPreferences.forModule(ExportSVGAction.class).get(PREFERENCE_DIR, "~")));
+
+
+        if (fc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
+            File file = fc.getSelectedFile();
+            if (!file.getName().contains(".")) {
+                file = new File(file.getAbsolutePath() + ".svg");
+            }
+
+            File dir = file;
+            if (!dir.isDirectory()) {
+                dir = dir.getParentFile();
+            }
+
+            NbPreferences.forModule(ExportSVGAction.class).put(PREFERENCE_DIR, dir.getAbsolutePath());
+            return file;
+        }
+
+        return null;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/ExportSVGCookie.java	Tue Feb 07 22:24:29 2012 +0100
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+package com.oracle.graal.visualizer.sharedactions;
+
+import java.awt.Graphics2D;
+
+public interface ExportSVGCookie {
+    void paint(Graphics2D g);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/ShowAllAction.java	Tue Feb 07 22:24:29 2012 +0100
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+package com.oracle.graal.visualizer.sharedactions;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionRegistration;
+
+@ActionID(id = "com.oracle.graal.visualizer.sharedactions.ShowAllAction", category = "View")
+@ActionRegistration(displayName = "Fit Scene to Window", iconBase="com/oracle/graal/visualizer/sharedactions/images/autosize.gif")
+@ActionReference(path = "Menu/View", position = 500)
+public class ShowAllAction implements ActionListener {
+    
+    private ZoomCookie zoomCookie;
+    
+    public ShowAllAction(ZoomCookie zoomCookie) {
+        this.zoomCookie = zoomCookie;
+    }
+
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        zoomCookie.showAll();
+    }
+          
+}   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/ZoomCookie.java	Tue Feb 07 22:24:29 2012 +0100
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+package com.oracle.graal.visualizer.sharedactions;
+
+public interface ZoomCookie {
+    void zoomIn();
+    void zoomOut();
+    void showAll();
+    
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/ZoomInAction.java	Tue Feb 07 22:24:29 2012 +0100
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+package com.oracle.graal.visualizer.sharedactions;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionRegistration;
+
+@ActionID(id = "com.oracle.graal.visualizer.sharedactions.ZoomInAction", category = "View")
+@ActionRegistration(displayName = "Zoom In", iconBase="com/oracle/graal/visualizer/sharedactions/images/zoomin.gif")
+@ActionReference(path = "Menu/View", position = 600)
+public class ZoomInAction implements ActionListener {
+    
+    private ZoomCookie zoomCookie;
+    
+    public ZoomInAction(ZoomCookie zoomCookie) {
+        this.zoomCookie = zoomCookie;
+    }
+
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        zoomCookie.zoomIn();
+    }
+          
+}   
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/ZoomOutAction.java	Tue Feb 07 22:24:29 2012 +0100
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ *
+ */
+package com.oracle.graal.visualizer.sharedactions;
+
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import org.openide.awt.ActionID;
+import org.openide.awt.ActionReference;
+import org.openide.awt.ActionRegistration;
+
+@ActionID(id = "com.oracle.graal.visualizer.sharedactions.ZoomOutAction", category = "View")
+@ActionRegistration(displayName = "Zoom Out", iconBase="com/oracle/graal/visualizer/sharedactions/images/zoomout.gif")
+@ActionReference(path = "Menu/View", position = 700)
+public class ZoomOutAction implements ActionListener {
+    
+    private ZoomCookie zoomCookie;
+    
+    public ZoomOutAction(ZoomCookie zoomCookie) {
+        this.zoomCookie = zoomCookie;
+    }
+
+    @Override
+    public void actionPerformed(ActionEvent e) {
+        zoomCookie.zoomOut();
+    }
+          
+}   
Binary file src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/images/autosize.gif has changed
Binary file src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/images/export.png has changed
Binary file src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/images/zoomin.gif has changed
Binary file src/share/tools/IdealGraphVisualizer/SharedActions/src/com/oracle/graal/visualizer/sharedactions/images/zoomout.gif has changed
--- a/src/share/tools/IdealGraphVisualizer/View/nbproject/project.xml	Tue Feb 07 21:45:06 2012 +0100
+++ b/src/share/tools/IdealGraphVisualizer/View/nbproject/project.xml	Tue Feb 07 22:24:29 2012 +0100
@@ -15,6 +15,14 @@
                     </run-dependency>
                 </dependency>
                 <dependency>
+                    <code-name-base>com.oracle.graal.visualizer.sharedactions</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>1.0</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
                     <code-name-base>com.sun.hotspot.igv.data</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ExportAction.java	Tue Feb 07 21:45:06 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,118 +0,0 @@
-/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-package com.sun.hotspot.igv.view.actions;
-
-import com.sun.hotspot.igv.settings.Settings;
-import com.oracle.graal.visualizer.editor.ExportCookie;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
-import java.io.File;
-import javax.swing.Action;
-import javax.swing.JFileChooser;
-import javax.swing.KeyStroke;
-import javax.swing.filechooser.FileFilter;
-import org.openide.util.*;
-import org.openide.util.actions.CallableSystemAction;
-
-/**
- *
- * @author Thomas Wuerthinger
- */
-public final class ExportAction extends CallableSystemAction implements LookupListener {
-
-    private final Lookup lookup;
-    private final Lookup.Result<ExportCookie> result;
-
-    public ExportAction() {
-        putValue(Action.SHORT_DESCRIPTION, "Export current graph as SVG file");
-        putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_E, InputEvent.CTRL_MASK));
-        lookup = Utilities.actionsGlobalContext();
-        result = lookup.lookup(new Lookup.Template<>(ExportCookie.class));
-        result.addLookupListener(this);
-        resultChanged(null);
-    }
-
-    @Override
-    public void resultChanged(LookupEvent e) {
-        super.setEnabled(result.allInstances().size() > 0);
-    }
-
-    @Override
-    public void performAction() {
-
-        JFileChooser fc = new JFileChooser();
-        fc.setFileFilter(new FileFilter() {
-
-            @Override
-            public boolean accept(File f) {
-                return true;
-            }
-
-            @Override
-            public String getDescription() {
-                return "SVG files (*.svg)";
-            }
-        });
-        fc.setCurrentDirectory(new File(Settings.get().get(Settings.DIRECTORY, Settings.DIRECTORY_DEFAULT)));
-
-
-        if (fc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
-            File file = fc.getSelectedFile();
-            if (!file.getName().contains(".")) {
-                file = new File(file.getAbsolutePath() + ".svg");
-            }
-
-            File dir = file;
-            if (!dir.isDirectory()) {
-                dir = dir.getParentFile();
-            }
-
-            Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath());
-            ExportCookie cookie = Utilities.actionsGlobalContext().lookup(ExportCookie.class);
-            if (cookie != null) {
-                cookie.export(file);
-            }
-        }
-    }
-
-    @Override
-    public String getName() {
-        return NbBundle.getMessage(ExportAction.class, "CTL_ExportAction");
-    }
-
-    @Override
-    protected String iconResource() {
-        return "com/sun/hotspot/igv/view/images/export.png";
-    }
-
-    @Override
-    public HelpCtx getHelpCtx() {
-        return HelpCtx.DEFAULT_HELP;
-    }
-
-    @Override
-    protected boolean asynchronous() {
-        return false;
-    }
-}
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ShowAllAction.java	Tue Feb 07 21:45:06 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-package com.sun.hotspot.igv.view.actions;
-
-import com.oracle.graal.visualizer.editor.EditorTopComponent;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
-import javax.swing.Action;
-import javax.swing.KeyStroke;
-import org.openide.awt.ActionID;
-import org.openide.awt.ActionReference;
-import org.openide.awt.ActionRegistration;
-import org.openide.util.HelpCtx;
-import org.openide.util.actions.CallableSystemAction;
-
-/**
- *
- * @author Thomas Wuerthinger
- */
-@ActionID(id = "com.sun.hotspot.igv.view.actions.ShowAllAction", category = "View")
-@ActionRegistration(displayName = "Show all nodes")
-@ActionReference(path = "Menu/View", position = 200)
-public final class ShowAllAction extends CallableSystemAction {
-
-    @Override
-    public void performAction() {
-        EditorTopComponent editor = EditorTopComponent.getActive();
-        if (editor != null) {
-            //editor.showAll();
-        }
-    }
-
-    public ShowAllAction() {
-        putValue(Action.SHORT_DESCRIPTION, "Show all nodes");
-        putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_A, InputEvent.CTRL_MASK));
-    }
-
-    @Override
-    public String getName() {
-        return "Show all";
-    }
-
-    @Override
-    protected void initialize() {
-        super.initialize();
-    }
-
-    @Override
-    public HelpCtx getHelpCtx() {
-        return HelpCtx.DEFAULT_HELP;
-    }
-
-    @Override
-    protected boolean asynchronous() {
-        return false;
-    }
-
-    @Override
-    protected String iconResource() {
-        return "com/sun/hotspot/igv/view/images/expand.gif";
-    }
-}
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ZoomInAction.java	Tue Feb 07 21:45:06 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-package com.sun.hotspot.igv.view.actions;
-
-import com.oracle.graal.visualizer.editor.EditorTopComponent;
-import com.sun.hotspot.igv.view.scene.DiagramScene;
-import com.sun.hotspot.igv.view.scene.GraphCompilationViewer;
-import java.awt.Event;
-import java.awt.event.KeyEvent;
-import javax.swing.Action;
-import javax.swing.KeyStroke;
-import org.openide.awt.ActionID;
-import org.openide.awt.ActionReference;
-import org.openide.awt.ActionRegistration;
-import org.openide.util.HelpCtx;
-import org.openide.util.actions.CallableSystemAction;
-
-/**
- *
- * @author Thomas Wuerthinger
- */
-public final class ZoomInAction extends CallableSystemAction {
-    private final DiagramScene scene;
-
-    @Override
-    public void performAction() {
-        scene.zoomIn();
-    }
-
-    @Override
-    public String getName() {
-        return "Zoom in";
-    }
-
-    public ZoomInAction(DiagramScene scene) {
-        this.scene = scene;
-        putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, Event.CTRL_MASK, false));
-        putValue(Action.SHORT_DESCRIPTION, "Zoom in");
-    }
-
-    @Override
-    public HelpCtx getHelpCtx() {
-        return HelpCtx.DEFAULT_HELP;
-    }
-
-    @Override
-    protected boolean asynchronous() {
-        return false;
-    }
-
-    @Override
-    protected String iconResource() {
-        return "com/sun/hotspot/igv/view/images/zoom_in.png";
-    }
-}
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/actions/ZoomOutAction.java	Tue Feb 07 21:45:06 2012 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- *
- */
-package com.sun.hotspot.igv.view.actions;
-
-import com.oracle.graal.visualizer.editor.EditorTopComponent;
-import com.sun.hotspot.igv.view.scene.DiagramScene;
-import com.sun.hotspot.igv.view.scene.GraphCompilationViewer;
-import java.awt.Event;
-import java.awt.event.KeyEvent;
-import javax.swing.Action;
-import javax.swing.KeyStroke;
-import org.openide.awt.ActionID;
-import org.openide.awt.ActionReference;
-import org.openide.awt.ActionRegistration;
-import org.openide.util.HelpCtx;
-import org.openide.util.actions.CallableSystemAction;
-
-/**
- *
- * @author Thomas Wuerthinger
- */
-public final class ZoomOutAction extends CallableSystemAction {
-    private final DiagramScene scene;
-
-    @Override
-    public void performAction() {
-        scene.zoomOut();
-    }
-
-    public ZoomOutAction(DiagramScene scene) {
-        this.scene = scene;
-        putValue(Action.SHORT_DESCRIPTION, "Zoom out");
-        putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, Event.CTRL_MASK, false));
-    }
-
-    @Override
-    public String getName() {
-        return "Zoom out";
-    }
-
-    @Override
-    protected void initialize() {
-        super.initialize();
-    }
-
-    @Override
-    public HelpCtx getHelpCtx() {
-        return HelpCtx.DEFAULT_HELP;
-    }
-
-    @Override
-    protected boolean asynchronous() {
-        return false;
-    }
-
-    @Override
-    protected String iconResource() {
-        return "com/sun/hotspot/igv/view/images/zoom_out.png";
-    }
-}
Binary file src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/images/export.png has changed
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/layer.xml	Tue Feb 07 21:45:06 2012 +0100
+++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/layer.xml	Tue Feb 07 22:24:29 2012 +0100
@@ -1,4 +1,22 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
 <filesystem>
+    <folder name="CompilationViewer">
+        <folder name="Graph">
+            <folder name="Actions">
+                <file name="com-oracle-graal-visualizer-sharedactions-ShowAllAction.shadow">
+                    <attr name="originalFile" stringvalue="Actions/View/com-oracle-graal-visualizer-sharedactions-ShowAllAction.instance"/>
+                </file>
+                <file name="com-oracle-graal-visualizer-sharedactions-ZoomInAction.shadow">
+                    <attr name="originalFile" stringvalue="Actions/View/com-oracle-graal-visualizer-sharedactions-ZoomInAction.instance"/>
+                </file>
+                <file name="com-oracle-graal-visualizer-sharedactions-ZoomOutAction.shadow">
+                    <attr name="originalFile" stringvalue="Actions/View/com-oracle-graal-visualizer-sharedactions-ZoomOutAction.instance"/>
+                </file>
+                <file name="com-oracle-graal-visualizer-sharedactions-ExportSVGAction.shadow">
+                    <attr name="originalFile" stringvalue="Actions/File/com-oracle-graal-visualizer-sharedactions-ExportSVGAction.instance"/>
+                </file>
+            </folder>
+        </folder>
+    </folder>
 </filesystem>
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/scene/DiagramScene.java	Tue Feb 07 21:45:06 2012 +0100
+++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/scene/DiagramScene.java	Tue Feb 07 22:24:29 2012 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,8 +24,9 @@
 package com.sun.hotspot.igv.view.scene;
 
 import com.oracle.graal.visualizer.editor.DiagramViewModel;
+import com.oracle.graal.visualizer.sharedactions.ExportSVGCookie;
+import com.oracle.graal.visualizer.sharedactions.ZoomCookie;
 import com.sun.hotspot.igv.data.ChangedListener;
-import com.sun.hotspot.igv.data.ControllableChangedListener;
 import com.sun.hotspot.igv.data.Pair;
 import com.sun.hotspot.igv.data.Properties;
 import com.sun.hotspot.igv.graph.*;
@@ -46,7 +47,6 @@
 import org.netbeans.api.visual.model.*;
 import org.netbeans.api.visual.widget.LayerWidget;
 import org.netbeans.api.visual.widget.Widget;
-import org.openide.awt.UndoRedo;
 import org.openide.nodes.AbstractNode;
 import org.openide.nodes.Children;
 import org.openide.nodes.Sheet;
@@ -54,11 +54,7 @@
 import org.openide.util.lookup.AbstractLookup;
 import org.openide.util.lookup.InstanceContent;
 
-/**
- *
- * @author Thomas Wuerthinger
- */
-public class DiagramScene extends ObjectScene {
+public class DiagramScene extends ObjectScene implements ExportSVGCookie, ZoomCookie {
 
     private CustomizablePanWidgetAction panAction;
     private WidgetAction hoverAction;
@@ -121,15 +117,6 @@
         return (T) w;
     }
 
-    private static boolean intersects(Set<? extends Object> s1, Set<? extends Object> s2) {
-        for (Object o : s1) {
-            if (s2.contains(o)) {
-                return true;
-            }
-        }
-        return false;
-    }
-
     public void zoomOut() {
         double zoom = getZoomFactor();
         Point viewPosition = getScrollPane().getViewport().getViewPosition();
@@ -157,21 +144,6 @@
         gotoFigures(list);
     }
 
-    private Set<Object> getObjectsFromIdSet(Set<Object> set) {
-        Set<Object> selectedObjects = new HashSet<>();
-        for (Figure f : getModel().getDiagramToView().getFigures()) {
-            if (intersects(f.getSource().getSourceNodesAsSet(), set)) {
-                selectedObjects.add(f);
-            }
-
-            for (Slot s : f.getSlots()) {
-                if (intersects(s.getSource().getSourceNodesAsSet(), set)) {
-                    selectedObjects.add(s);
-                }
-            }
-        }
-        return selectedObjects;
-    }
     private RectangularSelectProvider rectangularSelectProvider = new RectangularSelectProvider() {
 
         @Override
@@ -342,6 +314,7 @@
         this.model = model;
         content = new InstanceContent();
         lookup = new AbstractLookup(content);
+        content.add(this);
 
         this.setCheckClipping(true);
 
@@ -983,4 +956,9 @@
             smallUpdate(false);
         }
     };
+
+    @Override
+    public void showAll() {
+        // TODO(tw): Implement.
+    }
 }
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/scene/GraphCompilationViewer.java	Tue Feb 07 21:45:06 2012 +0100
+++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/scene/GraphCompilationViewer.java	Tue Feb 07 22:24:29 2012 +0100
@@ -27,7 +27,6 @@
 import com.sun.hotspot.igv.svg.BatikSVG;
 import com.oracle.graal.visualizer.editor.CompilationViewer;
 import com.oracle.graal.visualizer.editor.DiagramViewModel;
-import com.oracle.graal.visualizer.editor.ExportCookie;
 import com.sun.hotspot.igv.graph.Figure;
 import com.sun.hotspot.igv.view.actions.*;
 import java.awt.Component;
@@ -48,44 +47,7 @@
 public class GraphCompilationViewer implements CompilationViewer, PropertyChangeListener {
     
     private DiagramScene scene;
-    private JToolBar toolBar;
     private PredSuccAction predSuccAction;
-    
-    private ExportCookie exportCookie = new ExportCookie() {
-
-        @Override
-        public void export(File f) {
-
-            Graphics2D svgGenerator = BatikSVG.createGraphicsObject();
-
-            if (svgGenerator == null) {
-                NotifyDescriptor message = new NotifyDescriptor.Message("For export to SVG files the Batik SVG Toolkit must be intalled.", NotifyDescriptor.ERROR_MESSAGE);
-                DialogDisplayer.getDefault().notifyLater(message);
-            } else {
-                scene.paint(svgGenerator);
-                FileOutputStream os = null;
-                try {
-                    os = new FileOutputStream(f);
-                    Writer out = new OutputStreamWriter(os, "UTF-8");
-                    BatikSVG.printToStream(svgGenerator, out, true);
-                } catch (FileNotFoundException e) {
-                    NotifyDescriptor message = new NotifyDescriptor.Message("For export to SVG files the Batik SVG Toolkit must be intalled.", NotifyDescriptor.ERROR_MESSAGE);
-                    DialogDisplayer.getDefault().notifyLater(message);
-
-                } catch (UnsupportedEncodingException e) {
-                } finally {
-                    if (os != null) {
-                        try {
-                            os.close();
-                        } catch (IOException e) {
-                        }
-                    }
-                }
-
-            }
-        }
-    };
-    private Lookup lookup;
 
     GraphCompilationViewer(DiagramViewModel model) {
         
@@ -95,18 +57,11 @@
         };
         
         scene.setActions(actions);
-//        predSuccAction = new PredSuccAction();
-//        JToggleButton button = new JToggleButton(predSuccAction);
-//        button.setSelected(true);
-//        toolBar.add(button);
-//        predSuccAction.addPropertyChangeListener(this);
-        
-        lookup = new ProxyLookup(scene.getLookup(), Lookups.singleton(exportCookie));
     }
 
     @Override
     public Lookup getLookup() {
-        return lookup;
+        return scene.getLookup();
     }
 
     @Override
--- a/src/share/tools/IdealGraphVisualizer/nbproject/project.properties	Tue Feb 07 21:45:06 2012 +0100
+++ b/src/share/tools/IdealGraphVisualizer/nbproject/project.properties	Tue Feb 07 22:24:29 2012 +0100
@@ -20,10 +20,12 @@
     ${project.org.eclipse.draw2d}:\
     ${project.com.oracle.graal.visualizer.editor}:\
     ${project.com.oracle.graal.visualizer.outline}:\
-    ${project.com.oracle.graal.visualizer.snapshots}
+    ${project.com.oracle.graal.visualizer.snapshots}:\
+    ${project.com.oracle.graal.visualizer.sharedactions}
 project.at.ssw.visualizer.cfg=ControlFlowEditor
 project.com.oracle.graal.visualizer.editor=Editor
 project.com.oracle.graal.visualizer.outline=OutlineView
+project.com.oracle.graal.visualizer.sharedactions=SharedActions
 project.com.oracle.graal.visualizer.snapshots=SnapshotsView
 project.com.sun.hotspot.igv.bytecodes=Bytecodes
 project.com.sun.hotspot.igv.data=Data