# HG changeset patch # User Thomas Wuerthinger # Date 1328647506 -3600 # Node ID 7e8c901c00090a67e976530fb1c01d8371c07880 # Parent 9d640941c9c7fa04d3bec8dbfa08bf2c4aef6995 Fixed more actions of the CFG editor. diff -r 9d640941c9c7 -r 7e8c901c0009 src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/CfgCompilationViewer.java --- 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; diff -r 9d640941c9c7 -r 7e8c901c0009 src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/HideEdgesAction.java --- 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 scenes; + + public HideEdgesAction(List 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; - } } diff -r 9d640941c9c7 -r 7e8c901c0009 src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/HierarchicalCompoundLayoutAction.java --- 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 { diff -r 9d640941c9c7 -r 7e8c901c0009 src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/HierarchicalNodeLayoutAction.java --- 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 { diff -r 9d640941c9c7 -r 7e8c901c0009 src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/ShowAllAction.java --- 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; diff -r 9d640941c9c7 -r 7e8c901c0009 src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/ShowEdgesAction.java --- 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 scenes; + + public ShowEdgesAction(List 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; - } } diff -r 9d640941c9c7 -r 7e8c901c0009 src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/action/SwitchLoopClustersAction.java --- 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); - } - } - }); - } - } - -} diff -r 9d640941c9c7 -r 7e8c901c0009 src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/graph/CfgEventListener.java --- 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); - -} diff -r 9d640941c9c7 -r 7e8c901c0009 src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/graph/CfgScene.java --- 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 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.emptySet(), false); this.selectedNodes = Collections.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; } }); diff -r 9d640941c9c7 -r 7e8c901c0009 src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/graph/EdgeSwitchWidget.java --- 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(); } diff -r 9d640941c9c7 -r 7e8c901c0009 src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/graph/NodeWidget.java --- 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("" + nodeModel.getDescription().replaceAll("\n", "
") + ""); - 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)); diff -r 9d640941c9c7 -r 7e8c901c0009 src/share/tools/IdealGraphVisualizer/ControlFlowEditor/src/at/ssw/visualizer/cfg/layer.xml --- 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 @@ - + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -