KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > soot > cfg > actions > CFGActionBarContributor


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2004 Jennifer Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20
21 package ca.mcgill.sable.soot.cfg.actions;
22
23 import org.eclipse.gef.ui.actions.ActionBarContributor;
24 import org.eclipse.jface.action.*;
25 import org.eclipse.gef.ui.actions.*;
26 import org.eclipse.ui.IWorkbenchActionConstants;
27 import ca.mcgill.sable.soot.interaction.*;
28 import org.eclipse.ui.*;
29
30
31 public class CFGActionBarContributor extends ActionBarContributor {
32
33     
34     public CFGActionBarContributor() {
35         super();
36     }
37     
38     private StepForwardAction stepForward;
39     private StepBackwardAction stepBackward;
40     private FinishMethodAction finishMethod;
41     private NextMethodAction nextMethod;
42     private FlowSelectAction flowSelect;
43     private StopInteractionAction stopInteraction;
44
45
46     /* (non-Javadoc)
47      * @see org.eclipse.gef.ui.actions.ActionBarContributor#buildActions()
48      */

49     protected void buildActions() {
50         addRetargetAction(new ZoomInRetargetAction());
51         addRetargetAction(new ZoomOutRetargetAction());
52         
53         flowSelect = new FlowSelectAction(null);
54         addAction(flowSelect);
55         
56         stepBackward = new StepBackwardAction(null);
57         addAction(stepBackward);
58         stepForward = new StepForwardAction(null);
59         addAction(stepForward);
60         
61         finishMethod = new FinishMethodAction(null);
62         addAction(finishMethod);
63         nextMethod = new NextMethodAction(null);
64         addAction(nextMethod);
65         
66         stopInteraction = new StopInteractionAction(null);
67         addAction(stopInteraction);
68         
69         
70     }
71
72     /* (non-Javadoc)
73      * @see org.eclipse.gef.ui.actions.ActionBarContributor#declareGlobalActionKeys()
74      */

75     protected void declareGlobalActionKeys() {
76     }
77     
78     // this is for zoom toolbar buttons
79
public void contributeToToolBar(IToolBarManager toolBarManager){
80         super.contributeToToolBar(toolBarManager);
81         
82         toolBarManager.add(new Separator());
83         toolBarManager.add(getAction(StepBackwardAction.STEP_BACKWARD));
84         
85         toolBarManager.add(getAction(StepForwardAction.STEP_FORWARD));
86         toolBarManager.add(getAction(FinishMethodAction.FINISH_METHOD));
87         toolBarManager.add(getAction(NextMethodAction.NEXT_METHOD));
88
89         toolBarManager.add(getAction(StopInteractionAction.STOP_INTERACTION));
90     }
91     
92     public void contributeToMenu(IMenuManager menuManager){
93         super.contributeToMenu(menuManager);
94         
95         MenuManager viewMenu = new MenuManager("View");
96         viewMenu.add(getAction(GEFActionConstants.ZOOM_IN));
97         viewMenu.add(getAction(GEFActionConstants.ZOOM_OUT));
98         
99         menuManager.insertAfter(IWorkbenchActionConstants.M_EDIT, viewMenu);
100     }
101     
102     public void setActiveEditor(IEditorPart editor) {
103         super.setActiveEditor(editor);
104         stepForward.setEditorPart( editor );
105         stepBackward.setEditorPart(editor);
106         finishMethod.setEditorPart(editor);
107         nextMethod.setEditorPart(editor);
108         flowSelect.setEditorPart(editor);
109         stopInteraction.setEditorPart(editor);
110     }
111
112 }
113
Popular Tags