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