1 /*******************************************************************************
2 * Copyright (c) 2011 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
12 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng
.ui
.tracecontrol
.wizards
;
15 import org
.eclipse
.jface
.wizard
.WizardPage
;
16 import org
.eclipse
.linuxtools
.lttng
.tracecontrol
.model
.config
.TraceChannel
;
17 import org
.eclipse
.linuxtools
.lttng
.tracecontrol
.model
.config
.TraceChannels
;
18 import org
.eclipse
.linuxtools
.lttng
.ui
.tracecontrol
.Messages
;
19 import org
.eclipse
.swt
.SWT
;
20 import org
.eclipse
.swt
.events
.VerifyEvent
;
21 import org
.eclipse
.swt
.events
.VerifyListener
;
22 import org
.eclipse
.swt
.layout
.GridData
;
23 import org
.eclipse
.swt
.layout
.GridLayout
;
24 import org
.eclipse
.swt
.widgets
.Composite
;
25 import org
.eclipse
.swt
.widgets
.Event
;
26 import org
.eclipse
.swt
.widgets
.Label
;
27 import org
.eclipse
.swt
.widgets
.Listener
;
28 import org
.eclipse
.swt
.widgets
.Text
;
31 * <b><u>UstTraceChannelConfigurationPage</u></b>
33 * Wizard page implementation to configure the UST trace channels.
36 public class UstTraceChannelConfigurationPage
extends WizardPage
implements ITraceChannelConfigurationPage
{
38 // ------------------------------------------------------------------------
40 // ------------------------------------------------------------------------
41 private TraceChannels fChannels
;
42 private Composite fContainer
;
43 private Text fChannelTimerText
;
45 // ------------------------------------------------------------------------
47 // ------------------------------------------------------------------------
54 protected UstTraceChannelConfigurationPage(TraceChannels channels
) {
55 super("UstTraceChannelConfigurationPage"); //$NON-NLS-1$
57 setTitle(Messages
.ChannelConfigPage_PageTitle
);
61 // ------------------------------------------------------------------------
63 // ------------------------------------------------------------------------
67 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
70 public void createControl(Composite parent
) {
71 fContainer
= new Composite(parent
, SWT
.NULL
);
72 fContainer
.setLayout(new GridLayout());
73 setControl(fContainer
);
75 Composite headerComposite
= new Composite(fContainer
, SWT
.FILL
);
76 GridLayout headerLayout
= new GridLayout(4, true);
77 headerLayout
.marginHeight
= 0;
78 headerLayout
.marginWidth
= 0;
79 headerComposite
.setLayout(headerLayout
);
80 headerComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
82 Label label
= new Label(headerComposite
, SWT
.LEFT
);
83 label
.setText(Messages
.ChannelConfigPage_ChannelTimer
+ ":"); //$NON-NLS-1$
84 label
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 1, 1));
86 fChannelTimerText
= new Text(headerComposite
, SWT
.LEFT
);
87 fChannelTimerText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, false, 3, 1));
88 fChannelTimerText
.setToolTipText(Messages
.ChannelConfigPage_ChannelTimerTooltip
);
90 TraceChannel chan
= fChannels
.get(TraceChannel
.UST_TRACE_CHANNEL_NAME
);
91 if (chan
.getTimer() == TraceChannel
.UNKNOWN_VALUE
) {
92 fChannelTimerText
.setText(TraceChannel
.UNKNOWN_STRING
);
95 fChannelTimerText
.setText(String
.valueOf(chan
.getTimer()));
98 fChannelTimerText
.addVerifyListener(new VerifyListener() {
100 public void verifyText(VerifyEvent e
) {
101 e
.doit
= e
.text
.matches("[0-9]*"); //$NON-NLS-1$
105 fChannelTimerText
.addListener(SWT
.Modify
, new Listener() {
107 public void handleEvent(Event event
) {
108 String valueString
= fChannelTimerText
.getText();
109 TraceChannel chan
= fChannels
.get(TraceChannel
.UST_TRACE_CHANNEL_NAME
);
110 if (valueString
.length() == 0) {
111 valueString
= "0"; //$NON-NLS-1$
113 else if(TraceChannel
.UNKNOWN_STRING
.equals(valueString
)) {
114 chan
.setTimer(TraceChannel
.UNKNOWN_VALUE
);
117 chan
.setTimer(Integer
.parseInt(valueString
));
124 * @see org.eclipse.jface.dialogs.DialogPage#dispose()
127 public void dispose() {
133 * @see org.eclipse.linuxtools.lttng.rse.ui.wizards.ITraceChannelConfigurationPage#getTraceChannels()
136 public TraceChannels
getTraceChannels() {