1 /**********************************************************************
2 * Copyright (c) 2012, 2013 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
.linuxtools
.internal
.lttng2
.ui
.views
.control
.dialogs
;
15 import java
.util
.List
;
17 import org
.eclipse
.jface
.dialogs
.Dialog
;
18 import org
.eclipse
.jface
.dialogs
.IDialogConstants
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.LogLevelType
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceLogLevel
;
21 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.Activator
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.messages
.Messages
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceDomainComponent
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceProviderGroup
;
25 import org
.eclipse
.swt
.SWT
;
26 import org
.eclipse
.swt
.events
.SelectionAdapter
;
27 import org
.eclipse
.swt
.events
.SelectionEvent
;
28 import org
.eclipse
.swt
.graphics
.Point
;
29 import org
.eclipse
.swt
.layout
.GridData
;
30 import org
.eclipse
.swt
.layout
.GridLayout
;
31 import org
.eclipse
.swt
.widgets
.Button
;
32 import org
.eclipse
.swt
.widgets
.Composite
;
33 import org
.eclipse
.swt
.widgets
.Control
;
34 import org
.eclipse
.swt
.widgets
.Group
;
35 import org
.eclipse
.swt
.widgets
.Shell
;
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 fDialogComposite
.layout();
358 getShell().setMinimumSize(new Point(500, 650));
360 return fDialogComposite
;
364 protected void createButtonsForButtonBar(Composite parent
) {
365 createButton(parent
, IDialogConstants
.CANCEL_ID
, "&Cancel", true); //$NON-NLS-1$
366 createButton(parent
, IDialogConstants
.OK_ID
, "&Ok", true); //$NON-NLS-1$
370 protected void okPressed() {
371 fIsKernel
= fKernelButton
.getSelection();
373 // Validate kernel composite in case of kernel domain
374 if (fKernelComposite
!= null && !fKernelComposite
.isValid()) {
378 // Validate UST composite in case of UST domain
379 if (fUstComposite
!= null && !fUstComposite
.isValid()) {
383 // validation successful -> call super.okPressed()
387 // ------------------------------------------------------------------------
389 // ------------------------------------------------------------------------
392 * Creates the kernel composite (if not existing)
394 private void createKernelComposite() {
395 if (fKernelComposite
== null) {
396 fKernelComposite
= new EnableKernelEventComposite(fDialogComposite
, SWT
.NONE
, fProviderGroup
);
397 GridLayout layout
= new GridLayout(1, true);
398 fKernelComposite
.setLayout(layout
);
399 fKernelComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
401 fKernelComposite
.createContent();
406 * Disposes the kernel composite (if existing)
408 private void disposeKernelComposite() {
409 if (fKernelComposite
!= null) {
410 fKernelComposite
.dispose();
411 fKernelComposite
= null;
416 * Creates the UST composite (if not existing)
418 private void createUstComposite() {
419 if (fUstComposite
== null) {
420 fUstComposite
= new EnableUstEventsComposite(fDialogComposite
, SWT
.NONE
, fProviderGroup
);
421 GridLayout layout
= new GridLayout(1, true);
422 fUstComposite
.setLayout(layout
);
423 fUstComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
425 fUstComposite
.createContent();
430 * Disposes the UST composite (if existing)
432 private void disposeUstComposite() {
433 if (fUstComposite
!= null) {
434 fUstComposite
.dispose();
435 fUstComposite
= null;