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