8075492: adopt recent IGV

Adopted recent sources, updated README, added build and run instructions; ignored IGV build files in Mercurial; adapted HotSpot Ideal graph printer to current IGV's data format schema; reintroduced control flow window and basic block layout

Co-authored-by: Bernhard Urban <bernhard.urban@oracle.com>
Co-authored-by: Christian Haeubl <christian.haeubl@oracle.com>
Co-authored-by: Doug Simon <doug.simon@oracle.com>
Co-authored-by: Gilles Duboscq <gilles.duboscq@oracle.com>
Co-authored-by: Lukas Stadler <lukas.stadler@oracle.com>
Co-authored-by: Peter Hofer <peter.hofer@jku.at>
Co-authored-by: Roland Schatz <roland.schatz@oracle.com>
Co-authored-by: Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: kvn, roland
This commit is contained in:
Andreas Woess 2015-05-05 13:06:10 +02:00 committed by Michael Haupt
parent 6d705e6978
commit 5c13c285f7
385 changed files with 10302 additions and 7196 deletions
hotspot
.hgignore
src/share/tools/IdealGraphVisualizer
BatikSVGProxy
Bytecodes
ControlFlow
Coordinator
Data

@ -6,5 +6,7 @@
^src/share/tools/IdealGraphVisualizer/[a-zA-Z0-9]*/build/
^src/share/tools/IdealGraphVisualizer/build/
^src/share/tools/IdealGraphVisualizer/dist/
^src/share/tools/IdealGraphVisualizer/nbplatform/
.igv.log
^.hgtip
.DS_Store

@ -4,6 +4,13 @@
*** EDIT ../build.xml INSTEAD ***
-->
<project name="com.sun.hotspot.igv.svg-impl" basedir="..">
<fail message="Please build using Ant 1.7.1 or higher.">
<condition>
<not>
<antversion atleast="1.7.1"/>
</not>
</condition>
</fail>
<property file="nbproject/private/suite-private.properties"/>
<property file="nbproject/suite.properties"/>
<fail unless="suite.dir">You must set 'suite.dir' to point to your containing module suite</fail>
@ -16,13 +23,21 @@
<property name="@{name}" value="${@{value}}"/>
</sequential>
</macrodef>
<macrodef name="evalprops" uri="http://www.netbeans.org/ns/nb-module-project/2">
<attribute name="property"/>
<attribute name="value"/>
<sequential>
<property name="@{property}" value="@{value}"/>
</sequential>
</macrodef>
<property file="${user.properties.file}"/>
<nbmproject2:property name="harness.dir" value="nbplatform.${nbplatform.active}.harness.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
<nbmproject2:property name="netbeans.dest.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
<fail message="You must define 'nbplatform.${nbplatform.active}.harness.dir'">
<nbmproject2:property name="nbplatform.active.dir" value="nbplatform.${nbplatform.active}.netbeans.dest.dir" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
<nbmproject2:evalprops property="cluster.path.evaluated" value="${cluster.path}" xmlns:nbmproject2="http://www.netbeans.org/ns/nb-module-project/2"/>
<fail message="Path to 'platform' cluster missing in $${cluster.path} property or using corrupt Netbeans Platform (missing harness).">
<condition>
<not>
<available file="${harness.dir}" type="dir"/>
<contains string="${cluster.path.evaluated}" substring="platform"/>
</not>
</condition>
</fail>

@ -1,8 +1,5 @@
build.xml.data.CRC32=ebcf0422
build.xml.script.CRC32=d7a2678d
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=ebcf0422
nbproject/build-impl.xml.script.CRC32=57997f94
nbproject/build-impl.xml.stylesheet.CRC32=deb65f65
nbproject/build-impl.xml.script.CRC32=42ef3ff6
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.47.1

@ -1,2 +1,2 @@
javac.source=1.5
javac.compilerargs=-Xlint -Xlint:-serial
javac.source=1.7
javac.compilerargs=-Xlint -Xlint:-serial

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -25,40 +25,58 @@ package com.sun.hotspot.igv.svg;
import java.awt.Graphics2D;
import java.io.Writer;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import org.w3c.dom.DOMImplementation;
/**
*
* Utility class
* @author Thomas Wuerthinger
*/
public class 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 BatikSVG() {
}
private static Constructor SVGGraphics2DConstructor;
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);
String batikJar = System.getenv().get("IGV_BATIK_JAR");
if (batikJar == null) {
return null;
}
// Load batik in it's own class loader since some it's support jars interfere with the JDK
URL url = new File(batikJar).toURI().toURL();
ClassLoader cl = new URLClassLoader(new URL[] { url });
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) {
@ -71,12 +89,22 @@ public class BatikSVG {
return null;
} catch (InstantiationException e) {
return null;
} catch (MalformedURLException e) {
return null;
}
}
/**
* 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) {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -21,14 +21,9 @@
* questions.
*
*/
package com.sun.hotspot.igv.view;
/**
*
* @author Thomas Wuerthinger
* 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.
*/
public class PreferenceConstants {
package com.sun.hotspot.igv.svg;
public static final String KEY_LINE_GENERATOR = "lineGenerator";
public static final String DEFAULT_LINE_GENERATOR = "com.sun.hotspot.igv.positioning.BasicLineGenerator";
}

@ -1,6 +1,6 @@
Manifest-Version: 1.0
OpenIDE-Module: com.sun.hotspot.igv.bytecodes
OpenIDE-Module-Layer: com/sun/hotspot/igv/bytecodes/layer.xml
OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/bytecodes/Bundle.properties
OpenIDE-Module-Specification-Version: 1.0
Manifest-Version: 1.0
OpenIDE-Module: com.sun.hotspot.igv.bytecodes
OpenIDE-Module-Layer: com/sun/hotspot/igv/bytecodes/layer.xml
OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/bytecodes/Bundle.properties
OpenIDE-Module-Specification-Version: 1.0

@ -1,2 +1,2 @@
javac.source=1.5
javac.compilerargs=-Xlint -Xlint:-serial
javac.source=1.7
javac.compilerargs=-Xlint -Xlint:-serial

@ -14,13 +14,37 @@
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>com.sun.hotspot.igv.graph</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>com.sun.hotspot.igv.util</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.jdesktop.layout</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>1.4</specification-version>
<specification-version>1.16.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.awt</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>7.39.1</specification-version>
</run-dependency>
</dependency>
<dependency>
@ -28,7 +52,7 @@
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>6.11</specification-version>
<specification-version>6.34.1</specification-version>
</run-dependency>
</dependency>
<dependency>
@ -36,7 +60,7 @@
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>7.2.0.1</specification-version>
<specification-version>7.20.1</specification-version>
</run-dependency>
</dependency>
<dependency>
@ -44,7 +68,15 @@
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>7.9.0.1</specification-version>
<specification-version>8.14.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.util.lookup</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>8.6.1</specification-version>
</run-dependency>
</dependency>
<dependency>
@ -52,7 +84,7 @@
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>6.16</specification-version>
<specification-version>6.39.1</specification-version>
</run-dependency>
</dependency>
</module-dependencies>

@ -1,5 +1,5 @@
CTL_BytecodeViewAction=Open BytecodeView Window
CTL_BytecodeViewTopComponent=BytecodeView Window
CTL_BytecodeViewAction=Bytecode
CTL_BytecodeViewTopComponent=Bytecode
CTL_SelectBytecodesAction=Select nodes
HINT_BytecodeViewTopComponent=This is a BytecodeView window
HINT_BytecodeViewTopComponent=Shows the bytecode associated with the displayed graph.
OpenIDE-Module-Name=Bytecodes

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -29,14 +29,14 @@ 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.Image;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import javax.swing.Action;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.Node;
import org.openide.util.Utilities;
import org.openide.util.ImageUtilities;
/**
*
@ -49,29 +49,35 @@ public class BytecodeNode extends AbstractNode {
public BytecodeNode(InputBytecode bytecode, InputGraph graph, String bciValue) {
super(Children.LEAF);
this.setDisplayName(bytecode.getBci() + " " + bytecode.getName());
String displayName = bytecode.getBci() + " " + bytecode.getName() + " " + bytecode.getOperands();
bciValue = bytecode.getBci() + " " + bciValue;
bciValue = bciValue.trim();
Properties.PropertySelector<InputNode> selector = new Properties.PropertySelector<InputNode>(graph.getNodes());
Properties.PropertySelector<InputNode> selector = new Properties.PropertySelector<>(graph.getNodes());
StringPropertyMatcher matcher = new StringPropertyMatcher("bci", bciValue);
List<InputNode> nodeList = selector.selectMultiple(matcher);
if (nodeList.size() > 0) {
nodes = new HashSet<InputNode>();
nodes = new LinkedHashSet<>();
for (InputNode n : nodeList) {
nodes.add(n);
}
this.setDisplayName(this.getDisplayName() + " (" + nodes.size() + " nodes)");
displayName += " (" + nodes.size() + " nodes)";
}
if (bytecode.getComment() != null) {
displayName += " // " + bytecode.getComment();
}
this.setDisplayName(displayName);
}
@Override
public Image getIcon(int i) {
if (nodes != null) {
return Utilities.loadImage("com/sun/hotspot/igv/bytecodes/images/link.gif");
return ImageUtilities.loadImage("com/sun/hotspot/igv/bytecodes/images/link.png");
} else {
return Utilities.loadImage("com/sun/hotspot/igv/bytecodes/images/bytecode.gif");
return ImageUtilities.loadImage("com/sun/hotspot/igv/bytecodes/images/bytecode.png");
}
}
@ -91,6 +97,7 @@ public class BytecodeNode extends AbstractNode {
}
@Override
@SuppressWarnings("unchecked")
public <T extends Node.Cookie> T getCookie(Class<T> aClass) {
if (aClass == SelectBytecodesCookie.class && nodes != null) {
return (T) (new SelectBytecodesCookie(nodes));

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -37,6 +37,7 @@ public class BytecodeViewAction extends AbstractAction {
super(NbBundle.getMessage(BytecodeViewAction.class, "CTL_BytecodeViewAction"));
}
@Override
public void actionPerformed(ActionEvent evt) {
TopComponent win = BytecodeViewTopComponent.findInstance();
win.open();

@ -3,6 +3,8 @@
<Form version="1.3" maxVersion="1.3" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -26,6 +26,7 @@ package com.sun.hotspot.igv.bytecodes;
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;
@ -33,11 +34,7 @@ import org.openide.ErrorManager;
import org.openide.explorer.ExplorerManager;
import org.openide.explorer.ExplorerUtils;
import org.openide.explorer.view.BeanTreeView;
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.util.*;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
@ -91,6 +88,7 @@ final class BytecodeViewTopComponent extends TopComponent implements ExplorerMan
}// </editor-fold>//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 +124,7 @@ final class BytecodeViewTopComponent extends TopComponent implements ExplorerMan
@Override
public void componentOpened() {
Lookup.Template tpl = new Lookup.Template(Object.class);
Lookup.Template<InputGraphProvider> tpl = new Lookup.Template<>(InputGraphProvider.class);
result = Utilities.actionsGlobalContext().lookup(tpl);
result.addLookupListener(this);
}
@ -147,23 +145,47 @@ final class BytecodeViewTopComponent extends TopComponent implements ExplorerMan
return PREFERRED_ID;
}
@Override
public ExplorerManager getExplorerManager() {
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);
}
@Override
public void resultChanged(LookupEvent lookupEvent) {
final InputGraphProvider p = Lookup.getDefault().lookup(InputGraphProvider.class);
if (p != null) {
final InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);//)Utilities.actionsGlobalContext().lookup(InputGraphProvider.class);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
InputGraph graph = p.getGraph();
if (graph != null) {
Group g = graph.getGroup();
rootNode.update(graph, g.getMethod());
}
}
if (p != null) {
InputGraph graph = p.getGraph();
if (graph != null) {
Group g = graph.getGroup();
rootNode.update(graph, g.getMethod());
return;
}
}
rootNode.update(null, null);
}
});
}
}
final static class ResolvableHelper implements Serializable {

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -30,7 +30,7 @@ import java.awt.Image;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.Node;
import org.openide.util.Utilities;
import org.openide.util.ImageUtilities;
/**
*
@ -38,7 +38,7 @@ import org.openide.util.Utilities;
*/
public class MethodNode extends AbstractNode {
private static class MethodNodeChildren extends Children.Keys {
private static class MethodNodeChildren extends Children.Keys<InputBytecode> {
private InputMethod method;
private InputGraph graph;
@ -50,9 +50,8 @@ public class MethodNode extends AbstractNode {
this.graph = graph;
}
protected Node[] createNodes(Object object) {
assert object instanceof InputBytecode;
InputBytecode bc = (InputBytecode) object;
@Override
protected Node[] createNodes(InputBytecode bc) {
if (bc.getInlined() == null) {
return new Node[]{new BytecodeNode(bc, graph, bciString)};
} else {
@ -84,7 +83,7 @@ public class MethodNode extends AbstractNode {
@Override
public Image getIcon(int i) {
return Utilities.loadImage("com/sun/hotspot/igv/bytecodes/images/method.gif");
return ImageUtilities.loadImage("com/sun/hotspot/igv/bytecodes/images/method.png");
}
@Override

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,9 +24,9 @@
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.actions.CookieAction;
@ -36,22 +36,26 @@ import org.openide.util.actions.CookieAction;
*/
public final class SelectBytecodesAction extends CookieAction {
@Override
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());
}
}
@Override
protected int mode() {
return CookieAction.MODE_EXACTLY_ONE;
}
@Override
public String getName() {
return NbBundle.getMessage(SelectBytecodesAction.class, "CTL_SelectBytecodesAction");
}
@Override
protected Class[] cookieClasses() {
return new Class[]{
SelectBytecodesCookie.class
@ -64,6 +68,7 @@ public final class SelectBytecodesAction extends CookieAction {
putValue("noIconInMenu", Boolean.TRUE);
}
@Override
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}
@ -73,3 +78,4 @@ public final class SelectBytecodesAction extends CookieAction {
return false;
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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

@ -1,6 +1,6 @@
Manifest-Version: 1.0
OpenIDE-Module: com.sun.hotspot.igv.controlflow
OpenIDE-Module-Layer: com/sun/hotspot/igv/controlflow/layer.xml
OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/controlflow/Bundle.properties
OpenIDE-Module-Specification-Version: 1.0
Manifest-Version: 1.0
OpenIDE-Module: com.sun.hotspot.igv.controlflow
OpenIDE-Module-Layer: com/sun/hotspot/igv/controlflow/layer.xml
OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/controlflow/Bundle.properties
OpenIDE-Module-Specification-Version: 1.0

@ -30,13 +30,21 @@
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>com.sun.hotspot.igv.util</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.jdesktop.layout</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>1.4</specification-version>
<specification-version>1.16.1</specification-version>
</run-dependency>
</dependency>
<dependency>
@ -52,7 +60,15 @@
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>7.9.0.1</specification-version>
<specification-version>8.14.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.util.lookup</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>8.6.1</specification-version>
</run-dependency>
</dependency>
<dependency>

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -26,7 +26,9 @@ package com.sun.hotspot.igv.controlflow;
import com.sun.hotspot.igv.data.InputBlockEdge;
import com.sun.hotspot.igv.layout.Link;
import com.sun.hotspot.igv.layout.Port;
import java.awt.BasicStroke;
import java.awt.Point;
import java.awt.Stroke;
import java.util.ArrayList;
import java.util.List;
import org.netbeans.api.visual.widget.ConnectionWidget;
@ -37,12 +39,19 @@ import org.netbeans.api.visual.widget.ConnectionWidget;
*/
public class BlockConnectionWidget extends ConnectionWidget implements Link {
private static final Stroke NORMAL_STROKE = new BasicStroke(1.0f);
private static final Stroke BOLD_STROKE = new BasicStroke(2.5f);
private static final Stroke DASHED_STROKE = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[]{5, 5}, 0);
private static final Stroke BOLD_DASHED_STROKE = new BasicStroke(2.5f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 10.0f, new float[]{5, 5}, 0);
private BlockWidget from;
private BlockWidget to;
private Port inputSlot;
private Port outputSlot;
private List<Point> points;
private InputBlockEdge edge;
private boolean isDashed = false;
private boolean isBold = false;
public BlockConnectionWidget(ControlFlowScene scene, InputBlockEdge edge) {
super(scene);
@ -67,6 +76,30 @@ public class BlockConnectionWidget extends ConnectionWidget implements Link {
return outputSlot;
}
public void setBold(boolean bold) {
this.isBold = bold;
updateStroke();
}
public void setDashed(boolean dashed) {
this.isDashed = dashed;
updateStroke();
}
private void updateStroke() {
Stroke stroke = NORMAL_STROKE;
if (isBold) {
if (isDashed) {
stroke = BOLD_DASHED_STROKE;
} else {
stroke = BOLD_STROKE;
}
} else if (isDashed) {
stroke = DASHED_STROKE;
}
setStroke(stroke);
}
public void setControlPoints(List<Point> p) {
this.points = p;
}
@ -80,4 +113,9 @@ public class BlockConnectionWidget extends ConnectionWidget implements Link {
public String toString() {
return "Connection[ " + from.toString() + " - " + to.toString() + "]";
}
@Override
public boolean isVIP() {
return isBold;
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -31,6 +31,7 @@ import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import java.awt.Rectangle;
import org.netbeans.api.visual.border.BorderFactory;
import org.netbeans.api.visual.model.ObjectState;
import org.netbeans.api.visual.widget.LabelWidget;
@ -41,13 +42,13 @@ import org.netbeans.api.visual.widget.LabelWidget;
*/
public class BlockWidget extends LabelWidget implements Vertex {
public static final Dimension SIZE = new Dimension(20, 20);
public static final Dimension MIN_SIZE = new Dimension(20, 20);
private InputBlock block;
private Port inputSlot;
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(Font.SANS_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;
@ -59,29 +60,24 @@ public class BlockWidget extends LabelWidget implements Vertex {
this.setLabel(block.getName());
this.setForeground(NORMAL_FOREGROUND_COLOR);
this.setBorder(BorderFactory.createLineBorder(1, NORMAL_FOREGROUND_COLOR));
this.setMinimumSize(SIZE);
this.setMaximumSize(SIZE);
this.setMinimumSize(MIN_SIZE);
this.setFont(font);
this.setAlignment(Alignment.CENTER);
final BlockWidget widget = this;
inputSlot = new Port() {
public Point getRelativePosition() {
return new Point((int) (SIZE.getWidth() / 2), (int) (SIZE.getHeight() / 2));
return new Point((int) (getSize().getWidth() / 2), (int) (getSize().getHeight() / 2));
}
public Vertex getVertex() {
return widget;
}
};
outputSlot = new Port() {
public Point getRelativePosition() {
return new Point((int) (SIZE.getWidth() / 2), (int) (SIZE.getHeight() / 2));
return new Point((int) (getSize().getWidth() / 2), (int) (getSize().getHeight() / 2));
}
public Vertex getVertex() {
return widget;
}
@ -101,7 +97,12 @@ public class BlockWidget extends LabelWidget implements Vertex {
}
public Dimension getSize() {
return SIZE;
Rectangle bounds = getBounds();
if (bounds != null) {
return bounds.getSize();
} else {
return MIN_SIZE;
}
}
public void setPosition(Point p) {

@ -1,4 +1,4 @@
CTL_ControlFlowAction=Open ControlFlow Window
CTL_ControlFlowTopComponent=ControlFlow Window
HINT_ControlFlowTopComponent=This is a ControlFlow window
CTL_ControlFlowAction=Control Flow
CTL_ControlFlowTopComponent=Control Flow
HINT_ControlFlowTopComponent=Shows the blocks of the current graph.
OpenIDE-Module-Name=ControlFlow

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -23,17 +23,17 @@
*/
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.data.InputBlock;
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;
@ -44,15 +44,14 @@ import org.netbeans.api.visual.action.SelectProvider;
import org.netbeans.api.visual.action.WidgetAction;
import org.netbeans.api.visual.anchor.AnchorFactory;
import org.netbeans.api.visual.anchor.AnchorShape;
import org.netbeans.api.visual.layout.LayoutFactory;
import org.netbeans.api.visual.router.RouterFactory;
import org.netbeans.api.visual.widget.LayerWidget;
import org.netbeans.api.visual.widget.Widget;
import org.netbeans.api.visual.graph.GraphScene;
import org.netbeans.api.visual.graph.layout.GraphLayout;
import org.netbeans.api.visual.layout.LayoutFactory;
import org.netbeans.api.visual.layout.SceneLayout;
import org.netbeans.api.visual.widget.ConnectionWidget;
import org.openide.util.Lookup;
/**
*
@ -61,13 +60,12 @@ import org.openide.util.Lookup;
public class ControlFlowScene extends GraphScene<InputBlock, InputBlockEdge> implements SelectProvider, MoveProvider, RectangularSelectDecorator, RectangularSelectProvider {
private HashSet<BlockWidget> selection;
private HashMap<InputBlock, BlockWidget> blockMap;
private InputGraph oldGraph;
private LayerWidget edgeLayer;
private LayerWidget mainLayer;
private LayerWidget selectLayer;
private WidgetAction hoverAction = this.createWidgetHoverAction();
private WidgetAction selectAction = ActionFactory.createSelectAction(this);
private WidgetAction selectAction = new DoubleClickSelectAction(this);
private WidgetAction moveAction = ActionFactory.createMoveAction(null, this);
public ControlFlowScene() {
@ -111,27 +109,21 @@ public class ControlFlowScene extends GraphScene<InputBlock, InputBlockEdge> imp
addNode(b);
}
for (InputBlock b : g.getBlocks()) {
for (InputBlockEdge e : b.getOutputs()) {
addEdge(e);
assert g.getBlocks().contains(e.getFrom());
assert g.getBlocks().contains(e.getTo());
this.setEdgeSource(e, e.getFrom());
this.setEdgeTarget(e, e.getTo());
}
for (InputBlockEdge e : g.getBlockEdges()) {
addEdge(e);
assert g.getBlocks().contains(e.getFrom());
assert g.getBlocks().contains(e.getTo());
this.setEdgeSource(e, e.getFrom());
this.setEdgeTarget(e, e.getTo());
}
GraphLayout layout = new HierarchicalGraphLayout();//GridGraphLayout();
GraphLayout<InputBlock, InputBlockEdge> layout = new HierarchicalGraphLayout<InputBlock, InputBlockEdge>();//GridGraphLayout();
SceneLayout sceneLayout = LayoutFactory.createSceneGraphLayout(this, layout);
sceneLayout.invokeLayout();
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 +133,7 @@ public class ControlFlowScene extends GraphScene<InputBlock, InputBlockEdge> imp
}
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<InputNode> inputNodes = new HashSet<InputNode>();
for (BlockWidget w : selection) {
@ -204,15 +196,19 @@ public class ControlFlowScene extends GraphScene<InputBlock, InputBlockEdge> imp
}
public void setNewLocation(Widget widget, Point location) {
Point originalLocation = getOriginalLocation(widget);
int xOffset = location.x - originalLocation.x;
int yOffset = location.y - originalLocation.y;
for (Widget w : this.selection) {
Point p = new Point(w.getPreferredLocation());
p.translate(xOffset, yOffset);
w.setPreferredLocation(p);
if (selection.contains(widget)) {
// move entire selection
Point originalLocation = getOriginalLocation(widget);
int xOffset = location.x - originalLocation.x;
int yOffset = location.y - originalLocation.y;
for (Widget w : selection) {
Point p = new Point(w.getPreferredLocation());
p.translate(xOffset, yOffset);
w.setPreferredLocation(p);
}
} else {
widget.setPreferredLocation(location);
}
}
public Widget createSelectionWidget() {
@ -271,7 +267,15 @@ public class ControlFlowScene extends GraphScene<InputBlock, InputBlockEdge> imp
}
protected Widget attachEdgeWidget(InputBlockEdge edge) {
ConnectionWidget w = new BlockConnectionWidget(this, edge);
BlockConnectionWidget w = new BlockConnectionWidget(this, edge);
switch (edge.getState()) {
case NEW:
w.setBold(true);
break;
case DELETED:
w.setDashed(true);
break;
}
w.setRouter(RouterFactory.createDirectRouter());
w.setTargetAnchorShape(AnchorShape.TRIANGLE_FILLED);
edgeLayer.addChild(w);

@ -3,6 +3,8 @@
<Form version="1.3" maxVersion="1.3" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -25,6 +25,7 @@ package com.sun.hotspot.igv.controlflow;
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;
@ -63,17 +64,7 @@ final class ControlFlowTopComponent extends TopComponent implements LookupListen
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 @@ final class ControlFlowTopComponent extends TopComponent implements LookupListen
}// </editor-fold>//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 @@ final class ControlFlowTopComponent extends TopComponent implements LookupListen
@Override
public void componentOpened() {
Lookup.Template tpl = new Lookup.Template(Object.class);
Lookup.Template<InputGraphProvider> tpl = new Lookup.Template<InputGraphProvider>(InputGraphProvider.class);
result = Utilities.actionsGlobalContext().lookup(tpl);
result.addLookupListener(this);
}
@ -143,16 +135,16 @@ final class ControlFlowTopComponent extends TopComponent implements LookupListen
}
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 @@ final class ControlFlowTopComponent extends TopComponent implements LookupListen
@Override
public void requestActive() {
scene.getView().requestFocusInWindow();
super.requestActive();
scene.getView().requestFocus();
}
final static class ResolvableHelper implements Serializable {

@ -0,0 +1,61 @@
/*
* Copyright (c) 2011, 2015, 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 java.awt.Point;
import java.awt.event.MouseEvent;
import org.netbeans.api.visual.action.SelectProvider;
import org.netbeans.api.visual.action.WidgetAction;
import org.netbeans.api.visual.widget.Widget;
/**
* Selection action that acts on double-click only. Does not support aiming.
*
* @author Peter Hofer
*/
public class DoubleClickSelectAction extends WidgetAction.LockedAdapter {
private final SelectProvider provider;
public DoubleClickSelectAction(SelectProvider provider) {
this.provider = provider;
}
protected boolean isLocked() {
return false;
}
@Override
public State mousePressed(Widget widget, WidgetMouseEvent event) {
if (event.getClickCount() >= 2 && (event.getButton() == MouseEvent.BUTTON1 || event.getButton() == MouseEvent.BUTTON2)) {
boolean invert = (event.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0;
Point point = event.getPoint();
if (provider.isSelectionAllowed(widget, point, invert)) {
provider.select(widget, point, invert);
return State.CHAIN_ONLY;
}
}
return State.REJECTED;
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -34,7 +34,7 @@ import java.awt.Point;
import java.util.ArrayList;
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;
@ -76,6 +76,10 @@ public class HierarchicalGraphLayout<N, E> extends GraphLayout<N, E> {
public void setControlPoints(List<Point> list) {
// Do nothing for now
}
public boolean isVIP() {
return false;
}
}
private class VertexWrapper implements Vertex {
@ -127,6 +131,7 @@ public class HierarchicalGraphLayout<N, E> extends GraphLayout<N, E> {
}
public int compareTo(Vertex o) {
@SuppressWarnings("unchecked")
VertexWrapper vw = (VertexWrapper) o;
return node.toString().compareTo(vw.node.toString());
}
@ -138,8 +143,8 @@ public class HierarchicalGraphLayout<N, E> extends GraphLayout<N, E> {
protected void performGraphLayout(UniversalGraph<N, E> graph) {
Set<LinkWrapper> links = new HashSet<LinkWrapper>();
Set<VertexWrapper> vertices = new HashSet<VertexWrapper>();
Set<LinkWrapper> links = new LinkedHashSet<LinkWrapper>();
Set<VertexWrapper> vertices = new LinkedHashSet<VertexWrapper>();
Map<N, VertexWrapper> vertexMap = new HashMap<N, VertexWrapper>();
for (N node : graph.getNodes()) {

@ -1,2 +1,2 @@
javac.source=1.5
javac.compilerargs=-Xlint -Xlint:-serial
javac.source=1.7
javac.compilerargs=-Xlint -Xlint:-serial

@ -1,126 +1,142 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.apisupport.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
<code-name-base>com.sun.hotspot.igv.coordinator</code-name-base>
<suite-component/>
<module-dependencies>
<dependency>
<code-name-base>com.sun.hotspot.igv.data</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>com.sun.hotspot.igv.difference</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>com.sun.hotspot.igv.settings</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>com.sun.hotspot.igv.util</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.api.progress</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>1.10.0.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.actions</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>6.6.1.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.awt</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>6.11.0.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.dialogs</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>7.5.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.explorer</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>6.11</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.filesystems</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>7.3</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.loaders</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>6.7</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.nodes</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>7.2.0.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.util</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>7.9.0.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.windows</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>6.16</specification-version>
</run-dependency>
</dependency>
</module-dependencies>
<public-packages/>
</data>
</configuration>
</project>
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
<type>org.netbeans.modules.apisupport.project</type>
<configuration>
<data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
<code-name-base>com.sun.hotspot.igv.coordinator</code-name-base>
<suite-component/>
<module-dependencies>
<dependency>
<code-name-base>com.sun.hotspot.igv.connection</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>com.sun.hotspot.igv.data</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>com.sun.hotspot.igv.difference</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>com.sun.hotspot.igv.settings</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>com.sun.hotspot.igv.util</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>1.0</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.netbeans.api.progress</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
<specification-version>1.23.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.actions</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>6.21.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.awt</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>7.30.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.dialogs</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>7.18.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.explorer</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>6.34.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.filesystems</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>7.46.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.loaders</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>7.20.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.nodes</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>7.20.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.util</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>8.14.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.util.lookup</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>8.6.1</specification-version>
</run-dependency>
</dependency>
<dependency>
<code-name-base>org.openide.windows</code-name-base>
<build-prerequisite/>
<compile-dependency/>
<run-dependency>
<specification-version>6.39.1</specification-version>
</run-dependency>
</dependency>
</module-dependencies>
<public-packages/>
</data>
</configuration>
</project>

@ -1,2 +0,0 @@
com.sun.hotspot.igv.coordinator.StandardGroupOrganizer
com.sun.hotspot.igv.coordinator.GraphCountGroupOrganizer

@ -1,7 +1,6 @@
AdvancedOption_DisplayName_Coordinator=Settings
AdvancedOption_Tooltip_Coordinator=Visualization Tool Settings
CTL_OutlineTopComponent=Outline Window
CTL_SomeAction=test
HINT_OutlineTopComponent=This is a Outline window
OpenIDE-Module-Name=Coordinator
AdvancedOption_DisplayName_Coordinator=Settings
AdvancedOption_Tooltip_Coordinator=Visualization Tool Settings
CTL_OutlineTopComponent=Outline
CTL_SomeAction=test
HINT_OutlineTopComponent=Displays loaded groups of graphs.
OpenIDE-Module-Name=Coordinator

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,18 +24,13 @@
package com.sun.hotspot.igv.coordinator;
import com.sun.hotspot.igv.coordinator.actions.RemoveCookie;
import com.sun.hotspot.igv.data.ChangedListener;
import com.sun.hotspot.igv.data.Group;
import com.sun.hotspot.igv.data.services.GroupOrganizer;
import com.sun.hotspot.igv.data.InputGraph;
import com.sun.hotspot.igv.data.Pair;
import com.sun.hotspot.igv.data.*;
import java.awt.Image;
import java.util.ArrayList;
import java.util.List;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.Node;
import org.openide.util.Utilities;
import org.openide.util.ImageUtilities;
import org.openide.util.lookup.AbstractLookup;
import org.openide.util.lookup.InstanceContent;
@ -45,107 +40,72 @@ import org.openide.util.lookup.InstanceContent;
*/
public class FolderNode extends AbstractNode {
private GroupOrganizer organizer;
private InstanceContent content;
private List<Pair<String, List<Group>>> structure;
private List<String> subFolders;
private FolderChildren children;
private static class FolderChildren extends Children.Keys implements ChangedListener<Group> {
private static class FolderChildren extends Children.Keys<FolderElement> implements ChangedListener {
private FolderNode parent;
private List<Group> registeredGroups;
private final Folder folder;
public void setParent(FolderNode parent) {
this.parent = parent;
this.registeredGroups = new ArrayList<Group>();
public FolderChildren(Folder folder) {
this.folder = folder;
folder.getChangedEvent().addListener(this);
}
@Override
protected Node[] createNodes(Object arg0) {
for(Group g : registeredGroups) {
g.getChangedEvent().removeListener(this);
}
registeredGroups.clear();
Pair<String, List<Group>> p = (Pair<String, List<Group>>) arg0;
if (p.getLeft().length() == 0) {
List<Node> curNodes = new ArrayList<Node>();
for (Group g : p.getRight()) {
for (InputGraph graph : g.getGraphs()) {
curNodes.add(new GraphNode(graph));
}
g.getChangedEvent().addListener(this);
registeredGroups.add(g);
}
Node[] result = new Node[curNodes.size()];
for (int i = 0; i < curNodes.size(); i++) {
result[i] = curNodes.get(i);
}
return result;
} else {
return new Node[]{new FolderNode(p.getLeft(), parent.organizer, parent.subFolders, p.getRight())};
protected Node[] createNodes(FolderElement e) {
if (e instanceof InputGraph) {
return new Node[]{new GraphNode((InputGraph) e)};
} else if (e instanceof Folder) {
return new Node[]{new FolderNode((Folder) e)};
} else {
return null;
}
}
@Override
public void addNotify() {
this.setKeys(parent.structure);
this.setKeys(folder.getElements());
}
public void changed(Group source) {
List<Pair<String, List<Group>>> newStructure = new ArrayList<Pair<String, List<Group>>>();
for(Pair<String, List<Group>> p : parent.structure) {
refreshKey(p);
}
}
}
protected InstanceContent getContent() {
return content;
@Override
public void changed(Object source) {
addNotify();
}
}
@Override
public Image getIcon(int i) {
return Utilities.loadImage("com/sun/hotspot/igv/coordinator/images/folder.gif");
return ImageUtilities.loadImage("com/sun/hotspot/igv/coordinator/images/folder.png");
}
protected FolderNode(String name, GroupOrganizer organizer, List<String> subFolders, List<Group> groups) {
this(name, organizer, subFolders, groups, new FolderChildren(), new InstanceContent());
protected FolderNode(Folder folder) {
this(folder, new FolderChildren(folder), new InstanceContent());
}
private FolderNode(String name, GroupOrganizer organizer, List<String> oldSubFolders, final List<Group> groups, FolderChildren children, InstanceContent content) {
private FolderNode(final Folder folder, FolderChildren children, InstanceContent content) {
super(children, new AbstractLookup(content));
children.setParent(this);
this.content = content;
this.children = children;
content.add(new RemoveCookie() {
public void remove() {
for (Group g : groups) {
if (g.getDocument() != null) {
g.getDocument().removeGroup(g);
}
if (folder instanceof FolderElement) {
final FolderElement folderElement = (FolderElement) folder;
this.setDisplayName(folderElement.getName());
content.add(new RemoveCookie() {
@Override
public void remove() {
folderElement.getParent().removeElement(folderElement);
}
}
});
init(name, organizer, oldSubFolders, groups);
});
}
}
public void init(String name, GroupOrganizer organizer, List<String> oldSubFolders, List<Group> groups) {
public void init(String name, List<Group> groups) {
this.setDisplayName(name);
this.organizer = organizer;
this.subFolders = new ArrayList<String>(oldSubFolders);
if (name.length() > 0) {
this.subFolders.add(name);
}
structure = organizer.organize(subFolders, groups);
assert structure != null;
children.addNotify();
for (Group g : groups) {
content.add(g);
}
}
@Override

@ -1,81 +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.coordinator;
import com.sun.hotspot.igv.data.Group;
import com.sun.hotspot.igv.data.Pair;
import com.sun.hotspot.igv.data.services.GroupOrganizer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
/**
*
* @author Thomas Wuerthinger
*/
public class GraphCountGroupOrganizer implements GroupOrganizer {
public String getName() {
return "Graph count structure";
}
public List<Pair<String, List<Group>>> organize(List<String> subFolders, List<Group> groups) {
List<Pair<String, List<Group>>> result = new ArrayList<Pair<String, List<Group>>>();
if (subFolders.size() == 0) {
Map<Integer, List<Group>> map = new HashMap<Integer, List<Group>>();
for (Group g : groups) {
Integer cur = g.getGraphs().size();
if (!map.containsKey(cur)) {
map.put(cur, new ArrayList<Group>());
}
map.get(cur).add(g);
}
SortedSet<Integer> keys = new TreeSet<Integer>(map.keySet());
for (Integer i : keys) {
result.add(new Pair<String, List<Group>>("Graph count " + i, map.get(i)));
}
} else if (subFolders.size() == 1) {
for (Group g : groups) {
List<Group> children = new ArrayList<Group>();
children.add(g);
Pair<String, List<Group>> p = new Pair<String, List<Group>>();
p.setLeft(g.getName());
p.setRight(children);
result.add(p);
}
} else if (subFolders.size() == 2) {
result.add(new Pair<String, List<Group>>("", groups));
}
return result;
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -23,23 +23,27 @@
*/
package com.sun.hotspot.igv.coordinator;
import com.sun.hotspot.igv.coordinator.actions.CloneGraphAction;
import com.sun.hotspot.igv.coordinator.actions.DiffGraphAction;
import com.sun.hotspot.igv.coordinator.actions.DiffGraphCookie;
import com.sun.hotspot.igv.coordinator.actions.RemoveCookie;
import com.sun.hotspot.igv.coordinator.actions.GraphCloneCookie;
import com.sun.hotspot.igv.coordinator.actions.GraphOpenCookie;
import com.sun.hotspot.igv.coordinator.actions.GraphRemoveCookie;
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;
import org.openide.actions.OpenAction;
import org.openide.cookies.OpenCookie;
import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children;
import org.openide.nodes.Node;
import org.openide.nodes.NodeAdapter;
import org.openide.nodes.NodeEvent;
import org.openide.nodes.NodeMemberEvent;
import org.openide.nodes.Sheet;
import org.openide.util.ImageUtilities;
import org.openide.util.Lookup;
import org.openide.util.Utilities;
import org.openide.util.lookup.AbstractLookup;
import org.openide.util.lookup.InstanceContent;
@ -48,7 +52,6 @@ import org.openide.util.lookup.InstanceContent;
* @author Thomas Wuerthinger
*/
public class GraphNode extends AbstractNode {
private InputGraph graph;
/** Creates a new instance of GraphNode */
@ -56,7 +59,7 @@ public class GraphNode extends AbstractNode {
this(graph, new InstanceContent());
}
private GraphNode(final InputGraph graph, InstanceContent content) {
private GraphNode(InputGraph graph, InstanceContent content) {
super(Children.LEAF, new AbstractLookup(content));
this.graph = graph;
this.setDisplayName(graph.getName());
@ -66,19 +69,22 @@ public class GraphNode extends AbstractNode {
if (viewer != null) {
// Action for opening the graph
content.add(new OpenCookie() {
public void open() {
viewer.view(graph);
}
});
content.add(new GraphOpenCookie(viewer, graph));
}
// Action for removing a graph
content.add(new RemoveCookie() {
content.add(new GraphRemoveCookie(graph));
public void remove() {
graph.getGroup().removeGraph(graph);
// Action for diffing to the current graph
content.add(new DiffGraphCookie(graph));
// Action for cloning to the current graph
content.add(new GraphCloneCookie(viewer, graph));
this.addNodeListener(new NodeAdapter() {
@Override
public void childrenRemoved(NodeMemberEvent ev) {
GraphNode.this.graph = null;
}
});
}
@ -86,13 +92,17 @@ public class GraphNode extends AbstractNode {
@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;
}
@Override
public Image getIcon(int i) {
return Utilities.loadImage("com/sun/hotspot/igv/coordinator/images/graph.gif");
return ImageUtilities.loadImage("com/sun/hotspot/igv/coordinator/images/graph.png");
}
@Override
@ -100,31 +110,29 @@ public class GraphNode extends AbstractNode {
return getIcon(i);
}
@Override
public <T extends Node.Cookie> T getCookie(Class<T> 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)};
return new Action[]{(Action) DiffGraphAction.findObject(DiffGraphAction.class, true), (Action) CloneGraphAction.findObject(CloneGraphAction.class, true), (Action) OpenAction.findObject(OpenAction.class, true)};
}
@Override
public Action getPreferredAction() {
return (Action) OpenAction.findObject(OpenAction.class, true);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof GraphNode) {
return (graph == ((GraphNode) obj).graph);
}
return false;
}
@Override
public int hashCode() {
return graph.hashCode();
}
}

@ -3,6 +3,8 @@
<Form version="1.2" maxVersion="1.2" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/>
@ -14,28 +16,17 @@
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel2">
<Container class="javax.swing.JScrollPane" name="treeView">
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new BeanTreeView();"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new BeanTreeView();"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout" value="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout$BorderConstraintsDescription">
<BorderConstraints direction="Center"/>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
</Container>
</SubComponents>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
</Container>
</SubComponents>
</Form>

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -23,37 +23,25 @@
*/
package com.sun.hotspot.igv.coordinator;
import com.sun.hotspot.igv.coordinator.actions.ImportAction;
import com.sun.hotspot.igv.coordinator.actions.RemoveAction;
import com.sun.hotspot.igv.coordinator.actions.RemoveAllAction;
import com.sun.hotspot.igv.coordinator.actions.SaveAllAction;
import com.sun.hotspot.igv.coordinator.actions.SaveAsAction;
import com.sun.hotspot.igv.coordinator.actions.StructuredViewAction;
import com.sun.hotspot.igv.connection.Server;
import com.sun.hotspot.igv.coordinator.actions.*;
import com.sun.hotspot.igv.data.GraphDocument;
import com.sun.hotspot.igv.data.ChangedListener;
import com.sun.hotspot.igv.data.Group;
import com.sun.hotspot.igv.data.services.GroupCallback;
import com.sun.hotspot.igv.data.services.GroupOrganizer;
import com.sun.hotspot.igv.data.services.GroupReceiver;
import java.awt.BorderLayout;
import java.awt.Component;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.border.Border;
import org.openide.ErrorManager;
import org.openide.actions.GarbageCollectAction;
import org.openide.awt.Toolbar;
import org.openide.awt.ToolbarPool;
import org.openide.explorer.ExplorerManager;
import org.openide.explorer.ExplorerUtils;
import org.openide.explorer.view.BeanTreeView;
import org.openide.util.Lookup;
import org.openide.util.LookupEvent;
import org.openide.util.LookupListener;
import org.openide.util.NbBundle;
@ -72,7 +60,8 @@ public final class OutlineTopComponent extends TopComponent implements ExplorerM
private ExplorerManager manager;
private GraphDocument document;
private FolderNode root;
private GroupOrganizer organizer;
private Server server;
private Server binaryServer;
private OutlineTopComponent() {
initComponents();
@ -88,17 +77,9 @@ public final class OutlineTopComponent extends TopComponent implements ExplorerM
private void initListView() {
manager = new ExplorerManager();
organizer = new StandardGroupOrganizer();
root = new FolderNode("", organizer, new ArrayList<String>(), document.getGroups());
root = new FolderNode(document);
manager.setRootContext(root);
((BeanTreeView) this.jScrollPane1).setRootVisible(false);
document.getChangedEvent().addListener(new ChangedListener<GraphDocument>() {
public void changed(GraphDocument document) {
updateStructure();
}
});
((BeanTreeView) this.treeView).setRootVisible(false);
associateLookup(ExplorerUtils.createLookup(manager, getActionMap()));
}
@ -111,61 +92,41 @@ public final class OutlineTopComponent extends TopComponent implements ExplorerM
this.add(toolbar, BorderLayout.NORTH);
toolbar.add(ImportAction.get(ImportAction.class));
toolbar.add(((NodeAction) RemoveAction.get(RemoveAction.class)).createContextAwareInstance(this.getLookup()));
toolbar.add(RemoveAllAction.get(RemoveAllAction.class));
toolbar.add(((NodeAction) SaveAsAction.get(SaveAsAction.class)).createContextAwareInstance(this.getLookup()));
toolbar.add(SaveAllAction.get(SaveAllAction.class));
toolbar.add(StructuredViewAction.get(StructuredViewAction.class).getToolbarPresenter());
toolbar.add(((NodeAction) RemoveAction.get(RemoveAction.class)).createContextAwareInstance(this.getLookup()));
toolbar.add(RemoveAllAction.get(RemoveAllAction.class));
toolbar.add(GarbageCollectAction.get(GarbageCollectAction.class).getToolbarPresenter());
for (Toolbar tb : ToolbarPool.getDefault().getToolbars()) {
tb.setVisible(false);
}
initOrganizers();
}
public void setOrganizer(GroupOrganizer organizer) {
this.organizer = organizer;
updateStructure();
}
private void initOrganizers() {
}
private void initReceivers() {
final GroupCallback callback = new GroupCallback() {
@Override
public void started(Group g) {
getDocument().addGroup(g);
synchronized(OutlineTopComponent.this) {
getDocument().addElement(g);
}
}
};
Collection<? extends GroupReceiver> receivers = Lookup.getDefault().lookupAll(GroupReceiver.class);
if (receivers.size() > 0) {
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
for (GroupReceiver r : receivers) {
Component c = r.init(callback);
panel.add(c);
}
jPanel2.add(panel, BorderLayout.PAGE_START);
}
}
private void updateStructure() {
root.init("", organizer, new ArrayList<String>(), document.getGroups());
server = new Server(getDocument(), callback, false);
binaryServer = new Server(getDocument(), callback, true);
}
public void clear() {
document.clear();
}
@Override
public ExplorerManager getExplorerManager() {
return manager;
}
@ -221,6 +182,25 @@ public final class OutlineTopComponent extends TopComponent implements ExplorerM
return PREFERRED_ID;
}
@Override
public void requestActive() {
super.requestActive();
treeView.requestFocus();
}
@Override
public boolean requestFocus(boolean temporary) {
treeView.requestFocus();
return super.requestFocus(temporary);
}
@Override
protected boolean requestFocusInWindow(boolean temporary) {
treeView.requestFocus();
return super.requestFocusInWindow(temporary);
}
@Override
public void resultChanged(LookupEvent lookupEvent) {
}
@ -228,7 +208,7 @@ public final class OutlineTopComponent extends TopComponent implements ExplorerM
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
@ -253,19 +233,13 @@ public final class OutlineTopComponent extends TopComponent implements ExplorerM
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
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);
add(jPanel2, java.awt.BorderLayout.CENTER);
add(treeView, java.awt.BorderLayout.CENTER);
}// </editor-fold>//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
}

@ -4,7 +4,7 @@
<Row>
<Toolbar name="Edit" position="1" visible="false"/>
<Toolbar name="File" position="1" visible="false" />
<Toolbar name="Memory" position="1" visible="false" />
<Toolbar name="Memory" position="1" visible="true" />
</Row>
<Row>
<Toolbar name="WorkspaceSwitcher" />

@ -1,62 +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.coordinator;
import com.sun.hotspot.igv.data.Group;
import com.sun.hotspot.igv.data.services.GroupOrganizer;
import com.sun.hotspot.igv.data.Pair;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author Thomas Wuerthinger
*/
public class StandardGroupOrganizer implements GroupOrganizer {
public String getName() {
return "-- None --";
}
public List<Pair<String, List<Group>>> organize(List<String> subFolders, List<Group> groups) {
List<Pair<String, List<Group>>> result = new ArrayList<Pair<String, List<Group>>>();
if (groups.size() == 1 && subFolders.size() > 0) {
result.add(new Pair<String, List<Group>>("", groups));
} else {
for (Group g : groups) {
List<Group> children = new ArrayList<Group>();
children.add(g);
Pair<String, List<Group>> p = new Pair<String, List<Group>>();
p.setLeft(g.getName());
p.setRight(children);
result.add(p);
}
}
return result;
}
}

@ -1,18 +1,10 @@
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_SaveAsAction=Save selected methods...
CTL_SaveAllAction=Save all...
CTL_SaveFilterSettingsAction=Save filter settings...
CTL_PropertiesAction=Open Properties Window
CTL_RemoveAction=Remove selected graphs and groups
CTL_RemoveAllAction=Remove all graphs and groups
CTL_OutlineAction=Outline
CTL_SaveAsAction=Save selected groups...
CTL_SaveAllAction=Save all groups...
CTL_PropertiesAction=Open Properties Window
CTL_NewFilterAction=New filter...

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 2015, 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
@ -21,35 +21,62 @@
* questions.
*
*/
package com.sun.hotspot.igv.view.actions;
import com.sun.hotspot.igv.view.EditorTopComponent;
import javax.swing.Action;
package com.sun.hotspot.igv.coordinator.actions;
import org.openide.nodes.Node;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.actions.CallableSystemAction;
import org.openide.util.actions.CookieAction;
/**
*
* @author Thomas Wuerthinger
*/
public final class NodeFindAction extends CallableSystemAction {
public final class CloneGraphAction extends CookieAction {
public void performAction() {
EditorTopComponent comp = EditorTopComponent.getActive();
if (comp != null) {
comp.findNode();
@Override
protected void performAction(Node[] activatedNodes) {
GraphCloneCookie c = activatedNodes[0].getCookie(GraphCloneCookie.class);
assert c != null;
c.openClone();
}
@Override
protected int mode() {
return CookieAction.MODE_EXACTLY_ONE;
}
@Override
protected boolean enable(Node[] activatedNodes) {
boolean b = super.enable(activatedNodes);
if (b) {
assert activatedNodes.length == 1;
GraphCloneCookie c = activatedNodes[0].getCookie(GraphCloneCookie.class);
assert c != null;
return true;
}
return false;
}
public NodeFindAction() {
putValue(Action.SHORT_DESCRIPTION, "Find nodes");
}
@Override
public String getName() {
return NbBundle.getMessage(NodeFindAction.class, "CTL_NodeFindAction");
return "Open clone";
}
@Override
protected Class<?>[] cookieClasses() {
return new Class<?>[]{
GraphCloneCookie.class
};
}
@Override
protected String iconResource() {
return "com/sun/hotspot/igv/coordinator/images/graph.png";
}
@Override
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}
@ -58,14 +85,5 @@ public final class NodeFindAction extends CallableSystemAction {
protected boolean asynchronous() {
return false;
}
@Override
public boolean isEnabled() {
return true;
}
@Override
protected String iconResource() {
return "com/sun/hotspot/igv/view/images/search.gif";
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -35,30 +35,49 @@ import org.openide.util.actions.CookieAction;
*/
public final class DiffGraphAction extends CookieAction {
@Override
protected void performAction(Node[] activatedNodes) {
DiffGraphCookie c = activatedNodes[0].getCookie(DiffGraphCookie.class);
assert c != null;
c.openDiff();
}
@Override
protected int mode() {
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;
}
@Override
public String getName() {
return NbBundle.getMessage(DiffGraphAction.class, "CTL_DiffGraphAction");
}
protected Class[] cookieClasses() {
return new Class[]{
@Override
protected Class<?>[] cookieClasses() {
return new Class<?>[]{
DiffGraphCookie.class
};
}
@Override
protected String iconResource() {
return "com/sun/hotspot/igv/coordinator/images/diff.gif";
return "com/sun/hotspot/igv/coordinator/images/diff.png";
}
@Override
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}
@ -68,3 +87,4 @@ public final class DiffGraphAction extends CookieAction {
return false;
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -21,12 +21,13 @@
* questions.
*
*/
package com.sun.hotspot.igv.coordinator.actions;
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;
@ -36,21 +37,30 @@ import org.openide.util.Lookup;
*/
public class DiffGraphCookie implements Node.Cookie {
private InputGraph a;
private InputGraph b;
private InputGraph graph;
public DiffGraphCookie(InputGraph a, InputGraph b) {
this.a = a;
this.b = b;
public DiffGraphCookie(InputGraph graph) {
this.graph = graph;
}
private InputGraph getCurrentGraph() {
InputGraphProvider graphProvider = LookupHistory.getLast(InputGraphProvider.class);
if (graphProvider != null) {
return graphProvider.getGraph();
}
return null;
}
public boolean isPossible() {
return getCurrentGraph() != null;
}
public void openDiff() {
InputGraph other = getCurrentGraph();
final GraphViewer viewer = Lookup.getDefault().lookup(GraphViewer.class);
if(viewer != null) {
InputGraph diffGraph = Difference.createDiffGraph(a, b);
viewer.view(diffGraph);
if (viewer != null) {
InputGraph diffGraph = Difference.createDiffGraph(other, graph);
viewer.view(diffGraph, true);
}
}
}

@ -0,0 +1,43 @@
/*
* Copyright (c) 2013, 2015, 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.coordinator.actions;
import com.sun.hotspot.igv.data.InputGraph;
import com.sun.hotspot.igv.data.services.GraphViewer;
import org.openide.nodes.Node;
public class GraphCloneCookie implements Node.Cookie {
private final GraphViewer viewer;
private final InputGraph graph;
public GraphCloneCookie(GraphViewer viewer, InputGraph graph) {
this.viewer = viewer;
this.graph = graph;
}
public void openClone() {
viewer.view(graph, true);
}
}

@ -0,0 +1,44 @@
/*
* Copyright (c) 2011, 2015, 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.coordinator.actions;
import com.sun.hotspot.igv.data.InputGraph;
import com.sun.hotspot.igv.data.services.GraphViewer;
import org.openide.cookies.OpenCookie;
public class GraphOpenCookie implements OpenCookie {
private final GraphViewer viewer;
private final InputGraph graph;
public GraphOpenCookie(GraphViewer viewer, InputGraph graph) {
this.viewer = viewer;
this.graph = graph;
}
@Override
public void open() {
viewer.view(graph, false);
}
}

@ -0,0 +1,39 @@
/*
* Copyright (c) 2011, 2015, 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.coordinator.actions;
import com.sun.hotspot.igv.data.InputGraph;
public class GraphRemoveCookie implements RemoveCookie {
private final InputGraph graph;
public GraphRemoveCookie(InputGraph graph) {
this.graph = graph;
}
@Override
public void remove() {
graph.getGroup().removeElement(graph);
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -26,51 +26,54 @@ package com.sun.hotspot.igv.coordinator.actions;
import com.sun.hotspot.igv.coordinator.OutlineTopComponent;
import com.sun.hotspot.igv.data.GraphDocument;
import com.sun.hotspot.igv.data.serialization.BinaryParser;
import com.sun.hotspot.igv.data.serialization.GraphParser;
import com.sun.hotspot.igv.data.serialization.ParseMonitor;
import com.sun.hotspot.igv.data.serialization.Parser;
import com.sun.hotspot.igv.settings.Settings;
import com.sun.hotspot.igv.data.serialization.XMLParser;
import java.awt.event.InputEvent;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.channels.FileChannel;
import java.nio.file.StandardOpenOption;
import javax.swing.Action;
import javax.swing.JFileChooser;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.filechooser.FileFilter;
import org.netbeans.api.progress.ProgressHandle;
import org.netbeans.api.progress.ProgressHandleFactory;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.util.Exceptions;
import org.openide.util.HelpCtx;
import org.openide.util.NbBundle;
import org.openide.util.RequestProcessor;
import org.openide.util.actions.CallableSystemAction;
import org.openide.xml.XMLUtil;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
/**
*
* @author Thomas Wuerthinger
*/
public final class ImportAction extends CallableSystemAction {
private static final int WORKUNITS = 10000;
public static FileFilter getFileFilter() {
return new FileFilter() {
@Override
public boolean accept(File f) {
return f.getName().toLowerCase().endsWith(".xml") || f.isDirectory();
return f.getName().toLowerCase().endsWith(".xml") || f.getName().toLowerCase().endsWith(".bgv") || f.isDirectory();
}
@Override
public String getDescription() {
return "XML files (*.xml)";
return "Graph files (*.xml, *.bgv)";
}
};
}
@Override
public void performAction() {
JFileChooser fc = new JFileChooser();
@ -86,84 +89,79 @@ public final class ImportAction extends CallableSystemAction {
}
Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath());
try {
final XMLReader reader = XMLUtil.createXMLReader();
final FileInputStream inputStream = new FileInputStream(file);
final InputSource is = new InputSource(inputStream);
final FileChannel channel = FileChannel.open(file.toPath(), StandardOpenOption.READ);
final ProgressHandle handle = ProgressHandleFactory.createHandle("Opening file " + file.getName());
final int basis = 1000;
handle.start(basis);
final int start = inputStream.available();
final XMLParser.ParseMonitor parseMonitor = new XMLParser.ParseMonitor() {
public void setProgress(double d) {
handle.start(WORKUNITS);
final long start = channel.size();
ParseMonitor monitor = new ParseMonitor() {
@Override
public void updateProgress() {
try {
int curAvailable = inputStream.available();
int prog = (int) (basis * (double) (start - curAvailable) / (double) start);
int prog = (int) (WORKUNITS * (double) channel.position() / (double) start);
handle.progress(prog);
} catch (IOException ex) {
}
}
@Override
public void setState(String state) {
setProgress(0.0);
updateProgress();
handle.progress(state);
}
};
final Parser parser = new Parser();
final GraphParser parser;
final OutlineTopComponent component = OutlineTopComponent.findInstance();
component.requestActive();
if (file.getName().endsWith(".xml")) {
parser = new Parser(channel, monitor, null);
} else if (file.getName().endsWith(".bgv")) {
parser = new BinaryParser(channel, monitor, component.getDocument(), null);
} else {
parser = null;
}
RequestProcessor.getDefault().post(new Runnable() {
@Override
public void run() {
GraphDocument document = null;
try {
document = parser.parse(reader, is, parseMonitor);
parseMonitor.setState("Finishing");
component.getDocument().addGraphDocument(document);
} catch (SAXException ex) {
String s = "Exception during parsing the XML file, could not load document!";
if (ex instanceof XMLParser.MissingAttributeException) {
XMLParser.MissingAttributeException e = (XMLParser.MissingAttributeException) ex;
s += "\nMissing attribute \"" + e.getAttributeName() + "\"";
final GraphDocument document = parser.parse();
if (document != null) {
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run() {
component.requestActive();
component.getDocument().addGraphDocument(document);
}
});
}
ex.printStackTrace();
NotifyDescriptor d = new NotifyDescriptor.Message(s, NotifyDescriptor.ERROR_MESSAGE);
DialogDisplayer.getDefault().notify(d);
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
handle.finish();
}
});
} catch (SAXException ex) {
ex.printStackTrace();
} catch (FileNotFoundException ex) {
ex.printStackTrace();
Exceptions.printStackTrace(ex);
} catch (IOException ex) {
ex.printStackTrace();
Exceptions.printStackTrace(ex);
}
}
}
@Override
public String getName() {
return NbBundle.getMessage(ImportAction.class, "CTL_ImportAction");
}
public ImportAction() {
putValue(Action.SHORT_DESCRIPTION, "Open an XML graph document");
putValue(Action.SHORT_DESCRIPTION, "Open XML graph document...");
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O, InputEvent.CTRL_MASK));
}
@Override
protected String iconResource() {
return "com/sun/hotspot/igv/coordinator/images/import.gif";
return "com/sun/hotspot/igv/coordinator/images/import.png";
}
@Override
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,7 +24,7 @@
package com.sun.hotspot.igv.coordinator.actions;
import com.sun.hotspot.igv.coordinator.*;
import com.sun.hotspot.igv.coordinator.OutlineTopComponent;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import org.openide.util.NbBundle;
@ -40,6 +40,7 @@ public class OutlineAction extends AbstractAction {
super(NbBundle.getMessage(OutlineAction.class, "CTL_OutlineAction"));
}
@Override
public void actionPerformed(ActionEvent evt) {
TopComponent win = OutlineTopComponent.findInstance();
win.open();

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -36,6 +36,7 @@ import org.openide.util.actions.NodeAction;
*/
public final class RemoveAction extends NodeAction {
@Override
protected void performAction(Node[] activatedNodes) {
for (Node n : activatedNodes) {
RemoveCookie removeCookie = n.getCookie(RemoveCookie.class);
@ -46,18 +47,20 @@ public final class RemoveAction extends NodeAction {
}
public RemoveAction() {
putValue(Action.SHORT_DESCRIPTION, "Remove");
putValue(Action.SHORT_DESCRIPTION, "Remove selected graphs and groups");
}
@Override
public String getName() {
return NbBundle.getMessage(RemoveAction.class, "CTL_RemoveAction");
}
@Override
protected String iconResource() {
return "com/sun/hotspot/igv/coordinator/images/remove.gif";
return "com/sun/hotspot/igv/coordinator/images/remove.png";
}
@Override
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}
@ -67,6 +70,7 @@ public final class RemoveAction extends NodeAction {
return false;
}
@Override
protected boolean enable(Node[] nodes) {
return nodes.length > 0;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2015, 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
@ -40,20 +40,22 @@ import org.openide.util.actions.CallableSystemAction;
public final class RemoveAllAction extends CallableSystemAction {
@Override
public String getName() {
return NbBundle.getMessage(RemoveAllAction.class, "CTL_ImportAction");
return NbBundle.getMessage(RemoveAllAction.class, "CTL_RemoveAllAction");
}
public RemoveAllAction() {
putValue(Action.SHORT_DESCRIPTION, "Remove all methods");
putValue(Action.SHORT_DESCRIPTION, "Remove all graphs and groups");
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_SHIFT, InputEvent.CTRL_MASK));
}
@Override
protected String iconResource() {
return "com/sun/hotspot/igv/coordinator/images/removeall.gif";
return "com/sun/hotspot/igv/coordinator/images/removeall.png";
}
@Override
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2015, 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

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2015, 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
@ -39,17 +39,19 @@ import org.openide.util.actions.CallableSystemAction;
*/
public final class SaveAllAction extends CallableSystemAction {
@Override
public void performAction() {
final OutlineTopComponent component = OutlineTopComponent.findInstance();
SaveAsAction.save(component.getDocument());
}
@Override
public String getName() {
return NbBundle.getMessage(SaveAllAction.class, "CTL_SaveAllAction");
}
public SaveAllAction() {
putValue(Action.SHORT_DESCRIPTION, "Save all methods to XML file");
putValue(Action.SHORT_DESCRIPTION, "Save all groups to XML file...");
putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S, InputEvent.CTRL_MASK));
}
@ -58,6 +60,7 @@ public final class SaveAllAction extends CallableSystemAction {
return "com/sun/hotspot/igv/coordinator/images/saveall.gif";
}
@Override
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -28,12 +28,8 @@ import com.sun.hotspot.igv.data.GraphDocument;
import com.sun.hotspot.igv.data.Group;
import com.sun.hotspot.igv.data.serialization.Printer;
import com.sun.hotspot.igv.settings.Settings;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.io.*;
import javax.swing.Action;
import javax.swing.JFileChooser;
import org.openide.nodes.Node;
import org.openide.util.HelpCtx;
@ -47,12 +43,17 @@ import org.openide.util.actions.NodeAction;
*/
public final class SaveAsAction extends NodeAction {
public SaveAsAction() {
putValue(Action.SHORT_DESCRIPTION, "Save selected groups to XML file...");
}
@Override
protected void performAction(Node[] activatedNodes) {
GraphDocument doc = new GraphDocument();
for (Node n : activatedNodes) {
Group group = n.getLookup().lookup(Group.class);
doc.addGroup(group);
doc.addElement(group);
}
save(doc);
@ -75,10 +76,10 @@ public final class SaveAsAction extends NodeAction {
}
Settings.get().put(Settings.DIRECTORY, dir.getAbsolutePath());
try {
Writer writer = new OutputStreamWriter(new FileOutputStream(file));
Printer p = new Printer();
p.export(writer, doc);
writer.close();
try (Writer writer = new OutputStreamWriter(new FileOutputStream(file))) {
Printer p = new Printer();
p.export(writer, doc);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
@ -92,15 +93,17 @@ public final class SaveAsAction extends NodeAction {
return CookieAction.MODE_SOME;
}
@Override
public String getName() {
return NbBundle.getMessage(SaveAsAction.class, "CTL_SaveAsAction");
}
@Override
protected String iconResource() {
return "com/sun/hotspot/igv/coordinator/images/save.gif";
return "com/sun/hotspot/igv/coordinator/images/save.png";
}
@Override
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}
@ -110,6 +113,7 @@ public final class SaveAsAction extends NodeAction {
return false;
}
@Override
protected boolean enable(Node[] nodes) {
int cnt = 0;

@ -1,180 +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.coordinator.actions;
import com.sun.hotspot.igv.coordinator.OutlineTopComponent;
import com.sun.hotspot.igv.data.services.GroupOrganizer;
import java.awt.Component;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.Action;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import org.openide.awt.DropDownButtonFactory;
import org.openide.util.HelpCtx;
import org.openide.util.Lookup;
import org.openide.util.Utilities;
import org.openide.util.actions.CallableSystemAction;
public class StructuredViewAction extends CallableSystemAction {
private static JButton dropDownButton;
private static ButtonGroup buttonGroup;
private static JPopupMenu popup;
private MyMenuItemListener menuItemListener;
private Map<JMenuItem, GroupOrganizer> map;
public StructuredViewAction() {
putValue(Action.SHORT_DESCRIPTION, "Cluster nodes into blocks");
}
@Override
public Component getToolbarPresenter() {
Image iconImage = Utilities.loadImage("com/sun/hotspot/igv/coordinator/images/structure.gif");
ImageIcon icon = new ImageIcon(iconImage);
popup = new JPopupMenu();
menuItemListener = new MyMenuItemListener();
buttonGroup = new ButtonGroup();
Collection<? extends GroupOrganizer> organizersCollection = Lookup.getDefault().lookupAll(GroupOrganizer.class);
List<GroupOrganizer> organizers = new ArrayList<GroupOrganizer>(organizersCollection);
Collections.sort(organizers, new Comparator<GroupOrganizer>() {
public int compare(GroupOrganizer a, GroupOrganizer b) {
return a.getName().compareTo(b.getName());
}
});
map = new HashMap<JMenuItem, GroupOrganizer>();
boolean first = true;
for(GroupOrganizer organizer : organizers) {
JCheckBoxMenuItem item = new JCheckBoxMenuItem(organizer.getName());
map.put(item, organizer);
item.addActionListener(menuItemListener);
buttonGroup.add(item);
popup.add(item);
if(first) {
item.setSelected(true);
first = false;
}
}
dropDownButton = DropDownButtonFactory.createDropDownButton(
new ImageIcon(
new BufferedImage(32, 32, BufferedImage.TYPE_BYTE_GRAY)),
popup);
dropDownButton.setIcon(icon);
dropDownButton.setToolTipText("Insert Layer Registration");
dropDownButton.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
int state = e.getStateChange();
if (state == ItemEvent.SELECTED) {
performAction();
}
}
});
dropDownButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
performAction();
}
});
popup.addPopupMenuListener(new PopupMenuListener() {
public void popupMenuCanceled(PopupMenuEvent e) {
dropDownButton.setSelected(false);
}
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
dropDownButton.setSelected(false);
}
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
dropDownButton.setSelected(true);
}
});
return dropDownButton;
}
private class MyMenuItemListener implements ActionListener {
public void actionPerformed(ActionEvent ev) {
JMenuItem item = (JMenuItem) ev.getSource();
GroupOrganizer organizer = map.get(item);
assert organizer != null : "Organizer must exist!";
OutlineTopComponent.findInstance().setOrganizer(organizer);
}
}
@Override
public void performAction() {
popup.show(dropDownButton, 0, dropDownButton.getHeight());
}
public String getName() {
return "Structured View";
}
public HelpCtx getHelpCtx() {
return HelpCtx.DEFAULT_HELP;
}
@Override
protected boolean asynchronous() {
return false;
}
}

@ -4,12 +4,8 @@
<kind type="view" />
<state type="joined" />
<constraints>
<path orientation="horizontal" number="0" weight="0.779245283018868"/>
<path orientation="vertical" number="0" weight="0.7511825922421949"/>
<path orientation="horizontal" number="0" weight="0.5"/>
<path orientation="vertical" number="20" weight="0.7"/>
<path orientation="horizontal" number="40" weight="0.55"/>
<path orientation="horizontal" number="0" weight="0.2711864406779661"/>
<path orientation="horizontal" number="0" weight="0.2"/>
<path orientation="vertical" number="0" weight="0.75"/>
</constraints>
<bounds x="0" y="0" width="0" height="0" />
<frame state="0"/>

Binary file not shown.

Before

(image error) Size: 252 B

After

(image error) Size: 634 B

@ -1,110 +1,194 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.2//EN" "http://www.netbeans.org/dtds/filesystem-1_2.dtd">
<filesystem>
<attr name="Actions\Edit\com-sun-hotspot-igv-bytecodes-SelectBytecodesAction.instance\position" intvalue="200"/>
<attr name="Actions\Edit\org-netbeans-core-ui-sysopen-SystemOpenAction.instance\position" intvalue="100"/>
<attr name="Actions\Edit\org-openide-actions-CopyAction.instance\position" intvalue="1300"/>
<attr name="Actions\Edit\org-openide-actions-CutAction.instance\position" intvalue="1400"/>
<attr name="Actions\Edit\org-openide-actions-DeleteAction.instance\position" intvalue="1500"/>
<attr name="Actions\Edit\org-openide-actions-FindAction.instance\position" intvalue="1600"/>
<attr name="Actions\Edit\org-openide-actions-GotoAction.instance\position" intvalue="1700"/>
<attr name="Actions\Edit\org-openide-actions-PasteAction.instance\position" intvalue="1800"/>
<attr name="Actions\Edit\org-openide-actions-RedoAction.instance\position" intvalue="1900"/>
<attr name="Actions\Edit\org-openide-actions-ReplaceAction.instance\position" intvalue="2000"/>
<attr name="Actions\Edit\org-openide-actions-UndoAction.instance\position" intvalue="2100"/>
<folder name="Actions">
<folder name="File">
<file name="com-sun-hotspot-igv-coordinator-actions-SaveAsAction.instance">
<attr name="position" intvalue="700"/>
</file>
<file name="com-sun-hotspot-igv-coordinator-actions-SaveAllAction.instance">
<attr name="position" intvalue="800"/>
</file>
<file name="com-sun-hotspot-igv-coordinator-actions-ImportAction.instance">
<attr name="position" intvalue="1000"/>
</file>
<file name="com-sun-hotspot-igv-coordinator-actions-SaveAsAction.instance"/>
<file name="com-sun-hotspot-igv-coordinator-actions-SaveAllAction.instance"/>
<file name="com-sun-hotspot-igv-coordinator-actions-ImportAction.instance"/>
</folder>
<folder name="Edit">
<file name="com-sun-hotspot-igv-coordinator-actions-RemoveAction.instance">
<attr name="position" intvalue="1200"/>
</file>
<file name="com-sun-hotspot-igv-coordinator-actions-RemoveAction.instance"/>
<file name="com-sun-hotspot-igv-coordinator-actions-RemoveAllAction.instance"/>
</folder>
<folder name="Window">
<file name="com-sun-hotspot-igv-coordinator-actions-OutlineAction.instance"/>
</folder>
</folder>
<folder name="Menu">
<folder name="File">
<file name="Separator2.instance_hidden"/>
<file name="Separator3.instance_hidden"/>
<file name="SeparatorOpen.instance_hidden"/>
<file name="com-sun-hotspot-igv-coordinator-actions-ImportAction.shadow">
<attr name="originalFile" stringvalue="Actions/File/com-sun-hotspot-igv-coordinator-actions-ImportAction.instance"/>
<attr name="position" intvalue="100"/>
</file>
<file name="MySeparator2.instance">
<file name="SeparatorSave.instance">
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
<attr name="position" intvalue="300"/>
<attr name="position" intvalue="150"/>
</file>
<file name="com-sun-hotspot-igv-coordinator-actions-SaveAsAction.shadow">
<attr name="originalFile" stringvalue="Actions/File/com-sun-hotspot-igv-coordinator-actions-SaveAsAction.instance"/>
<attr name="position" intvalue="300"/>
<attr name="position" intvalue="200"/>
</file>
<file name="com-sun-hotspot-igv-coordinator-actions-SaveAllAction.shadow">
<attr name="originalFile" stringvalue="Actions/File/com-sun-hotspot-igv-coordinator-actions-SaveAllAction.instance"/>
<attr name="position" intvalue="400"/>
<attr name="position" intvalue="300"/>
</file>
<file name="MySeparator3.instance">
<file name="SeparatorRemove.instance">
<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
<attr name="position" intvalue="500"/>
</file>
<file name="org-netbeans-modules-openfile-OpenFileAction.instance_hidden"/>
<file name="org-openide-actions-PageSetupAction.instance_hidden"/>
<file name="org-openide-actions-PrintAction.instance_hidden"/>
<file name="org-openide-actions-SaveAction.instance_hidden"/>
<file name="org-openide-actions-SaveAllAction.instance_hidden"/>
<file name="org-openide-actions-SaveAsAction.shadow_hidden"/>
</folder>
<folder name="Edit">
<file name="com-sun-hotspot-igv-coordinator-actions-SaveFilterSettingsAction.shadow">
<attr name="originalFile" stringvalue="Actions/Edit/com-sun-hotspot-igv-coordinator-actions-SaveFilterSettingsAction.instance"/>
<attr name="position" intvalue="350"/>
</file>
<file name="com-sun-hotspot-igv-coordinator-actions-RemoveAction.shadow">
<attr name="originalFile" stringvalue="Actions/Edit/com-sun-hotspot-igv-coordinator-actions-RemoveAction.instance"/>
<attr name="position" intvalue="400" />
</file>
<file name="org-netbeans-core-actions-JumpNextAction.shadow_hidden"/>
<file name="org-netbeans-core-actions-JumpPrevAction.shadow_hidden"/>
<file name="org-openide-actions-CutAction.instance_hidden"/>
<file name="org-openide-actions-CopyAction.instance_hidden"/>
<file name="org-openide-actions-PasteAction.instance_hidden"/>
<file name="org-openide-actions-DeleteAction.instance_hidden"/>
<file name="org-openide-actions-FindAction.instance_hidden"/>
<file name="org-openide-actions-ReplaceAction.instance_hidden"/>
<file name="org-openide-actions-JumpNextAction.shadow_hidden"/>
<file name="org-openide-actions-JumpPrevAction.shadow_hidden"/>
<file name="com-sun-hotspot-igv-coordinator-actions-RemoveAllAction.shadow">
<attr name="originalFile" stringvalue="Actions/Edit/com-sun-hotspot-igv-coordinator-actions-RemoveAllAction.instance"/>
<attr name="position" intvalue="500" />
</file>
<!-- Hidden menu entries from other modules -->
<file name="org-netbeans-modules-editor-ExportHtmlAction.shadow_hidden"/>
<file name="org-netbeans-modules-openfile-OpenFileAction.shadow_hidden"/>
<file name="org-netbeans-modules-openfile-RecentFileAction.shadow_hidden"/>
<file name="org-netbeans-modules-print-action-PageSetupAction.shadow_hidden"/>
<file name="org-netbeans-modules-print-action-PrintAction.shadow_hidden"/>
<file name="org-netbeans-modules-project-ui-CloseProject.shadow_hidden"/>
<file name="org-netbeans-modules-project-ui-CustomizeProject.shadow_hidden"/>
<file name="org-netbeans-modules-project-ui-NewFile.shadow_hidden"/>
<file name="org-netbeans-modules-project-ui-NewProject.shadow_hidden"/>
<file name="org-netbeans-modules-project-ui-OpenProject.shadow_hidden"/>
<file name="org-netbeans-modules-project-ui-RecentProjects.shadow_hidden"/>
<file name="org-netbeans-modules-project-ui-groups-GroupsMenu.shadow_hidden"/>
<file name="org-openide-actions-SaveAction.shadow_hidden"/>
<file name="org-openide-actions-SaveAllAction.shadow_hidden"/>
<file name="org-openide-actions-SaveAsAction.shadow_hidden"/>
</folder>
<file name="GoTo_hidden"/>
<folder name="View">
<folder name="Edit">
<!-- Hidden menu entries from other modules -->
<file name="Separator1.instance_hidden"/>
<file name="Separator2.instance_hidden"/>
<file name="org-netbeans-core-actions-HTMLViewAction.instance_hidden"/>
<file name="org-netbeans-core-actions-LogAction.instance_hidden"/>
<file name="org-netbeans-core-windows-actions-ToolbarsListAction.instance_hidden"/>
<file name="SeparatorAfterFindPrevious.instance_hidden"/>
<file name="SeparatorAfterProjectsSearch.instance_hidden"/>
<file name="WhereUsedAction.shadow_hidden"/>
<file name="org-netbeans-modules-editor-MainMenuAction$FindNextAction.instance_hidden"/>
<file name="org-netbeans-modules-editor-MainMenuAction$FindPreviousAction.instance_hidden"/>
<file name="org-netbeans-modules-editor-MainMenuAction$FindSelectionAction.instance_hidden"/>
<file name="org-netbeans-modules-editor-MainMenuAction$PasteFormattedAction.instance_hidden"/>
<file name="org-netbeans-modules-editor-MainMenuAction$SelectAllAction.instance_hidden"/>
<file name="org-netbeans-modules-editor-MainMenuAction$SelectIdentifierAction.instance_hidden"/>
<file name="org-netbeans-modules-editor-MainMenuAction$StartMacroRecordingAction.instance_hidden"/>
<file name="org-netbeans-modules-editor-MainMenuAction$StopMacroRecordingAction.instance_hidden"/>
<file name="org-netbeans-modules-search-FindInFilesAction.shadow_hidden"/>
<file name="org-netbeans-modules-search-ReplaceInFilesAction.shadow_hidden"/>
<file name="org-openide-actions-CopyAction.shadow_hidden"/>
<file name="org-openide-actions-CutAction.shadow_hidden"/>
<file name="org-openide-actions-DeleteAction.shadow_hidden"/>
<file name="org-openide-actions-FindAction.shadow_hidden"/>
<file name="org-openide-actions-PasteAction.shadow_hidden"/>
<file name="org-openide-actions-ReplaceAction.shadow_hidden"/>
<file name="sep-before-reposearch.instance_hidden"/>
</folder>
<folder name="View">
<!-- Hidden menu entries from other modules -->
<file name="Separator1.instance_hidden"/>
<file name="Separator2.instance_hidden"/>
<file name="org-netbeans-core-actions-HTMLViewAction.shadow_hidden"/>
<file name="org-netbeans-core-actions-LogAction.shadow_hidden"/>
<file name="org-netbeans-core-multiview-EditorsAction.instance_hidden"/>
<file name="org-netbeans-core-windows-actions-ToolbarsListAction.instance_hidden"/>
<file name="org-netbeans-modules-editor-NbCodeFoldingAction.instance_hidden"/>
<file name="org-netbeans-modules-project-ui-SyncEditorWithViewsAction.shadow_hidden"/>
<file name="org-netbeans-modules-versioning-ShowTextAnnotationsAction.shadow_hidden"/>
<file name="org-netbeans-modules-versioning-diff-ShowDiffSidebarAction.shadow_hidden"/>
<file name="toggle-line-numbers.shadow_hidden"/>
<file name="toggle-non-printable-characters.shadow_hidden"/>
<file name="toggle-toolbar.shadow_hidden"/>
</folder>
<!-- Hidden menus -->
<folder name="GoTo_hidden"/>
<folder name="Source_hidden"/>
<folder name="Refactoring_hidden"/>
<folder name="BuildProject_hidden"/>
<folder name="RunProject_hidden"/>
<folder name="Versioning_hidden"/>
<folder name="Tools">
<!-- Hidden menu entries from other modules -->
<file name="LibrariesCustomizerAction.shadow_hidden"/>
<file name="PaletteManager_hidden"/>
<file name="Separator1.instance_hidden"/>
<file name="Separator2.instance_hidden"/>
<file name="ServerManagerAction3.shadow_hidden"/>
<file name="VariablesCustomizerAction.shadow_hidden"/>
<file name="org-netbeans-modules-autoupdate-ui-actions-PluginManagerAction.shadow_hidden"/>
<file name="org-netbeans-modules-favorites-templates-TemplatesAction.shadow_hidden"/>
<file name="org-netbeans-modules-options-OptionsWindowAction-separatorBefore.instance_hidden"/>
<file name="org-netbeans-modules-xml-catalog-CatalogAction.shadow_hidden"/>
<file name="org-openide-actions-ToolsAction.shadow_hidden"/>
</folder>
<folder name="Window">
<file name="OutlineAction.shadow">
<attr name="originalFile" stringvalue="Actions/Window/com-sun-hotspot-igv-coordinator-actions-OutlineAction.instance"/>
</file>
<!-- Hidden menu entries from other modules -->
<file name="Debug_hidden"/>
<file name="Navigator_hidden"/>
<file name="Other_hidden"/>
<file name="Output_hidden"/>
<file name="ProgressListAction.shadow_hidden"/>
<file name="ShowPaletteAction.shadow_hidden"/>
<file name="SwitchToRecentDocumentAction.shadow_hidden"/>
<file name="Versioning_hidden"/>
<file name="org-netbeans-core-ide-ServicesTabAction.shadow_hidden"/>
<file name="org-netbeans-modules-favorites-View.shadow_hidden"/>
<file name="org-netbeans-modules-project-ui-logical-tab-action.shadow_hidden"/>
<file name="org-netbeans-modules-project-ui-physical-tab-action.shadow_hidden"/>
<file name="org-netbeans-modules-tasklist-ui-TaskListAction.shadow_hidden"/>
<file name="CloneDocumentAction.shadow_hidden"/>
</folder>
<folder name="Help">
<!-- Hidden menu entries from other modules -->
<file name="Separator1.instance_hidden"/>
<file name="netbeans-kb.url_hidden"/>
<file name="org-netbeans-modules-autoupdate-ui-actions-CheckForUpdatesAction.shadow_hidden"/>
<file name="org-netbeans-modules-bugzilla-ReportNBIssueAction.shadow_hidden"/>
<file name="org-netbeans-modules-usersguide-master.xml_hidden"/>
<file name="shortcuts.xml_hidden"/>
</folder>
</folder>
<folder name="Toolbars">
<file name="Standard.xml" url="StandardConfiguration.xml"/>
<folder name="OptionsDialog">
<!-- Hidden option tabs from other modules -->
<file name="Editor.instance_hidden"/>
<file name="FontsAndColors.instance_hidden"/>
<file name="General.instance_hidden"/>
<file name="Keymaps.instance_hidden"/>
<folder name="Advanced">
<file name="Files.instance_hidden"/>
<file name="IssueTracking.instance_hidden"/>
<file name="JavaScript.instance_hidden"/>
<file name="Spellchecker.instance_hidden"/>
<file name="TermAdvancedOption.instance_hidden"/>
<file name="ToDo.instance_hidden"/>
<file name="Versioning.instance_hidden"/>
</folder>
</folder>
<folder name="Windows2">
<folder name="Components">
<file name="OutlineTopComponent.settings" url="OutlineTopComponentSettings.xml"/>
</folder>
<folder name="Modes">
<folder name="Modes">
<file name="customLeft.wsmode" url="customLeftWsmode.xml"/>
<folder name="customLeft">
<file name="OutlineTopComponent.wstcref" url="OutlineTopComponentWstcref.xml"/>

@ -1,5 +1,5 @@
Manifest-Version: 1.0
OpenIDE-Module: com.sun.hotspot.igv.data
OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/data/Bundle.properties
OpenIDE-Module-Specification-Version: 1.0
Manifest-Version: 1.0
OpenIDE-Module: com.sun.hotspot.igv.data
OpenIDE-Module-Localizing-Bundle: com/sun/hotspot/igv/data/Bundle.properties
OpenIDE-Module-Specification-Version: 1.0

@ -1,2 +1,8 @@
javac.source=1.5
javac.compilerargs=-Xlint -Xlint:-serial
javac.source=1.7
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

@ -6,6 +6,19 @@
<code-name-base>com.sun.hotspot.igv.data</code-name-base>
<suite-component/>
<module-dependencies/>
<test-dependencies>
<test-type>
<name>unit</name>
<test-dependency>
<code-name-base>org.netbeans.libs.junit4</code-name-base>
<compile-dependency/>
</test-dependency>
<test-dependency>
<code-name-base>org.openide.util</code-name-base>
<compile-dependency/>
</test-dependency>
</test-type>
</test-dependencies>
<public-packages>
<package>com.sun.hotspot.igv.data</package>
<package>com.sun.hotspot.igv.data.serialization</package>

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,20 +24,22 @@
package com.sun.hotspot.igv.data;
/**
*
* Class representing a generic changed event.
* @author Thomas Wuerthinger
* @param <T>
*/
public class ChangedEvent<T> extends Event<ChangedListener<T>> {
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;
}
@Override
protected void fire(ChangedListener<T> l) {
l.changed(object);
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2015, 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
@ -25,10 +25,14 @@
package com.sun.hotspot.igv.data;
/**
*
* Provides a changed event object.
* @author Thomas Wuerthinger
* @param <T> Class for which the changed event fires.
*/
public interface ChangedEventProvider<T> {
public ChangedEvent<T> getChangedEvent();
/**
* Returns the changed event object. Should always return the same instance.
*/
ChangedEvent<T> getChangedEvent();
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,10 +24,15 @@
package com.sun.hotspot.igv.data;
/**
*
* Listens to changed events.
* @author Thomas Wuerthinger
* @param <T> Class for which the changed event fires.
*/
public interface ChangedListener<T> {
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);
}

@ -0,0 +1,56 @@
/*
* Copyright (c) 2008, 2015, 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<T> implements ChangedListener<T>{
private boolean enabled;
public ControllableChangedListener() {
enabled = true;
}
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean b) {
enabled = b;
}
@Override
public void changed(T source) {
if(enabled) {
filteredChanged(source);
}
}
public abstract void filteredChanged(T source);
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -33,23 +33,48 @@ import java.util.List;
public abstract class Event<L> {
private List<L> listener;
private boolean fireEvents;
private boolean eventWasFired;
public Event() {
listener = new ArrayList<L>();
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<L> tmpList = new ArrayList<L>(listener);
for (L l : tmpList) {
fire(l);
if(fireEvents) {
List<L> 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();
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2015, 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
@ -21,19 +21,13 @@
* questions.
*
*/
package com.sun.hotspot.igv.data.services;
package com.sun.hotspot.igv.data;
import com.sun.hotspot.igv.data.Group;
import com.sun.hotspot.igv.data.Pair;
import java.util.List;
/**
*
* @author Thomas Wuerthinger
*/
public interface GroupOrganizer {
public String getName();
public List<Pair<String, List<Group>>> organize(List<String> subFolders, List<Group> groups);
public interface Folder {
List<? extends FolderElement> getElements();
void removeElement(FolderElement element);
void addElement(FolderElement group);
ChangedEvent<? extends Folder> getChangedEvent();
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, 2015, 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
@ -21,15 +21,11 @@
* questions.
*
*/
package com.sun.hotspot.igv.data.services;
package com.sun.hotspot.igv.data;
import java.awt.Component;
public interface FolderElement {
/**
*
* @author Thomas Wuerthinger
*/
public interface GroupReceiver {
public Component init(GroupCallback callback);
Folder getParent();
String getName();
void setParent(Folder parent);
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,53 +24,36 @@
package com.sun.hotspot.igv.data;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
*
* @author Thomas Wuerthinger
*/
public class GraphDocument extends Properties.Entity implements ChangedEventProvider<GraphDocument> {
public class GraphDocument extends Properties.Entity implements ChangedEventProvider<GraphDocument>, Folder {
private List<Group> groups;
private List<FolderElement> elements;
private ChangedEvent<GraphDocument> changedEvent;
public GraphDocument() {
groups = new ArrayList<Group>();
changedEvent = new ChangedEvent<GraphDocument>(this);
elements = new ArrayList<>();
changedEvent = new ChangedEvent<>(this);
}
public void clear() {
groups.clear();
elements.clear();
getChangedEvent().fire();
}
@Override
public ChangedEvent<GraphDocument> getChangedEvent() {
return changedEvent;
}
public List<Group> getGroups() {
return Collections.unmodifiableList(groups);
}
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();
}
}
public void addGraphDocument(GraphDocument document) {
for (Group g : document.groups) {
this.addGroup(g);
for (FolderElement e : document.elements) {
e.setParent(this);
this.addElement(e);
}
document.clear();
getChangedEvent().fire();
@ -80,12 +63,30 @@ public class GraphDocument extends Properties.Entity implements ChangedEventProv
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("GraphDocument: " + getProperties().toString() + " \n\n");
for (Group g : getGroups()) {
sb.append("GraphDocument: ").append(getProperties().toString()).append(" \n\n");
for (FolderElement g : getElements()) {
sb.append(g.toString());
sb.append("\n\n");
}
return sb.toString();
}
@Override
public List<? extends FolderElement> getElements() {
return elements;
}
@Override
public void removeElement(FolderElement element) {
if (elements.remove(element)) {
getChangedEvent().fire();
}
}
@Override
public void addElement(FolderElement element) {
elements.add(element);
getChangedEvent().fire();
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -23,49 +23,36 @@
*/
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;
import java.util.List;
import java.util.Set;
import java.util.*;
/**
*
* @author Thomas Wuerthinger
*/
public class Group extends Properties.Entity implements ChangedEventProvider<Group> {
public class Group extends Properties.Entity implements ChangedEventProvider<Group>, Folder, FolderElement {
private final List<FolderElement> elements;
private final List<InputGraph> graphs;
private List<InputGraph> graphs;
private transient ChangedEvent<Group> changedEvent;
private GraphDocument document;
private InputMethod method;
private String assembly;
private transient ChangedEvent<Group> changedEvent;
private Folder parent;
public Group() {
graphs = new ArrayList<InputGraph>();
init();
}
public Group(Folder parent) {
elements = new ArrayList<>();
graphs = new ArrayList<>();
changedEvent = new ChangedEvent<>(this);
this.parent = parent;
private void init() {
changedEvent = new ChangedEvent<Group>(this);
// Ensure that name and type are never null
getProperties().setProperty("name", "");
getProperties().setProperty("type", "");
}
public void fireChangedEvent() {
changedEvent.fire();
}
public void setAssembly(String s) {
this.assembly = s;
}
public String getAssembly() {
return assembly;
}
public void setMethod(InputMethod method) {
this.method = method;
}
@ -74,68 +61,120 @@ public class Group extends Properties.Entity implements ChangedEventProvider<Gro
return method;
}
void setDocument(GraphDocument document) {
this.document = document;
}
public GraphDocument getDocument() {
return document;
}
@Override
public ChangedEvent<Group> getChangedEvent() {
return changedEvent;
}
public List<InputGraph> getGraphs() {
return Collections.unmodifiableList(graphs);
@Override
public List<FolderElement> getElements() {
return Collections.unmodifiableList(elements);
}
public void addGraph(InputGraph g) {
assert g != null;
assert !graphs.contains(g);
graphs.add(g);
public int getGraphsCount() {
return elements.size();
}
@Override
public void addElement(FolderElement element) {
elements.add(element);
if (element instanceof InputGraph) {
graphs.add((InputGraph) element);
} else {
}
element.setParent(this);
changedEvent.fire();
}
public void removeGraph(InputGraph g) {
int index = graphs.indexOf(g);
if (index != -1) {
graphs.remove(g);
changedEvent.fire();
}
}
public Set<Integer> getAllNodes() {
Set<Integer> result = new HashSet<Integer>();
for (InputGraph g : graphs) {
Set<Integer> ids = g.getNodesAsSet();
result.addAll(g.getNodesAsSet());
for (Integer i : ids) {
result.add(-i);
Set<Integer> result = new HashSet<>();
for (FolderElement e : elements) {
if (e instanceof InputGraph) {
InputGraph g = (InputGraph) e;
result.addAll(g.getNodesAsSet());
}
}
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();
sb.append("Group " + getProperties().toString() + "\n");
for (InputGraph g : graphs) {
sb.append("Group ").append(getProperties()).append("\n");
for (FolderElement g : elements) {
sb.append(g.toString());
sb.append("\n");
sb.append('\n');
}
return sb.toString();
}
@Override
public String getName() {
return getProperties().get("name");
}
public String getType() {
return getProperties().get("type");
}
InputGraph getPrev(InputGraph graph) {
InputGraph lastGraph = null;
for (FolderElement e : elements) {
if (e == graph) {
return lastGraph;
}
if (e instanceof InputGraph) {
lastGraph = (InputGraph) e;
}
}
return null;
}
InputGraph getNext(InputGraph graph) {
boolean found = false;
for (FolderElement e : elements) {
if (e == graph) {
found = true;
} else if (found && e instanceof InputGraph) {
return (InputGraph) e;
}
}
return null;
}
public InputGraph getLastGraph() {
InputGraph lastGraph = null;
for (FolderElement e : elements) {
if (e instanceof InputGraph) {
lastGraph = (InputGraph) e;
}
}
return lastGraph;
}
@Override
public Folder getParent() {
return parent;
}
@Override
public void removeElement(FolderElement element) {
if (elements.remove(element)) {
if (element instanceof InputGraph) {
graphs.remove((InputGraph) element);
}
changedEvent.fire();
}
}
public List<InputGraph> getGraphs() {
return graphs;
}
@Override
public void setParent(Folder parent) {
this.parent = parent;
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -23,12 +23,7 @@
*/
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.List;
import java.util.Set;
import java.util.*;
/**
*
@ -37,104 +32,81 @@ import java.util.Set;
public class InputBlock {
private List<InputNode> nodes;
private List<String> successorNames;
private String name;
private InputGraph graph;
private Rectangle bounds;
private Set<InputBlock> successors;
private Set<InputBlock> predecessors;
private Set<InputBlockEdge> inputs;
private Set<InputBlockEdge> outputs;
public InputBlock(InputGraph graph, String name) {
this.graph = graph;
this.name = name;
nodes = new ArrayList<InputNode>();
successorNames = new ArrayList<String>();
successors = new HashSet<InputBlock>();
predecessors = new HashSet<InputBlock>();
inputs = new HashSet<InputBlockEdge>();
outputs = new HashSet<InputBlockEdge>();
@Override
public int hashCode() {
return name.hashCode();
}
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);
@Override
public boolean equals(Object o) {
if (o == this) {
return true;
}
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<String> 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<>();
successors = new LinkedHashSet<>(2);
}
public String getName() {
return name;
}
public void setName(String s) {
name = s;
}
public List<InputNode> getNodes() {
return Collections.unmodifiableList(nodes);
}
public void addNode(int id) {
InputNode n = graph.getNode(id);
assert n != null;
graph.setBlock(n, this);
addNode(graph.getNode(id));
}
public void addNode(InputNode node) {
assert !nodes.contains(node);
InputNode node = graph.getNode(id);
assert node != null;
assert !nodes.contains(node) : "duplicate : " + node;
graph.setBlock(node, this);
nodes.add(node);
}
public Set<InputBlock> getPredecessors() {
return Collections.unmodifiableSet(predecessors);
}
public Set<InputBlock> getSuccessors() {
return Collections.unmodifiableSet(successors);
}
public Set<InputBlockEdge> getInputs() {
return Collections.unmodifiableSet(inputs);
}
public Set<InputBlockEdge> getOutputs() {
return Collections.unmodifiableSet(outputs);
}
// resolveBlockLinks must be called afterwards
public void addSuccessor(String name) {
successorNames.add(name);
}
public void resolveBlockLinks() {
for (String s : successorNames) {
InputBlock b = graph.getBlock(s);
addSuccessor(b);
}
successorNames.clear();
}
public 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();
return "Block " + this.getName();
}
void addSuccessor(InputBlock b) {
if (!successors.contains(b)) {
successors.add(b);
}
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -29,8 +29,15 @@ package com.sun.hotspot.igv.data;
*/
public class InputBlockEdge {
public enum State {
SAME,
NEW,
DELETED
}
private InputBlock from;
private InputBlock to;
private State state = State.SAME;
public InputBlockEdge(InputBlock from, InputBlock to) {
assert from != null;
@ -47,13 +54,21 @@ public class InputBlockEdge {
return to;
}
public State getState() {
return state;
}
public void setState(State state) {
this.state = state;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof InputBlockEdge && obj != null) {
if (obj != null && obj instanceof InputBlockEdge) {
InputBlockEdge e = (InputBlockEdge) obj;
return e.from.equals(from) && e.to.equals(to);
}
return super.equals(obj);
return false;
}
@Override

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -31,11 +31,15 @@ public class InputBytecode {
private int bci;
private String name;
private String operands;
private String comment;
private InputMethod inlined;
public InputBytecode(int bci, String name) {
public InputBytecode(int bci, String name, String operands, String comment) {
this.bci = bci;
this.name = name;
this.operands = operands;
this.comment = comment;
}
public InputMethod getInlined() {
@ -53,4 +57,12 @@ public class InputBytecode {
public String getName() {
return name;
}
public String getOperands() {
return operands;
}
public String getComment() {
return comment;
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -23,6 +23,10 @@
*/
package com.sun.hotspot.igv.data;
import java.util.Comparator;
import java.util.WeakHashMap;
import java.lang.ref.WeakReference;
/**
*
* @author Thomas Wuerthinger
@ -30,21 +34,83 @@ package com.sun.hotspot.igv.data;
public class InputEdge {
public enum State {
IMMUTABLE,
SAME,
NEW,
DELETED
}
private char toIndex;
private int from;
private int to;
public static final Comparator<InputEdge> OUTGOING_COMPARATOR = new Comparator<InputEdge>(){
@Override
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<InputEdge> INGOING_COMPARATOR = new Comparator<InputEdge>(){
@Override
public int compare(InputEdge o1, InputEdge o2) {
if(o1.getToIndex() == o2.getToIndex()) {
return o1.getFrom() - o2.getFrom();
}
return o1.getToIndex() - o2.getToIndex();
}
};
private final char toIndex;
private final char fromIndex;
private final int from;
private final int to;
private final String label;
private final String type;
private State state;
public InputEdge(char toIndex, int from, int to) {
this((char) 0, toIndex, from, to, null, null);
}
public InputEdge(char fromIndex, char toIndex, int from, int to) {
this(fromIndex, toIndex, from, to, null, null);
}
public InputEdge(char fromIndex, char toIndex, int from, int to, String label, String type) {
this.toIndex = toIndex;
this.fromIndex = fromIndex;
this.from = from;
this.to = to;
this.state = State.SAME;
this.label = label;
this.type = type.intern();
}
static WeakHashMap<InputEdge, WeakReference<InputEdge>> immutableCache = new WeakHashMap<>();
public static synchronized InputEdge createImmutable(char fromIndex, char toIndex, int from, int to, String label, String type) {
InputEdge edge = new InputEdge(fromIndex, toIndex, from, to, label, type, State.IMMUTABLE);
WeakReference<InputEdge> result = immutableCache.get(edge);
if (result != null) {
InputEdge edge2 = result.get();
if (edge2 != null) {
return edge2;
}
}
immutableCache.put(edge, new WeakReference<>(edge));
return edge;
}
public InputEdge(char fromIndex, char toIndex, int from, int to, String label, String type, State state) {
this.toIndex = toIndex;
this.fromIndex = fromIndex;
this.from = from;
this.to = to;
this.state = state;
this.label = label;
this.type = type;
}
public State getState() {
@ -52,6 +118,9 @@ public class InputEdge {
}
public void setState(State x) {
if (state == State.IMMUTABLE) {
throw new InternalError("Can't change immutable instances");
}
this.state = x;
}
@ -59,6 +128,10 @@ public class InputEdge {
return toIndex;
}
public char getFromIndex() {
return fromIndex;
}
public String getName() {
return "in" + toIndex;
}
@ -71,22 +144,35 @@ public class InputEdge {
return to;
}
public String getLabel() {
return label;
}
public String getType() {
return type;
}
@Override
public boolean equals(Object o) {
if (o == null || !(o instanceof InputEdge)) {
return false;
}
InputEdge conn2 = (InputEdge) o;
return conn2.toIndex == toIndex && conn2.from == from && conn2.to == to;
boolean result = conn2.fromIndex == fromIndex && conn2.toIndex == toIndex && conn2.from == from && conn2.to == to;
if (result && (state == State.IMMUTABLE || conn2.state == State.IMMUTABLE)) {
// Immutable instances must be exactly the same
return conn2.label == label && conn2.state == state;
}
return result;
}
@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);
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -23,65 +23,141 @@
*/
package com.sun.hotspot.igv.data;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.HashMap;
import java.util.List;
import java.util.Set;
import java.util.*;
/**
*
* @author Thomas Wuerthinger
*/
public class InputGraph extends Properties.Entity {
public class InputGraph extends Properties.Entity implements FolderElement {
private HashMap<Integer, InputNode> nodes;
private ArrayList<InputEdge> edges;
private Group parent;
private HashMap<String, InputBlock> blocks;
private HashMap<Integer, InputBlock> nodeToBlock;
private boolean isDifferenceGraph;
private Map<Integer, InputNode> nodes;
private List<InputEdge> edges;
private Folder parent;
private Group parentGroup;
private Map<String, InputBlock> blocks;
private List<InputBlockEdge> blockEdges;
private Map<Integer, InputBlock> nodeToBlock;
public InputGraph(Group parent) {
this(parent, null);
public InputGraph(String name) {
setName(name);
nodes = new LinkedHashMap<>();
edges = new ArrayList<>();
blocks = new LinkedHashMap<>();
blockEdges = new ArrayList<>();
nodeToBlock = new LinkedHashMap<>();
}
public InputGraph(Group parent, InputGraph last) {
this(parent, last, "");
@Override
public void setParent(Folder parent) {
this.parent = parent;
if (parent instanceof Group) {
assert this.parentGroup == null;
this.parentGroup = (Group) parent;
}
}
private void clearBlocks() {
public InputBlockEdge addBlockEdge(InputBlock left, InputBlock right) {
InputBlockEdge edge = new InputBlockEdge(left, right);
blockEdges.add(edge);
left.addSuccessor(right);
return edge;
}
public List<InputNode> findRootNodes() {
List<InputNode> result = new ArrayList<>();
Set<Integer> 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<InputNode, List<InputEdge>> findAllOutgoingEdges() {
Map<InputNode, List<InputEdge>> result = new HashMap<>(getNodes().size());
for(InputNode n : this.getNodes()) {
result.put(n, new ArrayList<InputEdge>());
}
for(InputEdge e : this.edges) {
int from = e.getFrom();
InputNode fromNode = this.getNode(from);
List<InputEdge> fromList = result.get(fromNode);
assert fromList != null;
fromList.add(e);
}
for(InputNode n : this.getNodes()) {
List<InputEdge> list = result.get(n);
Collections.sort(list, InputEdge.OUTGOING_COMPARATOR);
}
return result;
}
public Map<InputNode, List<InputEdge>> findAllIngoingEdges() {
Map<InputNode, List<InputEdge>> result = new HashMap<>(getNodes().size());
for(InputNode n : this.getNodes()) {
result.put(n, new ArrayList<InputEdge>());
}
for(InputEdge e : this.edges) {
int to = e.getTo();
InputNode toNode = this.getNode(to);
List<InputEdge> toList = result.get(toNode);
assert toList != null;
toList.add(e);
}
for(InputNode n : this.getNodes()) {
List<InputEdge> list = result.get(n);
Collections.sort(list, InputEdge.INGOING_COMPARATOR);
}
return result;
}
public List<InputEdge> findOutgoingEdges(InputNode n) {
List<InputEdge> result = new ArrayList<>();
for(InputEdge e : this.edges) {
if(e.getFrom() == n.getId()) {
result.add(e);
}
}
Collections.sort(result, InputEdge.OUTGOING_COMPARATOR);
return result;
}
public void clearBlocks() {
blocks.clear();
nodeToBlock.clear();
}
public InputGraph(Group parent, InputGraph last, String name) {
this.parent = parent;
setName(name);
nodes = new HashMap<Integer, InputNode>();
edges = new ArrayList<InputEdge>();
blocks = new HashMap<String, InputBlock>();
nodeToBlock = new HashMap<Integer, InputBlock>();
if (last != null) {
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";
for (InputNode n : last.getNodes()) {
addNode(n);
}
for (InputEdge c : last.getEdges()) {
addEdge(c);
}
InputEdge edge = new InputEdge((char)fromIndex, (char)toIndex, from, to);
if(!this.getEdges().contains(edge)) {
this.addEdge(edge);
}
}
public void schedule(Collection<InputBlock> newBlocks) {
clearBlocks();
InputBlock noBlock = new InputBlock(this, "no block");
Set<InputNode> scheduledNodes = new HashSet<InputNode>();
public void ensureNodesInBlocks() {
InputBlock noBlock = null;
Set<InputNode> scheduledNodes = new HashSet<>();
for (InputBlock b : newBlocks) {
for (InputBlock b : getBlocks()) {
for (InputNode n : b.getNodes()) {
assert !scheduledNodes.contains(n);
scheduledNodes.add(n);
@ -91,18 +167,11 @@ public class InputGraph extends Properties.Entity {
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 +185,28 @@ public class InputGraph extends Properties.Entity {
}
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<InputGraph> list = parent.getGraphs();
if (!list.contains(this)) {
return null;
}
int index = list.indexOf(this);
if (index == list.size() - 1) {
return null;
} else {
return list.get(index + 1);
}
return parentGroup.getNext(this);
}
public InputGraph getPrev() {
List<InputGraph> list = parent.getGraphs();
if (!list.contains(this)) {
return null;
}
int index = list.indexOf(this);
if (index == 0) {
return null;
} else {
return list.get(index - 1);
}
return parentGroup.getPrev(this);
}
private void setName(String name) {
this.getProperties().setProperty("name", name);
}
@Override
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<InputNode> getNodes() {
return Collections.unmodifiableCollection(nodes.values());
}
@ -186,25 +236,22 @@ public class InputGraph extends Properties.Entity {
}
public void removeEdge(InputEdge c) {
assert edges.contains(c);
edges.remove(c);
assert !edges.contains(c);
boolean removed = edges.remove(c);
assert removed;
}
public void addEdge(InputEdge c) {
assert !edges.contains(c);
edges.add(c);
assert edges.contains(c);
}
public Group getGroup() {
return parent;
return parentGroup;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Graph " + getName() + " " + getProperties().toString() + "\n");
sb.append("Graph ").append(getName()).append(" ").append(getProperties().toString()).append("\n");
for (InputNode n : nodes.values()) {
sb.append(n.toString());
sb.append("\n");
@ -214,35 +261,31 @@ public class InputGraph extends Properties.Entity {
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 Collection<InputBlockEdge> getBlockEdges() {
return Collections.unmodifiableList(blockEdges);
}
public void setIsDifferenceGraph(boolean b) {
isDifferenceGraph = b;
@Override
public Folder getParent() {
return parent;
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -23,10 +23,11 @@
*/
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;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*
@ -42,14 +43,37 @@ public class InputMethod extends Properties.Entity {
private Group group;
private List<InputBytecode> 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;
this.name = name;
this.bci = bci;
this.shortName = shortName;
inlined = new ArrayList<InputMethod>();
bytecodes = new ArrayList<InputBytecode>();
inlined = new ArrayList<>();
bytecodes = new ArrayList<>();
}
public List<InputBytecode> getBytecodes() {
@ -87,31 +111,42 @@ public class InputMethod extends Properties.Entity {
}
public void setBytecodes(String text) {
Pattern instruction = Pattern.compile("\\s*(\\d+)\\s*:?\\s*(\\w+)\\s*(.*)(?://(.*))?");
String[] strings = text.split("\n");
int oldNumber = -1;
int oldBci = -1;
for (String s : strings) {
if (s.length() > 0 && Character.isDigit(s.charAt(0))) {
s = s.trim();
int spaceIndex = s.indexOf(' ');
String numberString = s.substring(0, spaceIndex);
String tmpName = s.substring(spaceIndex + 1, s.length());
int number = -1;
number = Integer.parseInt(numberString);
// assert correct order of bytecodes
assert number > oldNumber;
InputBytecode bc = new InputBytecode(number, tmpName);
bytecodes.add(bc);
for (InputMethod m : inlined) {
if (m.getBci() == number) {
bc.setInlined(m);
break;
if (s.startsWith(" ")) {
// indented lines are extra textual information
continue;
}
s = s.trim();
if (s.length() != 0) {
final Matcher matcher = instruction.matcher(s);
if (matcher.matches()) {
String bciString = matcher.group(1);
String opcode = matcher.group(2);
String operands = matcher.group(3).trim();
String comment = matcher.group(4);
if (comment != null) {
comment = comment.trim();
}
int bci = Integer.parseInt(bciString);
// assert correct order of bytecodes
assert bci > oldBci;
InputBytecode bc = new InputBytecode(bci, opcode, operands, comment);
bytecodes.add(bc);
for (InputMethod m : inlined) {
if (m.getBci() == bci) {
bc.setInlined(m);
break;
}
}
} else {
System.out.println("no match: " + s);
}
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -23,6 +23,10 @@
*/
package com.sun.hotspot.igv.data;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
/**
*
* @author Thomas Wuerthinger
@ -30,6 +34,37 @@ package com.sun.hotspot.igv.data;
public class InputNode extends Properties.Entity {
private int id;
private List<InputGraph> subgraphs;
public static final Comparator<InputNode> COMPARATOR = new Comparator<InputNode>() {
@Override
public int compare(InputNode o1, InputNode o2) {
return o1.getId() - o2.getId();
}
};
public static Comparator<InputNode> getPropertyComparator(final String propertyName) {
return new Comparator<InputNode>() {
@Override
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);
@ -49,21 +84,29 @@ public class InputNode extends Properties.Entity {
return id;
}
public void addSubgraph(InputGraph graph) {
if (subgraphs == null) {
subgraphs = new ArrayList<>();
}
subgraphs.add(graph);
}
public List<InputGraph> getSubgraphs() {
return subgraphs;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof InputNode)) {
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

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, 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
@ -58,15 +58,30 @@ public class Pair<L, R> {
@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);
Pair<?,?> obj = (Pair<?,?>) o;
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 + "]";
}
}

@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -24,13 +24,10 @@
package com.sun.hotspot.igv.data;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
/**
*
@ -58,13 +55,30 @@ public class Properties implements Serializable, Iterable<Property> {
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 +99,7 @@ public class Properties implements Serializable, Iterable<Property> {
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 {
@ -100,19 +114,12 @@ public class Properties implements Serializable, Iterable<Property> {
properties = new Properties(object.getProperties());
}
@Override
public Properties getProperties() {
return properties;
}
}
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();
@ -128,11 +135,16 @@ public class Properties implements Serializable, Iterable<Property> {
this.matcher = matcher;
}
@Override
public String getName() {
return matcher.getName();
}
@Override
public boolean match(String p) {
if (p == null) {
return false;
}
return !matcher.match(p);
}
}
@ -143,15 +155,26 @@ public class Properties implements Serializable, Iterable<Property> {
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;
}
@Override
public String getName() {
return name;
}
@Override
public boolean match(String p) {
if (p == null) {
throw new IllegalArgumentException("Property value must not be null!");
}
return p.equals(value);
}
}
@ -162,30 +185,55 @@ public class Properties implements Serializable, Iterable<Property> {
private Pattern valuePattern;
public RegexpPropertyMatcher(String name, String value) {
this.name = name;
valuePattern = Pattern.compile(value);
this(name, value, 0);
}
public RegexpPropertyMatcher(String name, String value, int flags) {
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;
try {
valuePattern = Pattern.compile(value, flags);
} catch (PatternSyntaxException e) {
throw new IllegalArgumentException("Bad pattern: " + value);
}
}
@Override
public String getName() {
return name;
}
@Override
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,14 +246,33 @@ public class Properties implements Serializable, Iterable<Property> {
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("[");
List<String[]> 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<String[]>() {
@Override
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]).append("=").append(p[1]);
}
return sb.append("]").toString();
}
@ -217,10 +284,6 @@ public class Properties implements Serializable, Iterable<Property> {
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 +296,16 @@ public class Properties implements Serializable, Iterable<Property> {
return null;
}
public List<T> selectMultiple(final String name, final String value) {
return selectMultiple(new StringPropertyMatcher(name, value));
}
public List<T> selectMultiple(PropertyMatcher matcher) {
List<T> result = new ArrayList<T>();
List<T> result = new ArrayList<>();
for (T t : objects) {
Property p = t.getProperties().selectSingle(matcher);
if (p != null) {
result.add(t);
}
}
return result;
}
}
@ -259,6 +320,10 @@ public class Properties implements Serializable, Iterable<Property> {
}
public void setProperty(String name, String value) {
setPropertyInternal(name.intern(), value != null ? value.intern() : null);
}
private void setPropertyInternal(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,34 +354,26 @@ public class Properties implements Serializable, Iterable<Property> {
map = newMap;
}
public Iterator<Property> getProperties() {
return iterator();
}
public void add(Properties properties) {
for (Property p : properties) {
add(p);
// Already interned
setPropertyInternal(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<Property>, Iterable<Property> {
public Iterator<Property> iterator() {
return this;
}
private class PropertiesIterator implements Iterator<Property> {
int index;
@Override
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;
}
@Override
public Property next() {
if (index < map.length) {
index += 2;
@ -325,11 +382,13 @@ public class Properties implements Serializable, Iterable<Property> {
return null;
}
@Override
public void remove() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
@Override
public Iterator<Property> iterator() {
return new PropertiesIterator();
}

Some files were not shown because too many files have changed in this diff Show More