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