Package: VdmRtEditorActionBarContributor

VdmRtEditorActionBarContributor

nameinstructionbranchcomplexitylinemethod
VdmRtEditorActionBarContributor()
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
contributeToMenu(IMenuManager)
M: 35 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 9 C: 0
0%
M: 1 C: 0
0%
contributeToToolBar(IToolBarManager)
M: 31 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
createActions()
M: 124 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 22 C: 0
0%
M: 1 C: 0
0%
setActiveEditor(IEditorPart)
M: 38 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * RT Trace Viewer Plugin
4: * %%
5: * Copyright (C) 2008 - 2014 Overture
6: * %%
7: * This program is free software: you can redistribute it and/or modify
8: * it under the terms of the GNU General Public License as
9: * published by the Free Software Foundation, either version 3 of the
10: * License, or (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public
18: * License along with this program. If not, see
19: * <http://www.gnu.org/licenses/gpl-3.0.html>.
20: * #~%
21: */
22: package org.overture.ide.plugins.rttraceviewer.view;
23:
24: import java.io.File;
25:
26: import org.eclipse.jface.action.Action;
27: import org.eclipse.jface.action.IMenuManager;
28: import org.eclipse.jface.action.IToolBarManager;
29: import org.eclipse.jface.action.MenuManager;
30: import org.eclipse.jface.action.Separator;
31: import org.eclipse.ui.IEditorPart;
32: import org.eclipse.ui.ISharedImages;
33: import org.eclipse.ui.IWorkbenchActionConstants;
34: import org.eclipse.ui.PlatformUI;
35: import org.eclipse.ui.part.EditorActionBarContributor;
36: import org.overture.ide.plugins.rttraceviewer.TracefileViewerPlugin;
37:
38: public class VdmRtEditorActionBarContributor extends EditorActionBarContributor
39: {
40:         private VdmRtLogEditor editor;
41:         private Action exportDiagramAction;
42:         private Action moveHorizontalAction;
43:         private Action openValidationAction;
44:         private Action moveNextHorizontalAction;
45:         private Action movePreviousHorizontalAction;
46:         private Action refreshAction;
47:
48:         /**
49:          * Creates a multi-page contributor.
50:          */
51:         public VdmRtEditorActionBarContributor()
52:         {
53:                 super();
54:                 createActions();
55:                 
56:         }
57:
58:         private void createActions()
59:         {
60:
61:                 openValidationAction = new Action("Show failed conjectures")
62:                 {
63:                         @Override
64:                         public void run()
65:                         {
66:                                 if (editor != null)
67:                                 {
68:                                         editor.openValidationConjectures();
69:                                 }
70:                         }
71:                 };
72:                 openValidationAction.setToolTipText("Open the validation conjecture file");
73:                 openValidationAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJS_WARN_TSK));
74:                 openValidationAction.setEnabled(true);
75:
76:                 exportDiagramAction = new Action("Export to JPG")
77:                 {
78:                         @Override
79:                         public void run()
80:                         {
81:                                 if (editor != null)
82:                                 {
83:                                         editor.diagramExportAction();
84:                                 }
85:                         }
86:                 };
87:                 exportDiagramAction.setToolTipText("Save all diagrams as JPG");
88:                 exportDiagramAction.setImageDescriptor(TracefileViewerPlugin.getImageDescriptor((new StringBuilder("icons")).append(File.separator).append("print.gif").toString()));
89:                 exportDiagramAction.setEnabled(true);
90:
91:                 moveHorizontalAction = new Action("Move time")
92:                 {
93:                         @Override
94:                         public void run()
95:                         {
96:                                 if (editor != null)
97:                                 {
98:                                         editor.moveHorizontal();
99:                                 }
100:                         }
101:                 };
102:                 moveHorizontalAction.setToolTipText("Move time in the views");
103:                 moveHorizontalAction.setImageDescriptor(TracefileViewerPlugin.getImageDescriptor((new StringBuilder("icons")).append(File.separator).append("panhor.gif").toString()));
104:                 moveHorizontalAction.setEnabled(true);
105:
106:                 moveNextHorizontalAction = new Action("Move next")
107:                 {
108:                         @Override
109:                         public void run()
110:                         {
111:                                 if (editor != null)
112:                                 {
113:                                         editor.moveNextHorizontal();
114:                                 }
115:                         }
116:                 };
117:                 moveNextHorizontalAction.setToolTipText("Move time to next time");
118:                 moveNextHorizontalAction.setEnabled(true);
119:
120:                 movePreviousHorizontalAction = new Action("Move Previous")
121:                 {
122:                         @Override
123:                         public void run()
124:                         {
125:                                 if (editor != null)
126:                                 {
127:                                         editor.movePreviousHorizontal();
128:                                 }
129:                         }
130:                 };
131:                 movePreviousHorizontalAction.setToolTipText("Move time to Previous time");
132:                 movePreviousHorizontalAction.setEnabled(true);
133:                 
134:                 refreshAction = new Action("Refresh")
135:                 {
136:                         @Override
137:                         public void run()
138:                         {
139:                                 if (editor != null)
140:                                 {
141:                                         editor.refresh();
142:                                 }
143:                         }
144:                 };
145:                 refreshAction.setToolTipText("Refresh view");
146:                 refreshAction.setEnabled(true);
147:         }
148:
149:         public void contributeToMenu(IMenuManager manager)
150:         {
151:                 IMenuManager menu = new MenuManager("&RealTime-Log");
152:                 manager.prependToGroup(IWorkbenchActionConstants.MB_ADDITIONS, menu);
153:                 // menu.add(sampleAction);
154:
155:                 menu.add(moveHorizontalAction);
156:                 menu.add(moveNextHorizontalAction);
157:                 menu.add(movePreviousHorizontalAction);
158:
159:                 menu.add(new Separator());
160:                 menu.add(exportDiagramAction);
161:
162: //                menu.add(new Separator());
163:                 menu.add(openValidationAction);
164:                 
165: //                menu.add(new Separator());
166: //                menu.add(refreshAction);
167:
168:         }
169:
170:         public void contributeToToolBar(IToolBarManager manager)
171:         {
172:                 manager.add(new Separator());
173:
174:                 manager.add(moveHorizontalAction);
175:                 manager.add(movePreviousHorizontalAction);
176:                 manager.add(moveNextHorizontalAction);
177:
178: //                manager.add(new Separator());
179:                 manager.add(exportDiagramAction);
180:
181: //                manager.add(new Separator());
182:                 manager.add(openValidationAction);
183: //                manager.add(new Separator());
184:                 
185: //                manager.add(refreshAction);
186:                 manager.add(new Separator());
187:         }
188:
189:         @Override
190:         public void setActiveEditor(IEditorPart targetEditor)
191:         {
192:•                if (targetEditor instanceof VdmRtLogEditor)
193:                 {
194:                         this.editor = (VdmRtLogEditor) targetEditor;
195:                         
196:                         moveHorizontalAction.setEnabled(editor.canMoveHorizontal());
197:                         moveNextHorizontalAction.setEnabled(editor.canMoveHorizontal());
198:                         movePreviousHorizontalAction.setEnabled(editor.canMoveHorizontal());
199:                         
200:                         exportDiagramAction.setEnabled(editor.canExportJpg());
201:                         
202:                         openValidationAction.setEnabled(editor.canOpenValidation());
203:                         
204:                 }
205:         }
206:
207: }