Package: VdmLineBreakpointPropertyPage

VdmLineBreakpointPropertyPage

nameinstructionbranchcomplexitylinemethod
VdmLineBreakpointPropertyPage()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
convertHeightInCharsToPixels(int)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
convertWidthInCharsToPixels(int)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
createConditionEditor(Composite)
M: 70 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 15 C: 0
0%
M: 1 C: 0
0%
createControl(Composite)
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
createTypeSpecificEditors(Composite)
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
createTypeSpecificLabels(Composite)
M: 43 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 12 C: 0
0%
M: 1 C: 0
0%
dispose()
M: 9 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
doStore()
M: 33 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%
setConditionEnabled(boolean)
M: 17 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*
2: * #%~
3: * org.overture.ide.debug
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.debug.ui.propertypages;
23:
24: import org.eclipse.core.runtime.CoreException;
25: import org.eclipse.debug.internal.ui.SWTFactory;
26: import org.eclipse.swt.SWT;
27: import org.eclipse.swt.events.SelectionAdapter;
28: import org.eclipse.swt.events.SelectionEvent;
29: import org.eclipse.swt.layout.GridData;
30: import org.eclipse.swt.widgets.Button;
31: import org.eclipse.swt.widgets.Composite;
32: import org.eclipse.swt.widgets.Label;
33: import org.eclipse.swt.widgets.Text;
34: import org.eclipse.ui.IWorkbenchPropertyPage;
35: import org.eclipse.ui.PlatformUI;
36: import org.overture.ide.debug.core.model.IVdmLineBreakpoint;
37:
38: @SuppressWarnings("restriction")
39: public class VdmLineBreakpointPropertyPage extends VdmBreakpointPropertyPage
40:                 implements IWorkbenchPropertyPage
41: {
42:
43:         private Button fEnableConditionButton;
44:         private BreakpointConditionEditor fConditionEditor;
45:         private Button fConditionIsTrue;
46:         private Button fConditionHasChanged;
47:         private Label fSuspendWhenLabel;
48:
49:         // Watchpoint editors
50:         // private Button fFieldAccess;
51:         // private Button fFieldModification;
52:         // // Method breakpoint editors
53:         // private Button fMethodEntry;
54:         // private Button fMethodExit;
55:         //
56:         // private static final String fgWatchpointError =
57:         // "fgWatchpointError";//PropertyPageMessages.JavaLineBreakpointPage_0;
58:         // private static final String fgMethodBreakpointError =
59:         // "fgMethodBreakpointError";//PropertyPageMessages.JavaLineBreakpointPage_1;
60:
61:         /*
62:          * (non-Javadoc)
63:          * @see org.eclipse.jdt.internal.debug.ui.propertypages.JavaBreakpointPage#doStore()
64:          */
65:         protected void doStore() throws CoreException
66:         {
67:                 IVdmLineBreakpoint breakpoint = (IVdmLineBreakpoint) getBreakpoint();
68:                 super.doStore();
69:•                if (fConditionEditor != null)
70:                 {
71:                         boolean enableCondition = fEnableConditionButton.getSelection();
72:                         String condition = fConditionEditor.getCondition();
73:                         // boolean suspendOnTrue= fConditionIsTrue.getSelection();
74:•                        if (breakpoint.getExpressionState() != enableCondition)
75:                         {
76:                                 breakpoint.setExpressionState(enableCondition);
77:                         }
78:•                        if (!condition.equals(breakpoint.getExpression()))
79:                         {
80:                                 breakpoint.setExpression(condition);
81:                         }
82:                         // if (breakpoint.isConditionSuspendOnTrue() != suspendOnTrue) {
83:                         // breakpoint.setConditionSuspendOnTrue(suspendOnTrue);
84:                         // }
85:                 }
86:                 // if (breakpoint instanceof IJavaWatchpoint) {
87:                 // IJavaWatchpoint watchpoint= (IJavaWatchpoint) getBreakpoint();
88:                 // boolean access = fFieldAccess.getSelection();
89:                 // boolean modification = fFieldModification.getSelection();
90:                 // if (access != watchpoint.isAccess()) {
91:                 // watchpoint.setAccess(access);
92:                 // }
93:                 // if (modification != watchpoint.isModification()) {
94:                 // watchpoint.setModification(modification);
95:                 // }
96:                 // }
97:                 // if (breakpoint instanceof IJavaMethodBreakpoint) {
98:                 // IJavaMethodBreakpoint methodBreakpoint= (IJavaMethodBreakpoint) getBreakpoint();
99:                 // boolean entry = fMethodEntry.getSelection();
100:                 // boolean exit = fMethodExit.getSelection();
101:                 // if (entry != methodBreakpoint.isEntry()) {
102:                 // methodBreakpoint.setEntry(entry);
103:                 // }
104:                 // if (exit != methodBreakpoint.isExit()) {
105:                 // methodBreakpoint.setExit(exit);
106:                 // }
107:                 // }
108:         }
109:
110:         /*
111:          * (non-Javadoc)
112:          * @see
113:          * org.eclipse.jdt.internal.debug.ui.propertypages.JavaBreakpointPage#createTypeSpecificLabels(org.eclipse.swt.widgets
114:          * .Composite)
115:          */
116:         protected void createTypeSpecificLabels(Composite parent)
117:         {
118:                 // Line number
119:                 IVdmLineBreakpoint breakpoint = (IVdmLineBreakpoint) getBreakpoint();
120:                 StringBuffer lineNumber = new StringBuffer(4);
121:                 try
122:                 {
123:                         int lNumber = breakpoint.getLineNumber();
124:•                        if (lNumber > 0)
125:                         {
126:                                 lineNumber.append(lNumber);
127:                         }
128:                 } catch (CoreException ce)
129:                 {
130:                         // JDIDebugUIPlugin.log(ce);
131:                 }
132:•                if (lineNumber.length() > 0)
133:                 {
134:                         createLabel(parent, "Line:");
135:                         Text text = SWTFactory.createText(parent, SWT.READ_ONLY, 1, 1);
136:                         text.setText(lineNumber.toString());
137:                         text.setBackground(parent.getBackground());
138:                 }
139:                 // IMember member = BreakpointUtils.getMember(breakpoint);
140:                 // if (member == null) {
141:                 // return;
142:                 // }
143:
144:                 // TODO: I removed this label until we find a solution to fidn the member
145:
146:                 // String label = "Member:"; //PropertyPageMessages.JavaLineBreakpointPage_3;
147:                 // if (breakpoint instanceof IJavaMethodBreakpoint) {
148:                 // label = PropertyPageMessages.JavaLineBreakpointPage_4;
149:                 // } else if (breakpoint instanceof IJavaWatchpoint) {
150:                 // label = PropertyPageMessages.JavaLineBreakpointPage_5;
151:                 // }
152:                 // createLabel(parent, label);
153:
154:                 // TODO: the member should be reated here
155:
156:                 // Text text = SWTFactory.createText(parent, SWT.READ_ONLY, 1, 1);
157:                 // text.setText("fJavaLabelProvider.getText(member)");
158:                 // text.setBackground(parent.getBackground());
159:         }
160:
161:         /**
162:          * Create the condition editor and associated editors.
163:          *
164:          * @see org.eclipse.jdt.internal.debug.ui.propertypages.JavaBreakpointPage#createTypeSpecificEditors(org.eclipse.swt.widgets.Composite)
165:          */
166:         protected void createTypeSpecificEditors(Composite parent)
167:                         throws CoreException
168:         {
169:                 setTitle("Line Breakpoint");
170:                 IVdmLineBreakpoint breakpoint = (IVdmLineBreakpoint) getBreakpoint();
171:                 // if (breakpoint..supportsCondition()) {
172:                 createConditionEditor(parent);
173:                 // }
174:                 // if (breakpoint instanceof IJavaWatchpoint) {
175:                 // setTitle(PropertyPageMessages.JavaLineBreakpointPage_19);
176:                 // IJavaWatchpoint watchpoint= (IJavaWatchpoint) getBreakpoint();
177:                 // SelectionAdapter watchpointValidator= new SelectionAdapter() {
178:                 // public void widgetSelected(SelectionEvent e) {
179:                 // validateWatchpoint();
180:                 // }
181:                 // };
182:                 // createLabel(parent, PropertyPageMessages.JavaLineBreakpointPage_6);
183:                 // fEnabledButton.addSelectionListener(watchpointValidator);
184:                 // fFieldAccess = createCheckButton(parent, PropertyPageMessages.JavaLineBreakpointPage_7);
185:                 // fFieldAccess.setSelection(watchpoint.isAccess());
186:                 // fFieldAccess.addSelectionListener(watchpointValidator);
187:                 // fFieldModification = createCheckButton(parent, PropertyPageMessages.JavaLineBreakpointPage_8);
188:                 // fFieldModification.setSelection(watchpoint.isModification());
189:                 // fFieldModification.addSelectionListener(watchpointValidator);
190:                 // }
191:                 // if (breakpoint instanceof IJavaMethodBreakpoint) {
192:                 // setTitle(PropertyPageMessages.JavaLineBreakpointPage_20);
193:                 // IJavaMethodBreakpoint methodBreakpoint = (IJavaMethodBreakpoint) getBreakpoint();
194:                 // SelectionAdapter methodBreakpointValidator= new SelectionAdapter() {
195:                 // public void widgetSelected(SelectionEvent e) {
196:                 // validateMethodBreakpoint();
197:                 // }
198:                 // };
199:                 // createLabel(parent, PropertyPageMessages.JavaLineBreakpointPage_9);
200:                 // fEnabledButton.addSelectionListener(methodBreakpointValidator);
201:                 // fMethodEntry = createCheckButton(parent, PropertyPageMessages.JavaLineBreakpointPage_10);
202:                 // fMethodEntry.setSelection(methodBreakpoint.isEntry());
203:                 // fMethodEntry.addSelectionListener(methodBreakpointValidator);
204:                 // fMethodExit = createCheckButton(parent, PropertyPageMessages.JavaLineBreakpointPage_11);
205:                 // fMethodExit.setSelection(methodBreakpoint.isExit());
206:                 // fMethodExit.addSelectionListener(methodBreakpointValidator);
207:                 // }
208:         }
209:
210:         /**
211:          * Creates the controls that allow the user to specify the breakpoint's condition
212:          *
213:          * @param parent
214:          * the composite in which the condition editor should be created
215:          * @throws CoreException
216:          * if an exception occurs accessing the breakpoint
217:          */
218:         private void createConditionEditor(Composite parent) throws CoreException
219:         {
220:                 IVdmLineBreakpoint breakpoint = (IVdmLineBreakpoint) getBreakpoint();
221:                 String label = null;
222:                 // if (BreakpointUtils.getType(breakpoint) != null) {
223:                 // IBindingService bindingService =
224:                 // (IBindingService)PlatformUI.getWorkbench().getAdapter(IBindingService.class);
225:                 // if(bindingService != null) {
226:                 // TriggerSequence keyBinding =
227:                 // bindingService.getBestActiveBindingFor(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
228:                 // if (keyBinding != null) {
229:                 // label = MessageFormat.format("messageFormat", new String[] {keyBinding.format()});
230:                 // }
231:                 // }
232:                 // }
233:•                if (label == null)
234:                 {
235:                         label = "Enable Condition";
236:                 }
237:
238:                 Composite conditionComposite = SWTFactory.createGroup(parent, EMPTY_STRING, 1, 1, GridData.FILL_BOTH);
239:                 fEnableConditionButton = createCheckButton(conditionComposite, label);
240:                 fEnableConditionButton.setSelection(breakpoint.getExpressionState());
241:                 fEnableConditionButton.addSelectionListener(new SelectionAdapter()
242:                 {
243:                         public void widgetSelected(SelectionEvent e)
244:                         {
245:                                 setConditionEnabled(fEnableConditionButton.getSelection());
246:                         }
247:                 });
248:                 fConditionEditor = new BreakpointConditionEditor(conditionComposite, this);
249:                 fSuspendWhenLabel = createLabel(conditionComposite, "Suspend when:");
250:                 fConditionIsTrue = createRadioButton(conditionComposite, "condition is 'true'");
251:                 fConditionHasChanged = createRadioButton(conditionComposite, "value of condition changes");
252:                 // if (breakpoint.isConditionSuspendOnTrue()) {
253:                 // fConditionIsTrue.setSelection(true);
254:                 // }
255:                 // else {
256:                 fConditionHasChanged.setSelection(true);
257:                 // }
258:                 setConditionEnabled(fEnableConditionButton.getSelection());
259:         }
260:
261:         /**
262:          * Sets the enabled state of the condition editing controls.
263:          *
264:          * @param enabled
265:          */
266:         private void setConditionEnabled(boolean enabled)
267:         {
268:                 fConditionEditor.setEnabled(enabled);
269:                 fSuspendWhenLabel.setEnabled(enabled);
270:                 fConditionIsTrue.setEnabled(enabled);
271:                 fConditionHasChanged.setEnabled(enabled);
272:         }
273:
274:         /*
275:          * (non-Javadoc)
276:          * @see org.eclipse.jface.dialogs.DialogPage#convertHeightInCharsToPixels(int)
277:          */
278:         public int convertHeightInCharsToPixels(int chars)
279:         {
280:                 return super.convertHeightInCharsToPixels(chars);
281:         }
282:
283:         /*
284:          * (non-Javadoc)
285:          * @see org.eclipse.jface.dialogs.DialogPage#convertWidthInCharsToPixels(int)
286:          */
287:         public int convertWidthInCharsToPixels(int chars)
288:         {
289:                 return super.convertWidthInCharsToPixels(chars);
290:         }
291:
292:         /*
293:          * (non-Javadoc)
294:          * @see org.eclipse.jface.dialogs.IDialogPage#dispose()
295:          */
296:         public void dispose()
297:         {
298:•                if (fConditionEditor != null)
299:                 {
300:                         fConditionEditor.dispose();
301:                 }
302:                 super.dispose();
303:         }
304:
305:         /*
306:          * (non-Javadoc)
307:          * @see org.eclipse.jface.preference.PreferencePage#createControl(org.eclipse.swt.widgets.Composite)
308:          */
309:         public void createControl(Composite parent)
310:         {
311:                 super.createControl(parent);
312:                 PlatformUI.getWorkbench().getHelpSystem().setHelp(getControl(), "context"); // TODO: HELP CONTEXT
313:         }
314:
315: }