lttng.control: Add support for enabling syscall by name
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui / src / org / eclipse / tracecompass / internal / lttng2 / control / ui / views / dialogs / EnableEventsDialog.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 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
12 **********************************************************************/
13 package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs;
14
15 import java.util.List;
16
17 import org.eclipse.jface.dialogs.Dialog;
18 import org.eclipse.jface.dialogs.IDialogConstants;
19 import org.eclipse.swt.SWT;
20 import org.eclipse.swt.events.SelectionAdapter;
21 import org.eclipse.swt.events.SelectionEvent;
22 import org.eclipse.swt.graphics.Point;
23 import org.eclipse.swt.layout.GridData;
24 import org.eclipse.swt.layout.GridLayout;
25 import org.eclipse.swt.widgets.Button;
26 import org.eclipse.swt.widgets.Composite;
27 import org.eclipse.swt.widgets.Control;
28 import org.eclipse.swt.widgets.Group;
29 import org.eclipse.swt.widgets.Shell;
30 import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceDomainType;
31 import org.eclipse.tracecompass.internal.lttng2.control.core.model.ITraceLogLevel;
32 import org.eclipse.tracecompass.internal.lttng2.control.core.model.LogLevelType;
33 import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
34 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
35 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceDomainComponent;
36 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceProviderGroup;
37
38 /**
39 * <p>
40 * Dialog box for collecting information events to be enabled.
41 * </p>
42 *
43 * @author Bernd Hufmann
44 */
45 public class EnableEventsDialog extends Dialog implements IEnableEventsDialog {
46
47 // ------------------------------------------------------------------------
48 // Constants
49 // ------------------------------------------------------------------------
50
51 /**
52 * The icon file for this dialog box.
53 */
54 public static final String ENABLE_EVENT_ICON_FILE = "icons/elcl16/enable_event.gif"; //$NON-NLS-1$
55
56 // ------------------------------------------------------------------------
57 // Attributes
58 // ------------------------------------------------------------------------
59 /**
60 * The dialog composite.
61 */
62 private Composite fDialogComposite;
63 /**
64 * The composite with widgets for collecting information about kernel events.
65 */
66 private EnableKernelEventComposite fKernelComposite;
67 /**
68 * The composite with widgets for collecting information about UST events.
69 */
70 private EnableUstEventsComposite fUstComposite;
71 /**
72 * The composite with widgets for collecting information about JUL events.
73 */
74 private EnableJulEventsComposite fJulComposite;
75 /**
76 * Radio button for selecting kernel domain.
77 */
78 private Button fKernelButton;
79 /**
80 * Radio button for selecting UST domain.
81 */
82 private Button fUstButton;
83 /**
84 * Radio button for selecting JUL domain.
85 */
86 private Button fJulButton;
87 /**
88 * The referenced trace provider group containing the kernel provider and UST
89 * provider component which contains a list of available tracepoints.
90 */
91 private TraceProviderGroup fProviderGroup;
92 /**
93 * The parent domain component where the channel node should be added.
94 * Null in case the domain is not known (i.e. on session level).
95 */
96 private TraceDomainComponent fDomainComponent;
97 /**
98 * The domain type ({@link TraceDomainType})
99 */
100 private TraceDomainType fDomain;
101
102
103 // ------------------------------------------------------------------------
104 // Constructors
105 // ------------------------------------------------------------------------
106 /**
107 * Constructor
108 * @param shell - a shell for the display of the dialog
109 */
110 public EnableEventsDialog(Shell shell) {
111 super(shell);
112 setShellStyle(SWT.RESIZE | getShellStyle());
113 }
114
115 // ------------------------------------------------------------------------
116 // Accessors
117 // ------------------------------------------------------------------------
118 @Override
119 public boolean isAllEvents() {
120 switch (fDomain) {
121 case KERNEL:
122 return fKernelComposite.isAllEvents();
123 case JUL:
124 return fJulComposite.isAllTracePoints();
125 case UST:
126 return fUstComposite.isAllTracePoints();
127 case LOG4J:
128 case PYTHON:
129 case UNKNOWN:
130 default:
131 return false;
132 }
133 }
134
135 @Override
136 public boolean isTracepoints() {
137 switch (fDomain) {
138 case JUL:
139 // Loggers are always TRACEPOINT
140 return true;
141 case KERNEL:
142 return fKernelComposite.isTracepoints();
143 case UST:
144 return fUstComposite.isTracepoints();
145 case LOG4J:
146 case PYTHON:
147 case UNKNOWN:
148 default:
149 return false;
150 }
151 }
152
153 @Override
154 public boolean isAllTracePoints() {
155 switch (fDomain) {
156 case KERNEL:
157 return fKernelComposite.isAllTracePoints();
158 case UST:
159 return fUstComposite.isAllTracePoints();
160 case JUL:
161 return fJulComposite.isAllTracePoints();
162 case LOG4J:
163 case PYTHON:
164 case UNKNOWN:
165 default:
166 return false;
167 }
168 }
169
170 @Override
171 public boolean isSyscalls() {
172 if (fDomain.equals(TraceDomainType.KERNEL)) {
173 return fKernelComposite.isSyscalls();
174 }
175 return false;
176 }
177
178 @Override
179 public boolean isAllSyscalls() {
180 if (fDomain.equals(TraceDomainType.KERNEL)) {
181 return fKernelComposite.isAllSyscalls();
182 }
183 return false;
184 }
185
186 @Override
187 public List<String> getEventNames() {
188 switch (fDomain) {
189 case JUL:
190 return fJulComposite.getEventNames();
191 case KERNEL:
192 return fKernelComposite.getEventNames();
193 case UST:
194 return fUstComposite.getEventNames();
195 case LOG4J:
196 case PYTHON:
197 case UNKNOWN:
198 default:
199 return null;
200 }
201 }
202
203 @Override
204 public boolean isDynamicProbe() {
205 if (fDomain.equals(TraceDomainType.KERNEL)) {
206 return fKernelComposite.isDynamicProbe();
207 }
208 return false;
209 }
210
211 @Override
212 public String getProbeName() {
213 if (fDomain.equals(TraceDomainType.KERNEL)) {
214 return fKernelComposite.getProbeName();
215 }
216 return null;
217 }
218
219 @Override
220 public String getProbeEventName() {
221 if (fDomain.equals(TraceDomainType.KERNEL)) {
222 return fKernelComposite.getProbeEventName();
223 }
224 return null;
225 }
226
227 @Override
228 public boolean isDynamicFunctionProbe() {
229 if (fDomain.equals(TraceDomainType.KERNEL)) {
230 return fKernelComposite.isDynamicFunctionProbe();
231 }
232 return false;
233 }
234
235 @Override
236 public String getFunctionEventName() {
237 if (fDomain.equals(TraceDomainType.KERNEL)) {
238 return fKernelComposite.getFunctionEventName();
239 }
240 return null;
241 }
242
243 @Override
244 public String getFunction() {
245 if (fDomain.equals(TraceDomainType.KERNEL)) {
246 return fKernelComposite.getFunction();
247 }
248 return null;
249 }
250
251 @Override
252 public boolean isWildcard() {
253 if (fDomain.equals(TraceDomainType.UST)) {
254 return fUstComposite.isWildcard();
255 }
256 return false;
257 }
258
259 @Override
260 public String getWildcard() {
261 if (fDomain.equals(TraceDomainType.UST)) {
262 return fUstComposite.getWildcard();
263 }
264 return null;
265 }
266
267 @Override
268 public boolean isLogLevel() {
269 switch (fDomain) {
270 case JUL:
271 return fJulComposite.isLogLevel();
272 case KERNEL:
273 return false;
274 case UST:
275 return fUstComposite.isLogLevel();
276 case LOG4J:
277 case PYTHON:
278 case UNKNOWN:
279 default:
280 return false;
281 }
282 }
283
284 @Override
285 public LogLevelType getLogLevelType() {
286 switch (fDomain) {
287 case JUL:
288 return fJulComposite.getLogLevelType();
289 case KERNEL:
290 return null;
291 case UST:
292 return fUstComposite.getLogLevelType();
293 case LOG4J:
294 case PYTHON:
295 case UNKNOWN:
296 default:
297 return null;
298 }
299 }
300
301 @Override
302 public ITraceLogLevel getLogLevel() {
303 switch (fDomain) {
304 case JUL:
305 return fJulComposite.getLogLevel();
306 case KERNEL:
307 return null;
308 case UST:
309 return fUstComposite.getLogLevel();
310 case LOG4J:
311 case PYTHON:
312 case UNKNOWN:
313 default:
314 return null;
315 }
316 }
317
318 @Override
319 public TraceDomainType getDomain() {
320 return fDomain;
321 }
322
323 @Override
324 public void setTraceProviderGroup(TraceProviderGroup providerGroup) {
325 fProviderGroup = providerGroup;
326 }
327
328 @Override
329 public void setTraceDomainComponent(TraceDomainComponent domain) {
330 fDomainComponent = domain;
331 if (fDomainComponent != null) {
332 fDomain = fDomainComponent.getDomain();
333 } else {
334 if (fProviderGroup != null) {
335 fDomain = fProviderGroup.hasKernelProvider() ? TraceDomainType.KERNEL : TraceDomainType.UST;
336 }
337 }
338 }
339
340 @Override
341 public String getFilterExpression() {
342
343 switch (fDomain) {
344 case KERNEL:
345 return fKernelComposite.getFilterExpression();
346 case UST:
347 return fUstComposite.getFilterExpression();
348 case JUL:
349 case LOG4J:
350 case PYTHON:
351 case UNKNOWN:
352 default:
353 return null;
354 }
355 }
356
357 @Override
358 public List<String> getExcludedEvents() {
359 if (fDomain.equals(TraceDomainType.UST)) {
360 return fUstComposite.getExcludedEvents();
361 }
362 return null;
363 }
364
365 // ------------------------------------------------------------------------
366 // Operations
367 // ------------------------------------------------------------------------
368
369 @Override
370 protected void configureShell(Shell newShell) {
371 super.configureShell(newShell);
372 newShell.setText(Messages.TraceControl_EnableEventsDialogTitle);
373 newShell.setImage(Activator.getDefault().loadIcon(ENABLE_EVENT_ICON_FILE));
374 }
375
376 @Override
377 protected Control createDialogArea(Composite parent) {
378
379 // Main dialog panel
380 fDialogComposite = new Composite(parent, SWT.NONE);
381 GridLayout layout = new GridLayout(1, true);
382 fDialogComposite.setLayout(layout);
383 fDialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
384
385 // ------------------------------------------------------------------------
386 // Domain Group
387 // ------------------------------------------------------------------------
388 Group domainGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
389 domainGroup.setText(Messages.TraceControl_DomainDisplayName);
390 layout = new GridLayout(3, true);
391 domainGroup.setLayout(layout);
392
393 fKernelButton = new Button(domainGroup, SWT.RADIO);
394 fKernelButton.setText(Messages.TraceControl_KernelDomainDisplayName);
395 fUstButton = new Button(domainGroup, SWT.RADIO);
396 fUstButton.setText(Messages.TraceControl_UstDisplayName);
397 fJulButton = new Button(domainGroup, SWT.RADIO);
398 fJulButton.setText(Messages.TraceControl_JULDomainDisplayName);
399
400 switch (fDomain) {
401 case KERNEL:
402 fKernelButton.setSelection(true);
403 break;
404 case UST:
405 fUstButton.setSelection(true);
406 break;
407 case JUL:
408 fJulButton.setSelection(true);
409 break;
410 case LOG4J:
411 case PYTHON:
412 case UNKNOWN:
413 default:
414 break;
415 }
416
417 if (fDomainComponent != null) {
418 fKernelButton.setEnabled(false);
419 fUstButton.setEnabled(false);
420 fJulButton.setEnabled(false);
421 } else if ((fProviderGroup != null) && (!fProviderGroup.hasKernelProvider())) {
422 fKernelButton.setEnabled(false);
423 fUstButton.setEnabled(true);
424 fJulButton.setEnabled(true);
425 }
426
427 // layout widgets
428 GridData data = new GridData(GridData.FILL_HORIZONTAL);
429 domainGroup.setLayoutData(data);
430
431 data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
432 fKernelButton.setLayoutData(data);
433 data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true);
434 fUstButton.setLayoutData(data);
435
436 // ------------------------------------------------------------------------
437 // Domain data group
438 // ------------------------------------------------------------------------
439 fUstComposite = null;
440 fKernelComposite = null;
441 fJulComposite = null;
442
443 switch (fDomain) {
444 case KERNEL:
445 createKernelComposite();
446 break;
447 case UST:
448 createUstComposite();
449 break;
450 case JUL:
451 createJulComposite();
452 break;
453 case LOG4J:
454 case PYTHON:
455 case UNKNOWN:
456 default:
457 break;
458 }
459
460 fKernelButton.addSelectionListener(new SelectionAdapter() {
461 @Override
462 public void widgetSelected(SelectionEvent e) {
463 if (fKernelButton.getSelection()) {
464 disposeAllComposite();
465 createKernelComposite();
466 fDialogComposite.layout();
467 }
468 }
469 });
470
471 fUstButton.addSelectionListener(new SelectionAdapter() {
472 @Override
473 public void widgetSelected(SelectionEvent e) {
474 if (fUstButton.getSelection()) {
475 disposeAllComposite();
476 createUstComposite();
477 fDialogComposite.layout();
478 }
479 }
480 });
481
482 fJulButton.addSelectionListener(new SelectionAdapter() {
483 @Override
484 public void widgetSelected(SelectionEvent e) {
485 if (fJulButton.getSelection()) {
486 disposeAllComposite();
487 createJulComposite();
488 fDialogComposite.layout();
489 }
490 }
491 });
492
493
494 getShell().setMinimumSize(new Point(550, 850));
495
496 return fDialogComposite;
497 }
498
499 @Override
500 protected void createButtonsForButtonBar(Composite parent) {
501 createButton(parent, IDialogConstants.CANCEL_ID, "&Cancel", true); //$NON-NLS-1$
502 createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$
503 }
504
505 @Override
506 protected void okPressed() {
507
508 if (fKernelButton.getSelection()) {
509 fDomain = TraceDomainType.KERNEL;
510 } else if (fUstButton.getSelection()){
511 fDomain = TraceDomainType.UST;
512 } else if (fJulButton.getSelection()) {
513 fDomain = TraceDomainType.JUL;
514 }
515
516 // Validate kernel composite in case of kernel domain
517 if (fKernelComposite != null && !fKernelComposite.isValid()) {
518 return;
519 }
520
521 // Validate UST composite in case of UST domain
522 if (fUstComposite != null && !fUstComposite.isValid()) {
523 return;
524 }
525
526 // Validate JUL composite in case of JUL domain
527 if (fJulComposite != null && !fJulComposite.isValid()) {
528 return;
529 }
530
531 // validation successful -> call super.okPressed()
532 super.okPressed();
533 }
534
535 // ------------------------------------------------------------------------
536 // Helper methods
537 // ------------------------------------------------------------------------
538
539 /**
540 * Disposes all composites (if existing)
541 */
542 private void disposeAllComposite() {
543 disposeKernelComposite();
544 disposeUstComposite();
545 disposeJulComposite();
546 }
547
548 /**
549 * Creates the kernel composite (if not existing)
550 */
551 private void createKernelComposite() {
552 if (fKernelComposite == null) {
553 fKernelComposite = new EnableKernelEventComposite(fDialogComposite, SWT.NONE, fProviderGroup);
554 GridLayout layout = new GridLayout(1, true);
555 fKernelComposite.setLayout(layout);
556 fKernelComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
557
558 fKernelComposite.createContent();
559 }
560 }
561
562 /**
563 * Disposes the kernel composite (if existing)
564 */
565 private void disposeKernelComposite() {
566 if (fKernelComposite != null) {
567 fKernelComposite.dispose();
568 fKernelComposite = null;
569 }
570 }
571
572 /**
573 * Creates the UST composite (if not existing)
574 */
575 private void createUstComposite() {
576 if (fUstComposite == null) {
577 fUstComposite = new EnableUstEventsComposite(fDialogComposite, SWT.NONE, fProviderGroup);
578 GridLayout layout = new GridLayout(1, true);
579 fUstComposite.setLayout(layout);
580 fUstComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
581
582 fUstComposite.createContent();
583 }
584 }
585
586 /**
587 * Disposes the UST composite (if existing)
588 */
589 private void disposeUstComposite() {
590 if (fUstComposite != null) {
591 fUstComposite.dispose();
592 fUstComposite = null;
593 }
594 }
595
596
597 /**
598 * Creates the JUL composite (if not existing)
599 */
600 private void createJulComposite() {
601 if (fJulComposite == null) {
602 fJulComposite = new EnableJulEventsComposite(fDialogComposite, SWT.NONE, fProviderGroup);
603 GridLayout layout = new GridLayout(1, true);
604 fJulComposite.setLayout(layout);
605 fJulComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
606
607 fJulComposite.createContent();
608 }
609 }
610
611 /**
612 * Disposes the JUL composite (if existing)
613 */
614 private void disposeJulComposite() {
615 if (fJulComposite != null) {
616 fJulComposite.dispose();
617 fJulComposite = null;
618 }
619 }
620
621 }
This page took 0.044905 seconds and 5 git commands to generate.