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 // ------------------------------------------------------------------------
109 public boolean isAllEvents() {
111 return fKernelComposite
.isAllEvents();
117 public boolean isTracepoints() {
119 return fKernelComposite
.isTracepoints();
121 return fUstComposite
.isTracepoints();
125 public boolean isAllTracePoints() {
127 return fKernelComposite
.isAllTracePoints();
129 return fUstComposite
.isAllTracePoints();
133 public boolean isSysCalls() {
135 return fKernelComposite
.isSysCalls();
141 public boolean isAllSysCalls() {
143 return fKernelComposite
.isSysCalls();
149 public List
<String
> getEventNames() {
151 return fKernelComposite
.getEventNames();
153 return fUstComposite
.getEventNames();
157 public boolean isDynamicProbe() {
159 return fKernelComposite
.isDynamicProbe();
165 public String
getProbeName() {
167 return fKernelComposite
.getProbeName();
173 public String
getProbeEventName() {
175 return fKernelComposite
.getProbeEventName();
181 public boolean isDynamicFunctionProbe() {
183 return fKernelComposite
.isDynamicFunctionProbe();
189 public String
getFunctionEventName() {
191 return fKernelComposite
.getFunctionEventName();
197 public String
getFunction() {
199 return fKernelComposite
.getFunction();
205 public boolean isWildcard() {
207 return fUstComposite
.isWildcard();
213 public String
getWildcard() {
215 return fUstComposite
.getWildcard();
221 public boolean isLogLevel() {
223 return fUstComposite
.isLogLevel();
229 public LogLevelType
getLogLevelType() {
231 return fUstComposite
.getLogLevelType();
237 public TraceLogLevel
getLogLevel() {
239 return fUstComposite
.getLogLevel();
245 public String
getLogLevelEventName() {
247 return fUstComposite
.getLogLevelEventName();
253 public boolean isKernel() {
258 public void setTraceProviderGroup(TraceProviderGroup providerGroup
) {
259 fProviderGroup
= providerGroup
;
263 public void setTraceDomainComponent(TraceDomainComponent domain
) {
265 if (fDomain
!= null) {
266 fIsKernel
= fDomain
.isKernel();
268 fIsKernel
= fProviderGroup
!= null ? fProviderGroup
.hasKernelProvider() : true;
273 public String
getFilterExpression() {
275 return fKernelComposite
.getFilterExpression();
277 return fUstComposite
.getFilterExpression();
280 // ------------------------------------------------------------------------
282 // ------------------------------------------------------------------------
285 protected void configureShell(Shell newShell
) {
286 super.configureShell(newShell
);
287 newShell
.setText(Messages
.TraceControl_EnableEventsDialogTitle
);
288 newShell
.setImage(Activator
.getDefault().loadIcon(ENABLE_EVENT_ICON_FILE
));
292 protected Control
createDialogArea(Composite parent
) {
295 fDialogComposite
= new Composite(parent
, SWT
.NONE
);
296 GridLayout layout
= new GridLayout(1, true);
297 fDialogComposite
.setLayout(layout
);
298 fDialogComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
300 // ------------------------------------------------------------------------
302 // ------------------------------------------------------------------------
303 Group domainGroup
= new Group(fDialogComposite
, SWT
.SHADOW_NONE
);
304 domainGroup
.setText(Messages
.TraceControl_DomainDisplayName
);
305 layout
= new GridLayout(2, true);
306 domainGroup
.setLayout(layout
);
308 fKernelButton
= new Button(domainGroup
, SWT
.RADIO
);
309 fKernelButton
.setText(Messages
.TraceControl_KernelDomainDisplayName
);
310 fKernelButton
.setSelection(fIsKernel
);
311 fUstButton
= new Button(domainGroup
, SWT
.RADIO
);
312 fUstButton
.setText(Messages
.TraceControl_UstDisplayName
);
313 fUstButton
.setSelection(!fIsKernel
);
315 if ((fDomain
!= null) || ((fProviderGroup
!= null) && (!fProviderGroup
.hasKernelProvider()))) {
316 fKernelButton
.setEnabled(false);
317 fUstButton
.setEnabled(false);
321 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
322 domainGroup
.setLayoutData(data
);
324 data
= new GridData(SWT
.BEGINNING
, SWT
.BEGINNING
, true, true);
325 fKernelButton
.setLayoutData(data
);
326 data
= new GridData(SWT
.BEGINNING
, SWT
.BEGINNING
, true, true);
327 fUstButton
.setLayoutData(data
);
329 // ------------------------------------------------------------------------
330 // Kernel or UST event data group
331 // ------------------------------------------------------------------------
332 fUstComposite
= null;
333 fKernelComposite
= null;
335 createKernelComposite();
336 fUstComposite
= null;
338 createUstComposite();
341 fKernelButton
.addSelectionListener(new SelectionAdapter() {
343 public void widgetSelected(SelectionEvent e
) {
344 if (fKernelButton
.getSelection()) {
345 disposeUstComposite();
346 createKernelComposite();
347 fDialogComposite
.layout();
352 fUstButton
.addSelectionListener(new SelectionAdapter() {
354 public void widgetSelected(SelectionEvent e
) {
355 if (fUstButton
.getSelection()) {
356 disposeKernelComposite();
357 createUstComposite();
358 fDialogComposite
.layout();
363 getShell().setMinimumSize(new Point(550, 750));
365 return fDialogComposite
;
369 protected void createButtonsForButtonBar(Composite parent
) {
370 createButton(parent
, IDialogConstants
.CANCEL_ID
, "&Cancel", true); //$NON-NLS-1$
371 createButton(parent
, IDialogConstants
.OK_ID
, "&Ok", true); //$NON-NLS-1$
375 protected void okPressed() {
376 fIsKernel
= fKernelButton
.getSelection();
378 // Validate kernel composite in case of kernel domain
379 if (fKernelComposite
!= null && !fKernelComposite
.isValid()) {
383 // Validate UST composite in case of UST domain
384 if (fUstComposite
!= null && !fUstComposite
.isValid()) {
388 // validation successful -> call super.okPressed()
392 // ------------------------------------------------------------------------
394 // ------------------------------------------------------------------------
397 * Creates the kernel composite (if not existing)
399 private void createKernelComposite() {
400 if (fKernelComposite
== null) {
401 fKernelComposite
= new EnableKernelEventComposite(fDialogComposite
, SWT
.NONE
, fProviderGroup
);
402 GridLayout layout
= new GridLayout(1, true);
403 fKernelComposite
.setLayout(layout
);
404 fKernelComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
406 fKernelComposite
.createContent();
411 * Disposes the kernel composite (if existing)
413 private void disposeKernelComposite() {
414 if (fKernelComposite
!= null) {
415 fKernelComposite
.dispose();
416 fKernelComposite
= null;
421 * Creates the UST composite (if not existing)
423 private void createUstComposite() {
424 if (fUstComposite
== null) {
425 fUstComposite
= new EnableUstEventsComposite(fDialogComposite
, SWT
.NONE
, fProviderGroup
);
426 GridLayout layout
= new GridLayout(1, true);
427 fUstComposite
.setLayout(layout
);
428 fUstComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
430 fUstComposite
.createContent();
435 * Disposes the UST composite (if existing)
437 private void disposeUstComposite() {
438 if (fUstComposite
!= null) {
439 fUstComposite
.dispose();
440 fUstComposite
= null;