# HG changeset patch # User Peter Hofer # Date 1307540190 -7200 # Node ID 53ddfe30564522d1e35a1f494355c1a725fac904 # Parent be276884eec04d87c127ce67df47125dbb53561a IdealGraphVisualizer: merge changes from the IGV project on Kenai and add Oracle copyright notices where necessary diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/genfiles.properties --- a/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/genfiles.properties Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/nbproject/genfiles.properties Wed Jun 08 15:36:30 2011 +0200 @@ -1,6 +1,3 @@ -build.xml.data.CRC32=ebcf0422 -build.xml.script.CRC32=d7a2678d -build.xml.stylesheet.CRC32=a56c6a5b@1.45.1 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=ebcf0422 diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/BatikSVGProxy/src/com/sun/hotspot/igv/svg/BatikSVG.java --- a/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/src/com/sun/hotspot/igv/svg/BatikSVG.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/src/com/sun/hotspot/igv/svg/BatikSVG.java Wed Jun 08 15:36:30 2011 +0200 @@ -31,34 +31,42 @@ import org.w3c.dom.DOMImplementation; /** - * + * Utility class * @author Thomas Wuerthinger */ public class BatikSVG { + private BatikSVG() { + } + private static Constructor SVGGraphics2DConstructor; - private static Method Method_stream; - private static Method Method_createDefault; - private static Method Method_getDOMImplementation; - private static Method Method_setEmbeddedFontsOn; + private static Method streamMethod; + private static Method createDefaultMethod; + private static Method getDOMImplementationMethod; + private static Method setEmbeddedFontsOnMethod; + private static Class classSVGGraphics2D; + /** + * Creates a graphics object that allows to be exported to SVG data using the {@link #printToStream(Graphics2D, Writer, boolean) printToStream} method. + * @return the newly created Graphics2D object or null if the library does not exist + */ public static Graphics2D createGraphicsObject() { try { if (SVGGraphics2DConstructor == null) { ClassLoader cl = BatikSVG.class.getClassLoader(); - Class Class_GenericDOMImplementation = cl.loadClass("org.apache.batik.dom.GenericDOMImplementation"); - Class Class_SVGGeneratorContext = cl.loadClass("org.apache.batik.svggen.SVGGeneratorContext"); - Class Class_SVGGraphics2D = cl.loadClass("org.apache.batik.svggen.SVGGraphics2D"); - Method_getDOMImplementation = Class_GenericDOMImplementation.getDeclaredMethod("getDOMImplementation", new Class[0]); - Method_createDefault = Class_SVGGeneratorContext.getDeclaredMethod("createDefault", new Class[]{org.w3c.dom.Document.class}); - Method_setEmbeddedFontsOn = Class_SVGGeneratorContext.getDeclaredMethod("setEmbeddedFontsOn", new Class[]{boolean.class}); - Method_stream = Class_SVGGraphics2D.getDeclaredMethod("stream", Writer.class, boolean.class); - SVGGraphics2DConstructor = Class_SVGGraphics2D.getConstructor(Class_SVGGeneratorContext, boolean.class); + Class classGenericDOMImplementation = cl.loadClass("org.apache.batik.dom.GenericDOMImplementation"); + Class classSVGGeneratorContext = cl.loadClass("org.apache.batik.svggen.SVGGeneratorContext"); + classSVGGraphics2D = cl.loadClass("org.apache.batik.svggen.SVGGraphics2D"); + getDOMImplementationMethod = classGenericDOMImplementation.getDeclaredMethod("getDOMImplementation", new Class[0]); + createDefaultMethod = classSVGGeneratorContext.getDeclaredMethod("createDefault", new Class[]{org.w3c.dom.Document.class}); + setEmbeddedFontsOnMethod = classSVGGeneratorContext.getDeclaredMethod("setEmbeddedFontsOn", new Class[]{boolean.class}); + streamMethod = classSVGGraphics2D.getDeclaredMethod("stream", Writer.class, boolean.class); + SVGGraphics2DConstructor = classSVGGraphics2D.getConstructor(classSVGGeneratorContext, boolean.class); } - DOMImplementation dom = (DOMImplementation) Method_getDOMImplementation.invoke(null); + DOMImplementation dom = (DOMImplementation) getDOMImplementationMethod.invoke(null); org.w3c.dom.Document document = dom.createDocument("http://www.w3.org/2000/svg", "svg", null); - Object ctx = Method_createDefault.invoke(null, document); - Method_setEmbeddedFontsOn.invoke(ctx, true); + Object ctx = createDefaultMethod.invoke(null, document); + setEmbeddedFontsOnMethod.invoke(ctx, true); Graphics2D svgGenerator = (Graphics2D) SVGGraphics2DConstructor.newInstance(ctx, true); return svgGenerator; } catch (ClassNotFoundException e) { @@ -74,9 +82,17 @@ } } + /** + * Serializes a graphics object to a stream in SVG format. + * @param svgGenerator the graphics object. Only graphics objects created by the {@link #createGraphicsObject() createGraphicsObject} method are valid. + * @param stream the stream to which the data is written + * @param useCSS whether to use CSS styles in the SVG output + */ public static void printToStream(Graphics2D svgGenerator, Writer stream, boolean useCSS) { + assert classSVGGraphics2D != null; + assert classSVGGraphics2D.isInstance(svgGenerator); try { - Method_stream.invoke(svgGenerator, stream, useCSS); + streamMethod.invoke(svgGenerator, stream, useCSS); } catch (IllegalAccessException e) { assert false; } catch (InvocationTargetException e) { diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/BatikSVGProxy/src/com/sun/hotspot/igv/svg/package-info.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/BatikSVGProxy/src/com/sun/hotspot/igv/svg/package-info.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +/** + * This package is used to proxy the SVG export functionality of the BatikSVG library. Reflection is used such that the + * library is optional and need not be present at build time. + */ +package com.sun.hotspot.igv.svg; + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/project.xml --- a/src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/project.xml Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Bytecodes/nbproject/project.xml Wed Jun 08 15:36:30 2011 +0200 @@ -15,6 +15,22 @@ + com.sun.hotspot.igv.graph + + + + 1.0 + + + + com.sun.hotspot.igv.util + + + + 1.0 + + + org.jdesktop.layout diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeNode.java --- a/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeNode.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeNode.java Wed Jun 08 15:36:30 2011 +0200 @@ -30,6 +30,7 @@ import com.sun.hotspot.igv.data.Properties.StringPropertyMatcher; import java.awt.Image; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; import javax.swing.Action; @@ -58,7 +59,7 @@ StringPropertyMatcher matcher = new StringPropertyMatcher("bci", bciValue); List nodeList = selector.selectMultiple(matcher); if (nodeList.size() > 0) { - nodes = new HashSet(); + nodes = new LinkedHashSet(); for (InputNode n : nodeList) { nodes.add(n); } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.form --- a/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.form Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.form Wed Jun 08 15:36:30 2011 +0200 @@ -3,6 +3,8 @@
+ + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.java --- a/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/BytecodeViewTopComponent.java Wed Jun 08 15:36:30 2011 +0200 @@ -26,6 +26,7 @@ import com.sun.hotspot.igv.data.Group; import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.services.InputGraphProvider; +import com.sun.hotspot.igv.util.LookupHistory; import java.awt.BorderLayout; import java.io.Serializable; import javax.swing.SwingUtilities; @@ -91,6 +92,7 @@ }// //GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables // End of variables declaration//GEN-END:variables + /** * Gets default instance. Do not use directly: reserved for *.settings files only, * i.e. deserialization routines; otherwise you could get a non-deserialized instance. @@ -126,7 +128,7 @@ @Override public void componentOpened() { - Lookup.Template tpl = new Lookup.Template(Object.class); + Lookup.Template tpl = new Lookup.Template(InputGraphProvider.class); result = Utilities.actionsGlobalContext().lookup(tpl); result.addLookupListener(this); } @@ -151,17 +153,35 @@ return manager; } + @Override + public void requestActive() { + super.requestActive(); + this.treeView.requestFocus(); + } + + @Override + public boolean requestFocus(boolean temporary) { + this.treeView.requestFocus(); + return super.requestFocus(temporary); + } + + @Override + protected boolean requestFocusInWindow(boolean temporary) { + this.treeView.requestFocus(); + return super.requestFocusInWindow(temporary); + } + public void resultChanged(LookupEvent lookupEvent) { - final InputGraphProvider p = Lookup.getDefault().lookup(InputGraphProvider.class); + final InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);//)Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); if (p != null) { SwingUtilities.invokeLater(new Runnable() { public void run() { - InputGraph graph = p.getGraph(); - if (graph != null) { - Group g = graph.getGroup(); - rootNode.update(graph, g.getMethod()); - } - } + InputGraph graph = p.getGraph(); + if (graph != null) { + Group g = graph.getGroup(); + rootNode.update(graph, g.getMethod()); + } + } }); } } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/SelectBytecodesAction.java --- a/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/SelectBytecodesAction.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Bytecodes/src/com/sun/hotspot/igv/bytecodes/SelectBytecodesAction.java Wed Jun 08 15:36:30 2011 +0200 @@ -24,10 +24,11 @@ package com.sun.hotspot.igv.bytecodes; import com.sun.hotspot.igv.data.services.InputGraphProvider; +import com.sun.hotspot.igv.util.LookupHistory; import org.openide.nodes.Node; import org.openide.util.HelpCtx; -import org.openide.util.Lookup; import org.openide.util.NbBundle; +import org.openide.util.Utilities; import org.openide.util.actions.CookieAction; /** @@ -38,7 +39,7 @@ protected void performAction(Node[] activatedNodes) { SelectBytecodesCookie c = activatedNodes[0].getCookie(SelectBytecodesCookie.class); - InputGraphProvider p = Lookup.getDefault().lookup(InputGraphProvider.class); + InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);//Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); if (p != null) { p.setSelectedNodes(c.getNodes()); } @@ -73,3 +74,4 @@ return false; } } + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/project.xml --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/project.xml Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlow/nbproject/project.xml Wed Jun 08 15:36:30 2011 +0200 @@ -31,6 +31,14 @@ + com.sun.hotspot.igv.util + + + + 1.0 + + + org.jdesktop.layout diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockConnectionWidget.java --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockConnectionWidget.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockConnectionWidget.java Wed Jun 08 15:36:30 2011 +0200 @@ -23,7 +23,7 @@ */ package com.sun.hotspot.igv.controlflow; -import com.sun.hotspot.igv.data.InputBlockEdge; +import com.sun.hotspot.igv.controlflow.InputBlockEdge; import com.sun.hotspot.igv.layout.Link; import com.sun.hotspot.igv.layout.Port; import java.awt.Point; diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockWidget.java --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockWidget.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockWidget.java Wed Jun 08 15:36:30 2011 +0200 @@ -47,7 +47,7 @@ private Port outputSlot; private Cluster cluster; private boolean root; - private static final Font font = new Font(Font.SERIF, Font.PLAIN, 12); + private static final Font font = new Font("Serif", Font.PLAIN, 12); private static final Font boldFont = font.deriveFont(Font.BOLD); public static final Color NORMAL_FOREGROUND_COLOR = Color.BLACK; public static final Color HOVER_FOREGROUND_COLOR = Color.BLUE; diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowScene.java --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowScene.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowScene.java Wed Jun 08 15:36:30 2011 +0200 @@ -24,16 +24,16 @@ package com.sun.hotspot.igv.controlflow; import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.data.InputBlockEdge; +import com.sun.hotspot.igv.controlflow.InputBlockEdge; import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.services.InputGraphProvider; import com.sun.hotspot.igv.data.InputNode; +import com.sun.hotspot.igv.util.LookupHistory; import java.awt.Color; import java.awt.Point; import java.awt.Rectangle; import java.util.ArrayList; import java.util.HashSet; -import java.util.HashMap; import java.util.Set; import javax.swing.BorderFactory; import org.netbeans.api.visual.action.ActionFactory; @@ -52,7 +52,7 @@ import org.netbeans.api.visual.graph.layout.GraphLayout; import org.netbeans.api.visual.layout.SceneLayout; import org.netbeans.api.visual.widget.ConnectionWidget; -import org.openide.util.Lookup; +import org.openide.util.Utilities; /** * @@ -61,7 +61,6 @@ public class ControlFlowScene extends GraphScene implements SelectProvider, MoveProvider, RectangularSelectDecorator, RectangularSelectProvider { private HashSet selection; - private HashMap blockMap; private InputGraph oldGraph; private LayerWidget edgeLayer; private LayerWidget mainLayer; @@ -81,7 +80,7 @@ edgeLayer = new LayerWidget(this); this.addChild(edgeLayer); - + selectLayer = new LayerWidget(this); this.addChild(selectLayer); @@ -112,7 +111,8 @@ } for (InputBlock b : g.getBlocks()) { - for (InputBlockEdge e : b.getOutputs()) { + for (InputBlock succ : b.getSuccessors()) { + final InputBlockEdge e = new InputBlockEdge(b, succ); addEdge(e); assert g.getBlocks().contains(e.getFrom()); assert g.getBlocks().contains(e.getTo()); @@ -128,10 +128,6 @@ this.validate(); } - public BlockWidget getBlockWidget(InputBlock b) { - return blockMap.get(b); - } - public void clearSelection() { for (BlockWidget w : selection) { w.setState(w.getState().deriveSelected(false)); @@ -141,7 +137,7 @@ } public void selectionChanged() { - InputGraphProvider p = Lookup.getDefault().lookup(InputGraphProvider.class); + InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);//)Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); if (p != null) { Set inputNodes = new HashSet(); for (BlockWidget w : selection) { diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.form --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.form Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.form Wed Jun 08 15:36:30 2011 +0200 @@ -3,6 +3,8 @@ + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.java --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.java Wed Jun 08 15:36:30 2011 +0200 @@ -25,6 +25,7 @@ import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.services.InputGraphProvider; +import com.sun.hotspot.igv.util.LookupHistory; import java.awt.BorderLayout; import java.io.Serializable; import javax.swing.JScrollPane; @@ -39,7 +40,7 @@ import org.openide.windows.WindowManager; /** - * + * * @author Thomas Wuerthinger */ final class ControlFlowTopComponent extends TopComponent implements LookupListener { @@ -63,17 +64,7 @@ this.add(panel, BorderLayout.CENTER); } - @Override - public void requestFocus() { - super.requestFocus(); - scene.getView().requestFocus(); - } - @Override - public boolean requestFocusInWindow() { - super.requestFocusInWindow(); - return scene.getView().requestFocusInWindow(); - } /** This method is called from within the constructor to * initialize the form. @@ -96,6 +87,7 @@ }// //GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables // End of variables declaration//GEN-END:variables + /** * Gets default instance. Do not use directly: reserved for *.settings files only, * i.e. deserialization routines; otherwise you could get a non-deserialized instance. @@ -131,7 +123,7 @@ @Override public void componentOpened() { - Lookup.Template tpl = new Lookup.Template(Object.class); + Lookup.Template tpl = new Lookup.Template(InputGraphProvider.class); result = Utilities.actionsGlobalContext().lookup(tpl); result.addLookupListener(this); } @@ -143,16 +135,16 @@ } public void resultChanged(LookupEvent lookupEvent) { - - final InputGraphProvider p = Lookup.getDefault().lookup(InputGraphProvider.class); + final InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);//Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); if (p != null) { SwingUtilities.invokeLater(new Runnable() { + public void run() { - InputGraph g = p.getGraph(); - if (g != null) { - scene.setGraph(g); - } - } + InputGraph g = p.getGraph(); + if (g != null) { + scene.setGraph(g); + } + } }); } } @@ -169,8 +161,8 @@ @Override public void requestActive() { - scene.getView().requestFocusInWindow(); super.requestActive(); + scene.getView().requestFocus(); } final static class ResolvableHelper implements Serializable { diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/HierarchicalGraphLayout.java --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/HierarchicalGraphLayout.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/HierarchicalGraphLayout.java Wed Jun 08 15:36:30 2011 +0200 @@ -35,6 +35,7 @@ import java.util.Collection; import java.util.HashMap; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -137,9 +138,9 @@ } protected void performGraphLayout(UniversalGraph graph) { - - Set links = new HashSet(); - Set vertices = new HashSet(); + + Set links = new LinkedHashSet(); + Set vertices = new LinkedHashSet(); Map vertexMap = new HashMap(); for (N node : graph.getNodes()) { diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/InputBlockEdge.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/InputBlockEdge.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package com.sun.hotspot.igv.controlflow; + +import com.sun.hotspot.igv.data.*; + +/** + * + * @author Thomas Wuerthinger + */ +public class InputBlockEdge { + + private InputBlock from; + private InputBlock to; + + public InputBlockEdge(InputBlock from, InputBlock to) { + assert from != null; + assert to != null; + this.from = from; + this.to = to; + } + + public InputBlock getFrom() { + return from; + } + + public InputBlock getTo() { + return to; + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof InputBlockEdge && obj != null) { + InputBlockEdge e = (InputBlockEdge) obj; + return e.from.equals(from) && e.to.equals(to); + } + return super.equals(obj); + } + + @Override + public int hashCode() { + int hash = from.hashCode(); + hash = 59 * hash + to.hashCode(); + return hash; + } +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.xml --- a/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.xml Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.xml Wed Jun 08 15:36:30 2011 +0200 @@ -48,6 +48,14 @@ + org.netbeans.spi.quicksearch + + + + 1.0 + + + org.openide.actions diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/Bundle.properties --- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/Bundle.properties Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/Bundle.properties Wed Jun 08 15:36:30 2011 +0200 @@ -5,3 +5,5 @@ CTL_SomeAction=test HINT_OutlineTopComponent=This is a Outline window OpenIDE-Module-Name=Coordinator +Toolbars/QuickSearch=Quick Search +QuickSearch/Nodes/com-sun-hotspot-igv-coordinator-QuickSearch.instance=Nodes diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java --- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java Wed Jun 08 15:36:30 2011 +0200 @@ -25,6 +25,7 @@ import com.sun.hotspot.igv.coordinator.actions.RemoveCookie; import com.sun.hotspot.igv.data.ChangedListener; +import com.sun.hotspot.igv.data.GraphDocument; import com.sun.hotspot.igv.data.Group; import com.sun.hotspot.igv.data.services.GroupOrganizer; import com.sun.hotspot.igv.data.InputGraph; @@ -55,6 +56,11 @@ private FolderNode parent; private List registeredGroups; + private GraphDocument document; + + public FolderChildren(GraphDocument document) { + this.document = document; + } public void setParent(FolderNode parent) { this.parent = parent; @@ -68,7 +74,7 @@ g.getChangedEvent().removeListener(this); } registeredGroups.clear(); - + Pair> p = (Pair>) arg0; if (p.getLeft().length() == 0) { @@ -88,7 +94,7 @@ return result; } else { - return new Node[]{new FolderNode(p.getLeft(), parent.organizer, parent.subFolders, p.getRight())}; + return new Node[]{new FolderNode(document, p.getLeft(), parent.organizer, parent.subFolders, p.getRight())}; } } @@ -96,13 +102,12 @@ public void addNotify() { this.setKeys(parent.structure); } - + public void changed(Group source) { - List>> newStructure = new ArrayList>>(); for(Pair> p : parent.structure) { refreshKey(p); } - } + } } protected InstanceContent getContent() { @@ -114,11 +119,11 @@ return Utilities.loadImage("com/sun/hotspot/igv/coordinator/images/folder.gif"); } - protected FolderNode(String name, GroupOrganizer organizer, List subFolders, List groups) { - this(name, organizer, subFolders, groups, new FolderChildren(), new InstanceContent()); + protected FolderNode(GraphDocument document, String name, GroupOrganizer organizer, List subFolders, List groups) { + this(document, name, organizer, subFolders, groups, new FolderChildren(document), new InstanceContent()); } - private FolderNode(String name, GroupOrganizer organizer, List oldSubFolders, final List groups, FolderChildren children, InstanceContent content) { + private FolderNode(final GraphDocument document, String name, GroupOrganizer organizer, List oldSubFolders, final List groups, FolderChildren children, InstanceContent content) { super(children, new AbstractLookup(content)); children.setParent(this); this.content = content; @@ -127,9 +132,8 @@ public void remove() { for (Group g : groups) { - if (g.getDocument() != null) { - g.getDocument().removeGroup(g); - } + document.removeGroup(g); + } } }); diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphCountGroupOrganizer.java --- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphCountGroupOrganizer.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphCountGroupOrganizer.java Wed Jun 08 15:36:30 2011 +0200 @@ -49,7 +49,7 @@ List>> result = new ArrayList>>(); if (subFolders.size() == 0) { - Map> map = new HashMap>(); + Map> map = new HashMap>(groups.size()); for (Group g : groups) { Integer cur = g.getGraphs().size(); if (!map.containsKey(cur)) { diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java --- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java Wed Jun 08 15:36:30 2011 +0200 @@ -27,8 +27,8 @@ import com.sun.hotspot.igv.coordinator.actions.DiffGraphCookie; import com.sun.hotspot.igv.coordinator.actions.RemoveCookie; import com.sun.hotspot.igv.data.InputGraph; +import com.sun.hotspot.igv.data.Properties; import com.sun.hotspot.igv.data.services.GraphViewer; -import com.sun.hotspot.igv.data.services.InputGraphProvider; import com.sun.hotspot.igv.util.PropertiesSheet; import java.awt.Image; import javax.swing.Action; @@ -36,7 +36,6 @@ import org.openide.cookies.OpenCookie; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; -import org.openide.nodes.Node; import org.openide.nodes.Sheet; import org.openide.util.Lookup; import org.openide.util.Utilities; @@ -81,12 +80,19 @@ graph.getGroup().removeGraph(graph); } }); + + // Action for diffing to the current graph + content.add(new DiffGraphCookie(graph)); } @Override protected Sheet createSheet() { Sheet s = super.createSheet(); - PropertiesSheet.initializeSheet(graph.getProperties(), s); + Properties p = new Properties(); + p.add(graph.getProperties()); + p.setProperty("nodeCount", Integer.toString(graph.getNodes().size())); + p.setProperty("edgeCount", Integer.toString(graph.getEdges().size())); + PropertiesSheet.initializeSheet(p, s); return s; } @@ -101,24 +107,6 @@ } @Override - public T getCookie(Class aClass) { - if (aClass == DiffGraphCookie.class) { - InputGraphProvider graphProvider = Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); - - InputGraph graphA = null; - if (graphProvider != null) { - graphA = graphProvider.getGraph(); - } - - if (graphA != null && !graphA.isDifferenceGraph()) { - return (T) new DiffGraphCookie(graphA, graph); - } - } - - return super.getCookie(aClass); - } - - @Override public Action[] getActions(boolean b) { return new Action[]{(Action) DiffGraphAction.findObject(DiffGraphAction.class, true), (Action) OpenAction.findObject(OpenAction.class, true)}; } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.form --- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.form Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.form Wed Jun 08 15:36:30 2011 +0200 @@ -3,6 +3,8 @@ + + @@ -23,7 +25,7 @@ - + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java --- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java Wed Jun 08 15:36:30 2011 +0200 @@ -62,7 +62,7 @@ import org.openide.windows.WindowManager; /** - * + * * @author Thomas Wuerthinger */ public final class OutlineTopComponent extends TopComponent implements ExplorerManager.Provider, LookupListener { @@ -89,9 +89,9 @@ private void initListView() { manager = new ExplorerManager(); organizer = new StandardGroupOrganizer(); - root = new FolderNode("", organizer, new ArrayList(), document.getGroups()); + root = new FolderNode(document, "", organizer, new ArrayList(), document.getGroups()); manager.setRootContext(root); - ((BeanTreeView) this.jScrollPane1).setRootVisible(false); + ((BeanTreeView) this.treeView).setRootVisible(false); document.getChangedEvent().addListener(new ChangedListener() { @@ -122,8 +122,6 @@ for (Toolbar tb : ToolbarPool.getDefault().getToolbars()) { tb.setVisible(false); } - - initOrganizers(); } public void setOrganizer(GroupOrganizer organizer) { @@ -131,10 +129,6 @@ updateStructure(); } - private void initOrganizers() { - - } - private void initReceivers() { final GroupCallback callback = new GroupCallback() { @@ -221,6 +215,24 @@ 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); + } + public void resultChanged(LookupEvent lookupEvent) { } @@ -228,7 +240,7 @@ public void readExternal(ObjectInput objectInput) throws IOException, ClassNotFoundException { // Not called when user starts application for the first time super.readExternal(objectInput); - ((BeanTreeView) this.jScrollPane1).setRootVisible(false); + ((BeanTreeView) this.treeView).setRootVisible(false); } @Override @@ -254,18 +266,18 @@ private void initComponents() { jPanel2 = new javax.swing.JPanel(); - jScrollPane1 = new BeanTreeView(); + treeView = new BeanTreeView(); setLayout(new java.awt.BorderLayout()); jPanel2.setLayout(new java.awt.BorderLayout()); - jPanel2.add(jScrollPane1, java.awt.BorderLayout.CENTER); + jPanel2.add(treeView, java.awt.BorderLayout.CENTER); add(jPanel2, java.awt.BorderLayout.CENTER); }// //GEN-END:initComponents // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JPanel jPanel2; - private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane treeView; // End of variables declaration//GEN-END:variables } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardConfiguration.xml --- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardConfiguration.xml Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardConfiguration.xml Wed Jun 08 15:36:30 2011 +0200 @@ -5,6 +5,7 @@ + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardGroupOrganizer.java --- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardGroupOrganizer.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardGroupOrganizer.java Wed Jun 08 15:36:30 2011 +0200 @@ -50,10 +50,15 @@ for (Group g : groups) { List children = new ArrayList(); children.add(g); - Pair> p = new Pair>(); - p.setLeft(g.getName()); - p.setRight(children); - result.add(p); + if(g.getGraphs().size() == 1) { + //g.getGraphs().get(0).setName(g.getName() + " / " + g.getGraphs().get(0).getName()); + result.add(new Pair>("", children)); + } else { + Pair> p = new Pair>(); + p.setLeft(g.getName()); + p.setRight(children); + result.add(p); + } } } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/Bundle.properties --- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/Bundle.properties Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/Bundle.properties Wed Jun 08 15:36:30 2011 +0200 @@ -1,18 +1,9 @@ -CTL_EditFilterAction=Edit... CTL_ImportAction=Open... CTL_OpenGraphAction=View graph CTL_DiffGraphAction=Difference to current graph CTL_RemoveAction=Remove methods -CTL_ApplyFilterAction=Apply -CTL_FilterAction=Open Filter Window -CTL_AppliedFilterAction=Open AppliedFilter Window -CTL_OutlineAction=Open Outline Window -CTL_MoveFilterUpAction=Move upwards -CTL_MoveFilterDownAction=Move downwards -CTL_RemoveFilterAction=Remove -CTL_RemoveFilterSettingsAction=Remove filter setting +CTL_OutlineAction=Open Outline Window CTL_SaveAsAction=Save selected methods... CTL_SaveAllAction=Save all... -CTL_SaveFilterSettingsAction=Save filter settings... -CTL_PropertiesAction=Open Properties Window +CTL_PropertiesAction=Open Properties Window CTL_NewFilterAction=New filter... diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphAction.java --- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphAction.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphAction.java Wed Jun 08 15:36:30 2011 +0200 @@ -37,6 +37,7 @@ protected void performAction(Node[] activatedNodes) { DiffGraphCookie c = activatedNodes[0].getCookie(DiffGraphCookie.class); + assert c != null; c.openDiff(); } @@ -44,6 +45,19 @@ return CookieAction.MODE_EXACTLY_ONE; } + @Override + protected boolean enable(Node[] activatedNodes) { + boolean b = super.enable(activatedNodes); + if (b) { + assert activatedNodes.length == 1; + DiffGraphCookie c = activatedNodes[0].getCookie(DiffGraphCookie.class); + assert c != null; + return c.isPossible(); + } + + return false; + } + public String getName() { return NbBundle.getMessage(DiffGraphAction.class, "CTL_DiffGraphAction"); } @@ -68,3 +82,4 @@ return false; } } + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphCookie.java --- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphCookie.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphCookie.java Wed Jun 08 15:36:30 2011 +0200 @@ -26,9 +26,12 @@ import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.services.GraphViewer; +import com.sun.hotspot.igv.data.services.InputGraphProvider; import com.sun.hotspot.igv.difference.Difference; +import com.sun.hotspot.igv.util.LookupHistory; import org.openide.nodes.Node; import org.openide.util.Lookup; +import org.openide.util.Utilities; /** * @@ -37,19 +40,31 @@ public class DiffGraphCookie implements Node.Cookie { private InputGraph a; - private InputGraph b; + + public DiffGraphCookie(InputGraph a) { + this.a = a; + } - public DiffGraphCookie(InputGraph a, InputGraph b) { - this.a = a; - this.b = b; + private InputGraph getCurrentGraph() { + + InputGraphProvider graphProvider = LookupHistory.getLast(InputGraphProvider.class);//)Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); + if (graphProvider != null) { + return graphProvider.getGraph(); + } + + return null; + } + + public boolean isPossible() { + return getCurrentGraph() != null; } public void openDiff() { - + final GraphViewer viewer = Lookup.getDefault().lookup(GraphViewer.class); - + InputGraph other = getCurrentGraph(); if(viewer != null) { - InputGraph diffGraph = Difference.createDiffGraph(a, b); + InputGraph diffGraph = Difference.createDiffGraph(other, a); viewer.view(diffGraph); } } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml --- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/layer.xml Wed Jun 08 15:36:30 2011 +0200 @@ -12,7 +12,7 @@ - + @@ -26,7 +26,7 @@ - + @@ -57,7 +57,7 @@ - + @@ -98,13 +98,22 @@ - + + + + + + + + + - + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/nbproject/project.properties --- a/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.properties Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.properties Wed Jun 08 15:36:30 2011 +0200 @@ -1,2 +1,8 @@ javac.source=1.5 javac.compilerargs=-Xlint -Xlint:-serial +src.dir=src +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +test.src.dir=test +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/nbproject/project.xml --- a/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.xml Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.xml Wed Jun 08 15:36:30 2011 +0200 @@ -6,6 +6,19 @@ com.sun.hotspot.igv.data + + + unit + + org.netbeans.libs.junit4 + + + + org.openide.util + + + + com.sun.hotspot.igv.data com.sun.hotspot.igv.data.serialization diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEvent.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEvent.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEvent.java Wed Jun 08 15:36:30 2011 +0200 @@ -24,16 +24,17 @@ package com.sun.hotspot.igv.data; /** - * + * Class representing a generic changed event. * @author Thomas Wuerthinger + * @param */ public class ChangedEvent extends Event> { private T object; - public ChangedEvent() { - } - + /** + * Creates a new event with the specific object as the one for which the event gets fired. + */ public ChangedEvent(T object) { this.object = object; } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEventProvider.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEventProvider.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedEventProvider.java Wed Jun 08 15:36:30 2011 +0200 @@ -25,10 +25,14 @@ package com.sun.hotspot.igv.data; /** - * + * Provides a changed event object. * @author Thomas Wuerthinger + * @param Class for which the changed event fires. */ public interface ChangedEventProvider { - public ChangedEvent getChangedEvent(); + /** + * Returns the changed event object. Should always return the same instance. + */ + ChangedEvent getChangedEvent(); } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedListener.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedListener.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ChangedListener.java Wed Jun 08 15:36:30 2011 +0200 @@ -24,10 +24,15 @@ package com.sun.hotspot.igv.data; /** - * + * Listens to changed events. * @author Thomas Wuerthinger + * @param Class for which the changed event fires. */ public interface ChangedListener { - public void changed(T source); + /** + * This method is called everytime a changed event is fired. + * @param source Object that has changed. + */ + void changed(T source); } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ControllableChangedListener.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/ControllableChangedListener.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.data; + +/** + * + * @author Thomas Wuerthinger + */ +public abstract class ControllableChangedListener implements ChangedListener{ + + private boolean enabled; + + + public ControllableChangedListener() { + enabled = true; + } + + public boolean isEnabled() { + return enabled; + } + + public void setEnabled(boolean b) { + enabled = b; + } + + public void changed(T source) { + if(enabled) { + filteredChanged(source); + } + } + + public abstract void filteredChanged(T source); +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Event.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Event.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Event.java Wed Jun 08 15:36:30 2011 +0200 @@ -33,25 +33,50 @@ public abstract class Event { private List listener; - + private boolean fireEvents; + private boolean eventWasFired; + public Event() { listener = new ArrayList(); + fireEvents = true; } public void addListener(L l) { listener.add(l); } - public void removeListener(L l) { + /** + * Remove listener + * @param l + */ + public void removeListener(final L l) { listener.remove(l); } public void fire() { - List tmpList = new ArrayList(listener); - for (L l : tmpList) { - fire(l); + if(fireEvents) { + List tmpList = new ArrayList(listener); + for (L l : tmpList) { + fire(l); + } + } else { + eventWasFired = true; } } + public void beginAtomic() { + assert fireEvents : "endAtomic has to be called before another beginAtomic may be called"; + this.fireEvents = false; + this.eventWasFired = false; + } + + public void endAtomic() { + assert !fireEvents : "beginAtomic has to be called first"; + this.fireEvents = true; + if(eventWasFired) { + fire(); + } + } + protected abstract void fire(L l); } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java Wed Jun 08 15:36:30 2011 +0200 @@ -55,14 +55,12 @@ } public void addGroup(Group group) { - group.setDocument(this); groups.add(group); getChangedEvent().fire(); } public void removeGroup(Group group) { if (groups.contains(group)) { - group.setDocument(null); groups.remove(group); getChangedEvent().fire(); } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Group.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Group.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Group.java Wed Jun 08 15:36:30 2011 +0200 @@ -23,10 +23,6 @@ */ package com.sun.hotspot.igv.data; -import com.sun.hotspot.igv.data.ChangedEvent; -import com.sun.hotspot.igv.data.ChangedEventProvider; -import com.sun.hotspot.igv.data.Properties; -import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; @@ -40,18 +36,17 @@ public class Group extends Properties.Entity implements ChangedEventProvider { private List graphs; - private transient ChangedEvent changedEvent; - private GraphDocument document; private InputMethod method; private String assembly; + private transient ChangedEvent changedEvent; public Group() { graphs = new ArrayList(); - init(); - } + changedEvent = new ChangedEvent(this); - private void init() { - changedEvent = new ChangedEvent(this); + // Ensure that name and type are never null + getProperties().setProperty("name", ""); + getProperties().setProperty("type", ""); } public void fireChangedEvent() { @@ -74,14 +69,6 @@ return method; } - void setDocument(GraphDocument document) { - this.document = document; - } - - public GraphDocument getDocument() { - return document; - } - public ChangedEvent getChangedEvent() { return changedEvent; } @@ -90,11 +77,15 @@ return Collections.unmodifiableList(graphs); } - public void addGraph(InputGraph g) { - assert g != null; - assert !graphs.contains(g); + public InputGraph addGraph(String name) { + return addGraph(name, null); + } + + public InputGraph addGraph(String name, Pair pair) { + InputGraph g = new InputGraph(graphs.size(), this, name, pair); graphs.add(g); changedEvent.fire(); + return g; } public void removeGraph(InputGraph g) { @@ -110,20 +101,10 @@ for (InputGraph g : graphs) { Set ids = g.getNodesAsSet(); result.addAll(g.getNodesAsSet()); - for (Integer i : ids) { - result.add(-i); - } } return result; } - public InputGraph getLastAdded() { - if (graphs.size() == 0) { - return null; - } - return graphs.get(graphs.size() - 1); - } - @Override public String toString() { StringBuilder sb = new StringBuilder(); @@ -138,4 +119,8 @@ public String getName() { return getProperties().get("name"); } + + public String getType() { + return getProperties().get("type"); + } } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlock.java Wed Jun 08 15:36:30 2011 +0200 @@ -23,10 +23,10 @@ */ package com.sun.hotspot.igv.data; -import java.awt.Rectangle; import java.util.ArrayList; import java.util.Collections; import java.util.HashSet; +import java.util.LinkedHashSet; import java.util.List; import java.util.Set; @@ -37,46 +37,57 @@ public class InputBlock { private List nodes; - private List successorNames; private String name; private InputGraph graph; - private Rectangle bounds; private Set successors; - private Set predecessors; - private Set inputs; - private Set outputs; + + @Override + public int hashCode() { + return name.hashCode(); + } + + @Override + public boolean equals(Object o) { + + if (o == this) { + return true; + } - public InputBlock(InputGraph graph, String name) { + if (o == null || (!(o instanceof InputBlock))) { + return false; + } + + final InputBlock b = (InputBlock)o; + final boolean result = b.nodes.equals(nodes) && b.name.equals(name) && b.successors.size() == successors.size(); + if (!result) { + return false; + } + + final HashSet s = new HashSet(); + for (InputBlock succ : successors) { + s.add(succ.name); + } + + for (InputBlock succ : b.successors) { + if (!s.contains(succ.name)) { + return false; + } + } + + return true; + } + + InputBlock(InputGraph graph, String name) { this.graph = graph; this.name = name; nodes = new ArrayList(); - successorNames = new ArrayList(); - successors = new HashSet(); - predecessors = new HashSet(); - inputs = new HashSet(); - outputs = new HashSet(); - } - - public void removeSuccessor(InputBlock b) { - if (successors.contains(b)) { - successors.remove(b); - b.predecessors.remove(this); - InputBlockEdge e = new InputBlockEdge(this, b); - assert outputs.contains(e); - outputs.remove(e); - assert b.inputs.contains(e); - b.inputs.remove(e); - } + successors = new LinkedHashSet(2); } public String getName() { return name; } - public void setName(String s) { - name = s; - } - public List getNodes() { return Collections.unmodifiableList(nodes); } @@ -85,56 +96,24 @@ InputNode n = graph.getNode(id); assert n != null; graph.setBlock(n, this); - addNode(graph.getNode(id)); - } - - public void addNode(InputNode node) { + final InputNode node = graph.getNode(id); + assert node != null; assert !nodes.contains(node); nodes.add(node); } - public Set getPredecessors() { - return Collections.unmodifiableSet(predecessors); - } - public Set getSuccessors() { return Collections.unmodifiableSet(successors); } - public Set getInputs() { - return Collections.unmodifiableSet(inputs); - } - - public Set getOutputs() { - return Collections.unmodifiableSet(outputs); - } - - // resolveBlockLinks must be called afterwards - public void addSuccessor(String name) { - successorNames.add(name); + @Override + public String toString() { + return "Block " + this.getName(); } - public void resolveBlockLinks() { - for (String s : successorNames) { - InputBlock b = graph.getBlock(s); - addSuccessor(b); - } - - successorNames.clear(); - } - - public void addSuccessor(InputBlock b) { + void addSuccessor(InputBlock b) { if (!successors.contains(b)) { successors.add(b); - b.predecessors.add(this); - InputBlockEdge e = new InputBlockEdge(this, b); - outputs.add(e); - b.inputs.add(e); } } - - @Override - public String toString() { - return this.getName(); - } } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlockEdge.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputBlockEdge.java Wed Jun 08 14:50:55 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.data; - -/** - * - * @author Thomas Wuerthinger - */ -public class InputBlockEdge { - - private InputBlock from; - private InputBlock to; - - public InputBlockEdge(InputBlock from, InputBlock to) { - assert from != null; - assert to != null; - this.from = from; - this.to = to; - } - - public InputBlock getFrom() { - return from; - } - - public InputBlock getTo() { - return to; - } - - @Override - public boolean equals(Object obj) { - if (obj instanceof InputBlockEdge && obj != null) { - InputBlockEdge e = (InputBlockEdge) obj; - return e.from.equals(from) && e.to.equals(to); - } - return super.equals(obj); - } - - @Override - public int hashCode() { - int hash = from.hashCode(); - hash = 59 * hash + to.hashCode(); - return hash; - } -} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputEdge.java Wed Jun 08 15:36:30 2011 +0200 @@ -23,6 +23,8 @@ */ package com.sun.hotspot.igv.data; +import java.util.Comparator; + /** * * @author Thomas Wuerthinger @@ -35,15 +37,41 @@ NEW, DELETED } + + public static final Comparator OUTGOING_COMPARATOR = new Comparator(){ + + public int compare(InputEdge o1, InputEdge o2) { + if(o1.getFromIndex() == o2.getFromIndex()) { + return o1.getTo() - o2.getTo(); + } + return o1.getFromIndex() - o2.getFromIndex(); + } + }; + + + public static final Comparator INGOING_COMPARATOR = new Comparator(){ + + public int compare(InputEdge o1, InputEdge o2) { + if(o1.getToIndex() == o2.getToIndex()) { + return o1.getFrom() - o2.getFrom(); + } + return o1.getToIndex() - o2.getToIndex(); + } + }; + + private char toIndex; private char fromIndex; - private char toIndex; private int from; private int to; private State state; + + public InputEdge(char toIndex, int from, int to) { + this((char)0, toIndex, from, to); + } public InputEdge(char fromIndex, char toIndex, int from, int to) { + this.toIndex = toIndex; this.fromIndex = fromIndex; - this.toIndex = toIndex; this.from = from; this.to = to; this.state = State.SAME; @@ -57,14 +85,14 @@ this.state = x; } + public char getToIndex() { + return toIndex; + } + public char getFromIndex() { return fromIndex; } - public char getToIndex() { - return toIndex; - } - public String getName() { return "in" + toIndex; } @@ -83,16 +111,16 @@ return false; } InputEdge conn2 = (InputEdge) o; - return conn2.toIndex == toIndex && conn2.from == from && conn2.to == to; + return conn2.fromIndex == fromIndex && conn2.toIndex == toIndex && conn2.from == from && conn2.to == to; } @Override public String toString() { - return "Edge from " + from + " to " + to + "(" + (int) toIndex + ") "; + return "Edge from " + from + " to " + to + "(" + (int) fromIndex + ", " + (int) toIndex + ") "; } @Override public int hashCode() { - return (from << 20 | to << 8 | toIndex); + return (from << 20 | to << 8 | toIndex << 4 | fromIndex); } } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java Wed Jun 08 15:36:30 2011 +0200 @@ -26,9 +26,12 @@ import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.HashMap; import java.util.HashSet; -import java.util.HashMap; +import java.util.Hashtable; +import java.util.LinkedHashMap; import java.util.List; +import java.util.Map; import java.util.Set; /** @@ -37,51 +40,129 @@ */ public class InputGraph extends Properties.Entity { - private HashMap nodes; + private LinkedHashMap nodes; private ArrayList edges; private Group parent; - private HashMap blocks; - private HashMap nodeToBlock; - private boolean isDifferenceGraph; + private LinkedHashMap blocks; + private LinkedHashMap nodeToBlock; + private Pair sourceGraphs; + private int parentIndex; - public InputGraph(Group parent) { - this(parent, null); + InputGraph(int parentIndex, Group parent, String name, Pair sourceGraphs) { + this.parentIndex = parentIndex; + this.parent = parent; + this.sourceGraphs = sourceGraphs; + setName(name); + nodes = new LinkedHashMap(); + edges = new ArrayList(); + blocks = new LinkedHashMap(); + nodeToBlock = new LinkedHashMap(); + } + + public void addBlockConnection(InputBlock left, InputBlock right) { + left.addSuccessor(right); } - public InputGraph(Group parent, InputGraph last) { - this(parent, last, ""); + public Pair getSourceGraphs() { + return sourceGraphs; + } + + public List findRootNodes() { + List result = new ArrayList(); + Set nonRoot = new HashSet(); + for(InputEdge curEdges : getEdges()) { + nonRoot.add(curEdges.getTo()); + } + + for(InputNode node : getNodes()) { + if(!nonRoot.contains(node.getId())) { + result.add(node); + } + } + + return result; + } + + public Map> findAllOutgoingEdges() { + + Map> result = new HashMap>(getNodes().size()); + for(InputNode n : this.getNodes()) { + result.put(n, new ArrayList()); + } + + for(InputEdge e : this.edges) { + int from = e.getFrom(); + InputNode fromNode = this.getNode(from); + List fromList = result.get(fromNode); + assert fromList != null; + fromList.add(e); + } + + for(InputNode n : this.getNodes()) { + List list = result.get(n); + Collections.sort(list, InputEdge.OUTGOING_COMPARATOR); + } + + return result; + } + + public Map> findAllIngoingEdges() { + + Map> result = new HashMap>(getNodes().size()); + for(InputNode n : this.getNodes()) { + result.put(n, new ArrayList()); + } + + for(InputEdge e : this.edges) { + int to = e.getTo(); + InputNode toNode = this.getNode(to); + List toList = result.get(toNode); + assert toList != null; + toList.add(e); + } + + for(InputNode n : this.getNodes()) { + List list = result.get(n); + Collections.sort(list, InputEdge.INGOING_COMPARATOR); + } + + return result; + } + + public List findOutgoingEdges(InputNode n) { + List result = new ArrayList(); + + for(InputEdge e : this.edges) { + if(e.getFrom() == n.getId()) { + result.add(e); + } + } + + Collections.sort(result, InputEdge.OUTGOING_COMPARATOR); + + return result; } - private void clearBlocks() { + public void clearBlocks() { blocks.clear(); nodeToBlock.clear(); } - - public InputGraph(Group parent, InputGraph last, String name) { - this.parent = parent; - setName(name); - nodes = new HashMap(); - edges = new ArrayList(); - blocks = new HashMap(); - nodeToBlock = new HashMap(); - if (last != null) { - - for (InputNode n : last.getNodes()) { - addNode(n); - } - - for (InputEdge c : last.getEdges()) { - addEdge(c); - } + + public void setEdge(int fromIndex, int toIndex, int from, int to) { + assert fromIndex == ((char)fromIndex) : "Downcast must be safe"; + assert toIndex == ((char)toIndex) : "Downcast must be safe"; + + InputEdge edge = new InputEdge((char)fromIndex, (char)toIndex, from, to); + if(!this.getEdges().contains(edge)) { + this.addEdge(edge); } } - public void schedule(Collection newBlocks) { - clearBlocks(); - InputBlock noBlock = new InputBlock(this, "no block"); + public void ensureNodesInBlocks() { + InputBlock noBlock = null; Set scheduledNodes = new HashSet(); - for (InputBlock b : newBlocks) { + for (InputBlock b : getBlocks()) { for (InputNode n : b.getNodes()) { assert !scheduledNodes.contains(n); scheduledNodes.add(n); @@ -91,17 +172,13 @@ for (InputNode n : this.getNodes()) { assert nodes.get(n.getId()) == n; if (!scheduledNodes.contains(n)) { + if (noBlock == null) { + noBlock = this.addBlock("no block"); + } noBlock.addNode(n.getId()); } } - if (noBlock.getNodes().size() != 0) { - newBlocks.add(noBlock); - } - for (InputBlock b : newBlocks) { - addBlock(b); - } - for (InputNode n : this.getNodes()) { assert this.getBlock(n) != null; } @@ -116,47 +193,37 @@ } public InputBlock getBlock(InputNode node) { + assert nodes.containsKey(node.getId()); + assert nodes.get(node.getId()).equals(node); return getBlock(node.getId()); } public InputGraph getNext() { List list = parent.getGraphs(); - if (!list.contains(this)) { - return null; - } - int index = list.indexOf(this); - if (index == list.size() - 1) { + if (parentIndex == list.size() - 1) { return null; } else { - return list.get(index + 1); + return list.get(parentIndex + 1); } } public InputGraph getPrev() { List list = parent.getGraphs(); - if (!list.contains(this)) { - return null; - } - int index = list.indexOf(this); - if (index == 0) { + if (parentIndex == 0) { return null; } else { - return list.get(index - 1); + return list.get(parentIndex - 1); } } + private void setName(String name) { + this.getProperties().setProperty("name", name); + } + public String getName() { return getProperties().get("name"); } - public String getAbsoluteName() { - String result = getName(); - if (this.parent != null) { - result = parent.getName() + ": " + result; - } - return result; - } - public Collection getNodes() { return Collections.unmodifiableCollection(nodes.values()); } @@ -192,8 +259,11 @@ } public void addEdge(InputEdge c) { - assert !edges.contains(c); - edges.add(c); + + // Be tolerant with duplicated edges. + if(!edges.contains(c)) { + edges.add(c); + } assert edges.contains(c); } @@ -214,35 +284,22 @@ sb.append(c.toString()); sb.append("\n"); } + + for (InputBlock b : getBlocks()) { + sb.append(b.toString()); + sb.append("\n"); + } + return sb.toString(); } - public void addBlock(InputBlock b) { + public InputBlock addBlock(String name) { + final InputBlock b = new InputBlock(this, name); blocks.put(b.getName(), b); - for (InputNode n : b.getNodes()) { - this.nodeToBlock.put(n.getId(), b); - } - } - - public void resolveBlockLinks() { - for (InputBlock b : blocks.values()) { - b.resolveBlockLinks(); - } - } - - public void setName(String s) { - getProperties().setProperty("name", s); + return b; } public InputBlock getBlock(String s) { return blocks.get(s); } - - public boolean isDifferenceGraph() { - return this.isDifferenceGraph; - } - - public void setIsDifferenceGraph(boolean b) { - isDifferenceGraph = b; - } } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputMethod.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputMethod.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputMethod.java Wed Jun 08 15:36:30 2011 +0200 @@ -23,7 +23,6 @@ */ package com.sun.hotspot.igv.data; -import com.sun.hotspot.igv.data.Properties; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -42,6 +41,29 @@ private Group group; private List bytecodes; + @Override + public int hashCode() { + int result = name.hashCode(); + result = result * 31 + bci; + result = result * 31 + shortName.hashCode(); + result = result * 31 + inlined.hashCode(); + result = result * 31 + bytecodes.hashCode(); + return result; + } + + @Override + public boolean equals(Object o) { + if (o == null || (!(o instanceof InputMethod))) { + return false; + } + + final InputMethod im = (InputMethod)o; + return name.equals(im.name) && bci == im.bci && shortName.equals(im.shortName) && + inlined.equals(im.inlined) && bytecodes.equals(im.bytecodes); + } + + + /** Creates a new instance of InputMethod */ public InputMethod(Group parent, String name, String shortName, int bci) { this.group = parent; diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputNode.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputNode.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputNode.java Wed Jun 08 15:36:30 2011 +0200 @@ -23,6 +23,8 @@ */ package com.sun.hotspot.igv.data; +import java.util.Comparator; + /** * * @author Thomas Wuerthinger @@ -31,6 +33,34 @@ private int id; + public static final Comparator COMPARATOR = new Comparator() { + public int compare(InputNode o1, InputNode o2) { + return o1.getId() - o2.getId(); + } + }; + + public static Comparator getPropertyComparator(final String propertyName) { + return new Comparator() { + + public int compare(InputNode o1, InputNode o2) { + + int i1 = 0; + try { + i1 = Integer.parseInt(o1.getProperties().get(propertyName)); + } catch(NumberFormatException e) { + } + + int i2 = 0; + try { + i2 = Integer.parseInt(o2.getProperties().get(propertyName)); + } catch(NumberFormatException e) { + } + + return i1 - i2; + } + }; + } + public InputNode(InputNode n) { super(n); setId(n.id); @@ -55,15 +85,12 @@ return false; } InputNode n = (InputNode) o; - if (n.id != id) { - return false; - } - return getProperties().equals(n.getProperties()); + return n.id == id; } @Override public int hashCode() { - return id; + return id * 13; } @Override diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Pair.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Pair.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Pair.java Wed Jun 08 15:36:30 2011 +0200 @@ -58,15 +58,30 @@ @Override public boolean equals(Object o) { - if (!(o instanceof Pair)) { + if (o == null || !(o instanceof Pair)) { return false; } Pair obj = (Pair) o; - return l.equals(obj.l) && r.equals(obj.r); + boolean b1 = (l == obj.l); + if (l != null) { + b1 = l.equals(obj.l); + } + + boolean b2 = (r == obj.r); + if (r != null) { + b2 = r.equals(obj.r); + } + + return b1 && b2; } @Override public int hashCode() { - return l.hashCode() * 71 + r.hashCode(); + return ((l == null) ? 0 : l.hashCode()) * 71 + ((r == null) ? 0 : r.hashCode()); + } + + @Override + public String toString() { + return "[" + l + "/" + r + "]"; } } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Properties.java Wed Jun 08 15:36:30 2011 +0200 @@ -26,11 +26,13 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; - +import java.util.regex.PatternSyntaxException; /** * @@ -58,13 +60,30 @@ return false; } } + + for (Property prop : p) { + String value = this.get(prop.getName()); + if (value == null || !value.equals(prop.getValue())) { + return false; + } + } + return true; } @Override public int hashCode() { int hash = 5; - hash = 83 * hash + (this.map != null ? this.map.hashCode() : 0); + + if (map != null) { + for (int i = 0; i < this.map.length; i++) { + if (map[i] == null) { + i++; + } else { + hash = hash * 83 + map[i].hashCode(); + } + } + } return hash; } @@ -85,7 +104,7 @@ public Properties(Properties p) { map = new String[p.map.length]; - System.arraycopy(map, 0, p.map, 0, p.map.length); + System.arraycopy(p.map, 0, map, 0, p.map.length); } public static class Entity implements Provider { @@ -105,14 +124,6 @@ } } - private String getProperty(String key) { - for (int i = 0; i < map.length; i += 2) - if (map[i] != null && map[i].equals(key)) { - return map[i + 1]; - } - return null; - } - public interface PropertyMatcher { String getName(); @@ -133,6 +144,9 @@ } public boolean match(String p) { + if (p == null) { + return false; + } return !matcher.match(p); } } @@ -143,6 +157,12 @@ private String value; public StringPropertyMatcher(String name, String value) { + if (name == null) { + throw new IllegalArgumentException("Property name must not be null!"); + } + if (value == null) { + throw new IllegalArgumentException("Property value must not be null!"); + } this.name = name; this.value = value; } @@ -152,6 +172,9 @@ } public boolean match(String p) { + if (p == null) { + throw new IllegalArgumentException("Property value must not be null!"); + } return p.equals(value); } } @@ -162,8 +185,22 @@ private Pattern valuePattern; public RegexpPropertyMatcher(String name, String value) { + + if (name == null) { + throw new IllegalArgumentException("Property name must not be null!"); + } + + if (value == null) { + throw new IllegalArgumentException("Property value pattern must not be null!"); + } + this.name = name; - valuePattern = Pattern.compile(value); + + try { + valuePattern = Pattern.compile(value); + } catch (PatternSyntaxException e) { + throw new IllegalArgumentException("Bad pattern: " + value); + } } public String getName() { @@ -171,21 +208,26 @@ } public boolean match(String p) { + if (p == null) { + throw new IllegalArgumentException("Property value must not be null!"); + } Matcher m = valuePattern.matcher(p); return m.matches(); } } public Property selectSingle(PropertyMatcher matcher) { + + final String name = matcher.getName(); String value = null; for (int i = 0; i < map.length; i += 2) { - if (map[i] != null && matcher.getName().equals(map[i])) { + if (map[i] != null && name.equals(map[i])) { value = map[i + 1]; break; } } if (value != null && matcher.match(value)) { - return new Property(matcher.getName(), value); + return new Property(name, value); } else { return null; } @@ -198,13 +240,31 @@ @Override public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("["); + List pairs = new ArrayList(); for (int i = 0; i < map.length; i += 2) { if (map[i + 1] != null) { - String p = map[i + 1]; - sb.append(map[i] + " = " + map[i + 1] + "; "); + pairs.add(new String[]{map[i], map[i + 1]}); + } + } + + Collections.sort(pairs, new Comparator() { + public int compare(String[] o1, String[] o2) { + assert o1.length == 2; + assert o2.length == 2; + return o1[0].compareTo(o2[0]); } + }); + + StringBuilder sb = new StringBuilder(); + sb.append("["); + boolean first = true; + for (String[] p : pairs) { + if (first) { + first = false; + } else { + sb.append(", "); + } + sb.append(p[0] + "=" + p[1]); } return sb.append("]").toString(); } @@ -217,10 +277,6 @@ this.objects = objects; } - public T selectSingle(final String name, final String value) { - return selectSingle(new StringPropertyMatcher(name, value)); - } - public T selectSingle(PropertyMatcher matcher) { for (T t : objects) { @@ -233,18 +289,16 @@ return null; } - public List selectMultiple(final String name, final String value) { - return selectMultiple(new StringPropertyMatcher(name, value)); - } - public List selectMultiple(PropertyMatcher matcher) { List result = new ArrayList(); + for (T t : objects) { Property p = t.getProperties().selectSingle(matcher); if (p != null) { result.add(t); } } + return result; } } @@ -259,6 +313,7 @@ } public void setProperty(String name, String value) { + for (int i = 0; i < map.length; i += 2) { if (map[i] != null && map[i].equals(name)) { String p = map[i + 1]; @@ -289,31 +344,20 @@ map = newMap; } - public Iterator getProperties() { - return iterator(); - } - public void add(Properties properties) { for (Property p : properties) { - add(p); + setProperty(p.getName(), p.getValue()); } } - public void add(Property property) { - assert property.getName() != null; - assert property.getValue() != null; - setProperty(property.getName(), property.getValue()); - } - class PropertiesIterator implements Iterator, Iterable { - public Iterator iterator() { - return this; - } + private class PropertiesIterator implements Iterator { int index; public boolean hasNext() { - while (index < map.length && map[index + 1] == null) + while (index < map.length && map[index + 1] == null) { index += 2; + } return index < map.length; } @@ -328,8 +372,8 @@ public void remove() { throw new UnsupportedOperationException("Not supported yet."); } + } - } public Iterator iterator() { return new PropertiesIterator(); } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Property.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Property.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Property.java Wed Jun 08 15:36:30 2011 +0200 @@ -32,25 +32,20 @@ public class Property implements Serializable { public static final long serialVersionUID = 1L; - private String name; private String value; - private Property() { - this(null, null); - } - - private Property(Property p) { - this(p.getName(), p.getValue()); - } - - private Property(String name) { - this(name, null); - } - - public Property(String name, String value) { + Property(String name, String value) { this.name = name; this.value = value; + + if (value == null) { + throw new IllegalArgumentException("Property value must not be null!"); + } + + if (name == null) { + throw new IllegalArgumentException("Property name must not be null!"); + } } public String getName() { @@ -63,17 +58,20 @@ @Override public String toString() { - return name + " = " + value + "; "; + return name + "=" + value; } @Override public boolean equals(Object o) { - if (!(o instanceof Property)) return false; - Property p2 = (Property)o; + if (!(o instanceof Property)) { + return false; + } + Property p2 = (Property) o; return name.equals(p2.name) && value.equals(p2.value); } + @Override public int hashCode() { - return name.hashCode() + value == null ? 0 : value.hashCode(); + return name.hashCode() * 13 + value.hashCode(); } } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Source.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Source.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package com.sun.hotspot.igv.data; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +/** + * + * @author Thomas Wuerthinger + */ +public class Source { + + private List sourceNodes; + private Set set; + + public Source() { + sourceNodes = new ArrayList(1); + set = new LinkedHashSet(1); + } + + public List getSourceNodes() { + return Collections.unmodifiableList(sourceNodes); + } + + public Set getSourceNodesAsSet() { + return Collections.unmodifiableSet(set); + } + + public void addSourceNode(InputNode n) { + if (!set.contains(n.getId())) { + sourceNodes.add(n); + set.add(n.getId()); + } + } + + public interface Provider { + + public Source getSource(); + } + + public void addSourceNodes(Source s) { + for (InputNode n : s.getSourceNodes()) { + addSourceNode(n); + } + } +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java Wed Jun 08 15:36:30 2011 +0200 @@ -30,6 +30,7 @@ import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.InputMethod; import com.sun.hotspot.igv.data.InputNode; +import com.sun.hotspot.igv.data.Pair; import com.sun.hotspot.igv.data.Properties; import com.sun.hotspot.igv.data.Property; import com.sun.hotspot.igv.data.services.GroupCallback; @@ -38,7 +39,9 @@ import com.sun.hotspot.igv.data.serialization.XMLParser.ParseMonitor; import com.sun.hotspot.igv.data.serialization.XMLParser.TopElementHandler; import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; @@ -63,6 +66,7 @@ public static final String REMOVE_EDGE_ELEMENT = "removeEdge"; public static final String REMOVE_NODE_ELEMENT = "removeNode"; public static final String METHOD_NAME_PROPERTY = "name"; + public static final String GROUP_NAME_PROPERTY = "name"; public static final String METHOD_IS_PUBLIC_PROPERTY = "public"; public static final String METHOD_IS_STATIC_PROPERTY = "static"; public static final String TRUE_VALUE = "true"; @@ -92,6 +96,7 @@ private boolean difference; private GroupCallback groupCallback; private HashMap idCache = new HashMap(); + private ArrayList> blockConnections = new ArrayList>(); private int maxId = 0; private int lookupID(String i) { @@ -197,19 +202,67 @@ protected InputGraph start() throws SAXException { String name = readAttribute(GRAPH_NAME_PROPERTY); - InputGraph previous = getParentObject().getLastAdded(); - if (!difference) { - previous = null; + InputGraph curGraph = getParentObject().addGraph(name); + if (difference) { + + List list = getParentObject().getGraphs(); + if (list.size() > 1) { + InputGraph previous = list.get(list.size() - 2); + for (InputNode n : previous.getNodes()) { + curGraph.addNode(n); + } + for (InputEdge e : previous.getEdges()) { + curGraph.addEdge(e); + } + } } - InputGraph curGraph = new InputGraph(getParentObject(), previous, name); this.graph = curGraph; return curGraph; } @Override protected void end(String text) throws SAXException { - getParentObject().addGraph(graph); - graph.resolveBlockLinks(); + + // Recover from control flow input with missing information + if (graph.getBlocks().size() > 0) { + boolean blockContainsNodes = false; + for (InputBlock b : graph.getBlocks()) { + if (b.getNodes().size() > 0) { + blockContainsNodes = true; + break; + } + } + + if (!blockContainsNodes) { + graph.clearBlocks(); + blockConnections.clear(); + } else { + + InputBlock noBlock = null; + + for (InputNode n : graph.getNodes()) { + if (graph.getBlock(n) == null) { + if (noBlock == null) { + noBlock = graph.addBlock("none"); + } + + noBlock.addNode(n.getId()); + } + + assert graph.getBlock(n) != null; + } + } + } + + // Resolve block successors + for (Pair p : blockConnections) { + final InputBlock left = graph.getBlock(p.getLeft()); + assert left != null; + final InputBlock right = graph.getBlock(p.getRight()); + assert right != null; + graph.addBlockConnection(left, right); + } + blockConnections.clear(); } }; // @@ -223,8 +276,10 @@ protected InputBlock start() throws SAXException { InputGraph graph = getParentObject(); String name = readRequiredAttribute(BLOCK_NAME_PROPERTY).intern(); - InputBlock b = new InputBlock(getParentObject(), name); - graph.addBlock(b); + InputBlock b = graph.addBlock(name); + for (InputNode n : b.getNodes()) { + assert graph.getBlock(n).equals(b); + } return b; } }; @@ -255,7 +310,7 @@ @Override protected InputBlock start() throws SAXException { String name = readRequiredAttribute(BLOCK_NAME_PROPERTY); - getParentObject().addSuccessor(name); + blockConnections.add(new Pair(getParentObject().getName(), name)); return getParentObject(); } }; @@ -372,7 +427,7 @@ @Override public String start() throws SAXException { return readRequiredAttribute(PROPERTY_NAME_PROPERTY).intern(); - } + } @Override public void end(String text) { @@ -430,7 +485,7 @@ } // Returns a new GraphDocument object deserialized from an XML input source. - public GraphDocument parse(XMLReader reader, InputSource source, XMLParser.ParseMonitor monitor) throws SAXException { + public synchronized GraphDocument parse(XMLReader reader, InputSource source, XMLParser.ParseMonitor monitor) throws SAXException { reader.setContentHandler(new XMLParser(xmlDocument, monitor)); try { reader.parse(source); diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Printer.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Printer.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Printer.java Wed Jun 08 15:36:30 2011 +0200 @@ -34,6 +34,7 @@ import com.sun.hotspot.igv.data.Properties; import com.sun.hotspot.igv.data.Property; import java.io.IOException; +import java.io.InputStream; import java.io.Writer; import java.util.HashSet; import java.util.Set; @@ -44,6 +45,16 @@ */ public class Printer { + private InputStream in; + + public Printer() { + this(null); + } + + public Printer(InputStream inputStream) { + this.in = inputStream; + } + public void export(Writer writer, GraphDocument document) { XMLWriter xmlWriter = new XMLWriter(writer); @@ -71,14 +82,24 @@ writer.startTag(Parser.GROUP_ELEMENT, attributes); writer.writeProperties(g.getProperties()); - if (g.getMethod() != null) { - export(writer, g.getMethod()); + boolean shouldExport = true; + if (in != null) { + char c = (char) in.read(); + if (c != 'y') { + shouldExport = false; + } } - InputGraph previous = null; - for (InputGraph graph : g.getGraphs()) { - export(writer, graph, previous, true); - previous = graph; + if (shouldExport) { + if (g.getMethod() != null) { + export(writer, g.getMethod()); + } + + InputGraph previous = null; + for (InputGraph graph : g.getGraphs()) { + export(writer, graph, previous, true); + previous = graph; + } } writer.endTag(); @@ -153,23 +174,25 @@ writer.startTag(Parser.CONTROL_FLOW_ELEMENT); for (InputBlock b : graph.getBlocks()) { - writer.startTag(Parser.BLOCK_ELEMENT, new Properties(Parser.BLOCK_NAME_PROPERTY, b.getName())); - - writer.startTag(Parser.SUCCESSORS_ELEMENT); - for (InputBlock s : b.getSuccessors()) { - writer.simpleTag(Parser.SUCCESSOR_ELEMENT, new Properties(Parser.BLOCK_NAME_PROPERTY, s.getName())); + + if (b.getSuccessors().size() > 0) { + writer.startTag(Parser.SUCCESSORS_ELEMENT); + for (InputBlock s : b.getSuccessors()) { + writer.simpleTag(Parser.SUCCESSOR_ELEMENT, new Properties(Parser.BLOCK_NAME_PROPERTY, s.getName())); + } + writer.endTag(); } - writer.endTag(); + if (b.getNodes().size() > 0) { writer.startTag(Parser.NODES_ELEMENT); - for (InputNode n : b.getNodes()) { - writer.simpleTag(Parser.NODE_ELEMENT, new Properties(Parser.NODE_ID_PROPERTY, n.getId() + "")); + for (InputNode n : b.getNodes()) { + writer.simpleTag(Parser.NODE_ELEMENT, new Properties(Parser.NODE_ID_PROPERTY, n.getId() + "")); + } + writer.endTag(); } + writer.endTag(); - - writer.endTag(); - } writer.endTag(); @@ -199,8 +222,8 @@ b.append(" "); b.append(code.getName()); b.append("\n"); - } + b.append("]]>"); w.write(b.toString()); w.endTag(); @@ -209,8 +232,12 @@ private Properties createProperties(InputEdge edge) { Properties p = new Properties(); - p.setProperty(Parser.FROM_INDEX_PROPERTY, Integer.toString(edge.getFromIndex())); - p.setProperty(Parser.TO_INDEX_PROPERTY, Integer.toString(edge.getToIndex())); + if (edge.getToIndex() != 0) { + p.setProperty(Parser.TO_INDEX_PROPERTY, Integer.toString(edge.getToIndex())); + } + if (edge.getFromIndex() != 0) { + p.setProperty(Parser.FROM_INDEX_PROPERTY, Integer.toString(edge.getFromIndex())); + } p.setProperty(Parser.TO_PROPERTY, Integer.toString(edge.getTo())); p.setProperty(Parser.FROM_PROPERTY, Integer.toString(edge.getFrom())); return p; diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLWriter.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLWriter.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/XMLWriter.java Wed Jun 08 15:36:30 2011 +0200 @@ -111,7 +111,7 @@ } public void writeProperties(Properties props) throws IOException { - if (props.getProperties().hasNext() == false) { + if (props.iterator().hasNext() == false) { return; } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/ChangedEventTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/ChangedEventTest.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.data; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author Thomas Wuerthinger + */ +public class ChangedEventTest { + + public ChangedEventTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of addListener method, of class Event. + */ + @Test + public void testBase() { + + ChangedEvent e = new ChangedEvent(5); + final int[] fireCount = new int[1]; + + e.addListener(new ChangedListener() { + public void changed(Integer s) { + assertEquals(s.intValue(), 5); + fireCount[0]++; + } + }); + + e.fire(); + assertEquals(1, fireCount[0]); + + e.fire(); + assertEquals(2, fireCount[0]); + + e.beginAtomic(); + + e.fire(); + assertEquals(2, fireCount[0]); + + e.fire(); + assertEquals(2, fireCount[0]); + + e.fire(); + assertEquals(2, fireCount[0]); + + e.endAtomic(); + assertEquals(3, fireCount[0]); + + } + + +} \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/ControllableChangedListenerTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/ControllableChangedListenerTest.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.data; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author Thomas Wuerthinger + */ +public class ControllableChangedListenerTest { + + public ControllableChangedListenerTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of isEnabled method, of class ControllableChangedListener. + */ + @Test + public void testBase() { + + final boolean[] hasFired = new boolean[1]; + final boolean[] shouldFire = new boolean[1]; + final Integer[] valueToFire = new Integer[1]; + ControllableChangedListener l = new ControllableChangedListener() { + + @Override + public void filteredChanged(Integer value) { + assertTrue(shouldFire[0]); + assertEquals(valueToFire[0], value); + hasFired[0] = true; + } + }; + + shouldFire[0] = true; + valueToFire[0] = 1; + hasFired[0] = false; + l.changed(1); + assertTrue(hasFired[0]); + + shouldFire[0] = false; + hasFired[0] = false; + l.setEnabled(false); + l.changed(1); + assertFalse(hasFired[0]); + + shouldFire[0] = true; + valueToFire[0] = 1; + hasFired[0] = false; + l.setEnabled(true); + l.changed(1); + assertTrue(hasFired[0]); + } +} \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/GroupTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/GroupTest.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.data; + +import java.util.Arrays; +import java.util.HashSet; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author Thomas Wuerthinger + */ +public class GroupTest { + + public GroupTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getAllNodes method, of class Group. + */ + @Test + public void testGetAllNodes() { + final Group g = new Group(); + final InputGraph graph1 = g.addGraph("1"); + final InputGraph graph2 = g.addGraph("2"); + graph1.addNode(new InputNode(1)); + graph1.addNode(new InputNode(2)); + graph2.addNode(new InputNode(2)); + graph2.addNode(new InputNode(3)); + assertEquals(g.getAllNodes(), new HashSet(Arrays.asList(1, 2, 3))); + } +} \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/InputGraphTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/InputGraphTest.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,206 @@ +/* + * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.data; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author Thomas Wuerthinger + */ +public class InputGraphTest { + + /** + * 1 + * / \ + * 2 3 + * \ | 5 + * \ | / + * 4 + */ + private static InputGraph referenceGraph; + + private static InputGraph emptyGraph; + + private static final InputNode N1 = new InputNode(1); + private static final InputNode N2 = new InputNode(2); + private static final InputNode N3 = new InputNode(3); + private static final InputNode N4 = new InputNode(4); + private static final InputNode N5 = new InputNode(5); + private static final InputEdge E12 = new InputEdge((char)0, 1, 2); + private static final InputEdge E13 = new InputEdge((char)0, 1, 3); + private static final InputEdge E24 = new InputEdge((char)0, 2, 4); + private static final InputEdge E34 = new InputEdge((char)0, 3, 4); + private static final InputEdge E54 = new InputEdge((char)0, 5, 4); + + public InputGraphTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + Group group = new Group(); + + emptyGraph = group.addGraph("emptyGraph"); + + referenceGraph = group.addGraph("referenceGraph"); + referenceGraph.addNode(N1); + referenceGraph.addNode(N2); + referenceGraph.addNode(N3); + referenceGraph.addNode(N4); + referenceGraph.addNode(N5); + + referenceGraph.addEdge(E12); + referenceGraph.addEdge(E13); + referenceGraph.addEdge(E24); + referenceGraph.addEdge(E34); + referenceGraph.addEdge(E54); + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of equals method, of class InputGraph. + */ + @Test + public void testEquals() { + + Group parentA = new Group(); + InputGraph a = parentA.addGraph("graph"); + + Group parentB = new Group(); + InputGraph b = parentB.addGraph("graph"); + + InputGraph c = parentB.addGraph("graph"); + + Util.assertGraphEquals(a, b); + Util.assertGraphEquals(b, c); + + a.addNode(new InputNode(1)); + Util.assertGraphNotEquals(a, b); + + b.addNode(new InputNode(1)); + Util.assertGraphEquals(a, b); + } + + /** + * Test of findRootNodes method, of class InputGraph. + */ + @Test + public void testFindRootNodes() { + assertTrue(emptyGraph.findRootNodes().size() == 0); + + List result = referenceGraph.findRootNodes(); + assertTrue(result.size() == 2); + assertTrue(result.contains(N1)); + assertTrue(result.contains(N5)); + } + + /** + * Test of findAllOutgoingEdges method, of class InputGraph. + */ + @Test + public void testFindAllOutgoingEdges() { + assertTrue(emptyGraph.findAllOutgoingEdges().size() == 0); + + Map> result = referenceGraph.findAllOutgoingEdges(); + assertTrue(result.size() == 5); + assertEquals(result.get(N1), Arrays.asList(E12, E13)); + assertEquals(result.get(N2), Arrays.asList(E24)); + assertEquals(result.get(N3), Arrays.asList(E34)); + assertEquals(result.get(N4), Arrays.asList()); + assertEquals(result.get(N5), Arrays.asList(E54)); + } + + /** + * Test of findAllIngoingEdges method, of class InputGraph. + */ + @Test + public void testFindAllIngoingEdges() { + assertTrue(emptyGraph.findAllIngoingEdges().size() == 0); + + Map> result = referenceGraph.findAllIngoingEdges(); + assertTrue(result.size() == 5); + assertEquals(result.get(N1), Arrays.asList()); + assertEquals(result.get(N2), Arrays.asList(E12)); + assertEquals(result.get(N3), Arrays.asList(E13)); + assertEquals(result.get(N4), Arrays.asList(E24, E34, E54)); + assertEquals(result.get(N5), Arrays.asList()); + } + + /** + * Test of findOutgoingEdges method, of class InputGraph. + */ + @Test + public void testFindOutgoingEdges() { + assertTrue(emptyGraph.findOutgoingEdges(new InputNode(1)).size() == 0); + + assertEquals(referenceGraph.findOutgoingEdges(N1), Arrays.asList(E12, E13)); + assertEquals(referenceGraph.findOutgoingEdges(N2), Arrays.asList(E24)); + assertEquals(referenceGraph.findOutgoingEdges(N3), Arrays.asList(E34)); + assertEquals(referenceGraph.findOutgoingEdges(N4), Arrays.asList()); + assertEquals(referenceGraph.findOutgoingEdges(N5), Arrays.asList(E54)); + } + + /** + * Test of getNext method, of class InputGraph. + */ + @Test + public void testGetNextPrev() { + final Group group = new Group(); + + final InputGraph a = group.addGraph("a"); + + final InputGraph b = group.addGraph("b"); + + final InputGraph c = group.addGraph("c"); + + assertEquals(null, a.getPrev()); + assertEquals(b, a.getNext()); + + assertEquals(a, b.getPrev()); + assertEquals(c, b.getNext()); + + assertEquals(b, c.getPrev()); + assertEquals(null, c.getNext()); + } +} \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/InputMethodTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/InputMethodTest.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.data; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.hamcrest.CoreMatchers.*; +import static org.junit.Assert.*; + +/** + * + * @author Thomas + */ +public class InputMethodTest { + + public InputMethodTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + + /** + * Test of getBytecodes method, of class InputMethod. + */ + @Test + public void testGetSetBytecodes() { + + final String input = "0 iload_0\n" + + "1 iconst_1\n" + + "2 if_icmpne 7\n" + + "5 iconst_1\n" + + "6 ireturn\n" + + "7 iconst_0\n" + + "8 ireturn"; + + final Group g = new Group(); + InputMethod m = new InputMethod(g, "name", "shortName", -1); + m.setBytecodes(input); + + assertThat(m.getBytecodes().size(), is(7)); + + assertThat(m.getBytecodes().get(0).getBci(), is(0)); + assertThat(m.getBytecodes().get(1).getBci(), is(1)); + assertThat(m.getBytecodes().get(2).getBci(), is(2)); + assertThat(m.getBytecodes().get(3).getBci(), is(5)); + + assertThat(m.getBytecodes().get(0).getName(), is("iload_0")); + assertThat(m.getBytecodes().get(1).getName(), is("iconst_1")); + assertThat(m.getBytecodes().get(2).getName(), is("if_icmpne 7")); + assertThat(m.getBytecodes().get(6).getName(), is("ireturn")); + + assertThat(m.getBytecodes().get(2).getInlined(), nullValue()); + assertThat(m.getBytecodes().get(6).getInlined(), nullValue()); + } + + +} \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PairTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PairTest.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,102 @@ +/* + * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.hotspot.igv.data; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author Thomas Wuerthinger + */ +public class PairTest { + + public PairTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getLeft method, of class Pair. + */ + @Test + public void testBase() { + Pair p = new Pair(); + assertTrue(p.getLeft() == null); + assertTrue(p.getRight() == null); + assertEquals("[null/null]", p.toString()); + assertFalse(p.equals(null)); + + Pair p2 = new Pair(1, 2); + assertTrue(p2.getLeft().intValue() == 1); + assertTrue(p2.getRight().intValue() == 2); + assertFalse(p.equals(p2)); + assertFalse(p2.equals(p)); + assertFalse(p.hashCode() == p2.hashCode()); + assertEquals("[1/2]", p2.toString()); + + Pair p3 = new Pair(1, 2); + assertTrue(p2.equals(p3)); + assertTrue(p2.hashCode() == p3.hashCode()); + + p2.setLeft(2); + assertFalse(p2.equals(p3)); + assertTrue(p2.getLeft().intValue() == 2); + assertTrue(p2.getRight().intValue() == 2); + assertFalse(p2.hashCode() == p3.hashCode()); + assertEquals("[2/2]", p2.toString()); + + p2.setRight(1); + assertFalse(p2.equals(p3)); + assertTrue(p2.getLeft().intValue() == 2); + assertTrue(p2.getRight().intValue() == 1); + assertFalse(p2.hashCode() == p3.hashCode()); + assertEquals("[2/1]", p2.toString()); + + p3.setLeft(2); + p3.setRight(1); + assertTrue(p2.hashCode() == p3.hashCode()); + assertTrue(p2.equals(p3)); + } +} \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PropertiesTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PropertiesTest.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,397 @@ +/* + * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.hotspot.igv.data; + +import com.sun.hotspot.igv.data.Properties.InvertPropertyMatcher; +import com.sun.hotspot.igv.data.Properties.PropertyMatcher; +import com.sun.hotspot.igv.data.Properties.PropertySelector; +import com.sun.hotspot.igv.data.Properties.RegexpPropertyMatcher; +import com.sun.hotspot.igv.data.Properties.StringPropertyMatcher; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import junit.framework.TestCase; + +/** + * + * @author Thomas Wuerthinger + */ +public class PropertiesTest extends TestCase { + + + + public PropertiesTest(String testName) { + super(testName); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + } + + @Override + protected void tearDown() throws Exception { + super.tearDown(); + } + + /** + * Test of equals method, of class Properties. + */ + public void testEquals() { + Properties a = new Properties(); + assertFalse(a.equals(null)); + assertTrue(a.equals(a)); + + Properties b = new Properties(); + assertTrue(a.equals(b)); + assertTrue(a.hashCode() == b.hashCode()); + + a.setProperty("p1", "1"); + assertFalse(a.equals(b)); + assertFalse(b.equals(a)); + assertFalse(a.hashCode() == b.hashCode()); + + b.setProperty("p1", "1"); + assertTrue(a.equals(b)); + assertTrue(a.hashCode() == b.hashCode()); + + Properties c = new Properties(a); + assertTrue(c.equals(a)); + assertTrue(c.equals(b)); + + c.setProperty("p1", "2"); + assertFalse(c.equals(b)); + assertFalse(c.hashCode() == b.hashCode()); + assertFalse(c.equals(a)); + assertFalse(c.hashCode() == a.hashCode()); + + a.setProperty("p2", "2"); + Properties d = new Properties(); + d.setProperty("p2", "2"); + d.setProperty("p1", "1"); + assertTrue(d.equals(a)); + } + + /** + * Test of selectSingle method, of class Properties. + */ + public void testSelectSingle() { + + final boolean[] called = new boolean[1]; + final String v = "2"; + final String n = "p2"; + + PropertyMatcher matcher = new PropertyMatcher() { + + public String getName() { + assertFalse(called[0]); + called[0] = true; + return n; + } + + public boolean match(String value) { + assertTrue(v.equals(value)); + return true; + } + }; + + Properties instance = new Properties(); + instance.setProperty("p1", "1"); + instance.setProperty(n, v); + instance.setProperty("p3", "3"); + Property result = instance.selectSingle(matcher); + assertEquals(result, new Property(n, v)); + + + called[0] = false; + PropertyMatcher matcher2 = new PropertyMatcher() { + + public String getName() { + assertFalse(called[0]); + called[0] = true; + return n; + } + + public boolean match(String value) { + return false; + } + }; + + + Property result2 = instance.selectSingle(matcher2); + assertTrue(result2 == null); + } + + /** + * Test of get method, of class Properties. + */ + public void testGet() { + Properties instance = new Properties(); + instance.setProperty("p1", "1"); + assertEquals("1", instance.get("p1")); + assertEquals(null, instance.get("p2")); + } + + /** + * Test of getProperties method, of class Properties. + */ + public void testIterator() { + Properties instance = new Properties(); + instance.setProperty("p1", "1"); + instance.setProperty("p2", "2"); + Iterator result = instance.iterator(); + assertTrue(result.hasNext()); + assertEquals(new Property("p1", "1"), result.next()); + assertTrue(result.hasNext()); + assertEquals(new Property("p2", "2"), result.next()); + assertFalse(result.hasNext()); + assertTrue(result.next() == null); + + try { + result.remove(); + fail(); + } catch(UnsupportedOperationException e) {} + } + + /** + * Test of add method, of class Properties. + */ + public void testAdd() { + Properties a = new Properties(); + a.setProperty("p1", "1"); + a.setProperty("p2", "2"); + + Properties b = new Properties(); + b.setProperty("p1", "1"); + + Properties c = new Properties(); + c.setProperty("p2", "2"); + + assertFalse(a.equals(b)); + b.add(c); + + assertTrue(a.equals(b)); + + b.setProperty("p3", null); + assertTrue(a.equals(b)); + + Properties empty = new Properties(); + b.add(empty); + assertTrue(a.equals(b)); + + empty.add(b); + assertTrue(a.equals(empty)); + } + + + /** + * Test the multiple argument constructors. + */ + public void testConstructors() { + Properties a = new Properties("p1", "1", "p2", "2", "p3", "3"); + Properties b = new Properties("p1", "1", "p2", "2"); + Properties c = new Properties("p1", "1"); + + assertTrue(a.get("p3").equals("3")); + assertTrue(b.get("p2").equals("2")); + assertTrue(b.get("p1").equals("1")); + + b.setProperty("p3", "3"); + c.setProperty("p2", "2"); + c.setProperty("p3", "3"); + + assertTrue(a.equals(b)); + assertTrue(a.equals(c)); + } + + /** + * Test Entity class + */ + public void testEntity() { + + Properties p = new Properties(); + + Properties.Entity entity = new Properties.Entity(); + assertEquals(entity.getProperties(), p); + + entity.getProperties().setProperty("p1", "1"); + Properties.Entity entity2 = new Properties.Entity(entity); + assertEquals(entity.getProperties(), entity2.getProperties()); + } + + /** + * Test property selector + */ + public void testPropertySelector() { + final Collection c = new ArrayList(); + + final Properties.Entity e1 = new Properties.Entity(); + e1.getProperties().setProperty("p1", "1"); + e1.getProperties().setProperty("p2", "2"); + c.add(e1); + + final Properties.Entity e2 = new Properties.Entity(); + e2.getProperties().setProperty("p2", "2"); + e2.getProperties().setProperty("p1", "1"); + e2.getProperties().setProperty("p3", "3"); + c.add(e2); + + final Properties.Entity e3 = new Properties.Entity(); + e3.getProperties().setProperty("p3", "3"); + e3.getProperties().setProperty("p4", "4"); + c.add(e3); + + final PropertySelector sel = new PropertySelector(c); + + final StringPropertyMatcher matcher1 = new StringPropertyMatcher("p2", "2"); + assertTrue(sel.selectMultiple(matcher1).size() == 2); + assertTrue(sel.selectMultiple(matcher1).contains(e1)); + assertTrue(sel.selectMultiple(matcher1).contains(e2)); + assertTrue(sel.selectSingle(matcher1).equals(e1) || sel.selectSingle(matcher1).equals(e2)); + + final StringPropertyMatcher matcher2 = new StringPropertyMatcher("p3", "3"); + assertTrue(sel.selectMultiple(matcher2).size() == 2); + assertTrue(sel.selectMultiple(matcher2).contains(e2)); + assertTrue(sel.selectMultiple(matcher2).contains(e3)); + assertTrue(sel.selectSingle(matcher2).equals(e2) || sel.selectSingle(matcher2).equals(e3)); + + final StringPropertyMatcher matcher3 = new StringPropertyMatcher("p4", "4"); + assertTrue(sel.selectMultiple(matcher3).size() == 1); + assertTrue(sel.selectMultiple(matcher3).contains(e3)); + assertTrue(sel.selectSingle(matcher3).equals(e3)); + + final StringPropertyMatcher matcher4 = new StringPropertyMatcher("p5", "5"); + assertTrue(sel.selectMultiple(matcher4).size() == 0); + assertTrue(sel.selectSingle(matcher4) == null); + } + + public void testRemoveProperty() { + final Properties p = new Properties(); + p.setProperty("p1", "1"); + p.setProperty("p2", "2"); + + assertTrue(p.get("p1").equals("1")); + assertTrue(p.get("p2").equals("2")); + + p.setProperty("p1", null); + assertTrue(p.get("p1") == null); + assertTrue(p.get("p2").equals("2")); + + p.setProperty("p2", null); + assertTrue(p.get("p1") == null); + assertTrue(p.get("p2") == null); + + p.setProperty("p3", "3"); + assertTrue(p.get("p1") == null); + assertTrue(p.get("p2") == null); + assertTrue(p.get("p3").equals("3")); + } + + /** + * Test property matchers + */ + public void testPropertyMatchers() { + final StringPropertyMatcher matcher = new StringPropertyMatcher("p1", "1"); + assertTrue(matcher.getName().equals("p1")); + assertTrue(matcher.match("1")); + assertFalse(matcher.match("2")); + try { + matcher.match(null); + fail(); + } catch(IllegalArgumentException e) {} + + try { + new StringPropertyMatcher(null, "**"); + fail(); + } catch(IllegalArgumentException e) {} + + try { + new StringPropertyMatcher("p1", null); + fail(); + } catch(IllegalArgumentException e) {} + + final RegexpPropertyMatcher matcher2 = new RegexpPropertyMatcher("p1", "C.*"); + assertTrue(matcher2.getName().equals("p1")); + assertTrue(matcher2.match("C")); + assertTrue(matcher2.match("Casdf")); + assertFalse(matcher2.match(" C")); + assertFalse(matcher2.match("c")); + assertFalse(matcher2.match("asdfC")); + + try { + matcher2.match(null); + fail(); + } catch(IllegalArgumentException e) {} + + try { + new RegexpPropertyMatcher("p1", "**"); + fail(); + } catch(IllegalArgumentException e) {} + + try { + new RegexpPropertyMatcher(null, "1"); + fail(); + } catch(IllegalArgumentException e) {} + + try { + new RegexpPropertyMatcher("p1", null); + fail(); + } catch(IllegalArgumentException e) {} + + final InvertPropertyMatcher matcher3 = new InvertPropertyMatcher(matcher); + assertTrue(matcher3.getName().equals("p1")); + assertFalse(matcher3.match("1")); + assertTrue(matcher3.match("2")); + assertFalse(matcher3.match(null)); + } + + public void testToString() { + Properties p = new Properties(); + assertEquals(p.toString(), "[]"); + + p.setProperty("p1", "1"); + assertEquals(p.toString(), "[p1=1]"); + + Properties p2 = new Properties(); + p2.setProperty("p1", "1"); + p2.setProperty("p2", "2"); + assertEquals(p2.toString(), "[p1=1, p2=2]"); + + Properties p3 = new Properties(); + p3.setProperty("p2", "2"); + p3.setProperty("p1", "1"); + assertEquals(p3.toString(), "[p1=1, p2=2]"); + + p3.setProperty("p0", "0"); + assertEquals(p3.toString(), "[p0=0, p1=1, p2=2]"); + + p2.setProperty("p1", null); + assertEquals(p2.toString(), "[p2=2]"); + + p2.setProperty("p2", null); + assertEquals(p2.toString(), "[]"); + } +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PropertyTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/PropertyTest.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,120 @@ +/* + * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.hotspot.igv.data; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author Thomas Wuerthinger + */ +public class PropertyTest { + + public PropertyTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getName method, of class Property. + */ + @Test + public void testGetNameAndValue() { + final Property p = new Property("name", "value"); + assertEquals(p.getName(), "name"); + assertEquals(p.getValue(), "value"); + + try { + new Property(null, "value"); + fail(); + } catch(IllegalArgumentException e) { + } + + + try { + new Property("name", null); + fail(); + } catch(IllegalArgumentException e) { + } + } + + /** + * Test of toString method, of class Property. + */ + @Test + public void testToString() { + final Property p = new Property("name", "value"); + assertEquals(p.toString(), "name=value"); + } + + /** + * Test of equals method, of class Property. + */ + @Test + public void testEquals() { + final Property p = new Property("name", "value"); + final Object o = new Object(); + assertFalse(p.equals(o)); + assertFalse(p.equals(null)); + assertTrue(p.equals(p)); + + final Property p2 = new Property("name", "value1"); + assertFalse(p.equals(p2)); + assertTrue(p.hashCode() != p2.hashCode()); + + final Property p3 = new Property("name2", "value"); + assertFalse(p.equals(p3)); + assertTrue(p.hashCode() != p3.hashCode()); + assertTrue(p2.hashCode() != p3.hashCode()); + + final Property p4 = new Property("name", "value"); + assertEquals(p, p4); + assertEquals(p.hashCode(), p4.hashCode()); + + final Property p5 = new Property("value", "name"); + assertFalse(p.equals(p5)); + assertTrue(p.hashCode() != p5.hashCode()); + } +} \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/SourceTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/SourceTest.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.data; + +import java.lang.Integer; +import java.util.Arrays; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; +import static org.hamcrest.CoreMatchers.*; + +/** + * + * @author Thomas + */ +public class SourceTest { + + public SourceTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getSourceNodes method, of class Source. + */ + @Test + public void testBase() { + final Source s = new Source(); + + final InputNode N1 = new InputNode(1); + final InputNode N2 = new InputNode(2); + + s.addSourceNode(N1); + assertEquals(s.getSourceNodes(), Arrays.asList(N1)); + assertEquals(s.getSourceNodesAsSet(), new LinkedHashSet(Arrays.asList(1))); + + s.addSourceNode(N2); + assertEquals(s.getSourceNodes(), Arrays.asList(N1, N2)); + assertEquals(s.getSourceNodesAsSet(), new LinkedHashSet(Arrays.asList(1, 2))); + + s.addSourceNode(N1); + assertEquals(s.getSourceNodes(), Arrays.asList(N1, N2)); + assertEquals(s.getSourceNodesAsSet(), new LinkedHashSet(Arrays.asList(1, 2))); + } +} \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/Util.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/Util.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,135 @@ +/* + * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.hotspot.igv.data; + +import static org.junit.Assert.*; + +/** + * + * @author Thomas Wuerthinger + */ +public class Util { + + public static void assertGraphDocumentNotEquals(GraphDocument a, GraphDocument b) { + try { + assertGraphDocumentEquals(a, b); + } catch(AssertionError e) { + return; + } + + fail("Graphs documents are equal!"); + } + + public static void assertGraphDocumentEquals(GraphDocument a, GraphDocument b) { + + if (a.getGroups().size() != b.getGroups().size()) { + fail(); + } + + int z = 0; + for (Group g : b.getGroups()) { + + Group thisG = a.getGroups().get(z); + assertGroupEquals(thisG, g); + z++; + } + } + + public static void assertGroupNotEquals(Group a, Group b) { + try { + assertGroupEquals(a, b); + } catch(AssertionError e) { + return; + } + + fail("Groups are equal!"); + } + + public static void assertGroupEquals(Group a, Group b) { + + if (a.getGraphs().size() != b.getGraphs().size()) { + fail(); + } + + int z = 0; + for (InputGraph graph : a.getGraphs()) { + InputGraph otherGraph = b.getGraphs().get(z); + assertGraphEquals(graph, otherGraph); + z++; + } + + if (a.getMethod() == null || b.getMethod() == null) { + if (a.getMethod() != b.getMethod()) { + fail(); + } + } else { + if (!a.getMethod().equals(b.getMethod())) { + fail(); + } + } + + if (a.getAssembly() == null || b.getAssembly() == null) { + if (a.getAssembly() != b.getAssembly()) { + fail(); + } + } else { + if (!a.getAssembly().equals(b.getAssembly())) { + fail(); + } + } + } + + public static void assertGraphNotEquals(InputGraph a, InputGraph b) { + try { + assertGraphEquals(a, b); + } catch(AssertionError e) { + return; + } + + fail("Graphs are equal!"); + } + + public static void assertGraphEquals(InputGraph a, InputGraph b) { + + if(!a.getNodesAsSet().equals(b.getNodesAsSet())) { + fail(); + } + + if (!a.getEdges().equals(b.getEdges())) { + fail(); + } + + if (a.getBlocks().equals(b.getBlocks())) { + fail(); + } + + for (InputNode n : a.getNodes()) { + assertEquals(a.getBlock(n), b.getBlock(n)); + } + + assertEquals(a.getSourceGraphs(), b.getSourceGraphs()); + } +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/serialization/ParserTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/serialization/ParserTest.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,232 @@ +/* + * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.hotspot.igv.data.serialization; + +import com.sun.hotspot.igv.data.GraphDocument; +import com.sun.hotspot.igv.data.Group; +import com.sun.hotspot.igv.data.InputBlock; +import com.sun.hotspot.igv.data.InputEdge; +import com.sun.hotspot.igv.data.InputGraph; +import com.sun.hotspot.igv.data.InputMethod; +import com.sun.hotspot.igv.data.InputNode; +import com.sun.hotspot.igv.data.Util; +import java.io.CharArrayWriter; +import java.io.StringReader; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openide.xml.XMLUtil; +import static org.junit.Assert.*; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; + +/** + * + * @author Thomas Wuerthinger + */ +public class ParserTest { + + public ParserTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + private void test(GraphDocument document) { + final Printer printer = new Printer(); + final CharArrayWriter writer = new CharArrayWriter(); + printer.export(writer, document); + test(document, writer.toString()); + } + + private void test(GraphDocument document, String xmlString) { + + StringReader sr = new StringReader(xmlString); + InputSource is = new InputSource(sr); + + try { + XMLReader reader = XMLUtil.createXMLReader(); + Parser parser = new Parser(); + final GraphDocument parsedDocument = parser.parse(reader, is, null); + Util.assertGraphDocumentEquals(document, parsedDocument); + } catch (SAXException ex) { + fail(ex.toString()); + } + } + + private void testBoth(GraphDocument document, String xmlString) { + test(document); + test(document, xmlString); + } + + /** + * Test of graph document serialization + */ + @Test + public void testSerialization() { + final GraphDocument doc = new GraphDocument(); + + test(doc); + + final Group group1 = new Group(); + doc.addGroup(group1); + test(doc); + + final Group group2 = new Group(); + doc.addGroup(group2); + test(doc); + + final InputGraph graph = group1.addGraph(""); + test(doc); + + graph.addNode(new InputNode(0)); + test(doc); + + graph.addNode(new InputNode(1)); + test(doc); + + graph.addNode(new InputNode(2)); + test(doc); + + graph.addNode(new InputNode(3)); + test(doc); + + graph.addEdge(new InputEdge((char)0, (char)0, 0, 1)); + test(doc); + + graph.addEdge(new InputEdge((char)1, (char)1, 0, 1)); + test(doc); + + graph.addEdge(new InputEdge((char)0, (char)0, 1, 2)); + test(doc); + + graph.addEdge(new InputEdge((char)0, (char)0, 2, 3)); + test(doc); + + group1.setMethod(new InputMethod(group1, "testMethod", "tM", 1)); + test(doc); + + final InputBlock b1 = graph.addBlock("1"); + b1.addNode(0); + b1.addNode(1); + + final InputBlock b2 = graph.addBlock("2"); + b2.addNode(2); + b2.addNode(3); + test(doc); + + final GraphDocument document2 = new GraphDocument(); + doc.addGraphDocument(document2); + test(doc); + assertTrue(doc.getGroups().size() == 2); + + final Group group3 = new Group(); + document2.addGroup(group3); + doc.addGraphDocument(document2); + assertTrue(doc.getGroups().size() == 3); + assertTrue(document2.getGroups().size() == 0); + + doc.clear(); + test(doc); + Util.assertGraphDocumentEquals(doc, new GraphDocument()); + } + + @Test + public void testSimpleExport() { + GraphDocument document = new GraphDocument(); + Group g = new Group(); + document.addGroup(g); + + InputGraph graph = g.addGraph("TestGraph"); + graph.getProperties().setProperty("testName", "testValue"); + + InputNode n1 = new InputNode(0); + InputNode n2 = new InputNode(1); + InputEdge e1 = new InputEdge((char)0, 0, 1); + InputEdge e2 = new InputEdge((char)1, 0, 1); + graph.addNode(n1); + graph.addNode(n2); + graph.addEdge(e1); + graph.addEdge(e2); + + test(document); + } + + @Test + public void testComplexExport() { + + GraphDocument document = new GraphDocument(); + Group g = new Group(); + document.addGroup(g); + + InputGraph graph = g.addGraph("TestGraph"); + graph.getProperties().setProperty("testName", "testValue"); + + InputNode n1 = new InputNode(0); + InputNode n2 = new InputNode(1); + InputEdge e1 = new InputEdge((char)0, 0, 0); + InputEdge e2 = new InputEdge((char)1, 1, 1); + graph.addNode(n1); + graph.addNode(n2); + graph.addEdge(e1); + graph.addEdge(e2); + + InputGraph graph2 = g.addGraph("TestGraph2"); + graph2.addNode(n1); + InputNode n3 = new InputNode(2); + graph2.addNode(n3); + InputEdge e3 = new InputEdge((char)0, 0, 2); + graph2.addEdge(e3); + + test(document); + } + + + /** + * Test of parse method, of class Parser. + */ + @Test + public void testParse() { + testBoth(new GraphDocument(), ""); + } + +} \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java --- a/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java Wed Jun 08 15:36:30 2011 +0200 @@ -28,6 +28,7 @@ import com.sun.hotspot.igv.data.InputEdge; import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.InputNode; +import com.sun.hotspot.igv.data.Pair; import com.sun.hotspot.igv.data.Property; import java.util.Collection; import java.util.HashMap; @@ -60,14 +61,14 @@ } private static InputGraph createDiffSameGroup(InputGraph a, InputGraph b) { - Map keyMapB = new HashMap(); + Map keyMapB = new HashMap(b.getNodes().size()); for (InputNode n : b.getNodes()) { Integer key = n.getId(); assert !keyMapB.containsKey(key); keyMapB.put(key, n); } - Set pairs = new HashSet(); + Set pairs = new HashSet(); for (InputNode n : a.getNodes()) { Integer key = n.getId(); @@ -75,30 +76,28 @@ if (keyMapB.containsKey(key)) { InputNode nB = keyMapB.get(key); - pairs.add(new Pair(n, nB)); + pairs.add(new NodePair(n, nB)); } } return createDiff(a, b, pairs); } - private static InputGraph createDiff(InputGraph a, InputGraph b, Set pairs) { + private static InputGraph createDiff(InputGraph a, InputGraph b, Set pairs) { Group g = new Group(); g.setMethod(a.getGroup().getMethod()); g.setAssembly(a.getGroup().getAssembly()); g.getProperties().setProperty("name", "Difference"); - InputGraph graph = new InputGraph(g, null); - graph.setName(a.getName() + ", " + b.getName()); - graph.setIsDifferenceGraph(true); + InputGraph graph = g.addGraph(a.getName() + ", " + b.getName(), new Pair(a, b)); Set nodesA = new HashSet(a.getNodes()); Set nodesB = new HashSet(b.getNodes()); - Map inputNodeMap = new HashMap(); - for (Pair p : pairs) { - InputNode n = p.getN1(); + Map inputNodeMap = new HashMap(pairs.size()); + for (NodePair p : pairs) { + InputNode n = p.getLeft(); assert nodesA.contains(n); - InputNode nB = p.getN2(); + InputNode nB = p.getRight(); assert nodesB.contains(nB); nodesA.remove(n); @@ -113,15 +112,22 @@ for (InputNode n : nodesA) { InputNode n2 = new InputNode(n); graph.addNode(n2); - markAsNew(n2); + markAsDeleted(n2); inputNodeMap.put(n, n2); } + int curIndex = 0; for (InputNode n : nodesB) { InputNode n2 = new InputNode(n); - n2.setId(-n2.getId()); + + // Find new ID for node of b, does not change the id property + while (graph.getNode(curIndex) != null) { + curIndex++; + } + + n2.setId(curIndex); graph.addNode(n2); - markAsDeleted(n2); + markAsNew(n2); inputNodeMap.put(n, n2); } @@ -140,7 +146,7 @@ InputEdge newEdge = new InputEdge(fromIndex, toIndex, nodeFrom.getId(), nodeTo.getId()); if (!newEdges.contains(newEdge)) { - markAsNew(newEdge); + markAsDeleted(newEdge); newEdges.add(newEdge); graph.addEdge(newEdge); } @@ -156,7 +162,7 @@ InputEdge newEdge = new InputEdge(fromIndex, toIndex, nodeFrom.getId(), nodeTo.getId()); if (!newEdges.contains(newEdge)) { - markAsDeleted(newEdge); + markAsNew(newEdge); newEdges.add(newEdge); graph.addEdge(newEdge); } else { @@ -168,24 +174,20 @@ } } - g.addGraph(graph); return graph; } - private static class Pair { + private static class NodePair extends Pair { + - private InputNode n1; - private InputNode n2; - - public Pair(InputNode n1, InputNode n2) { - this.n1 = n1; - this.n2 = n2; + public NodePair(InputNode n1, InputNode n2) { + super(n1, n2); } public double getValue() { double result = 0.0; - for (Property p : n1.getProperties()) { + for (Property p : getLeft().getProperties()) { double faktor = 1.0; for (String forbidden : IGNORE_PROPERTIES) { if (p.getName().equals(forbidden)) { @@ -193,7 +195,7 @@ break; } } - String p2 = n2.getProperties().get(p.getName()); + String p2 = getRight().getProperties().get(p.getName()); result += evaluate(p.getValue(), p2) * faktor; } @@ -210,21 +212,13 @@ return (double) (Math.abs(p.length() - p2.length())) / p.length() + 0.5; } } - - public InputNode getN1() { - return n1; - } - - public InputNode getN2() { - return n2; - } } private static InputGraph createDiff(InputGraph a, InputGraph b) { Set matched = new HashSet(); - Set pairs = new HashSet(); + Set pairs = new HashSet(); for (InputNode n : a.getNodes()) { String s = n.getProperties().get(MAIN_PROPERTY); if (s == null) { @@ -237,18 +231,18 @@ } if (s.equals(s2)) { - Pair p = new Pair(n, n2); + NodePair p = new NodePair(n, n2); pairs.add(p); } } } - Set selectedPairs = new HashSet(); + Set selectedPairs = new HashSet(); while (pairs.size() > 0) { double min = Double.MAX_VALUE; - Pair minPair = null; - for (Pair p : pairs) { + NodePair minPair = null; + for (NodePair p : pairs) { double cur = p.getValue(); if (cur < min) { minPair = p; @@ -261,9 +255,9 @@ } else { selectedPairs.add(minPair); - Set toRemove = new HashSet(); - for (Pair p : pairs) { - if (p.getN1() == minPair.getN1() || p.getN2() == minPair.getN2()) { + Set toRemove = new HashSet(); + for (NodePair p : pairs) { + if (p.getLeft() == minPair.getLeft() || p.getRight() == minPair.getRight()) { toRemove.add(p); } } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Filter/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction --- a/src/share/tools/IdealGraphVisualizer/Filter/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction Wed Jun 08 14:50:55 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -com.sun.hotspot.igv.filter.JavaSE6ScriptEngine \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CombineFilter.java --- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CombineFilter.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CombineFilter.java Wed Jun 08 15:36:30 2011 +0200 @@ -77,7 +77,7 @@ } assert slot != null; - slot.setName(f.getProperties().get("dump_spec")); + slot.setText(f.getProperties().get("dump_spec")); if (f.getProperties().get("short_name") != null) { slot.setShortName(f.getProperties().get("short_name")); } else { @@ -122,7 +122,7 @@ pos = Integer.parseInt(succ.getProperties().get("con")); } OutputSlot slot = f.createOutputSlot(pos); - slot.setName(succ.getProperties().get("dump_spec")); + slot.setText(succ.getProperties().get("dump_spec")); if (succ.getProperties().get("short_name") != null) { slot.setShortName(succ.getProperties().get("short_name")); } else { diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CustomFilter.java --- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CustomFilter.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/CustomFilter.java Wed Jun 08 15:36:30 2011 +0200 @@ -89,7 +89,9 @@ public boolean openInEditor() { EditFilterDialog dialog = new EditFilterDialog(CustomFilter.this); dialog.setVisible(true); - return dialog.wasAccepted(); + boolean result = dialog.wasAccepted(); + this.getChangedEvent().fire(); + return result; } @Override @@ -100,18 +102,12 @@ public static ScriptEngineAbstraction getEngine() { if (engine == null) { + Collection list = Lookup.getDefault().lookupAll(ScriptEngineAbstraction.class); ScriptEngineAbstraction chosen = null; - try { - Collection list = Lookup.getDefault().lookupAll(ScriptEngineAbstraction.class); - for (ScriptEngineAbstraction s : list) { - if (s.initialize(getJsHelperText())) { - if (chosen == null || !(chosen instanceof JavaSE6ScriptEngine)) { - chosen = s; - } - } + for (ScriptEngineAbstraction s : list) { + if (s.initialize(getJsHelperText())) { + chosen = s; } - } catch (NoClassDefFoundError ncdfe) { - Logger.getLogger("global").log(Level.SEVERE, null, ncdfe); } if (chosen == null) { diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/EditFilterDialog.java --- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/EditFilterDialog.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/EditFilterDialog.java Wed Jun 08 15:36:30 2011 +0200 @@ -137,17 +137,17 @@ }// //GEN-END:initComponents private void okButtonClicked(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonClicked - this.customFilter.setName(this.nameTextField.getText()); - this.customFilter.setCode(this.sourceTextArea.getText()); - accepted = true; - setVisible(false); + this.customFilter.setName(this.nameTextField.getText()); + this.customFilter.setCode(this.sourceTextArea.getText()); + accepted = true; + setVisible(false); }//GEN-LAST:event_okButtonClicked private void cancelButtonClicked(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonClicked - setVisible(false); + setVisible(false); }//GEN-LAST:event_cancelButtonClicked - - + + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton cancelButton; private javax.swing.JScrollPane jScrollPane1; @@ -157,5 +157,5 @@ private javax.swing.JLabel sourceLabel; private javax.swing.JTextArea sourceTextArea; // End of variables declaration//GEN-END:variables - + } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterChain.java --- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterChain.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/FilterChain.java Wed Jun 08 15:36:30 2011 +0200 @@ -26,6 +26,7 @@ import com.sun.hotspot.igv.graph.Diagram; import com.sun.hotspot.igv.data.ChangedEvent; import com.sun.hotspot.igv.data.ChangedEventProvider; +import com.sun.hotspot.igv.data.ChangedListener; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -38,18 +39,21 @@ private List filters; private transient ChangedEvent changedEvent; - private boolean fireEvents; + + private ChangedListener changedListener = new ChangedListener() { + public void changed(Filter source) { + changedEvent.fire(); + } + }; public FilterChain() { filters = new ArrayList(); changedEvent = new ChangedEvent(this); - this.fireEvents = true; } public FilterChain(FilterChain f) { this.filters = new ArrayList(f.filters); changedEvent = new ChangedEvent(this); - this.fireEvents = true; } public ChangedEvent getChangedEvent() { @@ -84,29 +88,12 @@ } } - public void beginAtomic() { - this.fireEvents = false; - } - - public void endAtomic() { - this.fireEvents = true; - changedEvent.fire(); - } public void addFilter(Filter filter) { assert filter != null; filters.add(filter); - if (fireEvents) { - changedEvent.fire(); - } - } - - public void addFilterSameSequence(Filter filter) { - assert filter != null; - filters.add(filter); - if (fireEvents) { - changedEvent.fire(); - } + filter.getChangedEvent().addListener(changedListener); + changedEvent.fire(); } public boolean containsFilter(Filter filter) { @@ -116,9 +103,8 @@ public void removeFilter(Filter filter) { assert filters.contains(filter); filters.remove(filter); - if (fireEvents) { - changedEvent.fire(); - } + filter.getChangedEvent().removeListener(changedListener); + changedEvent.fire(); } public void moveFilterUp(Filter filter) { @@ -128,9 +114,7 @@ filters.remove(index); filters.add(index - 1, filter); } - if (fireEvents) { - changedEvent.fire(); - } + changedEvent.fire(); } public void moveFilterDown(Filter filter) { @@ -140,16 +124,10 @@ filters.remove(index); filters.add(index + 1, filter); } - if (fireEvents) { - changedEvent.fire(); - } + changedEvent.fire(); } public List getFilters() { return Collections.unmodifiableList(filters); } - - public void clear() { - filters.clear(); - } } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/JavaSE6ScriptEngine.java --- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/JavaSE6ScriptEngine.java Wed Jun 08 14:50:55 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -/* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.sun.hotspot.igv.filter; - -import com.sun.hotspot.igv.graph.Diagram; -import javax.script.Bindings; -import javax.script.ScriptContext; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; -import javax.script.ScriptException; -import org.openide.util.Exceptions; - -/** - * - * @author Thomas Wuerthinger - */ -public class JavaSE6ScriptEngine implements ScriptEngineAbstraction { - - private ScriptEngine engine; - private Bindings bindings; - - public boolean initialize(String jsHelperText) { - try { - ScriptEngineManager sem = new ScriptEngineManager(); - ScriptEngine e = sem.getEngineByName("ECMAScript"); - engine = e; - e.eval(jsHelperText); - Bindings b = e.getContext().getBindings(ScriptContext.ENGINE_SCOPE); - b.put("IO", System.out); - bindings = b; - return true; - } catch (Exception e) { - return false; - } - } - - public void execute(Diagram d, String code) { - try { - Bindings b = bindings; - b.put("graph", d); - engine.eval(code, b); - } catch (ScriptException ex) { - Exceptions.printStackTrace(ex); - } - } -} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveInputsFilter.java --- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveInputsFilter.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveInputsFilter.java Wed Jun 08 15:36:30 2011 +0200 @@ -73,7 +73,7 @@ } is.removeAllConnections(); is.setShortName("X"); - is.setName(sb.toString()); + is.setText(sb.toString()); last.add(is); } else { last.clear(); @@ -91,10 +91,10 @@ if (i != 0) { sb.append("
"); } - sb.append(is2.getName()); + sb.append(is2.getText()); } - first.setName(sb.toString()); + first.setText(sb.toString()); for (int i = 1; i < last.size(); i++) { f.removeSlot(last.get(i)); diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveSelfLoopsFilter.java --- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveSelfLoopsFilter.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/RemoveSelfLoopsFilter.java Wed Jun 08 15:36:30 2011 +0200 @@ -72,7 +72,7 @@ } c.getInputSlot().setShortName("O"); - c.getInputSlot().setName("Self Loop"); + c.getInputSlot().setText("Self Loop"); } } } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/SplitFilter.java --- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/SplitFilter.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/SplitFilter.java Wed Jun 08 15:36:30 2011 +0200 @@ -39,25 +39,50 @@ private String name; private Selector selector; + private String propertyName; - public SplitFilter(String name, Selector selector) { + public SplitFilter(String name, Selector selector, String propertyName) { this.name = name; this.selector = selector; + this.propertyName = propertyName; } public String getName() { return name; } - + public void apply(Diagram d) { List
list = selector.selected(d); for (Figure f : list) { + + for (InputSlot is : f.getInputSlots()) { + for (Connection c : is.getConnections()) { + OutputSlot os = c.getOutputSlot(); + if (f.getSource().getSourceNodes().size() > 0) { + os.getSource().addSourceNodes(f.getSource()); + os.setAssociatedNode(f.getSource().getSourceNodes().get(0)); + os.setColor(f.getColor()); + } + + + String s = Figure.resolveString(propertyName, f.getProperties()); + if (s != null) { + os.setShortName(s); + } + + } + } for (OutputSlot os : f.getOutputSlots()) { for (Connection c : os.getConnections()) { InputSlot is = c.getInputSlot(); - is.setName(f.getProperties().get("dump_spec")); - String s = f.getProperties().get("short_name"); + if (f.getSource().getSourceNodes().size() > 0) { + is.getSource().addSourceNodes(f.getSource()); + is.setAssociatedNode(f.getSource().getSourceNodes().get(0)); + is.setColor(f.getColor()); + } + + String s = Figure.resolveString(propertyName, f.getProperties()); if (s != null) { is.setShortName(s); } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/helper.js --- a/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/helper.js Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Filter/src/com/sun/hotspot/igv/filter/helper.js Wed Jun 08 15:36:30 2011 +0200 @@ -21,16 +21,16 @@ * questions. * */ - + /** * * @author Thomas Wuerthinger */ - + function colorize(property, regexp, color) { var f = new ColorFilter(""); f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.RegexpPropertyMatcher(property, regexp)), color)); - f.apply(graph); + f.apply(graph); } function remove(property, regexp) { @@ -39,8 +39,11 @@ f.apply(graph); } -function split(property, regexp) { - var f = new SplitFilter("", new MatcherSelector(new Properties.RegexpPropertyMatcher(property, regexp))); +function split(property, regexp, propertyName) { + if (propertyName == undefined) { + propertyName = graph.getNodeText(); + } + var f = new SplitFilter("", new MatcherSelector(new Properties.RegexpPropertyMatcher(property, regexp)), propertyName); f.apply(graph); } @@ -68,4 +71,4 @@ var pink = Color.pink var red = Color.red; var yellow = Color.yellow; -var white = Color.white; +var white = Color.white; \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/genfiles.properties --- a/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/genfiles.properties Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/nbproject/genfiles.properties Wed Jun 08 15:36:30 2011 +0200 @@ -1,6 +1,3 @@ -build.xml.data.CRC32=09ba2a87 -build.xml.script.CRC32=9c158403 -build.xml.stylesheet.CRC32=a56c6a5b@1.45.1 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=09ba2a87 diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.form --- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.form Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.form Wed Jun 08 15:36:30 2011 +0200 @@ -3,6 +3,7 @@ + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.java --- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.java Wed Jun 08 15:36:30 2011 +0200 @@ -84,7 +84,7 @@ import org.openide.filesystems.FileObject; /** - * + * * @author Thomas Wuerthinger */ public final class FilterTopComponent extends TopComponent implements LookupListener, ExplorerManager.Provider { @@ -139,7 +139,7 @@ if (s != customFilterSetting) { FilterChain chain = getFilterChain(); - chain.beginAtomic(); + chain.getChangedEvent().beginAtomic(); List toRemove = new ArrayList(); for (Filter f : chain.getFilters()) { if (!s.containsFilter(f)) { @@ -156,7 +156,7 @@ } } - chain.endAtomic(); + chain.getChangedEvent().endAtomic(); filterSettingsChangedEvent.fire(); } else { this.updateComboBoxSelection(); @@ -269,8 +269,6 @@ private class FilterChildren extends Children.Keys implements ChangedListener { - //private Node[] oldSelection; - //private ArrayList newSelection; private HashMap nodeHash = new HashMap(); protected Node[] createNodes(Object object) { @@ -280,7 +278,7 @@ assert object instanceof Filter; Filter filter = (Filter) object; - com.sun.hotspot.igv.filterwindow.FilterNode node = new com.sun.hotspot.igv.filterwindow.FilterNode(filter); + FilterNode node = new FilterNode(filter); node.getSelectionChangedEvent().addListener(this); nodeHash.put(object, node); return new Node[]{node}; @@ -322,12 +320,7 @@ } public FilterChain getFilterChain() { - return filterChain;/* - EditorTopComponent tc = EditorTopComponent.getActive(); - if (tc == null) { - return filterChain; - } - return tc.getFilterChain();*/ + return filterChain; } private FilterTopComponent() { @@ -566,7 +559,6 @@ return PREFERRED_ID; } - @Override public ExplorerManager getExplorerManager() { return manager; } @@ -586,11 +578,6 @@ public void resultChanged(LookupEvent lookupEvent) { setChain(Utilities.actionsGlobalContext().lookup(FilterChain.class)); - /* - EditorTopComponent tc = EditorTopComponent.getActive(); - if (tc != null) { - setChain(tc.getFilterChain()); - }*/ } public void setChain(FilterChain chain) { @@ -610,6 +597,24 @@ } @Override + public boolean requestFocus(boolean temporary) { + view.requestFocus(); + return super.requestFocus(temporary); + } + + @Override + protected boolean requestFocusInWindow(boolean temporary) { + view.requestFocus(); + return super.requestFocusInWindow(temporary); + } + + @Override + public void requestActive() { + super.requestActive(); + view.requestFocus(); + } + + @Override public void writeExternal(ObjectOutput out) throws IOException { super.writeExternal(out); diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/Bundle.properties --- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/Bundle.properties Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/actions/Bundle.properties Wed Jun 08 15:36:30 2011 +0200 @@ -1,10 +1,7 @@ -# To change this template, choose Tools | Templates -# and open the template in the editor. - -CTL_FilterAction=Open Filter Window +CTL_FilterAction=Open Filter Window +CTL_MoveFilterUpAction=Move upwards CTL_MoveFilterDownAction=Move downwards -CTL_MoveFilterUpAction=Move upwards -CTL_NewFilterAction=New filter... CTL_RemoveFilterAction=Remove CTL_RemoveFilterSettingsAction=Remove filter setting CTL_SaveFilterSettingsAction=Save filter settings... +CTL_NewFilterAction=New filter... diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.xml --- a/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.xml Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Graph/nbproject/project.xml Wed Jun 08 15:36:30 2011 +0200 @@ -25,6 +25,7 @@ com.sun.hotspot.igv.graph + com.sun.hotspot.igv.graph.services diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Block.java --- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Block.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Block.java Wed Jun 08 15:36:30 2011 +0200 @@ -60,14 +60,6 @@ return succs; } - public Set getPredecessors() { - Set succs = new HashSet(); - for (InputBlock b : inputBlock.getPredecessors()) { - succs.add(diagram.getBlock(b)); - } - return succs; - } - public void setBounds(Rectangle r) { this.bounds = r; } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Connection.java --- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Connection.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Connection.java Wed Jun 08 15:36:30 2011 +0200 @@ -23,6 +23,7 @@ */ package com.sun.hotspot.igv.graph; +import com.sun.hotspot.igv.data.Source; import com.sun.hotspot.igv.layout.Link; import com.sun.hotspot.igv.layout.Port; import java.awt.Color; @@ -31,7 +32,7 @@ import java.util.List; /** - * + * * @author Thomas Wuerthinger */ public class Connection implements Source.Provider, Link { @@ -99,6 +100,10 @@ outputSlot.getFigure().removeSuccessor(inputSlot.getFigure()); outputSlot.connections.remove(this); } + + public String getToolTipText() { + return "From " + this.getOutputSlot().getFigure().toString() + " to " + this.getInputSlot().getFigure(); + } @Override public String toString() { @@ -121,3 +126,4 @@ controlPoints = list; } } + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java --- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Diagram.java Wed Jun 08 15:36:30 2011 +0200 @@ -28,6 +28,7 @@ import com.sun.hotspot.igv.data.InputGraph; import com.sun.hotspot.igv.data.InputNode; import com.sun.hotspot.igv.data.Properties; +import com.sun.hotspot.igv.data.Properties.StringPropertyMatcher; import java.awt.Font; import java.util.ArrayList; import java.util.Collection; @@ -35,7 +36,8 @@ import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; -import java.util.HashMap; +import java.util.Hashtable; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Set; @@ -52,19 +54,26 @@ private int curId; private String nodeText; private Font font; + private Font slotFont; public Font getFont() { return font; } + public Font getSlotFont() { + return slotFont; + } + private Diagram() { figures = new ArrayList
(); - blocks = new HashMap(); + blocks = new LinkedHashMap(8); this.nodeText = ""; - this.font = new Font("Serif", Font.PLAIN, 14); + this.font = new Font("Arial", Font.PLAIN, 13); + this.slotFont = new Font("Arial", Font.PLAIN, 10); } public Block getBlock(InputBlock b) { + assert blocks.containsKey(b); return blocks.get(b); } @@ -72,12 +81,7 @@ return nodeText; } - public void schedule(Collection newBlocks) { - graph.schedule(newBlocks); - updateBlocks(); - } - - private void updateBlocks() { + public void updateBlocks() { blocks.clear(); for (InputBlock b : graph.getBlocks()) { Block curBlock = new Block(b, this); @@ -113,6 +117,22 @@ assert outputSlot.getFigure().getDiagram() == this; return new Connection(inputSlot, outputSlot); } + + public Map> calcSourceToFigureRelation() { + Map> map = new HashMap>(); + + for(InputNode node : this.getGraph().getNodes()) { + map.put(node, new HashSet
()); + } + + for(Figure f : this.getFigures()) { + for(InputNode node : f.getSource().getSourceNodes()) { + map.get(node).add(f); + } + } + + return map; + } public static Diagram createDiagram(InputGraph graph, String nodeText) { if (graph == null) { @@ -126,7 +146,7 @@ d.updateBlocks(); Collection nodes = graph.getNodes(); - HashMap figureHash = new HashMap(); + Hashtable figureHash = new Hashtable(); for (InputNode n : nodes) { Figure f = d.createFigure(); f.getSource().addSourceNode(n); @@ -141,6 +161,8 @@ Figure fromFigure = figureHash.get(from); Figure toFigure = figureHash.get(to); assert fromFigure != null && toFigure != null; + + if(fromFigure == null || toFigure == null) continue; int fromIndex = e.getFromIndex(); while (fromFigure.getOutputSlots().size() <= fromIndex) { @@ -230,9 +252,9 @@ public Figure getRootFigure() { Properties.PropertySelector
selector = new Properties.PropertySelector
(figures); - Figure root = selector.selectSingle("name", "Root"); + Figure root = selector.selectSingle(new StringPropertyMatcher("name", "Root")); if (root == null) { - root = selector.selectSingle("name", "Start"); + root = selector.selectSingle(new StringPropertyMatcher("name", "Start")); } if (root == null) { List
rootFigures = getRootFigures(); diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Figure.java --- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Figure.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Figure.java Wed Jun 08 15:36:30 2011 +0200 @@ -23,16 +23,21 @@ */ package com.sun.hotspot.igv.graph; +import com.sun.hotspot.igv.data.InputBlock; +import com.sun.hotspot.igv.data.Source; +import com.sun.hotspot.igv.data.InputNode; import com.sun.hotspot.igv.layout.Cluster; import com.sun.hotspot.igv.layout.Vertex; import com.sun.hotspot.igv.data.Properties; import java.awt.Color; import java.awt.Dimension; +import java.awt.Font; import java.awt.FontMetrics; import java.awt.Graphics; import java.awt.Point; import java.awt.image.BufferedImage; import java.util.ArrayList; +import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.List; @@ -44,9 +49,11 @@ */ public class Figure extends Properties.Entity implements Source.Provider, Vertex { - public static final int INSET = 6; - public static final int SLOT_WIDTH = 10; - public static final int SLOT_START = 3; + public static final int INSET = 12; + public static int SLOT_WIDTH = 12; + public static final int OVERLAPPING = 6; + public static final int SLOT_START = 4; + public static final int SLOT_OFFSET = 8; public static final boolean VERTICAL_LAYOUT = true; protected List inputSlots; protected List outputSlots; @@ -66,28 +73,49 @@ if (heightCash == -1) { BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics(); - g.setFont(diagram.getFont()); + g.setFont(diagram.getFont().deriveFont(Font.BOLD)); FontMetrics metrics = g.getFontMetrics(); String nodeText = diagram.getNodeText(); heightCash = nodeText.split("\n").length * metrics.getHeight() + INSET; } return heightCash; } + + public static List getAllBefore(List inputList, T tIn) { + List result = new ArrayList(); + for(T t : inputList) { + if(t.equals(tIn)) { + break; + } + result.add(t); + } + return result; + } + + public static int getSlotsWidth(Collection slots) { + int result = Figure.SLOT_OFFSET; + for(Slot s : slots) { + result += s.getWidth() + Figure.SLOT_OFFSET; + } + return result; + } public int getWidth() { if (widthCash == -1) { int max = 0; BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); Graphics g = image.getGraphics(); - g.setFont(diagram.getFont()); + g.setFont(diagram.getFont().deriveFont(Font.BOLD)); FontMetrics metrics = g.getFontMetrics(); - for (String s : lines) { + for (String s : getLines()) { int cur = metrics.stringWidth(s); if (cur > max) { max = cur; } } widthCash = max + INSET; + widthCash = Math.max(widthCash, Figure.getSlotsWidth(inputSlots)); + widthCash = Math.max(widthCash, Figure.getSlotsWidth(outputSlots)); } return widthCash; } @@ -221,6 +249,13 @@ public List getInputSlots() { return Collections.unmodifiableList(inputSlots); } + + public Set getSlots() { + Set result = new HashSet(); + result.addAll(getInputSlots()); + result.addAll(getOutputSlots()); + return result; + } public List getOutputSlots() { return Collections.unmodifiableList(outputSlots); @@ -248,13 +283,13 @@ String[] result = new String[strings.length]; for (int i = 0; i < strings.length; i++) { - result[i] = resolveString(strings[i]); + result[i] = resolveString(strings[i], getProperties()); } lines = result; } - private String resolveString(String string) { + public static final String resolveString(String string, Properties properties) { StringBuilder sb = new StringBuilder(); boolean inBrackets = false; @@ -264,7 +299,7 @@ char c = string.charAt(i); if (inBrackets) { if (c == ']') { - String value = getProperties().get(curIdent.toString()); + String value = properties.get(curIdent.toString()); if (value == null) { value = ""; } @@ -289,10 +324,12 @@ public Dimension getSize() { if (VERTICAL_LAYOUT) { int width = Math.max(getWidth(), Figure.SLOT_WIDTH * (Math.max(inputSlots.size(), outputSlots.size()) + 1)); - int height = getHeight() + 2 * Figure.SLOT_WIDTH; + int height = getHeight() + 2 * Figure.SLOT_WIDTH - 2 * Figure.OVERLAPPING; + + return new Dimension(width, height); } else { - int width = getWidth() + 2 * Figure.SLOT_WIDTH; + int width = getWidth() + 2 * Figure.SLOT_WIDTH - 2*Figure.OVERLAPPING; int height = Figure.SLOT_WIDTH * (Math.max(inputSlots.size(), outputSlots.size()) + 1); return new Dimension(width, height); } @@ -308,15 +345,19 @@ assert false : "Should never reach here, every figure must have at least one source node!"; return null; } else { - Cluster result = diagram.getBlock(diagram.getGraph().getBlock(getSource().getSourceNodes().get(0))); + final InputBlock inputBlock = diagram.getGraph().getBlock(getSource().getSourceNodes().get(0)); + assert inputBlock != null; + Cluster result = diagram.getBlock(inputBlock); assert result != null; return result; } } public boolean isRoot() { - if (source.getSourceNodes().size() > 0 && source.getSourceNodes().get(0).getProperties().get("name").equals("Root")) { - return true; + + List sourceNodes = source.getSourceNodes(); + if (sourceNodes.size() > 0 && sourceNodes.get(0).getProperties().get("name") != null) { + return source.getSourceNodes().get(0).getProperties().get("name").equals("Root"); } else { return false; } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/InputSlot.java --- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/InputSlot.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/InputSlot.java Wed Jun 08 15:36:30 2011 +0200 @@ -27,7 +27,7 @@ import java.util.List; /** - * + * * @author Thomas Wuerthinger */ public class InputSlot extends Slot { @@ -45,9 +45,12 @@ InputSlot s = inputSlots.remove(position); inputSlots.add(position, s); } - public Point getRelativePosition() { - return new Point(getFigure().getWidth() * (getPosition() + 1) / (getFigure().getInputSlots().size() + 1), Figure.SLOT_WIDTH - Figure.SLOT_START); + int gap = getFigure().getWidth() - Figure.getSlotsWidth(getFigure().getInputSlots()); + double gapRatio = (double)gap / (double)(getFigure().getInputSlots().size() + 1); + int gapAmount = (int)((getPosition() + 1)*gapRatio); + return new Point(gapAmount + Figure.getSlotsWidth(Figure.getAllBefore(getFigure().getInputSlots(), this)) + getWidth()/2, -Figure.SLOT_START); + //return new Point((getFigure().getWidth() / (getFigure().getInputSlots().size() * 2)) * (getPosition() * 2 + 1), -Figure.SLOT_START); } @Override diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/OutputSlot.java --- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/OutputSlot.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/OutputSlot.java Wed Jun 08 15:36:30 2011 +0200 @@ -26,7 +26,7 @@ import java.awt.Point; /** - * + * * @author Thomas Wuerthinger */ public class OutputSlot extends Slot { @@ -45,7 +45,13 @@ } public Point getRelativePosition() { - return new Point(getFigure().getWidth() * (getPosition() + 1) / (getFigure().getOutputSlots().size() + 1), getFigure().getSize().height - Figure.SLOT_WIDTH + Figure.SLOT_START); + int gap = getFigure().getWidth() - Figure.getSlotsWidth(getFigure().getOutputSlots()); + if(gap < 0) { + gap = 0; + } + double gapRatio = (double)gap / (double)(getFigure().getOutputSlots().size() + 1); + int gapAmount = (int)((getPosition() + 1)*gapRatio); + return new Point(gapAmount + Figure.getSlotsWidth(Figure.getAllBefore(getFigure().getOutputSlots(), this)) + getWidth()/2, Figure.SLOT_START); } @Override diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Slot.java --- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Slot.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Slot.java Wed Jun 08 15:36:30 2011 +0200 @@ -23,103 +23,168 @@ */ package com.sun.hotspot.igv.graph; +import com.sun.hotspot.igv.data.InputNode; +import com.sun.hotspot.igv.data.Properties; +import com.sun.hotspot.igv.data.Source; import com.sun.hotspot.igv.layout.Port; import com.sun.hotspot.igv.layout.Vertex; +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics; +import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Comparator; /** - * + * * @author Thomas Wuerthinger */ -public abstract class Slot implements Port, Source.Provider { - - private int wantedIndex; - private String name; - private String shortName; // 1 - 2 characters - private Source source; - protected List connections; - private Figure figure; +public abstract class Slot implements Port, Source.Provider, Properties.Provider { - protected Slot(Figure figure, int wantedIndex) { - this.figure = figure; - connections = new ArrayList(2); - source = new Source(); - this.wantedIndex = wantedIndex; - name = ""; - shortName = ""; - assert figure != null; - } - public static final Comparator slotIndexComparator = new Comparator() { + private int wantedIndex; + private Source source; + protected List connections; + private InputNode associatedNode; + private Color color; + private String text; + private String shortName; + private Figure figure; + + protected Slot(Figure figure, int wantedIndex) { + this.figure = figure; + connections = new ArrayList(2); + source = new Source(); + this.wantedIndex = wantedIndex; + text = ""; + shortName = ""; + assert figure != null; + } - public int compare(Slot o1, Slot o2) { - return o1.wantedIndex - o2.wantedIndex; - } - }; - public static final Comparator slotFigureComparator = new Comparator() { + public Properties getProperties() { + Properties p = new Properties(); + if (source.getSourceNodes().size() > 0) { + for (InputNode n : source.getSourceNodes()) { + p.add(n.getProperties()); + } + } else { + p.setProperty("name", "Slot"); + p.setProperty("figure", figure.getProperties().get("name")); + p.setProperty("connectionCount", Integer.toString(connections.size())); + } + return p; + } + public static final Comparator slotIndexComparator = new Comparator() { - public int compare(Slot o1, Slot o2) { - return o1.figure.getId() - o2.figure.getId(); - } - }; + public int compare(Slot o1, Slot o2) { + return o1.wantedIndex - o2.wantedIndex; + } + }; + public static final Comparator slotFigureComparator = new Comparator() { - public int getWantedIndex() { - return wantedIndex; - } + public int compare(Slot o1, Slot o2) { + return o1.figure.getId() - o2.figure.getId(); + } + }; + + public InputNode getAssociatedNode() { + return associatedNode; + } + + public void setAssociatedNode(InputNode node) { + associatedNode = node; + } - public Source getSource() { - return source; - } + public int getWidth() { + if (shortName == null || shortName.length() <= 1) { + return Figure.SLOT_WIDTH; + } else { + BufferedImage image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB); + Graphics g = image.getGraphics(); + g.setFont(figure.getDiagram().getSlotFont().deriveFont(Font.BOLD)); + FontMetrics metrics = g.getFontMetrics(); + return Math.max(Figure.SLOT_WIDTH, metrics.stringWidth(shortName) + 6); + } + } - public String getName() { - return name; - } + public int getWantedIndex() { + return wantedIndex; + } - public void setShortName(String s) { - assert s != null; - assert s.length() <= 2; - this.shortName = s; + public Source getSource() { + return source; + } - } + public String getText() { + return text; + } - public String getShortName() { - return shortName; - } + public void setShortName(String s) { + assert s != null; +// assert s.length() <= 2; + this.shortName = s; + + } - public boolean getShowName() { - return getShortName() != null && getShortName().length() > 0; - } + public String getShortName() { + return shortName; + } + + public String getToolTipText() { + StringBuilder sb = new StringBuilder(); + sb.append(text); - public void setName(String s) { - if (s == null) { - s = ""; - } - this.name = s; - } + for (InputNode n : getSource().getSourceNodes()) { + sb.append("Node (ID=" + n.getId() + "): " + n.getProperties().get("name")); + sb.append("
"); + } + + return sb.toString(); + } + + public boolean shouldShowName() { + return getShortName() != null && getShortName().length() > 0; + } - public Figure getFigure() { - assert figure != null; - return figure; - } + public void setText(String s) { + if (s == null) { + s = ""; + } + this.text = s; + } - public List getConnections() { - return Collections.unmodifiableList(connections); - } + public Figure getFigure() { + assert figure != null; + return figure; + } + + public Color getColor() { + return this.color; + } + + public void setColor(Color c) { + color = c; + } - public void removeAllConnections() { - List connectionsCopy = new ArrayList(this.connections); - for (Connection c : connectionsCopy) { - c.remove(); - } - } + public List getConnections() { + return Collections.unmodifiableList(connections); + } - public Vertex getVertex() { - return figure; - } + public void removeAllConnections() { + List connectionsCopy = new ArrayList(this.connections); + for (Connection c : connectionsCopy) { + c.remove(); + } + } - public abstract int getPosition(); + public Vertex getVertex() { + return figure; + } - public abstract void setPosition(int position); + public abstract int getPosition(); + + public abstract void setPosition(int position); } + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Source.java --- a/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/Source.java Wed Jun 08 14:50:55 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.graph; - -import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.InputNode; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * - * @author Thomas Wuerthinger - */ -public class Source { - - private List sourceNodes; - private Set set; - - public Source() { - sourceNodes = new ArrayList(1); - } - - public List getSourceNodes() { - return Collections.unmodifiableList(sourceNodes); - } - - public Set getSourceNodesAsSet() { - if (set == null) { - set = new HashSet(); - for (InputNode n : sourceNodes) { - int id = n.getId(); - //if(id < 0) id = -id; - set.add(id); - } - } - return set; - } - - public void addSourceNode(InputNode n) { - sourceNodes.add(n); - set = null; - } - - public void removeSourceNode(InputNode n) { - sourceNodes.remove(n); - set = null; - } - - public interface Provider { - - public Source getSource(); - } - - public void setSourceNodes(List sourceNodes) { - this.sourceNodes = sourceNodes; - set = null; - } - - public void addSourceNodes(Source s) { - for (InputNode n : s.getSourceNodes()) { - sourceNodes.add(n); - } - set = null; - } - - public boolean isInBlock(InputGraph g, InputBlock blockNode) { - - for (InputNode n : this.getSourceNodes()) { - if (g.getBlock(n) == blockNode) { - return true; - } - } - return false; - } -} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/services/DiagramProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Graph/src/com/sun/hotspot/igv/graph/services/DiagramProvider.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.graph.services; + +import com.sun.hotspot.igv.data.ChangedEvent; +import com.sun.hotspot.igv.graph.Diagram; + +/** + * + * @author Thomas Wuerthinger + */ +public interface DiagramProvider { + Diagram getDiagram(); + ChangedEvent getChangedEvent(); + +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphTextEditor/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphTextEditor/build.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,8 @@ + + + + + + Builds, tests, and runs the project com.sun.hotspot.igv.graphtexteditor. + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphTextEditor/manifest.mf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphTextEditor/manifest.mf Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +OpenIDE-Module: com.sun.hotspot.igv.graphtexteditor +OpenIDE-Module-Layer: com/sun/hotspot/igv/graphtexteditor/layer.xml +OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/graphtexteditor/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/build-impl.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/build-impl.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,45 @@ + + + + + + + + + + + + + You must set 'suite.dir' to point to your containing module suite + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/genfiles.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/genfiles.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,5 @@ +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=ac7a776e +nbproject/build-impl.xml.script.CRC32=9388e04e +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45.1 diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/project.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,2 @@ +javac.source=1.5 +javac.compilerargs=-Xlint -Xlint:-serial diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/project.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,93 @@ + + + org.netbeans.modules.apisupport.project + + + com.sun.hotspot.igv.graphtexteditor + + + + com.sun.hotspot.igv.data + + + + 1.0 + + + + com.sun.hotspot.igv.graph + + + + 1.0 + + + + com.sun.hotspot.igv.graphtotext + + + + 1.0 + + + + com.sun.hotspot.igv.selectioncoordinator + + + + 1.0 + + + + com.sun.hotspot.igv.structuredtext + + + + 1.0 + + + + com.sun.hotspot.igv.texteditor + + + + 1.0 + + + + com.sun.hotspot.igv.util + + + + 1.0 + + + + org.openide.util + + + + 7.12.0.1 + + + + org.openide.util.lookup + + + + 8.6.1 + + + + org.openide.windows + + + + 6.20 + + + + + + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/suite.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphTextEditor/nbproject/suite.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,1 @@ +suite.dir=${basedir}/.. diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/Bundle.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,4 @@ +CTL_TextAction=Open Text Window +CTL_TextTopComponent=Text Window +HINT_TextTopComponent=This is a Text window +OpenIDE-Module-Name=GraphTextEditor diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextAction.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextAction.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.graphtexteditor; + +import java.awt.event.ActionEvent; +import javax.swing.AbstractAction; +import org.openide.util.NbBundle; +import org.openide.windows.TopComponent; + +/** + * Action which shows Text component. + */ +public class TextAction extends AbstractAction { + + public TextAction() { + super(NbBundle.getMessage(TextAction.class, "CTL_TextAction")); + + System.out.println("Text action initialized!!!"); +// putValue(SMALL_ICON, new ImageIcon(Utilities.loadImage(TextTopComponent.ICON_PATH, true))); + } + + public void actionPerformed(ActionEvent evt) { + TopComponent win = TextTopComponent.findInstance(); + win.open(); + win.requestActive(); + } +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.form --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.form Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,300 @@ +/* + * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package com.sun.hotspot.igv.graphtexteditor; + +import com.sun.hotspot.igv.data.ChangedListener; +import com.sun.hotspot.igv.texteditor.*; +import com.sun.hotspot.igv.data.InputGraph; +import com.sun.hotspot.igv.data.Pair; +import com.sun.hotspot.igv.graph.Diagram; +import com.sun.hotspot.igv.graph.services.DiagramProvider; +import com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter; +import com.sun.hotspot.igv.selectioncoordinator.SelectionCoordinator; +import com.sun.hotspot.igv.structuredtext.StructuredText; +import com.sun.hotspot.igv.util.LookupHistory; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Color; +import java.io.Serializable; +import java.util.Collection; +import java.util.logging.Logger; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JSplitPane; +import org.openide.util.Lookup; +import org.openide.util.LookupEvent; +import org.openide.util.LookupListener; +import org.openide.util.NbBundle; +import org.openide.util.Utilities; +import org.openide.windows.TopComponent; +import org.openide.windows.WindowManager; + +/** + * @author Thomas Wuerthinger + */ +final class TextTopComponent extends TopComponent implements LookupListener { + + private static TextTopComponent instance; + private Lookup.Result result = null; + private static final String PREFERRED_ID = "TextTopComponent"; + private Diagram lastDiagram; + private TextEditor leftEditor; + private TextEditor rightEditor; + private TextEditor singleEditor; + private JSplitPane splitPane; + private CardLayout cardLayout; + private JPanel cardLayoutPanel; + private boolean firstTimeSlider = true; + + private static final String TWO_GRAPHS = "twoGraphs"; + private static final String ONE_GRAPH = "oneGraph"; + private static final String NO_GRAPH = "noGraph"; + + private DiagramProvider currentDiagramProvider; + + private TextTopComponent() { + initComponents(); + setName(NbBundle.getMessage(TextTopComponent.class, "CTL_TextTopComponent")); + setToolTipText(NbBundle.getMessage(TextTopComponent.class, "HINT_TextTopComponent")); + + // Card layout for three different views. + cardLayout = new CardLayout(); + cardLayoutPanel = new JPanel(cardLayout); + this.setLayout(new BorderLayout()); + this.add(cardLayoutPanel, BorderLayout.CENTER); + + // No graph selected. + JLabel noGraphLabel = new JLabel("No graph opened"); + noGraphLabel.setBackground(Color.red); + //noGraphPanel.add(noGraphLabel); + cardLayoutPanel.add(noGraphLabel, NO_GRAPH); + + // Single graph selected. + singleEditor = new TextEditor(); + cardLayoutPanel.add(singleEditor.getComponent(), ONE_GRAPH); + + // Graph difference => show split pane with two graphs. + splitPane = new JSplitPane(); + leftEditor = new TextEditor(); + splitPane.setLeftComponent(leftEditor.getComponent()); + rightEditor = new TextEditor(); + splitPane.setRightComponent(rightEditor.getComponent()); + cardLayoutPanel.add(splitPane, TWO_GRAPHS); + } + + + private StructuredText convert(InputGraph graph, Diagram diagram) { + Collection converters = Lookup.getDefault().lookupAll(GraphToTextConverter.class); + StructuredText text = null; + if (converters.size() == 0) { + text = new StructuredText(graph.getName()); + text.println("No graph-to-text converter exists!"); + return text; + } + + for (GraphToTextConverter converter : converters) { + if (converter.canConvert(graph)) { + text = converter.convert(graph, diagram); + if (text == null) { + text = new StructuredText(graph.getName()); + text.println("Class " + converter.getClass().getName() + " misbehaved and returned null on graph-to-text conversion!"); + } + return text; + } + } + + text = new StructuredText(graph.getName()); + text.println("No appropriate graph-to-text converter found!"); + return text; + } + + private void updateDiagram(Diagram diagram) { + + if (diagram == lastDiagram) { + // No change => return. + return; + } + + lastDiagram = diagram; + + if (diagram == null) { + showCard(NO_GRAPH); + } else if (diagram.getGraph().getSourceGraphs() != null) { + showCard(TWO_GRAPHS); + if (firstTimeSlider) { + splitPane.setDividerLocation(0.5); + } + firstTimeSlider = false; + Pair graphs = diagram.getGraph().getSourceGraphs(); + leftEditor.setStructuredText(convert(graphs.getLeft(), diagram)); + rightEditor.setStructuredText(convert(graphs.getRight(), diagram)); + + // TODO: Hack to update view - remove + SelectionCoordinator.getInstance().getHighlightedChangedEvent().fire(); + } else { + showCard(ONE_GRAPH); + StructuredText text = convert(diagram.getGraph(), diagram); + singleEditor.setStructuredText(text); + + // TODO: Hack to update view - remove + SelectionCoordinator.getInstance().getHighlightedChangedEvent().fire(); + } + } + + private ChangedListener diagramChangedListener = new ChangedListener() { + + public void changed(DiagramProvider source) { + updateDiagram(source.getDiagram()); + } + + }; + + private void updateDiagramProvider(DiagramProvider provider) { + + if (provider == currentDiagramProvider) { + return; + } + + if (currentDiagramProvider != null) { + currentDiagramProvider.getChangedEvent().removeListener(diagramChangedListener); + } + + currentDiagramProvider = provider; + + if (currentDiagramProvider != null) { + currentDiagramProvider.getChangedEvent().addListener(diagramChangedListener); + updateDiagram(currentDiagramProvider.getDiagram()); + } else { + updateDiagram(null); + } + } + + private void showCard(final String card) { + cardLayout.show(cardLayoutPanel, card); + } + + public void resultChanged(LookupEvent lookupEvent) { + DiagramProvider p = Utilities.actionsGlobalContext().lookup(DiagramProvider.class); + + if (p == null) { + p = LookupHistory.getLast(DiagramProvider.class); + } + + updateDiagramProvider(p); + } + + /** 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() { + + setLayout(new java.awt.BorderLayout()); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + // End of variables declaration//GEN-END:variables + /** + * 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 TextTopComponent getDefault() { + if (instance == null) { + instance = new TextTopComponent(); + } + return instance; + } + + /** + * Obtain the TextTopComponent instance. Never call {@link #getDefault} directly! + */ + public static synchronized TextTopComponent findInstance() { + TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID); + if (win == null) { + Logger.getLogger(TextTopComponent.class.getName()).warning( + "Cannot find " + PREFERRED_ID + " component. It will not be located properly in the window system."); + return getDefault(); + } + if (win instanceof TextTopComponent) { + return (TextTopComponent) win; + } + Logger.getLogger(TextTopComponent.class.getName()).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() { + + DiagramProvider p = LookupHistory.getLast(DiagramProvider.class); + updateDiagramProvider(p); + + Lookup.Template tpl = new Lookup.Template(DiagramProvider.class); + result = Utilities.actionsGlobalContext().lookup(tpl); + result.addLookupListener(this); + } + + @Override + public void componentClosed() { + result.removeLookupListener(this); + result = null; + updateDiagramProvider(null); + } + + /** replaces this in object stream */ + @Override + public Object writeReplace() { + return new ResolvableHelper(); + } + + @Override + protected String preferredID() { + return PREFERRED_ID; + } + + @Override + public void requestActive() { + super.requestActive(); + cardLayoutPanel.requestFocus(); + } + + final static class ResolvableHelper implements Serializable { + + private static final long serialVersionUID = 1L; + + public Object readResolve() { + return TextTopComponent.getDefault(); + } + } +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponentSettings.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponentSettings.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,12 @@ + + + + + + + + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponentWstcref.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponentWstcref.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,11 @@ + + + + + + + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/layer.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/layer.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphToText/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphToText/build.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,8 @@ + + + + + + Builds, tests, and runs the project com.sun.hotspot.igv.graphtotext. + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphToText/manifest.mf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphToText/manifest.mf Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +OpenIDE-Module: com.sun.hotspot.igv.graphtotext +OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/graphtotext/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/build-impl.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/build-impl.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,45 @@ + + + + + + + + + + + + + You must set 'suite.dir' to point to your containing module suite + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/genfiles.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/genfiles.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,5 @@ +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=10eff8f6 +nbproject/build-impl.xml.script.CRC32=b176ca1a +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45.1 diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/platform.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/platform.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,175 @@ +cluster.path=\ + ${nbplatform.active.dir}/ide:\ + ${nbplatform.active.dir}/platform +disabled.modules=\ + org.apache.xml.resolver,\ + org.mozilla.rhino.patched,\ + org.netbeans.api.debugger,\ + org.netbeans.api.java.classpath,\ + org.netbeans.api.xml,\ + org.netbeans.core.browser,\ + org.netbeans.core.execution,\ + org.netbeans.core.ide,\ + org.netbeans.core.multiview,\ + org.netbeans.lib.cvsclient,\ + org.netbeans.lib.terminalemulator,\ + org.netbeans.libs.antlr3.runtime,\ + org.netbeans.libs.bugtracking,\ + org.netbeans.libs.bugzilla,\ + org.netbeans.libs.bytelist,\ + org.netbeans.libs.commons_codec,\ + org.netbeans.libs.commons_logging,\ + org.netbeans.libs.commons_net,\ + org.netbeans.libs.freemarker,\ + org.netbeans.libs.ini4j,\ + org.netbeans.libs.jakarta_oro,\ + org.netbeans.libs.jaxb,\ + org.netbeans.libs.jsch,\ + org.netbeans.libs.jsr223,\ + org.netbeans.libs.jvyamlb,\ + org.netbeans.libs.jzlib,\ + org.netbeans.libs.lucene,\ + org.netbeans.libs.smack,\ + org.netbeans.libs.svnClientAdapter,\ + org.netbeans.libs.svnClientAdapter.javahl,\ + org.netbeans.libs.svnClientAdapter.svnkit,\ + org.netbeans.libs.swingx,\ + org.netbeans.libs.xerces,\ + org.netbeans.modules.autoupdate.services,\ + org.netbeans.modules.autoupdate.ui,\ + org.netbeans.modules.bugtracking,\ + org.netbeans.modules.bugtracking.bridge,\ + org.netbeans.modules.bugzilla,\ + org.netbeans.modules.core.kit,\ + org.netbeans.modules.csl.api,\ + org.netbeans.modules.css.editor,\ + org.netbeans.modules.css.visual,\ + org.netbeans.modules.db,\ + org.netbeans.modules.db.core,\ + org.netbeans.modules.db.dataview,\ + org.netbeans.modules.db.drivers,\ + org.netbeans.modules.db.kit,\ + org.netbeans.modules.db.metadata.model,\ + org.netbeans.modules.db.mysql,\ + org.netbeans.modules.db.sql.editor,\ + org.netbeans.modules.db.sql.visualeditor,\ + org.netbeans.modules.dbapi,\ + org.netbeans.modules.defaults,\ + org.netbeans.modules.derby,\ + org.netbeans.modules.diff,\ + org.netbeans.modules.dlight.nativeexecution,\ + org.netbeans.modules.dlight.terminal,\ + org.netbeans.modules.editor.bookmarks,\ + org.netbeans.modules.editor.bracesmatching,\ + org.netbeans.modules.editor.codetemplates,\ + org.netbeans.modules.editor.completion,\ + org.netbeans.modules.editor.errorstripe,\ + org.netbeans.modules.editor.errorstripe.api,\ + org.netbeans.modules.editor.guards,\ + org.netbeans.modules.editor.indent.project,\ + org.netbeans.modules.editor.kit,\ + org.netbeans.modules.editor.macros,\ + org.netbeans.modules.editor.plain,\ + org.netbeans.modules.editor.plain.lib,\ + org.netbeans.modules.editor.structure,\ + org.netbeans.modules.extbrowser,\ + org.netbeans.modules.extexecution,\ + org.netbeans.modules.extexecution.destroy,\ + org.netbeans.modules.favorites,\ + org.netbeans.modules.glassfish.common,\ + org.netbeans.modules.gototest,\ + org.netbeans.modules.gsf.codecoverage,\ + org.netbeans.modules.gsf.testrunner,\ + org.netbeans.modules.html,\ + org.netbeans.modules.html.editor,\ + org.netbeans.modules.html.editor.lib,\ + org.netbeans.modules.html.lexer,\ + org.netbeans.modules.html.parser,\ + org.netbeans.modules.html.validation,\ + org.netbeans.modules.httpserver,\ + org.netbeans.modules.hudson,\ + org.netbeans.modules.hudson.mercurial,\ + org.netbeans.modules.hudson.subversion,\ + org.netbeans.modules.ide.kit,\ + org.netbeans.modules.image,\ + org.netbeans.modules.javascript.editing,\ + org.netbeans.modules.javascript.hints,\ + org.netbeans.modules.javascript.kit,\ + org.netbeans.modules.javascript.refactoring,\ + org.netbeans.modules.jellytools.ide,\ + org.netbeans.modules.jumpto,\ + org.netbeans.modules.languages,\ + org.netbeans.modules.languages.diff,\ + org.netbeans.modules.languages.manifest,\ + org.netbeans.modules.languages.yaml,\ + org.netbeans.modules.lexer.nbbridge,\ + org.netbeans.modules.localhistory,\ + org.netbeans.modules.mercurial,\ + org.netbeans.modules.options.editor,\ + org.netbeans.modules.parsing.api,\ + org.netbeans.modules.parsing.lucene,\ + org.netbeans.modules.print.editor,\ + org.netbeans.modules.project.ant,\ + org.netbeans.modules.project.libraries,\ + org.netbeans.modules.projectapi,\ + org.netbeans.modules.projectui,\ + org.netbeans.modules.projectui.buildmenu,\ + org.netbeans.modules.projectuiapi,\ + org.netbeans.modules.properties,\ + org.netbeans.modules.properties.syntax,\ + org.netbeans.modules.refactoring.api,\ + org.netbeans.modules.schema2beans,\ + org.netbeans.modules.server,\ + org.netbeans.modules.servletapi,\ + org.netbeans.modules.spellchecker,\ + org.netbeans.modules.spellchecker.apimodule,\ + org.netbeans.modules.spellchecker.bindings.htmlxml,\ + org.netbeans.modules.spellchecker.bindings.properties,\ + org.netbeans.modules.spellchecker.dictionary_en,\ + org.netbeans.modules.spellchecker.kit,\ + org.netbeans.modules.subversion,\ + org.netbeans.modules.swing.validation,\ + org.netbeans.modules.target.iterator,\ + org.netbeans.modules.tasklist.kit,\ + org.netbeans.modules.tasklist.projectint,\ + org.netbeans.modules.tasklist.todo,\ + org.netbeans.modules.tasklist.ui,\ + org.netbeans.modules.terminal,\ + org.netbeans.modules.usersguide,\ + org.netbeans.modules.utilities,\ + org.netbeans.modules.utilities.project,\ + org.netbeans.modules.versioning,\ + org.netbeans.modules.versioning.indexingbridge,\ + org.netbeans.modules.versioning.system.cvss,\ + org.netbeans.modules.versioning.util,\ + org.netbeans.modules.web.client.tools.api,\ + org.netbeans.modules.web.common,\ + org.netbeans.modules.xml,\ + org.netbeans.modules.xml.axi,\ + org.netbeans.modules.xml.catalog,\ + org.netbeans.modules.xml.core,\ + org.netbeans.modules.xml.jaxb.api,\ + org.netbeans.modules.xml.lexer,\ + org.netbeans.modules.xml.multiview,\ + org.netbeans.modules.xml.retriever,\ + org.netbeans.modules.xml.schema.completion,\ + org.netbeans.modules.xml.schema.model,\ + org.netbeans.modules.xml.tax,\ + org.netbeans.modules.xml.text,\ + org.netbeans.modules.xml.tools,\ + org.netbeans.modules.xml.wsdl.model,\ + org.netbeans.modules.xml.xam,\ + org.netbeans.modules.xml.xdm,\ + org.netbeans.modules.xsl,\ + org.netbeans.spi.debugger.ui,\ + org.netbeans.spi.editor.hints,\ + org.netbeans.spi.navigator,\ + org.netbeans.spi.palette,\ + org.netbeans.spi.tasklist,\ + org.netbeans.spi.viewmodel,\ + org.netbeans.swing.dirchooser,\ + org.openide.compat,\ + org.openide.execution,\ + org.openide.options,\ + org.openide.util.enumerations +nbplatform.active=default diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/project.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,2 @@ +javac.source=1.5 +javac.compilerargs=-Xlint -Xlint:-serial diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/project.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,40 @@ + + + org.netbeans.modules.apisupport.project + + + com.sun.hotspot.igv.graphtotext + + + + com.sun.hotspot.igv.data + + + + 1.0 + + + + com.sun.hotspot.igv.graph + + + + 1.0 + + + + com.sun.hotspot.igv.structuredtext + + + + 1.0 + + + + + com.sun.hotspot.igv.graphtotext + com.sun.hotspot.igv.graphtotext.services + + + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/suite.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphToText/nbproject/suite.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,1 @@ +suite.dir=${basedir}/.. diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/BFSGraphToTextConverter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/BFSGraphToTextConverter.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,157 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.graphtotext; + +import com.sun.hotspot.igv.data.InputEdge; +import com.sun.hotspot.igv.data.InputGraph; +import com.sun.hotspot.igv.data.InputNode; +import com.sun.hotspot.igv.data.Pair; +import com.sun.hotspot.igv.data.Properties; +import com.sun.hotspot.igv.graph.Diagram; +import com.sun.hotspot.igv.graphtotext.services.GraphToTextVisitor; +import com.sun.hotspot.igv.structuredtext.Element; +import com.sun.hotspot.igv.structuredtext.StructuredText; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Queue; +import java.util.Set; + +/** + * + * @author Thomas + */ +public class BFSGraphToTextConverter { + + private GraphToTextVisitor visitor; + private Map visitorMap; + private InputGraph graph; + private Diagram diagram; + + public BFSGraphToTextConverter(GraphToTextVisitor visitor) { + this.visitor = visitor; + visitorMap = new HashMap(); + } + + public void registerVisitor(GraphToTextVisitor visitor, Properties.PropertyMatcher matcher) { + visitorMap.put(matcher, visitor); + } + + private GraphToTextVisitor chooseVisitor(GraphToTextVisitor defaultVisitor, InputNode node) { + for(Properties.PropertyMatcher matcher : visitorMap.keySet()) { + if(node.getProperties().selectSingle(matcher) != null) { + return visitorMap.get(matcher); + } + } + + return defaultVisitor; + } + + private Element cyclicVisit(GraphToTextVisitor visitor, InputNode node, List path) { + return chooseVisitor(visitor, node).cyclicVisit(node, path); + } + + private Element visit(GraphToTextVisitor visitor, InputNode node, List path, List> children) { + return chooseVisitor(visitor, node).visit(node, path, children); + } + + protected Diagram getDiagram() { + return diagram; + } + + public StructuredText convert(InputGraph graph, Diagram diagram) { + + this.graph = graph; + this.diagram = diagram; + StructuredText text = new StructuredText(graph.getName()); + + Map> outgoing = graph.findAllOutgoingEdges(); + Map> pathMap = new HashMap>(); + Queue queue = new LinkedList(); + List rootNodes = graph.findRootNodes(); + queue.addAll(rootNodes); + for(InputNode node : rootNodes) { + pathMap.put(node, new ArrayList()); + } + + Set visited = new HashSet(); + visited.addAll(rootNodes); + + Set fullEdges = new HashSet(); + List visitOrder = new ArrayList(); + while(!queue.isEmpty()) { + + InputNode current = queue.remove(); + visitOrder.add(current); + List path = pathMap.get(current); + + List edges = outgoing.get(current); + for(InputEdge e : edges) { + InputNode dest = graph.getNode(e.getTo()); + if(!visited.contains(dest)) { + queue.add(dest); + visited.add(dest); + List curPath = new ArrayList(path); + curPath.add(e); + pathMap.put(dest, curPath); + fullEdges.add(e); + } + } + } + + + + Map fullVisitCache = new HashMap(); + for(int i=visitOrder.size() - 1; i>=0; i--) { + InputNode current = visitOrder.get(i); + List path = pathMap.get(current); + List edges = outgoing.get(current); + List> list = new ArrayList>(); + for(InputEdge e : edges) { + if(fullEdges.contains(e)) { + assert fullVisitCache.containsKey(graph.getNode(e.getTo())); + list.add(new Pair(e, fullVisitCache.get(graph.getNode(e.getTo())))); + } else { +// assert fullVisitCache.containsKey(graph.getNode(e.getTo())); + List curPath = new ArrayList(path); + curPath.add(e); + list.add(new Pair(e, cyclicVisit(visitor, graph.getNode(e.getTo()), curPath))); + } + } + + Element e = visit(visitor, current, pathMap.get(current), list); + fullVisitCache.put(current, e); + } + + for(InputNode node : rootNodes) { + text.addChild(fullVisitCache.get(node)); + } + + return text; + } +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/Bundle.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,1 @@ +OpenIDE-Module-Name=GraphToText diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/AbstractGraphToTextVisitor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/AbstractGraphToTextVisitor.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.graphtotext.services; + +import com.sun.hotspot.igv.data.InputEdge; +import com.sun.hotspot.igv.data.InputNode; +import com.sun.hotspot.igv.data.Pair; +import com.sun.hotspot.igv.structuredtext.Element; +import com.sun.hotspot.igv.structuredtext.SimpleElement; +import java.util.List; + +/** + * + * @author Thomas + */ +public class AbstractGraphToTextVisitor implements GraphToTextVisitor { + + public Element cyclicVisit(InputNode node, List path) { + return SimpleElement.EMPTY; + } + + public Element visit(InputNode node, List path, List> children) { + return cyclicVisit(node, path); + } + +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/GraphToTextConverter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/GraphToTextConverter.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.graphtotext.services; + +import com.sun.hotspot.igv.data.InputGraph; +import com.sun.hotspot.igv.graph.Diagram; +import com.sun.hotspot.igv.structuredtext.StructuredText; + +/** + * + * @author Thomas Wuerthinger + */ +public interface GraphToTextConverter { + StructuredText convert(InputGraph graph, Diagram diagram); + boolean canConvert(InputGraph graph); +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/GraphToTextVisitor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/GraphToTextVisitor.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.graphtotext.services; + +import com.sun.hotspot.igv.data.InputEdge; +import com.sun.hotspot.igv.data.InputNode; +import com.sun.hotspot.igv.data.Pair; +import com.sun.hotspot.igv.structuredtext.Element; +import java.util.List; + +/** + * + * @author Thomas + */ +public interface GraphToTextVisitor { + + Element cyclicVisit(InputNode node, List path); + Element visit(InputNode node, List path, List> children); +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterNode.java --- a/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterNode.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterNode.java Wed Jun 08 15:36:30 2011 +0200 @@ -93,7 +93,7 @@ outputSlot = new Port() { public Point getRelativePosition() { - return new Point(size.width / 2, size.height); + return new Point(size.width / 2, 0);//size.height); } public Vertex getVertex() { @@ -183,7 +183,7 @@ for (Link e : subEdges) { List arr = e.getControlPoints(); - ArrayList newArr = new ArrayList(); + ArrayList newArr = new ArrayList(arr.size()); for (Point p : arr) { if (p != null) { Point p2 = new Point(p); diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterOutputSlotNode.java --- a/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterOutputSlotNode.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/ClusterOutputSlotNode.java Wed Jun 08 15:36:30 2011 +0200 @@ -88,7 +88,7 @@ public Point getRelativePosition() { Point p = new Point(thisNode.getPosition()); p.x += ClusterNode.BORDER; - p.y = thisBlockNode.getSize().height; + p.y = 0;//thisBlockNode.getSize().height; return p; } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalClusterLayoutManager.java --- a/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalClusterLayoutManager.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalClusterLayoutManager.java Wed Jun 08 15:36:30 2011 +0200 @@ -116,7 +116,7 @@ for (Vertex v : graph.getVertices()) { Cluster c = v.getCluster(); - assert c != null; + assert c != null : "Cluster of vertex " + v + " is null!"; clusterNodes.get(c).addSubNode(v); } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalLayoutManager.java --- a/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalLayoutManager.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/HierarchicalLayoutManager.java Wed Jun 08 15:36:30 2011 +0200 @@ -101,11 +101,13 @@ public int yOffset; public int bottomYOffset; public Vertex vertex; // Only used for non-dummy nodes, otherwise null + public List preds = new ArrayList(); public List succs = new ArrayList(); public HashMap outOffsets = new HashMap(); public HashMap inOffsets = new HashMap(); public int pos = -1; // Position within layer + public int crossingNumber; @Override @@ -276,10 +278,10 @@ if (e.link != null) { ArrayList points = new ArrayList(); - Point p = new Point(e.to.x + e.relativeTo, e.to.y + e.to.yOffset); + Point p = new Point(e.to.x + e.relativeTo, e.to.y + e.to.yOffset + e.link.getTo().getRelativePosition().y); points.add(p); if (e.to.inOffsets.containsKey(e.relativeTo)) { - points.add(new Point(p.x, p.y + e.to.inOffsets.get(e.relativeTo))); + points.add(new Point(p.x, p.y + e.to.inOffsets.get(e.relativeTo) + e.link.getTo().getRelativePosition().y)); } LayoutNode cur = e.from; @@ -299,9 +301,9 @@ cur = curEdge.from; } - p = new Point(cur.x + curEdge.relativeFrom, cur.y + cur.height - cur.bottomYOffset); + p = new Point(cur.x + curEdge.relativeFrom, cur.y + cur.height - cur.bottomYOffset + (curEdge.link == null ? 0 : curEdge.link.getFrom().getRelativePosition().y)); if (curEdge.from.outOffsets.containsKey(curEdge.relativeFrom)) { - points.add(new Point(p.x, p.y + curEdge.from.outOffsets.get(curEdge.relativeFrom))); + points.add(new Point(p.x, p.y + curEdge.from.outOffsets.get(curEdge.relativeFrom) + (curEdge.link == null ? 0 : curEdge.link.getFrom().getRelativePosition().y))); } points.add(p); @@ -360,10 +362,10 @@ for (LayoutEdge e : n.succs) { if (e.link != null) { ArrayList points = new ArrayList(); - Point p = new Point(e.from.x + e.relativeFrom, e.from.y + e.from.height - e.from.bottomYOffset); + Point p = new Point(e.from.x + e.relativeFrom, e.from.y + e.from.height - e.from.bottomYOffset + e.link.getFrom().getRelativePosition().y); points.add(p); if (e.from.outOffsets.containsKey(e.relativeFrom)) { - points.add(new Point(p.x, p.y + e.from.outOffsets.get(e.relativeFrom))); + points.add(new Point(p.x, p.y + e.from.outOffsets.get(e.relativeFrom) + e.link.getFrom().getRelativePosition().y)); } LayoutNode cur = e.to; @@ -387,10 +389,10 @@ } - p = new Point(cur.x + curEdge.relativeTo, cur.y + cur.yOffset); + p = new Point(cur.x + curEdge.relativeTo, cur.y + cur.yOffset + ((curEdge.link == null) ? 0 : curEdge.link.getTo().getRelativePosition().y)); points.add(p); if (curEdge.to.inOffsets.containsKey(curEdge.relativeTo)) { - points.add(new Point(p.x, p.y + curEdge.to.inOffsets.get(curEdge.relativeTo))); + points.add(new Point(p.x, p.y + curEdge.to.inOffsets.get(curEdge.relativeTo) + ((curEdge.link == null) ? 0 : curEdge.link.getTo().getRelativePosition().y))); } @@ -643,6 +645,7 @@ result += cur; } return result / size; //median(values); + } } @@ -1112,7 +1115,6 @@ layers[i] = new ArrayList(); } - // Generate initial ordering HashSet visited = new HashSet(); for (LayoutNode n : nodes) { @@ -1146,10 +1148,6 @@ downSweep(); upSweep(); } - - /*for(int i=0; i= layerCount) { - index = 2*layerCount - i - 1; - } - for(LayoutNode n : layers[index]) { - float sum = 0.0f; - for(LayoutEdge e : n.preds) { - float cur = e.from.pos; - if(e.from.width != 0 && e.relativeFrom != 0) { - cur += (float)e.relativeFrom / (float)(e.from.width); - } - sum += cur; - } - for(LayoutEdge e : n.succs) { - float cur = e.to.pos; - if(e.to.width != 0 && e.relativeTo != 0) { - cur += (float)e.relativeTo / (float)(e.to.width); - } - sum += cur; - } - if(n.preds.size() + n.succs.size() > 0) { - sum /= n.preds.size() + n.succs.size(); - n.crossingNumber = sum; - } - } - Collections.sort(layers[index], crossingNodeComparator); - updateXOfLayer(index); - int z = 0; - for(LayoutNode n : layers[index]) { - n.pos = z; - z++; - } - } - }*/ private void upSweep() { // Upsweep @@ -1303,7 +1263,7 @@ int sum = 0; for (LayoutEdge e : n.succs) { int cur = e.to.x + e.relativeTo;//pos; - /* + /* if(e.to.width != 0 && e.relativeTo != 0) { cur += (float)e.relativeTo / (float)(e.to.width); }*/ @@ -1331,11 +1291,6 @@ } } - private int evaluate() { - // TODO: Implement efficient evaluate / crossing min - return 0; - } - @Override public void postCheck() { @@ -1355,7 +1310,7 @@ protected void run() { int curY = 0; - //maxLayerHeight = new int[layers.length]; + for (int i = 0; i < layers.length; i++) { int maxHeight = 0; int baseLine = 0; @@ -1383,8 +1338,6 @@ } } - //maxLayerHeight[i] = maxHeight + baseLine + bottomBaseLine; - curY += maxHeight + baseLine + bottomBaseLine; curY += layerOffset + (int) Math.sqrt(maxXOffset); } @@ -1649,10 +1602,14 @@ } protected void run() { + + List insertOrder = new ArrayList(); + HashSet set = new HashSet(); for (LayoutNode n : nodes) { if (n.preds.size() == 0) { set.add(n); + insertOrder.add(n); n.layer = 0; } } @@ -1691,6 +1648,7 @@ for (LayoutNode n : newSet) { n.layer = z; + insertOrder.add(n); } // Swap sets @@ -1700,7 +1658,7 @@ z += minLayerDifference; } - optimize(set); + optimize(insertOrder); layerCount = z - minLayerDifference; @@ -1714,23 +1672,22 @@ for (Vertex v : firstLayerHint) { LayoutNode n = vertexToLayoutNode.get(v); assert n.preds.size() == 0; + n.layer = 0; assert n.layer == 0; } } - public void optimize(HashSet set) { - - for (LayoutNode n : set) { - if (n.preds.size() == 0 && n.succs.size() > 0) { - int minLayer = n.succs.get(0).to.layer; - for (LayoutEdge e : n.succs) { + public void optimize(List insertOrder) { + for (int i = insertOrder.size() - 1; i >= 0; i--) { + LayoutNode cur = insertOrder.get(i); + if (cur.succs.size() > cur.preds.size()) { + int minLayer = cur.succs.get(0).to.layer; + for (LayoutEdge e : cur.succs) { minLayer = Math.min(minLayer, e.to.layer); } - - n.layer = minLayer - 1; + cur.layer = minLayer - 1; } } - } @Override @@ -1752,7 +1709,7 @@ protected void run() { - // Remove self-edges, TODO: Special treatment + // Remove self-edges for (LayoutNode node : nodes) { ArrayList succs = new ArrayList(node.succs); for (LayoutEdge e : succs) { @@ -2105,6 +2062,6 @@ } public void doRouting(LayoutGraph graph) { - // Do nothing for now + // Do nothing for now } } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/OldHierarchicalLayoutManager.java --- a/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/OldHierarchicalLayoutManager.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/HierarchicalLayout/src/com/sun/hotspot/igv/hierarchicallayout/OldHierarchicalLayoutManager.java Wed Jun 08 15:36:30 2011 +0200 @@ -754,7 +754,6 @@ private void assignCoordinates(ArrayList> layers[]) { - // TODO: change this for (int i = 0; i < layers.length; i++) { ArrayList> curArray = layers[i]; int curY = 0; diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/build.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,8 @@ + + + + + + Builds, tests, and runs the project com.sun.hotspot.igv.java6scriptingproxy. + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/manifest.mf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/manifest.mf Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +OpenIDE-Module: com.sun.hotspot.igv.java6scriptingproxy +OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/java6scriptingproxy/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/build-impl.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/build-impl.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,45 @@ + + + + + + + + + + + + + You must set 'suite.dir' to point to your containing module suite + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/genfiles.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/genfiles.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,5 @@ +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=485d21b4 +nbproject/build-impl.xml.script.CRC32=341e7d1e +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45.1 diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/project.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,2 @@ +javac.source=1.5 +javac.compilerargs=-Xlint -Xlint:-serial diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/project.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,31 @@ + + + org.netbeans.modules.apisupport.project + + + com.sun.hotspot.igv.java6scriptingproxy + + + + com.sun.hotspot.igv.filter + + + + 1.0 + + + + com.sun.hotspot.igv.graph + + + + 1.0 + + + + + com.sun.hotspot.igv.java6scriptingproxy + + + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/suite.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/nbproject/suite.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,1 @@ +suite.dir=${basedir}/.. diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,1 @@ +com.sun.hotspot.igv.java6scriptingproxy.JavaSE6ScriptEngine \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/com/sun/hotspot/igv/java6scriptingproxy/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/com/sun/hotspot/igv/java6scriptingproxy/Bundle.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,1 @@ +OpenIDE-Module-Name=Java6ScriptingProxy diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/com/sun/hotspot/igv/java6scriptingproxy/JavaSE6ScriptEngine.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/com/sun/hotspot/igv/java6scriptingproxy/JavaSE6ScriptEngine.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,93 @@ +/* + * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.hotspot.igv.java6scriptingproxy; + +import com.sun.hotspot.igv.filter.*; +import com.sun.hotspot.igv.graph.Diagram; +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +/** + * + * @author Thomas Wuerthinger + */ +public class JavaSE6ScriptEngine implements ScriptEngineAbstraction { + + private Object engine; + private Object bindings; + private Method Bindings_put; + private Method ScriptEngine_eval; + + public boolean initialize(String jsHelperText) { + try { + + ClassLoader cl = JavaSE6ScriptEngine.class.getClassLoader(); + Class managerClass = cl.loadClass("javax.script.ScriptEngineManager"); + Class engineClass = cl.loadClass("javax.script.ScriptEngine"); + Class bindingsClass = cl.loadClass("javax.script.Bindings"); + Class contextClass = cl.loadClass("javax.script.ScriptContext"); + + Object manager = managerClass.newInstance(); + Method getEngineByName = managerClass.getMethod("getEngineByName", String.class); + engine = getEngineByName.invoke(manager, "ECMAScript"); + Method eval = engineClass.getMethod("eval", String.class); + ScriptEngine_eval = engineClass.getMethod("eval", String.class, bindingsClass); + eval.invoke(engine, jsHelperText); + Method getContext = engineClass.getMethod("getContext"); + Object context = getContext.invoke(engine); + Method getBindings = contextClass.getMethod("getBindings", Integer.TYPE); + Field f = contextClass.getField("ENGINE_SCOPE"); + bindings = getBindings.invoke(context, f.getInt(null)); + Bindings_put = bindingsClass.getMethod("put", String.class, Object.class); + Bindings_put.invoke(bindings, "IO", System.out); + + /* + * Non-reflective code: + ScriptEngineManager sem = new ScriptEngineManager(); + ScriptEngine e = sem.getEngineByName("ECMAScript"); + engine = e; + e.eval(jsHelperText); + Bindings b = e.getContext().getBindings(ScriptContext.ENGINE_SCOPE); + b.put("IO", System.out); + bindings = b; + */ + + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + public void execute(Diagram d, String code) { + try { + Bindings_put.invoke(bindings, "graph", d); + ScriptEngine_eval.invoke(engine, code, bindings); + } catch (Exception ex) { + ex.printStackTrace(); + } + } +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Cluster.java --- a/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Cluster.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/Cluster.java Wed Jun 08 15:36:30 2011 +0200 @@ -37,6 +37,4 @@ public void setBounds(Rectangle r); public Set getSuccessors(); - - public Set getPredecessors(); } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/LayoutGraph.java --- a/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/LayoutGraph.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Layout/src/com/sun/hotspot/igv/layout/LayoutGraph.java Wed Jun 08 15:36:30 2011 +0200 @@ -50,9 +50,9 @@ assert verify(); vertices = new TreeSet(); - portLinks = new HashMap>(); - inputPorts = new HashMap>(); - outputPorts = new HashMap>(); + portLinks = new HashMap>(links.size()); + inputPorts = new HashMap>(links.size()); + outputPorts = new HashMap>(links.size()); for (Link l : links) { Port p = l.getFrom(); @@ -148,7 +148,7 @@ // Returns a set of vertices with the following properties: // - All Vertices in the set startingRoots are elements of the set. - // - When starting a DFS at every vertex in the set, every vertex of the + // - When starting a DFS at every vertex in the set, every vertex of the // whole graph is visited. public Set findRootVertices(Set startingRoots) { diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Maxine/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Maxine/build.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,8 @@ + + + + + + Builds, tests, and runs the project com.sun.hotspot.igv.maxine. + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Maxine/manifest.mf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Maxine/manifest.mf Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +OpenIDE-Module: com.sun.hotspot.igv.maxine +OpenIDE-Module-Layer: com/sun/hotspot/igv/maxine/layer.xml +OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/maxine/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Maxine/nbproject/build-impl.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Maxine/nbproject/build-impl.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,45 @@ + + + + + + + + + + + + + You must set 'suite.dir' to point to your containing module suite + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Maxine/nbproject/genfiles.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Maxine/nbproject/genfiles.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,5 @@ +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=44af392c +nbproject/build-impl.xml.script.CRC32=1a1fcc4d +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45.1 diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Maxine/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Maxine/nbproject/project.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,2 @@ +javac.source=1.5 +javac.compilerargs=-Xlint -Xlint:-serial diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Maxine/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Maxine/nbproject/project.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,45 @@ + + + org.netbeans.modules.apisupport.project + + + com.sun.hotspot.igv.maxine + + + + com.sun.hotspot.igv.data + + + + 1.0 + + + + com.sun.hotspot.igv.graph + + + + 1.0 + + + + com.sun.hotspot.igv.graphtotext + + + + 1.0 + + + + com.sun.hotspot.igv.structuredtext + + + + 1.0 + + + + + + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Maxine/nbproject/suite.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Maxine/nbproject/suite.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,1 @@ +suite.dir=${basedir}/.. diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Maxine/src/META-INF/services/com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Maxine/src/META-INF/services/com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,1 @@ +com.sun.hotspot.igv.maxine.CirGraphToTextConverter \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/Bundle.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,1 @@ +OpenIDE-Module-Name=Maxine diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/CirGraphToTextConverter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/CirGraphToTextConverter.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,229 @@ +/* + * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.hotspot.igv.maxine; + +import com.sun.hotspot.igv.data.InputEdge; +import com.sun.hotspot.igv.data.InputGraph; +import com.sun.hotspot.igv.data.InputNode; +import com.sun.hotspot.igv.data.Pair; +import com.sun.hotspot.igv.data.Properties; +import com.sun.hotspot.igv.data.Properties.PropertyMatcher; +import com.sun.hotspot.igv.data.Properties.RegexpPropertyMatcher; +import com.sun.hotspot.igv.data.Properties.StringPropertyMatcher; +import com.sun.hotspot.igv.graph.Diagram; +import com.sun.hotspot.igv.graph.Figure; +import com.sun.hotspot.igv.graphtotext.BFSGraphToTextConverter; +import com.sun.hotspot.igv.graphtotext.services.AbstractGraphToTextVisitor; +import com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter; +import com.sun.hotspot.igv.graphtotext.services.GraphToTextVisitor; +import com.sun.hotspot.igv.structuredtext.Element; +import com.sun.hotspot.igv.structuredtext.MultiElement; +import com.sun.hotspot.igv.structuredtext.SimpleElement; +import com.sun.hotspot.igv.structuredtext.StructuredText; +import java.awt.Color; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.swing.text.Style; +import javax.swing.text.StyleConstants; +import javax.swing.text.StyleContext; + +/** + * + * @author Thomas Wuerthinger + */ +public class CirGraphToTextConverter implements GraphToTextConverter { + + private static final String CALL_OPERATOR = " \u2022 "; + + private Map> map; + private InputGraph graph; + + public StructuredText convert(InputGraph graph, Diagram diagram) { + map = diagram.calcSourceToFigureRelation(); + this.graph = graph; + + BFSGraphToTextConverter converter = new BFSGraphToTextConverter(nodeVisitor); + converter.registerVisitor(localVariableVisitor, new StringPropertyMatcher("type", "LocalVariable")); + converter.registerVisitor(parameterVisitor, new StringPropertyMatcher("type", "Parameter")); + converter.registerVisitor(closureVisitor, new RegexpPropertyMatcher("type", "Closure")); + converter.registerVisitor(continuationVisitor, new RegexpPropertyMatcher("type", "Continuation")); + converter.registerVisitor(callVisitor, new RegexpPropertyMatcher("type", "Call")); + converter.registerVisitor(blockVisitor, new RegexpPropertyMatcher("type", "Block")); + return converter.convert(graph, diagram); + } + private GraphToTextVisitor nodeVisitor = new NodeVisitor(); + private GraphToTextVisitor localVariableVisitor = new NodeVisitor(); + private GraphToTextVisitor parameterVisitor = new NodeVisitor(); + private GraphToTextVisitor closureVisitor = new ClosureVisitor("proc"); + private GraphToTextVisitor continuationVisitor = new ClosureVisitor("cont"); + private GraphToTextVisitor callVisitor = new CallVisitor(); + private GraphToTextVisitor blockVisitor = new BlockVisitor(); + + private void printOffset(List path, MultiElement elem) { + for (int i = 0; i < path.size(); i++) { + InputEdge cur = path.get(i); + InputNode fromNode = graph.getNode(cur.getFrom()); + SimpleElement simpleElem = new SimpleElement(" ", calcStyle(fromNode)); + simpleElem.addSource(fromNode.getId()); + elem.addChild(simpleElem); + } + } + + private class NodeVisitor extends AbstractGraphToTextVisitor { + + @Override + public Element cyclicVisit(InputNode node, List path) { + SimpleElement elem = new SimpleElement(node.getProperties().get("name"), calcStyle(node)); + elem.addSource(node.getId()); + return elem; + } + } + + private Color calcColor(InputNode node) { + Set
figureSet = this.map.get(node); + if(figureSet != null && figureSet.size() == 1) { + return figureSet.iterator().next().getColor(); + } else { + return Color.WHITE; + } + } + + private Style calcStyle(InputNode node) { + Color c = calcColor(node); + Style defaultStyle = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); + Style newStyle = StyleContext.getDefaultStyleContext().addStyle(null, defaultStyle); + + StyleConstants.setBackground(newStyle, c); + return newStyle; + } + + private class ClosureVisitor extends AbstractGraphToTextVisitor { + + private String label; + + protected String getLabel(InputNode node) { + return label; + } + + public ClosureVisitor(String label) { + this.label = label; + } + + @Override + public Element cyclicVisit(InputNode node, List path) { + return SimpleElement.EMPTY; + } + + @Override + public Element visit(InputNode node, List path, List> children) { + MultiElement e = new MultiElement(calcStyle(node)); + e.print("{", node.getId()); + e.print(getLabel(node), node.getId()); + + e.print("[", node.getId()); + for (int i = 0; i < children.size() - 1; i++) { + Pair p = children.get(i); + e.addChild(p.getRight()); + if (i != children.size() - 2) { + e.print("|", node.getId()); + } + } + e.print("]", node.getId()); + e.print(CALL_OPERATOR, node.getId()); + e.println(); + List newPath = new ArrayList(path); + newPath.add(children.get(children.size() - 1).getLeft()); + printOffset(newPath, e); + + MultiElement childElement = new MultiElement("..."); + childElement.addChild(children.get(children.size() - 1).getRight()); + e.addChild(childElement); + + e.println(); + printOffset(path, e); + e.print("}", node.getId()); + MultiElement resElem = new MultiElement(); + resElem.addChild(e); + return resElem; + } + } + + private class CallVisitor extends AbstractGraphToTextVisitor { + + @Override + public Element cyclicVisit(InputNode node, List path) { + return SimpleElement.EMPTY; + } + + @Override + public Element visit(InputNode node, List path, List> children) { + MultiElement e = new MultiElement(calcStyle(node)); + e.print("(", node.getId()); + for (int i = 0; i < children.size(); i++) { + Pair p = children.get(i); + e.addChild(p.getRight()); + if (i != children.size() - 1) { + e.print("|", node.getId()); + } + } + e.print(")", node.getId()); + MultiElement resElem = new MultiElement(); + resElem.addChild(e); + return resElem; + } + } + + private class BlockVisitor extends ClosureVisitor { + + public BlockVisitor() { + super("block"); + } + + @Override + protected String getLabel(InputNode node) { + return node.getProperties().get("name"); + } + + @Override + public Element cyclicVisit(InputNode node, List path) { + MultiElement e = new MultiElement(calcStyle(node)); + e.print(getLabel(node), node); + return e; + } + + @Override + public Element visit(InputNode node, List path, List> children) { + return super.visit(node, path, children); + } + } + + private static final PropertyMatcher MATCHER = new Properties.RegexpPropertyMatcher("type", ".*CIR.*"); + public boolean canConvert(InputGraph graph) { + return graph.getGroup().getProperties().selectSingle(MATCHER) != null; + } +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/filters/color.filter --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/filters/color.filter Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,9 @@ +colorize("name", ".*", white); +colorize("name", "cont",new java.awt.Color(1.0, 0.8, 0.8)); +colorize("name", "proc", new java.awt.Color(0.8, 0.8, 1.0)); +colorize("name", "call", new java.awt.Color(0.9, 0.9, 0.9)); +colorize("name", "block", new java.awt.Color(1.0, 1.0, 0.6)); +colorize("class", ".*Constant", new java.awt.Color(0.7, 1.0, 0.9)); +colorize("class", ".*Parameter", new java.awt.Color(0.9, 1.0, 0.7)); +colorize("class", ".*Variable", new java.awt.Color(0.7, 1.0, 0.7)); +colorize("class", ".*cir\.snippet.*", yellow); \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/filters/structural.filter --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/filters/structural.filter Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,7 @@ +split("class", ".*Constant"); +split("class", ".*Variable"); +split("class", ".*Parameter"); +split("class", ".*Snippet"); +split("class", ".*Switch"); +split("class", ".*cir\.snippet.*"); +split("class", ".*cir\.builtin.*"); \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/layer.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Maxine/src/com/sun/hotspot/igv/maxine/layer.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/genfiles.properties --- a/src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/genfiles.properties Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/NetworkConnection/nbproject/genfiles.properties Wed Jun 08 15:36:30 2011 +0200 @@ -1,6 +1,3 @@ -build.xml.data.CRC32=5a0e591e -build.xml.script.CRC32=a265137e -build.xml.stylesheet.CRC32=a56c6a5b@1.45.1 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=5a0e591e diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/build-impl.xml --- a/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/build-impl.xml Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/build-impl.xml Wed Jun 08 15:36:30 2011 +0200 @@ -4,6 +4,13 @@ *** EDIT ../build.xml INSTEAD *** --> + + + + + + + You must set 'suite.dir' to point to your containing module suite @@ -16,13 +23,21 @@ + + + + + + + - - + + + - + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/genfiles.properties --- a/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/genfiles.properties Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/nbproject/genfiles.properties Wed Jun 08 15:36:30 2011 +0200 @@ -1,8 +1,5 @@ -build.xml.data.CRC32=0c3e7912 -build.xml.script.CRC32=44d0050c -build.xml.stylesheet.CRC32=79c3b980 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=0c3e7912 -nbproject/build-impl.xml.script.CRC32=7aab3f52 -nbproject/build-impl.xml.stylesheet.CRC32=deb65f65 +nbproject/build-impl.xml.script.CRC32=87376d18 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45.1 diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/RhinoScriptEngine.java --- a/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/RhinoScriptEngine.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/RhinoScriptEngine.java Wed Jun 08 15:36:30 2011 +0200 @@ -52,14 +52,12 @@ Class scriptable = cl.loadClass("org.mozilla.javascript.Scriptable"); importerTopLevel = cl.loadClass("org.mozilla.javascript.ImporterTopLevel"); importer = importerTopLevel.getDeclaredConstructor(context); - scope_put = importerTopLevel.getMethod("put", new Class[]{String.class, scriptable, Object.class}); - cx_evaluateString = context.getDeclaredMethod("evaluateString", new Class[]{scriptable, String.class, String.class, Integer.TYPE, Object.class}); - context_enter = context.getDeclaredMethod("enter", new Class[0]); - context_exit = context.getDeclaredMethod("exit", new Class[0]); + scope_put = importerTopLevel.getMethod("put", String.class, scriptable, Object.class); + cx_evaluateString = context.getDeclaredMethod("evaluateString", scriptable, String.class, String.class, Integer.TYPE, Object.class); + context_enter = context.getDeclaredMethod("enter"); + context_exit = context.getDeclaredMethod("exit"); return true; - } catch (NoSuchMethodException nsme) { - return false; - } catch (ClassNotFoundException cnfe) { + } catch (Exception e) { return false; } } @@ -77,9 +75,8 @@ // Exit from the context. context_exit.invoke(null, (Object[]) null); } - } catch (InvocationTargetException iae) { - } catch (IllegalAccessException iae) { - } catch (InstantiationException iae) { + } catch (Exception e) { + e.printStackTrace(); } } } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/SelectionCoordinator/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/build.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,8 @@ + + + + + + Builds, tests, and runs the project com.sun.hotspot.igv.selectioncoordinator. + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/SelectionCoordinator/manifest.mf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/manifest.mf Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +OpenIDE-Module: com.sun.hotspot.igv.selectioncoordinator +OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/selectioncoordinator/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/build-impl.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/build-impl.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,45 @@ + + + + + + + + + + + + + You must set 'suite.dir' to point to your containing module suite + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/genfiles.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/genfiles.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,5 @@ +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=13553862 +nbproject/build-impl.xml.script.CRC32=3db87c68 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45.1 diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/platform.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/platform.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,129 @@ +# Deprecated since 5.0u1; for compatibility with 5.0: +disabled.clusters=\ + apisupport1,\ + gsf1,\ + harness,\ + java2,\ + nb6.1,\ + profiler3 +disabled.modules=\ + org.apache.xml.resolver,\ + org.netbeans.api.debugger,\ + org.netbeans.api.xml,\ + org.netbeans.core.execution,\ + org.netbeans.core.ide,\ + org.netbeans.core.multiview,\ + org.netbeans.core.nativeaccess,\ + org.netbeans.core.output2,\ + org.netbeans.insane,\ + org.netbeans.lib.cvsclient,\ + org.netbeans.libs.commons_logging,\ + org.netbeans.libs.freemarker,\ + org.netbeans.libs.ini4j,\ + org.netbeans.libs.jna,\ + org.netbeans.libs.jsch,\ + org.netbeans.libs.jsr223,\ + org.netbeans.libs.lucene,\ + org.netbeans.libs.svnClientAdapter,\ + org.netbeans.libs.xerces,\ + org.netbeans.modules.applemenu,\ + org.netbeans.modules.autoupdate.services,\ + org.netbeans.modules.autoupdate.ui,\ + org.netbeans.modules.classfile,\ + org.netbeans.modules.core.kit,\ + org.netbeans.modules.db,\ + org.netbeans.modules.db.core,\ + org.netbeans.modules.db.drivers,\ + org.netbeans.modules.db.kit,\ + org.netbeans.modules.db.mysql,\ + org.netbeans.modules.db.sql.editor,\ + org.netbeans.modules.db.sql.visualeditor,\ + org.netbeans.modules.dbapi,\ + org.netbeans.modules.defaults,\ + org.netbeans.modules.diff,\ + org.netbeans.modules.editor.bookmarks,\ + org.netbeans.modules.editor.bracesmatching,\ + org.netbeans.modules.editor.codetemplates,\ + org.netbeans.modules.editor.completion,\ + org.netbeans.modules.editor.errorstripe,\ + org.netbeans.modules.editor.errorstripe.api,\ + org.netbeans.modules.editor.guards,\ + org.netbeans.modules.editor.highlights,\ + org.netbeans.modules.editor.macros,\ + org.netbeans.modules.editor.plain,\ + org.netbeans.modules.editor.plain.lib,\ + org.netbeans.modules.editor.structure,\ + org.netbeans.modules.extbrowser,\ + org.netbeans.modules.favorites,\ + org.netbeans.modules.gototest,\ + org.netbeans.modules.httpserver,\ + org.netbeans.modules.ide.kit,\ + org.netbeans.modules.image,\ + org.netbeans.modules.javahelp,\ + org.netbeans.modules.jumpto,\ + org.netbeans.modules.languages,\ + org.netbeans.modules.languages.bat,\ + org.netbeans.modules.languages.diff,\ + org.netbeans.modules.languages.manifest,\ + org.netbeans.modules.languages.sh,\ + org.netbeans.modules.lexer.editorbridge,\ + org.netbeans.modules.lexer.nbbridge,\ + org.netbeans.modules.localhistory,\ + org.netbeans.modules.masterfs,\ + org.netbeans.modules.mercurial,\ + org.netbeans.modules.progress.ui,\ + org.netbeans.modules.project.ant,\ + org.netbeans.modules.project.libraries,\ + org.netbeans.modules.projectui,\ + org.netbeans.modules.projectuiapi,\ + org.netbeans.modules.properties,\ + org.netbeans.modules.properties.syntax,\ + org.netbeans.modules.refactoring.api,\ + org.netbeans.modules.schema2beans,\ + org.netbeans.modules.sendopts,\ + org.netbeans.modules.server,\ + org.netbeans.modules.servletapi,\ + org.netbeans.modules.subversion,\ + org.netbeans.modules.tasklist.kit,\ + org.netbeans.modules.tasklist.projectint,\ + org.netbeans.modules.tasklist.todo,\ + org.netbeans.modules.tasklist.ui,\ + org.netbeans.modules.templates,\ + org.netbeans.modules.timers,\ + org.netbeans.modules.usersguide,\ + org.netbeans.modules.utilities,\ + org.netbeans.modules.utilities.project,\ + org.netbeans.modules.versioning,\ + org.netbeans.modules.versioning.system.cvss,\ + org.netbeans.modules.versioning.util,\ + org.netbeans.modules.web.flyingsaucer,\ + org.netbeans.modules.xml,\ + org.netbeans.modules.xml.axi,\ + org.netbeans.modules.xml.catalog,\ + org.netbeans.modules.xml.core,\ + org.netbeans.modules.xml.lexer,\ + org.netbeans.modules.xml.multiview,\ + org.netbeans.modules.xml.retriever,\ + org.netbeans.modules.xml.schema.completion,\ + org.netbeans.modules.xml.schema.model,\ + org.netbeans.modules.xml.tax,\ + org.netbeans.modules.xml.text,\ + org.netbeans.modules.xml.tools,\ + org.netbeans.modules.xml.wsdl.model,\ + org.netbeans.modules.xml.xam,\ + org.netbeans.modules.xml.xdm,\ + org.netbeans.modules.xsl,\ + org.netbeans.spi.debugger.ui,\ + org.netbeans.spi.editor.hints,\ + org.netbeans.spi.navigator,\ + org.netbeans.spi.palette,\ + org.netbeans.spi.tasklist,\ + org.netbeans.spi.viewmodel,\ + org.netbeans.swing.dirchooser,\ + org.openide.compat,\ + org.openide.util.enumerations +enabled.clusters=\ + ide9,\ + platform8 +nbjdk.active=default +nbplatform.active=default diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/project.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,2 @@ +javac.source=1.5 +javac.compilerargs=-Xlint -Xlint:-serial diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/project.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,23 @@ + + + org.netbeans.modules.apisupport.project + + + com.sun.hotspot.igv.selectioncoordinator + + + + com.sun.hotspot.igv.data + + + + 1.0 + + + + + com.sun.hotspot.igv.selectioncoordinator + + + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/suite.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/nbproject/suite.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,1 @@ +suite.dir=${basedir}/.. diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/SelectionCoordinator/src/com/sun/hotspot/igv/selectioncoordinator/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/src/com/sun/hotspot/igv/selectioncoordinator/Bundle.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,1 @@ +OpenIDE-Module-Name=SelectionCoordinator diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/SelectionCoordinator/src/com/sun/hotspot/igv/selectioncoordinator/SelectionCoordinator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/SelectionCoordinator/src/com/sun/hotspot/igv/selectioncoordinator/SelectionCoordinator.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.selectioncoordinator; + +import com.sun.hotspot.igv.data.ChangedEvent; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; + +/** + * + * @author Thomas + */ +public class SelectionCoordinator { + + private static SelectionCoordinator singleInstance = new SelectionCoordinator(); + private Set selectedObjects; + private Set highlightedObjects; + private ChangedEvent selectedChangedEvent; + private ChangedEvent highlightedChangedEvent; + + public static SelectionCoordinator getInstance() { + return singleInstance; + } + + private SelectionCoordinator() { + selectedChangedEvent = new ChangedEvent(this); + highlightedChangedEvent = new ChangedEvent(this); + selectedObjects = new HashSet(); + highlightedObjects = new HashSet(); + } + + public Set getSelectedObjects() { + return Collections.unmodifiableSet(selectedObjects); + } + + public Set getHighlightedObjects() { + return Collections.unmodifiableSet(highlightedObjects); + } + + public ChangedEvent getHighlightedChangedEvent() { + return highlightedChangedEvent; + } + + public ChangedEvent getSelectedChangedEvent() { + return selectedChangedEvent; + } + + public void addHighlighted(Object o) { + if (!highlightedObjects.contains(o)) { + highlightedObjects.add(o); + highlightedObjectsChanged(); + } + } + + public void removeHighlighted(Object o) { + if (highlightedObjects.contains(o)) { + highlightedObjects.remove(o); + highlightedObjectsChanged(); + } + } + + public void addAllHighlighted(Set s) { + int oldSize = highlightedObjects.size(); + highlightedObjects.addAll(s); + if (oldSize != highlightedObjects.size()) { + highlightedObjectsChanged(); + } + } + + public void removeAllHighlighted(Set s) { + int oldSize = highlightedObjects.size(); + highlightedObjects.removeAll(s); + if (oldSize != highlightedObjects.size()) { + highlightedObjectsChanged(); + } + } + + private void highlightedObjectsChanged() { + highlightedChangedEvent.fire(); + + } + + public void addAllSelected(Set s) { + int oldSize = selectedObjects.size(); + selectedObjects.addAll(s); + if (oldSize != selectedObjects.size()) { + selectedObjectsChanged(); + } + } + + public void removeAllSelected(Set s) { + int oldSize = selectedObjects.size(); + selectedObjects.removeAll(s); + if (oldSize != selectedObjects.size()) { + selectedObjectsChanged(); + } + } + + public void setSelectedObjects(Set s) { + assert s != null; + selectedObjects.clear(); + selectedObjects.addAll(s); + selectedObjectsChanged(); + } + + private void selectedObjectsChanged() { + selectedChangedEvent.fire(); + } + + public void setHighlightedObjects(Set s) { + assert s != null; + this.highlightedObjects.clear(); + this.highlightedObjects.addAll(s); + highlightedObjectsChanged(); + } +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.xml --- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.xml Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/ServerCompiler/nbproject/project.xml Wed Jun 08 15:36:30 2011 +0200 @@ -14,6 +14,30 @@ 1.0 + + com.sun.hotspot.igv.graph + + + + 1.0 + + + + com.sun.hotspot.igv.graphtotext + + + + 1.0 + + + + com.sun.hotspot.igv.structuredtext + + + + 1.0 + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/META-INF/services/com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/META-INF/services/com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,1 @@ +com.sun.hotspot.igv.servercompiler.ServerCompilerGraphToTextConverter \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/JavaGroupOrganizer.java --- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/JavaGroupOrganizer.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/JavaGroupOrganizer.java Wed Jun 08 15:36:30 2011 +0200 @@ -68,7 +68,7 @@ } private void buildResult(List>> result, List groups, NameProvider provider) { - HashMap> map = new HashMap>(); + HashMap> map = new HashMap>(groups.size()); for (Group g : groups) { String s = provider.getName(g); @@ -113,7 +113,7 @@ } int current = firstPoint; - while (current > 0 && name.charAt(current) != ' ') { + while (current >= 0 && name.charAt(current) != ' ') { current--; } @@ -145,10 +145,10 @@ } int current = firstPoint; - while (current > 0 && name.charAt(current) != ' ') { + while (current >= 0 && name.charAt(current) != ' ') { current--; } - + String fullClassName = name.substring(current + 1, firstParenthese); int lastPoint = fullClassName.lastIndexOf("."); if (lastPoint == -1) { @@ -182,7 +182,7 @@ } int current = firstPoint; - while (current > 0 && name.charAt(current) != ' ') { + while (current >= 0 && name.charAt(current) != ' ') { current--; } diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerGraphToTextConverter.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerGraphToTextConverter.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,176 @@ +/* + * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package com.sun.hotspot.igv.servercompiler; + +import com.sun.hotspot.igv.data.InputBlock; +import com.sun.hotspot.igv.data.InputEdge; +import com.sun.hotspot.igv.data.InputGraph; +import com.sun.hotspot.igv.data.InputNode; +import com.sun.hotspot.igv.data.Properties; +import com.sun.hotspot.igv.data.Properties.PropertyMatcher; +import com.sun.hotspot.igv.data.Properties.PropertySelector; +import com.sun.hotspot.igv.graph.Diagram; +import com.sun.hotspot.igv.graph.Figure; +import com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter; +import com.sun.hotspot.igv.structuredtext.Element; +import com.sun.hotspot.igv.structuredtext.MultiElement; +import com.sun.hotspot.igv.structuredtext.SimpleElement; +import com.sun.hotspot.igv.structuredtext.StructuredText; +import java.awt.Color; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Set; +import javax.swing.text.Style; +import javax.swing.text.StyleConstants; +import javax.swing.text.StyleContext; + +/** + * + * @author Thomas Wuerthinger + */ +public class ServerCompilerGraphToTextConverter implements GraphToTextConverter { + + + private Map> map; + private Map> ingoingEdges; + private Map> outgoingEdges; + private InputGraph graph; + + private Collection sortNodes(Collection nodes) { + List result = new ArrayList(nodes); + + Collections.sort(result, InputNode.getPropertyComparator("idx")); + + + return result; + } + + public StructuredText convert(InputGraph graph, Diagram diagram) { + + this.graph = graph; + map = diagram.calcSourceToFigureRelation(); + ingoingEdges = graph.findAllIngoingEdges(); + outgoingEdges = graph.findAllOutgoingEdges(); + + final StructuredText result = new StructuredText(graph.getName()); + + for (InputBlock b : graph.getBlocks()) { + result.addChild(new SimpleElement("Block " + b.getName() + "\n")); + for (InputNode n : sortNodes(b.getNodes())) { + result.addChild(getNodeElement(n)); + } + } + + boolean first = true; + for (InputNode n : sortNodes(graph.getNodes())) { + if (graph.getBlock(n) == null) { + if (first) { + first = false; + result.addChild(new SimpleElement("No block: \n")); + } + result.addChild(getNodeElement(n)); + } + } + + + return result; + } + + private Element getNodeNameElement(InputNode n) { + + final SimpleElement name = new SimpleElement(n.getProperties().get("idx") + " " + n.getProperties().get("name"), calcStyle(n)); + name.addSource(n.getId()); + return name; + } + + private Element getNodeSmallElement(InputNode n) { + final SimpleElement id = new SimpleElement(n.getProperties().get("idx"), calcStyle(n)); + id.addSource(n.getId()); + return id; + } + + private Element getNodeElement(InputNode n) { + + final MultiElement result = new MultiElement(); + + result.print("\t"); + result.addChild(getNodeNameElement(n)); + + result.print(" === "); + + for (InputEdge e : outgoingEdges.get(n)) { + result.print(" "); + result.addChild(getNodeSmallElement(graph.getNode(e.getTo()))); + result.print(" "); + } + + result.print(" [["); + + for (InputEdge e : ingoingEdges.get(n)) { + result.print(" "); + result.addChild(getNodeSmallElement(graph.getNode(e.getFrom()))); + result.print(" "); + } + + result.print("]] "); + + result.print(n.getProperties().get("dump_spec")); + + result.print("\n"); + + return result; + } + + private static final PropertyMatcher MATCHER = new Properties.RegexpPropertyMatcher("name", "Root"); + public boolean canConvert(InputGraph graph) { + return new PropertySelector(graph.getNodes()).selectSingle(MATCHER) != null; + } + + private Color calcColor(InputNode node) { + Set
figureSet = this.map.get(node); + if(figureSet != null && figureSet.size() == 1) { + return figureSet.iterator().next().getColor(); + } else { + return Color.WHITE; + } + } + + private Color lessColor(Color c) { + return new Color(255 - (255 - c.getRed()) / 4, 255 - (255 - c.getGreen()) / 4, 255 - (255 - c.getBlue()) / 4); + } + + private Style calcStyle(InputNode node) { + Color c = calcColor(node); + Style defaultStyle = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); + Style newStyle = StyleContext.getDefaultStyleContext().addStyle(null, defaultStyle); + + StyleConstants.setBackground(newStyle, lessColor(c)); + return newStyle; + } +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java --- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java Wed Jun 08 15:36:30 2011 +0200 @@ -93,7 +93,7 @@ if (!visited.contains(parent)) { visited.add(parent); - InputBlock block = new InputBlock(graph, "" + blockCount); + InputBlock block = graph.addBlock(Integer.toString(blockCount)); blocks.add(block); if (parent == root) { rootBlock = block; @@ -125,7 +125,7 @@ n = n.preds.get(0); } if (n.block != null) { - n.block.addSuccessor(block); + graph.addBlockConnection(n.block, block); } } } @@ -136,12 +136,12 @@ for (Node n2 : n.succs) { if (n2 != parent && n2.block != null && n2.block != rootBlock) { - block.addSuccessor(n2.block); + graph.addBlockConnection(block, n2.block); } } } else { if (n != parent && n.block != null && n.block != rootBlock) { - block.addSuccessor(n.block); + graph.addBlockConnection(block, n.block); } } } @@ -161,7 +161,7 @@ } if (pushed == 0 && p == root) { - // TODO: special handling when root backedges are not built yet + // TODO: special handling when root backedges are not built yet } } } @@ -174,7 +174,7 @@ } int z = 0; - blockIndex = new HashMap(); + blockIndex = new HashMap(blocks.size()); for (InputBlock b : blocks) { blockIndex.put(b, z); z++; @@ -191,14 +191,14 @@ for (InputNode n : tmpNodes) { String block = getBlockName(n); if (graph.getBlock(n) == null) { - graph.getBlock(block).addNode(n); + graph.getBlock(block).addNode(n.getId()); assert graph.getBlock(n) != null; } } return graph.getBlocks(); } else { nodes = new ArrayList(); - inputNodeToNode = new HashMap(); + inputNodeToNode = new HashMap(graph.getNodes().size()); this.graph = graph; buildUpGraph(); @@ -207,7 +207,17 @@ buildCommonDominators(); scheduleLatest(); + + InputBlock noBlock = null; for (InputNode n : graph.getNodes()) { + if (graph.getBlock(n) == null) { + if (noBlock == null) { + noBlock = graph.addBlock("none"); + blocks.add(noBlock); + } + + graph.setBlock(n, noBlock); + } assert graph.getBlock(n) != null; } @@ -219,6 +229,10 @@ Node root = findRoot(); + if(root == null) { + assert false : "No root found!"; + return; + } // Mark all nodes reachable in backward traversal from root Set reachable = new HashSet(); @@ -374,12 +388,12 @@ } public void buildDominators() { - dominatorMap = new HashMap(); + dominatorMap = new HashMap(graph.getBlocks().size()); if (blocks.size() == 0) { return; } - Vector intermediate = new Vector(); - Map map = new HashMap(); + Vector intermediate = new Vector(graph.getBlocks().size()); + Map map = new HashMap(graph.getBlocks().size()); int z = 0; for (InputBlock b : blocks) { BlockIntermediate bi = new BlockIntermediate(); @@ -538,22 +552,21 @@ } private Node findRoot() { - Node node0 = null; + Node alternativeRoot = null; for (Node n : nodes) { InputNode inputNode = n.inputNode; - if(inputNode.getProperties().get("name") == null) { - System.out.println("NO name !! " + inputNode); + String s = inputNode.getProperties().get("name"); + if (s != null && s.equals("Root")) { + return n; } - if (inputNode != null && inputNode.getProperties().get("name") != null && inputNode.getProperties().get("name").equals("Root")) { - return n; - } else if (inputNode.getId() == 0) { - // use as fallback in case no root node is found - node0 = n; + + if (n.preds.size() == 0) { + alternativeRoot = n; } } - return node0; + return alternativeRoot; } public void buildUpGraph() { @@ -569,7 +582,7 @@ inputNodeToNode.put(n, node); } - Map> edgeMap = new HashMap>(); + Map> edgeMap = new HashMap>(graph.getEdges().size()); for (InputEdge e : graph.getEdges()) { int to = e.getTo(); diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/color.filter --- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/color.filter Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/color.filter Wed Jun 08 15:36:30 2011 +0200 @@ -1,5 +1,18 @@ colorize("name", ".*", yellow); colorize("name", "Catch.*", blue); - colorize("name", "Region|Loop|CountedLoop|Root", red); colorize("name", "CProj|IfFalse|IfTrue|JProj|CatchProj", magenta); +colorize("name", "Con.*", orange); +colorize("name", "Parm|Proj", lightGray); + +// Nodes with bci +colorize("bci", "..*", magenta); + +// Line style +var f = new ColorFilter("Line Style filter"); +f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "int:")), null, Color.BLUE, null)); +f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "control")), null, Color.RED, null)); +f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "memory")), null, Color.GREEN, null)); +f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "tuple:")), null, Color.MAGENTA, null)); +f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "bottom")), null, Color.LIGHT_GRAY, null)); +f.apply(graph); \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/combine.filter --- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/combine.filter Wed Jun 08 14:50:55 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -var f = new CombineFilter("Combine Filter"); -f.addRule(new CombineFilter.CombineRule(new Properties.RegexpPropertyMatcher("name", ".*"), new Properties.RegexpPropertyMatcher("name", "Proj|IfFalse|IfTrue|JProj|MachProj|JumpProj|CatchProj"))); -f.addRule(new CombineFilter.CombineRule(new Properties.RegexpPropertyMatcher("name", "Cmp.*"), new Properties.RegexpPropertyMatcher("name", "Bool"))); -f.apply(graph); \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/extendedColor.filter --- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/extendedColor.filter Wed Jun 08 14:50:55 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,3 +0,0 @@ -colorize("name", "Con.*", orange); -colorize("name", "Parm|Proj", lightGray); -colorize("bci", "..*", magenta); \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/linestyle.filter --- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/linestyle.filter Wed Jun 08 14:50:55 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ -var f = new ColorFilter("Line Style filter"); -f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "int:")), null, Color.BLUE, null)); -f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "control")), null, Color.RED, null)); -f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "memory")), null, Color.GREEN, null)); -f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "tuple:")), null, Color.MAGENTA, null)); -f.addRule(new ColorFilter.ColorRule(new MatcherSelector(new Properties.StringPropertyMatcher("type", "bottom")), null, Color.LIGHT_GRAY, null)); -f.apply(graph); \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/register.filter --- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/register.filter Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/register.filter Wed Jun 08 15:36:30 2011 +0200 @@ -1,4 +1,5 @@ +// Register coloring colorize("reg", "EAX", green); colorize("reg", "EFLAGS", gray); colorize("reg", "EBP", orange); -colorize("reg", "ECX", cyan); +colorize("reg", "ECX", cyan); \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/remove.filter --- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/remove.filter Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/remove.filter Wed Jun 08 15:36:30 2011 +0200 @@ -1,1 +1,8 @@ -remove("dump_spec", "FramePtr|ReturnAdr|I_O"); \ No newline at end of file +remove("dump_spec", "FramePtr|ReturnAdr|I_O"); +removeInputs("name", "Root"); +var f = new RemoveSelfLoopsFilter("Remove Self-Loops"); +f.apply(graph); +removeInputs("name", "SafePoint|CallStaticJava|CallDynamicJava|CallJava|CallLeaf|CallRuntime|AbstractLock|CallLeafNoFP|Call|CallStaticJavaDirect", 5); +removeInputs("name", "Unlock|Lock", 7); +removeInputs("name", "Allocate", 7); +removeInputs("name", "AllocateArray", 9); \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeMemory.filter --- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeMemory.filter Wed Jun 08 14:50:55 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ - -//var f = new RemoveFilter("Remove Memory"); -//f.addRule(new RemoveFilter.RemoveRule(new MatcherSelector(new Properties.StringPropertyMatcher("dump_spec", "Memory")), false)); -//f.addRule(new RemoveFilter.RemoveRule(new AndSelector(new MatcherSelector(new Properties.StringPropertyMatcher("name", "Proj")), new MatcherSelector(new Properties.StringPropertyMatcher("type", "memory"))), false)); -//f.apply(graph); - -remove("dump_spec", "Memory"); diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeRootInputs.filter --- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeRootInputs.filter Wed Jun 08 14:50:55 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -removeInputs("name", "Root"); \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeSafepointInputs.filter --- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeSafepointInputs.filter Wed Jun 08 14:50:55 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -removeInputs("name", "SafePoint|CallStaticJava|CallDynamicJava|CallJava|CallLeaf|CallRuntime|AbstractLock|CallLeafNoFP|Call|CallStaticJavaDirect", 5); -removeInputs("name", "Unlock|Lock", 7); -removeInputs("name", "Allocate", 7); -removeInputs("name", "AllocateArray", 9); diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeSelfLoops.filter --- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/removeSelfLoops.filter Wed Jun 08 14:50:55 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -var f = new RemoveSelfLoopsFilter("Remove Self-Loops"); -f.apply(graph); \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/split.filter --- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/split.filter Wed Jun 08 14:50:55 2011 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -split("name", "BoxLock"); -split("name", "(Con.*)|(loadCon.*)"); \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/structural.filter --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/filters/structural.filter Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,6 @@ +var f = new CombineFilter("Combine Filter"); +f.addRule(new CombineFilter.CombineRule(new Properties.RegexpPropertyMatcher("name", ".*"), new Properties.RegexpPropertyMatcher("name", "Proj|IfFalse|IfTrue|JProj|MachProj|JumpProj|CatchProj"))); +f.addRule(new CombineFilter.CombineRule(new Properties.RegexpPropertyMatcher("name", "Cmp.*"), new Properties.RegexpPropertyMatcher("name", "Bool"))); +f.apply(graph); +split("name", "BoxLock"); +split("name", "(Con.*)|(loadCon.*)", "[dump_spec]"); \ No newline at end of file diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/layer.xml --- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/layer.xml Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/layer.xml Wed Jun 08 15:36:30 2011 +0200 @@ -2,60 +2,28 @@ - - - - - - - - - - + + - - - - - - - + + + - - - - - + - + - - - - - + - - - - - + - - - - - - - + + + - - - + + + - - - - - + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/layer.xml --- a/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/layer.xml Wed Jun 08 14:50:55 2011 +0200 +++ b/src/share/tools/IdealGraphVisualizer/Settings/src/com/sun/hotspot/igv/settings/layer.xml Wed Jun 08 15:36:30 2011 +0200 @@ -2,8 +2,8 @@ - - + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/StructuredText/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/StructuredText/build.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,8 @@ + + + + + + Builds, tests, and runs the project com.sun.hotspot.igv.structuredtext. + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/StructuredText/manifest.mf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/StructuredText/manifest.mf Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,5 @@ +Manifest-Version: 1.0 +OpenIDE-Module: com.sun.hotspot.igv.structuredtext +OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/structuredtext/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/build-impl.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/build-impl.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,45 @@ + + + + + + + + + + + + + You must set 'suite.dir' to point to your containing module suite + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/genfiles.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/genfiles.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,5 @@ +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=216fc635 +nbproject/build-impl.xml.script.CRC32=6022dc85 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45.1 diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/platform.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/platform.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,129 @@ +# Deprecated since 5.0u1; for compatibility with 5.0: +disabled.clusters=\ + apisupport1,\ + gsf1,\ + harness,\ + java2,\ + nb6.1,\ + profiler3 +disabled.modules=\ + org.apache.xml.resolver,\ + org.netbeans.api.debugger,\ + org.netbeans.api.xml,\ + org.netbeans.core.execution,\ + org.netbeans.core.ide,\ + org.netbeans.core.multiview,\ + org.netbeans.core.nativeaccess,\ + org.netbeans.core.output2,\ + org.netbeans.insane,\ + org.netbeans.lib.cvsclient,\ + org.netbeans.libs.commons_logging,\ + org.netbeans.libs.freemarker,\ + org.netbeans.libs.ini4j,\ + org.netbeans.libs.jna,\ + org.netbeans.libs.jsch,\ + org.netbeans.libs.jsr223,\ + org.netbeans.libs.lucene,\ + org.netbeans.libs.svnClientAdapter,\ + org.netbeans.libs.xerces,\ + org.netbeans.modules.applemenu,\ + org.netbeans.modules.autoupdate.services,\ + org.netbeans.modules.autoupdate.ui,\ + org.netbeans.modules.classfile,\ + org.netbeans.modules.core.kit,\ + org.netbeans.modules.db,\ + org.netbeans.modules.db.core,\ + org.netbeans.modules.db.drivers,\ + org.netbeans.modules.db.kit,\ + org.netbeans.modules.db.mysql,\ + org.netbeans.modules.db.sql.editor,\ + org.netbeans.modules.db.sql.visualeditor,\ + org.netbeans.modules.dbapi,\ + org.netbeans.modules.defaults,\ + org.netbeans.modules.diff,\ + org.netbeans.modules.editor.bookmarks,\ + org.netbeans.modules.editor.bracesmatching,\ + org.netbeans.modules.editor.codetemplates,\ + org.netbeans.modules.editor.completion,\ + org.netbeans.modules.editor.errorstripe,\ + org.netbeans.modules.editor.errorstripe.api,\ + org.netbeans.modules.editor.guards,\ + org.netbeans.modules.editor.highlights,\ + org.netbeans.modules.editor.macros,\ + org.netbeans.modules.editor.plain,\ + org.netbeans.modules.editor.plain.lib,\ + org.netbeans.modules.editor.structure,\ + org.netbeans.modules.extbrowser,\ + org.netbeans.modules.favorites,\ + org.netbeans.modules.gototest,\ + org.netbeans.modules.httpserver,\ + org.netbeans.modules.ide.kit,\ + org.netbeans.modules.image,\ + org.netbeans.modules.javahelp,\ + org.netbeans.modules.jumpto,\ + org.netbeans.modules.languages,\ + org.netbeans.modules.languages.bat,\ + org.netbeans.modules.languages.diff,\ + org.netbeans.modules.languages.manifest,\ + org.netbeans.modules.languages.sh,\ + org.netbeans.modules.lexer.editorbridge,\ + org.netbeans.modules.lexer.nbbridge,\ + org.netbeans.modules.localhistory,\ + org.netbeans.modules.masterfs,\ + org.netbeans.modules.mercurial,\ + org.netbeans.modules.progress.ui,\ + org.netbeans.modules.project.ant,\ + org.netbeans.modules.project.libraries,\ + org.netbeans.modules.projectui,\ + org.netbeans.modules.projectuiapi,\ + org.netbeans.modules.properties,\ + org.netbeans.modules.properties.syntax,\ + org.netbeans.modules.refactoring.api,\ + org.netbeans.modules.schema2beans,\ + org.netbeans.modules.sendopts,\ + org.netbeans.modules.server,\ + org.netbeans.modules.servletapi,\ + org.netbeans.modules.subversion,\ + org.netbeans.modules.tasklist.kit,\ + org.netbeans.modules.tasklist.projectint,\ + org.netbeans.modules.tasklist.todo,\ + org.netbeans.modules.tasklist.ui,\ + org.netbeans.modules.templates,\ + org.netbeans.modules.timers,\ + org.netbeans.modules.usersguide,\ + org.netbeans.modules.utilities,\ + org.netbeans.modules.utilities.project,\ + org.netbeans.modules.versioning,\ + org.netbeans.modules.versioning.system.cvss,\ + org.netbeans.modules.versioning.util,\ + org.netbeans.modules.web.flyingsaucer,\ + org.netbeans.modules.xml,\ + org.netbeans.modules.xml.axi,\ + org.netbeans.modules.xml.catalog,\ + org.netbeans.modules.xml.core,\ + org.netbeans.modules.xml.lexer,\ + org.netbeans.modules.xml.multiview,\ + org.netbeans.modules.xml.retriever,\ + org.netbeans.modules.xml.schema.completion,\ + org.netbeans.modules.xml.schema.model,\ + org.netbeans.modules.xml.tax,\ + org.netbeans.modules.xml.text,\ + org.netbeans.modules.xml.tools,\ + org.netbeans.modules.xml.wsdl.model,\ + org.netbeans.modules.xml.xam,\ + org.netbeans.modules.xml.xdm,\ + org.netbeans.modules.xsl,\ + org.netbeans.spi.debugger.ui,\ + org.netbeans.spi.editor.hints,\ + org.netbeans.spi.navigator,\ + org.netbeans.spi.palette,\ + org.netbeans.spi.tasklist,\ + org.netbeans.spi.viewmodel,\ + org.netbeans.swing.dirchooser,\ + org.openide.compat,\ + org.openide.util.enumerations +enabled.clusters=\ + ide9,\ + platform8 +nbjdk.active=default +nbplatform.active=default diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/project.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,2 @@ +javac.source=1.5 +javac.compilerargs=-Xlint -Xlint:-serial diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/project.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,15 @@ + + + org.netbeans.modules.apisupport.project + + + com.sun.hotspot.igv.structuredtext + + + + com.sun.hotspot.igv.structuredtext + com.sun.hotspot.igv.structuredtext.services + + + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/suite.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/StructuredText/nbproject/suite.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,1 @@ +suite.dir=${basedir}/.. diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Bundle.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,1 @@ +OpenIDE-Module-Name=StructuredText diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Element.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Element.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.structuredtext; + +import com.sun.hotspot.igv.structuredtext.services.ElementVisitor; +import java.util.Collections; +import java.util.HashSet; +import java.util.Set; +import javax.swing.text.Style; +import javax.swing.text.StyleContext; + +/** + * + * @author Thomas + */ +public abstract class Element { + + private Set source; + private Style style; + private Style highlightedStyle; + + public Element() { + source = new HashSet(); + style = null; + highlightedStyle = null; + } + + public Style getStyle() { + return style; + } + + public Style getHighlightedStyle() { + return highlightedStyle; + } + + public void setStyle(Style style) { + this.style = style; + } + + public void setHighlightedStyle(Style style) { + this.highlightedStyle = style; + } + + public void setStyleRecursive(Style style) { + this.style = style; + } + + public void setHighlightedStyleRecursive(Style style) { + this.highlightedStyle = style; + } + + public Set getSource() { + return Collections.unmodifiableSet(source); + } + + public void addSource(Object o) { + source.add(o); + } + + public abstract void accept(ElementVisitor visitor); +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/MultiElement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/MultiElement.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,141 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.structuredtext; + +import com.sun.hotspot.igv.structuredtext.services.ElementVisitor; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import javax.swing.text.Style; + +/** + * + * @author Thomas + */ +public class MultiElement extends Element { + + private List children; + private String foldString; + + public MultiElement() { + this((String)null); + } + + public MultiElement(String foldString) { + this(foldString, null); + } + + public MultiElement(Style style) { + this(null, style); + } + + public MultiElement(String foldString, Style style) { + setStyle(style); + this.foldString = foldString; + children = new ArrayList(); + } + + public void print(String s) { + print(s, null); + } + + @Override + public void setStyleRecursive(Style style) { + super.setStyleRecursive(style); + for(Element elem : this.getChildren()) { + elem.setStyleRecursive(style); + } + } + + @Override + public void setHighlightedStyleRecursive(Style style) { + super.setStyleRecursive(style); + for(Element elem : this.getChildren()) { + elem.setHighlightedStyleRecursive(style); + } + } + + public void print(String s, Object source) { + if (s == null) { + s = ""; + } + SimpleElement elem = new SimpleElement(s); + if(source != null) { + elem.addSource(source); + } + addChild(elem); + } + + public void print(String s, Object source, int padding) { + if (s == null) { + s = ""; + } + StringBuffer sb = new StringBuffer(s); + while(sb.length() < padding) { + sb.insert(0, ' '); + } + + print(sb.toString(), source); + + } + + public void println() { + println(""); + } + + public void println(String s) { + print(s + "\n"); + } + + public void println(String s, Object source) { + print(s + "\n", source); + } + + + public void println(String s, Object source, int padding) { + print(s + "\n", source, padding); + } + + public void addChild(Element element) { + assert element != null; + this.children.add(element); + } + + public String getFoldString() { + return foldString; + } + + public void setFoldString(String s) { + this.foldString = s; + } + + public List getChildren() { + return Collections.unmodifiableList(children); + } + + public void accept(ElementVisitor visitor) { + visitor.visit(this); + } +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Range.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Range.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.structuredtext; + +/** + * + * @author Thomas + */ +public class Range { + + private int start; + private int length; + + public Range(int start, int length) { + this.start = start; + this.length = length; + } + + public int getStart() { + return start; + } + + public boolean overlaps(Range r2) { + if(start < r2.start) { + return start + length > r2.start; + } else { + return r2.start + r2.length > start; + } + } + + public int getLength() { + return length; + } + +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/SimpleElement.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/SimpleElement.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.structuredtext; + +import com.sun.hotspot.igv.structuredtext.services.ElementVisitor; +import javax.swing.text.Style; +import javax.swing.text.StyleContext; + +/** + * + * @author Thomas + */ +public class SimpleElement extends Element { + + public static final Element EMPTY = new SimpleElement(""); + public static final Element LN = new SimpleElement("\n"); + public static final Element TAB = new SimpleElement("\t"); + + private String text; + + public SimpleElement(String s) { + this(s, null); + } + + public SimpleElement(String s, Style style) { + setText(s); + setStyle(style); + assert text != null; + } + + private static String addPadding(String s, int minLength) { + + StringBuilder sb = new StringBuilder(s); + while(sb.length() < minLength) { + sb.insert(0, ' '); + } + return sb.toString(); + } + + public SimpleElement(String s, int length) { + this(addPadding(s, length)); + } + + + public String getText() { + return text; + } + + public void setText(String s) { + this.text = s; + } + + public void accept(ElementVisitor visitor) { + visitor.visit(this); + } +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/StructuredText.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/StructuredText.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.structuredtext; + +import com.sun.hotspot.igv.structuredtext.services.ElementVisitor; +import java.util.HashMap; +import java.util.Map; + + +/** + * + * @author Thomas + */ +public class StructuredText extends MultiElement { + + private String name; + + public StructuredText(String name) { + this.name = name; + } + + public String getName() { + return name; + } + + public Element findElementAt(final int searchIndex) { + + final Element[] result = new Element[1]; + this.accept(new ElementVisitor() { + + private int index; + + @Override + public void visit(MultiElement element) { + int startIndex = index; + super.visit(element); + } + + @Override + public void visit(SimpleElement element) { + if(searchIndex >= index && searchIndex < index + element.getText().length()) { + assert result[0] == null; + result[0] = element; + } + index += element.getText().length(); + } + }); + + return result[0]; + } + + public Map calculateRanges() { + + final Map result = new HashMap(); + + this.accept(new ElementVisitor() { + + private int index; + + @Override + public void visit(MultiElement element) { + int startIndex = index; + super.visit(element); + result.put(element, new Range(startIndex, index - startIndex)); + } + + @Override + public void visit(SimpleElement element) { + result.put(element, new Range(index, element.getText().length())); + index += element.getText().length(); + } + }); + + + return result; + + } + + public String convertToString() { + final StringBuilder result = new StringBuilder(); + this.accept(new ElementVisitor() { + @Override + public void visit(SimpleElement element) { + result.append(element.getText()); + } + } + ); + return result.toString(); + } +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/ToolTipProvider.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/ToolTipProvider.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.structuredtext; + +/** + * + * @author thomas + */ +public interface ToolTipProvider { + + String getToolTip(); + +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/services/ElementVisitor.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/services/ElementVisitor.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.structuredtext.services; + +import com.sun.hotspot.igv.structuredtext.Element; +import com.sun.hotspot.igv.structuredtext.MultiElement; +import com.sun.hotspot.igv.structuredtext.SimpleElement; + +/** + * + * @author Thomas + */ +public abstract class ElementVisitor { + + public void visit(MultiElement element) { + + for(Element e : element.getChildren()) { + e.accept(this); + } + } + public abstract void visit(SimpleElement element); +} diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/TextEditor/build.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/TextEditor/build.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,8 @@ + + + + + + Builds, tests, and runs the project com.sun.hotspot.igv.texteditor. + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/TextEditor/manifest.mf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/TextEditor/manifest.mf Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +OpenIDE-Module: com.sun.hotspot.igv.texteditor +OpenIDE-Module-Layer: com/sun/hotspot/igv/texteditor/layer.xml +OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/texteditor/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/build-impl.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/build-impl.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,45 @@ + + + + + + + + + + + + + You must set 'suite.dir' to point to your containing module suite + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/genfiles.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/genfiles.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,5 @@ +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=2b80dbe4 +nbproject/build-impl.xml.script.CRC32=122053f6 +nbproject/build-impl.xml.stylesheet.CRC32=238281d1@1.45.1 diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/platform.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/platform.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,129 @@ +# Deprecated since 5.0u1; for compatibility with 5.0: +disabled.clusters=\ + apisupport1,\ + gsf1,\ + harness,\ + java2,\ + nb6.1,\ + profiler3 +disabled.modules=\ + org.apache.xml.resolver,\ + org.netbeans.api.debugger,\ + org.netbeans.api.xml,\ + org.netbeans.core.execution,\ + org.netbeans.core.ide,\ + org.netbeans.core.multiview,\ + org.netbeans.core.nativeaccess,\ + org.netbeans.core.output2,\ + org.netbeans.insane,\ + org.netbeans.lib.cvsclient,\ + org.netbeans.libs.commons_logging,\ + org.netbeans.libs.freemarker,\ + org.netbeans.libs.ini4j,\ + org.netbeans.libs.jna,\ + org.netbeans.libs.jsch,\ + org.netbeans.libs.jsr223,\ + org.netbeans.libs.lucene,\ + org.netbeans.libs.svnClientAdapter,\ + org.netbeans.libs.xerces,\ + org.netbeans.modules.applemenu,\ + org.netbeans.modules.autoupdate.services,\ + org.netbeans.modules.autoupdate.ui,\ + org.netbeans.modules.classfile,\ + org.netbeans.modules.core.kit,\ + org.netbeans.modules.db,\ + org.netbeans.modules.db.core,\ + org.netbeans.modules.db.drivers,\ + org.netbeans.modules.db.kit,\ + org.netbeans.modules.db.mysql,\ + org.netbeans.modules.db.sql.editor,\ + org.netbeans.modules.db.sql.visualeditor,\ + org.netbeans.modules.dbapi,\ + org.netbeans.modules.defaults,\ + org.netbeans.modules.diff,\ + org.netbeans.modules.editor.bookmarks,\ + org.netbeans.modules.editor.bracesmatching,\ + org.netbeans.modules.editor.codetemplates,\ + org.netbeans.modules.editor.completion,\ + org.netbeans.modules.editor.errorstripe,\ + org.netbeans.modules.editor.errorstripe.api,\ + org.netbeans.modules.editor.guards,\ + org.netbeans.modules.editor.highlights,\ + org.netbeans.modules.editor.macros,\ + org.netbeans.modules.editor.plain,\ + org.netbeans.modules.editor.plain.lib,\ + org.netbeans.modules.editor.structure,\ + org.netbeans.modules.extbrowser,\ + org.netbeans.modules.favorites,\ + org.netbeans.modules.gototest,\ + org.netbeans.modules.httpserver,\ + org.netbeans.modules.ide.kit,\ + org.netbeans.modules.image,\ + org.netbeans.modules.javahelp,\ + org.netbeans.modules.jumpto,\ + org.netbeans.modules.languages,\ + org.netbeans.modules.languages.bat,\ + org.netbeans.modules.languages.diff,\ + org.netbeans.modules.languages.manifest,\ + org.netbeans.modules.languages.sh,\ + org.netbeans.modules.lexer.editorbridge,\ + org.netbeans.modules.lexer.nbbridge,\ + org.netbeans.modules.localhistory,\ + org.netbeans.modules.masterfs,\ + org.netbeans.modules.mercurial,\ + org.netbeans.modules.progress.ui,\ + org.netbeans.modules.project.ant,\ + org.netbeans.modules.project.libraries,\ + org.netbeans.modules.projectui,\ + org.netbeans.modules.projectuiapi,\ + org.netbeans.modules.properties,\ + org.netbeans.modules.properties.syntax,\ + org.netbeans.modules.refactoring.api,\ + org.netbeans.modules.schema2beans,\ + org.netbeans.modules.sendopts,\ + org.netbeans.modules.server,\ + org.netbeans.modules.servletapi,\ + org.netbeans.modules.subversion,\ + org.netbeans.modules.tasklist.kit,\ + org.netbeans.modules.tasklist.projectint,\ + org.netbeans.modules.tasklist.todo,\ + org.netbeans.modules.tasklist.ui,\ + org.netbeans.modules.templates,\ + org.netbeans.modules.timers,\ + org.netbeans.modules.usersguide,\ + org.netbeans.modules.utilities,\ + org.netbeans.modules.utilities.project,\ + org.netbeans.modules.versioning,\ + org.netbeans.modules.versioning.system.cvss,\ + org.netbeans.modules.versioning.util,\ + org.netbeans.modules.web.flyingsaucer,\ + org.netbeans.modules.xml,\ + org.netbeans.modules.xml.axi,\ + org.netbeans.modules.xml.catalog,\ + org.netbeans.modules.xml.core,\ + org.netbeans.modules.xml.lexer,\ + org.netbeans.modules.xml.multiview,\ + org.netbeans.modules.xml.retriever,\ + org.netbeans.modules.xml.schema.completion,\ + org.netbeans.modules.xml.schema.model,\ + org.netbeans.modules.xml.tax,\ + org.netbeans.modules.xml.text,\ + org.netbeans.modules.xml.tools,\ + org.netbeans.modules.xml.wsdl.model,\ + org.netbeans.modules.xml.xam,\ + org.netbeans.modules.xml.xdm,\ + org.netbeans.modules.xsl,\ + org.netbeans.spi.debugger.ui,\ + org.netbeans.spi.editor.hints,\ + org.netbeans.spi.navigator,\ + org.netbeans.spi.palette,\ + org.netbeans.spi.tasklist,\ + org.netbeans.spi.viewmodel,\ + org.netbeans.swing.dirchooser,\ + org.openide.compat,\ + org.openide.util.enumerations +enabled.clusters=\ + ide9,\ + platform8 +nbjdk.active=default +nbplatform.active=default diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/project.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/project.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,2 @@ +javac.source=1.5 +javac.compilerargs=-Xlint -Xlint:-serial diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/project.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/project.xml Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,99 @@ + + + org.netbeans.modules.apisupport.project + + + com.sun.hotspot.igv.texteditor + + + + com.sun.hotspot.igv.data + + + + 1.0 + + + + com.sun.hotspot.igv.selectioncoordinator + + + + 1.0 + + + + com.sun.hotspot.igv.structuredtext + + + + 1.0 + + + + org.netbeans.modules.editor + + + + 3 + 1.42.2.3.9.2 + + + + org.netbeans.modules.editor.fold + + + + 1 + 1.8 + + + + org.netbeans.modules.editor.lib + + + + 3 + 3.8.1.13.9 + + + + org.netbeans.modules.editor.lib2 + + + + 1 + 1.11.2.2 + + + + org.openide.text + + + + 6.18 + + + + org.openide.util + + + + 7.12.0.1 + + + + org.openide.windows + + + + 6.20 + + + + + com.sun.hotspot.igv.texteditor + + + + diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/suite.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/TextEditor/nbproject/suite.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,1 @@ +suite.dir=${basedir}/.. diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/Bundle.properties --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/Bundle.properties Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,2 @@ + +OpenIDE-Module-Name=TextEditor diff -r be276884eec0 -r 53ddfe305645 src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/SyntaxLayer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/SyntaxLayer.java Wed Jun 08 15:36:30 2011 +0200 @@ -0,0 +1,327 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package com.sun.hotspot.igv.texteditor; + +import com.sun.hotspot.igv.data.ChangedListener; +import com.sun.hotspot.igv.selectioncoordinator.SelectionCoordinator; +import com.sun.hotspot.igv.structuredtext.MultiElement; +import com.sun.hotspot.igv.structuredtext.SimpleElement; +import com.sun.hotspot.igv.structuredtext.StructuredText; +import com.sun.hotspot.igv.structuredtext.Element; +import com.sun.hotspot.igv.structuredtext.Range; +import com.sun.hotspot.igv.structuredtext.ToolTipProvider; +import com.sun.hotspot.igv.structuredtext.services.ElementVisitor; +import java.awt.Color; +import java.awt.Cursor; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Stack; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.AttributeSet; +import javax.swing.text.Style; +import javax.swing.text.StyleConstants; +import javax.swing.text.StyleContext; +import org.netbeans.spi.editor.highlighting.HighlightsLayerFactory; +import org.netbeans.spi.editor.highlighting.HighlightsSequence; +import org.netbeans.spi.editor.highlighting.support.AbstractHighlightsContainer; + +/** + * + * @author Thomas + */ +public class SyntaxLayer extends AbstractHighlightsContainer implements ChangedListener { + + private HighlightsLayerFactory.Context context; + + public SyntaxLayer(final HighlightsLayerFactory.Context context) { + this.context = context; + + context.getDocument().addDocumentListener(new DocumentListener() { + + public void insertUpdate(DocumentEvent arg0) { + update(); + } + + public void removeUpdate(DocumentEvent arg0) { + } + + public void changedUpdate(DocumentEvent arg0) { + } + }); + + SelectionCoordinator.getInstance().getSelectedChangedEvent().addListener(this); + SelectionCoordinator.getInstance().getHighlightedChangedEvent().addListener(this); + + context.getComponent().addMouseMotionListener(new MouseMotionListener() { + + public void mouseDragged(MouseEvent e) { + } + + public void mouseMoved(MouseEvent e) { + // [tw] hack to prevent sidebar mouse over + if (e.getPoint().getX() < 15) return; + + int index = context.getComponent().viewToModel(e.getPoint()); + Element elem = indexToElement(index); + if (elem != null) { + Set highlightedSource = new HashSet(elem.getSource()); + SelectionCoordinator.getInstance().setHighlightedObjects(highlightedSource); + context.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + } + } + }); + + context.getComponent().addMouseListener(new MouseListener() { + + public void mouseClicked(MouseEvent e) { + + int index = context.getComponent().viewToModel(e.getPoint()); + Element elem = indexToElement(index); + if (elem != null) { + Set selectedSource = new HashSet(elem.getSource()); + + for (Object o : selectedSource) { + if (o instanceof ToolTipProvider) { + String toolTip = ((ToolTipProvider) o).getToolTip(); + } + } + + if ((e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0) { + + SelectionCoordinator.getInstance().addAllSelected(selectedSource); + } else { + SelectionCoordinator.getInstance().setSelectedObjects(selectedSource); + } + context.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + } else { + context.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); + + } + } + + public void mousePressed(MouseEvent e) { + } + + public void mouseReleased(MouseEvent e) { + } + + public void mouseEntered(MouseEvent e) { + } + + public void mouseExited(MouseEvent e) { + SelectionCoordinator.getInstance().setHighlightedObjects(new HashSet()); + } + }); + } + + public void changed(SelectionCoordinator source) { + update(); + } + + private void update() { + fireHighlightsChange(0, context.getDocument().getLength()); + } + + private Element indexToElement(int index) { + StructuredText text = (StructuredText) context.getDocument().getProperty(StructuredText.class); + if (text == null) { + return null; + } + return text.findElementAt(index); + } + + private static class HighlightsRange { + + private int start; + private int end; + private AttributeSet attributes; + + public HighlightsRange(int start, int length, AttributeSet attributes) { + this.start = start; + this.end = start + length; + this.attributes = attributes; + } + + public int getStart() { + return start; + } + + public int getEnd() { + return end; + } + + public AttributeSet getAttributes() { + return attributes; + } + } + + private static class HighlightsSequenceImpl implements HighlightsSequence { + + private List ranges; + private int currentIndex; + + public HighlightsSequenceImpl() { + this(new ArrayList()); + } + + public HighlightsSequenceImpl(List ranges) { + this.ranges = ranges; + this.currentIndex = -1; + } + + public boolean moveNext() { + currentIndex++; + return currentIndex < ranges.size(); + } + + public int getStartOffset() { + return ranges.get(currentIndex).getStart(); + } + + public int getEndOffset() { + return ranges.get(currentIndex).getEnd(); + } + + public AttributeSet getAttributes() { + return ranges.get(currentIndex).getAttributes(); + } + } + + private boolean intersects(Set s1, Set s2) { + for (Object o : s1) { + if (s2.contains(o)) { + return true; + } + } + return false; + } + + public HighlightsSequence getHighlights(final int start, final int end) { + + StructuredText text = (StructuredText) context.getDocument().getProperty(StructuredText.class); + if (text == null) { + return new HighlightsSequenceImpl(); + } + final Map ranges = text.calculateRanges(); + final List highlightsRanges = new ArrayList(); + final Range baseRange = new Range(start, end - start); + + text.accept(new ElementVisitor() { + + private Stack