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
.LogLevelType
;
31 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceLogLevel
;
32 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.Activator
;
33 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.messages
.Messages
;
34 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceDomainComponent
;
35 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceProviderGroup
;
39 * Dialog box for collecting information events to be enabled.
42 * @author Bernd Hufmann
44 public class EnableEventsDialog
extends Dialog
implements IEnableEventsDialog
{
46 // ------------------------------------------------------------------------
48 // ------------------------------------------------------------------------
51 * The icon file for this dialog box.
53 public static final String ENABLE_EVENT_ICON_FILE
= "icons/elcl16/enable_event.gif"; //$NON-NLS-1$
55 // ------------------------------------------------------------------------
57 // ------------------------------------------------------------------------
59 * The dialog composite.
61 private Composite fDialogComposite
;
63 * The composite with widgets for collecting information about kernel events.
65 private EnableKernelEventComposite fKernelComposite
;
67 * The composite with widgets for collecting information about UST events.
69 private EnableUstEventsComposite fUstComposite
;
71 * Radio button for selecting kernel domain.
73 private Button fKernelButton
;
75 * Radio button for selecting UST domain.
77 private Button fUstButton
;
79 * The referenced trace provider group containing the kernel provider and UST
80 * provider component which contains a list of available tracepoints.
82 private TraceProviderGroup fProviderGroup
;
84 * The parent domain component where the channel node should be added.
85 * Null in case the domain is not known (i.e. on session level).
87 private TraceDomainComponent fDomain
;
89 * Output domain information. True in case of Kernel domain. False for UST.
91 private boolean fIsKernel
;
93 // ------------------------------------------------------------------------
95 // ------------------------------------------------------------------------
98 * @param shell - a shell for the display of the dialog
100 public EnableEventsDialog(Shell shell
) {
102 setShellStyle(SWT
.RESIZE
| getShellStyle());
105 // ------------------------------------------------------------------------
107 // ------------------------------------------------------------------------
110 public boolean isTracepoints() {
112 return fKernelComposite
.isTracepoints();
114 return fUstComposite
.isTracepoints();
118 public boolean isAllTracePoints() {
120 return fKernelComposite
.isAllTracePoints();
122 return fUstComposite
.isAllTracePoints();
126 public boolean isSysCalls() {
128 return fKernelComposite
.isSysCalls();
134 public boolean isAllSysCalls() {
136 return fKernelComposite
.isSysCalls();
142 public List
<String
> getEventNames() {
144 return fKernelComposite
.getEventNames();
146 return fUstComposite
.getEventNames();
150 public boolean isDynamicProbe() {
152 return fKernelComposite
.isDynamicProbe();
158 public String
getProbeName() {
160 return fKernelComposite
.getProbeName();
166 public String
getProbeEventName() {
168 return fKernelComposite
.getProbeEventName();
174 public boolean isDynamicFunctionProbe() {
176 return fKernelComposite
.isDynamicFunctionProbe();
182 public String
getFunctionEventName() {
184 return fKernelComposite
.getFunctionEventName();
190 public String
getFunction() {
192 return fKernelComposite
.getFunction();
198 public boolean isWildcard() {
200 return fUstComposite
.isWildcard();
206 public String
getWildcard() {
208 return fUstComposite
.getWildcard();
214 public boolean isLogLevel() {
216 return fUstComposite
.isLogLevel();
222 public LogLevelType
getLogLevelType() {
224 return fUstComposite
.getLogLevelType();
230 public TraceLogLevel
getLogLevel() {
232 return fUstComposite
.getLogLevel();
238 public String
getLogLevelEventName() {
240 return fUstComposite
.getLogLevelEventName();
246 public boolean isKernel() {
251 public void setTraceProviderGroup(TraceProviderGroup providerGroup
) {
252 fProviderGroup
= providerGroup
;
256 public void setTraceDomainComponent(TraceDomainComponent domain
) {
258 if (fDomain
!= null) {
259 fIsKernel
= fDomain
.isKernel();
261 fIsKernel
= fProviderGroup
!= null ? fProviderGroup
.hasKernelProvider() : true;
266 public String
getFilterExpression() {
268 return fUstComposite
.getFilterExpression();
273 // ------------------------------------------------------------------------
275 // ------------------------------------------------------------------------
278 protected void configureShell(Shell newShell
) {
279 super.configureShell(newShell
);
280 newShell
.setText(Messages
.TraceControl_EnableEventsDialogTitle
);
281 newShell
.setImage(Activator
.getDefault().loadIcon(ENABLE_EVENT_ICON_FILE
));
285 protected Control
createDialogArea(Composite parent
) {
288 fDialogComposite
= new Composite(parent
, SWT
.NONE
);
289 GridLayout layout
= new GridLayout(1, true);
290 fDialogComposite
.setLayout(layout
);
291 fDialogComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
293 // ------------------------------------------------------------------------
295 // ------------------------------------------------------------------------
296 Group domainGroup
= new Group(fDialogComposite
, SWT
.SHADOW_NONE
);
297 domainGroup
.setText(Messages
.TraceControl_DomainDisplayName
);
298 layout
= new GridLayout(2, true);
299 domainGroup
.setLayout(layout
);
301 fKernelButton
= new Button(domainGroup
, SWT
.RADIO
);
302 fKernelButton
.setText(Messages
.TraceControl_KernelDomainDisplayName
);
303 fKernelButton
.setSelection(fIsKernel
);
304 fUstButton
= new Button(domainGroup
, SWT
.RADIO
);
305 fUstButton
.setText(Messages
.TraceControl_UstDisplayName
);
306 fUstButton
.setSelection(!fIsKernel
);
308 if ((fDomain
!= null) || ((fProviderGroup
!= null) && (!fProviderGroup
.hasKernelProvider()))) {
309 fKernelButton
.setEnabled(false);
310 fUstButton
.setEnabled(false);
314 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
315 domainGroup
.setLayoutData(data
);
317 data
= new GridData(SWT
.BEGINNING
, SWT
.BEGINNING
, true, true);
318 fKernelButton
.setLayoutData(data
);
319 data
= new GridData(SWT
.BEGINNING
, SWT
.BEGINNING
, true, true);
320 fUstButton
.setLayoutData(data
);
322 // ------------------------------------------------------------------------
323 // Kernel or UST event data group
324 // ------------------------------------------------------------------------
325 fUstComposite
= null;
326 fKernelComposite
= null;
328 createKernelComposite();
329 fUstComposite
= null;
331 createUstComposite();
334 fKernelButton
.addSelectionListener(new SelectionAdapter() {
336 public void widgetSelected(SelectionEvent e
) {
337 if (fKernelButton
.getSelection()) {
338 disposeUstComposite();
339 createKernelComposite();
340 fDialogComposite
.layout();
345 fUstButton
.addSelectionListener(new SelectionAdapter() {
347 public void widgetSelected(SelectionEvent e
) {
348 if (fUstButton
.getSelection()) {
349 disposeKernelComposite();
350 createUstComposite();
351 fDialogComposite
.layout();
356 getShell().setMinimumSize(new Point(500, 650));
358 return fDialogComposite
;
362 protected void createButtonsForButtonBar(Composite parent
) {
363 createButton(parent
, IDialogConstants
.CANCEL_ID
, "&Cancel", true); //$NON-NLS-1$
364 createButton(parent
, IDialogConstants
.OK_ID
, "&Ok", true); //$NON-NLS-1$
368 protected void okPressed() {
369 fIsKernel
= fKernelButton
.getSelection();
371 // Validate kernel composite in case of kernel domain
372 if (fKernelComposite
!= null && !fKernelComposite
.isValid()) {
376 // Validate UST composite in case of UST domain
377 if (fUstComposite
!= null && !fUstComposite
.isValid()) {
381 // validation successful -> call super.okPressed()
385 // ------------------------------------------------------------------------
387 // ------------------------------------------------------------------------
390 * Creates the kernel composite (if not existing)
392 private void createKernelComposite() {
393 if (fKernelComposite
== null) {
394 fKernelComposite
= new EnableKernelEventComposite(fDialogComposite
, SWT
.NONE
, fProviderGroup
);
395 GridLayout layout
= new GridLayout(1, true);
396 fKernelComposite
.setLayout(layout
);
397 fKernelComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
399 fKernelComposite
.createContent();
404 * Disposes the kernel composite (if existing)
406 private void disposeKernelComposite() {
407 if (fKernelComposite
!= null) {
408 fKernelComposite
.dispose();
409 fKernelComposite
= null;
414 * Creates the UST composite (if not existing)
416 private void createUstComposite() {
417 if (fUstComposite
== null) {
418 fUstComposite
= new EnableUstEventsComposite(fDialogComposite
, SWT
.NONE
, fProviderGroup
);
419 GridLayout layout
= new GridLayout(1, true);
420 fUstComposite
.setLayout(layout
);
421 fUstComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
423 fUstComposite
.createContent();
428 * Disposes the UST composite (if existing)
430 private void disposeUstComposite() {
431 if (fUstComposite
!= null) {
432 fUstComposite
.dispose();
433 fUstComposite
= null;