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