Mercurial > hg > graal-jvmci-8
changeset 4393:86b40f74c8af
Removing unused projects.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Sat, 28 Jan 2012 21:53:02 +0100 |
parents | a04feadb1d47 |
children | cf609017d3d4 |
files | src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockConnectionWidget.java src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/BlockWidget.java src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/Bundle.properties src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowAction.java src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowScene.java src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.form src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponent.java src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponentSettings.xml src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/ControlFlowTopComponentWstcref.xml src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/DoubleClickSelectAction.java src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/HierarchicalGraphLayout.java src/share/tools/IdealGraphVisualizer/ControlFlow/src/com/sun/hotspot/igv/controlflow/layer.xml src/share/tools/IdealGraphVisualizer/Data/src/com/sun/hotspot/igv/data/serialization/Parser.java src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/Bundle.properties src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextAction.java src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.form src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponent.java src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponentSettings.xml src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/TextTopComponentWstcref.xml src/share/tools/IdealGraphVisualizer/GraphTextEditor/src/com/sun/hotspot/igv/graphtexteditor/layer.xml src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/BFSGraphToTextConverter.java src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/Bundle.properties src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/AbstractGraphToTextVisitor.java src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/GraphToTextConverter.java src/share/tools/IdealGraphVisualizer/GraphToText/src/com/sun/hotspot/igv/graphtotext/services/GraphToTextVisitor.java src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/com/sun/hotspot/igv/java6scriptingproxy/Bundle.properties src/share/tools/IdealGraphVisualizer/Java6ScriptingProxy/src/com/sun/hotspot/igv/java6scriptingproxy/JavaSE6ScriptEngine.java src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/META-INF/services/com.sun.hotspot.igv.filter.ScriptEngineAbstraction src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/Bundle.properties src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/RhinoScriptEngine.java src/share/tools/IdealGraphVisualizer/RhinoScriptEngineProxy/src/com/sun/hotspot/igv/rhino/layer.xml src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Bundle.properties src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Element.java src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/MultiElement.java src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/Range.java src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/SimpleElement.java src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/StructuredText.java src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/ToolTipProvider.java src/share/tools/IdealGraphVisualizer/StructuredText/src/com/sun/hotspot/igv/structuredtext/services/ElementVisitor.java src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/Bundle.properties src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/SyntaxLayer.java src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextEditor.java src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextEditorKit.java src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextFoldManager.java src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextFoldManagerFactory.java src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextHighlightsLayerFactory.java src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextSideBarFactory.java src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/layer.xml src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/org-netbeans-modules-editor-preferences.xml |
diffstat | 50 files changed, 5 insertions(+), 3601 deletions(-) [+] |
line wrap: on
line diff
--- 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<Point> 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<Point> p) { - this.points = p; - } - - @Override - public List<Point> getControlPoints() { - return points; - } - - @Override - public String toString() { - return "Connection[ " + from.toString() + " - " + to.toString() + "]"; - } - - @Override - public boolean isVIP() { - return false; - } -}
--- 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); - } - } - } -}
--- 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
--- 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(); - } -}
--- 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<InputBlock, InputBlockEdge> implements SelectProvider, MoveProvider, RectangularSelectDecorator, RectangularSelectProvider { - - private HashSet<BlockWidget> 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<InputBlock> blocks = new ArrayList<>(this.getNodes()); - for (InputBlock b : blocks) { - removeNode(b); - } - - ArrayList<InputBlockEdge> 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<InputBlock, InputBlockEdge> 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<InputNode> 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))); - } -}
--- 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 @@ -<?xml version="1.0" encoding="UTF-8" ?> - -<Form version="1.3" maxVersion="1.3" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> - <AuxValues> - <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> - <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> - <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/> - <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="2"/> - <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> - <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> - </AuxValues> - - <Layout> - <DimensionLayout dim="0"> - <Group type="103" groupAlignment="0" attributes="0"> - <EmptySpace min="0" pref="400" max="32767" attributes="0"/> - </Group> - </DimensionLayout> - <DimensionLayout dim="1"> - <Group type="103" groupAlignment="0" attributes="0"> - <EmptySpace min="0" pref="300" max="32767" attributes="0"/> - </Group> - </DimensionLayout> - </Layout> -</Form>
--- 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. - */ - // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//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) - ); - }// </editor-fold>//GEN-END:initComponents - // Variables declaration - do not modify//GEN-BEGIN:variables - // End of variables declaration//GEN-END:variables - - /** - * Gets default instance. Do not use directly: reserved for *.settings files only, - * i.e. deserialization routines; otherwise you could get a non-deserialized instance. - * 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<InputGraphProvider> 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(); - } - } -}
--- 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN" "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd"> -<settings version="1.0"> - <module name="com.sun.hotspot.igv.controlflow" spec="1.0"/> - <instanceof class="org.openide.windows.TopComponent"/> - <instanceof class="com.sun.hotspot.igv.controlflow.ControlFlowTopComponent"/> - <instance class="com.sun.hotspot.igv.controlflow.ControlFlowTopComponent" method="getDefault"/> -</settings>
--- 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE tc-ref PUBLIC "-//NetBeans//DTD Top Component in Mode Properties 2.0//EN" "http://www.netbeans.org/dtds/tc-ref2_0.dtd"> -<tc-ref version="2.0" > - <module name="com.sun.hotspot.igv.controlflow" spec="1.0"/> - <tc-id id="ControlFlowTopComponent"/> - <state opened="true"/> -</tc-ref>
--- 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; - } -}
--- 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<N, E> extends GraphLayout<N, E> { - - 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<Point> getControlPoints() { - return new ArrayList<>(); - } - - @Override - public void setControlPoints(List<Point> list) { - // Do nothing for now - } - - @Override - public boolean isVIP() { - return false; - } - } - - private class VertexWrapper implements Vertex { - - private N node; - private UniversalGraph<N, E> graph; - private Port slot; - private Point position; - - public VertexWrapper(N node, UniversalGraph<N, E> 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<N, E> graph) { - - Set<LinkWrapper> links = new LinkedHashSet<>(); - Set<VertexWrapper> vertices = new LinkedHashSet<>(); - Map<N, VertexWrapper> 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<N, E> graph, Collection<N> nodes) { - throw new UnsupportedOperationException(); - } -}
--- 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd"> -<filesystem> - <folder name="Actions"> - <folder name="Window"> - <file name="com-sun-hotspot-igv-controlflow-ControlFlowAction.instance"/> - </folder> - </folder> - <folder name="Menu"> - <folder name="Window"> - <file name="ControlFlowAction.shadow"> - <attr name="originalFile" stringvalue="Actions/Window/com-sun-hotspot-igv-controlflow-ControlFlowAction.instance"/> - </file> - </folder> - </folder> - <folder name="Windows2"> - <folder name="Components"> - <file name="ControlFlowTopComponent.settings" url="ControlFlowTopComponentSettings.xml"/> - </folder> - <folder name="Modes"> - <folder name="customRightTopMode"> - <file name="ControlFlowTopComponent.wstcref" url="ControlFlowTopComponentWstcref.xml"/> - </folder> - </folder> - </folder> -</filesystem>
--- 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<String, Integer> idCache = new HashMap<>(); private ArrayList<Pair<String, String>> 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; } }; // <group> @@ -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 {
--- 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
--- 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(); - } -}
--- 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 @@ -<?xml version="1.1" encoding="UTF-8" ?> - -<Form version="1.4" maxVersion="1.6" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> - <AuxValues> - <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/> - <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> - <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/> - <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> - <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> - <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> - <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> - <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> - <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/> - </AuxValues> - - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/> -</Form>
--- 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<? extends GraphToTextConverter> 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<InputGraph, InputGraph> 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<DiagramProvider> diagramChangedListener = new ChangedListener<DiagramProvider>() { - - 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. - */ - // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents - private void initComponents() { - - setLayout(new java.awt.BorderLayout()); - }// </editor-fold>//GEN-END:initComponents - - - // Variables declaration - do not modify//GEN-BEGIN:variables - // End of variables declaration//GEN-END:variables - /** - * Gets default instance. Do not use directly: reserved for *.settings files only, - * i.e. deserialization routines; otherwise you could get a non-deserialized instance. - * 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<DiagramProvider> tpl = new Lookup.Template<DiagramProvider>(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(); - } - } -}
--- 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -To change this template, choose Tools | Templates -and open the template in the editor. ---> -<!DOCTYPE settings PUBLIC "-//NetBeans//DTD Session settings 1.0//EN" "http://www.netbeans.org/dtds/sessionsettings-1_0.dtd"> -<settings version="1.0"> - <module name="com.sun.hotspot.igv.graphtexteditor" spec="1.0"/> - <instanceof class="org.openide.windows.TopComponent"/> - <instanceof class="com.sun.hotspot.igv.graphtexteditor.TextTopComponent"/> - <instance class="com.sun.hotspot.igv.graphtexteditor.TextTopComponent" method="getDefault"/> -</settings>
--- 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -To change this template, choose Tools | Templates -and open the template in the editor. ---> -<!DOCTYPE tc-ref PUBLIC "-//NetBeans//DTD Top Component in Mode Properties 2.0//EN" "http://www.netbeans.org/dtds/tc-ref2_0.dtd"> -<tc-ref version="2.0" > - <module name="com.sun.hotspot.igv.graphtexteditor" spec="1.0"/> - <tc-id id="TextTopComponent"/> - <state opened="true"/> -</tc-ref>
--- 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd"> -<filesystem> - <folder name="Actions"> - <folder name="Window"> - <file name="com-sun-hotspot-igv-graphtexteditor-TextAction.instance"/> - </folder> - </folder> - <folder name="Menu"> - <folder name="Window"> - <file name="TextAction.shadow"> - <attr name="originalFile" stringvalue="Actions/Window/com-sun-hotspot-igv-graphtexteditor-TextAction.instance"/> - </file> - </folder> - </folder> - <folder name="Windows2"> - <folder name="Components"> - <file name="TextTopComponent.settings" url="TextTopComponentSettings.xml"/> - </folder> - <folder name="Modes"> - <folder name="customRightTopMode"> - <file name="TextTopComponent.wstcref" url="TextTopComponentWstcref.xml"/> - </folder> - </folder> - </folder> - -</filesystem>
--- 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<Properties.PropertyMatcher, GraphToTextVisitor> visitorMap; - private InputGraph graph; - private Diagram diagram; - - public BFSGraphToTextConverter(GraphToTextVisitor visitor) { - this.visitor = visitor; - visitorMap = new HashMap<Properties.PropertyMatcher, GraphToTextVisitor>(); - } - - 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<InputEdge> path) { - return chooseVisitor(visitor, node).cyclicVisit(node, path); - } - - private Element visit(GraphToTextVisitor visitor, InputNode node, List<InputEdge> path, List<Pair<InputEdge, Element>> 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<InputNode, List<InputEdge>> outgoing = graph.findAllOutgoingEdges(); - Map<InputNode, List<InputEdge>> pathMap = new HashMap<InputNode, List<InputEdge>>(); - Queue<InputNode> queue = new LinkedList<InputNode>(); - List<InputNode> rootNodes = graph.findRootNodes(); - queue.addAll(rootNodes); - for(InputNode node : rootNodes) { - pathMap.put(node, new ArrayList<InputEdge>()); - } - - Set<InputNode> visited = new HashSet<InputNode>(); - visited.addAll(rootNodes); - - Set<InputEdge> fullEdges = new HashSet<InputEdge>(); - List<InputNode> visitOrder = new ArrayList<InputNode>(); - while(!queue.isEmpty()) { - - InputNode current = queue.remove(); - visitOrder.add(current); - List<InputEdge> path = pathMap.get(current); - - List<InputEdge> 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<InputEdge> curPath = new ArrayList<InputEdge>(path); - curPath.add(e); - pathMap.put(dest, curPath); - fullEdges.add(e); - } - } - } - - - - Map<InputNode, Element> fullVisitCache = new HashMap<InputNode, Element>(); - for(int i=visitOrder.size() - 1; i>=0; i--) { - InputNode current = visitOrder.get(i); - List<InputEdge> path = pathMap.get(current); - List<InputEdge> edges = outgoing.get(current); - List<Pair<InputEdge, Element>> list = new ArrayList<Pair<InputEdge, Element>>(); - for(InputEdge e : edges) { - if(fullEdges.contains(e)) { - assert fullVisitCache.containsKey(graph.getNode(e.getTo())); - list.add(new Pair<InputEdge, Element>(e, fullVisitCache.get(graph.getNode(e.getTo())))); - } else { -// assert fullVisitCache.containsKey(graph.getNode(e.getTo())); - List<InputEdge> curPath = new ArrayList<InputEdge>(path); - curPath.add(e); - list.add(new Pair<InputEdge, Element>(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; - } -}
--- 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
--- 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<InputEdge> path) { - return SimpleElement.EMPTY; - } - - public Element visit(InputNode node, List<InputEdge> path, List<Pair<InputEdge, Element>> children) { - return cyclicVisit(node, path); - } - -}
--- 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); -}
--- 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<InputEdge> path); - Element visit(InputNode node, List<InputEdge> path, List<Pair<InputEdge, Element>> children); -}
--- 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
--- 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
--- 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(); - } - } -}
--- 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
--- 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
--- 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, "<cmd>", 1, null); - } finally { - // Exit from the context. - context_exit.invoke(null, (Object[]) null); - } - } catch (Exception e) { - e.printStackTrace(); - } - } -}
--- 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 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd"> -<filesystem> -</filesystem>
--- 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
--- 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<Object> source; - private Style style; - private Style highlightedStyle; - - public Element() { - source = new HashSet<Object>(); - 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<Object> getSource() { - return Collections.unmodifiableSet(source); - } - - public void addSource(Object o) { - source.add(o); - } - - public abstract void accept(ElementVisitor visitor); -}
--- 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<Element> 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<Element>(); - } - - 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<Element> getChildren() { - return Collections.unmodifiableList(children); - } - - public void accept(ElementVisitor visitor) { - visitor.visit(this); - } -}
--- 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; - } - -}
--- 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); - } -}
--- 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<Element, Range> calculateRanges() { - - final Map<Element, Range> result = new HashMap<Element, Range>(); - - 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(); - } -}
--- 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(); - -}
--- 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); -}
--- 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
--- 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<SelectionCoordinator> { - - 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<Object> highlightedSource = new HashSet<Object>(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<Object> selectedSource = new HashSet<Object>(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<Object>()); - } - }); - } - - 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<HighlightsRange> ranges; - private int currentIndex; - - public HighlightsSequenceImpl() { - this(new ArrayList<HighlightsRange>()); - } - - public HighlightsSequenceImpl(List<HighlightsRange> 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<Object> s1, Set<Object> 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<Element, Range> ranges = text.calculateRanges(); - final List<HighlightsRange> highlightsRanges = new ArrayList<HighlightsRange>(); - final Range baseRange = new Range(start, end - start); - - text.accept(new ElementVisitor() { - - private Stack<Style> styleStack = new Stack<Style>(); - private Stack<Style> highlightedStyleStack = new Stack<Style>(); - private Stack<MultiElement> parentElements = new Stack<MultiElement>(); - - @Override - public void visit(MultiElement element) { - Style curStyle = element.getStyle(); - Style curHighlightedStyle = element.getHighlightedStyle(); - if(curStyle != null) { - styleStack.push(curStyle); - } - if (curHighlightedStyle != null) { - highlightedStyleStack.push(curHighlightedStyle); - } - parentElements.push(element); - super.visit(element); - if(curStyle != null) { - styleStack.pop(); - } - if (curHighlightedStyle != null) { - highlightedStyleStack.pop(); - } - parentElements.pop(); - } - - - @Override - public void visit(SimpleElement element) { - Range curRange = ranges.get(element); - if (baseRange.overlaps(curRange)) { - Style style = element.getStyle(); - if(style == null) { - if(styleStack.size() > 0) { - style = styleStack.peek(); - } else { - style = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE); - StyleConstants.setBackground(style, Color.WHITE); - } - } - - - Style highlightedStyle = element.getHighlightedStyle(); - if (highlightedStyle == null) { - if (highlightedStyleStack.size() > 0) { - highlightedStyle = highlightedStyleStack.peek(); - } - } - - Set<Object> highlightedSource = SelectionCoordinator.getInstance().getHighlightedObjects(); - if (highlightedSource != null) { - - boolean doesIntersect = intersects(element.getSource(), highlightedSource); - for (MultiElement parentElement : parentElements) { - if (doesIntersect) { - break; - } - - doesIntersect = intersects(parentElement.getSource(), highlightedSource); - } - - if (doesIntersect) { - - if (highlightedStyle != null) { - style = highlightedStyle; - } else { - style = StyleContext.getDefaultStyleContext().addStyle(null, style); - Color bg = StyleConstants.getBackground(style); - Color fg = StyleConstants.getForeground(style); - StyleConstants.setBackground(style, new Color(255 - bg.getRed(), 255 - bg.getGreen(), 255 - bg.getBlue())); - StyleConstants.setForeground(style, new Color(255 - fg.getRed(), 255 - fg.getGreen(), 255 - fg.getBlue())); - } - } - } - - Set<Object> selectedSource = SelectionCoordinator.getInstance().getSelectedObjects(); - if (selectedSource != null && intersects(element.getSource(), selectedSource)) { - style = StyleContext.getDefaultStyleContext().addStyle(null, style); - StyleConstants.setBold(style, true); - } - - highlightsRanges.add(new HighlightsRange(curRange.getStart(), curRange.getLength(), style)); - } - } - }); - - return new HighlightsSequenceImpl(highlightsRanges); - } -}
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextEditor.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,154 +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.structuredtext.Element; -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.services.ElementVisitor; -import java.awt.Component; -import java.util.HashSet; -import java.util.Set; -import javax.swing.JEditorPane; -import javax.swing.SwingUtilities; -import javax.swing.text.BadLocationException; -import javax.swing.text.Document; -import javax.swing.text.Position; -import javax.swing.text.SimpleAttributeSet; -import org.netbeans.modules.editor.NbEditorDocument; -import org.netbeans.modules.editor.NbEditorUtilities; -import org.openide.text.Annotation; -import org.openide.text.Line; -import org.openide.util.Exceptions; - -/** - * - * @author Thomas Wuerthinger - */ -public class TextEditor { - - private JEditorPane editorPane; - private Component component; - private Set<Annotation> addedAnnotations; - - public TextEditor() { - editorPane = new JEditorPane(); - component = createEditor(editorPane); - addedAnnotations = new HashSet<Annotation>(); - - } - - public Component getComponent() { - return component; - } - - public void setStructuredText(StructuredText text) { - assert text != null; - - setStructuredText(text, null); - } - - public void setStructuredText(final StructuredText text, final Element focusedElement) { - - assert text != null; - - SwingUtilities.invokeLater(new Runnable() { - - public void run() { - Document doc = editorPane.getDocument(); - doc.putProperty(StructuredText.class, text); - - for (Annotation a : addedAnnotations) { - ((NbEditorDocument) editorPane.getDocument()).removeAnnotation(a); - } - - try { - editorPane.getDocument().remove(0, editorPane.getDocument().getLength()); - editorPane.getDocument().insertString(0, text.convertToString(), SimpleAttributeSet.EMPTY); - - text.accept(new ElementVisitor() { - - private int pos = 0; - - private void checkForFocus(Element element) { - if (element == focusedElement) { - editorPane.setCaretPosition(pos); - } - } - - @Override - public void visit(MultiElement element) { - super.visit(element); - checkForFocus(element); - } - - @Override - public void visit(SimpleElement element) { - checkForFocus(element); - for (Object o : element.getSource()) { - if (o instanceof Annotation) { - Annotation a = (Annotation) o; - final Line line = NbEditorUtilities.getLine(editorPane.getDocument(), pos, false); - - ((NbEditorDocument) editorPane.getDocument()).addAnnotation(new PositionImpl(pos), element.getText().length(), a); - addedAnnotations.add(a); - } - } - pos += element.getText().length(); - } - - class PositionImpl implements Position { - - private int position; - - public PositionImpl(int position) { - this.position = position; - } - - public int getOffset() { - return position; - } - } - }); - - } catch (BadLocationException ex) { - Exceptions.printStackTrace(ex); - } - - } - }); - - } - - private Component createEditor(JEditorPane pane) { - TextEditorKit kit = new TextEditorKit(); - pane.setEditable(false); - NbEditorDocument doc = (NbEditorDocument) kit.createDefaultDocument(); - pane.setEditorKit(kit); - pane.setDocument(doc); - return doc.createEditor(pane); - } -}
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextEditorKit.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,101 +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.texteditor; - -import java.util.ArrayList; -import java.util.List; -import javax.swing.Action; -import org.netbeans.editor.BaseDocument; -import org.netbeans.modules.editor.NbEditorKit; - -/** - * - * @author Thomas Wuerthinger - */ -public class TextEditorKit extends NbEditorKit { - - public static final String MIME_TYPE = "text/text-igv"; - - /** - * Actions to be not available in the editor. - */ - private static final String[] ACTION_FILTER = { - NbEditorKit.shiftLineLeftAction, - NbEditorKit.shiftLineRightAction, - NbEditorKit.jumpListNextAction, - NbEditorKit.jumpListNextComponentAction, - NbEditorKit.jumpListPrevAction, - NbEditorKit.jumpListPrevComponentAction, - NbEditorKit.pasteAction, - NbEditorKit.removeLineAction, - NbEditorKit.cutAction, - NbEditorKit.findAction, - NbEditorKit.findNextAction, - NbEditorKit.findPreviousAction, - NbEditorKit.toggleHighlightSearchAction, - NbEditorKit.findSelectionAction, - "jump-list-last-edit" - }; - - @Override - protected Action[] createActions() { - Action[] actions = super.createActions(); - List<Action> returnedActions = new ArrayList<Action>(); - for(Action a : actions) { - System.out.println("action: " + a.getValue(Action.NAME)); - - boolean found = false; - for(String s : ACTION_FILTER) { - if(s.equals(a.getValue(Action.NAME))) { - found = true; - } - } - if(!found) { - returnedActions.add(a); - } - } - - Action[] result = new Action[returnedActions.size()]; - for(int i=0; i<returnedActions.size(); i++) { - result[i] = returnedActions.get(i); - } - - return result; - } - - @Override - protected void initDocument(BaseDocument doc) { - super.initDocument(doc); - System.out.println("Initializing document: " + doc); - - } - - @Override - public String getContentType() { - return MIME_TYPE; - } - - -}
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextFoldManager.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +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.texteditor; - -import com.sun.hotspot.igv.structuredtext.MultiElement; -import com.sun.hotspot.igv.structuredtext.SimpleElement; -import javax.swing.event.DocumentEvent; -import javax.swing.text.BadLocationException; -import org.netbeans.api.editor.fold.Fold; -import org.netbeans.spi.editor.fold.FoldHierarchyTransaction; -import org.netbeans.spi.editor.fold.FoldManager; -import org.netbeans.spi.editor.fold.FoldOperation; -import com.sun.hotspot.igv.structuredtext.Element; -import com.sun.hotspot.igv.structuredtext.Range; -import com.sun.hotspot.igv.structuredtext.StructuredText; -import com.sun.hotspot.igv.structuredtext.services.ElementVisitor; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.logging.Logger; -import javax.swing.text.Document; -import org.netbeans.api.editor.fold.FoldType; - -/** - * - * @author Thomas Wuerthinger - */ -public class TextFoldManager implements FoldManager { - - private FoldOperation operation; - private final FoldType defaultFoldType = new FoldType("default"); - private Set<Fold> currentFolds; - - public TextFoldManager() { - currentFolds = new HashSet<Fold>(); - } - - public void init(FoldOperation operation) { - this.operation = operation; - } - - public void initFolds(final FoldHierarchyTransaction transaction) { - } - - private void update(Document document, final FoldHierarchyTransaction transaction) { - - - StructuredText text = (StructuredText) document.getProperty(StructuredText.class); - if (text == null) { - // No StructuredText object behind the document object. - return; - } - - if(document.getLength() == 0) { - return; - } - - final Map<Element, Range> ranges = text.calculateRanges(); - currentFolds.clear(); - - text.accept(new ElementVisitor() { - @Override - public void visit(MultiElement element) { - super.visit(element); - Range curRange = ranges.get(element); - - if (element.getFoldString() != null) { - try { - Fold f = operation.addToHierarchy(defaultFoldType, element.getFoldString(), false, - curRange.getStart(), curRange.getStart() + curRange.getLength(), 0, 0, - null, transaction); - currentFolds.add(f); - } catch (BadLocationException ex) { - assert false : "Structured text not in sync with document content " + ex.getStackTrace(); - } - } - } - - @Override - public void visit(SimpleElement element) { - } - }); - } - - public void insertUpdate(DocumentEvent event, FoldHierarchyTransaction transaction) { - update(event.getDocument(), transaction); - } - - public void removeUpdate(DocumentEvent event, FoldHierarchyTransaction transaction) { - update(event.getDocument(), transaction); - } - - public void changedUpdate(DocumentEvent event, FoldHierarchyTransaction transaction) { -// update(event.getDocument(), transaction); - } - - public void removeEmptyNotify(Fold arg0) { - } - - public void removeDamagedNotify(Fold arg0) { - } - - public void expandNotify(Fold arg0) { - } - - public void release() { - } -}
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextFoldManagerFactory.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +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.texteditor; - -import org.netbeans.spi.editor.fold.FoldManager; -import org.netbeans.spi.editor.fold.FoldManagerFactory; - -/** - * - * @author Thomas Wuerthinger - */ -public class TextFoldManagerFactory implements FoldManagerFactory{ - public FoldManager createFoldManager() { - return new TextFoldManager(); - } -}
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextHighlightsLayerFactory.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) 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.texteditor; - -import org.netbeans.spi.editor.highlighting.HighlightsLayer; -import org.netbeans.spi.editor.highlighting.HighlightsLayerFactory; -import org.netbeans.spi.editor.highlighting.ZOrder; - -/** - * - * @author Thomas Wuerthinger - */ -public class TextHighlightsLayerFactory implements HighlightsLayerFactory { - public HighlightsLayer[] createLayers(HighlightsLayerFactory.Context context) { - return new HighlightsLayer[] { - HighlightsLayer.create("com.sun.hotspot.igv.texteditor.SyntaxLayer", ZOrder.TOP_RACK, true, new SyntaxLayer(context)) - }; - } - -}
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/TextSideBarFactory.java Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ -package com.sun.hotspot.igv.texteditor; - -import javax.swing.JComponent; -import javax.swing.text.JTextComponent; -import org.netbeans.editor.CodeFoldingSideBar; -import org.netbeans.editor.SideBarFactory; - -/** - * - * @author Thomas Wuerthinger - */ -public class TextSideBarFactory implements SideBarFactory { - public JComponent createSideBar(JTextComponent text) { - return new CodeFoldingSideBar(text); - } -}
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/layer.xml Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd"> -<filesystem> - - <folder name="Editors"> - <folder name="Preferences"/> - <folder name="text"> - <folder name="text-igv"> - <file name="EditorKit.instance"> - <attr name="instanceClass" stringvalue="com.sun.hotspot.igv.texteditor.TextEditorKit"/> - </file> - <folder name="FoldManager"> - <file name="com-sun-hotspot-igv-texteditor-TextFoldManagerFactory.instance"/> - </folder> - <folder name="Preferences"> - <file name="org-netbeans-modules-editor-preferences.xml" url="org-netbeans-modules-editor-preferences.xml"/> - </folder> - <folder name="SideBar"> - <file name="com-sun-hotspot-igv-texteditor-TextSideBarFactory.instance"> - <attr name="position" intvalue="1500"/> - </file> - </folder> - <file name="com-sun-hotspot-igv-texteditor-TextHighlightsLayerFactory.instance"/> - </folder> - </folder> - </folder> -</filesystem>
--- a/src/share/tools/IdealGraphVisualizer/TextEditor/src/com/sun/hotspot/igv/texteditor/org-netbeans-modules-editor-preferences.xml Sat Jan 28 21:44:17 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,51 +0,0 @@ -<?xml version="1.0"?> -<!-- -DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. - -Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. - - -The contents of this file are subject to the terms of either the GNU -General Public License Version 2 only ("GPL") or the Common -Development and Distribution License("CDDL") (collectively, the -"License"). You may not use this file except in compliance with the -License. You can obtain a copy of the License at -http://www.netbeans.org/cddl-gplv2.html -or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the -specific language governing permissions and limitations under the -License. When distributing the software, include this License Header -Notice in each file and include the License file at -nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this -particular file as subject to the "Classpath" exception as provided -by Sun in the GPL Version 2 section of the License file that -accompanied this code. If applicable, add the following below the -License Header, with the fields enclosed by brackets [] replaced by -your own identifying information: -"Portions Copyrighted [year] [name of copyright owner]" - -Contributor(s): - -The Original Software is NetBeans. The Initial Developer of the Original -Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun -Microsystems, Inc. All Rights Reserved. - -If you wish your version of this file to be governed by only the CDDL -or only the GPL Version 2, indicate your decision by adding -"[Contributor] elects to include this software in this distribution -under the [CDDL or GPL Version 2] license." If you do not indicate a -single choice of license, a recipient has the option to distribute -your version of this file under either the CDDL, the GPL Version 2 or -to extend the choice of license to its licensees as provided above. -However, if you add GPL Version 2 code and therefore, elected the GPL -Version 2 license, then the option applies only if the new code is -made subject to such option by the copyright holder. ---> -<!DOCTYPE editor-preferences PUBLIC "-//NetBeans//DTD Editor Preferences 1.0//EN" "http://www.netbeans.org/dtds/EditorPreferences-1_0.dtd"> - -<editor-preferences> - <entry name="toolbarVisible" value="false" javaType="java.lang.Boolean" /> - <entry name="line-number-visible" value="false" javaType="java.lang.Boolean" /> - <entry name="code-folding-enable" value="true" javaType="java.lang.Boolean" /> - <entry name="status-bar-visible" value="false" javaType="java.lang.Boolean" /> - <entry name="text-limit-line-visible" value="false" javaType="java.lang.Boolean" /> -</editor-preferences>