# HG changeset patch # User Thomas Wuerthinger # Date 1328399185 -3600 # Node ID f721895e62e88acb1726f1dbfa020419a291241c # Parent b995eee3697062fd6b611d691e349fe094d03c96 Added snapshots view. diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Editor/src/com/oracle/graal/visualizer/editor/EditorTopComponent.java --- a/src/share/tools/IdealGraphVisualizer/Editor/src/com/oracle/graal/visualizer/editor/EditorTopComponent.java Sat Feb 04 21:41:02 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Editor/src/com/oracle/graal/visualizer/editor/EditorTopComponent.java Sun Feb 05 00:46:25 2012 +0100 @@ -132,12 +132,13 @@ this.group = graph.getGroup(); rangeSliderModel = new RangeSliderModel(calculateStringList(group)); + content = new InstanceContent(); + content.add(rangeSliderModel); int graphPos = group.getGraphs().indexOf(graph); rangeSliderModel.setPositions(graphPos, graphPos); rangeSlider = new RangeSlider(rangeSliderModel); Collection factories = Lookup.getDefault().lookupAll(CompilationViewerFactory.class); - content = new InstanceContent(); proxyLookup = Lookups.proxy(currentViewLookupProvider); this.associateLookup(new ProxyLookup(new Lookup[]{proxyLookup, new AbstractLookup(content)})); diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/manifest.mf --- a/src/share/tools/IdealGraphVisualizer/Outline/manifest.mf Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -Manifest-Version: 1.0 -OpenIDE-Module: com.oracle.graal.visualizer.outline -OpenIDE-Module-Layer: com/oracle/graal/visualizer/outline/layer.xml -OpenIDE-Module-Localizing-Bundle: com/oracle/graal/visualizer/outline/Bundle.properties -OpenIDE-Module-Specification-Version: 1.0 - diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/Bundle.properties --- a/src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/Bundle.properties Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -AdvancedOption_DisplayName_Coordinator=Settings -AdvancedOption_Tooltip_Coordinator=Visualization Tool Settings -CTL_OutlineTopComponent=Outline -HINT_OutlineTopComponent=Displays loaded compilations. -OpenIDE-Module-Name=Outline diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/CompilationNode.java --- a/src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/CompilationNode.java Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,148 +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 com.oracle.graal.visualizer.outline; - -import com.sun.hotspot.igv.data.*; -import com.sun.hotspot.igv.data.services.GraphViewer; -import java.awt.Image; -import java.util.ArrayList; -import java.util.List; -import javax.swing.Action; -import javax.swing.JOptionPane; -import org.openide.actions.OpenAction; -import org.openide.cookies.OpenCookie; -import org.openide.nodes.AbstractNode; -import org.openide.nodes.Children; -import org.openide.nodes.Node; -import org.openide.util.ImageUtilities; -import org.openide.util.Lookup; -import org.openide.util.lookup.AbstractLookup; -import org.openide.util.lookup.InstanceContent; -import org.openide.util.lookup.Lookups; - -public class CompilationNode extends AbstractNode implements ChangedListener { - - private CompilationNode(final Folder folder, Children children, InstanceContent content) { - super(children, new AbstractLookup(content)); - this.setDisplayName(folder.getName()); - - if (folder instanceof Group) { - content.add(new OpenCookie() { - - @Override - public void open() { - final List graphs = ((Group) folder).getGraphs(); - if (graphs.isEmpty()) { - JOptionPane.showMessageDialog(null, "Cannot open compilation, because there was no snapshots recorded!"); - } else { - Lookup.getDefault().lookup(GraphViewer.class).view(graphs.get(0)); - } - } - }); - } - content.add(folder); - folder.getChangedEvent().addListener(this); - } - - @Override - public void changed(Object folder) { - if (this.getChildren() == Children.LEAF) { - setChildren(createFolderChildren((Folder) folder)); - this.fireIconChange(); - } - } - - private static class FolderChildren extends Children.Keys { - - private final Folder folder; - - public FolderChildren(Folder folder) { - this.folder = folder; - folder.getChangedEvent().addListener(changedListener); - } - - @Override - protected Node[] createNodes(Folder e) { - return new Node[]{new CompilationNode(e)}; - } - - @Override - public void addNotify() { - List result = new ArrayList<>(); - for (FolderElement o : folder.getElements()) { - if (o instanceof Folder) { - result.add((Folder) o); - } - } - this.setKeys(result); - } - private final ChangedListener changedListener = new ChangedListener() { - - @Override - public void changed(Object source) { - addNotify(); - } - }; - } - - @Override - public Image getIcon(int i) { - if (this.getChildren() == Children.LEAF) { - return ImageUtilities.loadImage("com/oracle/graal/visualizer/outline/images/leaf_node.gif"); - } else { - return ImageUtilities.loadImage("com/oracle/graal/visualizer/outline/images/node.gif"); - } - } - - protected CompilationNode(Folder folder) { - this(folder, createFolderChildren(folder), new InstanceContent()); - } - - private static Children createFolderChildren(Folder folder) { - for (FolderElement elem : folder.getElements()) { - if (elem instanceof Folder) { - return new FolderChildren(folder); - } - } - return Children.LEAF; - } - - @Override - public Action[] getActions(boolean context) { - List actions = new ArrayList<>(); - actions.add((Action) OpenAction.findObject(OpenAction.class, true)); - actions.addAll(Lookups.forPath(OutlineTopComponent.NODE_ACTIONS_FOLDER).lookupAll(Action.class)); - return actions.toArray(new Action[actions.size()]); - } - - @Override - public Action getPreferredAction() { - return (Action) OpenAction.findObject(OpenAction.class, true); - } - - @Override - public Image getOpenedIcon(int i) { - return getIcon(i); - } -} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/OutlineTopComponent.form --- a/src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/OutlineTopComponent.form Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/OutlineTopComponent.java --- a/src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/OutlineTopComponent.java Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,228 +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 com.oracle.graal.visualizer.outline; - -import com.oracle.graal.visualizer.outline.server.Server; -import com.oracle.graal.visualizer.outline.server.ServerPanel; -import com.sun.hotspot.igv.data.GraphDocument; -import java.awt.BorderLayout; -import java.io.IOException; -import java.io.ObjectInput; -import java.io.ObjectOutput; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import javax.swing.Action; -import javax.swing.UIManager; -import javax.swing.border.Border; -import org.openide.ErrorManager; -import org.openide.actions.GarbageCollectAction; -import org.openide.awt.Toolbar; -import org.openide.explorer.ExplorerManager; -import org.openide.explorer.ExplorerUtils; -import org.openide.explorer.view.BeanTreeView; -import org.openide.util.ContextAwareAction; -import org.openide.util.LookupEvent; -import org.openide.util.LookupListener; -import org.openide.util.NbBundle; -import org.openide.util.lookup.Lookups; -import org.openide.windows.TopComponent; -import org.openide.windows.WindowManager; - -public final class OutlineTopComponent extends TopComponent implements ExplorerManager.Provider, LookupListener { - - public static final String GLOBAL_ACTIONS_FOLDER = "Actions/Outline/Global"; - public static final String NODE_ACTIONS_FOLDER = "Actions/Outline/Nodes"; - public static OutlineTopComponent instance; - public static final String PREFERRED_ID = "OutlineTopComponent"; - private ExplorerManager manager; - private GraphDocument document; - private Server server; - - private OutlineTopComponent() { - initComponents(); - - setName(NbBundle.getMessage(OutlineTopComponent.class, "CTL_OutlineTopComponent")); - setToolTipText(NbBundle.getMessage(OutlineTopComponent.class, "HINT_OutlineTopComponent")); - - document = new GraphDocument(); - initListView(); - initToolbar(); - } - - private void initListView() { - manager = new ExplorerManager(); - manager.setRootContext(new CompilationNode(document)); - ((BeanTreeView) this.treeView).setRootVisible(false); - associateLookup(ExplorerUtils.createLookup(manager, getActionMap())); - } - - private void initToolbar() { - - Toolbar toolbar = new Toolbar(); - Border b = (Border) UIManager.get("Nb.Editor.Toolbar.border"); //NOI18N - toolbar.setBorder(b); - this.add(toolbar, BorderLayout.NORTH); - for (Action a : lookupActions(GLOBAL_ACTIONS_FOLDER)) { - toolbar.add(a); - } - toolbar.add(GarbageCollectAction.get(GarbageCollectAction.class).getToolbarPresenter()); - toolbar.add(new ServerPanel(getDocument())); - } - - private List lookupActions(String path) { - List actions = new ArrayList<>(); - for (Action a : Lookups.forPath(path).lookupAll(Action.class)) { - Action newAction = a; - if (a instanceof ContextAwareAction) { - newAction = ((ContextAwareAction) a).createContextAwareInstance(getLookup()); - } - newAction.putValue(Action.SHORT_DESCRIPTION, newAction.getValue(Action.NAME)); - actions.add(newAction); - - } - return actions; - } - - public void clear() { - document.clear(); - } - - @Override - public ExplorerManager getExplorerManager() { - return manager; - } - - public GraphDocument getDocument() { - return document; - } - - /** - * Gets default instance. Do not use directly: reserved for *.settings files - * only, i.e. deserialization routines; otherwise you could get a - * non-deserialized instance. To obtain the singleton instance, use {@link findInstance}. - */ - public static synchronized OutlineTopComponent getDefault() { - if (instance == null) { - instance = new OutlineTopComponent(); - } - return instance; - } - - /** - * Obtain the OutlineTopComponent instance. Never call {@link #getDefault} - * directly! - */ - public static synchronized OutlineTopComponent findInstance() { - TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID); - if (win == null) { - ErrorManager.getDefault().log(ErrorManager.WARNING, "Cannot find Outline component. It will not be located properly in the window system."); - return getDefault(); - } - if (win instanceof OutlineTopComponent) { - return (OutlineTopComponent) win; - } - ErrorManager.getDefault().log(ErrorManager.WARNING, "There seem to be multiple components with the '" + PREFERRED_ID + "' ID. That is a potential source of errors and unexpected behavior."); - return getDefault(); - } - - @Override - public int getPersistenceType() { - return TopComponent.PERSISTENCE_ALWAYS; - } - - @Override - public void componentOpened() { - this.requestActive(); - } - - @Override - public void componentClosed() { - } - - @Override - protected String preferredID() { - return PREFERRED_ID; - } - - @Override - public void requestActive() { - super.requestActive(); - treeView.requestFocus(); - } - - @Override - public boolean requestFocus(boolean temporary) { - treeView.requestFocus(); - return super.requestFocus(temporary); - } - - @Override - protected boolean requestFocusInWindow(boolean temporary) { - treeView.requestFocus(); - return super.requestFocusInWindow(temporary); - } - - @Override - public void resultChanged(LookupEvent lookupEvent) { - } - - @Override - public void readExternal(ObjectInput objectInput) throws IOException, ClassNotFoundException { - // Not called when user starts application for the first time - super.readExternal(objectInput); - ((BeanTreeView) this.treeView).setRootVisible(false); - } - - @Override - public void writeExternal(ObjectOutput objectOutput) throws IOException { - super.writeExternal(objectOutput); - } - - static final class ResolvableHelper implements Serializable { - - private static final long serialVersionUID = 1L; - - public Object readResolve() { - return OutlineTopComponent.getDefault(); - } - } - - /** - * This method is called from within the constructor to initialize the form. - * WARNING: Do NOT modify this code. The content of this method is always - * regenerated by the Form Editor. - */ - // //GEN-BEGIN:initComponents - private void initComponents() { - - treeView = new BeanTreeView(); - - setLayout(new java.awt.BorderLayout()); - add(treeView, java.awt.BorderLayout.CENTER); - }// //GEN-END:initComponents - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JScrollPane treeView; - // End of variables declaration//GEN-END:variables -} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/OutlineTopComponentSettings.xml --- a/src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/OutlineTopComponentSettings.xml Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ - - - - - - - - diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/OutlineTopComponentWstcref.xml --- a/src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/OutlineTopComponentWstcref.xml Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ - - - - - - - diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/actions/ImportAction.java --- a/src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/actions/ImportAction.java Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,155 +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 com.oracle.graal.visualizer.outline.actions; - -import com.oracle.graal.visualizer.outline.OutlineTopComponent; -import com.sun.hotspot.igv.data.GraphDocument; -import com.sun.hotspot.igv.data.serialization.Parser; -import com.sun.hotspot.igv.data.serialization.XMLParser; -import com.sun.hotspot.igv.settings.Settings; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import javax.swing.JFileChooser; -import javax.swing.SwingUtilities; -import javax.swing.filechooser.FileFilter; -import org.netbeans.api.progress.ProgressHandle; -import org.netbeans.api.progress.ProgressHandleFactory; -import org.openide.DialogDisplayer; -import org.openide.NotifyDescriptor; -import org.openide.awt.ActionID; -import org.openide.awt.ActionReference; -import org.openide.awt.ActionReferences; -import org.openide.awt.ActionRegistration; -import org.openide.util.RequestProcessor; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -@ActionID(id = "com.oracle.graal.visualizer.outline.actions.ImportAction", category = "File") -@ActionRegistration(displayName = "Import", iconBase="com/oracle/graal/visualizer/outline/images/import.png") -@ActionReferences(value = { - @ActionReference(path = "Menu/File", position = 100), - @ActionReference(path = OutlineTopComponent.GLOBAL_ACTIONS_FOLDER)}) -public final class ImportAction implements ActionListener { - - public static FileFilter getFileFilter() { - return new FileFilter() { - - @Override - public boolean accept(File f) { - return f.getName().toLowerCase().endsWith(".xml") || f.isDirectory(); - } - - @Override - public String getDescription() { - return "XML files (*.xml)"; - } - }; - } - - @Override - public void actionPerformed(ActionEvent e) { - - JFileChooser fc = new JFileChooser(); - fc.setFileFilter(ImportAction.getFileFilter()); - fc.setCurrentDirectory(new File(Settings.get().get(Settings.DIRECTORY, Settings.DIRECTORY_DEFAULT))); - - if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { - File file = fc.getSelectedFile(); - - File dir = file; - if (!dir.isDirectory()) { - dir = dir.getParentFile(); - } - - Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath()); - - try { - final FileInputStream inputStream = new FileInputStream(file); - final InputSource is = new InputSource(inputStream); - - final ProgressHandle handle = ProgressHandleFactory.createHandle("Opening file " + file.getName()); - final int basis = 1000; - handle.start(basis); - final int start = inputStream.available(); - - final XMLParser.ParseMonitor parseMonitor = new XMLParser.ParseMonitor() { - - @Override - public void setProgress(double d) { - try { - int curAvailable = inputStream.available(); - int prog = (int) (basis * (double) (start - curAvailable) / (double) start); - handle.progress(prog); - } catch (IOException ex) { - } - } - - @Override - public void setState(String state) { - setProgress(0.0); - handle.progress(state); - } - }; - final Parser parser = new Parser(); - final OutlineTopComponent component = OutlineTopComponent.findInstance(); - - component.requestActive(); - - RequestProcessor.getDefault().post(new Runnable() { - - @Override - public void run() { - try { - final GraphDocument document = parser.parse(is, parseMonitor); - parseMonitor.setState("Finishing"); - SwingUtilities.invokeLater(new Runnable(){ - - @Override - public void run() { - component.getDocument().addGraphDocument(document); - } - }); - } catch (SAXException ex) { - String s = "Exception during parsing the XML file, could not load document!"; - if (ex instanceof XMLParser.MissingAttributeException) { - XMLParser.MissingAttributeException e = (XMLParser.MissingAttributeException) ex; - s += "\nMissing attribute \"" + e.getAttributeName() + "\""; - } - NotifyDescriptor d = new NotifyDescriptor.Message(s, NotifyDescriptor.ERROR_MESSAGE); - DialogDisplayer.getDefault().notify(d); - } - handle.finish(); - } - }); - - } catch (IOException ex) { - DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message("Error reading file!", NotifyDescriptor.ERROR_MESSAGE)); - } - } - } -} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/actions/OutlineAction.java --- a/src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/actions/OutlineAction.java Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +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 com.oracle.graal.visualizer.outline.actions; - -import com.oracle.graal.visualizer.outline.OutlineTopComponent; -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; -import org.openide.windows.TopComponent; - -@ActionID(id = "com.oracle.graal.visualizer.outline.actions.OutlineAction", category = "Window") -@ActionRegistration(displayName = "Compilations") -@ActionReference(path = "Menu/Window", name = "OutlineAction") -public class OutlineAction implements ActionListener { - @Override - public void actionPerformed(ActionEvent evt) { - TopComponent win = OutlineTopComponent.findInstance(); - win.open(); - win.requestActive(); - } -} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/actions/RemoveAction.java --- a/src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/actions/RemoveAction.java Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +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 com.oracle.graal.visualizer.outline.actions; - -import com.oracle.graal.visualizer.outline.OutlineTopComponent; -import com.sun.hotspot.igv.data.FolderElement; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.List; -import org.openide.awt.ActionID; -import org.openide.awt.ActionReference; -import org.openide.awt.ActionReferences; -import org.openide.awt.ActionRegistration; - -@ActionID(id = "com.oracle.graal.visualizer.outline.actions.RemoveAction", category = "Edit") -@ActionRegistration(displayName = "Remove", iconBase = "com/oracle/graal/visualizer/outline/images/remove.png") -@ActionReferences(value = { - @ActionReference(path = "Menu/File", position = 400), - @ActionReference(path = OutlineTopComponent.NODE_ACTIONS_FOLDER)}) -public final class RemoveAction implements ActionListener { - - List elements; - - public RemoveAction(List elements) { - this.elements = elements; - } - - @Override - public void actionPerformed(ActionEvent e) { - for (FolderElement element : elements) { - element.getParent().removeElement(element); - } - } -} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/actions/RemoveAllAction.java --- a/src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/actions/RemoveAllAction.java Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +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. 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.outline.actions; - -import com.oracle.graal.visualizer.outline.OutlineTopComponent; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import org.openide.awt.ActionID; -import org.openide.awt.ActionReference; -import org.openide.awt.ActionReferences; -import org.openide.awt.ActionRegistration; - -@ActionID(id = "com.oracle.graal.visualizer.outline.actions.RemoveAllAction", category = "Edit") -@ActionRegistration(displayName = "Remove all", iconBase = "com/oracle/graal/visualizer/outline/images/removeall.png") -@ActionReferences(value = { - @ActionReference(path = "Menu/File", position = 500), - @ActionReference(path = OutlineTopComponent.GLOBAL_ACTIONS_FOLDER)}) -public final class RemoveAllAction implements ActionListener { - - @Override - public void actionPerformed(ActionEvent e) { - OutlineTopComponent.findInstance().clear(); - } -} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/actions/SaveAllAction.java --- a/src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/actions/SaveAllAction.java Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +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. 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.outline.actions; - -import com.oracle.graal.visualizer.outline.OutlineTopComponent; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import org.openide.awt.ActionID; -import org.openide.awt.ActionReference; -import org.openide.awt.ActionReferences; -import org.openide.awt.ActionRegistration; - -@ActionID(id = "com.oracle.graal.visualizer.outline.actions.SaveAllAction", category = "File") -@ActionRegistration(displayName = "Save all..", iconBase = "com/oracle/graal/visualizer/outline/images/saveall.gif") -@ActionReferences(value = { - @ActionReference(path = "Menu/File", position = 300), - @ActionReference(path = OutlineTopComponent.GLOBAL_ACTIONS_FOLDER)}) -public final class SaveAllAction implements ActionListener { - - @Override - public void actionPerformed(ActionEvent e) { - final OutlineTopComponent component = OutlineTopComponent.findInstance(); - SaveAsAction.save(component.getDocument()); - } -} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/actions/SaveAsAction.java --- a/src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/actions/SaveAsAction.java Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,105 +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 com.oracle.graal.visualizer.outline.actions; - -import com.oracle.graal.visualizer.outline.OutlineTopComponent; -import com.sun.hotspot.igv.data.Folder; -import com.sun.hotspot.igv.data.FolderElement; -import com.sun.hotspot.igv.data.GraphDocument; -import com.sun.hotspot.igv.data.serialization.Printer; -import com.sun.hotspot.igv.settings.Settings; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.*; -import java.util.List; -import javax.swing.JFileChooser; -import javax.swing.JOptionPane; -import org.openide.awt.ActionID; -import org.openide.awt.ActionReference; -import org.openide.awt.ActionReferences; -import org.openide.awt.ActionRegistration; - -@ActionID(id = "com.oracle.graal.visualizer.outline.actions.SaveAsAction", category = "File") -@ActionRegistration(displayName = "Save as...", iconBase="com/oracle/graal/visualizer/outline/images/save.png") -@ActionReferences(value = { - @ActionReference(path = "Menu/File", position = 200), - @ActionReference(path = OutlineTopComponent.NODE_ACTIONS_FOLDER)}) -public final class SaveAsAction implements ActionListener { - - private final List elements; - - public SaveAsAction(List elements) { - this.elements = elements; - } - - - @Override - public void actionPerformed(ActionEvent e) { - GraphDocument doc = new GraphDocument(); - outer: for (FolderElement element : elements) { - Folder cur = element.getParent(); - while (cur instanceof FolderElement) { - FolderElement curElement = (FolderElement) cur; - if (elements.contains(curElement)) { - continue outer; - } - cur = curElement.getParent(); - } - - Folder previousParent = element.getParent(); - doc.addElement(element); - element.setParent(previousParent); - } - - save(doc); - } - - public static void save(GraphDocument doc) { - JFileChooser fc = new JFileChooser(); - fc.setFileFilter(ImportAction.getFileFilter()); - 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() + ".xml"); - } - - File dir = file; - if (!dir.isDirectory()) { - dir = dir.getParentFile(); - } - Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath()); - try { - try (Writer writer = new OutputStreamWriter(new FileOutputStream(file))) { - Printer p = new Printer(); - p.export(writer, doc); - } - } catch (IOException e) { - JOptionPane.showMessageDialog(null, "Error writing file " + file.getAbsolutePath()); - } - } - } -} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/customLeftWsmode.xml --- a/src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/customLeftWsmode.xml Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/images/import.png Binary file src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/images/import.png has changed diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/images/leaf_node.gif Binary file src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/images/leaf_node.gif has changed diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/images/node.gif Binary file src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/images/node.gif has changed diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/images/remove.png Binary file src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/images/remove.png has changed diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/images/removeall.png Binary file src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/images/removeall.png has changed diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/images/save.png Binary file src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/images/save.png has changed diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/images/saveall.gif Binary file src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/images/saveall.gif has changed diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/layer.xml --- a/src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/layer.xml Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,174 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/server/Bundle.properties --- a/src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/server/Bundle.properties Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -OpenIDE-Module-Name=NetworkConnection diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/server/Client.java --- a/src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/server/Client.java Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,67 +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. 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.outline.server; - -import com.sun.hotspot.igv.data.serialization.Parser; -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.Socket; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; - -public class Client implements Runnable { - - private Socket socket; - private ServerCallback callback; - - public Client(Socket socket, ServerCallback callback) { - this.callback = callback; - this.socket = socket; - } - - @Override - public void run() { - callback.connectionOpened(socket.getInetAddress()); - try { - InputStream inputStream = new BufferedInputStream(socket.getInputStream()); - InputSource is = new InputSource(inputStream); - - try { - Parser parser = new Parser(callback); - parser.parse(is, null); - } catch (SAXException ex) { - throw new IOException(ex); - } - } catch (IOException ex) { - } finally { - try { - socket.close(); - } catch (IOException ex) { - } - callback.connectionClosed(); - } - } -} \ No newline at end of file diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/server/Server.java --- a/src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/server/Server.java Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,89 +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. 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.outline.server; - -import java.io.IOException; -import java.net.ServerSocket; -import java.net.Socket; -import org.openide.DialogDisplayer; -import org.openide.NotifyDescriptor; -import org.openide.util.RequestProcessor; - -public class Server { - - private Runnable serverRunnable; - private ServerSocket serverSocket; - - private Server() {} - - - public static Server start(final ServerCallback callback, int port) { - - final Server server = new Server(); - - try { - server.serverSocket = new java.net.ServerSocket(port); - } catch (IOException ex) { - NotifyDescriptor message = new NotifyDescriptor.Message("Could not create server. Listening for incoming data is disabled.", NotifyDescriptor.ERROR_MESSAGE); - DialogDisplayer.getDefault().notifyLater(message); - return null; - } - - Runnable runnable = new Runnable() { - - @Override - public void run() { - while (true) { - try { - Socket clientSocket = server.serverSocket.accept(); - if (server.serverRunnable != this) { - clientSocket.close(); - return; - } - RequestProcessor.getDefault().post(new Client(clientSocket, callback), 0, Thread.MAX_PRIORITY); - } catch (IOException ex) { - server.serverSocket = null; - NotifyDescriptor message = new NotifyDescriptor.Message("Error during listening for incoming connections. Listening for incoming data is disabled.", NotifyDescriptor.ERROR_MESSAGE); - DialogDisplayer.getDefault().notifyLater(message); - return; - } - } - } - }; - - server.serverRunnable = runnable; - RequestProcessor.getDefault().post(runnable, 0, Thread.MAX_PRIORITY); - return server; - } - - void shutdown() { - try { - serverSocket.close(); - } catch (IOException ex) { - } - - serverSocket = null; - } -} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/server/ServerCallback.java --- a/src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/server/ServerCallback.java Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +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. 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.outline.server; - -import com.sun.hotspot.igv.data.services.GroupCallback; -import java.net.InetAddress; - -public interface ServerCallback extends GroupCallback { - - public void connectionOpened(InetAddress inetAddress); - - public void connectionClosed(); - -} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/server/ServerPanel.java --- a/src/share/tools/IdealGraphVisualizer/Outline/src/com/oracle/graal/visualizer/outline/server/ServerPanel.java Sat Feb 04 21:41:02 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,130 +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. 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.outline.server; - -import com.sun.hotspot.igv.data.GraphDocument; -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.settings.Settings; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Font; -import java.net.InetAddress; -import java.util.prefs.PreferenceChangeEvent; -import java.util.prefs.PreferenceChangeListener; -import javax.swing.BorderFactory; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.SwingUtilities; - -public class ServerPanel extends JPanel { - - private final static int BORDER_SIZE = 2; - JLabel label; - private Server server; - private int port = -1; - private int numberOfConnections; - private final GraphDocument document; - private final PreferenceChangeListener preferenceChanged = new PreferenceChangeListener() { - - @Override - public void preferenceChange(PreferenceChangeEvent evt) { - updateServer(); - } - }; - private ServerCallback callback = new ServerCallback() { - - @Override - public void connectionOpened(InetAddress inetAddress) { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - numberOfConnections++; - updateLabel(); - } - }); - } - - @Override - public void connectionClosed() { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - numberOfConnections--; - updateLabel(); - } - }); - } - - @Override - public void started(Group g) { - document.addElement(g); - } - }; - - private void updateLabel() { - if (numberOfConnections == 0) { - label.setText(String.format("Listening on %d", port)); - label.setFont(label.getFont().deriveFont(Font.PLAIN)); - } else { - label.setText(String.format("%d connections", numberOfConnections)); - label.setFont(label.getFont().deriveFont(Font.BOLD)); - } - } - - private void updateServer() { - int curPort = Integer.parseInt(Settings.get().get(Settings.PORT, Settings.PORT_DEFAULT)); - if (curPort != port) { - port = curPort; - if (server != null) { - server.shutdown(); - } - server = Server.start(callback, port); - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - updateLabel(); - } - }); - } - } - - public ServerPanel(GraphDocument document) { - - this.document = document; - Settings.get().addPreferenceChangeListener(preferenceChanged); - label = new JLabel(); - label.setBorder(BorderFactory.createEmptyBorder(0, BORDER_SIZE, 0, BORDER_SIZE)); - this.setLayout(new BorderLayout()); - this.add(label, BorderLayout.WEST); - updateServer(); - } - - public Component getToolbarPresenter() { - return label; - } -} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/manifest.mf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/manifest.mf Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +OpenIDE-Module: com.oracle.graal.visualizer.outline +OpenIDE-Module-Layer: com/oracle/graal/visualizer/outline/layer.xml +OpenIDE-Module-Localizing-Bundle: com/oracle/graal/visualizer/outline/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/Bundle.properties Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,5 @@ +AdvancedOption_DisplayName_Coordinator=Settings +AdvancedOption_Tooltip_Coordinator=Visualization Tool Settings +CTL_OutlineTopComponent=Outline +HINT_OutlineTopComponent=Displays loaded compilations. +OpenIDE-Module-Name=OutlineView diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/CompilationNode.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/CompilationNode.java Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,148 @@ +/* + * 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.outline; + +import com.sun.hotspot.igv.data.*; +import com.sun.hotspot.igv.data.services.GraphViewer; +import java.awt.Image; +import java.util.ArrayList; +import java.util.List; +import javax.swing.Action; +import javax.swing.JOptionPane; +import org.openide.actions.OpenAction; +import org.openide.cookies.OpenCookie; +import org.openide.nodes.AbstractNode; +import org.openide.nodes.Children; +import org.openide.nodes.Node; +import org.openide.util.ImageUtilities; +import org.openide.util.Lookup; +import org.openide.util.lookup.AbstractLookup; +import org.openide.util.lookup.InstanceContent; +import org.openide.util.lookup.Lookups; + +public class CompilationNode extends AbstractNode implements ChangedListener { + + private CompilationNode(final Folder folder, Children children, InstanceContent content) { + super(children, new AbstractLookup(content)); + this.setDisplayName(folder.getName()); + + if (folder instanceof Group) { + content.add(new OpenCookie() { + + @Override + public void open() { + final List graphs = ((Group) folder).getGraphs(); + if (graphs.isEmpty()) { + JOptionPane.showMessageDialog(null, "Cannot open compilation, because there was no snapshots recorded!"); + } else { + Lookup.getDefault().lookup(GraphViewer.class).view(graphs.get(0)); + } + } + }); + } + content.add(folder); + folder.getChangedEvent().addListener(this); + } + + @Override + public void changed(Object folder) { + if (this.getChildren() == Children.LEAF) { + setChildren(createFolderChildren((Folder) folder)); + this.fireIconChange(); + } + } + + private static class FolderChildren extends Children.Keys { + + private final Folder folder; + + public FolderChildren(Folder folder) { + this.folder = folder; + folder.getChangedEvent().addListener(changedListener); + } + + @Override + protected Node[] createNodes(Folder e) { + return new Node[]{new CompilationNode(e)}; + } + + @Override + public void addNotify() { + List result = new ArrayList<>(); + for (FolderElement o : folder.getElements()) { + if (o instanceof Folder) { + result.add((Folder) o); + } + } + this.setKeys(result); + } + private final ChangedListener changedListener = new ChangedListener() { + + @Override + public void changed(Object source) { + addNotify(); + } + }; + } + + @Override + public Image getIcon(int i) { + if (this.getChildren() == Children.LEAF) { + return ImageUtilities.loadImage("com/oracle/graal/visualizer/outline/images/leaf_node.gif"); + } else { + return ImageUtilities.loadImage("com/oracle/graal/visualizer/outline/images/node.gif"); + } + } + + protected CompilationNode(Folder folder) { + this(folder, createFolderChildren(folder), new InstanceContent()); + } + + private static Children createFolderChildren(Folder folder) { + for (FolderElement elem : folder.getElements()) { + if (elem instanceof Folder) { + return new FolderChildren(folder); + } + } + return Children.LEAF; + } + + @Override + public Action[] getActions(boolean context) { + List actions = new ArrayList<>(); + actions.add((Action) OpenAction.findObject(OpenAction.class, true)); + actions.addAll(Lookups.forPath(OutlineTopComponent.NODE_ACTIONS_FOLDER).lookupAll(Action.class)); + return actions.toArray(new Action[actions.size()]); + } + + @Override + public Action getPreferredAction() { + return (Action) OpenAction.findObject(OpenAction.class, true); + } + + @Override + public Image getOpenedIcon(int i) { + return getIcon(i); + } +} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/OutlineTopComponent.form --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/OutlineTopComponent.form Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,32 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/OutlineTopComponent.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/OutlineTopComponent.java Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,228 @@ +/* + * 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.outline; + +import com.oracle.graal.visualizer.outline.server.Server; +import com.oracle.graal.visualizer.outline.server.ServerPanel; +import com.sun.hotspot.igv.data.GraphDocument; +import java.awt.BorderLayout; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectOutput; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import javax.swing.Action; +import javax.swing.UIManager; +import javax.swing.border.Border; +import org.openide.ErrorManager; +import org.openide.actions.GarbageCollectAction; +import org.openide.awt.Toolbar; +import org.openide.explorer.ExplorerManager; +import org.openide.explorer.ExplorerUtils; +import org.openide.explorer.view.BeanTreeView; +import org.openide.util.ContextAwareAction; +import org.openide.util.LookupEvent; +import org.openide.util.LookupListener; +import org.openide.util.NbBundle; +import org.openide.util.lookup.Lookups; +import org.openide.windows.TopComponent; +import org.openide.windows.WindowManager; + +public final class OutlineTopComponent extends TopComponent implements ExplorerManager.Provider, LookupListener { + + public static final String GLOBAL_ACTIONS_FOLDER = "Actions/Outline/Global"; + public static final String NODE_ACTIONS_FOLDER = "Actions/Outline/Nodes"; + public static OutlineTopComponent instance; + public static final String PREFERRED_ID = "OutlineTopComponent"; + private ExplorerManager manager; + private GraphDocument document; + private Server server; + + private OutlineTopComponent() { + initComponents(); + + setName(NbBundle.getMessage(OutlineTopComponent.class, "CTL_OutlineTopComponent")); + setToolTipText(NbBundle.getMessage(OutlineTopComponent.class, "HINT_OutlineTopComponent")); + + document = new GraphDocument(); + initListView(); + initToolbar(); + } + + private void initListView() { + manager = new ExplorerManager(); + manager.setRootContext(new CompilationNode(document)); + ((BeanTreeView) this.treeView).setRootVisible(false); + associateLookup(ExplorerUtils.createLookup(manager, getActionMap())); + } + + private void initToolbar() { + + Toolbar toolbar = new Toolbar(); + Border b = (Border) UIManager.get("Nb.Editor.Toolbar.border"); //NOI18N + toolbar.setBorder(b); + this.add(toolbar, BorderLayout.NORTH); + for (Action a : lookupActions(GLOBAL_ACTIONS_FOLDER)) { + toolbar.add(a); + } + toolbar.add(GarbageCollectAction.get(GarbageCollectAction.class).getToolbarPresenter()); + toolbar.add(new ServerPanel(getDocument())); + } + + private List lookupActions(String path) { + List actions = new ArrayList<>(); + for (Action a : Lookups.forPath(path).lookupAll(Action.class)) { + Action newAction = a; + if (a instanceof ContextAwareAction) { + newAction = ((ContextAwareAction) a).createContextAwareInstance(getLookup()); + } + newAction.putValue(Action.SHORT_DESCRIPTION, newAction.getValue(Action.NAME)); + actions.add(newAction); + + } + return actions; + } + + public void clear() { + document.clear(); + } + + @Override + public ExplorerManager getExplorerManager() { + return manager; + } + + public GraphDocument getDocument() { + return document; + } + + /** + * Gets default instance. Do not use directly: reserved for *.settings files + * only, i.e. deserialization routines; otherwise you could get a + * non-deserialized instance. To obtain the singleton instance, use {@link findInstance}. + */ + public static synchronized OutlineTopComponent getDefault() { + if (instance == null) { + instance = new OutlineTopComponent(); + } + return instance; + } + + /** + * Obtain the OutlineTopComponent instance. Never call {@link #getDefault} + * directly! + */ + public static synchronized OutlineTopComponent findInstance() { + TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID); + if (win == null) { + ErrorManager.getDefault().log(ErrorManager.WARNING, "Cannot find Outline component. It will not be located properly in the window system."); + return getDefault(); + } + if (win instanceof OutlineTopComponent) { + return (OutlineTopComponent) win; + } + ErrorManager.getDefault().log(ErrorManager.WARNING, "There seem to be multiple components with the '" + PREFERRED_ID + "' ID. That is a potential source of errors and unexpected behavior."); + return getDefault(); + } + + @Override + public int getPersistenceType() { + return TopComponent.PERSISTENCE_ALWAYS; + } + + @Override + public void componentOpened() { + this.requestActive(); + } + + @Override + public void componentClosed() { + } + + @Override + protected String preferredID() { + return PREFERRED_ID; + } + + @Override + public void requestActive() { + super.requestActive(); + treeView.requestFocus(); + } + + @Override + public boolean requestFocus(boolean temporary) { + treeView.requestFocus(); + return super.requestFocus(temporary); + } + + @Override + protected boolean requestFocusInWindow(boolean temporary) { + treeView.requestFocus(); + return super.requestFocusInWindow(temporary); + } + + @Override + public void resultChanged(LookupEvent lookupEvent) { + } + + @Override + public void readExternal(ObjectInput objectInput) throws IOException, ClassNotFoundException { + // Not called when user starts application for the first time + super.readExternal(objectInput); + ((BeanTreeView) this.treeView).setRootVisible(false); + } + + @Override + public void writeExternal(ObjectOutput objectOutput) throws IOException { + super.writeExternal(objectOutput); + } + + static final class ResolvableHelper implements Serializable { + + private static final long serialVersionUID = 1L; + + public Object readResolve() { + return OutlineTopComponent.getDefault(); + } + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + // //GEN-BEGIN:initComponents + private void initComponents() { + + treeView = new BeanTreeView(); + + setLayout(new java.awt.BorderLayout()); + add(treeView, java.awt.BorderLayout.CENTER); + }// //GEN-END:initComponents + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JScrollPane treeView; + // End of variables declaration//GEN-END:variables +} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/OutlineTopComponentSettings.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/OutlineTopComponentSettings.xml Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,8 @@ + + + + + + + + diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/OutlineTopComponentWstcref.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/OutlineTopComponentWstcref.xml Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,7 @@ + + + + + + + diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/actions/ImportAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/actions/ImportAction.java Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,155 @@ +/* + * 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.outline.actions; + +import com.oracle.graal.visualizer.outline.OutlineTopComponent; +import com.sun.hotspot.igv.data.GraphDocument; +import com.sun.hotspot.igv.data.serialization.Parser; +import com.sun.hotspot.igv.data.serialization.XMLParser; +import com.sun.hotspot.igv.settings.Settings; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import javax.swing.JFileChooser; +import javax.swing.SwingUtilities; +import javax.swing.filechooser.FileFilter; +import org.netbeans.api.progress.ProgressHandle; +import org.netbeans.api.progress.ProgressHandleFactory; +import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; +import org.openide.awt.ActionID; +import org.openide.awt.ActionReference; +import org.openide.awt.ActionReferences; +import org.openide.awt.ActionRegistration; +import org.openide.util.RequestProcessor; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +@ActionID(id = "com.oracle.graal.visualizer.outline.actions.ImportAction", category = "File") +@ActionRegistration(displayName = "Import", iconBase="com/oracle/graal/visualizer/outline/images/import.png") +@ActionReferences(value = { + @ActionReference(path = "Menu/File", position = 100), + @ActionReference(path = OutlineTopComponent.GLOBAL_ACTIONS_FOLDER)}) +public final class ImportAction implements ActionListener { + + public static FileFilter getFileFilter() { + return new FileFilter() { + + @Override + public boolean accept(File f) { + return f.getName().toLowerCase().endsWith(".xml") || f.isDirectory(); + } + + @Override + public String getDescription() { + return "XML files (*.xml)"; + } + }; + } + + @Override + public void actionPerformed(ActionEvent e) { + + JFileChooser fc = new JFileChooser(); + fc.setFileFilter(ImportAction.getFileFilter()); + fc.setCurrentDirectory(new File(Settings.get().get(Settings.DIRECTORY, Settings.DIRECTORY_DEFAULT))); + + if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { + File file = fc.getSelectedFile(); + + File dir = file; + if (!dir.isDirectory()) { + dir = dir.getParentFile(); + } + + Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath()); + + try { + final FileInputStream inputStream = new FileInputStream(file); + final InputSource is = new InputSource(inputStream); + + final ProgressHandle handle = ProgressHandleFactory.createHandle("Opening file " + file.getName()); + final int basis = 1000; + handle.start(basis); + final int start = inputStream.available(); + + final XMLParser.ParseMonitor parseMonitor = new XMLParser.ParseMonitor() { + + @Override + public void setProgress(double d) { + try { + int curAvailable = inputStream.available(); + int prog = (int) (basis * (double) (start - curAvailable) / (double) start); + handle.progress(prog); + } catch (IOException ex) { + } + } + + @Override + public void setState(String state) { + setProgress(0.0); + handle.progress(state); + } + }; + final Parser parser = new Parser(); + final OutlineTopComponent component = OutlineTopComponent.findInstance(); + + component.requestActive(); + + RequestProcessor.getDefault().post(new Runnable() { + + @Override + public void run() { + try { + final GraphDocument document = parser.parse(is, parseMonitor); + parseMonitor.setState("Finishing"); + SwingUtilities.invokeLater(new Runnable(){ + + @Override + public void run() { + component.getDocument().addGraphDocument(document); + } + }); + } catch (SAXException ex) { + String s = "Exception during parsing the XML file, could not load document!"; + if (ex instanceof XMLParser.MissingAttributeException) { + XMLParser.MissingAttributeException e = (XMLParser.MissingAttributeException) ex; + s += "\nMissing attribute \"" + e.getAttributeName() + "\""; + } + NotifyDescriptor d = new NotifyDescriptor.Message(s, NotifyDescriptor.ERROR_MESSAGE); + DialogDisplayer.getDefault().notify(d); + } + handle.finish(); + } + }); + + } catch (IOException ex) { + DialogDisplayer.getDefault().notify(new NotifyDescriptor.Message("Error reading file!", NotifyDescriptor.ERROR_MESSAGE)); + } + } + } +} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/actions/OutlineAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/actions/OutlineAction.java Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,45 @@ +/* + * 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.outline.actions; + +import com.oracle.graal.visualizer.outline.OutlineTopComponent; +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; +import org.openide.windows.TopComponent; + +@ActionID(id = "com.oracle.graal.visualizer.outline.actions.OutlineAction", category = "Window") +@ActionRegistration(displayName = "Compilations") +@ActionReference(path = "Menu/Window", name = "OutlineAction") +public class OutlineAction implements ActionListener { + @Override + public void actionPerformed(ActionEvent evt) { + TopComponent win = OutlineTopComponent.findInstance(); + win.open(); + win.requestActive(); + } +} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/actions/RemoveAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/actions/RemoveAction.java Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,55 @@ +/* + * 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.outline.actions; + +import com.oracle.graal.visualizer.outline.OutlineTopComponent; +import com.sun.hotspot.igv.data.FolderElement; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; +import org.openide.awt.ActionID; +import org.openide.awt.ActionReference; +import org.openide.awt.ActionReferences; +import org.openide.awt.ActionRegistration; + +@ActionID(id = "com.oracle.graal.visualizer.outline.actions.RemoveAction", category = "Edit") +@ActionRegistration(displayName = "Remove", iconBase = "com/oracle/graal/visualizer/outline/images/remove.png") +@ActionReferences(value = { + @ActionReference(path = "Menu/File", position = 400), + @ActionReference(path = OutlineTopComponent.NODE_ACTIONS_FOLDER)}) +public final class RemoveAction implements ActionListener { + + List elements; + + public RemoveAction(List elements) { + this.elements = elements; + } + + @Override + public void actionPerformed(ActionEvent e) { + for (FolderElement element : elements) { + element.getParent().removeElement(element); + } + } +} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/actions/RemoveAllAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/actions/RemoveAllAction.java Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,46 @@ +/* + * 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. 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.outline.actions; + +import com.oracle.graal.visualizer.outline.OutlineTopComponent; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import org.openide.awt.ActionID; +import org.openide.awt.ActionReference; +import org.openide.awt.ActionReferences; +import org.openide.awt.ActionRegistration; + +@ActionID(id = "com.oracle.graal.visualizer.outline.actions.RemoveAllAction", category = "Edit") +@ActionRegistration(displayName = "Remove all", iconBase = "com/oracle/graal/visualizer/outline/images/removeall.png") +@ActionReferences(value = { + @ActionReference(path = "Menu/File", position = 500), + @ActionReference(path = OutlineTopComponent.GLOBAL_ACTIONS_FOLDER)}) +public final class RemoveAllAction implements ActionListener { + + @Override + public void actionPerformed(ActionEvent e) { + OutlineTopComponent.findInstance().clear(); + } +} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/actions/SaveAllAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/actions/SaveAllAction.java Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,47 @@ +/* + * 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. 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.outline.actions; + +import com.oracle.graal.visualizer.outline.OutlineTopComponent; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import org.openide.awt.ActionID; +import org.openide.awt.ActionReference; +import org.openide.awt.ActionReferences; +import org.openide.awt.ActionRegistration; + +@ActionID(id = "com.oracle.graal.visualizer.outline.actions.SaveAllAction", category = "File") +@ActionRegistration(displayName = "Save all..", iconBase = "com/oracle/graal/visualizer/outline/images/saveall.gif") +@ActionReferences(value = { + @ActionReference(path = "Menu/File", position = 300), + @ActionReference(path = OutlineTopComponent.GLOBAL_ACTIONS_FOLDER)}) +public final class SaveAllAction implements ActionListener { + + @Override + public void actionPerformed(ActionEvent e) { + final OutlineTopComponent component = OutlineTopComponent.findInstance(); + SaveAsAction.save(component.getDocument()); + } +} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/actions/SaveAsAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/actions/SaveAsAction.java Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,105 @@ +/* + * 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.outline.actions; + +import com.oracle.graal.visualizer.outline.OutlineTopComponent; +import com.sun.hotspot.igv.data.Folder; +import com.sun.hotspot.igv.data.FolderElement; +import com.sun.hotspot.igv.data.GraphDocument; +import com.sun.hotspot.igv.data.serialization.Printer; +import com.sun.hotspot.igv.settings.Settings; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.*; +import java.util.List; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import org.openide.awt.ActionID; +import org.openide.awt.ActionReference; +import org.openide.awt.ActionReferences; +import org.openide.awt.ActionRegistration; + +@ActionID(id = "com.oracle.graal.visualizer.outline.actions.SaveAsAction", category = "File") +@ActionRegistration(displayName = "Save as...", iconBase="com/oracle/graal/visualizer/outline/images/save.png") +@ActionReferences(value = { + @ActionReference(path = "Menu/File", position = 200), + @ActionReference(path = OutlineTopComponent.NODE_ACTIONS_FOLDER)}) +public final class SaveAsAction implements ActionListener { + + private final List elements; + + public SaveAsAction(List elements) { + this.elements = elements; + } + + + @Override + public void actionPerformed(ActionEvent e) { + GraphDocument doc = new GraphDocument(); + outer: for (FolderElement element : elements) { + Folder cur = element.getParent(); + while (cur instanceof FolderElement) { + FolderElement curElement = (FolderElement) cur; + if (elements.contains(curElement)) { + continue outer; + } + cur = curElement.getParent(); + } + + Folder previousParent = element.getParent(); + doc.addElement(element); + element.setParent(previousParent); + } + + save(doc); + } + + public static void save(GraphDocument doc) { + JFileChooser fc = new JFileChooser(); + fc.setFileFilter(ImportAction.getFileFilter()); + 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() + ".xml"); + } + + File dir = file; + if (!dir.isDirectory()) { + dir = dir.getParentFile(); + } + Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath()); + try { + try (Writer writer = new OutputStreamWriter(new FileOutputStream(file))) { + Printer p = new Printer(); + p.export(writer, doc); + } + } catch (IOException e) { + JOptionPane.showMessageDialog(null, "Error writing file " + file.getAbsolutePath()); + } + } + } +} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/customLeftWsmode.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/customLeftWsmode.xml Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/images/import.png Binary file src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/images/import.png has changed diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/images/leaf_node.gif Binary file src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/images/leaf_node.gif has changed diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/images/node.gif Binary file src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/images/node.gif has changed diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/images/remove.png Binary file src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/images/remove.png has changed diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/images/removeall.png Binary file src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/images/removeall.png has changed diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/images/save.png Binary file src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/images/save.png has changed diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/images/saveall.gif Binary file src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/images/saveall.gif has changed diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/layer.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/layer.xml Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,174 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/server/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/server/Bundle.properties Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,1 @@ +OpenIDE-Module-Name=NetworkConnection diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/server/Client.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/server/Client.java Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,67 @@ +/* + * 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. 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.outline.server; + +import com.sun.hotspot.igv.data.serialization.Parser; +import java.io.BufferedInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.Socket; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +public class Client implements Runnable { + + private Socket socket; + private ServerCallback callback; + + public Client(Socket socket, ServerCallback callback) { + this.callback = callback; + this.socket = socket; + } + + @Override + public void run() { + callback.connectionOpened(socket.getInetAddress()); + try { + InputStream inputStream = new BufferedInputStream(socket.getInputStream()); + InputSource is = new InputSource(inputStream); + + try { + Parser parser = new Parser(callback); + parser.parse(is, null); + } catch (SAXException ex) { + throw new IOException(ex); + } + } catch (IOException ex) { + } finally { + try { + socket.close(); + } catch (IOException ex) { + } + callback.connectionClosed(); + } + } +} \ No newline at end of file diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/server/Server.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/server/Server.java Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,89 @@ +/* + * 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. 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.outline.server; + +import java.io.IOException; +import java.net.ServerSocket; +import java.net.Socket; +import org.openide.DialogDisplayer; +import org.openide.NotifyDescriptor; +import org.openide.util.RequestProcessor; + +public class Server { + + private Runnable serverRunnable; + private ServerSocket serverSocket; + + private Server() {} + + + public static Server start(final ServerCallback callback, int port) { + + final Server server = new Server(); + + try { + server.serverSocket = new java.net.ServerSocket(port); + } catch (IOException ex) { + NotifyDescriptor message = new NotifyDescriptor.Message("Could not create server. Listening for incoming data is disabled.", NotifyDescriptor.ERROR_MESSAGE); + DialogDisplayer.getDefault().notifyLater(message); + return null; + } + + Runnable runnable = new Runnable() { + + @Override + public void run() { + while (true) { + try { + Socket clientSocket = server.serverSocket.accept(); + if (server.serverRunnable != this) { + clientSocket.close(); + return; + } + RequestProcessor.getDefault().post(new Client(clientSocket, callback), 0, Thread.MAX_PRIORITY); + } catch (IOException ex) { + server.serverSocket = null; + NotifyDescriptor message = new NotifyDescriptor.Message("Error during listening for incoming connections. Listening for incoming data is disabled.", NotifyDescriptor.ERROR_MESSAGE); + DialogDisplayer.getDefault().notifyLater(message); + return; + } + } + } + }; + + server.serverRunnable = runnable; + RequestProcessor.getDefault().post(runnable, 0, Thread.MAX_PRIORITY); + return server; + } + + void shutdown() { + try { + serverSocket.close(); + } catch (IOException ex) { + } + + serverSocket = null; + } +} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/server/ServerCallback.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/server/ServerCallback.java Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,37 @@ +/* + * 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. 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.outline.server; + +import com.sun.hotspot.igv.data.services.GroupCallback; +import java.net.InetAddress; + +public interface ServerCallback extends GroupCallback { + + public void connectionOpened(InetAddress inetAddress); + + public void connectionClosed(); + +} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/server/ServerPanel.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/OutlineView/src/com/oracle/graal/visualizer/outline/server/ServerPanel.java Sun Feb 05 00:46:25 2012 +0100 @@ -0,0 +1,130 @@ +/* + * 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. 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.outline.server; + +import com.sun.hotspot.igv.data.GraphDocument; +import com.sun.hotspot.igv.data.Group; +import com.sun.hotspot.igv.settings.Settings; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Font; +import java.net.InetAddress; +import java.util.prefs.PreferenceChangeEvent; +import java.util.prefs.PreferenceChangeListener; +import javax.swing.BorderFactory; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; + +public class ServerPanel extends JPanel { + + private final static int BORDER_SIZE = 2; + JLabel label; + private Server server; + private int port = -1; + private int numberOfConnections; + private final GraphDocument document; + private final PreferenceChangeListener preferenceChanged = new PreferenceChangeListener() { + + @Override + public void preferenceChange(PreferenceChangeEvent evt) { + updateServer(); + } + }; + private ServerCallback callback = new ServerCallback() { + + @Override + public void connectionOpened(InetAddress inetAddress) { + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + numberOfConnections++; + updateLabel(); + } + }); + } + + @Override + public void connectionClosed() { + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + numberOfConnections--; + updateLabel(); + } + }); + } + + @Override + public void started(Group g) { + document.addElement(g); + } + }; + + private void updateLabel() { + if (numberOfConnections == 0) { + label.setText(String.format("Listening on %d", port)); + label.setFont(label.getFont().deriveFont(Font.PLAIN)); + } else { + label.setText(String.format("%d connections", numberOfConnections)); + label.setFont(label.getFont().deriveFont(Font.BOLD)); + } + } + + private void updateServer() { + int curPort = Integer.parseInt(Settings.get().get(Settings.PORT, Settings.PORT_DEFAULT)); + if (curPort != port) { + port = curPort; + if (server != null) { + server.shutdown(); + } + server = Server.start(callback, port); + SwingUtilities.invokeLater(new Runnable() { + + @Override + public void run() { + updateLabel(); + } + }); + } + } + + public ServerPanel(GraphDocument document) { + + this.document = document; + Settings.get().addPreferenceChangeListener(preferenceChanged); + label = new JLabel(); + label.setBorder(BorderFactory.createEmptyBorder(0, BORDER_SIZE, 0, BORDER_SIZE)); + this.setLayout(new BorderLayout()); + this.add(label, BorderLayout.WEST); + updateServer(); + } + + public Component getToolbarPresenter() { + return label; + } +} diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Snapshots/src/com/oracle/graal/visualizer/snapshots/SnapshotTopComponent.java --- a/src/share/tools/IdealGraphVisualizer/Snapshots/src/com/oracle/graal/visualizer/snapshots/SnapshotTopComponent.java Sat Feb 04 21:41:02 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Snapshots/src/com/oracle/graal/visualizer/snapshots/SnapshotTopComponent.java Sun Feb 05 00:46:25 2012 +0100 @@ -23,22 +23,55 @@ */ package com.oracle.graal.visualizer.snapshots; +import com.oracle.graal.visualizer.editor.EditorTopComponent; +import com.oracle.graal.visualizer.util.LookupUtils; +import com.sun.hotspot.igv.util.RangeSlider; +import com.sun.hotspot.igv.util.RangeSliderModel; +import java.awt.BorderLayout; import org.openide.awt.ActionID; import org.openide.awt.ActionReference; +import org.openide.util.Lookup.Result; +import org.openide.util.LookupEvent; +import org.openide.util.LookupListener; import org.openide.windows.TopComponent; -@TopComponent.Description(preferredID = "SnapshotTopComponent", -persistenceType = TopComponent.PERSISTENCE_NEVER) +@TopComponent.Description(preferredID = "SnapshotTopComponent", persistenceType = TopComponent.PERSISTENCE_NEVER) @TopComponent.Registration(mode = "output", openAtStartup = true) @ActionID(category = "Window", id = "com.oracle.graal.visualizer.snapshots.SnapshotTopComponent") @ActionReference(path = "Menu/Window") @TopComponent.OpenActionRegistration(displayName = "Snapshot", preferredID = "SnapshotTopComponent") public final class SnapshotTopComponent extends TopComponent { + private final Result result; + private final RangeSlider rangeSlider; + private final LookupListener lookupListener = new LookupListener() { + + @Override + public void resultChanged(LookupEvent le) { + update(); + } + }; + public SnapshotTopComponent() { initComponents(); setName("Snapshot Window"); setToolTipText("This is a Snapshot window"); + + result = LookupUtils.getLastActiveDelegatingLookup(EditorTopComponent.class).lookupResult(RangeSliderModel.class); + result.addLookupListener(lookupListener); + this.rangeSlider = new RangeSlider(null); + this.setLayout(new BorderLayout()); + this.add(rangeSlider, BorderLayout.CENTER); + update(); + + } + + private void update() { + if (result.allInstances().size() > 0) { + rangeSlider.setModel(result.allInstances().iterator().next()); + } else { + rangeSlider.setModel(null); + } } /** @@ -59,7 +92,6 @@ .addGap(0, 300, Short.MAX_VALUE) ); }// //GEN-END:initComponents - // Variables declaration - do not modify//GEN-BEGIN:variables // End of variables declaration//GEN-END:variables } diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Util/nbproject/project.xml --- a/src/share/tools/IdealGraphVisualizer/Util/nbproject/project.xml Sat Feb 04 21:41:02 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Util/nbproject/project.xml Sun Feb 05 00:46:25 2012 +0100 @@ -56,6 +56,7 @@ + com.oracle.graal.visualizer.util com.sun.hotspot.igv.util diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/Bundle.properties --- a/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/Bundle.properties Sat Feb 04 21:41:02 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/Bundle.properties Sun Feb 05 00:46:25 2012 +0100 @@ -1,1 +1,1 @@ -OpenIDE-Module-Name=Util +OpenIDE-Module-Name=Util diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/RangeSlider.java --- a/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/RangeSlider.java Sat Feb 04 21:41:02 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Util/src/com/sun/hotspot/igv/util/RangeSlider.java Sun Feb 05 00:46:25 2012 +0100 @@ -32,7 +32,7 @@ import java.util.List; import javax.swing.JComponent; -public class RangeSlider extends JComponent { +public final class RangeSlider extends JComponent { public static final int BAR_THICKNESS = 2; public static final int BAR_CIRCLE_SIZE = 9; @@ -51,8 +51,7 @@ public RangeSlider(RangeSliderModel newModel) { this.addMouseMotionListener(mouseMotionListener); this.addMouseListener(mouseListener); - newModel.getChangedEvent().addListener(modelChangedListener); - this.model = newModel; + setModel(newModel); } private RangeSliderModel getPaintingModel() { @@ -82,8 +81,8 @@ d.height = ITEM_HEIGHT * list.size(); return d; } - private ChangedListener modelChangedListener = new ChangedListener() { + @Override public void changed(RangeSliderModel source) { update(); @@ -208,17 +207,21 @@ @Override public void mouseClicked(MouseEvent e) { - int index = getIndexFromPosition(e.getPoint().y); - model.setPositions(index, index); + if (model != null) { + int index = getIndexFromPosition(e.getPoint().y); + model.setPositions(index, index); + } } @Override public void mousePressed(MouseEvent e) { - int index = getIndexFromPosition(e.getPoint().y); - startPoint = e.getPoint(); - tempModel = model.copy(); - tempModel.getChangedEvent().addListener(modelChangedListener); - tempModel.setPositions(index, index); + if (model != null) { + int index = getIndexFromPosition(e.getPoint().y); + startPoint = e.getPoint(); + tempModel = model.copy(); + tempModel.getChangedEvent().addListener(modelChangedListener); + tempModel.setPositions(index, index); + } } @Override @@ -240,4 +243,18 @@ repaint(); } }; + + public void setModel(RangeSliderModel newModel) { + if (newModel != this.model) { + if (this.model != null) { + this.model.getChangedEvent().removeListener(modelChangedListener); + } + this.model = newModel; + if (newModel != null) { + newModel.getChangedEvent().addListener(modelChangedListener); + } + this.tempModel = null; + update(); + } + } } diff -r b995eee36970 -r f721895e62e8 src/share/tools/IdealGraphVisualizer/nbproject/project.properties --- a/src/share/tools/IdealGraphVisualizer/nbproject/project.properties Sat Feb 04 21:41:02 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/nbproject/project.properties Sun Feb 05 00:46:25 2012 +0100 @@ -4,7 +4,6 @@ branding.token=${app.name} modules=\ ${project.com.sun.hotspot.igv.graph}:\ - ${project.com.oracle.graal.visualizer.outline}:\ ${project.com.sun.hotspot.igv.filter}:\ ${project.com.sun.hotspot.igv.hierarchicallayout}:\ ${project.com.sun.hotspot.igv.layout}:\ @@ -20,12 +19,11 @@ ${project.at.ssw.visualizer.cfg}:\ ${project.org.eclipse.draw2d}:\ ${project.com.oracle.graal.visualizer.editor}:\ - ${project.com.oracle.graal.visualizer.snapshots} + ${project.com.oracle.graal.visualizer.outline} project.at.ssw.visualizer.cfg=ControlFlowEditor project.com.oracle.graal.visualizer.editor=Editor -project.com.oracle.graal.visualizer.snapshots=Snapshots +project.com.oracle.graal.visualizer.outline=OutlineView project.com.sun.hotspot.igv.bytecodes=Bytecodes -project.com.oracle.graal.visualizer.outline=Outline project.com.sun.hotspot.igv.data=Data project.com.sun.hotspot.igv.difference=Difference project.com.sun.hotspot.igv.filter=Filter