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