Commit | Line | Data |
---|---|---|
ccc66d01 BH |
1 | /********************************************************************** |
2 | * Copyright (c) 2012 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Bernd Hufmann - Initial API and implementation | |
11 | **********************************************************************/ | |
115b4a01 | 12 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs; |
ccc66d01 BH |
13 | |
14 | import java.util.ArrayList; | |
15 | import java.util.List; | |
16 | ||
17 | import org.eclipse.jface.dialogs.MessageDialog; | |
18 | import org.eclipse.jface.viewers.CheckStateChangedEvent; | |
19 | import org.eclipse.jface.viewers.CheckboxTreeViewer; | |
20 | import org.eclipse.jface.viewers.ICheckStateListener; | |
115b4a01 BH |
21 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.Messages; |
22 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.TraceControlContentProvider; | |
23 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.TraceControlLabelProvider; | |
24 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent; | |
25 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.BaseEventComponent; | |
26 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.KernelProviderComponent; | |
27 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProviderGroup; | |
ccc66d01 BH |
28 | import org.eclipse.swt.SWT; |
29 | import org.eclipse.swt.events.SelectionAdapter; | |
30 | import org.eclipse.swt.events.SelectionEvent; | |
31 | import org.eclipse.swt.graphics.Image; | |
32 | import org.eclipse.swt.layout.GridData; | |
33 | import org.eclipse.swt.layout.GridLayout; | |
34 | import org.eclipse.swt.widgets.Button; | |
35 | import org.eclipse.swt.widgets.Composite; | |
36 | import org.eclipse.swt.widgets.Group; | |
37 | import org.eclipse.swt.widgets.Label; | |
38 | import org.eclipse.swt.widgets.Text; | |
39 | ||
40 | /** | |
41 | * <b><u>EnableKernelEventsComposite</u></b> | |
42 | * <p> | |
43 | * A composite for collecting information about kernel events to be enabled. | |
44 | * </p> | |
45 | */ | |
46 | public class EnableKernelEventComposite extends Composite implements IEnableKernelEvents { | |
47 | ||
48 | // ------------------------------------------------------------------------ | |
49 | // Constants | |
50 | // ------------------------------------------------------------------------ | |
51 | private enum KernelGroupEnum { TRACEPOINTS, SYSCALLS, PROBE, FUNCTION }; | |
52 | ||
53 | // ------------------------------------------------------------------------ | |
54 | // Attributes | |
55 | // ------------------------------------------------------------------------ | |
56 | ||
57 | /** | |
58 | * A button to enable/disable the tracepoints group | |
59 | */ | |
60 | private Button fTracepointsActivateButton; | |
61 | /** | |
62 | * A tree viewer for displaying and selection of available tracepoints. | |
63 | */ | |
64 | private CheckboxTreeViewer fTracepointsViewer; | |
65 | /** | |
66 | * A button to enable/disable the syscalls group | |
67 | */ | |
68 | private Button fSysCallsActivateButton; | |
69 | /** | |
70 | * A button to enable or disable the dynamic probe group. | |
71 | */ | |
72 | private Button fProbeActivateButton; | |
73 | /** | |
74 | * The text field for the event name for the dynamic probe. | |
75 | */ | |
76 | private Text fProbeEventNameText; | |
77 | /** | |
78 | * The text field for the dynamic probe. | |
79 | */ | |
80 | private Text fProbeText; | |
81 | /** | |
82 | * A button to enable or disable the dynamic function probe group. | |
83 | */ | |
84 | private Button fFunctionActivateButton; | |
85 | /** | |
86 | * The text field for the event name for the dynamic probe. | |
87 | */ | |
88 | private Text fFunctionEventNameText; | |
89 | /** | |
90 | * The text field for the dynamic function entry/return probe. | |
91 | */ | |
92 | private Text fFunctionText; | |
93 | /** | |
94 | * The referenced trace provider group containing the kernel provider | |
95 | * component which contains a list of available tracepoints. | |
96 | */ | |
97 | private TraceProviderGroup fProviderGroup; | |
98 | /** | |
99 | * The flag indicating that tracepoints are selected. | |
100 | */ | |
101 | private boolean fIsTracepoints; | |
102 | /** | |
103 | * The flag indicating that all tracepoints are selected. | |
104 | */ | |
105 | private boolean fIsAllTracepoints; | |
106 | /** | |
107 | * The flag indicating that syscalls are selected. | |
108 | */ | |
109 | private boolean fIsSysCalls; | |
110 | /** | |
111 | * The list of tracepoints to be enabled. | |
112 | */ | |
113 | private List<String> fSelectedEvents; | |
114 | /** | |
115 | * The flag indicating that dynamic probe is selected. | |
116 | */ | |
117 | private boolean fIsDynamicProbe; | |
118 | /** | |
119 | * The event name of the dynamic probe. | |
120 | */ | |
121 | private String fProbeEventName; | |
122 | /** | |
123 | * The dynamic probe. | |
124 | */ | |
125 | private String fProbeString; | |
126 | /** | |
127 | * The flag indicating that the dynamic function probe is selected. | |
128 | */ | |
129 | private boolean fIsDynamicFunctionProbe; | |
130 | /** | |
131 | * The event name of the dynamic function entry/return probe. | |
132 | */ | |
133 | private String fFunctionEventName; | |
134 | /** | |
135 | * The dynamic function entry/return probe. | |
136 | */ | |
137 | private String fFunctionString; | |
138 | ||
139 | // ------------------------------------------------------------------------ | |
140 | // Constructors | |
141 | // ------------------------------------------------------------------------ | |
142 | ||
143 | public EnableKernelEventComposite(Composite parent, int style, TraceProviderGroup providerGroup) { | |
144 | super(parent, style); | |
145 | fProviderGroup = providerGroup; | |
146 | } | |
147 | ||
148 | // ------------------------------------------------------------------------ | |
149 | // Acessors | |
150 | // ------------------------------------------------------------------------ | |
151 | /* | |
152 | * (non-Javadoc) | |
115b4a01 | 153 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isTracpoints() |
ccc66d01 BH |
154 | */ |
155 | @Override | |
156 | public boolean isTracepoints() { | |
157 | return fIsTracepoints; | |
158 | } | |
159 | ||
160 | /* (non-Javadoc) | |
115b4a01 | 161 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isAllTracePoints() |
ccc66d01 BH |
162 | */ |
163 | @Override | |
164 | public boolean isAllTracePoints() { | |
165 | return fIsAllTracepoints; | |
166 | } | |
167 | ||
168 | /* | |
169 | * (non-Javadoc) | |
115b4a01 | 170 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isSysCalls() |
ccc66d01 BH |
171 | */ |
172 | @Override | |
173 | public boolean isSysCalls() { | |
174 | return fIsSysCalls; | |
175 | } | |
176 | ||
177 | /* (non-Javadoc) | |
115b4a01 | 178 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isAllSysCalls() |
ccc66d01 BH |
179 | */ |
180 | @Override | |
181 | public boolean isAllSysCalls() { | |
182 | return fIsSysCalls; | |
183 | } | |
184 | ||
185 | /* (non-Javadoc) | |
115b4a01 | 186 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getEventNames() |
ccc66d01 BH |
187 | */ |
188 | @Override | |
189 | public List<String> getEventNames() { | |
190 | return new ArrayList<String>(fSelectedEvents); | |
191 | } | |
192 | /* | |
193 | * (non-Javadoc) | |
115b4a01 | 194 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isDynamicProbe() |
ccc66d01 BH |
195 | */ |
196 | @Override | |
197 | public boolean isDynamicProbe() { | |
198 | return fIsDynamicProbe; | |
199 | } | |
200 | ||
201 | /* (non-Javadoc) | |
115b4a01 | 202 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getProbeName() |
ccc66d01 BH |
203 | */ |
204 | @Override | |
205 | public String getProbeName() { | |
206 | return fProbeString; | |
207 | } | |
208 | ||
209 | /* (non-Javadoc) | |
115b4a01 | 210 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getProbeEventName() |
ccc66d01 BH |
211 | */ |
212 | @Override | |
213 | public String getProbeEventName() { | |
214 | return fProbeEventName; | |
215 | } | |
216 | ||
217 | /* | |
218 | * (non-Javadoc) | |
115b4a01 | 219 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isDynamicFunctionProbe() |
ccc66d01 BH |
220 | */ |
221 | @Override | |
222 | public boolean isDynamicFunctionProbe() { | |
223 | return fIsDynamicFunctionProbe; | |
224 | } | |
225 | ||
226 | /* (non-Javadoc) | |
115b4a01 | 227 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getFunctionEventName() |
ccc66d01 BH |
228 | */ |
229 | @Override | |
230 | public String getFunctionEventName() { | |
231 | return fFunctionEventName; | |
232 | } | |
233 | ||
234 | /* (non-Javadoc) | |
115b4a01 | 235 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getFunction() |
ccc66d01 BH |
236 | */ |
237 | @Override | |
238 | public String getFunction() { | |
239 | return fFunctionString; | |
240 | } | |
241 | ||
242 | // ------------------------------------------------------------------------ | |
243 | // Operations | |
244 | // ------------------------------------------------------------------------ | |
245 | /** | |
246 | * Creates the composite content | |
247 | */ | |
248 | public void createContent() { | |
249 | ||
250 | // Tracepoints Group | |
251 | createTracepointsGroup(); | |
252 | ||
253 | // Syscalls Group | |
254 | createSysCallsGroup(); | |
255 | ||
256 | // Dynamic Probe Group | |
257 | createDynamicProbeGroup(); | |
258 | ||
259 | // Dynamic Function Probe Group | |
260 | createDynamicFunctionPropeGroup(); | |
261 | ||
262 | // Set default enablements | |
263 | setKernelEnablements(KernelGroupEnum.TRACEPOINTS); | |
264 | } | |
265 | ||
266 | /** | |
267 | * Validates the kernel composite input data. | |
268 | * @return true if configured data is valid and can be retrieved. | |
269 | */ | |
270 | public boolean isValid() { | |
271 | fIsTracepoints = fTracepointsActivateButton.getSelection(); | |
272 | fIsSysCalls = fSysCallsActivateButton.getSelection(); | |
273 | fIsDynamicProbe = fProbeActivateButton.getSelection(); | |
274 | fIsDynamicFunctionProbe = fFunctionActivateButton.getSelection(); | |
275 | ||
5f1f22f8 BH |
276 | // initialize tracepoint fields |
277 | fIsAllTracepoints = false; | |
ccc66d01 | 278 | fSelectedEvents = new ArrayList<String>(); |
5f1f22f8 BH |
279 | |
280 | if (fIsTracepoints) { | |
281 | List<ITraceControlComponent> comps = fProviderGroup.getChildren(KernelProviderComponent.class); | |
282 | fIsAllTracepoints = fTracepointsViewer.getChecked(comps.get(0)); | |
283 | ||
284 | Object[] checkedElements = fTracepointsViewer.getCheckedElements(); | |
285 | for (int i = 0; i < checkedElements.length; i++) { | |
286 | ITraceControlComponent component = (ITraceControlComponent)checkedElements[i]; | |
287 | if (component instanceof BaseEventComponent) { | |
288 | fSelectedEvents.add(component.getName()); | |
289 | } | |
ccc66d01 BH |
290 | } |
291 | } | |
5f1f22f8 BH |
292 | |
293 | if (fIsDynamicProbe) { | |
294 | String temp = fProbeEventNameText.getText(); | |
295 | if (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$ | |
296 | MessageDialog.openError(getShell(), | |
297 | Messages.TraceControl_EnableEventsDialogTitle, | |
298 | Messages.TraceControl_InvalidProbeNameError + " (" + temp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ | |
299 | ||
300 | return false; | |
301 | } | |
302 | ||
303 | if(!fProbeText.getText().matches("\\s*")) { //$NON-NLS-1$ | |
304 | fProbeEventName = temp; | |
305 | // fProbeString will be validated by lttng-tools | |
306 | fProbeString = fProbeText.getText(); | |
307 | } | |
ccc66d01 | 308 | } |
ccc66d01 BH |
309 | |
310 | // initialize function string | |
311 | fFunctionEventName = null; | |
312 | fFunctionString = null; | |
5f1f22f8 BH |
313 | if (fIsDynamicFunctionProbe) { |
314 | String functionTemp = fFunctionEventNameText.getText(); | |
315 | if (!functionTemp.matches("^[\\s]{0,}$") && !functionTemp.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$ | |
316 | MessageDialog.openError(getShell(), | |
317 | Messages.TraceControl_EnableEventsDialogTitle, | |
318 | Messages.TraceControl_InvalidProbeNameError + " (" + functionTemp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ | |
ccc66d01 | 319 | |
5f1f22f8 BH |
320 | return false; |
321 | } | |
ccc66d01 | 322 | |
5f1f22f8 BH |
323 | if(!fFunctionText.getText().matches("\\s*")) { //$NON-NLS-1$ |
324 | fFunctionEventName = functionTemp; | |
325 | // fFunctionString will be validated by lttng-tools | |
326 | fFunctionString = fFunctionText.getText(); | |
327 | } | |
ccc66d01 BH |
328 | } |
329 | ||
330 | return true; | |
331 | } | |
332 | ||
333 | /** | |
334 | * Creates tracepoints group. | |
335 | */ | |
336 | private void createTracepointsGroup() { | |
337 | ||
338 | GridLayout layout; | |
339 | GridData data; | |
340 | Group tpMainGroup = new Group(this, SWT.SHADOW_NONE); | |
341 | tpMainGroup.setText(Messages.TraceControl_EnableEventsTracepointGroupName); | |
342 | layout = new GridLayout(2, false); | |
343 | tpMainGroup.setLayout(layout); | |
344 | data = new GridData(GridData.FILL_BOTH); | |
345 | tpMainGroup.setLayoutData(data); | |
346 | ||
347 | Composite buttonComposite = new Composite(tpMainGroup, SWT.NONE); | |
348 | layout = new GridLayout(1, true); | |
349 | buttonComposite.setLayout(layout); | |
350 | data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true); | |
351 | buttonComposite.setLayoutData(data); | |
352 | ||
353 | fTracepointsActivateButton = new Button(buttonComposite, SWT.RADIO); | |
354 | fTracepointsActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName); | |
355 | data = new GridData(GridData.FILL_HORIZONTAL); | |
356 | fTracepointsActivateButton.setLayoutData(data); | |
357 | fTracepointsActivateButton.addSelectionListener(new SelectionAdapter() { | |
358 | @Override | |
359 | public void widgetSelected(SelectionEvent e) { | |
360 | setKernelEnablements(KernelGroupEnum.TRACEPOINTS); | |
361 | } | |
362 | }); | |
363 | ||
364 | Group tracepointsGroup = new Group(tpMainGroup, SWT.SHADOW_NONE); | |
365 | layout = new GridLayout(1, true); | |
366 | tracepointsGroup.setLayout(layout); | |
367 | data = new GridData(GridData.FILL_BOTH); | |
368 | tracepointsGroup.setLayoutData(data); | |
369 | ||
370 | fTracepointsViewer = new CheckboxTreeViewer(tracepointsGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); | |
371 | fTracepointsViewer.getTree().setToolTipText(Messages.TraceControl_EnableEventsTracepointTreeTooltip); | |
372 | ||
373 | fTracepointsViewer.setContentProvider(new KernelContentProvider()); | |
374 | fTracepointsViewer.setLabelProvider(new KernelLabelProvider()); | |
375 | fTracepointsViewer.addCheckStateListener(new KernelCheckListener()); | |
376 | fTracepointsViewer.setInput(fProviderGroup); | |
377 | ||
378 | fTracepointsViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH)); | |
379 | } | |
380 | ||
381 | /** | |
382 | * Creates syscalls group. | |
383 | */ | |
384 | private void createSysCallsGroup() { | |
385 | GridLayout layout; | |
386 | GridData data; | |
387 | Group sysCallsMainGroup = new Group(this, SWT.SHADOW_NONE); | |
388 | sysCallsMainGroup.setText(Messages.TraceControl_EnableEventsSyscallName); | |
389 | sysCallsMainGroup.setToolTipText(Messages.TraceControl_EnableEventsSyscallTooltip); | |
390 | layout = new GridLayout(2, false); | |
391 | sysCallsMainGroup.setLayout(layout); | |
392 | data = new GridData(GridData.FILL_HORIZONTAL); | |
393 | sysCallsMainGroup.setLayoutData(data); | |
394 | ||
395 | Composite buttonComposite = new Composite(sysCallsMainGroup, SWT.NONE); | |
396 | layout = new GridLayout(1, false); | |
397 | buttonComposite.setLayout(layout); | |
398 | data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true); | |
399 | buttonComposite.setLayoutData(data); | |
400 | ||
401 | fSysCallsActivateButton = new Button(buttonComposite, SWT.RADIO); | |
402 | fSysCallsActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName); | |
403 | fSysCallsActivateButton.setToolTipText(Messages.TraceControl_EnableEventsSyscallTooltip); | |
404 | fSysCallsActivateButton.setSelection(false); | |
405 | data = new GridData(GridData.FILL_HORIZONTAL); | |
406 | fSysCallsActivateButton.setLayoutData(data); | |
407 | fSysCallsActivateButton.addSelectionListener(new SelectionAdapter() { | |
408 | @Override | |
409 | public void widgetSelected(SelectionEvent e) { | |
410 | setKernelEnablements(KernelGroupEnum.SYSCALLS); | |
411 | } | |
412 | }); | |
413 | } | |
414 | ||
415 | /** | |
416 | * Creates dynamic probe group. | |
417 | */ | |
418 | private void createDynamicProbeGroup() { | |
419 | GridLayout layout; | |
420 | GridData data; | |
421 | Group probeMainGroup = new Group(this, SWT.SHADOW_NONE); | |
422 | probeMainGroup.setText(Messages.TraceControl_EnableEventsProbeGroupName); | |
423 | layout = new GridLayout(2, false); | |
424 | probeMainGroup.setLayout(layout); | |
425 | data = new GridData(GridData.FILL_HORIZONTAL); | |
426 | probeMainGroup.setLayoutData(data); | |
427 | ||
428 | Composite buttonComposite = new Composite(probeMainGroup, SWT.NONE); | |
429 | layout = new GridLayout(1, false); | |
430 | buttonComposite.setLayout(layout); | |
431 | data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true); | |
432 | buttonComposite.setLayoutData(data); | |
433 | ||
434 | fProbeActivateButton = new Button(buttonComposite, SWT.RADIO); | |
435 | fProbeActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName); | |
436 | fProbeActivateButton.setSelection(false); | |
437 | data = new GridData(GridData.FILL_HORIZONTAL); | |
438 | fProbeActivateButton.setLayoutData(data); | |
439 | fProbeActivateButton.addSelectionListener(new SelectionAdapter() { | |
440 | @Override | |
441 | public void widgetSelected(SelectionEvent e) { | |
442 | setKernelEnablements(KernelGroupEnum.PROBE); | |
443 | } | |
444 | }); | |
445 | ||
446 | Group probeGroup = new Group(probeMainGroup, SWT.SHADOW_NONE); | |
447 | layout = new GridLayout(4, true); | |
448 | probeGroup.setLayout(layout); | |
449 | probeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); | |
450 | ||
451 | Label probeNameLabel = new Label(probeGroup, SWT.LEFT); | |
452 | probeNameLabel.setText(Messages.TraceControl_EnableEventsEventNameLabel); | |
453 | data = new GridData(GridData.FILL_BOTH); | |
454 | data.horizontalSpan = 1; | |
455 | probeNameLabel.setLayoutData(data); | |
456 | ||
457 | fProbeEventNameText = new Text(probeGroup, SWT.LEFT); | |
458 | fProbeEventNameText.setToolTipText(Messages.TraceControl_EnableEventsProbeEventNameTooltip); | |
459 | ||
460 | data = new GridData(GridData.FILL_BOTH); | |
461 | data.horizontalSpan = 3; | |
462 | fProbeEventNameText.setLayoutData(data); | |
463 | ||
464 | Label probeLabel = new Label(probeGroup, SWT.LEFT); | |
465 | probeLabel.setText(Messages.TraceControl_EnableEventsProbeNameLabel); | |
466 | data = new GridData(GridData.FILL_BOTH); | |
467 | data.horizontalSpan = 1; | |
468 | probeLabel.setLayoutData(data); | |
469 | ||
470 | fProbeText = new Text(probeGroup, SWT.LEFT); | |
471 | fProbeText.setToolTipText(Messages.TraceControl_EnableEventsProbeNameTooltip); | |
472 | data = new GridData(GridData.FILL_BOTH); | |
473 | data.horizontalSpan = 3; | |
474 | fProbeText.setLayoutData(data); | |
475 | } | |
476 | ||
477 | /** | |
478 | * Creates dynamic function entry/return probe group. | |
479 | */ | |
480 | private void createDynamicFunctionPropeGroup() { | |
481 | GridLayout layout; | |
482 | GridData data; | |
483 | Group functionMainGroup = new Group(this, SWT.SHADOW_NONE); | |
484 | functionMainGroup.setText(Messages.TraceControl_EnableEventsFucntionGroupName); | |
485 | layout = new GridLayout(2, false); | |
486 | functionMainGroup.setLayout(layout); | |
487 | data = new GridData(GridData.FILL_HORIZONTAL); | |
488 | functionMainGroup.setLayoutData(data); | |
489 | ||
490 | Composite buttonComposite = new Composite(functionMainGroup, SWT.NONE); | |
491 | layout = new GridLayout(1, false); | |
492 | buttonComposite.setLayout(layout); | |
493 | data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true); | |
494 | buttonComposite.setLayoutData(data); | |
495 | ||
496 | fFunctionActivateButton = new Button(buttonComposite, SWT.RADIO); | |
497 | fFunctionActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName); | |
498 | fFunctionActivateButton.setSelection(false); | |
499 | data = new GridData(GridData.FILL_HORIZONTAL); | |
500 | fFunctionActivateButton.setLayoutData(data); | |
501 | fFunctionActivateButton.addSelectionListener(new SelectionAdapter() { | |
502 | @Override | |
503 | public void widgetSelected(SelectionEvent e) { | |
504 | setKernelEnablements(KernelGroupEnum.FUNCTION); | |
505 | } | |
506 | }); | |
507 | ||
508 | Group functionGroup = new Group(functionMainGroup, SWT.SHADOW_NONE); | |
509 | layout = new GridLayout(4, true); | |
510 | functionGroup.setLayout(layout); | |
511 | functionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); | |
512 | ||
513 | Label functionNameLabel = new Label(functionGroup, SWT.LEFT); | |
514 | functionNameLabel.setText(Messages.TraceControl_EnableEventsEventNameLabel); | |
515 | data = new GridData(GridData.FILL_BOTH); | |
516 | data.horizontalSpan = 1; | |
517 | functionNameLabel.setLayoutData(data); | |
518 | ||
519 | fFunctionEventNameText = new Text(functionGroup, SWT.LEFT); | |
520 | fFunctionEventNameText.setToolTipText(Messages.TraceControl_EnableEventsFunctionEventNameTooltip); | |
521 | data = new GridData(GridData.FILL_BOTH); | |
522 | data.horizontalSpan = 3; | |
523 | fFunctionEventNameText.setLayoutData(data); | |
524 | ||
525 | Label functionLabel = new Label(functionGroup, SWT.LEFT); | |
526 | functionLabel.setText(Messages.TraceControl_EnableEventsFunctionNameLabel); | |
527 | data = new GridData(GridData.FILL_BOTH); | |
528 | data.horizontalSpan = 1; | |
529 | functionLabel.setLayoutData(data); | |
530 | ||
531 | fFunctionText = new Text(functionGroup, SWT.LEFT); | |
532 | fFunctionText.setToolTipText(Messages.TraceControl_EnableEventsProbeNameTooltip); | |
533 | data = new GridData(GridData.FILL_BOTH); | |
534 | data.horizontalSpan = 3; | |
535 | fFunctionText.setLayoutData(data); | |
536 | } | |
537 | ||
538 | /** | |
539 | * Enable/selects widgets depending on the group specified. | |
540 | * @param group - group to enable. | |
541 | */ | |
542 | private void setKernelEnablements(KernelGroupEnum group) { | |
543 | fTracepointsActivateButton.setSelection(group == KernelGroupEnum.TRACEPOINTS); | |
544 | fTracepointsViewer.getTree().setEnabled(group == KernelGroupEnum.TRACEPOINTS); | |
545 | ||
546 | fSysCallsActivateButton.setSelection(group == KernelGroupEnum.SYSCALLS); | |
547 | ||
548 | fProbeActivateButton.setSelection(group == KernelGroupEnum.PROBE); | |
549 | fProbeEventNameText.setEnabled(group == KernelGroupEnum.PROBE); | |
550 | fProbeText.setEnabled(group == KernelGroupEnum.PROBE); | |
551 | ||
552 | fFunctionActivateButton.setSelection(group == KernelGroupEnum.FUNCTION); | |
553 | fFunctionEventNameText.setEnabled(group == KernelGroupEnum.FUNCTION); | |
554 | fFunctionText.setEnabled(group == KernelGroupEnum.FUNCTION); | |
555 | } | |
556 | ||
557 | // ------------------------------------------------------------------------ | |
558 | // Local classes | |
559 | // ------------------------------------------------------------------------ | |
560 | /** | |
561 | * Content provider for the tracepoints tree. | |
562 | */ | |
c56972bb | 563 | final static public class KernelContentProvider extends TraceControlContentProvider { |
ccc66d01 BH |
564 | @Override |
565 | public Object[] getChildren(Object parentElement) { | |
566 | if (parentElement instanceof TraceProviderGroup) { | |
567 | List<ITraceControlComponent> children = ((ITraceControlComponent)parentElement).getChildren(KernelProviderComponent.class); | |
568 | return (ITraceControlComponent[]) children.toArray(new ITraceControlComponent[children.size()]); | |
569 | } | |
570 | if (parentElement instanceof ITraceControlComponent) { | |
571 | return ((ITraceControlComponent)parentElement).getChildren(); | |
572 | } | |
573 | return new Object[0]; | |
574 | } | |
575 | } | |
576 | ||
577 | /** | |
578 | * Content label for the tracepoints tree. | |
579 | */ | |
c56972bb | 580 | final static public class KernelLabelProvider extends TraceControlLabelProvider { |
ccc66d01 BH |
581 | @Override |
582 | public Image getImage(Object element) { | |
583 | return null; | |
584 | } | |
585 | @Override | |
586 | public String getText(Object element) { | |
587 | if ((element != null) && (element instanceof KernelProviderComponent)) { | |
588 | return Messages.TraceControl_EnableEventsTracepointTreeAllLabel; | |
589 | } | |
590 | return super.getText(element); | |
591 | } | |
592 | } | |
593 | ||
594 | /** | |
595 | * Check state listener for the tracepoints tree. | |
596 | */ | |
597 | final public class KernelCheckListener implements ICheckStateListener { | |
598 | @Override | |
599 | public void checkStateChanged(CheckStateChangedEvent event) { | |
600 | if (event.getChecked()) { | |
601 | if (event.getElement() instanceof KernelProviderComponent) { | |
602 | fTracepointsViewer.setSubtreeChecked(event.getElement(), true); | |
603 | } | |
604 | } else { | |
605 | if (event.getElement() instanceof KernelProviderComponent) { | |
606 | fTracepointsViewer.setSubtreeChecked(event.getElement(), false); | |
607 | } else { | |
608 | ITraceControlComponent component = (ITraceControlComponent) event.getElement(); | |
609 | fTracepointsViewer.setChecked(component.getParent(), false); | |
610 | } | |
611 | } | |
612 | } | |
613 | } | |
614 | } |