# HG changeset patch # User Thomas Wuerthinger # Date 1327783982 -3600 # Node ID 86b40f74c8afb108932afa4a03f84eb9186935cb # Parent a04feadb1d473bf8a27ab2b1db6b5b01afe14558 Removing unused projects. diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockConnectionWidget.java --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockConnectionWidget.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,124 +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.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; - -/** - * - * @author Thomas Wuerthinger - */ -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 points; - private InputBlockEdge edge; - private boolean isDashed = false; - private boolean isBold = false; - - public BlockConnectionWidget(ControlFlowScene scene, InputBlockEdge edge) { - super(scene); - - this.edge = edge; - this.from = (BlockWidget) scene.findWidget(edge.getFrom()); - this.to = (BlockWidget) scene.findWidget(edge.getTo()); - inputSlot = to.getInputSlot(); - outputSlot = from.getOutputSlot(); - points = new ArrayList<>(); - } - - public InputBlockEdge getEdge() { - return edge; - } - - @Override - public Port getTo() { - return inputSlot; - } - - @Override - public Port getFrom() { - 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); - } - - @Override - public void setControlPoints(List p) { - this.points = p; - } - - @Override - public List getControlPoints() { - return points; - } - - @Override - public String toString() { - return "Connection[ " + from.toString() + " - " + to.toString() + "]"; - } - - @Override - public boolean isVIP() { - return false; - } -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockWidget.java --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockWidget.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,171 +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.controlflow; - -import com.sun.hotspot.igv.data.InputBlock; -import com.sun.hotspot.igv.layout.Cluster; -import com.sun.hotspot.igv.layout.Port; -import com.sun.hotspot.igv.layout.Vertex; -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; - -/** - * - * @author Thomas Wuerthinger - */ -public class BlockWidget extends LabelWidget implements Vertex { - - 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.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; - - /** Creates a new instance of BlockWidget */ - public BlockWidget(ControlFlowScene scene, InputBlock block) { - super(scene); - this.block = block; - this.setLabel(block.getName()); - this.setForeground(NORMAL_FOREGROUND_COLOR); - this.setBorder(BorderFactory.createLineBorder(1, NORMAL_FOREGROUND_COLOR)); - this.setMinimumSize(MIN_SIZE); - - this.setFont(font); - this.setAlignment(Alignment.CENTER); - - final BlockWidget widget = this; - inputSlot = new Port() { - @Override - public Point getRelativePosition() { - return new Point((int) (getSize().getWidth() / 2), (int) (getSize().getHeight() / 2)); - } - @Override - public Vertex getVertex() { - return widget; - } - }; - outputSlot = new Port() { - @Override - public Point getRelativePosition() { - return new Point((int) (getSize().getWidth() / 2), (int) (getSize().getHeight() / 2)); - } - @Override - public Vertex getVertex() { - return widget; - } - }; - } - - public Port getInputSlot() { - return inputSlot; - } - - public Port getOutputSlot() { - return outputSlot; - } - - public InputBlock getBlock() { - return block; - } - - @Override - public Dimension getSize() { - Rectangle bounds = getBounds(); - if (bounds != null) { - return bounds.getSize(); - } else { - return MIN_SIZE; - } - } - - @Override - public void setPosition(Point p) { - this.setPreferredLocation(p); - } - - @Override - public String toString() { - return block.getName(); - } - - @Override - public Point getPosition() { - return this.getPreferredLocation(); - } - - @Override - public Cluster getCluster() { - return cluster; - } - - @Override - public boolean isRoot() { - return root; - } - - public void setCluster(Cluster c) { - cluster = c; - } - - public void setRoot(boolean b) { - root = b; - } - - @Override - public int compareTo(Vertex o) { - return toString().compareTo(o.toString()); - } - - @Override - protected void notifyStateChanged(ObjectState previousState, ObjectState state) { - super.notifyStateChanged(previousState, state); - - if (previousState.isHovered() != state.isHovered()) { - if (state.isHovered()) { - this.setBorder(BorderFactory.createLineBorder(1, HOVER_FOREGROUND_COLOR)); - } else { - this.setBorder(BorderFactory.createLineBorder(1, NORMAL_FOREGROUND_COLOR)); - } - } - - if (previousState.isSelected() != state.isSelected()) { - if (state.isSelected()) { - this.setFont(boldFont); - } else { - this.setFont(font); - } - } - } -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/Bundle.properties --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/Bundle.properties Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -CTL_ControlFlowAction=Control Flow -CTL_ControlFlowTopComponent=Control Flow -HINT_ControlFlowTopComponent=Shows the blocks of the current graph. -OpenIDE-Module-Name=ControlFlow diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowAction.java --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowAction.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +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.controlflow; - -import java.awt.event.ActionEvent; -import javax.swing.AbstractAction; -import org.openide.util.NbBundle; -import org.openide.windows.TopComponent; - -/** - * - * @author Thomas Wuerthinger - */ -public class ControlFlowAction extends AbstractAction { - - public ControlFlowAction() { - super(NbBundle.getMessage(ControlFlowAction.class, "CTL_ControlFlowAction")); - } - - @Override - public void actionPerformed(ActionEvent evt) { - TopComponent win = ControlFlowTopComponent.findInstance(); - win.open(); - win.requestActive(); - } -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowScene.java --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowScene.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,312 +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.controlflow; - -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.Set; -import javax.swing.BorderFactory; -import org.netbeans.api.visual.action.ActionFactory; -import org.netbeans.api.visual.action.MoveProvider; -import org.netbeans.api.visual.action.RectangularSelectDecorator; -import org.netbeans.api.visual.action.RectangularSelectProvider; -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.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; - -/** - * - * @author Thomas Wuerthinger - */ -public class ControlFlowScene extends GraphScene implements SelectProvider, MoveProvider, RectangularSelectDecorator, RectangularSelectProvider { - - private HashSet selection; - private InputGraph oldGraph; - private LayerWidget edgeLayer; - private LayerWidget mainLayer; - private LayerWidget selectLayer; - private WidgetAction hoverAction = this.createWidgetHoverAction(); - private WidgetAction selectAction = new DoubleClickSelectAction(this); - private WidgetAction moveAction = ActionFactory.createMoveAction(null, this); - - public ControlFlowScene() { - selection = new HashSet<>(); - - this.getInputBindings().setZoomActionModifiers(0); - this.setLayout(LayoutFactory.createAbsoluteLayout()); - - mainLayer = new LayerWidget(this); - this.addChild(mainLayer); - - edgeLayer = new LayerWidget(this); - this.addChild(edgeLayer); - - selectLayer = new LayerWidget(this); - this.addChild(selectLayer); - - this.getActions().addAction(hoverAction); - this.getActions().addAction(selectAction); - this.getActions().addAction(ActionFactory.createRectangularSelectAction(this, selectLayer, this)); - this.getActions().addAction(ActionFactory.createMouseCenteredZoomAction(1.1)); - } - - public void setGraph(InputGraph g) { - if (g == oldGraph) { - return; - } - oldGraph = g; - - ArrayList blocks = new ArrayList<>(this.getNodes()); - for (InputBlock b : blocks) { - removeNode(b); - } - - ArrayList edges = new ArrayList<>(this.getEdges()); - for (InputBlockEdge e : edges) { - removeEdge(e); - } - - for (InputBlock b : g.getBlocks()) { - addNode(b); - } - - 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(); - SceneLayout sceneLayout = LayoutFactory.createSceneGraphLayout(this, layout); - sceneLayout.invokeLayout(); - - this.validate(); - } - - public void clearSelection() { - for (BlockWidget w : selection) { - w.setState(w.getState().deriveSelected(false)); - } - selection.clear(); - selectionChanged(); - } - - public void selectionChanged() { - InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);//)Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); - if (p != null) { - Set inputNodes = new HashSet<>(); - for (BlockWidget w : selection) { - inputNodes.addAll(w.getBlock().getNodes()); - } - p.setSelectedNodes(inputNodes); - } - } - - public void addToSelection(BlockWidget widget) { - widget.setState(widget.getState().deriveSelected(true)); - selection.add(widget); - selectionChanged(); - } - - public void removeFromSelection(BlockWidget widget) { - widget.setState(widget.getState().deriveSelected(false)); - selection.remove(widget); - selectionChanged(); - } - - @Override - public boolean isAimingAllowed(Widget widget, Point point, boolean b) { - return false; - } - - @Override - public boolean isSelectionAllowed(Widget widget, Point point, boolean b) { - return true; - } - - @Override - public void select(Widget widget, Point point, boolean change) { - if (widget == this) { - clearSelection(); - } else { - - assert widget instanceof BlockWidget; - BlockWidget bw = (BlockWidget) widget; - if (change) { - if (selection.contains(bw)) { - removeFromSelection(bw); - } else { - addToSelection(bw); - } - } else { - if (!selection.contains(bw)) { - clearSelection(); - addToSelection(bw); - } - } - } - } - - @Override - public void movementStarted(Widget widget) { - } - - @Override - public void movementFinished(Widget widget) { - } - - @Override - public Point getOriginalLocation(Widget widget) { - return widget.getPreferredLocation(); - } - - @Override - public void setNewLocation(Widget widget, Point location) { - 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); - } - } - - @Override - public Widget createSelectionWidget() { - Widget widget = new Widget(this); - widget.setOpaque(false); - widget.setBorder(BorderFactory.createLineBorder(Color.black, 2)); - widget.setForeground(Color.red); - return widget; - } - - @Override - public void performSelection(Rectangle rectangle) { - - if (rectangle.width < 0) { - rectangle.x += rectangle.width; - rectangle.width *= -1; - } - - if (rectangle.height < 0) { - rectangle.y += rectangle.height; - rectangle.height *= -1; - } - - boolean changed = false; - for (InputBlock b : this.getNodes()) { - BlockWidget w = (BlockWidget) findWidget(b); - Rectangle r = new Rectangle(w.getBounds()); - r.setLocation(w.getLocation()); - if (r.intersects(rectangle)) { - if (!selection.contains(w)) { - changed = true; - selection.add(w); - w.setState(w.getState().deriveSelected(true)); - } - } else { - if (selection.contains(w)) { - changed = true; - selection.remove(w); - w.setState(w.getState().deriveSelected(false)); - } - } - } - - if (changed) { - selectionChanged(); - } - - } - - @Override - protected Widget attachNodeWidget(InputBlock node) { - BlockWidget w = new BlockWidget(this, node); - mainLayer.addChild(w); - w.getActions().addAction(hoverAction); - w.getActions().addAction(selectAction); - w.getActions().addAction(moveAction); - return w; - } - - @Override - protected Widget attachEdgeWidget(InputBlockEdge 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); - return w; - } - - @Override - protected void attachEdgeSourceAnchor(InputBlockEdge edge, InputBlock oldSourceNode, InputBlock sourceNode) { - Widget w = this.findWidget(edge); - assert w instanceof ConnectionWidget; - ConnectionWidget cw = (ConnectionWidget) w; - cw.setSourceAnchor(AnchorFactory.createRectangularAnchor(findWidget(sourceNode))); - - } - - @Override - protected void attachEdgeTargetAnchor(InputBlockEdge edge, InputBlock oldTargetNode, InputBlock targetNode) { - Widget w = this.findWidget(edge); - assert w instanceof ConnectionWidget; - ConnectionWidget cw = (ConnectionWidget) w; - cw.setTargetAnchor(AnchorFactory.createRectangularAnchor(findWidget(targetNode))); - } -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.form --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.form Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,28 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - - - - - - - - -
diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.java --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,178 +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.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; -import javax.swing.SwingUtilities; -import org.openide.ErrorManager; -import org.openide.util.Lookup; -import org.openide.util.LookupEvent; -import org.openide.util.LookupListener; -import org.openide.util.NbBundle; -import org.openide.util.Utilities; -import org.openide.windows.TopComponent; -import org.openide.windows.WindowManager; - -/** - * - * @author Thomas Wuerthinger - */ -final class ControlFlowTopComponent extends TopComponent implements LookupListener { - - private static ControlFlowTopComponent instance; - private Lookup.Result result = null; - private static final String PREFERRED_ID = "ControlFlowTopComponent"; - private ControlFlowScene scene; - - private ControlFlowTopComponent() { - initComponents(); - setName(NbBundle.getMessage(ControlFlowTopComponent.class, "CTL_ControlFlowTopComponent")); - setToolTipText(NbBundle.getMessage(ControlFlowTopComponent.class, "HINT_ControlFlowTopComponent")); - - scene = new ControlFlowScene(); - this.setLayout(new BorderLayout()); - this.associateLookup(scene.getLookup()); - - - JScrollPane panel = new JScrollPane(scene.createView()); - this.add(panel, BorderLayout.CENTER); - } - - - - /** This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. - */ - // //GEN-BEGIN:initComponents - private void initComponents() { - - org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); - this.setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(0, 400, Short.MAX_VALUE) - ); - layout.setVerticalGroup( - layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(0, 300, Short.MAX_VALUE) - ); - }// //GEN-END:initComponents - // Variables declaration - do not modify//GEN-BEGIN:variables - // End of variables declaration//GEN-END:variables - - /** - * Gets default instance. Do not use directly: reserved for *.settings files only, - * i.e. deserialization routines; otherwise you could get a non-deserialized instance. - * To obtain the singleton instance, use {@link findInstance}. - */ - public static synchronized ControlFlowTopComponent getDefault() { - if (instance == null) { - instance = new ControlFlowTopComponent(); - } - return instance; - } - - /** - * Obtain the ControlFlowTopComponent instance. Never call {@link #getDefault} directly! - */ - public static synchronized ControlFlowTopComponent findInstance() { - TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID); - if (win == null) { - ErrorManager.getDefault().log(ErrorManager.WARNING, "Cannot find ControlFlow component. It will not be located properly in the window system."); - return getDefault(); - } - if (win instanceof ControlFlowTopComponent) { - return (ControlFlowTopComponent) win; - } - ErrorManager.getDefault().log(ErrorManager.WARNING, "There seem to be multiple components with the '" + PREFERRED_ID + "' ID. That is a potential source of errors and unexpected behavior."); - return getDefault(); - } - - @Override - public int getPersistenceType() { - return TopComponent.PERSISTENCE_ALWAYS; - } - - @Override - public void componentOpened() { - Lookup.Template tpl = new Lookup.Template<>(InputGraphProvider.class); - result = Utilities.actionsGlobalContext().lookup(tpl); - result.addLookupListener(this); - } - - @Override - public void componentClosed() { - result.removeLookupListener(this); - result = null; - } - - @Override - public void resultChanged(LookupEvent lookupEvent) { - final InputGraphProvider p = LookupHistory.getLast(InputGraphProvider.class);//Utilities.actionsGlobalContext().lookup(InputGraphProvider.class); - if (p != null) { - SwingUtilities.invokeLater(new Runnable() { - - @Override - public void run() { - InputGraph g = p.getGraph(); - if (g != null) { - scene.setGraph(g); - } - } - }); - } - } - - @Override - public Object writeReplace() { - return new ResolvableHelper(); - } - - @Override - protected String preferredID() { - return PREFERRED_ID; - } - - @Override - public void requestActive() { - super.requestActive(); - scene.getView().requestFocus(); - } - - final static class ResolvableHelper implements Serializable { - - private static final long serialVersionUID = 1L; - - public Object readResolve() { - return ControlFlowTopComponent.getDefault(); - } - } -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponentSettings.xml --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponentSettings.xml Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ - - - - - - - - diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponentWstcref.xml --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponentWstcref.xml Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,7 +0,0 @@ - - - - - - - diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/DoubleClickSelectAction.java --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/DoubleClickSelectAction.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.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; - } - - @Override - 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; - } -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/HierarchicalGraphLayout.java --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/HierarchicalGraphLayout.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,187 +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.controlflow; - -import com.sun.hotspot.igv.hierarchicallayout.HierarchicalLayoutManager; -import com.sun.hotspot.igv.layout.Cluster; -import com.sun.hotspot.igv.layout.LayoutGraph; -import com.sun.hotspot.igv.layout.Link; -import com.sun.hotspot.igv.layout.Port; -import com.sun.hotspot.igv.layout.Vertex; -import java.awt.Dimension; -import java.awt.Point; -import java.util.ArrayList; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedHashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import org.netbeans.api.visual.graph.layout.GraphLayout; -import org.netbeans.api.visual.graph.layout.UniversalGraph; -import org.netbeans.api.visual.widget.Widget; - -/** - * - * @author Thomas Wuerthinger - */ -public class HierarchicalGraphLayout extends GraphLayout { - - public HierarchicalGraphLayout() { - } - - private class LinkWrapper implements Link { - - private VertexWrapper from; - private VertexWrapper to; - - public LinkWrapper(VertexWrapper from, VertexWrapper to) { - this.from = from; - this.to = to; - } - - @Override - public Port getFrom() { - return from.getSlot(); - } - - @Override - public Port getTo() { - return to.getSlot(); - } - - @Override - public List getControlPoints() { - return new ArrayList<>(); - } - - @Override - public void setControlPoints(List list) { - // Do nothing for now - } - - @Override - public boolean isVIP() { - return false; - } - } - - private class VertexWrapper implements Vertex { - - private N node; - private UniversalGraph graph; - private Port slot; - private Point position; - - public VertexWrapper(N node, UniversalGraph graph) { - this.node = node; - this.graph = graph; - final VertexWrapper vertex = this; - this.slot = new Port() { - - @Override - public Vertex getVertex() { - return vertex; - } - - @Override - public Point getRelativePosition() { - return new Point((int) (vertex.getSize().getWidth() / 2), (int) (vertex.getSize().getHeight() / 2)); - } - }; - - Widget w = graph.getScene().findWidget(node); - this.position = w.getPreferredLocation(); - } - - @Override - public Cluster getCluster() { - return null; - } - - @Override - public Dimension getSize() { - Widget w = graph.getScene().findWidget(node); - return w.getBounds().getSize(); - } - - @Override - public Point getPosition() { - return position; - } - - @Override - public void setPosition(Point p) { - HierarchicalGraphLayout.this.setResolvedNodeLocation(graph, node, p); - position = p; - } - - @Override - public boolean isRoot() { - return false; - } - - @Override - public int compareTo(Vertex o) { - @SuppressWarnings("unchecked") - VertexWrapper vw = (VertexWrapper) o; - return node.toString().compareTo(vw.node.toString()); - } - - public Port getSlot() { - return slot; - } - } - - @Override - protected void performGraphLayout(UniversalGraph graph) { - - Set links = new LinkedHashSet<>(); - Set vertices = new LinkedHashSet<>(); - Map vertexMap = new HashMap<>(); - - for (N node : graph.getNodes()) { - VertexWrapper v = new VertexWrapper(node, graph); - vertexMap.put(node, v); - vertices.add(v); - } - - for (E edge : graph.getEdges()) { - N source = graph.getEdgeSource(edge); - N target = graph.getEdgeTarget(edge); - LinkWrapper l = new LinkWrapper(vertexMap.get(source), vertexMap.get(target)); - links.add(l); - } - - HierarchicalLayoutManager m = new HierarchicalLayoutManager(HierarchicalLayoutManager.Combine.NONE); - - LayoutGraph layoutGraph = new LayoutGraph(links, vertices); - m.doLayout(layoutGraph); - } - - @Override - protected void performNodesLayout(UniversalGraph graph, Collection nodes) { - throw new UnsupportedOperationException(); - } -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/layer.xml --- a/src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/layer.xml Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java --- a/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java Sat Jan 28 21:44:17 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java Sat Jan 28 21:53:02 2012 +0100 @@ -98,6 +98,7 @@ private HashMap idCache = new HashMap<>(); private ArrayList> blockConnections = new ArrayList<>(); private int maxId = 0; + private GraphDocument graphDocument; private int lookupID(String i) { try { @@ -118,7 +119,8 @@ @Override protected GraphDocument start() throws SAXException { - return new GraphDocument(); + graphDocument = new GraphDocument(); + return graphDocument; } }; // @@ -508,7 +510,7 @@ } // Returns a new GraphDocument object deserialized from an XML input source. - public synchronized GraphDocument parse(InputSource source, XMLParser.ParseMonitor monitor) throws SAXException { + public GraphDocument parse(InputSource source, XMLParser.ParseMonitor monitor) throws SAXException { XMLReader reader = createReader(); reader.setContentHandler(new XMLParser(xmlDocument, monitor)); @@ -518,7 +520,7 @@ throw new SAXException(ex); } - return topHandler.getObject(); + return graphDocument; } private XMLReader createReader() throws SAXException { diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/Bundle.properties --- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/Bundle.properties Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ -CTL_TextAction=Text -CTL_TextTopComponent=Text -HINT_TextTopComponent=Shows a textual representation of the graph. -OpenIDE-Module-Name=GraphTextEditor diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextAction.java --- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextAction.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.graphtexteditor; - -import java.awt.event.ActionEvent; -import javax.swing.AbstractAction; -import org.openide.util.NbBundle; -import org.openide.windows.TopComponent; - -/** - * Action which shows Text component. - */ -public class TextAction extends AbstractAction { - - public TextAction() { - super(NbBundle.getMessage(TextAction.class, "CTL_TextAction")); - } - - public void actionPerformed(ActionEvent evt) { - TopComponent win = TextTopComponent.findInstance(); - win.open(); - win.requestActive(); - } -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.form --- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.form Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,18 +0,0 @@ - - -
- - - - - - - - - - - - - - - diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.java --- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,403 +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.graphtexteditor; - -import com.sun.hotspot.igv.data.ChangedListener; -import com.sun.hotspot.igv.data.Properties; -import com.sun.hotspot.igv.texteditor.*; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.Pair; -import com.sun.hotspot.igv.data.Property; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graph.services.DiagramProvider; -import com.sun.hotspot.igv.graphtotext.services.GraphToTextConverter; -import com.sun.hotspot.igv.selectioncoordinator.SelectionCoordinator; -import com.sun.hotspot.igv.structuredtext.MultiElement; -import com.sun.hotspot.igv.structuredtext.StructuredText; -import com.sun.hotspot.igv.util.LookupHistory; -import java.awt.BorderLayout; -import java.awt.CardLayout; -import java.awt.Color; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.io.IOException; -import java.io.Serializable; -import java.io.StringReader; -import java.util.Collection; -import java.util.logging.Logger; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JPanel; -import javax.swing.JSplitPane; -import javax.swing.JToolBar; -import org.netbeans.api.diff.Diff; -import org.netbeans.api.diff.DiffView; -import org.netbeans.api.diff.StreamSource; -import org.openide.util.Lookup; -import org.openide.util.LookupEvent; -import org.openide.util.LookupListener; -import org.openide.util.NbBundle; -import org.openide.util.Utilities; -import org.openide.windows.TopComponent; -import org.openide.windows.WindowManager; - -/** - * @author Thomas Wuerthinger - * @author Peter Hofer - */ -final class TextTopComponent extends TopComponent implements LookupListener { - - private static TextTopComponent instance; - private Lookup.Result result = null; - private static final String PREFERRED_ID = "TextTopComponent"; - private Diagram lastDiagram; - private TextEditor leftEditor; - private TextEditor rightEditor; - private TextEditor singleEditor; - private JSplitPane splitPane; - private CardLayout cardLayout; - private JPanel cardLayoutPanel; - private JComboBox sourceCombo; - private boolean firstTimeSplitter = true; - private JPanel textDiffPanel; - - private static final String TWO_GRAPHS_TEXT_DIFF = "twoGraphsTextDiff"; - private static final String TWO_GRAPHS = "twoGraphs"; - private static final String ONE_GRAPH = "oneGraph"; - private static final String NO_GRAPH = "noGraph"; - - private static final String GRAPH_TEXT_REPRESENTATION = "< Graph Text Representation >"; - - private DiagramProvider currentDiagramProvider; - - private TextTopComponent() { - initComponents(); - setName(NbBundle.getMessage(TextTopComponent.class, "CTL_TextTopComponent")); - setToolTipText(NbBundle.getMessage(TextTopComponent.class, "HINT_TextTopComponent")); - - setLayout(new BorderLayout()); - - // Selector for displayed data - JToolBar sourceSelectBar = new JToolBar(); - sourceSelectBar.setLayout(new BorderLayout()); - sourceSelectBar.setFloatable(false); - sourceSelectBar.add(new JLabel("Show: "), BorderLayout.WEST); - sourceCombo = new JComboBox(); - sourceCombo.addItem(GRAPH_TEXT_REPRESENTATION); - sourceCombo.addItemListener(sourceSelectionListener); - sourceSelectBar.add(sourceCombo, BorderLayout.CENTER); - add(sourceSelectBar, BorderLayout.NORTH); - - // Card layout for three different views. - cardLayout = new CardLayout(); - cardLayoutPanel = new JPanel(cardLayout); - add(cardLayoutPanel, BorderLayout.CENTER); - - // No graph selected. - JLabel noGraphLabel = new JLabel("No graph open.", JLabel.CENTER); - noGraphLabel.setOpaque(true); - noGraphLabel.setBackground(Color.WHITE); - cardLayoutPanel.add(noGraphLabel, NO_GRAPH); - - // Single graph selected. - singleEditor = new TextEditor(); - cardLayoutPanel.add(singleEditor.getComponent(), ONE_GRAPH); - - // Graph difference => show split pane with two graphs. - splitPane = new JSplitPane(); - leftEditor = new TextEditor(); - rightEditor = new TextEditor(); - // Work around a problem with JSplitPane and the NetBeans editor: - // setDividerLocation() doesn't work when the split pane has not been - // layouted and painted yet. JSplitPane then initially uses a tiny width - // for the left editor component, which causes the editor to calculate - // invalid offsets and constantly throw exceptions, particularly on - // mouse events. Thus, defer adding the two components and setting the - // divider's location. - splitPane.addComponentListener(new ComponentAdapter() { - @Override - public void componentResized(ComponentEvent e) { - if (firstTimeSplitter && splitPane.getWidth() > 0) { - splitPane.setLeftComponent(leftEditor.getComponent()); - splitPane.setRightComponent(rightEditor.getComponent()); - splitPane.setDividerLocation(0.5); - firstTimeSplitter = false; - } - } - }); - cardLayoutPanel.add(splitPane, TWO_GRAPHS); - - // Text difference => NetBeans diff view - // Diff component is created and added on demand - textDiffPanel = new JPanel(new BorderLayout()); - cardLayoutPanel.add(textDiffPanel, TWO_GRAPHS_TEXT_DIFF); - } - - - private StructuredText convert(InputGraph graph, Diagram diagram) { - Collection converters = Lookup.getDefault().lookupAll(GraphToTextConverter.class); - StructuredText text = null; - if (converters.size() == 0) { - text = new StructuredText(graph.getName()); - text.println("No graph-to-text converter exists!"); - return text; - } - - for (GraphToTextConverter converter : converters) { - if (converter.canConvert(graph)) { - text = converter.convert(graph, diagram); - if (text == null) { - text = new StructuredText(graph.getName()); - text.println("Class " + converter.getClass().getName() + " misbehaved and returned null on graph-to-text conversion!"); - } - return text; - } - } - - text = new StructuredText(graph.getName()); - text.println("No appropriate graph-to-text converter found!"); - return text; - } - - private StructuredText createStructuredPlainText(String name, String text) { - StructuredText structured = new StructuredText(name); - MultiElement multi = new MultiElement(); - multi.print(text); - structured.addChild(multi); - return structured; - } - - private ItemListener sourceSelectionListener = new ItemListener() { - public void itemStateChanged(ItemEvent e) { - if (e.getStateChange() == ItemEvent.SELECTED) { - if (e.getItem() == GRAPH_TEXT_REPRESENTATION) { - displayDiagram(lastDiagram); - } else { - displayGroupProperty(lastDiagram, (String) e.getItem()); - } - } - } - }; - - private void setDiagram(Diagram diagram) { - if (diagram == lastDiagram) { - // No change => return. - return; - } - lastDiagram = diagram; - - // Rebuild combobox choices - Object selection = sourceCombo.getSelectedItem(); - sourceCombo.removeAllItems(); - // NOTE: addItem() makes the first inserted item the selected item, - // so use insertItemAt() instead - sourceCombo.insertItemAt(GRAPH_TEXT_REPRESENTATION, 0); - if (diagram != null) { - // Single graph - for (Property p : diagram.getGraph().getGroup().getProperties()) { - sourceCombo.addItem(p.getName()); - } - } - // NOTE: The following triggers a display update. - sourceCombo.setSelectedItem(selection); - if (sourceCombo.getSelectedItem() == null) { - // previously selected property doesn't exist in new graph's group: - // default to show graph representation - sourceCombo.setSelectedItem(GRAPH_TEXT_REPRESENTATION); - } - } - - private void displayGroupProperty(Diagram diagram, String property) { - if (diagram == null) { - showCard(NO_GRAPH); - } else { - showCard(ONE_GRAPH); - String text = diagram.getGraph().getGroup().getProperties().get(property); - singleEditor.setStructuredText(createStructuredPlainText(diagram.getGraph().getName(), text)); - } - } - - private void displayDiagram(Diagram diagram) { - if (diagram == null) { - showCard(NO_GRAPH); - } /* This side-by-side view of the source graphs for diff graphs doesn't - * work properly because nodes that exist only in graph B (the 'new' - * graph) are in most cases assigned different ids. - - else if (diagram.getGraph().getSourceGraphs() != null) { - showCard(TWO_GRAPHS); - Pair graphs = diagram.getGraph().getSourceGraphs(); - leftEditor.setStructuredText(convert(graphs.getLeft(), diagram)); - rightEditor.setStructuredText(convert(graphs.getRight(), diagram)); - - // TODO: Hack to update view - remove - SelectionCoordinator.getInstance().getHighlightedChangedEvent().fire(); - } */ - else { - showCard(ONE_GRAPH); - StructuredText text = convert(diagram.getGraph(), diagram); - singleEditor.setStructuredText(text); - - // TODO: Hack to update view - remove - SelectionCoordinator.getInstance().getHighlightedChangedEvent().fire(); - } - } - - private ChangedListener diagramChangedListener = new ChangedListener() { - - public void changed(DiagramProvider source) { - setDiagram(source.getDiagram()); - } - - }; - - private void setDiagramProvider(DiagramProvider provider) { - if (provider == currentDiagramProvider) { - return; - } - - if (currentDiagramProvider != null) { - currentDiagramProvider.getChangedEvent().removeListener(diagramChangedListener); - } - - currentDiagramProvider = provider; - - if (currentDiagramProvider != null) { - currentDiagramProvider.getChangedEvent().addListener(diagramChangedListener); - setDiagram(currentDiagramProvider.getDiagram()); - } else { - setDiagram(null); - } - } - - private void showCard(final String card) { - cardLayout.show(cardLayoutPanel, card); - } - - public void resultChanged(LookupEvent lookupEvent) { - DiagramProvider p = Utilities.actionsGlobalContext().lookup(DiagramProvider.class); - - if (p == null) { - p = LookupHistory.getLast(DiagramProvider.class); - } - - setDiagramProvider(p); - } - - /** This method is called from within the constructor to - * initialize the form. - * WARNING: Do NOT modify this code. The content of this method is - * always regenerated by the Form Editor. - */ - // //GEN-BEGIN:initComponents - private void initComponents() { - - setLayout(new java.awt.BorderLayout()); - }// //GEN-END:initComponents - - - // Variables declaration - do not modify//GEN-BEGIN:variables - // End of variables declaration//GEN-END:variables - /** - * Gets default instance. Do not use directly: reserved for *.settings files only, - * i.e. deserialization routines; otherwise you could get a non-deserialized instance. - * To obtain the singleton instance, use {@link findInstance}. - */ - public static synchronized TextTopComponent getDefault() { - if (instance == null) { - instance = new TextTopComponent(); - } - return instance; - } - - /** - * Obtain the TextTopComponent instance. Never call {@link #getDefault} directly! - */ - public static synchronized TextTopComponent findInstance() { - TopComponent win = WindowManager.getDefault().findTopComponent(PREFERRED_ID); - if (win == null) { - Logger.getLogger(TextTopComponent.class.getName()).warning( - "Cannot find " + PREFERRED_ID + " component. It will not be located properly in the window system."); - return getDefault(); - } - if (win instanceof TextTopComponent) { - return (TextTopComponent) win; - } - Logger.getLogger(TextTopComponent.class.getName()).warning( - "There seem to be multiple components with the '" + PREFERRED_ID + - "' ID. That is a potential source of errors and unexpected behavior."); - return getDefault(); - } - - @Override - public int getPersistenceType() { - return TopComponent.PERSISTENCE_ALWAYS; - } - - @Override - public void componentOpened() { - - DiagramProvider p = LookupHistory.getLast(DiagramProvider.class); - setDiagramProvider(p); - - Lookup.Template tpl = new Lookup.Template(DiagramProvider.class); - result = Utilities.actionsGlobalContext().lookup(tpl); - result.addLookupListener(this); - } - - @Override - public void componentClosed() { - result.removeLookupListener(this); - result = null; - setDiagramProvider(null); - } - - /** replaces this in object stream */ - @Override - public Object writeReplace() { - return new ResolvableHelper(); - } - - @Override - protected String preferredID() { - return PREFERRED_ID; - } - - @Override - public void requestActive() { - super.requestActive(); - cardLayoutPanel.requestFocus(); - } - - final static class ResolvableHelper implements Serializable { - - private static final long serialVersionUID = 1L; - - public Object readResolve() { - return TextTopComponent.getDefault(); - } - } -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponentSettings.xml --- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponentSettings.xml Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ - - - - - - - - - diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponentWstcref.xml --- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponentWstcref.xml Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,11 +0,0 @@ - - - - - - - - diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/layer.xml --- a/src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/layer.xml Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/BFSGraphToTextConverter.java --- a/src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/BFSGraphToTextConverter.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,157 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.graphtotext; - -import com.sun.hotspot.igv.data.InputEdge; -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.data.Pair; -import com.sun.hotspot.igv.data.Properties; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.graphtotext.services.GraphToTextVisitor; -import com.sun.hotspot.igv.structuredtext.Element; -import com.sun.hotspot.igv.structuredtext.StructuredText; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.Queue; -import java.util.Set; - -/** - * - * @author Thomas - */ -public class BFSGraphToTextConverter { - - private GraphToTextVisitor visitor; - private Map visitorMap; - private InputGraph graph; - private Diagram diagram; - - public BFSGraphToTextConverter(GraphToTextVisitor visitor) { - this.visitor = visitor; - visitorMap = new HashMap(); - } - - public void registerVisitor(GraphToTextVisitor visitor, Properties.PropertyMatcher matcher) { - visitorMap.put(matcher, visitor); - } - - private GraphToTextVisitor chooseVisitor(GraphToTextVisitor defaultVisitor, InputNode node) { - for(Properties.PropertyMatcher matcher : visitorMap.keySet()) { - if(node.getProperties().selectSingle(matcher) != null) { - return visitorMap.get(matcher); - } - } - - return defaultVisitor; - } - - private Element cyclicVisit(GraphToTextVisitor visitor, InputNode node, List path) { - return chooseVisitor(visitor, node).cyclicVisit(node, path); - } - - private Element visit(GraphToTextVisitor visitor, InputNode node, List path, List> children) { - return chooseVisitor(visitor, node).visit(node, path, children); - } - - protected Diagram getDiagram() { - return diagram; - } - - public StructuredText convert(InputGraph graph, Diagram diagram) { - - this.graph = graph; - this.diagram = diagram; - StructuredText text = new StructuredText(graph.getName()); - - Map> outgoing = graph.findAllOutgoingEdges(); - Map> pathMap = new HashMap>(); - Queue queue = new LinkedList(); - List rootNodes = graph.findRootNodes(); - queue.addAll(rootNodes); - for(InputNode node : rootNodes) { - pathMap.put(node, new ArrayList()); - } - - Set visited = new HashSet(); - visited.addAll(rootNodes); - - Set fullEdges = new HashSet(); - List visitOrder = new ArrayList(); - while(!queue.isEmpty()) { - - InputNode current = queue.remove(); - visitOrder.add(current); - List path = pathMap.get(current); - - List edges = outgoing.get(current); - for(InputEdge e : edges) { - InputNode dest = graph.getNode(e.getTo()); - if(!visited.contains(dest)) { - queue.add(dest); - visited.add(dest); - List curPath = new ArrayList(path); - curPath.add(e); - pathMap.put(dest, curPath); - fullEdges.add(e); - } - } - } - - - - Map fullVisitCache = new HashMap(); - for(int i=visitOrder.size() - 1; i>=0; i--) { - InputNode current = visitOrder.get(i); - List path = pathMap.get(current); - List edges = outgoing.get(current); - List> list = new ArrayList>(); - for(InputEdge e : edges) { - if(fullEdges.contains(e)) { - assert fullVisitCache.containsKey(graph.getNode(e.getTo())); - list.add(new Pair(e, fullVisitCache.get(graph.getNode(e.getTo())))); - } else { -// assert fullVisitCache.containsKey(graph.getNode(e.getTo())); - List curPath = new ArrayList(path); - curPath.add(e); - list.add(new Pair(e, cyclicVisit(visitor, graph.getNode(e.getTo()), curPath))); - } - } - - Element e = visit(visitor, current, pathMap.get(current), list); - fullVisitCache.put(current, e); - } - - for(InputNode node : rootNodes) { - text.addChild(fullVisitCache.get(node)); - } - - return text; - } -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/Bundle.properties --- a/src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/Bundle.properties Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -OpenIDE-Module-Name=GraphToText diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/AbstractGraphToTextVisitor.java --- a/src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/AbstractGraphToTextVisitor.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.graphtotext.services; - -import com.sun.hotspot.igv.data.InputEdge; -import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.data.Pair; -import com.sun.hotspot.igv.structuredtext.Element; -import com.sun.hotspot.igv.structuredtext.SimpleElement; -import java.util.List; - -/** - * - * @author Thomas - */ -public class AbstractGraphToTextVisitor implements GraphToTextVisitor { - - public Element cyclicVisit(InputNode node, List path) { - return SimpleElement.EMPTY; - } - - public Element visit(InputNode node, List path, List> children) { - return cyclicVisit(node, path); - } - -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/GraphToTextConverter.java --- a/src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/GraphToTextConverter.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,38 +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.graphtotext.services; - -import com.sun.hotspot.igv.data.InputGraph; -import com.sun.hotspot.igv.graph.Diagram; -import com.sun.hotspot.igv.structuredtext.StructuredText; - -/** - * - * @author Thomas Wuerthinger - */ -public interface GraphToTextConverter { - StructuredText convert(InputGraph graph, Diagram diagram); - boolean canConvert(InputGraph graph); -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/GraphToTextVisitor.java --- a/src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/GraphToTextVisitor.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.graphtotext.services; - -import com.sun.hotspot.igv.data.InputEdge; -import com.sun.hotspot.igv.data.InputNode; -import com.sun.hotspot.igv.data.Pair; -import com.sun.hotspot.igv.structuredtext.Element; -import java.util.List; - -/** - * - * @author Thomas - */ -public interface GraphToTextVisitor { - - Element cyclicVisit(InputNode node, List path); - Element visit(InputNode node, List path, List> children); -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction --- a/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -com.sun.hotspot.igv.java6scriptingproxy.JavaSE6ScriptEngine \ No newline at end of file diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/com/sun/hotspot/igv/java6scriptingproxy/Bundle.properties --- a/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/com/sun/hotspot/igv/java6scriptingproxy/Bundle.properties Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -OpenIDE-Module-Name=Java6ScriptingProxy diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/com/sun/hotspot/igv/java6scriptingproxy/JavaSE6ScriptEngine.java --- a/src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/com/sun/hotspot/igv/java6scriptingproxy/JavaSE6ScriptEngine.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +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.java6scriptingproxy; - -import com.sun.hotspot.igv.filter.*; -import com.sun.hotspot.igv.graph.Diagram; -import java.lang.reflect.Field; -import java.lang.reflect.Method; - -/** - * - * @author Thomas Wuerthinger - */ -public class JavaSE6ScriptEngine implements ScriptEngineAbstraction { - - private Object engine; - private Object bindings; - private Method Bindings_put; - private Method ScriptEngine_eval; - - public boolean initialize(String jsHelperText) { - try { - ClassLoader cl = JavaSE6ScriptEngine.class.getClassLoader(); - Class managerClass = cl.loadClass("javax.script.ScriptEngineManager"); - Class engineClass = cl.loadClass("javax.script.ScriptEngine"); - Class bindingsClass = cl.loadClass("javax.script.Bindings"); - Class contextClass = cl.loadClass("javax.script.ScriptContext"); - - Object manager = managerClass.newInstance(); - Method getEngineByName = managerClass.getMethod("getEngineByName", String.class); - engine = getEngineByName.invoke(manager, "ECMAScript"); - Method eval = engineClass.getMethod("eval", String.class); - ScriptEngine_eval = engineClass.getMethod("eval", String.class, bindingsClass); - eval.invoke(engine, jsHelperText); - Method getContext = engineClass.getMethod("getContext"); - Object context = getContext.invoke(engine); - Method getBindings = contextClass.getMethod("getBindings", Integer.TYPE); - Field f = contextClass.getField("ENGINE_SCOPE"); - bindings = getBindings.invoke(context, f.getInt(null)); - Bindings_put = bindingsClass.getMethod("put", String.class, Object.class); - Bindings_put.invoke(bindings, "IO", System.out); - - /* - * Non-reflective code: - ScriptEngineManager sem = new ScriptEngineManager(); - ScriptEngine e = sem.getEngineByName("ECMAScript"); - engine = e; - e.eval(jsHelperText); - Bindings b = e.getContext().getBindings(ScriptContext.ENGINE_SCOPE); - b.put("IO", System.out); - bindings = b; - */ - - return true; - } catch (Exception e) { - e.printStackTrace(); - return false; - } - } - - public void execute(Diagram d, String code) { - try { - Bindings_put.invoke(bindings, "graph", d); - ScriptEngine_eval.invoke(engine, code, bindings); - } catch (Exception ex) { - ex.printStackTrace(); - } - } -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction --- a/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -com.sun.hotspot.igv.rhino.RhinoScriptEngine \ No newline at end of file diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/Bundle.properties --- a/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/Bundle.properties Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -OpenIDE-Module-Name=RhinoScriptEngineProxy diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/RhinoScriptEngine.java --- a/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/RhinoScriptEngine.java Sat Jan 28 21:44:17 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.rhino; - -import com.sun.hotspot.igv.filter.ScriptEngineAbstraction; -import com.sun.hotspot.igv.graph.Diagram; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; - -/** - * - * @author Thomas Wuerthinger - */ -public class RhinoScriptEngine implements ScriptEngineAbstraction { - - private String jsHelperText; - private Constructor importer; - private Method scope_put; - private Method cx_evaluateString; - private Method context_enter; - private Method context_exit; - - public boolean initialize(String s) { - this.jsHelperText = s; - Class importerTopLevel = null; - try { - ClassLoader cl = RhinoScriptEngine.class.getClassLoader(); - Class context = cl.loadClass("org.mozilla.javascript.Context"); - Class scriptable = cl.loadClass("org.mozilla.javascript.Scriptable"); - importerTopLevel = cl.loadClass("org.mozilla.javascript.ImporterTopLevel"); - importer = importerTopLevel.getDeclaredConstructor(context); - scope_put = importerTopLevel.getMethod("put", String.class, scriptable, Object.class); - cx_evaluateString = context.getDeclaredMethod("evaluateString", scriptable, String.class, String.class, Integer.TYPE, Object.class); - context_enter = context.getDeclaredMethod("enter"); - context_exit = context.getDeclaredMethod("exit"); - return true; - } catch (Exception e) { - return false; - } - } - - public void execute(Diagram d, String code) { - try { - Object cx = context_enter.invoke(null, (Object[]) null); - try { - Object scope = importer.newInstance(cx); - scope_put.invoke(scope, "IO", scope, System.out); - scope_put.invoke(scope, "graph", scope, d); - cx_evaluateString.invoke(cx, scope, jsHelperText, "jsHelper.js", 1, null); - cx_evaluateString.invoke(cx, scope, code, "", 1, null); - } finally { - // Exit from the context. - context_exit.invoke(null, (Object[]) null); - } - } catch (Exception e) { - e.printStackTrace(); - } - } -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/layer.xml --- a/src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/layer.xml Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,4 +0,0 @@ - - - - diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Bundle.properties --- a/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Bundle.properties Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -OpenIDE-Module-Name=StructuredText diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Element.java --- a/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Element.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.structuredtext; - -import com.sun.hotspot.igv.structuredtext.services.ElementVisitor; -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; -import javax.swing.text.Style; -import javax.swing.text.StyleContext; - -/** - * - * @author Thomas - */ -public abstract class Element { - - private Set source; - private Style style; - private Style highlightedStyle; - - public Element() { - source = new HashSet(); - style = null; - highlightedStyle = null; - } - - public Style getStyle() { - return style; - } - - public Style getHighlightedStyle() { - return highlightedStyle; - } - - public void setStyle(Style style) { - this.style = style; - } - - public void setHighlightedStyle(Style style) { - this.highlightedStyle = style; - } - - public void setStyleRecursive(Style style) { - this.style = style; - } - - public void setHighlightedStyleRecursive(Style style) { - this.highlightedStyle = style; - } - - public Set getSource() { - return Collections.unmodifiableSet(source); - } - - public void addSource(Object o) { - source.add(o); - } - - public abstract void accept(ElementVisitor visitor); -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/MultiElement.java --- a/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/MultiElement.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.structuredtext; - -import com.sun.hotspot.igv.structuredtext.services.ElementVisitor; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import javax.swing.text.Style; - -/** - * - * @author Thomas - */ -public class MultiElement extends Element { - - private List children; - private String foldString; - - public MultiElement() { - this((String)null); - } - - public MultiElement(String foldString) { - this(foldString, null); - } - - public MultiElement(Style style) { - this(null, style); - } - - public MultiElement(String foldString, Style style) { - setStyle(style); - this.foldString = foldString; - children = new ArrayList(); - } - - public void print(String s) { - print(s, null); - } - - @Override - public void setStyleRecursive(Style style) { - super.setStyleRecursive(style); - for(Element elem : this.getChildren()) { - elem.setStyleRecursive(style); - } - } - - @Override - public void setHighlightedStyleRecursive(Style style) { - super.setStyleRecursive(style); - for(Element elem : this.getChildren()) { - elem.setHighlightedStyleRecursive(style); - } - } - - public void print(String s, Object source) { - if (s == null) { - s = ""; - } - SimpleElement elem = new SimpleElement(s); - if(source != null) { - elem.addSource(source); - } - addChild(elem); - } - - public void print(String s, Object source, int padding) { - if (s == null) { - s = ""; - } - StringBuilder sb = new StringBuilder(s); - while (sb.length() < padding) { - sb.insert(0, ' '); - } - print(sb.toString(), source); - } - - public void println() { - println(""); - } - - public void println(String s) { - print(s + "\n"); - } - - public void println(String s, Object source) { - print(s + "\n", source); - } - - - public void println(String s, Object source, int padding) { - print(s + "\n", source, padding); - } - - public void addChild(Element element) { - assert element != null; - this.children.add(element); - } - - public String getFoldString() { - return foldString; - } - - public void setFoldString(String s) { - this.foldString = s; - } - - public List getChildren() { - return Collections.unmodifiableList(children); - } - - public void accept(ElementVisitor visitor) { - visitor.visit(this); - } -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Range.java --- a/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Range.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.structuredtext; - -/** - * - * @author Thomas - */ -public class Range { - - private int start; - private int length; - - public Range(int start, int length) { - this.start = start; - this.length = length; - } - - public int getStart() { - return start; - } - - public boolean overlaps(Range r2) { - if(start < r2.start) { - return start + length > r2.start; - } else { - return r2.start + r2.length > start; - } - } - - public int getLength() { - return length; - } - -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/SimpleElement.java --- a/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/SimpleElement.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.structuredtext; - -import com.sun.hotspot.igv.structuredtext.services.ElementVisitor; -import javax.swing.text.Style; -import javax.swing.text.StyleContext; - -/** - * - * @author Thomas - */ -public class SimpleElement extends Element { - - public static final Element EMPTY = new SimpleElement(""); - public static final Element LN = new SimpleElement("\n"); - public static final Element TAB = new SimpleElement("\t"); - - private String text; - - public SimpleElement(String s) { - this(s, null); - } - - public SimpleElement(String s, Style style) { - setText(s); - setStyle(style); - assert text != null; - } - - private static String addPadding(String s, int minLength) { - - StringBuilder sb = new StringBuilder(s); - while(sb.length() < minLength) { - sb.insert(0, ' '); - } - return sb.toString(); - } - - public SimpleElement(String s, int length) { - this(addPadding(s, length)); - } - - - public String getText() { - return text; - } - - public void setText(String s) { - this.text = s; - } - - public void accept(ElementVisitor visitor) { - visitor.visit(this); - } -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/StructuredText.java --- a/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/StructuredText.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.structuredtext; - -import com.sun.hotspot.igv.structuredtext.services.ElementVisitor; -import java.util.HashMap; -import java.util.Map; - - -/** - * - * @author Thomas - */ -public class StructuredText extends MultiElement { - - private String name; - - public StructuredText(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public Element findElementAt(final int searchIndex) { - - final Element[] result = new Element[1]; - this.accept(new ElementVisitor() { - - private int index; - - @Override - public void visit(MultiElement element) { - int startIndex = index; - super.visit(element); - } - - @Override - public void visit(SimpleElement element) { - if(searchIndex >= index && searchIndex < index + element.getText().length()) { - assert result[0] == null; - result[0] = element; - } - index += element.getText().length(); - } - }); - - return result[0]; - } - - public Map calculateRanges() { - - final Map result = new HashMap(); - - this.accept(new ElementVisitor() { - - private int index; - - @Override - public void visit(MultiElement element) { - int startIndex = index; - super.visit(element); - result.put(element, new Range(startIndex, index - startIndex)); - } - - @Override - public void visit(SimpleElement element) { - result.put(element, new Range(index, element.getText().length())); - index += element.getText().length(); - } - }); - - - return result; - - } - - public String convertToString() { - final StringBuilder result = new StringBuilder(); - this.accept(new ElementVisitor() { - @Override - public void visit(SimpleElement element) { - result.append(element.getText()); - } - } - ); - return result.toString(); - } -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/ToolTipProvider.java --- a/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/ToolTipProvider.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.structuredtext; - -/** - * - * @author thomas - */ -public interface ToolTipProvider { - - String getToolTip(); - -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/services/ElementVisitor.java --- a/src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/services/ElementVisitor.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.structuredtext.services; - -import com.sun.hotspot.igv.structuredtext.Element; -import com.sun.hotspot.igv.structuredtext.MultiElement; -import com.sun.hotspot.igv.structuredtext.SimpleElement; - -/** - * - * @author Thomas - */ -public abstract class ElementVisitor { - - public void visit(MultiElement element) { - - for(Element e : element.getChildren()) { - e.accept(this); - } - } - public abstract void visit(SimpleElement element); -} diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/Bundle.properties --- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/Bundle.properties Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,2 +0,0 @@ - -OpenIDE-Module-Name=TextEditor diff -r a04feadb1d47 -r 86b40f74c8af src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/SyntaxLayer.java --- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/SyntaxLayer.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,327 +0,0 @@ -/* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package com.sun.hotspot.igv.texteditor; - -import com.sun.hotspot.igv.data.ChangedListener; -import com.sun.hotspot.igv.selectioncoordinator.SelectionCoordinator; -import com.sun.hotspot.igv.structuredtext.MultiElement; -import com.sun.hotspot.igv.structuredtext.SimpleElement; -import com.sun.hotspot.igv.structuredtext.StructuredText; -import com.sun.hotspot.igv.structuredtext.Element; -import com.sun.hotspot.igv.structuredtext.Range; -import com.sun.hotspot.igv.structuredtext.ToolTipProvider; -import com.sun.hotspot.igv.structuredtext.services.ElementVisitor; -import java.awt.Color; -import java.awt.Cursor; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.Stack; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.AttributeSet; -import javax.swing.text.Style; -import javax.swing.text.StyleConstants; -import javax.swing.text.StyleContext; -import org.netbeans.spi.editor.highlighting.HighlightsLayerFactory; -import org.netbeans.spi.editor.highlighting.HighlightsSequence; -import org.netbeans.spi.editor.highlighting.support.AbstractHighlightsContainer; - -/** - * - * @author Thomas - */ -public class SyntaxLayer extends AbstractHighlightsContainer implements ChangedListener { - - private HighlightsLayerFactory.Context context; - - public SyntaxLayer(final HighlightsLayerFactory.Context context) { - this.context = context; - - context.getDocument().addDocumentListener(new DocumentListener() { - - public void insertUpdate(DocumentEvent arg0) { - update(); - } - - public void removeUpdate(DocumentEvent arg0) { - } - - public void changedUpdate(DocumentEvent arg0) { - } - }); - - SelectionCoordinator.getInstance().getSelectedChangedEvent().addListener(this); - SelectionCoordinator.getInstance().getHighlightedChangedEvent().addListener(this); - - context.getComponent().addMouseMotionListener(new MouseMotionListener() { - - public void mouseDragged(MouseEvent e) { - } - - public void mouseMoved(MouseEvent e) { - // [tw] hack to prevent sidebar mouse over - if (e.getPoint().getX() < 15) return; - - int index = context.getComponent().viewToModel(e.getPoint()); - Element elem = indexToElement(index); - if (elem != null) { - Set highlightedSource = new HashSet(elem.getSource()); - SelectionCoordinator.getInstance().setHighlightedObjects(highlightedSource); - context.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - } - } - }); - - context.getComponent().addMouseListener(new MouseListener() { - - public void mouseClicked(MouseEvent e) { - - int index = context.getComponent().viewToModel(e.getPoint()); - Element elem = indexToElement(index); - if (elem != null) { - Set selectedSource = new HashSet(elem.getSource()); - - for (Object o : selectedSource) { - if (o instanceof ToolTipProvider) { - String toolTip = ((ToolTipProvider) o).getToolTip(); - } - } - - if ((e.getModifiersEx() & MouseEvent.CTRL_DOWN_MASK) != 0) { - - SelectionCoordinator.getInstance().addAllSelected(selectedSource); - } else { - SelectionCoordinator.getInstance().setSelectedObjects(selectedSource); - } - context.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); - } else { - context.getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR)); - - } - } - - public void mousePressed(MouseEvent e) { - } - - public void mouseReleased(MouseEvent e) { - } - - public void mouseEntered(MouseEvent e) { - } - - public void mouseExited(MouseEvent e) { - SelectionCoordinator.getInstance().setHighlightedObjects(new HashSet()); - } - }); - } - - public void changed(SelectionCoordinator source) { - update(); - } - - private void update() { - fireHighlightsChange(0, context.getDocument().getLength()); - } - - private Element indexToElement(int index) { - StructuredText text = (StructuredText) context.getDocument().getProperty(StructuredText.class); - if (text == null) { - return null; - } - return text.findElementAt(index); - } - - private static class HighlightsRange { - - private int start; - private int end; - private AttributeSet attributes; - - public HighlightsRange(int start, int length, AttributeSet attributes) { - this.start = start; - this.end = start + length; - this.attributes = attributes; - } - - public int getStart() { - return start; - } - - public int getEnd() { - return end; - } - - public AttributeSet getAttributes() { - return attributes; - } - } - - private static class HighlightsSequenceImpl implements HighlightsSequence { - - private List ranges; - private int currentIndex; - - public HighlightsSequenceImpl() { - this(new ArrayList()); - } - - public HighlightsSequenceImpl(List ranges) { - this.ranges = ranges; - this.currentIndex = -1; - } - - public boolean moveNext() { - currentIndex++; - return currentIndex < ranges.size(); - } - - public int getStartOffset() { - return ranges.get(currentIndex).getStart(); - } - - public int getEndOffset() { - return ranges.get(currentIndex).getEnd(); - } - - public AttributeSet getAttributes() { - return ranges.get(currentIndex).getAttributes(); - } - } - - private boolean intersects(Set s1, Set s2) { - for (Object o : s1) { - if (s2.contains(o)) { - return true; - } - } - return false; - } - - public HighlightsSequence getHighlights(final int start, final int end) { - - StructuredText text = (StructuredText) context.getDocument().getProperty(StructuredText.class); - if (text == null) { - return new HighlightsSequenceImpl(); - } - final Map ranges = text.calculateRanges(); - final List highlightsRanges = new ArrayList(); - final Range baseRange = new Range(start, end - start); - - text.accept(new ElementVisitor() { - - private Stack