Commit | Line | Data |
---|---|---|
ccc66d01 | 1 | /********************************************************************** |
60ae41e1 | 2 | * Copyright (c) 2012, 2014 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 | 10 | * Bernd Hufmann - Initial API and implementation |
d4489ec9 | 11 | * Marc-Andre Laperle - Add filtering textbox |
ccc66d01 | 12 | **********************************************************************/ |
9bc60be7 | 13 | package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs; |
ccc66d01 BH |
14 | |
15 | import java.util.ArrayList; | |
aa2c8e1a | 16 | import java.util.Arrays; |
ccc66d01 | 17 | import java.util.List; |
aa2c8e1a | 18 | import java.util.stream.Collectors; |
ccc66d01 BH |
19 | |
20 | import org.eclipse.jface.dialogs.MessageDialog; | |
21 | import org.eclipse.jface.viewers.CheckStateChangedEvent; | |
22 | import org.eclipse.jface.viewers.CheckboxTreeViewer; | |
23 | import org.eclipse.jface.viewers.ICheckStateListener; | |
d4489ec9 | 24 | import org.eclipse.jface.viewers.TreeViewer; |
ccc66d01 BH |
25 | import org.eclipse.swt.SWT; |
26 | import org.eclipse.swt.events.SelectionAdapter; | |
27 | import org.eclipse.swt.events.SelectionEvent; | |
28 | import org.eclipse.swt.graphics.Image; | |
29 | import org.eclipse.swt.layout.GridData; | |
30 | import org.eclipse.swt.layout.GridLayout; | |
31 | import org.eclipse.swt.widgets.Button; | |
32 | import org.eclipse.swt.widgets.Composite; | |
33 | import org.eclipse.swt.widgets.Group; | |
34 | import org.eclipse.swt.widgets.Label; | |
35 | import org.eclipse.swt.widgets.Text; | |
1bc37054 | 36 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceDomainType; |
9bc60be7 AM |
37 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages; |
38 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent; | |
39 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.BaseEventComponent; | |
40 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.KernelProviderComponent; | |
41 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceControlContentProvider; | |
42 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceControlLabelProvider; | |
43 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceProviderGroup; | |
d4489ec9 MAL |
44 | import org.eclipse.ui.dialogs.FilteredTree; |
45 | import org.eclipse.ui.dialogs.PatternFilter; | |
ccc66d01 BH |
46 | |
47 | /** | |
ccc66d01 BH |
48 | * <p> |
49 | * A composite for collecting information about kernel events to be enabled. | |
50 | * </p> | |
cfdb727a | 51 | * |
dbd4432d | 52 | * @author Bernd Hufmann |
ccc66d01 BH |
53 | */ |
54 | public class EnableKernelEventComposite extends Composite implements IEnableKernelEvents { | |
55 | ||
56 | // ------------------------------------------------------------------------ | |
57 | // Constants | |
58 | // ------------------------------------------------------------------------ | |
9ee91a86 | 59 | private enum KernelGroupEnum { ALL, TRACEPOINTS, SYSCALLS, PROBE, FUNCTION } |
ccc66d01 BH |
60 | |
61 | // ------------------------------------------------------------------------ | |
62 | // Attributes | |
63 | // ------------------------------------------------------------------------ | |
64 | ||
9ee91a86 BH |
65 | /** |
66 | * A button to enable/disable the all tracepoints&sycalls group | |
67 | */ | |
68 | private Button fAllActivateButton; | |
ccc66d01 BH |
69 | /** |
70 | * A button to enable/disable the tracepoints group | |
71 | */ | |
72 | private Button fTracepointsActivateButton; | |
73 | /** | |
74 | * A tree viewer for displaying and selection of available tracepoints. | |
75 | */ | |
76 | private CheckboxTreeViewer fTracepointsViewer; | |
77 | /** | |
78 | * A button to enable/disable the syscalls group | |
79 | */ | |
80 | private Button fSysCallsActivateButton; | |
aa2c8e1a BR |
81 | /** |
82 | * A Text field for the specific event name. | |
83 | */ | |
84 | private Text fSpecificEventText; | |
ccc66d01 BH |
85 | /** |
86 | * A button to enable or disable the dynamic probe group. | |
87 | */ | |
88 | private Button fProbeActivateButton; | |
89 | /** | |
cfdb727a | 90 | * The text field for the event name for the dynamic probe. |
ccc66d01 BH |
91 | */ |
92 | private Text fProbeEventNameText; | |
93 | /** | |
94 | * The text field for the dynamic probe. | |
95 | */ | |
96 | private Text fProbeText; | |
97 | /** | |
98 | * A button to enable or disable the dynamic function probe group. | |
99 | */ | |
100 | private Button fFunctionActivateButton; | |
101 | /** | |
cfdb727a | 102 | * The text field for the event name for the dynamic probe. |
ccc66d01 BH |
103 | */ |
104 | private Text fFunctionEventNameText; | |
105 | /** | |
106 | * The text field for the dynamic function entry/return probe. | |
107 | */ | |
108 | private Text fFunctionText; | |
f0584d20 BH |
109 | /** |
110 | * The filter text | |
111 | */ | |
112 | private Text fFilterText; | |
ccc66d01 | 113 | /** |
cfdb727a | 114 | * The referenced trace provider group containing the kernel provider |
ccc66d01 BH |
115 | * component which contains a list of available tracepoints. |
116 | */ | |
cfdb727a | 117 | private final TraceProviderGroup fProviderGroup; |
9ee91a86 BH |
118 | /** |
119 | * The flag indicating that all tracepoints/syscalls are selected. | |
120 | */ | |
121 | private boolean fIsAllTracepointsAndSyscalls; | |
ccc66d01 BH |
122 | /** |
123 | * The flag indicating that tracepoints are selected. | |
124 | */ | |
125 | private boolean fIsTracepoints; | |
126 | /** | |
127 | * The flag indicating that all tracepoints are selected. | |
128 | */ | |
129 | private boolean fIsAllTracepoints; | |
130 | /** | |
131 | * The flag indicating that syscalls are selected. | |
132 | */ | |
133 | private boolean fIsSysCalls; | |
134 | /** | |
135 | * The list of tracepoints to be enabled. | |
136 | */ | |
137 | private List<String> fSelectedEvents; | |
138 | /** | |
139 | * The flag indicating that dynamic probe is selected. | |
140 | */ | |
141 | private boolean fIsDynamicProbe; | |
142 | /** | |
cfdb727a | 143 | * The event name of the dynamic probe. |
ccc66d01 BH |
144 | */ |
145 | private String fProbeEventName; | |
146 | /** | |
147 | * The dynamic probe. | |
148 | */ | |
149 | private String fProbeString; | |
150 | /** | |
151 | * The flag indicating that the dynamic function probe is selected. | |
152 | */ | |
153 | private boolean fIsDynamicFunctionProbe; | |
154 | /** | |
155 | * The event name of the dynamic function entry/return probe. | |
156 | */ | |
157 | private String fFunctionEventName; | |
158 | /** | |
159 | * The dynamic function entry/return probe. | |
160 | */ | |
161 | private String fFunctionString; | |
f0584d20 BH |
162 | /** |
163 | * The filter expression | |
164 | */ | |
165 | private String fFilterExpression; | |
ccc66d01 BH |
166 | |
167 | // ------------------------------------------------------------------------ | |
168 | // Constructors | |
169 | // ------------------------------------------------------------------------ | |
170 | ||
cfdb727a AM |
171 | /** |
172 | * Constructor | |
173 | * | |
174 | * @param parent | |
175 | * The parent composite | |
176 | * @param style | |
177 | * The index of the style for this event composite | |
178 | * @param providerGroup | |
179 | * The trace provider group | |
180 | */ | |
ccc66d01 BH |
181 | public EnableKernelEventComposite(Composite parent, int style, TraceProviderGroup providerGroup) { |
182 | super(parent, style); | |
183 | fProviderGroup = providerGroup; | |
184 | } | |
185 | ||
186 | // ------------------------------------------------------------------------ | |
187 | // Acessors | |
188 | // ------------------------------------------------------------------------ | |
9ee91a86 BH |
189 | @Override |
190 | public boolean isAllEvents() { | |
191 | return fIsAllTracepointsAndSyscalls; | |
192 | } | |
ccc66d01 BH |
193 | @Override |
194 | public boolean isTracepoints() { | |
195 | return fIsTracepoints; | |
196 | } | |
cfdb727a | 197 | |
ccc66d01 BH |
198 | @Override |
199 | public boolean isAllTracePoints() { | |
200 | return fIsAllTracepoints; | |
201 | } | |
cfdb727a | 202 | |
ccc66d01 BH |
203 | @Override |
204 | public boolean isSysCalls() { | |
205 | return fIsSysCalls; | |
206 | } | |
cfdb727a | 207 | |
ccc66d01 BH |
208 | @Override |
209 | public boolean isAllSysCalls() { | |
210 | return fIsSysCalls; | |
211 | } | |
cfdb727a | 212 | |
ccc66d01 BH |
213 | @Override |
214 | public List<String> getEventNames() { | |
e0838ca1 | 215 | return new ArrayList<>(fSelectedEvents); |
ccc66d01 | 216 | } |
11252342 | 217 | |
ccc66d01 BH |
218 | @Override |
219 | public boolean isDynamicProbe() { | |
220 | return fIsDynamicProbe; | |
221 | } | |
cfdb727a | 222 | |
ccc66d01 BH |
223 | @Override |
224 | public String getProbeName() { | |
225 | return fProbeString; | |
226 | } | |
cfdb727a | 227 | |
ccc66d01 BH |
228 | @Override |
229 | public String getProbeEventName() { | |
230 | return fProbeEventName; | |
231 | } | |
cfdb727a | 232 | |
ccc66d01 BH |
233 | @Override |
234 | public boolean isDynamicFunctionProbe() { | |
235 | return fIsDynamicFunctionProbe; | |
236 | } | |
cfdb727a | 237 | |
ccc66d01 BH |
238 | @Override |
239 | public String getFunctionEventName() { | |
240 | return fFunctionEventName; | |
241 | } | |
cfdb727a | 242 | |
ccc66d01 BH |
243 | @Override |
244 | public String getFunction() { | |
245 | return fFunctionString; | |
246 | } | |
247 | ||
f0584d20 BH |
248 | @Override |
249 | public String getFilterExpression() { | |
250 | return fFilterExpression; | |
251 | } | |
252 | ||
ccc66d01 BH |
253 | // ------------------------------------------------------------------------ |
254 | // Operations | |
255 | // ------------------------------------------------------------------------ | |
11252342 | 256 | |
ccc66d01 BH |
257 | /** |
258 | * Creates the composite content | |
259 | */ | |
260 | public void createContent() { | |
cfdb727a | 261 | |
9ee91a86 BH |
262 | // All Tracepoints/syscalls Group |
263 | createAllTracepointsSyscallGroup(); | |
264 | ||
cfdb727a | 265 | // Tracepoints Group |
ccc66d01 BH |
266 | createTracepointsGroup(); |
267 | ||
cfdb727a | 268 | // Syscalls Group |
ccc66d01 | 269 | createSysCallsGroup(); |
cfdb727a AM |
270 | |
271 | // Dynamic Probe Group | |
ccc66d01 BH |
272 | createDynamicProbeGroup(); |
273 | ||
cfdb727a | 274 | // Dynamic Function Probe Group |
ccc66d01 | 275 | createDynamicFunctionPropeGroup(); |
cfdb727a | 276 | |
f0584d20 BH |
277 | // Filter Group |
278 | createFilterGroup(); | |
279 | ||
ccc66d01 | 280 | // Set default enablements |
9ee91a86 | 281 | setKernelEnablements(KernelGroupEnum.ALL); |
ccc66d01 | 282 | } |
cfdb727a | 283 | |
ccc66d01 BH |
284 | /** |
285 | * Validates the kernel composite input data. | |
286 | * @return true if configured data is valid and can be retrieved. | |
287 | */ | |
288 | public boolean isValid() { | |
9ee91a86 | 289 | fIsAllTracepointsAndSyscalls = fAllActivateButton.getSelection(); |
ccc66d01 BH |
290 | fIsTracepoints = fTracepointsActivateButton.getSelection(); |
291 | fIsSysCalls = fSysCallsActivateButton.getSelection(); | |
292 | fIsDynamicProbe = fProbeActivateButton.getSelection(); | |
293 | fIsDynamicFunctionProbe = fFunctionActivateButton.getSelection(); | |
294 | ||
5f1f22f8 BH |
295 | // initialize tracepoint fields |
296 | fIsAllTracepoints = false; | |
e0838ca1 | 297 | fSelectedEvents = new ArrayList<>(); |
5f1f22f8 BH |
298 | |
299 | if (fIsTracepoints) { | |
5f1f22f8 BH |
300 | Object[] checkedElements = fTracepointsViewer.getCheckedElements(); |
301 | for (int i = 0; i < checkedElements.length; i++) { | |
302 | ITraceControlComponent component = (ITraceControlComponent)checkedElements[i]; | |
303 | if (component instanceof BaseEventComponent) { | |
304 | fSelectedEvents.add(component.getName()); | |
305 | } | |
ccc66d01 | 306 | } |
579acd01 BH |
307 | // verify if all events are selected |
308 | int nbEvents = 0; | |
309 | List<ITraceControlComponent> comps = fProviderGroup.getChildren(KernelProviderComponent.class); | |
310 | for (ITraceControlComponent comp : comps) { | |
311 | nbEvents += comp.getChildren().length; | |
312 | } | |
313 | fIsAllTracepoints = (nbEvents == fSelectedEvents.size()); | |
aa2c8e1a BR |
314 | String tmpSpecificEvent = fSpecificEventText.getText(); |
315 | if (!fIsAllTracepoints && !tmpSpecificEvent.trim().isEmpty()) { | |
316 | // Format the text to a List<String> | |
317 | // Removing all non visible characters | |
318 | tmpSpecificEvent = tmpSpecificEvent.replaceAll("\\s", ""); //$NON-NLS-1$ //$NON-NLS-2$ | |
319 | // Splitting the different events that are separated by commas | |
320 | List<String> list = Arrays.asList(tmpSpecificEvent.split(",")); //$NON-NLS-1$ | |
321 | fSelectedEvents.addAll(list); | |
322 | fSelectedEvents = fSelectedEvents.stream().distinct().collect(Collectors.toList()); | |
323 | } | |
ccc66d01 | 324 | } |
5f1f22f8 BH |
325 | |
326 | if (fIsDynamicProbe) { | |
327 | String temp = fProbeEventNameText.getText(); | |
4bd5ece2 | 328 | if (temp.trim().isEmpty() || |
c371fa43 | 329 | (!temp.matches("^[\\s]{0,}$") && !temp.matches("^[a-zA-Z0-9\\-\\_]{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$ |
5f1f22f8 BH |
330 | MessageDialog.openError(getShell(), |
331 | Messages.TraceControl_EnableEventsDialogTitle, | |
332 | Messages.TraceControl_InvalidProbeNameError + " (" + temp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ | |
333 | ||
334 | return false; | |
335 | } | |
336 | ||
c371fa43 BH |
337 | fProbeEventName = temp; |
338 | // fProbeString will be validated by lttng-tools | |
339 | fProbeString = fProbeText.getText(); | |
ccc66d01 | 340 | } |
ccc66d01 BH |
341 | |
342 | // initialize function string | |
343 | fFunctionEventName = null; | |
344 | fFunctionString = null; | |
5f1f22f8 BH |
345 | if (fIsDynamicFunctionProbe) { |
346 | String functionTemp = fFunctionEventNameText.getText(); | |
4bd5ece2 | 347 | if (functionTemp.trim().isEmpty() || |
c371fa43 | 348 | (!functionTemp.matches("^[\\s]{0,}$") && !functionTemp.matches("^[a-zA-Z0-9\\-\\_]{1,}$"))) { //$NON-NLS-1$ //$NON-NLS-2$ |
5f1f22f8 BH |
349 | MessageDialog.openError(getShell(), |
350 | Messages.TraceControl_EnableEventsDialogTitle, | |
351 | Messages.TraceControl_InvalidProbeNameError + " (" + functionTemp + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ | |
ccc66d01 | 352 | |
5f1f22f8 BH |
353 | return false; |
354 | } | |
ccc66d01 | 355 | |
c371fa43 BH |
356 | fFunctionEventName = functionTemp; |
357 | // fFunctionString will be validated by lttng-tools | |
358 | fFunctionString = fFunctionText.getText(); | |
ccc66d01 BH |
359 | } |
360 | ||
f0584d20 BH |
361 | // initialize filter with null |
362 | fFilterExpression = null; | |
1bc37054 | 363 | if (fProviderGroup.isEventFilteringSupported(TraceDomainType.KERNEL)) { |
f0584d20 BH |
364 | String tempFilter = fFilterText.getText(); |
365 | ||
4bd5ece2 | 366 | if(!tempFilter.trim().isEmpty()) { |
f0584d20 BH |
367 | fFilterExpression = tempFilter; |
368 | } | |
369 | } | |
370 | ||
ccc66d01 BH |
371 | return true; |
372 | } | |
cfdb727a | 373 | |
9ee91a86 BH |
374 | /** |
375 | * Creates all tracepoints/syscalls group. | |
376 | */ | |
377 | private void createAllTracepointsSyscallGroup() { | |
378 | ||
379 | GridLayout layout; | |
380 | GridData data; | |
381 | Group tpMainGroup = new Group(this, SWT.SHADOW_NONE); | |
382 | tpMainGroup.setText(Messages.TraceControl_EnableEventsAllEventsLabel); | |
383 | layout = new GridLayout(2, false); | |
384 | tpMainGroup.setLayout(layout); | |
385 | data = new GridData(GridData.FILL_HORIZONTAL); | |
386 | tpMainGroup.setLayoutData(data); | |
387 | ||
388 | Composite buttonComposite = new Composite(tpMainGroup, SWT.NONE); | |
389 | layout = new GridLayout(1, true); | |
390 | buttonComposite.setLayout(layout); | |
391 | data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true); | |
392 | buttonComposite.setLayoutData(data); | |
393 | ||
394 | fAllActivateButton = new Button(buttonComposite, SWT.RADIO); | |
395 | fAllActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName); | |
396 | fAllActivateButton.setToolTipText(Messages.TraceControl_EnableEventsAllEventsTooltip); | |
397 | data = new GridData(GridData.FILL_HORIZONTAL); | |
398 | fAllActivateButton.setLayoutData(data); | |
399 | fAllActivateButton.addSelectionListener(new SelectionAdapter() { | |
400 | @Override | |
401 | public void widgetSelected(SelectionEvent e) { | |
402 | setKernelEnablements(KernelGroupEnum.ALL); | |
403 | } | |
404 | }); | |
405 | } | |
406 | ||
ccc66d01 BH |
407 | /** |
408 | * Creates tracepoints group. | |
409 | */ | |
410 | private void createTracepointsGroup() { | |
411 | ||
412 | GridLayout layout; | |
413 | GridData data; | |
414 | Group tpMainGroup = new Group(this, SWT.SHADOW_NONE); | |
415 | tpMainGroup.setText(Messages.TraceControl_EnableEventsTracepointGroupName); | |
416 | layout = new GridLayout(2, false); | |
417 | tpMainGroup.setLayout(layout); | |
418 | data = new GridData(GridData.FILL_BOTH); | |
419 | tpMainGroup.setLayoutData(data); | |
420 | ||
421 | Composite buttonComposite = new Composite(tpMainGroup, SWT.NONE); | |
422 | layout = new GridLayout(1, true); | |
423 | buttonComposite.setLayout(layout); | |
424 | data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true); | |
425 | buttonComposite.setLayoutData(data); | |
426 | ||
427 | fTracepointsActivateButton = new Button(buttonComposite, SWT.RADIO); | |
428 | fTracepointsActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName); | |
429 | data = new GridData(GridData.FILL_HORIZONTAL); | |
430 | fTracepointsActivateButton.setLayoutData(data); | |
431 | fTracepointsActivateButton.addSelectionListener(new SelectionAdapter() { | |
432 | @Override | |
433 | public void widgetSelected(SelectionEvent e) { | |
434 | setKernelEnablements(KernelGroupEnum.TRACEPOINTS); | |
435 | } | |
436 | }); | |
437 | ||
438 | Group tracepointsGroup = new Group(tpMainGroup, SWT.SHADOW_NONE); | |
439 | layout = new GridLayout(1, true); | |
440 | tracepointsGroup.setLayout(layout); | |
441 | data = new GridData(GridData.FILL_BOTH); | |
442 | tracepointsGroup.setLayoutData(data); | |
443 | ||
d4489ec9 MAL |
444 | new FilteredTree(tracepointsGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, new PatternFilter(), true) { |
445 | @Override | |
446 | protected TreeViewer doCreateTreeViewer(Composite aparent, int style) { | |
447 | fTracepointsViewer = new CheckboxTreeViewer(aparent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); | |
448 | fTracepointsViewer.getTree().setToolTipText(Messages.TraceControl_EnableEventsTracepointTreeTooltip); | |
ccc66d01 | 449 | |
d4489ec9 MAL |
450 | fTracepointsViewer.setContentProvider(new KernelContentProvider()); |
451 | fTracepointsViewer.setLabelProvider(new KernelLabelProvider()); | |
452 | fTracepointsViewer.addCheckStateListener(new KernelCheckListener()); | |
453 | fTracepointsViewer.setInput(fProviderGroup); | |
ccc66d01 | 454 | |
d4489ec9 MAL |
455 | fTracepointsViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH)); |
456 | return fTracepointsViewer; | |
457 | } | |
ad9972cc PJPG |
458 | |
459 | @Override | |
460 | protected void updateToolbar(boolean visible) { | |
461 | super.updateToolbar(visible); | |
462 | treeViewer.expandAll(); | |
463 | } | |
d4489ec9 | 464 | }; |
aa2c8e1a BR |
465 | |
466 | Group specificEventGroup = new Group(tracepointsGroup, SWT.SHADOW_NONE); | |
467 | specificEventGroup.setText(Messages.TraceControl_EnableEventsSpecificEventGroupName); | |
468 | layout = new GridLayout(4, true); | |
469 | specificEventGroup.setLayout(layout); | |
470 | specificEventGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); | |
471 | ||
472 | Label specificEventLabel = new Label(specificEventGroup, SWT.LEFT); | |
e010f47b | 473 | specificEventLabel.setText(Messages.TraceControl_EnableEventsEventNameLabel); |
aa2c8e1a BR |
474 | data = new GridData(GridData.FILL_HORIZONTAL); |
475 | data.horizontalSpan = 1; | |
476 | specificEventLabel.setLayoutData(data); | |
477 | ||
478 | fSpecificEventText = new Text(specificEventGroup, SWT.LEFT); | |
479 | fSpecificEventText.setToolTipText(Messages.TraceControl_EnableEventsSpecificEventTooltip); | |
480 | data = new GridData(GridData.FILL_HORIZONTAL); | |
481 | data.horizontalSpan = 3; | |
482 | fSpecificEventText.setLayoutData(data); | |
ccc66d01 BH |
483 | } |
484 | ||
485 | /** | |
486 | * Creates syscalls group. | |
487 | */ | |
488 | private void createSysCallsGroup() { | |
489 | GridLayout layout; | |
490 | GridData data; | |
491 | Group sysCallsMainGroup = new Group(this, SWT.SHADOW_NONE); | |
492 | sysCallsMainGroup.setText(Messages.TraceControl_EnableEventsSyscallName); | |
493 | sysCallsMainGroup.setToolTipText(Messages.TraceControl_EnableEventsSyscallTooltip); | |
494 | layout = new GridLayout(2, false); | |
495 | sysCallsMainGroup.setLayout(layout); | |
496 | data = new GridData(GridData.FILL_HORIZONTAL); | |
497 | sysCallsMainGroup.setLayoutData(data); | |
498 | ||
499 | Composite buttonComposite = new Composite(sysCallsMainGroup, SWT.NONE); | |
500 | layout = new GridLayout(1, false); | |
501 | buttonComposite.setLayout(layout); | |
502 | data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true); | |
503 | buttonComposite.setLayoutData(data); | |
504 | ||
505 | fSysCallsActivateButton = new Button(buttonComposite, SWT.RADIO); | |
506 | fSysCallsActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName); | |
507 | fSysCallsActivateButton.setToolTipText(Messages.TraceControl_EnableEventsSyscallTooltip); | |
508 | fSysCallsActivateButton.setSelection(false); | |
509 | data = new GridData(GridData.FILL_HORIZONTAL); | |
510 | fSysCallsActivateButton.setLayoutData(data); | |
511 | fSysCallsActivateButton.addSelectionListener(new SelectionAdapter() { | |
512 | @Override | |
513 | public void widgetSelected(SelectionEvent e) { | |
514 | setKernelEnablements(KernelGroupEnum.SYSCALLS); | |
515 | } | |
516 | }); | |
517 | } | |
518 | ||
519 | /** | |
520 | * Creates dynamic probe group. | |
521 | */ | |
522 | private void createDynamicProbeGroup() { | |
523 | GridLayout layout; | |
524 | GridData data; | |
525 | Group probeMainGroup = new Group(this, SWT.SHADOW_NONE); | |
526 | probeMainGroup.setText(Messages.TraceControl_EnableEventsProbeGroupName); | |
527 | layout = new GridLayout(2, false); | |
528 | probeMainGroup.setLayout(layout); | |
529 | data = new GridData(GridData.FILL_HORIZONTAL); | |
530 | probeMainGroup.setLayoutData(data); | |
531 | ||
532 | Composite buttonComposite = new Composite(probeMainGroup, SWT.NONE); | |
533 | layout = new GridLayout(1, false); | |
534 | buttonComposite.setLayout(layout); | |
535 | data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true); | |
536 | buttonComposite.setLayoutData(data); | |
537 | ||
538 | fProbeActivateButton = new Button(buttonComposite, SWT.RADIO); | |
539 | fProbeActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName); | |
540 | fProbeActivateButton.setSelection(false); | |
541 | data = new GridData(GridData.FILL_HORIZONTAL); | |
542 | fProbeActivateButton.setLayoutData(data); | |
543 | fProbeActivateButton.addSelectionListener(new SelectionAdapter() { | |
544 | @Override | |
545 | public void widgetSelected(SelectionEvent e) { | |
546 | setKernelEnablements(KernelGroupEnum.PROBE); | |
547 | } | |
548 | }); | |
549 | ||
550 | Group probeGroup = new Group(probeMainGroup, SWT.SHADOW_NONE); | |
551 | layout = new GridLayout(4, true); | |
552 | probeGroup.setLayout(layout); | |
553 | probeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); | |
554 | ||
555 | Label probeNameLabel = new Label(probeGroup, SWT.LEFT); | |
556 | probeNameLabel.setText(Messages.TraceControl_EnableEventsEventNameLabel); | |
557 | data = new GridData(GridData.FILL_BOTH); | |
558 | data.horizontalSpan = 1; | |
559 | probeNameLabel.setLayoutData(data); | |
560 | ||
561 | fProbeEventNameText = new Text(probeGroup, SWT.LEFT); | |
562 | fProbeEventNameText.setToolTipText(Messages.TraceControl_EnableEventsProbeEventNameTooltip); | |
563 | ||
564 | data = new GridData(GridData.FILL_BOTH); | |
565 | data.horizontalSpan = 3; | |
566 | fProbeEventNameText.setLayoutData(data); | |
567 | ||
568 | Label probeLabel = new Label(probeGroup, SWT.LEFT); | |
569 | probeLabel.setText(Messages.TraceControl_EnableEventsProbeNameLabel); | |
570 | data = new GridData(GridData.FILL_BOTH); | |
571 | data.horizontalSpan = 1; | |
572 | probeLabel.setLayoutData(data); | |
573 | ||
574 | fProbeText = new Text(probeGroup, SWT.LEFT); | |
575 | fProbeText.setToolTipText(Messages.TraceControl_EnableEventsProbeNameTooltip); | |
576 | data = new GridData(GridData.FILL_BOTH); | |
577 | data.horizontalSpan = 3; | |
578 | fProbeText.setLayoutData(data); | |
579 | } | |
580 | ||
581 | /** | |
582 | * Creates dynamic function entry/return probe group. | |
583 | */ | |
584 | private void createDynamicFunctionPropeGroup() { | |
585 | GridLayout layout; | |
586 | GridData data; | |
587 | Group functionMainGroup = new Group(this, SWT.SHADOW_NONE); | |
588 | functionMainGroup.setText(Messages.TraceControl_EnableEventsFucntionGroupName); | |
589 | layout = new GridLayout(2, false); | |
590 | functionMainGroup.setLayout(layout); | |
591 | data = new GridData(GridData.FILL_HORIZONTAL); | |
592 | functionMainGroup.setLayoutData(data); | |
593 | ||
594 | Composite buttonComposite = new Composite(functionMainGroup, SWT.NONE); | |
595 | layout = new GridLayout(1, false); | |
596 | buttonComposite.setLayout(layout); | |
597 | data = new GridData(SWT.BEGINNING, SWT.CENTER, false, true); | |
598 | buttonComposite.setLayoutData(data); | |
599 | ||
600 | fFunctionActivateButton = new Button(buttonComposite, SWT.RADIO); | |
601 | fFunctionActivateButton.setText(Messages.TraceControl_EnableGroupSelectionName); | |
602 | fFunctionActivateButton.setSelection(false); | |
603 | data = new GridData(GridData.FILL_HORIZONTAL); | |
604 | fFunctionActivateButton.setLayoutData(data); | |
605 | fFunctionActivateButton.addSelectionListener(new SelectionAdapter() { | |
606 | @Override | |
607 | public void widgetSelected(SelectionEvent e) { | |
608 | setKernelEnablements(KernelGroupEnum.FUNCTION); | |
609 | } | |
610 | }); | |
611 | ||
612 | Group functionGroup = new Group(functionMainGroup, SWT.SHADOW_NONE); | |
613 | layout = new GridLayout(4, true); | |
614 | functionGroup.setLayout(layout); | |
615 | functionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); | |
616 | ||
617 | Label functionNameLabel = new Label(functionGroup, SWT.LEFT); | |
618 | functionNameLabel.setText(Messages.TraceControl_EnableEventsEventNameLabel); | |
619 | data = new GridData(GridData.FILL_BOTH); | |
620 | data.horizontalSpan = 1; | |
621 | functionNameLabel.setLayoutData(data); | |
622 | ||
623 | fFunctionEventNameText = new Text(functionGroup, SWT.LEFT); | |
624 | fFunctionEventNameText.setToolTipText(Messages.TraceControl_EnableEventsFunctionEventNameTooltip); | |
625 | data = new GridData(GridData.FILL_BOTH); | |
626 | data.horizontalSpan = 3; | |
627 | fFunctionEventNameText.setLayoutData(data); | |
628 | ||
629 | Label functionLabel = new Label(functionGroup, SWT.LEFT); | |
630 | functionLabel.setText(Messages.TraceControl_EnableEventsFunctionNameLabel); | |
631 | data = new GridData(GridData.FILL_BOTH); | |
632 | data.horizontalSpan = 1; | |
633 | functionLabel.setLayoutData(data); | |
634 | ||
635 | fFunctionText = new Text(functionGroup, SWT.LEFT); | |
636 | fFunctionText.setToolTipText(Messages.TraceControl_EnableEventsProbeNameTooltip); | |
637 | data = new GridData(GridData.FILL_BOTH); | |
638 | data.horizontalSpan = 3; | |
639 | fFunctionText.setLayoutData(data); | |
640 | } | |
641 | ||
642 | /** | |
643 | * Enable/selects widgets depending on the group specified. | |
644 | * @param group - group to enable. | |
645 | */ | |
646 | private void setKernelEnablements(KernelGroupEnum group) { | |
9ee91a86 | 647 | fAllActivateButton.setSelection(group == KernelGroupEnum.ALL); |
ccc66d01 BH |
648 | fTracepointsActivateButton.setSelection(group == KernelGroupEnum.TRACEPOINTS); |
649 | fTracepointsViewer.getTree().setEnabled(group == KernelGroupEnum.TRACEPOINTS); | |
aa2c8e1a | 650 | fSpecificEventText.setEnabled(group == KernelGroupEnum.TRACEPOINTS); |
ccc66d01 BH |
651 | |
652 | fSysCallsActivateButton.setSelection(group == KernelGroupEnum.SYSCALLS); | |
653 | ||
654 | fProbeActivateButton.setSelection(group == KernelGroupEnum.PROBE); | |
655 | fProbeEventNameText.setEnabled(group == KernelGroupEnum.PROBE); | |
656 | fProbeText.setEnabled(group == KernelGroupEnum.PROBE); | |
657 | ||
658 | fFunctionActivateButton.setSelection(group == KernelGroupEnum.FUNCTION); | |
659 | fFunctionEventNameText.setEnabled(group == KernelGroupEnum.FUNCTION); | |
660 | fFunctionText.setEnabled(group == KernelGroupEnum.FUNCTION); | |
661 | } | |
662 | ||
f0584d20 | 663 | private void createFilterGroup() { |
1bc37054 | 664 | if (fProviderGroup.isEventFilteringSupported(TraceDomainType.KERNEL)) { |
f0584d20 BH |
665 | Group filterMainGroup = new Group(this, SWT.SHADOW_NONE); |
666 | filterMainGroup.setText(Messages.TraceControl_EnableEventsFilterGroupName); | |
667 | GridLayout layout = new GridLayout(3, false); | |
668 | filterMainGroup.setLayout(layout); | |
669 | GridData data = new GridData(GridData.FILL_HORIZONTAL); | |
670 | filterMainGroup.setLayoutData(data); | |
671 | ||
672 | fFilterText = new Text(filterMainGroup, SWT.LEFT); | |
673 | fFilterText.setToolTipText(Messages.TraceControl_EnableEventsFilterTooltip); | |
674 | data = new GridData(GridData.FILL_HORIZONTAL); | |
675 | fFilterText.setLayoutData(data); | |
676 | } | |
677 | } | |
678 | ||
ccc66d01 BH |
679 | // ------------------------------------------------------------------------ |
680 | // Local classes | |
681 | // ------------------------------------------------------------------------ | |
682 | /** | |
cfdb727a | 683 | * Content provider for the tracepoints tree. |
ccc66d01 | 684 | */ |
77735e82 | 685 | public static final class KernelContentProvider extends TraceControlContentProvider { |
ccc66d01 BH |
686 | @Override |
687 | public Object[] getChildren(Object parentElement) { | |
688 | if (parentElement instanceof TraceProviderGroup) { | |
689 | List<ITraceControlComponent> children = ((ITraceControlComponent)parentElement).getChildren(KernelProviderComponent.class); | |
cfdb727a | 690 | return children.toArray(new ITraceControlComponent[children.size()]); |
ccc66d01 BH |
691 | } |
692 | if (parentElement instanceof ITraceControlComponent) { | |
693 | return ((ITraceControlComponent)parentElement).getChildren(); | |
694 | } | |
695 | return new Object[0]; | |
696 | } | |
697 | } | |
cfdb727a | 698 | |
ccc66d01 | 699 | /** |
cfdb727a | 700 | * Content label for the tracepoints tree. |
ccc66d01 | 701 | */ |
77735e82 | 702 | public static final class KernelLabelProvider extends TraceControlLabelProvider { |
ccc66d01 BH |
703 | @Override |
704 | public Image getImage(Object element) { | |
705 | return null; | |
706 | } | |
707 | @Override | |
708 | public String getText(Object element) { | |
709 | if ((element != null) && (element instanceof KernelProviderComponent)) { | |
710 | return Messages.TraceControl_EnableEventsTracepointTreeAllLabel; | |
711 | } | |
712 | return super.getText(element); | |
713 | } | |
714 | } | |
cfdb727a | 715 | |
ccc66d01 | 716 | /** |
cfdb727a | 717 | * Check state listener for the tracepoints tree. |
ccc66d01 | 718 | */ |
77735e82 | 719 | public final class KernelCheckListener implements ICheckStateListener { |
ccc66d01 BH |
720 | @Override |
721 | public void checkStateChanged(CheckStateChangedEvent event) { | |
722 | if (event.getChecked()) { | |
723 | if (event.getElement() instanceof KernelProviderComponent) { | |
724 | fTracepointsViewer.setSubtreeChecked(event.getElement(), true); | |
cfdb727a AM |
725 | } |
726 | } else { | |
ccc66d01 BH |
727 | if (event.getElement() instanceof KernelProviderComponent) { |
728 | fTracepointsViewer.setSubtreeChecked(event.getElement(), false); | |
729 | } else { | |
730 | ITraceControlComponent component = (ITraceControlComponent) event.getElement(); | |
731 | fTracepointsViewer.setChecked(component.getParent(), false); | |
732 | } | |
733 | } | |
734 | } | |
735 | } | |
736 | } |