1 /**********************************************************************
2 * Copyright (c) 2012 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 **********************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.dialogs
;
14 import java
.util
.List
;
16 import org
.eclipse
.jface
.dialogs
.Dialog
;
17 import org
.eclipse
.jface
.dialogs
.IDialogConstants
;
18 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.Activator
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.Messages
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.LogLevelType
;
21 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceLogLevel
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceDomainComponent
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceProviderGroup
;
24 import org
.eclipse
.swt
.SWT
;
25 import org
.eclipse
.swt
.events
.SelectionAdapter
;
26 import org
.eclipse
.swt
.events
.SelectionEvent
;
27 import org
.eclipse
.swt
.graphics
.Point
;
28 import org
.eclipse
.swt
.layout
.GridData
;
29 import org
.eclipse
.swt
.layout
.GridLayout
;
30 import org
.eclipse
.swt
.widgets
.Button
;
31 import org
.eclipse
.swt
.widgets
.Composite
;
32 import org
.eclipse
.swt
.widgets
.Control
;
33 import org
.eclipse
.swt
.widgets
.Group
;
34 import org
.eclipse
.swt
.widgets
.Shell
;
37 * <b><u>EnableEventsDialog</u></b>
39 * Dialog box for collecting information events to be enabled.
42 public class EnableEventsDialog
extends Dialog
implements IEnableEventsDialog
{
44 // ------------------------------------------------------------------------
46 // ------------------------------------------------------------------------
49 * The icon file for this dialog box.
51 public static final String ENABLE_EVENT_ICON_FILE
= "icons/elcl16/edit.gif"; //$NON-NLS-1$
53 // ------------------------------------------------------------------------
55 // ------------------------------------------------------------------------
57 * The dialog composite.
59 private Composite fDialogComposite
;
61 * The composite with widgets for collecting information about kernel events.
63 private EnableKernelEventComposite fKernelComposite
;
65 * The composite with widgets for collecting information about UST events.
67 private EnableUstEventsComposite fUstComposite
;
69 * Radio button for selecting kernel domain.
71 private Button fKernelButton
;
73 * Radio button for selecting UST domain.
75 private Button fUstButton
;
77 * The referenced trace provider group containing the kernel provider and UST
78 * provider component which contains a list of available tracepoints.
80 private TraceProviderGroup fProviderGroup
;
82 * The parent domain component where the channel node should be added.
83 * Null in case the domain is not known (i.e. on session level).
85 private TraceDomainComponent fDomain
;
87 * Output domain information. True in case of Kernel domain. False for UST.
89 private boolean fIsKernel
;
91 // ------------------------------------------------------------------------
93 // ------------------------------------------------------------------------
96 * @param shell - a shell for the display of the dialog
97 * @param providerGroup - the trace provider group
99 public EnableEventsDialog(Shell shell
) {
101 setShellStyle(SWT
.RESIZE
);
104 // ------------------------------------------------------------------------
106 // ------------------------------------------------------------------------
110 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isTracpoints()
113 public boolean isTracepoints() {
115 return fKernelComposite
.isTracepoints();
117 return fUstComposite
.isTracepoints();
121 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isAllTracePoints()
124 public boolean isAllTracePoints() {
126 return fKernelComposite
.isAllTracePoints();
128 return fUstComposite
.isAllTracePoints();
133 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isSysCalls()
136 public boolean isSysCalls() {
138 return fKernelComposite
.isSysCalls();
144 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isAllSysCalls()
147 public boolean isAllSysCalls() {
149 return fKernelComposite
.isSysCalls();
155 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getEventNames()
158 public List
<String
> getEventNames() {
160 return fKernelComposite
.getEventNames();
162 return fUstComposite
.getEventNames();
166 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isDynamicProbe()
169 public boolean isDynamicProbe() {
171 return fKernelComposite
.isDynamicProbe();
177 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getProbeName()
180 public String
getProbeName() {
182 return fKernelComposite
.getProbeName();
188 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getProbeEventName()
191 public String
getProbeEventName() {
193 return fKernelComposite
.getProbeEventName();
200 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#isDynamicFunctionProbe()
203 public boolean isDynamicFunctionProbe() {
205 return fKernelComposite
.isDynamicFunctionProbe();
211 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getFunctionEventName()
214 public String
getFunctionEventName() {
216 return fKernelComposite
.getFunctionEventName();
223 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableKernelEvents#getFunction()
226 public String
getFunction() {
228 return fKernelComposite
.getFunction();
235 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#isWildcard()
238 public boolean isWildcard() {
240 return fUstComposite
.isWildcard();
247 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getWildcard()
250 public String
getWildcard() {
252 return fUstComposite
.getWildcard();
260 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#isLogLevel()
263 public boolean isLogLevel() {
265 return fUstComposite
.isLogLevel();
273 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getLogLevelType()
276 public LogLevelType
getLogLevelType() {
278 return fUstComposite
.getLogLevelType();
286 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getLogLevel()
289 public TraceLogLevel
getLogLevel() {
291 return fUstComposite
.getLogLevel();
299 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getLogLevelEventName()
302 public String
getLogLevelEventName() {
304 return fUstComposite
.getLogLevelEventName();
311 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableEventsDialog#isKernel()
314 public boolean isKernel() {
320 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableEventsDialog#setTraceProviderGroup(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceProviderGroup)
323 public void setTraceProviderGroup(TraceProviderGroup providerGroup
) {
324 fProviderGroup
= providerGroup
;
329 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableEventsDialog#setTraceDomainComponent(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent)
332 public void setTraceDomainComponent(TraceDomainComponent domain
) {
334 if (fDomain
!= null) {
335 fIsKernel
= fDomain
.isKernel();
341 // ------------------------------------------------------------------------
343 // ------------------------------------------------------------------------
346 * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
349 protected void configureShell(Shell newShell
) {
350 super.configureShell(newShell
);
351 newShell
.setText(Messages
.TraceControl_EnableEventsDialogTitle
);
352 newShell
.setImage(Activator
.getDefault().loadIcon(ENABLE_EVENT_ICON_FILE
));
357 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
360 protected Control
createDialogArea(Composite parent
) {
363 fDialogComposite
= new Composite(parent
, SWT
.NONE
);
364 GridLayout layout
= new GridLayout(1, true);
365 fDialogComposite
.setLayout(layout
);
366 fDialogComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
368 // ------------------------------------------------------------------------
370 // ------------------------------------------------------------------------
371 Group domainGroup
= new Group(fDialogComposite
, SWT
.SHADOW_NONE
);
372 domainGroup
.setText(Messages
.TraceControl_DomainDisplayName
);
373 layout
= new GridLayout(2, true);
374 domainGroup
.setLayout(layout
);
376 fKernelButton
= new Button(domainGroup
, SWT
.RADIO
);
377 fKernelButton
.setText(Messages
.TraceControl_KernelDomainDisplayName
);
378 fKernelButton
.setSelection(fIsKernel
);
379 fUstButton
= new Button(domainGroup
, SWT
.RADIO
);
380 fUstButton
.setText(Messages
.TraceControl_UstDisplayName
);
381 fUstButton
.setSelection(!fIsKernel
);
383 if (fDomain
!= null) {
384 fKernelButton
.setEnabled(false);
385 fUstButton
.setEnabled(false);
389 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
390 domainGroup
.setLayoutData(data
);
392 data
= new GridData(SWT
.BEGINNING
, SWT
.BEGINNING
, true, true);
393 fKernelButton
.setLayoutData(data
);
394 data
= new GridData(SWT
.BEGINNING
, SWT
.BEGINNING
, true, true);
395 fUstButton
.setLayoutData(data
);
397 // ------------------------------------------------------------------------
398 // Kernel or UST event data group
399 // ------------------------------------------------------------------------
400 fUstComposite
= null;
401 fKernelComposite
= null;
403 createKernelComposite();
404 fUstComposite
= null;
406 createUstComposite();
409 fKernelButton
.addSelectionListener(new SelectionAdapter() {
411 public void widgetSelected(SelectionEvent e
) {
412 if (fKernelButton
.getSelection()) {
413 disposeUstComposite();
414 createKernelComposite();
415 fDialogComposite
.layout();
420 fUstButton
.addSelectionListener(new SelectionAdapter() {
422 public void widgetSelected(SelectionEvent e
) {
423 if (fUstButton
.getSelection()) {
424 disposeKernelComposite();
425 createUstComposite();
426 fDialogComposite
.layout();
431 fDialogComposite
.layout();
433 getShell().setMinimumSize(new Point(500, 650));
435 return fDialogComposite
;
441 * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
444 protected void createButtonsForButtonBar(Composite parent
) {
445 createButton(parent
, IDialogConstants
.OK_ID
, "&Ok", true); //$NON-NLS-1$
450 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
453 protected void okPressed() {
454 fIsKernel
= fKernelButton
.getSelection();
456 // Validate kernel composite in case of kernel domain
457 if (fKernelComposite
!= null && !fKernelComposite
.isValid()) {
461 // Validate UST composite in case of UST domain
462 if (fUstComposite
!= null && !fUstComposite
.isValid()) {
466 // validation successful -> call super.okPressed()
470 // ------------------------------------------------------------------------
472 // ------------------------------------------------------------------------
474 * Creates the kernel composite (if not existing)
476 private void createKernelComposite() {
477 if (fKernelComposite
== null) {
478 fKernelComposite
= new EnableKernelEventComposite(fDialogComposite
, SWT
.NONE
, fProviderGroup
);
479 GridLayout layout
= new GridLayout(1, true);
480 fKernelComposite
.setLayout(layout
);
481 fKernelComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
483 fKernelComposite
.createContent();
488 * Disposes the kernel composite (if existing)
490 private void disposeKernelComposite() {
491 if (fKernelComposite
!= null) {
492 fKernelComposite
.dispose();
493 fKernelComposite
= null;
498 * Creates the UST composite (if not existing)
500 private void createUstComposite() {
501 if (fUstComposite
== null) {
502 fUstComposite
= new EnableUstEventsComposite(fDialogComposite
, SWT
.NONE
, fProviderGroup
);
503 GridLayout layout
= new GridLayout(1, true);
504 fUstComposite
.setLayout(layout
);
505 fUstComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
507 fUstComposite
.createContent();
512 * Disposes the UST composite (if existing)
514 private void disposeUstComposite() {
515 if (fUstComposite
!= null) {
516 fUstComposite
.dispose();
517 fUstComposite
= null;