Commit | Line | Data |
---|---|---|
bbb3538a | 1 | /********************************************************************** |
11252342 | 2 | * Copyright (c) 2012, 2013 Ericsson |
a07c7629 | 3 | * |
bbb3538a BH |
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 | |
a07c7629 BH |
8 | * |
9 | * Contributors: | |
bbb3538a | 10 | * Bernd Hufmann - Initial API and implementation |
e799e5f3 | 11 | * Simon Delisle - Updated for support of LTTng Tools 2.2 |
bbb3538a | 12 | **********************************************************************/ |
115b4a01 | 13 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs; |
bbb3538a BH |
14 | |
15 | import org.eclipse.jface.dialogs.Dialog; | |
16 | import org.eclipse.jface.dialogs.IDialogConstants; | |
17 | import org.eclipse.jface.dialogs.MessageDialog; | |
9315aeee | 18 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IChannelInfo; |
83051fc3 | 19 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.BufferType; |
9315aeee | 20 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ChannelInfo; |
115b4a01 | 21 | import org.eclipse.linuxtools.internal.lttng2.ui.Activator; |
9315aeee | 22 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages; |
e799e5f3 | 23 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent; |
115b4a01 | 24 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent; |
e799e5f3 | 25 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.LTTngControlServiceConstants; |
bbb3538a | 26 | import org.eclipse.swt.SWT; |
e799e5f3 SD |
27 | import org.eclipse.swt.events.FocusEvent; |
28 | import org.eclipse.swt.events.FocusListener; | |
29 | import org.eclipse.swt.events.SelectionAdapter; | |
30 | import org.eclipse.swt.events.SelectionEvent; | |
bbb3538a BH |
31 | import org.eclipse.swt.events.VerifyEvent; |
32 | import org.eclipse.swt.events.VerifyListener; | |
bbb3538a BH |
33 | import org.eclipse.swt.layout.GridData; |
34 | import org.eclipse.swt.layout.GridLayout; | |
35 | import org.eclipse.swt.widgets.Button; | |
36 | import org.eclipse.swt.widgets.Composite; | |
37 | import org.eclipse.swt.widgets.Control; | |
38 | import org.eclipse.swt.widgets.Group; | |
39 | import org.eclipse.swt.widgets.Label; | |
40 | import org.eclipse.swt.widgets.Shell; | |
41 | import org.eclipse.swt.widgets.Text; | |
42 | ||
43 | /** | |
bbb3538a | 44 | * <p> |
d62bfa55 | 45 | * Dialog box for collecting channel information when enabling a channel (which will be created). |
bbb3538a | 46 | * </p> |
a07c7629 | 47 | * |
dbd4432d | 48 | * @author Bernd Hufmann |
bbb3538a | 49 | */ |
d62bfa55 | 50 | public class EnableChannelDialog extends Dialog implements IEnableChannelDialog { |
bbb3538a BH |
51 | |
52 | // ------------------------------------------------------------------------ | |
53 | // Constants | |
54 | // ------------------------------------------------------------------------ | |
55 | /** | |
56 | * The icon file for this dialog box. | |
57 | */ | |
a07c7629 | 58 | public static final String ENABLE_CHANNEL_ICON_FILE = "icons/elcl16/add_button.gif"; //$NON-NLS-1$ |
bbb3538a | 59 | |
e799e5f3 SD |
60 | /** |
61 | * To indicate that the default value will be used for this field | |
62 | */ | |
63 | private static final String DEFAULT_TEXT = "<" + Messages.EnableChannelDialog_DefaultMessage + ">"; //$NON-NLS-1$ //$NON-NLS-2$ | |
64 | ||
bbb3538a BH |
65 | // ------------------------------------------------------------------------ |
66 | // Attributes | |
67 | // ------------------------------------------------------------------------ | |
bbb3538a BH |
68 | /** |
69 | * The text widget for the channel name | |
70 | */ | |
71 | private Text fChannelNameText = null; | |
0886cf00 BH |
72 | /** |
73 | * The discard mode of the channel. | |
74 | */ | |
75 | private Button fDiscardModeButton = null; | |
bbb3538a BH |
76 | /** |
77 | * The overwrite mode of the channel. | |
78 | */ | |
c56972bb | 79 | private Button fOverwriteModeButton = null; |
bbb3538a BH |
80 | /** |
81 | * The sub-buffer size of the channel. | |
82 | */ | |
c56972bb | 83 | private Text fSubBufferSizeText = null; |
bbb3538a BH |
84 | /** |
85 | * The number of sub-buffers of the channel. | |
86 | */ | |
c56972bb | 87 | private Text fNumberOfSubBuffersText = null; |
bbb3538a BH |
88 | /** |
89 | * The switch timer interval of the channel. | |
90 | */ | |
c56972bb | 91 | private Text fSwitchTimerText = null; |
bbb3538a BH |
92 | /** |
93 | * The read timer interval of the channel. | |
94 | */ | |
c56972bb | 95 | private Text fReadTimerText = null; |
bbb3538a BH |
96 | /** |
97 | * Radio button for selecting kernel domain. | |
98 | */ | |
c56972bb | 99 | private Button fKernelButton = null; |
bbb3538a BH |
100 | /** |
101 | * Radio button for selecting UST domain. | |
102 | */ | |
c56972bb | 103 | private Button fUstButton = null; |
bbb3538a | 104 | /** |
a07c7629 | 105 | * The parent domain component where the channel node should be added. |
bbb3538a BH |
106 | * Null in case of creation on session level. |
107 | */ | |
c56972bb | 108 | private TraceDomainComponent fDomain = null; |
e799e5f3 SD |
109 | /** |
110 | * The target node component | |
111 | */ | |
112 | private TargetNodeComponent fTargetNodeComponent = null; | |
bbb3538a | 113 | /** |
a07c7629 | 114 | * Common verify listener for numeric text input. |
bbb3538a | 115 | */ |
c56972bb | 116 | private VerifyListener fVerifyListener = null; |
e799e5f3 SD |
117 | /** |
118 | * Common focus listener | |
119 | */ | |
120 | private FocusListener fFocusListener = null; | |
bbb3538a BH |
121 | /** |
122 | * Output channel information. | |
123 | */ | |
c56972bb | 124 | private IChannelInfo fChannelInfo = null; |
bbb3538a | 125 | /** |
a07c7629 | 126 | * Output domain information. True in case of Kernel domain. False for UST. |
bbb3538a BH |
127 | */ |
128 | private boolean fIsKernel; | |
a07c7629 BH |
129 | /** |
130 | * Flag which indicates whether Kernel domain is available or not | |
131 | */ | |
132 | private boolean fHasKernel; | |
e799e5f3 SD |
133 | /** |
134 | * Maximum size of trace files of the channel. | |
135 | */ | |
136 | private Text fMaxSizeTraceText = null; | |
137 | /** | |
138 | * Maximum number of trace files of the channel. | |
139 | */ | |
140 | private Text fMaxNumberTraceText = null; | |
83051fc3 BH |
141 | /** |
142 | * CheckBox for selecting shared buffers (kernel onlyu). | |
143 | */ | |
144 | private Button fSharedBuffersButton = null; | |
145 | /** | |
146 | * CheckBox for selecting per UID buffers. | |
147 | */ | |
148 | private Button fPIDBuffersButton = null; | |
e799e5f3 SD |
149 | /** |
150 | * CheckBox for selecting per UID buffers. | |
151 | */ | |
152 | private Button fUIDBuffersButton = null; | |
153 | /** | |
154 | * CheckBox to configure metadata channel | |
155 | */ | |
156 | private Button fMetadataChannelButton = null; | |
157 | /** | |
158 | * Previous channel name | |
159 | */ | |
160 | private String fPreviousChannelName = null; | |
161 | ||
bbb3538a BH |
162 | // ------------------------------------------------------------------------ |
163 | // Constructors | |
164 | // ------------------------------------------------------------------------ | |
165 | ||
166 | /** | |
167 | * Constructor | |
168 | * @param shell - a shell for the display of the dialog | |
169 | */ | |
d62bfa55 | 170 | public EnableChannelDialog(Shell shell) { |
d132bcc7 BH |
171 | super(shell); |
172 | fIsKernel = true; | |
bbb3538a BH |
173 | |
174 | // Common verify listener | |
175 | fVerifyListener = new VerifyListener() { | |
176 | @Override | |
177 | public void verifyText(VerifyEvent e) { | |
e799e5f3 SD |
178 | // only numbers and default are allowed. |
179 | e.doit = e.text.matches("[0-9]*") || e.text.matches(DEFAULT_TEXT); //$NON-NLS-1$ | |
bbb3538a BH |
180 | } |
181 | }; | |
e799e5f3 SD |
182 | |
183 | // Common focus listener | |
184 | fFocusListener = new FocusListener() { | |
185 | ||
186 | @Override | |
187 | public void focusLost(FocusEvent e) { | |
188 | Text focusLostWidget = (Text) e.widget; | |
189 | if (focusLostWidget.getText().isEmpty()) { | |
190 | focusLostWidget.setText(DEFAULT_TEXT); | |
191 | focusLostWidget.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); | |
192 | } | |
193 | } | |
194 | ||
195 | @Override | |
196 | public void focusGained(FocusEvent e) { | |
197 | Text focusGainedWidget = (Text) e.widget; | |
198 | if (focusGainedWidget.getText().equals(DEFAULT_TEXT)) { | |
199 | focusGainedWidget.setText(""); //$NON-NLS-1$ | |
200 | focusGainedWidget.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_BLACK)); | |
201 | } | |
202 | } | |
203 | }; | |
204 | ||
8a396998 | 205 | setShellStyle(SWT.RESIZE | getShellStyle()); |
bbb3538a BH |
206 | } |
207 | ||
208 | // ------------------------------------------------------------------------ | |
209 | // Accessors | |
210 | // ------------------------------------------------------------------------ | |
11252342 | 211 | |
bbb3538a BH |
212 | @Override |
213 | public IChannelInfo getChannelInfo() { | |
214 | return fChannelInfo; | |
215 | } | |
216 | ||
d132bcc7 BH |
217 | @Override |
218 | public void setDomainComponent(TraceDomainComponent domain) { | |
219 | fDomain = domain; | |
220 | if (fDomain != null) { | |
221 | fIsKernel = fDomain.isKernel(); | |
222 | } else { | |
223 | fIsKernel = true; | |
224 | } | |
225 | } | |
226 | ||
bbb3538a BH |
227 | @Override |
228 | public boolean isKernel() { | |
229 | return fIsKernel; | |
230 | } | |
231 | ||
a07c7629 BH |
232 | @Override |
233 | public void setHasKernel(boolean hasKernel) { | |
234 | if (fDomain != null) { | |
235 | fIsKernel = fDomain.isKernel(); | |
236 | } else { | |
237 | fIsKernel = hasKernel; | |
238 | } | |
239 | ||
240 | fHasKernel = hasKernel; | |
241 | } | |
242 | ||
e799e5f3 SD |
243 | @Override |
244 | public void setTargetNodeComponent(TargetNodeComponent node) { | |
245 | fTargetNodeComponent = node; | |
246 | } | |
247 | ||
bbb3538a BH |
248 | // ------------------------------------------------------------------------ |
249 | // Operations | |
250 | // ------------------------------------------------------------------------ | |
11252342 | 251 | |
bbb3538a BH |
252 | @Override |
253 | protected void configureShell(Shell newShell) { | |
254 | super.configureShell(newShell); | |
255 | newShell.setText(Messages.TraceControl_EnableChannelDialogTitle); | |
31a6a4e4 | 256 | newShell.setImage(Activator.getDefault().loadIcon(ENABLE_CHANNEL_ICON_FILE)); |
bbb3538a BH |
257 | } |
258 | ||
bbb3538a BH |
259 | @Override |
260 | protected Control createDialogArea(Composite parent) { | |
a07c7629 | 261 | |
83051fc3 BH |
262 | int numColumn = 2; |
263 | if (fTargetNodeComponent.isBufferTypeConfigSupported()) { | |
264 | numColumn = 3; | |
265 | } | |
266 | ||
bbb3538a | 267 | // Main dialog panel |
046b6849 | 268 | Composite dialogComposite = new Composite(parent, SWT.NONE); |
83051fc3 | 269 | GridLayout layout = new GridLayout(1, true); |
046b6849 | 270 | dialogComposite.setLayout(layout); |
bbb3538a | 271 | |
83051fc3 BH |
272 | Composite commonModeGroup = new Composite(dialogComposite, SWT.NONE); |
273 | layout = new GridLayout(3, true); | |
274 | commonModeGroup.setLayout(layout); | |
275 | ||
276 | Label channelNameLabel = new Label(commonModeGroup, SWT.RIGHT); | |
bbb3538a | 277 | channelNameLabel.setText(Messages.TraceControl_EnableChannelNameLabel); |
83051fc3 | 278 | fChannelNameText = new Text(commonModeGroup, SWT.NONE); |
498704b3 | 279 | fChannelNameText.setToolTipText(Messages.TraceControl_EnableChannelNameTooltip); |
a07c7629 | 280 | |
83051fc3 | 281 | Label subBufferSizeLabel = new Label(commonModeGroup, SWT.RIGHT); |
bbb3538a | 282 | subBufferSizeLabel.setText(Messages.TraceControl_SubBufferSizePropertyName); |
83051fc3 | 283 | fSubBufferSizeText = new Text(commonModeGroup, SWT.NONE); |
bbb3538a BH |
284 | fSubBufferSizeText.setToolTipText(Messages.TraceControl_EnableChannelSubBufferSizeTooltip); |
285 | fSubBufferSizeText.addVerifyListener(fVerifyListener); | |
e799e5f3 SD |
286 | fSubBufferSizeText.addFocusListener(fFocusListener); |
287 | fSubBufferSizeText.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); | |
a07c7629 | 288 | |
83051fc3 | 289 | Label numSubBufferLabel = new Label(commonModeGroup, SWT.RIGHT); |
bbb3538a | 290 | numSubBufferLabel.setText(Messages.TraceControl_NbSubBuffersPropertyName); |
83051fc3 | 291 | fNumberOfSubBuffersText = new Text(commonModeGroup, SWT.NONE); |
bbb3538a BH |
292 | fNumberOfSubBuffersText.setToolTipText(Messages.TraceControl_EnableChannelNbSubBuffersTooltip); |
293 | fNumberOfSubBuffersText.addVerifyListener(fVerifyListener); | |
e799e5f3 | 294 | fNumberOfSubBuffersText.addFocusListener(fFocusListener); |
bbb3538a | 295 | |
83051fc3 | 296 | Label switchTimerLabel = new Label(commonModeGroup, SWT.RIGHT); |
bbb3538a | 297 | switchTimerLabel.setText(Messages.TraceControl_SwitchTimerPropertyName); |
83051fc3 | 298 | fSwitchTimerText = new Text(commonModeGroup, SWT.NONE); |
bbb3538a BH |
299 | fSwitchTimerText.setToolTipText(Messages.TraceControl_EnableChannelSwitchTimerTooltip); |
300 | fSwitchTimerText.addVerifyListener(fVerifyListener); | |
e799e5f3 | 301 | fSwitchTimerText.addFocusListener(fFocusListener); |
bbb3538a | 302 | |
83051fc3 | 303 | Label readTimerLabel = new Label(commonModeGroup, SWT.RIGHT); |
bbb3538a | 304 | readTimerLabel.setText(Messages.TraceControl_ReadTimerPropertyName); |
83051fc3 | 305 | fReadTimerText = new Text(commonModeGroup, SWT.NONE); |
bbb3538a BH |
306 | fReadTimerText.setToolTipText(Messages.TraceControl_EnableChannelReadTimerTooltip); |
307 | fReadTimerText.addVerifyListener(fVerifyListener); | |
e799e5f3 SD |
308 | fReadTimerText.addFocusListener(fFocusListener); |
309 | ||
310 | if (fTargetNodeComponent.isTraceFileRotationSupported()) { | |
83051fc3 | 311 | Label maxSizeTraceFilesLabel = new Label(commonModeGroup, SWT.RIGHT); |
e799e5f3 | 312 | maxSizeTraceFilesLabel.setText(Messages.TraceControl_MaxSizeTraceFilesPropertyName); |
83051fc3 | 313 | fMaxSizeTraceText = new Text(commonModeGroup, SWT.NONE); |
e799e5f3 SD |
314 | fMaxSizeTraceText.setToolTipText(Messages.TraceControl_EnbleChannelMaxSizeTraceFilesTooltip); |
315 | fMaxSizeTraceText.addVerifyListener(fVerifyListener); | |
316 | fMaxSizeTraceText.addFocusListener(fFocusListener); | |
317 | ||
83051fc3 | 318 | Label maxNumTraceFilesLabel = new Label(commonModeGroup, SWT.RIGHT); |
e799e5f3 | 319 | maxNumTraceFilesLabel.setText(Messages.TraceControl_MaxNumTraceFilesPropertyName); |
83051fc3 | 320 | fMaxNumberTraceText = new Text(commonModeGroup, SWT.NONE); |
e799e5f3 SD |
321 | fMaxNumberTraceText.setToolTipText(Messages.TraceControl_EnbleChannelMaxNumTraceFilesTooltip); |
322 | fMaxNumberTraceText.addVerifyListener(fVerifyListener); | |
323 | fMaxNumberTraceText.addFocusListener(fFocusListener); | |
324 | } | |
325 | ||
326 | if (fTargetNodeComponent.isPeriodicalMetadataFlushSupported()) { | |
83051fc3 | 327 | fMetadataChannelButton = new Button(commonModeGroup, SWT.CHECK); |
e799e5f3 SD |
328 | fMetadataChannelButton.setText(Messages.TraceControl_ConfigureMetadataChannelName); |
329 | fMetadataChannelButton.setSelection(false); | |
330 | ||
331 | fMetadataChannelButton.addSelectionListener(new SelectionAdapter() { | |
332 | @Override | |
333 | public void widgetSelected(SelectionEvent e) { | |
334 | if (fMetadataChannelButton.getSelection()) { | |
335 | fPreviousChannelName = fChannelNameText.getText(); | |
336 | fChannelNameText.setText("metadata"); //$NON-NLS-1$ | |
337 | fChannelNameText.setEnabled(false); | |
338 | } else { | |
339 | fChannelNameText.setText(fPreviousChannelName); | |
340 | fChannelNameText.setEnabled(true); | |
341 | } | |
342 | } | |
343 | }); | |
344 | } | |
046b6849 | 345 | Group discardModeGroup = new Group(dialogComposite, SWT.SHADOW_NONE); |
0886cf00 | 346 | discardModeGroup.setText(Messages.TraceControl_EnableChannelDiscardModeGroupName); |
83051fc3 | 347 | layout = new GridLayout(numColumn, true); |
a07c7629 | 348 | discardModeGroup.setLayout(layout); |
0886cf00 BH |
349 | |
350 | fDiscardModeButton = new Button(discardModeGroup, SWT.RADIO); | |
351 | fDiscardModeButton.setText(Messages.TraceControl_EnableChannelDiscardModeLabel); | |
352 | fDiscardModeButton.setToolTipText(Messages.TraceControl_EnableChannelDiscardModeTooltip); | |
353 | fDiscardModeButton.setSelection(true); | |
a07c7629 | 354 | |
0886cf00 BH |
355 | fOverwriteModeButton = new Button(discardModeGroup, SWT.RADIO); |
356 | fOverwriteModeButton.setText(Messages.TraceControl_EnableChannelOverwriteModeLabel); | |
bbb3538a | 357 | fOverwriteModeButton.setToolTipText(Messages.TraceControl_EnableChannelOverwriteModeTooltip); |
0886cf00 | 358 | fOverwriteModeButton.setSelection(false); |
bbb3538a | 359 | |
046b6849 BH |
360 | Group domainGroup = new Group(dialogComposite, SWT.SHADOW_NONE); |
361 | domainGroup.setText(Messages.TraceControl_DomainDisplayName); | |
83051fc3 | 362 | layout = new GridLayout(numColumn, true); |
046b6849 | 363 | domainGroup.setLayout(layout); |
a07c7629 | 364 | |
046b6849 | 365 | fKernelButton = new Button(domainGroup, SWT.RADIO); |
bbb3538a BH |
366 | fKernelButton.setText(Messages.TraceControl_KernelDomainDisplayName); |
367 | fKernelButton.setSelection(fIsKernel); | |
046b6849 | 368 | fUstButton = new Button(domainGroup, SWT.RADIO); |
bbb3538a BH |
369 | fUstButton.setText(Messages.TraceControl_UstDisplayName); |
370 | fUstButton.setSelection(!fIsKernel); | |
371 | ||
83051fc3 BH |
372 | if (fTargetNodeComponent.isBufferTypeConfigSupported()) { |
373 | Group bufferTypeGroup = new Group(dialogComposite, SWT.SHADOW_NONE); | |
374 | bufferTypeGroup.setText(Messages.TraceControl_BufferTypeDisplayName); | |
375 | layout = new GridLayout(numColumn, true); | |
376 | bufferTypeGroup.setLayout(layout); | |
377 | ||
378 | GridData data = new GridData(GridData.FILL, GridData.BEGINNING, false, false); | |
379 | data.horizontalSpan = 3; | |
380 | bufferTypeGroup.setLayoutData(data); | |
381 | ||
382 | fSharedBuffersButton = new Button(bufferTypeGroup, SWT.RADIO); | |
383 | fSharedBuffersButton.setText(Messages.TraceControl_SharedBuffersDisplayName); | |
384 | fSharedBuffersButton.setSelection(fIsKernel); | |
385 | fSharedBuffersButton.setEnabled(false); | |
386 | ||
387 | fPIDBuffersButton = new Button(bufferTypeGroup, SWT.RADIO); | |
388 | fPIDBuffersButton.setText(Messages.TraceControl_PerPidBuffersDisplayName); | |
389 | fPIDBuffersButton.setToolTipText(Messages.TraceControl_PerPidBuffersTooltip); | |
390 | fPIDBuffersButton.setSelection(false); | |
391 | ||
392 | fUIDBuffersButton = new Button(bufferTypeGroup, SWT.RADIO); | |
e799e5f3 | 393 | fUIDBuffersButton.setText(Messages.TraceControl_PerUidBuffersDisplayName); |
83051fc3 | 394 | fUIDBuffersButton.setToolTipText(Messages.TraceControl_PerPidBuffersTooltip); |
e799e5f3 | 395 | fUIDBuffersButton.setSelection(false); |
83051fc3 | 396 | |
e799e5f3 | 397 | fUIDBuffersButton.setEnabled(!fIsKernel); |
83051fc3 | 398 | fPIDBuffersButton.setEnabled(!fIsKernel); |
e799e5f3 | 399 | |
83051fc3 | 400 | // Update buffers type buttons depending on UST or Kernel |
e799e5f3 SD |
401 | fUstButton.addSelectionListener(new SelectionAdapter() { |
402 | @Override | |
403 | public void widgetSelected(SelectionEvent e) { | |
404 | if (fUstButton.getSelection()) { | |
83051fc3 BH |
405 | fSharedBuffersButton.setSelection(false); |
406 | fPIDBuffersButton.setSelection(false); | |
407 | fUIDBuffersButton.setSelection(false); | |
408 | fPIDBuffersButton.setEnabled(true); | |
e799e5f3 SD |
409 | fUIDBuffersButton.setEnabled(true); |
410 | } else { | |
83051fc3 BH |
411 | fSharedBuffersButton.setSelection(true); |
412 | fPIDBuffersButton.setSelection(false); | |
413 | fUIDBuffersButton.setSelection(false); | |
414 | fPIDBuffersButton.setEnabled(false); | |
e799e5f3 SD |
415 | fUIDBuffersButton.setEnabled(false); |
416 | } | |
417 | } | |
418 | }); | |
419 | } | |
420 | ||
a07c7629 | 421 | if ((fDomain != null) || (!fHasKernel)) { |
bbb3538a BH |
422 | fKernelButton.setEnabled(false); |
423 | fUstButton.setEnabled(false); | |
83051fc3 BH |
424 | |
425 | if (fTargetNodeComponent.isBufferTypeConfigSupported()) { | |
426 | fSharedBuffersButton.setEnabled(false); | |
76fd8d05 BH |
427 | fUIDBuffersButton.setEnabled(!fHasKernel); |
428 | fPIDBuffersButton.setEnabled(!fHasKernel); | |
429 | setBufferTypeButtonSelection(); | |
83051fc3 | 430 | } |
bbb3538a BH |
431 | } |
432 | ||
433 | // layout widgets | |
83051fc3 BH |
434 | GridData data = new GridData(GridData.FILL, GridData.BEGINNING, false, false); |
435 | data.horizontalSpan = 3; | |
0886cf00 BH |
436 | discardModeGroup.setLayoutData(data); |
437 | data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true); | |
438 | fDiscardModeButton.setLayoutData(data); | |
439 | data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true); | |
440 | fOverwriteModeButton.setLayoutData(data); | |
a07c7629 | 441 | |
83051fc3 BH |
442 | data = new GridData(GridData.FILL, GridData.BEGINNING, false, false); |
443 | data.horizontalSpan = 3; | |
046b6849 | 444 | domainGroup.setLayoutData(data); |
bbb3538a BH |
445 | |
446 | data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true); | |
447 | fKernelButton.setLayoutData(data); | |
448 | data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true); | |
449 | fUstButton.setLayoutData(data); | |
83051fc3 BH |
450 | if (fTargetNodeComponent.isBufferTypeConfigSupported()) { |
451 | data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true); | |
452 | fSharedBuffersButton.setLayoutData(data); | |
453 | data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true); | |
454 | fPIDBuffersButton.setLayoutData(data); | |
e799e5f3 SD |
455 | data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true); |
456 | fUIDBuffersButton.setLayoutData(data); | |
457 | } | |
83051fc3 | 458 | |
e799e5f3 SD |
459 | if (fTargetNodeComponent.isPeriodicalMetadataFlushSupported()) { |
460 | data = new GridData(SWT.BEGINNING, SWT.BEGINNING, true, true); | |
83051fc3 | 461 | data.horizontalSpan = numColumn; |
e799e5f3 SD |
462 | fMetadataChannelButton.setLayoutData(data); |
463 | } | |
a07c7629 | 464 | |
d62bfa55 BH |
465 | data = new GridData(GridData.FILL_HORIZONTAL); |
466 | data.horizontalSpan = 2; | |
bbb3538a BH |
467 | |
468 | fChannelNameText.setLayoutData(data); | |
469 | fSubBufferSizeText.setLayoutData(data); | |
470 | fNumberOfSubBuffersText.setLayoutData(data); | |
471 | fSwitchTimerText.setLayoutData(data); | |
472 | fReadTimerText.setLayoutData(data); | |
e799e5f3 SD |
473 | if (fTargetNodeComponent.isTraceFileRotationSupported()) { |
474 | fMaxNumberTraceText.setLayoutData(data); | |
475 | fMaxSizeTraceText.setLayoutData(data); | |
476 | } | |
bbb3538a | 477 | |
bbb3538a BH |
478 | setDefaults(); |
479 | ||
046b6849 | 480 | return dialogComposite; |
bbb3538a BH |
481 | } |
482 | ||
bbb3538a BH |
483 | @Override |
484 | protected void createButtonsForButtonBar(Composite parent) { | |
79c3db85 BH |
485 | createButton(parent, IDialogConstants.DETAILS_ID, "&Default", true); //$NON-NLS-1$ |
486 | createButton(parent, IDialogConstants.CANCEL_ID, "&Cancel", true); //$NON-NLS-1$ | |
bbb3538a BH |
487 | createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$ |
488 | } | |
489 | ||
bbb3538a BH |
490 | @Override |
491 | protected void okPressed() { | |
492 | // Set channel information | |
c371fa43 BH |
493 | ChannelInfo channelInfo = new ChannelInfo(fChannelNameText.getText()); |
494 | channelInfo.setSubBufferSize(fSubBufferSizeText.getText().equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Long.parseLong(fSubBufferSizeText.getText())); | |
495 | channelInfo.setNumberOfSubBuffers(fNumberOfSubBuffersText.getText().equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Integer.parseInt(fNumberOfSubBuffersText.getText())); | |
496 | channelInfo.setSwitchTimer(fSwitchTimerText.getText().equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Long.parseLong(fSwitchTimerText.getText())); | |
497 | channelInfo.setReadTimer(fReadTimerText.getText().equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Long.parseLong(fReadTimerText.getText())); | |
498 | channelInfo.setOverwriteMode(fOverwriteModeButton.getSelection()); | |
e799e5f3 | 499 | if (fTargetNodeComponent.isTraceFileRotationSupported()) { |
c371fa43 BH |
500 | channelInfo.setMaxSizeTraceFiles(fMaxSizeTraceText.getText().equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Integer.parseInt(fMaxSizeTraceText.getText())); |
501 | channelInfo.setMaxNumberTraceFiles(fMaxNumberTraceText.getText().equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Integer.parseInt(fMaxNumberTraceText.getText())); | |
e799e5f3 | 502 | } |
83051fc3 BH |
503 | if (fTargetNodeComponent.isBufferTypeConfigSupported()) { |
504 | if (fSharedBuffersButton.getSelection()) { | |
c371fa43 | 505 | channelInfo.setBufferType(BufferType.BUFFER_SHARED); |
83051fc3 | 506 | } else if (fPIDBuffersButton.getSelection()) { |
c371fa43 | 507 | channelInfo.setBufferType(BufferType.BUFFER_PER_PID); |
83051fc3 | 508 | } else if (fUIDBuffersButton.getSelection()) { |
c371fa43 | 509 | channelInfo.setBufferType(BufferType.BUFFER_PER_UID); |
83051fc3 | 510 | } else { |
c371fa43 | 511 | channelInfo.setBufferType(BufferType.BUFFER_TYPE_UNKNOWN); |
83051fc3 | 512 | } |
e799e5f3 | 513 | } |
bbb3538a | 514 | |
c56972bb | 515 | fIsKernel = fKernelButton.getSelection(); |
bbb3538a BH |
516 | |
517 | // Check for invalid names | |
c371fa43 | 518 | if (!channelInfo.getName().matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ |
bbb3538a BH |
519 | MessageDialog.openError(getShell(), |
520 | Messages.TraceControl_EnableChannelDialogTitle, | |
c371fa43 | 521 | Messages.TraceControl_InvalidChannelNameError + " (" + channelInfo.getName() + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ |
bbb3538a BH |
522 | return; |
523 | } | |
524 | ||
525 | // Check for duplicate names | |
c371fa43 | 526 | if (fDomain != null && fDomain.containsChild(channelInfo.getName())) { |
bbb3538a BH |
527 | MessageDialog.openError(getShell(), |
528 | Messages.TraceControl_EnableChannelDialogTitle, | |
c371fa43 | 529 | Messages.TraceControl_ChannelAlreadyExistsError + " (" + channelInfo.getName() + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ |
bbb3538a BH |
530 | return; |
531 | } | |
532 | ||
c371fa43 BH |
533 | fChannelInfo = channelInfo; |
534 | ||
bbb3538a BH |
535 | // validation successful -> call super.okPressed() |
536 | super.okPressed(); | |
537 | } | |
a07c7629 | 538 | |
bbb3538a BH |
539 | @Override |
540 | protected void buttonPressed(int buttonId) { | |
541 | if (buttonId == IDialogConstants.DETAILS_ID) { | |
542 | setDefaults(); | |
543 | return; | |
544 | } | |
545 | super.buttonPressed(buttonId); | |
546 | } | |
547 | ||
548 | // ------------------------------------------------------------------------ | |
549 | // Helper methods | |
550 | // ------------------------------------------------------------------------ | |
11252342 | 551 | |
bbb3538a BH |
552 | /** |
553 | * Sets default value depending on Kernel or UST | |
554 | */ | |
555 | private void setDefaults() { | |
e799e5f3 SD |
556 | fSwitchTimerText.setText(DEFAULT_TEXT); |
557 | fSwitchTimerText.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); | |
558 | fReadTimerText.setText(DEFAULT_TEXT); | |
559 | fReadTimerText.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); | |
bbb3538a | 560 | fOverwriteModeButton.setSelection(IChannelInfo.DEFAULT_OVERWRITE_MODE); |
e799e5f3 SD |
561 | if (fTargetNodeComponent.isTraceFileRotationSupported()) { |
562 | fMaxSizeTraceText.setText(DEFAULT_TEXT); | |
563 | fMaxSizeTraceText.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); | |
564 | fMaxNumberTraceText.setText(DEFAULT_TEXT); | |
565 | fMaxNumberTraceText.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); | |
bbb3538a | 566 | } |
e799e5f3 SD |
567 | fSubBufferSizeText.setText(DEFAULT_TEXT); |
568 | fSubBufferSizeText.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); | |
569 | fNumberOfSubBuffersText.setText(DEFAULT_TEXT); | |
570 | fNumberOfSubBuffersText.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); | |
83051fc3 | 571 | if (fTargetNodeComponent.isBufferTypeConfigSupported()) { |
76fd8d05 | 572 | setBufferTypeButtonSelection(); |
83051fc3 | 573 | } |
bbb3538a | 574 | } |
76fd8d05 BH |
575 | |
576 | private void setBufferTypeButtonSelection() { | |
577 | if ((fDomain != null) && fDomain.getBufferType() != null) { | |
578 | switch (fDomain.getBufferType()) { | |
579 | case BUFFER_PER_PID: | |
580 | fPIDBuffersButton.setSelection(true); | |
581 | break; | |
582 | case BUFFER_PER_UID: | |
583 | fUIDBuffersButton.setSelection(true); | |
584 | break; | |
585 | case BUFFER_SHARED: | |
586 | fSharedBuffersButton.setSelection(true); | |
587 | break; | |
588 | //$CASES-OMITTED$ | |
589 | default: | |
590 | break; | |
591 | } | |
592 | } | |
593 | } | |
594 | ||
bbb3538a | 595 | } |