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