1 /**********************************************************************
2 * Copyright (c) 2012, 2014 Ericsson
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
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
;
15 import java
.util
.List
;
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
;
40 * Dialog box for collecting information events to be enabled.
43 * @author Bernd Hufmann
45 public class EnableEventsDialog
extends Dialog
implements IEnableEventsDialog
{
47 // ------------------------------------------------------------------------
49 // ------------------------------------------------------------------------
52 * The icon file for this dialog box.
54 public static final String ENABLE_EVENT_ICON_FILE
= "icons/elcl16/enable_event.gif"; //$NON-NLS-1$
56 // ------------------------------------------------------------------------
58 // ------------------------------------------------------------------------
60 * The dialog composite.
62 private Composite fDialogComposite
;
64 * The composite with widgets for collecting information about kernel events.
66 private EnableKernelEventComposite fKernelComposite
;
68 * The composite with widgets for collecting information about UST events.
70 private EnableUstEventsComposite fUstComposite
;
72 * The composite with widgets for collecting information about JUL events.
74 private EnableJulEventsComposite fJulComposite
;
76 * Radio button for selecting kernel domain.
78 private Button fKernelButton
;
80 * Radio button for selecting UST domain.
82 private Button fUstButton
;
84 * Radio button for selecting JUL domain.
86 private Button fJulButton
;
88 * The referenced trace provider group containing the kernel provider and UST
89 * provider component which contains a list of available tracepoints.
91 private TraceProviderGroup fProviderGroup
;
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).
96 private TraceDomainComponent fDomainComponent
;
98 * The domain type ({@link TraceDomainType})
100 private TraceDomainType fDomain
;
103 // ------------------------------------------------------------------------
105 // ------------------------------------------------------------------------
108 * @param shell - a shell for the display of the dialog
110 public EnableEventsDialog(Shell shell
) {
112 setShellStyle(SWT
.RESIZE
| getShellStyle());
115 // ------------------------------------------------------------------------
117 // ------------------------------------------------------------------------
119 public boolean isAllEvents() {
122 return fKernelComposite
.isAllEvents();
124 return fJulComposite
.isAllTracePoints();
126 return fUstComposite
.isAllTracePoints();
136 public boolean isTracepoints() {
139 // Loggers are always TRACEPOINT
142 return fKernelComposite
.isTracepoints();
144 return fUstComposite
.isTracepoints();
154 public boolean isAllTracePoints() {
157 return fKernelComposite
.isAllTracePoints();
159 return fUstComposite
.isAllTracePoints();
161 return fJulComposite
.isAllTracePoints();
171 public boolean isSyscalls() {
172 if (fDomain
.equals(TraceDomainType
.KERNEL
)) {
173 return fKernelComposite
.isSyscalls();
179 public boolean isAllSyscalls() {
180 if (fDomain
.equals(TraceDomainType
.KERNEL
)) {
181 return fKernelComposite
.isAllSyscalls();
187 public List
<String
> getEventNames() {
190 return fJulComposite
.getEventNames();
192 return fKernelComposite
.getEventNames();
194 return fUstComposite
.getEventNames();
204 public boolean isDynamicProbe() {
205 if (fDomain
.equals(TraceDomainType
.KERNEL
)) {
206 return fKernelComposite
.isDynamicProbe();
212 public String
getProbeName() {
213 if (fDomain
.equals(TraceDomainType
.KERNEL
)) {
214 return fKernelComposite
.getProbeName();
220 public String
getProbeEventName() {
221 if (fDomain
.equals(TraceDomainType
.KERNEL
)) {
222 return fKernelComposite
.getProbeEventName();
228 public boolean isDynamicFunctionProbe() {
229 if (fDomain
.equals(TraceDomainType
.KERNEL
)) {
230 return fKernelComposite
.isDynamicFunctionProbe();
236 public String
getFunctionEventName() {
237 if (fDomain
.equals(TraceDomainType
.KERNEL
)) {
238 return fKernelComposite
.getFunctionEventName();
244 public String
getFunction() {
245 if (fDomain
.equals(TraceDomainType
.KERNEL
)) {
246 return fKernelComposite
.getFunction();
252 public boolean isWildcard() {
253 if (fDomain
.equals(TraceDomainType
.UST
)) {
254 return fUstComposite
.isWildcard();
260 public String
getWildcard() {
261 if (fDomain
.equals(TraceDomainType
.UST
)) {
262 return fUstComposite
.getWildcard();
268 public boolean isLogLevel() {
271 return fJulComposite
.isLogLevel();
275 return fUstComposite
.isLogLevel();
285 public LogLevelType
getLogLevelType() {
288 return fJulComposite
.getLogLevelType();
292 return fUstComposite
.getLogLevelType();
302 public ITraceLogLevel
getLogLevel() {
305 return fJulComposite
.getLogLevel();
309 return fUstComposite
.getLogLevel();
319 public TraceDomainType
getDomain() {
324 public void setTraceProviderGroup(TraceProviderGroup providerGroup
) {
325 fProviderGroup
= providerGroup
;
329 public void setTraceDomainComponent(TraceDomainComponent domain
) {
330 fDomainComponent
= domain
;
331 if (fDomainComponent
!= null) {
332 fDomain
= fDomainComponent
.getDomain();
334 if (fProviderGroup
!= null) {
335 fDomain
= fProviderGroup
.hasKernelProvider() ? TraceDomainType
.KERNEL
: TraceDomainType
.UST
;
341 public String
getFilterExpression() {
345 return fKernelComposite
.getFilterExpression();
347 return fUstComposite
.getFilterExpression();
358 public List
<String
> getExcludedEvents() {
359 if (fDomain
.equals(TraceDomainType
.UST
)) {
360 return fUstComposite
.getExcludedEvents();
365 // ------------------------------------------------------------------------
367 // ------------------------------------------------------------------------
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
));
377 protected Control
createDialogArea(Composite parent
) {
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
));
385 // ------------------------------------------------------------------------
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
);
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
);
402 fKernelButton
.setSelection(true);
405 fUstButton
.setSelection(true);
408 fJulButton
.setSelection(true);
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);
428 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
429 domainGroup
.setLayoutData(data
);
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
);
436 // ------------------------------------------------------------------------
438 // ------------------------------------------------------------------------
439 fUstComposite
= null;
440 fKernelComposite
= null;
441 fJulComposite
= null;
445 createKernelComposite();
448 createUstComposite();
451 createJulComposite();
460 fKernelButton
.addSelectionListener(new SelectionAdapter() {
462 public void widgetSelected(SelectionEvent e
) {
463 if (fKernelButton
.getSelection()) {
464 disposeAllComposite();
465 createKernelComposite();
466 fDialogComposite
.layout();
471 fUstButton
.addSelectionListener(new SelectionAdapter() {
473 public void widgetSelected(SelectionEvent e
) {
474 if (fUstButton
.getSelection()) {
475 disposeAllComposite();
476 createUstComposite();
477 fDialogComposite
.layout();
482 fJulButton
.addSelectionListener(new SelectionAdapter() {
484 public void widgetSelected(SelectionEvent e
) {
485 if (fJulButton
.getSelection()) {
486 disposeAllComposite();
487 createJulComposite();
488 fDialogComposite
.layout();
494 getShell().setMinimumSize(new Point(550, 850));
496 return fDialogComposite
;
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$
506 protected void okPressed() {
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
;
516 // Validate kernel composite in case of kernel domain
517 if (fKernelComposite
!= null && !fKernelComposite
.isValid()) {
521 // Validate UST composite in case of UST domain
522 if (fUstComposite
!= null && !fUstComposite
.isValid()) {
526 // Validate JUL composite in case of JUL domain
527 if (fJulComposite
!= null && !fJulComposite
.isValid()) {
531 // validation successful -> call super.okPressed()
535 // ------------------------------------------------------------------------
537 // ------------------------------------------------------------------------
540 * Disposes all composites (if existing)
542 private void disposeAllComposite() {
543 disposeKernelComposite();
544 disposeUstComposite();
545 disposeJulComposite();
549 * Creates the kernel composite (if not existing)
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
));
558 fKernelComposite
.createContent();
563 * Disposes the kernel composite (if existing)
565 private void disposeKernelComposite() {
566 if (fKernelComposite
!= null) {
567 fKernelComposite
.dispose();
568 fKernelComposite
= null;
573 * Creates the UST composite (if not existing)
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
));
582 fUstComposite
.createContent();
587 * Disposes the UST composite (if existing)
589 private void disposeUstComposite() {
590 if (fUstComposite
!= null) {
591 fUstComposite
.dispose();
592 fUstComposite
= null;
598 * Creates the JUL composite (if not existing)
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
));
607 fJulComposite
.createContent();
612 * Disposes the JUL composite (if existing)
614 private void disposeJulComposite() {
615 if (fJulComposite
!= null) {
616 fJulComposite
.dispose();
617 fJulComposite
= null;