Mercurial > hg > truffle
changeset 4508:7e8c901c0009
Fixed more actions of the CFG editor.
line wrap: on
line diff
--- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/CfgCompilationViewer.java Tue Feb 07 21:09:31 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/CfgCompilationViewer.java Tue Feb 07 21:45:06 2012 +0100 @@ -25,7 +25,6 @@ package at.ssw.visualizer.cfg; import at.ssw.visualizer.cfg.action.*; -import at.ssw.visualizer.cfg.graph.CfgEventListener; import at.ssw.visualizer.cfg.graph.CfgScene; import at.ssw.visualizer.cfg.graph.EdgeWidget; import at.ssw.visualizer.cfg.graph.NodeWidget;
--- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/HideEdgesAction.java Tue Feb 07 21:09:31 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/HideEdgesAction.java Tue Feb 07 21:45:06 2012 +0100 @@ -1,37 +1,52 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ package at.ssw.visualizer.cfg.action; import at.ssw.visualizer.cfg.graph.CfgScene; -import at.ssw.visualizer.cfg.graph.EdgeWidget; -import at.ssw.visualizer.cfg.model.CfgEdge; -import at.ssw.visualizer.cfg.model.CfgNode; -import org.openide.util.HelpCtx; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; +import org.openide.awt.ActionID; +import org.openide.awt.ActionReference; +import org.openide.awt.ActionRegistration; -/** - * Hides all edges connected to the selected node. - * - * @author Bernhard Stiftner - * @author Rumpfhuber Stefan - */ -public class HideEdgesAction extends AbstractCfgEditorAction { +@ActionID(id = "at.ssw.visualizer.cfg.action.HideEdges", category = "View") +@ActionRegistration(displayName = "Hide Edges", iconBase="at/ssw/visualizer/cfg/icons/hideedges.gif") +@ActionReference(path = "CompilationViewer/CFG/Actions", position = 180) +public class HideEdgesAction implements ActionListener { - public void performAction() { - CfgScene tc = getEditor(); - if (tc != null) { - tc.setSelectedEdgesVisibility(false); + private List<CfgScene> scenes; + + public HideEdgesAction(List<CfgScene> scenes) { + this.scenes = scenes; + } + + @Override + public void actionPerformed(ActionEvent e) { + for (CfgScene scene : scenes) { + scene.setSelectedEdgesVisibility(false); } } - - public String getName() { - return "Hide Edges"; - } - - @Override - protected String iconResource() { - return "at/ssw/visualizer/cfg/icons/hideedges.gif"; - } - - public HelpCtx getHelpCtx() { - return HelpCtx.DEFAULT_HELP; - } }
--- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/HierarchicalCompoundLayoutAction.java Tue Feb 07 21:09:31 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/HierarchicalCompoundLayoutAction.java Tue Feb 07 21:45:06 2012 +0100 @@ -33,7 +33,7 @@ import org.openide.awt.ActionRegistration; -@ActionID(id = "HierarchicalCompoundLayout", category = "View") +@ActionID(id = "at.ssw.visualizer.cfg.action.HierarchicalCompoundLayout", category = "View") @ActionRegistration(displayName = "Compound Layout", iconBase="at/ssw/visualizer/cfg/icons/arrangeloop.gif") @ActionReference(path = "CompilationViewer/CFG/Actions", position = 150) public class HierarchicalCompoundLayoutAction implements ActionListener {
--- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/HierarchicalNodeLayoutAction.java Tue Feb 07 21:09:31 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/HierarchicalNodeLayoutAction.java Tue Feb 07 21:45:06 2012 +0100 @@ -33,7 +33,7 @@ import org.openide.awt.ActionRegistration; -@ActionID(id = "HierarchicalNodeLayout", category = "View") +@ActionID(id = "at.ssw.visualizer.cfg.action.HierarchicalNodeLayout", category = "View") @ActionRegistration(displayName = "Layout", iconBase="at/ssw/visualizer/cfg/icons/arrangehier.gif") @ActionReference(path = "CompilationViewer/CFG/Actions", position = 160) public class HierarchicalNodeLayoutAction implements ActionListener {
--- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/ShowAllAction.java Tue Feb 07 21:09:31 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/ShowAllAction.java Tue Feb 07 21:45:06 2012 +0100 @@ -1,3 +1,26 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ package at.ssw.visualizer.cfg.action; import at.ssw.visualizer.cfg.graph.CfgScene;
--- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/ShowEdgesAction.java Tue Feb 07 21:09:31 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/ShowEdgesAction.java Tue Feb 07 21:45:06 2012 +0100 @@ -1,37 +1,52 @@ +/* + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ package at.ssw.visualizer.cfg.action; import at.ssw.visualizer.cfg.graph.CfgScene; -import at.ssw.visualizer.cfg.graph.EdgeWidget; -import at.ssw.visualizer.cfg.model.CfgEdge; -import at.ssw.visualizer.cfg.model.CfgNode; -import org.openide.util.HelpCtx; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.List; +import org.openide.awt.ActionID; +import org.openide.awt.ActionReference; +import org.openide.awt.ActionRegistration; + -/** - * Shows all edges connected to the selected node. - * - * @author Bernhard Stiftner - * @author Rumpfhuber Stefan - */ -public class ShowEdgesAction extends AbstractCfgEditorAction { +@ActionID(id = "ShowEdges", category = "View") +@ActionRegistration(displayName = "Show Edges", iconBase="at/ssw/visualizer/cfg/icons/showedges.gif") +@ActionReference(path = "CompilationViewer/CFG/Actions", position = 170) +public class ShowEdgesAction implements ActionListener { - public void performAction() { - CfgScene tc = getEditor(); - if (tc != null) { - tc.setSelectedEdgesVisibility(true); + private List<CfgScene> scenes; + + public ShowEdgesAction(List<CfgScene> scenes) { + this.scenes = scenes; + } + + @Override + public void actionPerformed(ActionEvent e) { + for (CfgScene scene : scenes) { + scene.setSelectedEdgesVisibility(true); } } - - public String getName() { - return "Show edges"; - } - - - @Override - protected String iconResource() { - return "at/ssw/visualizer/cfg/icons/showedges.gif"; - } - - public HelpCtx getHelpCtx() { - return HelpCtx.DEFAULT_HELP; - } }
--- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/SwitchLoopClustersAction.java Tue Feb 07 21:09:31 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -package at.ssw.visualizer.cfg.action; - -import at.ssw.visualizer.cfg.graph.CfgScene; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import javax.swing.JComponent; -import javax.swing.JToggleButton; -import org.openide.util.HelpCtx; -import org.openide.util.actions.Presenter; - -public class SwitchLoopClustersAction extends AbstractCfgEditorAction implements Presenter.Toolbar { - - @Override - public void performAction() { - CfgScene tc = getEditor(); - if (tc != null) { - CfgScene scene = tc; - boolean visible = scene.isLoopClusterVisible(); - scene.setLoopWidgets(!visible); - } - } - - @Override - public String getName() { - return "Enable/Disable Loop Clusters"; - } - - @Override - protected String iconResource() { - return "at/ssw/visualizer/cfg/icons/cluster.gif"; - } - - public HelpCtx getHelpCtx() { - return HelpCtx.DEFAULT_HELP; - } - - - @Override - public JComponent getToolbarPresenter() { - return new ToolbarPresenter(); - } - - class ToolbarPresenter extends JToggleButton { - private static final String TOOLTIP_ENABLE = "Enable LoopClusters"; - private static final String TOOLTIP_DISABLE = "Disable LoopClusters"; - - public ToolbarPresenter() { - super(SwitchLoopClustersAction.this); - setText(null); - this.setToolTipText(TOOLTIP_DISABLE); - this.setSelected(true); - - this.addItemListener(new ItemListener(){ - public void itemStateChanged(ItemEvent e) { - if(isSelected()){ - setToolTipText(TOOLTIP_DISABLE); - } else { - setToolTipText(TOOLTIP_ENABLE); - } - } - }); - } - } - -}
--- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/graph/CfgEventListener.java Tue Feb 07 21:09:31 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -package at.ssw.visualizer.cfg.graph; - -import java.util.EventListener; - - -public interface CfgEventListener extends EventListener { - - /** - * the node or the edge selection got changed - */ - public void selectionChanged(CfgScene scene); - -}
--- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/graph/CfgScene.java Tue Feb 07 21:09:31 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/graph/CfgScene.java Tue Feb 07 21:45:06 2012 +0100 @@ -77,10 +77,10 @@ private CfgEnv env; private int currentLayout = -1; private JScrollPane scrollPane; - private EventListenerList listenerList = new EventListenerList(); private WidgetAction contextPopupAction = this.createContextMenuAction(this); private List<NodeWidget> nodeWidgets = null; private boolean loopClustersVisible = true; + private static String PREFERENCE_LOOP_CLUSTER = "loopClusters"; private static String PREFERENCE_ROUTER = "router"; private static String PREFERENCE_LAYOUT = "layout"; @@ -92,6 +92,8 @@ public void preferenceChange(PreferenceChangeEvent evt) { if (evt.getKey().equals(PREFERENCE_ROUTER)) { setUseBezierRouter(Boolean.parseBoolean(evt.getNewValue())); + } else if (evt.getKey().equals(PREFERENCE_LOOP_CLUSTER)) { + setLoopWidgets(Boolean.parseBoolean(evt.getNewValue())); } } }; @@ -136,6 +138,7 @@ CfgPreferences prefs = CfgPreferences.getInstance(); this.setBackground(prefs.getBackgroundColor()); setUseBezierRouter(getPreferences().getBoolean(PREFERENCE_ROUTER, true)); + setLoopWidgets(getPreferences().getBoolean(PREFERENCE_LOOP_CLUSTER, true)); setSceneLayout(getPreferences().getInt(PREFERENCE_LAYOUT, CfgEditorContext.LAYOUT_HIERARCHICALNODELAYOUT)); } @@ -235,7 +238,6 @@ out.changeEdgeVisibility(visible); } } - this.fireSelectionChanged(); this.validate(); } @@ -262,6 +264,7 @@ } this.loopClustersVisible = visible; this.validate(); + getPreferences().putBoolean(PREFERENCE_LOOP_CLUSTER, visible); } private void setUseBezierRouter(boolean value) { @@ -461,7 +464,6 @@ if (!this.selectedNodes.isEmpty()) { this.userSelectionSuggested(Collections.<CfgNode>emptySet(), false); this.selectedNodes = Collections.<CfgNode>emptySet(); - this.fireSelectionChanged(); this.validate(); } } @@ -494,7 +496,6 @@ } this.userSelectionSuggested(selectedObjects, false); - this.fireSelectionChanged(); this.validate(); } @@ -583,23 +584,6 @@ this.setZoomFactor(zoomFactor * 0.9); } - public void addCfgEventListener(CfgEventListener l) { - listenerList.add(CfgEventListener.class, l); - } - - public void removeCfgEventListener(CfgEventListener l) { - listenerList.remove(CfgEventListener.class, l); - } - - public void fireSelectionChanged() { - Object[] listeners = listenerList.getListenerList(); - for (int i = listeners.length - 2; i >= 0; i -= 2) { - if (listeners[i] == CfgEventListener.class) { - ((CfgEventListener) listeners[i + 1]).selectionChanged(this); - } - } - } - //Enables Antialiasing @Override public void paintChildren() { @@ -776,8 +760,6 @@ } } - menu.add(SystemAction.get(ShowEdgesAction.class)); - menu.add(SystemAction.get(HideEdgesAction.class)); return menu; } });
--- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/graph/EdgeSwitchWidget.java Tue Feb 07 21:09:31 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/graph/EdgeSwitchWidget.java Tue Feb 07 21:45:06 2012 +0100 @@ -193,7 +193,6 @@ else this.setToolTipText(TT_SHOW_EDGES); - scene.fireSelectionChanged();//updates Edge visibility for context action revalidate(); }
--- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/graph/NodeWidget.java Tue Feb 07 21:09:31 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/graph/NodeWidget.java Tue Feb 07 21:45:06 2012 +0100 @@ -32,7 +32,6 @@ private final int FONT_MAXSIZE=18; private int borderWidth; - private boolean selected=false; private boolean nodeColorCustomized; private String text; private Rectangle2D fontRect; @@ -44,7 +43,6 @@ public NodeWidget(CfgScene scene, CfgNode nodeModel ){ super(scene); this.setToolTipText("<html>" + nodeModel.getDescription().replaceAll("\n", "<br>") + "</html>"); - this.selected=false; this.text = nodeModel.getBasicBlock().getName(); this.borderWidth = nodeModel.getLoopDepth()+1; this.setBorder(BorderFactory.createRoundedBorder(arcWidth+borderWidth, arcHeight+borderWidth, borderWidth, borderWidth, Color.BLACK, Color.BLACK));
--- a/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/layer.xml Tue Feb 07 21:09:31 2012 +0100 +++ b/src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/layer.xml Tue Feb 07 21:45:06 2012 +0100 @@ -11,62 +11,20 @@ <folder name="CFG"> <folder name="Actions"> <file name="com-oracle-graal-visualizer-cfg-RouterAction.instance"> - <attr name="displayName" stringvalue="Bezier routing"/> + <attr name="displayName" stringvalue="Use bezier routing"/> <attr methodvalue="org.openide.awt.Actions.checkbox" name="instanceCreate"/> <attr name="iconBase" stringvalue="at/ssw/visualizer/cfg/icons/bezierrouter.gif"/> <attr name="preferencesNode" methodvalue="at.ssw.visualizer.cfg.graph.CfgScene.getPreferences"/> <attr name="preferencesKey" stringvalue="router"/> </file> + <file name="com-oracle-graal-visualizer-cfg-LoopClusterAction.instance"> + <attr name="displayName" stringvalue="Show loop clusters"/> + <attr methodvalue="org.openide.awt.Actions.checkbox" name="instanceCreate"/> + <attr name="iconBase" stringvalue="at/ssw/visualizer/cfg/icons/cluster.gif"/> + <attr name="preferencesNode" methodvalue="at.ssw.visualizer.cfg.graph.CfgScene.getPreferences"/> + <attr name="preferencesKey" stringvalue="loopClusters"/> + </file> </folder> </folder> </folder> - <folder name="Actions"> - <folder name="Window"> - <file name="ShowCFGEditor.instance"> - <attr name="instanceClass" stringvalue="at.ssw.visualizer.cfg.action.ShowCFGEditorAction"/> - </file> - </folder> - <folder name="View"> - <file name="ShowEdges.instance"> - <attr name="instanceClass" stringvalue="at.ssw.visualizer.cfg.action.ShowEdgesAction"/> - </file> - <file name="HideEdges.instance"> - <attr name="instanceClass" stringvalue="at.ssw.visualizer.cfg.action.HideEdgesAction"/> - </file> - <file name="Export.instance"> - <attr name="instanceClass" stringvalue="at.ssw.visualizer.cfg.action.ExportAction"/> - </file> - <file name="Zoomin.instance"> - <attr name="instanceClass" stringvalue="at.ssw.visualizer.cfg.action.ZoominAction"/> - </file> - <file name="Zoomout.instance"> - <attr name="instanceClass" stringvalue="at.ssw.visualizer.cfg.action.ZoomoutAction"/> - </file> - <file name="ShowAll.instance"> - <attr name="instanceClass" stringvalue="at.ssw.visualizer.cfg.action.ShowAllAction"/> - </file> - </folder> - </folder> - - <folder name="Menu"> - <folder name="BuildProject_hidden"> - <file name="at-ssw-visualizer-cfg-action-SomeAction.shadow"> - <attr name="originalFile" stringvalue="Actions/Build/at-ssw-visualizer-cfg-action-SomeAction.instance"/> - </file> - </folder> - <folder name="Window"> - <file name="ShowCFGEditor.shadow"> - <attr name="originalFile" stringvalue="Actions/Window/ShowCFGEditor.instance"/> - <attr name="position" intvalue="1300"/> - </file> - </folder> - </folder> - - <folder name="at-ssw-visualizer-actions-cfg"> - <file name="ShowCFGEditor.shadow"> - <attr name="originalFile" stringvalue="Actions/Window/ShowCFGEditor.instance"/> - <attr name="position" intvalue="300"/> - </file> - </folder> - </filesystem>