Mercurial > hg > graal-compiler
changeset 4372:2e66f6fd4bc9
IGV clean up. Allow groups with subgroups.
line wrap: on
line diff
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.properties Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/nbproject/project.properties Fri Jan 27 19:39:29 2012 +0100 @@ -1,2 +1,2 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupOrganizer Fri Jan 27 16:42:05 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ -com.sun.hotspot.igv.coordinator.StandardGroupOrganizer -com.sun.hotspot.igv.coordinator.GraphCountGroupOrganizer \ No newline at end of file
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/FolderNode.java Fri Jan 27 19:39:29 2012 +0100 @@ -24,14 +24,8 @@ 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.GraphDocument; -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; @@ -46,108 +40,65 @@ */ 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<Pair<String, List<Group>>> implements ChangedListener<Group> { + private static class FolderChildren extends Children.Keys<FolderElement> implements ChangedListener { - private FolderNode parent; - private List<Group> registeredGroups; - private final GraphDocument document; + private final Folder folder; - public FolderChildren(GraphDocument document) { - this.document = document; - } - - 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(Pair<String, List<Group>> p) { - - for(Group g : registeredGroups) { - g.getChangedEvent().removeListener(this); - } - registeredGroups.clear(); - - if (p.getLeft().length() == 0) { - - List<Node> curNodes = new ArrayList<Node>(); - for (Group g : p.getRight()) { - for (InputGraph graph : g.getGraphListCopy()) { - curNodes.add(new GraphNode(document, 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(document, 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) { - for(Pair<String, List<Group>> p : parent.structure) { - refreshKey(p); - } + public void changed(Object source) { + addNotify(); } } - protected InstanceContent getContent() { - return content; - } - @Override public Image getIcon(int i) { return ImageUtilities.loadImage("com/sun/hotspot/igv/coordinator/images/folder.png"); } - protected FolderNode(GraphDocument document, String name, GroupOrganizer organizer, List<String> subFolders, List<Group> groups) { - this(document, name, organizer, subFolders, groups, new FolderChildren(document), new InstanceContent()); + protected FolderNode(Folder folder) { + this(folder, new FolderChildren(folder), new InstanceContent()); } - private FolderNode(final GraphDocument document, 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) { - document.removeGroup(g); - + if (folder instanceof FolderElement) { + final FolderElement folderElement = (FolderElement) folder; + this.setDisplayName(folderElement.getName()); + content.add(new RemoveCookie() { + 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) {
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphCountGroupOrganizer.java Fri Jan 27 16:42:05 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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>>(groups.size()); - for (Group g : groups) { - Integer cur = g.getGraphsCount(); - 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; - } -}
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/GraphNode.java Fri Jan 27 19:39:29 2012 +0100 @@ -48,18 +48,15 @@ * @author Thomas Wuerthinger */ public class GraphNode extends AbstractNode { - private final GraphDocument document; private final InputGraph graph; /** Creates a new instance of GraphNode */ - public GraphNode(GraphDocument document, InputGraph graph) { - this(document, graph, new InstanceContent()); + public GraphNode(InputGraph graph) { + this(graph, new InstanceContent()); } - private GraphNode(GraphDocument document, InputGraph graph, InstanceContent content) { + private GraphNode(InputGraph graph, InstanceContent content) { super(Children.LEAF, new AbstractLookup(content)); - - this.document = document; this.graph = graph; this.setDisplayName(graph.getName()); content.add(graph); @@ -72,7 +69,7 @@ } // Action for removing a graph - content.add(new GraphRemoveCookie(document, graph)); + content.add(new GraphRemoveCookie(graph)); // Action for diffing to the current graph content.add(new DiffGraphCookie(graph));
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/OutlineTopComponent.java Fri Jan 27 19:39:29 2012 +0100 @@ -28,12 +28,10 @@ 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.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; @@ -72,7 +70,6 @@ private ExplorerManager manager; private GraphDocument document; private FolderNode root; - private GroupOrganizer organizer; private OutlineTopComponent() { initComponents(); @@ -88,18 +85,10 @@ private void initListView() { manager = new ExplorerManager(); - organizer = new StandardGroupOrganizer(); - root = new FolderNode(document, "", organizer, new ArrayList<String>(), document.getGroups()); + root = new FolderNode(document); manager.setRootContext(root); ((BeanTreeView) this.treeView).setRootVisible(false); - document.getChangedEvent().addListener(new ChangedListener<GraphDocument>() { - - public void changed(GraphDocument document) { - updateStructure(); - } - }); - associateLookup(ExplorerUtils.createLookup(manager, getActionMap())); } @@ -118,24 +107,17 @@ toolbar.add(((NodeAction) RemoveAction.get(RemoveAction.class)).createContextAwareInstance(this.getLookup())); toolbar.add(RemoveAllAction.get(RemoveAllAction.class)); - toolbar.add(StructuredViewAction.get(StructuredViewAction.class).getToolbarPresenter()); - for (Toolbar tb : ToolbarPool.getDefault().getToolbars()) { tb.setVisible(false); } } - public void setOrganizer(GroupOrganizer organizer) { - this.organizer = organizer; - updateStructure(); - } - private void initReceivers() { final GroupCallback callback = new GroupCallback() { public void started(Group g) { - getDocument().addGroup(g); + getDocument().addElement(g); } }; @@ -153,10 +135,6 @@ } } - private void updateStructure() { - root.init("", organizer, new ArrayList<String>(), document.getGroups()); - } - public void clear() { document.clear(); }
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/StandardGroupOrganizer.java Fri Jan 27 16:42:05 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +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.Arrays; -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) { - Pair<String, List<Group>> p = new Pair<String, List<Group>>(); - p.setLeft(g.getName()); - p.setRight(Arrays.asList(g)); - result.add(p); - } - } - return result; - } -}
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphAction.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphAction.java Fri Jan 27 19:39:29 2012 +0100 @@ -62,8 +62,8 @@ return NbBundle.getMessage(DiffGraphAction.class, "CTL_DiffGraphAction"); } - protected Class[] cookieClasses() { - return new Class[]{ + protected Class<?>[] cookieClasses() { + return new Class<?>[]{ DiffGraphCookie.class }; }
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphCookie.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/DiffGraphCookie.java Fri Jan 27 19:39:29 2012 +0100 @@ -60,16 +60,6 @@ public void openDiff() { InputGraph other = getCurrentGraph(); - - if (!graph.getGroup().isComplete() || !other.getGroup().isComplete()) { - String msg = "One of the graphs or the groups they belong to are still being loaded. Creating a diff now can cause problems. Do you want to continue?"; - NotifyDescriptor desc = new NotifyDescriptor(msg, "Incomplete data", NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.QUESTION_MESSAGE, null, NotifyDescriptor.NO_OPTION); - - if (DialogDisplayer.getDefault().notify(desc) == DialogDescriptor.NO_OPTION) { - return; - } - } - final GraphViewer viewer = Lookup.getDefault().lookup(GraphViewer.class); if (viewer != null) { InputGraph diffGraph = Difference.createDiffGraph(other, graph);
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphOpenCookie.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphOpenCookie.java Fri Jan 27 19:39:29 2012 +0100 @@ -41,15 +41,6 @@ } public void open() { - if (!graph.getGroup().isComplete()) { - String msg = "This graph or the group it belongs to is still being loaded. Opening this graph now can cause problems. Do you want to continue and open the graph?"; - NotifyDescriptor desc = new NotifyDescriptor(msg, "Incomplete data", NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.QUESTION_MESSAGE, null, NotifyDescriptor.NO_OPTION); - - if (DialogDisplayer.getDefault().notify(desc) == DialogDescriptor.NO_OPTION) { - return; - } - } - viewer.view(graph); } }
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphRemoveCookie.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/GraphRemoveCookie.java Fri Jan 27 19:39:29 2012 +0100 @@ -30,29 +30,13 @@ import org.openide.NotifyDescriptor; public class GraphRemoveCookie implements RemoveCookie { - private final GraphDocument document; private final InputGraph graph; - public GraphRemoveCookie(GraphDocument document, InputGraph graph) { - this.document = document; + public GraphRemoveCookie(InputGraph graph) { this.graph = graph; } public void remove() { - if (!graph.getGroup().isComplete()) { - String msg = "This graph or the group it belongs to is still being loaded. Removing this graph now can cause problems. Do you want to continue and remove the graph?"; - NotifyDescriptor desc = new NotifyDescriptor(msg, "Incomplete data", NotifyDescriptor.YES_NO_OPTION, NotifyDescriptor.QUESTION_MESSAGE, null, NotifyDescriptor.NO_OPTION); - - if (DialogDisplayer.getDefault().notify(desc) == DialogDescriptor.NO_OPTION) { - return; - } - } - - if (graph.getGroup().getGraphsCount() > 1) { - graph.getGroup().removeGraph(graph); - } else { - // Last graph, remove the entire group - document.removeGroup(graph.getGroup()); - } + graph.getGroup().removeElement(graph); } }
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAsAction.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/SaveAsAction.java Fri Jan 27 19:39:29 2012 +0100 @@ -57,7 +57,7 @@ GraphDocument doc = new GraphDocument(); for (Node n : activatedNodes) { Group group = n.getLookup().lookup(Group.class); - doc.addGroup(group); + doc.addElement(group); } save(doc);
--- a/src/share/tools/IdealGraphVisualizer/Coordinator/src/com/sun/hotspot/igv/coordinator/actions/StructuredViewAction.java Fri Jan 27 16:42:05 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -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.ImageUtilities; -import org.openide.util.Lookup; -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 = ImageUtilities.loadImage("com/sun/hotspot/igv/coordinator/images/structure.png"); - 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("Choose group organization"); - - 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; - } - -}
--- a/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.properties Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/nbproject/project.properties Fri Jan 27 19:39:29 2012 +0100 @@ -1,8 +1,8 @@ -javac.source=1.5 -javac.compilerargs=-Xlint -Xlint:-serial -src.dir=src -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -test.src.dir=test -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results +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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Folder.java Fri Jan 27 19:39:29 2012 +0100 @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package com.sun.hotspot.igv.data; + +import java.util.List; + +public interface Folder { + List<? extends FolderElement> getElements(); + void removeElement(FolderElement element); + void addElement(FolderElement group); + ChangedEvent<? extends Folder> getChangedEvent(); +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/FolderElement.java Fri Jan 27 19:39:29 2012 +0100 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ +package com.sun.hotspot.igv.data; + +public interface FolderElement { + + Folder getParent(); + String getName(); +}
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/GraphDocument.java Fri Jan 27 19:39:29 2012 +0100 @@ -31,18 +31,18 @@ * * @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>(); + elements = new ArrayList<FolderElement>(); changedEvent = new ChangedEvent<GraphDocument>(this); } public void clear() { - groups.clear(); + elements.clear(); getChangedEvent().fire(); } @@ -50,25 +50,9 @@ return changedEvent; } - public List<Group> getGroups() { - return Collections.unmodifiableList(groups); - } - - public void addGroup(Group group) { - groups.add(group); - getChangedEvent().fire(); - } - - public void removeGroup(Group group) { - if (groups.contains(group)) { - groups.remove(group); - getChangedEvent().fire(); - } - } - public void addGraphDocument(GraphDocument document) { - for (Group g : document.groups) { - this.addGroup(g); + for (FolderElement e : document.elements) { + this.addElement(e); } document.clear(); getChangedEvent().fire(); @@ -79,11 +63,29 @@ StringBuilder sb = new StringBuilder(); sb.append("GraphDocument: " + getProperties().toString() + " \n\n"); - for (Group g : getGroups()) { + 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(); + } }
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Group.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Group.java Fri Jan 27 19:39:29 2012 +0100 @@ -23,54 +23,36 @@ */ package com.sun.hotspot.igv.data; -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 InputMethod method; - private String assembly; private transient ChangedEvent<Group> changedEvent; - private transient boolean complete = true; + private final Folder parent; - public Group() { - graphs = Collections.synchronizedList(new ArrayList<InputGraph>()); - changedEvent = new ChangedEvent<Group>(this); + public Group(Folder parent) { + elements = new ArrayList<>(); + graphs = new ArrayList<>(); + changedEvent = new ChangedEvent<>(this); + this.parent = parent; // Ensure that name and type are never null getProperties().setProperty("name", ""); getProperties().setProperty("type", ""); } - public void setComplete(boolean complete) { - this.complete = complete; - } - - public boolean isComplete() { - return complete; - } - 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; } @@ -83,52 +65,28 @@ return changedEvent; } - public List<InputGraph> getGraphs() { - return Collections.unmodifiableList(graphs); + public List<FolderElement> getElements() { + return Collections.unmodifiableList(elements); } public int getGraphsCount() { - return graphs.size(); + return elements.size(); } - - public List<InputGraph> getGraphListCopy() { - synchronized (graphs) { - return new ArrayList<InputGraph>(graphs); - } - } - - public void addGraph(InputGraph graph) { - synchronized (graphs) { - graph.setParent(this, graphs.size()); - graphs.add(graph); + + public void addElement(FolderElement element) { + elements.add(element); + if (element instanceof InputGraph) { + graphs.add((InputGraph) element); + ((InputGraph) element).setParent(this); } changedEvent.fire(); } - public InputGraph addGraph(String name) { - return addGraph(name, null); - } - - public InputGraph addGraph(String name, Pair<InputGraph, InputGraph> pair) { - InputGraph g; - synchronized (graphs) { - g = new InputGraph(graphs.size(), this, name, pair); - graphs.add(g); - } - changedEvent.fire(); - return g; - } - - public void removeGraph(InputGraph g) { - if (graphs.remove(g)) { - changedEvent.fire(); - } - } - public Set<Integer> getAllNodes() { Set<Integer> result = new HashSet<Integer>(); - synchronized (graphs) { - for (InputGraph g : graphs) { + for (FolderElement e : elements) { + if (e instanceof InputGraph) { + InputGraph g = (InputGraph) e; result.addAll(g.getNodesAsSet()); } } @@ -138,12 +96,10 @@ @Override public String toString() { StringBuilder sb = new StringBuilder(); - sb.append("Group " + getProperties().toString() + "\n"); - synchronized (graphs) { - for (InputGraph g : graphs) { - sb.append(g.toString()); - sb.append('\n'); - } + sb.append("Group ").append(getProperties()).append("\n"); + for (FolderElement g : elements) { + sb.append(g.toString()); + sb.append('\n'); } return sb.toString(); } @@ -154,5 +110,60 @@ 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; } }
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/InputGraph.java Fri Jan 27 19:39:29 2012 +0100 @@ -38,7 +38,7 @@ * * @author Thomas Wuerthinger */ -public class InputGraph extends Properties.Entity { +public class InputGraph extends Properties.Entity implements FolderElement { private Map<Integer, InputNode> nodes; private Set<InputEdge> edges; @@ -46,17 +46,13 @@ private Map<String, InputBlock> blocks; private Set<InputBlockEdge> blockEdges; private Map<Integer, InputBlock> nodeToBlock; - private Pair<InputGraph, InputGraph> sourceGraphs; - private int parentIndex; - public static InputGraph createWithoutGroup(String name, Pair<InputGraph, InputGraph> sourceGraphs) { - return new InputGraph(-1, null, name, sourceGraphs); + public InputGraph(String name) { + this(null, name); } - InputGraph(int parentIndex, Group parent, String name, Pair<InputGraph, InputGraph> sourceGraphs) { - this.parentIndex = parentIndex; + InputGraph(Group parent, String name) { this.parent = parent; - this.sourceGraphs = sourceGraphs; setName(name); nodes = new LinkedHashMap<Integer, InputNode>(); edges = new LinkedHashSet<InputEdge>(); @@ -65,12 +61,10 @@ nodeToBlock = new LinkedHashMap<Integer, InputBlock>(); } - public void setParent(Group parent, int parentIndex) { + public void setParent(Group parent) { assert (this.parent == null); - assert (this.parentIndex == -1); this.parent = parent; - this.parentIndex = parentIndex; } public InputBlockEdge addBlockEdge(InputBlock left, InputBlock right) { @@ -79,10 +73,6 @@ left.addSuccessor(right); return edge; } - - public Pair<InputGraph, InputGraph> getSourceGraphs() { - return sourceGraphs; - } public List<InputNode> findRootNodes() { List<InputNode> result = new ArrayList<InputNode>(); @@ -213,21 +203,11 @@ } public InputGraph getNext() { - List<InputGraph> list = parent.getGraphs(); - if (parentIndex == list.size() - 1) { - return null; - } else { - return list.get(parentIndex + 1); - } + return parent.getNext(this); } public InputGraph getPrev() { - List<InputGraph> list = parent.getGraphs(); - if (parentIndex == 0) { - return null; - } else { - return list.get(parentIndex - 1); - } + return parent.getPrev(this); } private void setName(String name) { @@ -317,4 +297,9 @@ public Collection<InputBlockEdge> getBlockEdges() { return Collections.unmodifiableSet(blockEdges); } + + @Override + public Folder getParent() { + return parent; + } }
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Pair.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/Pair.java Fri Jan 27 19:39:29 2012 +0100 @@ -61,7 +61,7 @@ if (o == null || !(o instanceof Pair)) { return false; } - Pair obj = (Pair) o; + Pair<?,?> obj = (Pair<?,?>) o; boolean b1 = (l == obj.l); if (l != null) { b1 = l.equals(obj.l);
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java Fri Jan 27 19:39:29 2012 +0100 @@ -23,15 +23,7 @@ */ package com.sun.hotspot.igv.data.serialization; -import com.sun.hotspot.igv.data.GraphDocument; -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.data.InputEdge; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.InputMethod; -import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.data.Pair; -import com.sun.hotspot.igv.data.Properties; +import com.sun.hotspot.igv.data.*; import com.sun.hotspot.igv.data.services.GroupCallback; import com.sun.hotspot.igv.data.serialization.XMLParser.ElementHandler; import com.sun.hotspot.igv.data.serialization.XMLParser.HandoverElementHandler; @@ -128,12 +120,11 @@ } }; // <group> - private ElementHandler<Group, GraphDocument> groupHandler = new XMLParser.ElementHandler<Group, GraphDocument>(GROUP_ELEMENT) { + private ElementHandler<Group, Folder> groupHandler = new XMLParser.ElementHandler<Group, Folder>(GROUP_ELEMENT) { @Override protected Group start() throws SAXException { - Group group = new Group(); - group.setComplete(false); + Group group = new Group(this.getParentObject()); String differenceProperty = this.readAttribute(DIFFERENCE_PROPERTY); Parser.this.difference = (differenceProperty != null && (differenceProperty.equals("1") || differenceProperty.equals("true"))); @@ -149,19 +140,11 @@ @Override protected void end(String text) throws SAXException { Group group = getObject(); - group.setComplete(true); if (groupCallback == null) { - getParentObject().addGroup(group); + getParentObject().addElement(group); } } }; - private HandoverElementHandler<Group> assemblyHandler = new XMLParser.HandoverElementHandler<Group>(ASSEMBLY_ELEMENT, true) { - - @Override - protected void end(String text) throws SAXException { - getParentObject().setAssembly(text); - } - }; // <method> private ElementHandler<InputMethod, Group> methodHandler = new XMLParser.ElementHandler<InputMethod, Group>(METHOD_ELEMENT) { @@ -174,7 +157,7 @@ } }; - private InputMethod parseMethod(XMLParser.ElementHandler handler, Group group) throws SAXException { + private InputMethod parseMethod(XMLParser.ElementHandler<?,?> handler, Group group) throws SAXException { String s = handler.readRequiredAttribute(METHOD_BCI_PROPERTY); int bci = 0; try { @@ -213,11 +196,10 @@ @Override protected InputGraph start() throws SAXException { String name = readAttribute(GRAPH_NAME_PROPERTY); - InputGraph curGraph = InputGraph.createWithoutGroup(name, null); + InputGraph curGraph = new InputGraph(name); if (difference) { - List<InputGraph> list = getParentObject().getGraphs(); - if (list.size() > 0) { - InputGraph previous = list.get(list.size() - 1); + InputGraph previous = getParentObject().getLastGraph(); + if (previous != null) { for (InputNode n : previous.getNodes()) { curGraph.addNode(n); } @@ -280,7 +262,7 @@ blockConnections.clear(); // Add to group - getParentObject().addGraph(graph); + getParentObject().addElement(graph); } }; // <nodes> @@ -469,8 +451,8 @@ topHandler.addChild(groupHandler); groupHandler.addChild(methodHandler); - groupHandler.addChild(assemblyHandler); groupHandler.addChild(graphHandler); + groupHandler.addChild(groupHandler); methodHandler.addChild(inlinedHandler); methodHandler.addChild(bytecodesHandler);
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Printer.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Printer.java Fri Jan 27 19:39:29 2012 +0100 @@ -23,16 +23,7 @@ */ package com.sun.hotspot.igv.data.serialization; -import com.sun.hotspot.igv.data.GraphDocument; -import com.sun.hotspot.igv.data.Group; -import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.data.InputBytecode; -import com.sun.hotspot.igv.data.InputEdge; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.InputMethod; -import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.data.Properties; -import com.sun.hotspot.igv.data.Property; +import com.sun.hotspot.igv.data.*; import java.io.IOException; import java.io.InputStream; import java.io.Writer; @@ -68,8 +59,12 @@ private void export(XMLWriter xmlWriter, GraphDocument document) throws IOException { xmlWriter.startTag(Parser.ROOT_ELEMENT); xmlWriter.writeProperties(document.getProperties()); - for (Group g : document.getGroups()) { - export(xmlWriter, g); + for (FolderElement e : document.getElements()) { + if (e instanceof Group) { + export(xmlWriter, (Group) e); + } else if (e instanceof InputGraph) { + export(xmlWriter, (InputGraph)e, null, false); + } } xmlWriter.endTag(); @@ -96,9 +91,14 @@ } InputGraph previous = null; - for (InputGraph graph : g.getGraphs()) { - export(writer, graph, previous, true); - previous = graph; + for (FolderElement e : g.getElements()) { + if (e instanceof InputGraph) { + InputGraph graph = (InputGraph) e; + export(writer, graph, previous, true); + previous = graph; + } else if (e instanceof Group) { + export(writer, (Group) e); + } } }
--- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/services/GroupOrganizer.java Fri Jan 27 16:42:05 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.data.services; - -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); -}
--- a/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/Util.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/test/unit/src/com/sun/hotspot/igv/data/Util.java Fri Jan 27 19:39:29 2012 +0100 @@ -90,16 +90,6 @@ fail(); } } - - if (a.getAssembly() == null || b.getAssembly() == null) { - if (a.getAssembly() != b.getAssembly()) { - fail(); - } - } else { - if (!a.getAssembly().equals(b.getAssembly())) { - fail(); - } - } } public static void assertGraphNotEquals(InputGraph a, InputGraph b) { @@ -129,7 +119,5 @@ for (InputNode n : a.getNodes()) { assertEquals(a.getBlock(n), b.getBlock(n)); } - - assertEquals(a.getSourceGraphs(), b.getSourceGraphs()); } }
--- a/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Difference/src/com/sun/hotspot/igv/difference/Difference.java Fri Jan 27 19:39:29 2012 +0100 @@ -101,9 +101,8 @@ ensureScheduled(a); ensureScheduled(b); - Group g = new Group(); + Group g = new Group(null); g.setMethod(a.getGroup().getMethod()); - g.setAssembly(a.getGroup().getAssembly()); if (a.getGroup() == b.getGroup()) { g.getProperties().add(a.getGroup().getProperties()); } else { @@ -117,7 +116,8 @@ } } g.getProperties().setProperty("name", "Difference"); - InputGraph graph = g.addGraph(a.getName() + ", " + b.getName(), new Pair<InputGraph, InputGraph>(a, b)); + InputGraph graph = new InputGraph(a.getName() + ", " + b.getName()); + g.addElement(graph); Map<InputBlock, InputBlock> blocksMap = new HashMap<InputBlock, InputBlock>(); for (InputBlock blk : a.getBlocks()) {
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckListView.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckListView.java Fri Jan 27 19:39:29 2012 +0100 @@ -44,8 +44,8 @@ } @Override - protected JList createList() { - JList tmpList = super.createList(); + protected JList<Object> createList() { + JList<Object> tmpList = super.createList(); tmpList.setCellRenderer(new CheckRenderer(tmpList)); return tmpList; }
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckRenderer.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/CheckRenderer.java Fri Jan 27 19:39:29 2012 +0100 @@ -37,12 +37,12 @@ /** * @author Thomas Wuerthinger */ -public class CheckRenderer extends JCheckBox implements ListCellRenderer { +public class CheckRenderer extends JCheckBox implements ListCellRenderer<Object> { - private JList list; + private JList<Object> list; private Color startBackground; - public CheckRenderer(final JList list) { + public CheckRenderer(final JList<Object> list) { this.list = list; list.addMouseListener( new MouseAdapter() { @@ -65,7 +65,7 @@ startBackground = this.getBackground(); } - public Component getListCellRendererComponent(final JList list, Object value, final int index, boolean isSelected, boolean cellHasFocus) { + public Component getListCellRendererComponent(final JList<? extends Object> list, Object value, final int index, boolean isSelected, boolean cellHasFocus) { setText(value.toString()); CheckNode node = ((CheckNodeListModel) list.getModel()).getCheckNodeAt(index); this.setSelected(node.isSelected());
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterNode.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterNode.java Fri Jan 27 19:39:29 2012 +0100 @@ -48,7 +48,7 @@ public class FilterNode extends CheckNode implements LookupListener, ChangedListener<FilterTopComponent> { private Filter filter; - private Lookup.Result result; + private Lookup.Result<FilterChain> result; public FilterNode(Filter filter) { this(filter, new InstanceContent());
--- a/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/FilterWindow/src/com/sun/hotspot/igv/filterwindow/FilterTopComponent.java Fri Jan 27 19:39:29 2012 +0100 @@ -99,7 +99,7 @@ private ExplorerManager manager; private FilterChain filterChain; private FilterChain sequence; - private Lookup.Result result; + private Lookup.Result<FilterChain> result; private JComboBox comboBox; private List<FilterSetting> filterSettings; private FilterSetting customFilterSetting = new FilterSetting("-- Custom --");
--- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.java Fri Jan 27 19:39:29 2012 +0100 @@ -216,22 +216,9 @@ // so use insertItemAt() instead sourceCombo.insertItemAt(GRAPH_TEXT_REPRESENTATION, 0); if (diagram != null) { - if (diagram.getGraph().getSourceGraphs() != null) { - // Diff graph with source graphs with possibly different groups: - // show properties from both graphs - Pair<InputGraph, InputGraph> sourceGraphs = diagram.getGraph().getSourceGraphs(); - Properties props = new Properties(sourceGraphs.getLeft().getGroup().getProperties()); - if (sourceGraphs.getLeft().getGroup() != sourceGraphs.getRight().getGroup()) { - props.add(sourceGraphs.getRight().getGroup().getProperties()); - } - for (Property p : props) { - sourceCombo.addItem(p.getName()); - } - } else { - // Single graph - for (Property p : diagram.getGraph().getGroup().getProperties()) { - sourceCombo.addItem(p.getName()); - } + // Single graph + for (Property p : diagram.getGraph().getGroup().getProperties()) { + sourceCombo.addItem(p.getName()); } } // NOTE: The following triggers a display update. @@ -246,30 +233,6 @@ private void displayGroupProperty(Diagram diagram, String property) { if (diagram == null) { showCard(NO_GRAPH); - } else if (diagram.getGraph().getSourceGraphs() != null) { - showCard(TWO_GRAPHS_TEXT_DIFF); - textDiffPanel.removeAll(); - try { - Pair<InputGraph, InputGraph> sourceGraphs = diagram.getGraph().getSourceGraphs(); - - String ltext = sourceGraphs.getLeft().getGroup().getProperties().get(property); - if (ltext == null) { - ltext = ""; - } - StreamSource leftsrc = StreamSource.createSource("left", sourceGraphs.getLeft().getName(), "text/plain", new StringReader(ltext)); - - String rtext = sourceGraphs.getRight().getGroup().getProperties().get(property); - if (rtext == null) { - rtext = ""; - } - StreamSource rightsrc = StreamSource.createSource("right", sourceGraphs.getRight().getName(), "text/plain", new StringReader(rtext)); - - DiffView view = Diff.getDefault().createDiff(leftsrc, rightsrc); - textDiffPanel.add(view.getComponent(), BorderLayout.CENTER); - } catch (IOException e) { - throw new RuntimeException(e); - } - textDiffPanel.revalidate(); // required when card was visible before } else { showCard(ONE_GRAPH); String text = diagram.getGraph().getGroup().getProperties().get(property);
--- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/META-INF/services/com.sun.hotspot.igv.data.services.GroupOrganizer Fri Jan 27 16:42:05 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -com.sun.hotspot.igv.servercompiler.JavaGroupOrganizer \ No newline at end of file
--- a/src/share/tools/IdealGraphVisualizer/ServerCompiler/src/com/sun/hotspot/igv/servercompiler/JavaGroupOrganizer.java Fri Jan 27 16:42:05 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,200 +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.servercompiler; - -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.Collections; -import java.util.Comparator; -import java.util.HashMap; -import java.util.List; - -/** - * - * @author Thomas Wuerthinger - */ -public class JavaGroupOrganizer implements GroupOrganizer { - - public String getName() { - return "Java 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) { - buildResult(result, groups, packageNameProvider); - } else if (subFolders.size() == 1) { - buildResult(result, groups, classNameProvider); - } else if (subFolders.size() == 2) { - 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(reducedNameProvider.getName(g)); - p.setRight(children); - result.add(p); - } - } else { - result.add(new Pair<String, List<Group>>("", groups)); - } - - return result; - } - - private void buildResult(List<Pair<String, List<Group>>> result, List<Group> groups, NameProvider provider) { - HashMap<String, List<Group>> map = new HashMap<String, List<Group>>(groups.size()); - for (Group g : groups) { - String s = provider.getName(g); - - if (!map.containsKey(s)) { - List<Group> list = new ArrayList<Group>(); - Pair<String, List<Group>> pair = new Pair<String, List<Group>>(s, list); - result.add(pair); - map.put(s, list); - } - - List<Group> curList = map.get(s); - curList.add(g); - } - - Collections.sort(result, new Comparator<Pair<String, List<Group>>>() { - - public int compare(Pair<String, List<Group>> a, Pair<String, List<Group>> b) { - return a.getLeft().compareTo(b.getLeft()); - } - }); - } - - private static interface NameProvider { - - public String getName(Group g); - } - private NameProvider reducedNameProvider = new NameProvider() { - - public String getName(Group g) { - String name = g.getName(); - assert name != null : "name of group must be set!"; - final String noReducedName = name; - - int firstPoint = name.indexOf("."); - if (firstPoint == -1) { - return noReducedName; - } - - int firstParenthese = name.indexOf("("); - if (firstParenthese == -1 || firstParenthese < firstPoint) { - return noReducedName; - } - - int current = firstPoint; - while (current >= 0 && name.charAt(current) != ' ') { - current--; - } - - String tmp = name.substring(0, firstParenthese); - int lastPoint = tmp.lastIndexOf("."); - if (lastPoint == -1) { - return noReducedName; - } - - name = name.substring(0, current + 1) + name.substring(lastPoint + 1); - return name; - } - }; - private NameProvider packageNameProvider = new NameProvider() { - - public String getName(Group g) { - String name = g.getName(); - assert name != null : "name of group must be set!"; - final String noPackage = "<default>"; - - int firstPoint = name.indexOf("."); - if (firstPoint == -1) { - return noPackage; - } - - int firstParenthese = name.indexOf("("); - if (firstParenthese == -1 || firstParenthese < firstPoint) { - return noPackage; - } - - int current = firstPoint; - while (current >= 0 && name.charAt(current) != ' ') { - current--; - } - - String fullClassName = name.substring(current + 1, firstParenthese); - int lastPoint = fullClassName.lastIndexOf("."); - if (lastPoint == -1) { - return noPackage; - } - lastPoint = fullClassName.lastIndexOf(".", lastPoint - 1); - if (lastPoint == -1) { - return noPackage; - } - - String packageName = fullClassName.substring(0, lastPoint); - return packageName; - } - }; - private NameProvider classNameProvider = new NameProvider() { - - public String getName(Group g) { - String name = g.getName(); - assert name != null : "name of group must be set!"; - - final String noClass = "<noclass>"; - - int firstPoint = name.indexOf("."); - if (firstPoint == -1) { - return noClass; - } - - int firstParenthese = name.indexOf("("); - if (firstParenthese == -1 || firstParenthese < firstPoint) { - return noClass; - } - - int current = firstPoint; - while (current >= 0 && name.charAt(current) != ' ') { - current--; - } - - String fullClassName = name.substring(current + 1, firstParenthese); - int lastPoint = fullClassName.lastIndexOf("."); - if (lastPoint == -1) { - return noClass; - } - int lastlastPoint = fullClassName.lastIndexOf(".", lastPoint - 1); - - String className = fullClassName.substring(lastlastPoint + 1, lastPoint); - return className; - } - }; -}
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramScene.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramScene.java Fri Jan 27 19:39:29 2012 +0100 @@ -1014,7 +1014,7 @@ return true; } - public static boolean doesIntersect(Set s1, Set s2) { + public static boolean doesIntersect(Set<?> s1, Set<?> s2) { if (s1.size() > s2.size()) { Set tmp = s1; s1 = s2;
--- a/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramViewModel.java Fri Jan 27 16:42:05 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/View/src/com/sun/hotspot/igv/view/DiagramViewModel.java Fri Jan 27 19:39:29 2012 +0100 @@ -365,14 +365,6 @@ if (diagram == null) { diagram = Diagram.createDiagram(getGraphToView(), Settings.get().get(Settings.NODE_TEXT, Settings.NODE_TEXT_DEFAULT)); getFilterChain().apply(diagram, getSequenceFilterChain()); - if (diagram.getGraph().getSourceGraphs() != null) { - CustomFilter f = new CustomFilter( - "difference", "colorize('state', 'same', white);" + - "colorize('state', 'changed', orange);" + - "colorize('state', 'new', green);" + - "colorize('state', 'deleted', red);"); - f.apply(diagram); - } } return diagram;