Commit | Line | Data |
---|---|---|
bbb3538a | 1 | /********************************************************************** |
81d5dc3a | 2 | * Copyright (c) 2012, 2014 Ericsson |
f3b33d40 | 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 | |
f3b33d40 BH |
8 | * |
9 | * Contributors: | |
bbb3538a | 10 | * Bernd Hufmann - Initial API and implementation |
ba3a9bd2 | 11 | * Bernd Hufmann - Updated for support of LTTng Tools 2.1 |
81d5dc3a | 12 | * Marc-Andre Laperle - Support for creating a live session |
b732adaa | 13 | * Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE |
bbb3538a | 14 | **********************************************************************/ |
8e8c0226 | 15 | |
9bc60be7 | 16 | package org.eclipse.tracecompass.internal.lttng2.control.ui.views.dialogs; |
bbb3538a | 17 | |
b732adaa MS |
18 | import org.eclipse.core.filesystem.IFileInfo; |
19 | import org.eclipse.core.filesystem.IFileStore; | |
bbb3538a | 20 | import org.eclipse.jface.dialogs.IDialogConstants; |
abb1f9a7 | 21 | import org.eclipse.jface.dialogs.TitleAreaDialog; |
b732adaa | 22 | import org.eclipse.remote.core.IRemoteFileManager; |
bbb3538a | 23 | import org.eclipse.swt.SWT; |
f3b33d40 | 24 | import org.eclipse.swt.custom.CCombo; |
81d5dc3a MAL |
25 | import org.eclipse.swt.events.FocusEvent; |
26 | import org.eclipse.swt.events.FocusListener; | |
a30e79fe BH |
27 | import org.eclipse.swt.events.ModifyEvent; |
28 | import org.eclipse.swt.events.ModifyListener; | |
f3b33d40 BH |
29 | import org.eclipse.swt.events.SelectionAdapter; |
30 | import org.eclipse.swt.events.SelectionEvent; | |
81d5dc3a MAL |
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; | |
f3b33d40 | 35 | import org.eclipse.swt.widgets.Button; |
bbb3538a BH |
36 | import org.eclipse.swt.widgets.Composite; |
37 | import org.eclipse.swt.widgets.Control; | |
f3b33d40 | 38 | import org.eclipse.swt.widgets.Group; |
bbb3538a BH |
39 | import org.eclipse.swt.widgets.Label; |
40 | import org.eclipse.swt.widgets.Shell; | |
41 | import org.eclipse.swt.widgets.Text; | |
9bc60be7 AM |
42 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.ISessionInfo; |
43 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.SessionInfo; | |
44 | import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator; | |
45 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages; | |
46 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent; | |
47 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionGroup; | |
48 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.remote.IRemoteSystemProxy; | |
49 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.service.LTTngControlServiceConstants; | |
bbb3538a BH |
50 | |
51 | /** | |
bbb3538a BH |
52 | * <p> |
53 | * Dialog box for collecting session creation information. | |
54 | * </p> | |
f3b33d40 | 55 | * |
dbd4432d | 56 | * @author Bernd Hufmann |
bbb3538a | 57 | */ |
abb1f9a7 | 58 | public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessionDialog { |
bbb3538a BH |
59 | |
60 | // ------------------------------------------------------------------------ | |
61 | // Constants | |
62 | // ------------------------------------------------------------------------ | |
63 | /** | |
64 | * The icon file for this dialog box. | |
65 | */ | |
f3b33d40 BH |
66 | public static final String CREATE_SESSION_ICON_FILE = "icons/elcl16/add_button.gif"; //$NON-NLS-1$ |
67 | ||
81d5dc3a MAL |
68 | /** |
69 | * To indicate that the default value will be used for this field | |
70 | */ | |
71 | private static final String DEFAULT_TEXT = "<" + Messages.EnableChannelDialog_DefaultMessage + ">"; //$NON-NLS-1$ //$NON-NLS-2$ | |
72 | ||
f3b33d40 BH |
73 | /** |
74 | * Supported network protocols for streaming | |
75 | */ | |
76 | private enum StreamingProtocol { | |
77 | /** Default network protocol for IPv4 (TCP)*/ | |
78 | net, | |
79 | /** Default network protocol for IPv6 (TCP)*/ | |
80 | net6, | |
81 | /** File */ | |
82 | file, | |
83 | } | |
84 | ||
81d5dc3a MAL |
85 | /** |
86 | * Supported network protocols for Live tracing | |
87 | */ | |
88 | private enum LiveProtocol { | |
89 | /** Default network protocol for IPv4 (TCP)*/ | |
90 | net, | |
91 | /** Default network protocol for IPv6 (TCP)*/ | |
92 | net6 | |
93 | } | |
94 | ||
f3b33d40 BH |
95 | private enum StreamingProtocol2 { |
96 | /** Default network protocol for IPv4 (TCP)*/ | |
97 | net, | |
98 | /** Default network protocol for IPv6 (TCP)*/ | |
99 | net6, | |
100 | /** TCP network protocol for IPv4*/ | |
101 | tcp, | |
102 | /** TCP network protocol for IPv6*/ | |
103 | tcp6 } | |
104 | ||
105 | /** | |
106 | * Index of last supported streaming protocol for common URL configuration. | |
107 | */ | |
77735e82 | 108 | private static final int COMMON_URL_LAST_INDEX = 1; |
f3b33d40 BH |
109 | /** |
110 | * Index of default streaming protocol. | |
111 | */ | |
77735e82 | 112 | private static final int DEFAULT_URL_INDEX = 0; |
bbb3538a BH |
113 | |
114 | // ------------------------------------------------------------------------ | |
115 | // Attributes | |
116 | // ------------------------------------------------------------------------ | |
117 | /** | |
118 | * The dialog composite. | |
119 | */ | |
120 | private Composite fDialogComposite = null; | |
121 | /** | |
122 | * The text widget for the session name | |
123 | */ | |
124 | private Text fSessionNameText = null; | |
a30e79fe BH |
125 | /** |
126 | * The label widget for the session path. | |
127 | */ | |
128 | private Label fSessionPathLabel = null; | |
bbb3538a | 129 | /** |
f3b33d40 | 130 | * The text widget for the session path. |
bbb3538a BH |
131 | */ |
132 | private Text fSessionPathText = null; | |
81d5dc3a MAL |
133 | /** |
134 | * The button widget to select a normal session | |
135 | */ | |
136 | private Button fNormalModeButton = null; | |
589d0d33 BH |
137 | /** |
138 | * The button widget to select a snapshot session | |
139 | */ | |
140 | private Button fSnapshotButton = null; | |
f3b33d40 | 141 | /** |
81d5dc3a MAL |
142 | * The group that contains the mutually exclusive mode buttons |
143 | */ | |
144 | private Group fModeButtonGroup = null; | |
145 | /** | |
146 | * The button widget to select a live session | |
f3b33d40 | 147 | */ |
81d5dc3a MAL |
148 | private Button fLiveButton = null; |
149 | ||
150 | /** | |
151 | * The text widget to set a live delay | |
152 | */ | |
153 | private Text fLiveDelayText = null; | |
f3b33d40 | 154 | /** |
81d5dc3a | 155 | * The Group for advanced configuration. |
f3b33d40 | 156 | */ |
81d5dc3a MAL |
157 | private Group fAdvancedGroup = null; |
158 | /** | |
159 | * The button to show advanced options. | |
160 | */ | |
161 | private Button fAdvancedButton = null; | |
f3b33d40 BH |
162 | /** |
163 | * The composite with streaming configuration parameter. | |
164 | */ | |
165 | private Composite fStreamingComposite = null; | |
a30e79fe BH |
166 | /** |
167 | * The text widget for the trace path. | |
168 | */ | |
169 | private Text fTracePathText = null; | |
f3b33d40 BH |
170 | /** |
171 | * The button to link data protocol/Address with control protocol. | |
172 | */ | |
173 | private Button fLinkDataWithControlButton = null; | |
174 | /** | |
175 | * The Combo box for channel protocol selection. | |
176 | */ | |
177 | private CCombo fControlProtocolCombo = null; | |
178 | /** | |
179 | * A selection listener that copies the protocol from control to data when being linked. | |
180 | */ | |
181 | private ControlProtocolSelectionListener fCopyProtocolSelectionListener; | |
a30e79fe BH |
182 | /** |
183 | * A selection listener updates the control port text depending on the control protocol selected. | |
184 | */ | |
f3b33d40 | 185 | private ProtocolComboSelectionListener fControlProtocolSelectionListener; |
a30e79fe BH |
186 | /** |
187 | * A selection listener updates the data port text depending on the data protocol selected. | |
188 | */ | |
f3b33d40 | 189 | private ProtocolComboSelectionListener fDataProtocolSelectionListener; |
f3b33d40 BH |
190 | /** |
191 | * The text box for the host/IP address of the control channel. | |
192 | */ | |
193 | private Text fControlHostAddressText = null; | |
194 | /** | |
195 | * A key listener that copies the host address from control to data when being linked. | |
196 | */ | |
a30e79fe | 197 | private CopyModifyListener fControlUrlKeyListener; |
abb1f9a7 MAL |
198 | /** |
199 | * A modify listener that updates the enablement of the dialog. | |
200 | */ | |
201 | private UpdateEnablementModifyListener fUpdateEnablementModifyListener; | |
f3b33d40 BH |
202 | /** |
203 | * The text box for the control port. | |
204 | */ | |
205 | private Text fControlPortText = null; | |
206 | /** | |
207 | * The Combo box for data protocol selection. | |
208 | */ | |
209 | private CCombo fDataProtocolCombo = null; | |
210 | /** | |
211 | * The text box for the host/IP address of the data channel. | |
212 | */ | |
213 | private Text fDataHostAddressText = null; | |
214 | /** | |
215 | * The text box for the data port. | |
216 | */ | |
217 | private Text fDataPortText = null; | |
bbb3538a BH |
218 | /** |
219 | * The parent where the new node should be added. | |
220 | */ | |
c56972bb | 221 | private TraceSessionGroup fParent = null; |
bbb3538a BH |
222 | /** |
223 | * The session name string. | |
224 | */ | |
aa254866 | 225 | private String fSessionName = ""; //$NON-NLS-1$; |
bbb3538a BH |
226 | /** |
227 | * The session path string. | |
228 | */ | |
229 | private String fSessionPath = null; | |
589d0d33 | 230 | /** |
abb1f9a7 | 231 | * Flag whether the session is snapshot or not |
589d0d33 BH |
232 | */ |
233 | private boolean fIsSnapshot = false; | |
81d5dc3a MAL |
234 | /** |
235 | * Flag whether the session is live or not | |
236 | */ | |
237 | private boolean fIsLive = false; | |
6fd3c6e9 MAL |
238 | /** |
239 | * The text box for the live address (relayd). | |
240 | */ | |
241 | private Text fLiveHostAddressText = null; | |
242 | /** | |
243 | * The text box for the live port (relayd). | |
244 | */ | |
245 | private Text fLivePortText = null; | |
81d5dc3a MAL |
246 | /** |
247 | * The live delay | |
248 | */ | |
249 | private Integer fLiveDelay = 0; | |
6fd3c6e9 MAL |
250 | /** |
251 | * The live url. | |
252 | */ | |
253 | private String fLiveUrl = null; | |
254 | /** | |
255 | * The live port. | |
256 | */ | |
257 | private Integer fLivePort = 0; | |
bbb3538a BH |
258 | /** |
259 | * Flag whether default location (path) shall be used or not | |
260 | */ | |
261 | private boolean fIsDefaultPath = true; | |
f3b33d40 | 262 | /** |
81d5dc3a | 263 | * Flag whether the advanced options are enabled or not |
f3b33d40 | 264 | */ |
81d5dc3a | 265 | private boolean fIsAdvancedEnabled = false; |
f3b33d40 BH |
266 | /** |
267 | * The network URL in case control and data is configured together. | |
268 | * If set, fControlUrl and fDataUrl will be null. | |
269 | */ | |
270 | private String fNetworkUrl = null; | |
271 | /** | |
272 | * The control URL in case control and data is configured separately. | |
273 | * If set, fDataUrl will be set too and fNetworkUrl will be null. | |
274 | */ | |
275 | private String fControlUrl = null; | |
276 | /** | |
277 | * The data URL in case control and data is configured separately. | |
278 | * If set, fControlUrl will be set too and fNetworkUrl will be null. | |
279 | */ | |
280 | private String fDataUrl = null; | |
281 | /** | |
a30e79fe | 282 | * The trace path string. |
f3b33d40 | 283 | */ |
a30e79fe | 284 | private String fTracePath = null; |
81d5dc3a MAL |
285 | /** |
286 | * The Group for advanced configuration of Live mode. | |
287 | */ | |
288 | private Group fLiveGroup = null; | |
bbb3538a BH |
289 | |
290 | // ------------------------------------------------------------------------ | |
291 | // Constructors | |
292 | // ------------------------------------------------------------------------ | |
293 | /** | |
294 | * Constructor | |
295 | * @param shell - a shell for the display of the dialog | |
bbb3538a | 296 | */ |
d132bcc7 | 297 | public CreateSessionDialog(Shell shell) { |
bbb3538a | 298 | super(shell); |
8a396998 | 299 | setShellStyle(SWT.RESIZE | getShellStyle()); |
bbb3538a BH |
300 | } |
301 | ||
302 | // ------------------------------------------------------------------------ | |
303 | // Accessors | |
304 | // ------------------------------------------------------------------------ | |
11252342 | 305 | |
d132bcc7 | 306 | @Override |
f3b33d40 BH |
307 | public void initialize(TraceSessionGroup group) { |
308 | fParent = group; | |
309 | fStreamingComposite = null; | |
81d5dc3a MAL |
310 | fLiveGroup = null; |
311 | fLiveButton = null; | |
312 | fIsLive = false; | |
313 | fSnapshotButton = null; | |
aa254866 | 314 | fSessionName = ""; //$NON-NLS-1$ |
f3b33d40 | 315 | fSessionPath = null; |
589d0d33 | 316 | fIsSnapshot = false; |
f3b33d40 | 317 | fIsDefaultPath = true; |
81d5dc3a | 318 | fIsAdvancedEnabled = false; |
f3b33d40 BH |
319 | fNetworkUrl = null; |
320 | fControlUrl = null; | |
321 | fDataUrl = null; | |
f3b33d40 | 322 | } |
bbb3538a BH |
323 | // ------------------------------------------------------------------------ |
324 | // Operations | |
325 | // ------------------------------------------------------------------------ | |
f3b33d40 | 326 | |
bbb3538a BH |
327 | @Override |
328 | protected void configureShell(Shell newShell) { | |
329 | super.configureShell(newShell); | |
330 | newShell.setText(Messages.TraceControl_CreateSessionDialogTitle); | |
31a6a4e4 | 331 | newShell.setImage(Activator.getDefault().loadIcon(CREATE_SESSION_ICON_FILE)); |
bbb3538a BH |
332 | } |
333 | ||
bbb3538a BH |
334 | @Override |
335 | protected Control createDialogArea(Composite parent) { | |
abb1f9a7 MAL |
336 | Composite dialogAreaa = (Composite) super.createDialogArea(parent); |
337 | setTitle(Messages.TraceControl_CreateSessionDialogTitle); | |
338 | setMessage(Messages.TraceControl_CreateSessionDialogMessage); | |
f3b33d40 | 339 | |
bbb3538a | 340 | // Main dialog panel |
abb1f9a7 | 341 | fDialogComposite = new Composite(dialogAreaa, SWT.NONE); |
f3b33d40 | 342 | GridLayout layout = new GridLayout(1, true); |
5f1f22f8 BH |
343 | fDialogComposite.setLayout(layout); |
344 | fDialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); | |
bbb3538a | 345 | |
f3b33d40 BH |
346 | Group sessionGroup = new Group(fDialogComposite, SWT.SHADOW_NONE); |
347 | sessionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); | |
348 | sessionGroup.setLayout(new GridLayout(4, true)); | |
349 | ||
abb1f9a7 MAL |
350 | fUpdateEnablementModifyListener = new UpdateEnablementModifyListener(); |
351 | ||
f3b33d40 | 352 | Label sessionNameLabel = new Label(sessionGroup, SWT.RIGHT); |
bbb3538a | 353 | sessionNameLabel.setText(Messages.TraceControl_CreateSessionNameLabel); |
f3b33d40 | 354 | fSessionNameText = new Text(sessionGroup, SWT.NONE); |
bbb3538a | 355 | fSessionNameText.setToolTipText(Messages.TraceControl_CreateSessionNameTooltip); |
abb1f9a7 | 356 | fSessionNameText.addModifyListener(fUpdateEnablementModifyListener); |
81d5dc3a MAL |
357 | GridData data = new GridData(GridData.FILL_HORIZONTAL); |
358 | data.horizontalSpan = 3; | |
359 | fSessionNameText.setLayoutData(data); | |
f3b33d40 | 360 | |
a30e79fe BH |
361 | fSessionPathLabel = new Label(sessionGroup, SWT.RIGHT); |
362 | fSessionPathLabel.setText(Messages.TraceControl_CreateSessionPathLabel); | |
f3b33d40 | 363 | fSessionPathText = new Text(sessionGroup, SWT.NONE); |
bbb3538a | 364 | fSessionPathText.setToolTipText(Messages.TraceControl_CreateSessionPathTooltip); |
81d5dc3a MAL |
365 | data = new GridData(GridData.FILL_HORIZONTAL); |
366 | data.horizontalSpan = 3; | |
367 | fSessionPathText.setLayoutData(data); | |
abb1f9a7 | 368 | fSessionPathText.addModifyListener(fUpdateEnablementModifyListener); |
bbb3538a | 369 | |
81d5dc3a MAL |
370 | if (fParent.isSnapshotSupported() || fParent.isLiveSupported()) { |
371 | fModeButtonGroup = new Group(sessionGroup, SWT.NONE); | |
372 | data = new GridData(GridData.FILL_HORIZONTAL); | |
589d0d33 | 373 | data.horizontalSpan = 4; |
81d5dc3a MAL |
374 | fModeButtonGroup.setLayoutData(data); |
375 | fModeButtonGroup.setLayout(new GridLayout(3, true)); | |
376 | ||
377 | SelectionAdapter modeChangedListener = new SelectionAdapter() { | |
56254dd4 BH |
378 | @Override |
379 | public void widgetSelected(SelectionEvent e) { | |
81d5dc3a MAL |
380 | if (fLiveButton != null) { |
381 | if (fLiveButton.getSelection()) { | |
382 | createAdvancedLiveGroup(); | |
383 | updateSessionPathEnablement(); | |
384 | updateProtocolComboItems(); | |
385 | } else { | |
386 | disposeLiveGroup(); | |
387 | updateSessionPathEnablement(); | |
388 | updateProtocolComboItems(); | |
389 | } | |
390 | } | |
56254dd4 BH |
391 | updateEnablement(); |
392 | } | |
81d5dc3a MAL |
393 | }; |
394 | ||
395 | fNormalModeButton = new Button(fModeButtonGroup, SWT.RADIO); | |
396 | fNormalModeButton.setText(Messages.TraceControl_CreateSessionNormalLabel); | |
397 | fNormalModeButton.setToolTipText(Messages.TraceControl_CreateSessionNormalTooltip); | |
398 | fNormalModeButton.setSelection(true); | |
399 | fNormalModeButton.addSelectionListener(modeChangedListener); | |
400 | ||
401 | if (fParent.isSnapshotSupported()) { | |
402 | fSnapshotButton = new Button(fModeButtonGroup, SWT.RADIO); | |
403 | fSnapshotButton.setText(Messages.TraceControl_CreateSessionSnapshotLabel); | |
404 | fSnapshotButton.setToolTipText(Messages.TraceControl_CreateSessionSnapshotTooltip); | |
405 | fSnapshotButton.addSelectionListener(modeChangedListener); | |
406 | } | |
f3b33d40 | 407 | |
81d5dc3a MAL |
408 | if (fParent.isLiveSupported()) { |
409 | fLiveButton = new Button(fModeButtonGroup, SWT.RADIO); | |
410 | fLiveButton.setText(Messages.TraceControl_CreateSessionLiveLabel); | |
411 | fLiveButton.setToolTipText(Messages.TraceControl_CreateSessionLiveTooltip); | |
412 | fLiveButton.addSelectionListener(modeChangedListener); | |
413 | } | |
414 | } | |
bbb3538a | 415 | |
81d5dc3a | 416 | if (fParent.isNetworkStreamingSupported() || fParent.isLiveSupported()) { |
f3b33d40 BH |
417 | createAdvancedOptionsComposite(); |
418 | } | |
419 | ||
bbb3538a BH |
420 | return fDialogComposite; |
421 | } | |
422 | ||
f3b33d40 BH |
423 | private void createAdvancedOptionsComposite() { |
424 | ||
81d5dc3a MAL |
425 | fAdvancedGroup = new Group(fDialogComposite, SWT.SHADOW_NONE); |
426 | fAdvancedGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); | |
427 | fAdvancedGroup.setLayout(new GridLayout(1, true)); | |
f3b33d40 | 428 | |
81d5dc3a MAL |
429 | fAdvancedButton = new Button(fAdvancedGroup, SWT.PUSH); |
430 | fAdvancedButton.setText(Messages.TraceControl_CreateSessionConfigureStreamingButtonText + " >>>"); //$NON-NLS-1$ | |
431 | fAdvancedButton.setToolTipText(Messages.TraceControl_CreateSessionConfigureStreamingButtonTooltip); | |
432 | fAdvancedButton.addSelectionListener(new SelectionAdapter() { | |
f3b33d40 BH |
433 | @Override |
434 | public void widgetSelected(SelectionEvent e) { | |
81d5dc3a MAL |
435 | if (fIsAdvancedEnabled) { |
436 | fIsAdvancedEnabled = false; | |
437 | fAdvancedButton.setText(">>> " + Messages.TraceControl_CreateSessionConfigureStreamingButtonText); //$NON-NLS-1$ | |
438 | fAdvancedButton.setToolTipText(Messages.TraceControl_CreateSessionConfigureStreamingButtonTooltip); | |
439 | ||
440 | if (fParent.isNetworkStreamingSupported()) { | |
441 | updateSessionPathEnablement(); | |
442 | disposeConfigureStreamingComposite(); | |
443 | } | |
444 | ||
445 | if (fParent.isLiveSupported()) { | |
446 | disposeLiveGroup(); | |
447 | } | |
f3b33d40 | 448 | } else { |
81d5dc3a MAL |
449 | fIsAdvancedEnabled = true; |
450 | fAdvancedButton.setText("<<< " + Messages.TraceControl_CreateSessionNoStreamingButtonText); //$NON-NLS-1$ | |
451 | fAdvancedButton.setToolTipText(Messages.TraceControl_CreateSessionNoStreamingButtonTooltip); | |
452 | ||
453 | if (fParent.isNetworkStreamingSupported()) { | |
454 | updateSessionPathEnablement(); | |
455 | createConfigureStreamingComposite(); | |
456 | } | |
457 | if (fLiveButton != null && fLiveButton.getSelection()) { | |
458 | createAdvancedLiveGroup(); | |
459 | } | |
f3b33d40 BH |
460 | } |
461 | ||
abb1f9a7 MAL |
462 | updateEnablement(); |
463 | getShell().pack(); | |
f3b33d40 BH |
464 | } |
465 | }); | |
466 | } | |
467 | ||
81d5dc3a MAL |
468 | private void updateSessionPathEnablement() { |
469 | if (fIsAdvancedEnabled || fIsLive) { | |
470 | fSessionPathText.setEnabled(false); | |
471 | fSessionPathText.setText(""); //$NON-NLS-1$ | |
472 | fSessionPathLabel.setText(""); //$NON-NLS-1$ | |
473 | } else { | |
474 | fSessionPathText.setEnabled(true); | |
475 | fSessionPathLabel.setText(Messages.TraceControl_CreateSessionPathLabel); | |
476 | } | |
477 | } | |
478 | ||
479 | private void updateProtocolComboItems() { | |
480 | if (fControlProtocolCombo == null || fControlProtocolCombo.isDisposed()) { | |
481 | return; | |
482 | } | |
483 | ||
484 | int currentSelection = fControlProtocolCombo.getSelectionIndex() <= COMMON_URL_LAST_INDEX ? | |
485 | fControlProtocolCombo.getSelectionIndex() : DEFAULT_URL_INDEX; | |
486 | ||
487 | fControlProtocolCombo.removeAll(); | |
488 | Enum<? extends Enum<?>>[] values; | |
489 | if (fIsLive) { | |
490 | values = LiveProtocol.values(); | |
491 | } else if (fLinkDataWithControlButton.getSelection()) { | |
492 | values = StreamingProtocol.values(); | |
493 | } else { | |
494 | values = StreamingProtocol2.values(); | |
495 | } | |
496 | ||
497 | String[] controlItems = new String[values.length]; | |
498 | for (int i = 0; i < controlItems.length; i++) { | |
499 | controlItems[i] = values[i].name(); | |
500 | } | |
501 | fControlProtocolCombo.setItems(controlItems); | |
502 | fDataProtocolCombo.setItems(controlItems); | |
503 | ||
504 | // Set selection | |
505 | if (currentSelection != -1) { | |
506 | fControlProtocolCombo.select(currentSelection); | |
507 | fDataProtocolCombo.select(currentSelection); | |
508 | } | |
509 | } | |
510 | ||
f3b33d40 BH |
511 | private void createConfigureStreamingComposite() { |
512 | if (fStreamingComposite == null) { | |
81d5dc3a | 513 | fStreamingComposite = new Group(fAdvancedGroup, SWT.SHADOW_NONE); |
f3b33d40 BH |
514 | GridLayout layout = new GridLayout(1, true); |
515 | fStreamingComposite.setLayout(layout); | |
516 | fStreamingComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); | |
517 | ||
f3b33d40 | 518 | layout = new GridLayout(7, true); |
81d5dc3a MAL |
519 | fStreamingComposite.setLayout(layout); |
520 | fStreamingComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); | |
f3b33d40 | 521 | |
81d5dc3a | 522 | Label tracePathLabel = new Label(fStreamingComposite, SWT.RIGHT); |
a30e79fe | 523 | tracePathLabel.setText(Messages.TraceControl_CreateSessionTracePathText); |
81d5dc3a | 524 | fTracePathText = new Text(fStreamingComposite, SWT.NONE); |
a30e79fe BH |
525 | fTracePathText.setToolTipText(Messages.TraceControl_CreateSessionTracePathTooltip); |
526 | ||
527 | // layout widgets | |
528 | GridData data = new GridData(GridData.FILL_HORIZONTAL); | |
529 | data.horizontalSpan = 6; | |
530 | fTracePathText.setLayoutData(data); | |
abb1f9a7 | 531 | fTracePathText.addModifyListener(fUpdateEnablementModifyListener); |
a30e79fe | 532 | |
81d5dc3a | 533 | fLinkDataWithControlButton = new Button(fStreamingComposite, SWT.CHECK); |
f3b33d40 BH |
534 | fLinkDataWithControlButton.setText(Messages.TraceControl_CreateSessionLinkButtonText); |
535 | fLinkDataWithControlButton.setToolTipText(Messages.TraceControl_CreateSessionLinkButtonTooltip); | |
a30e79fe | 536 | data = new GridData(GridData.FILL_HORIZONTAL); |
f3b33d40 BH |
537 | data.horizontalSpan = 7; |
538 | fLinkDataWithControlButton.setLayoutData(data); | |
539 | fLinkDataWithControlButton.setSelection(true); | |
540 | ||
81d5dc3a | 541 | Label label = new Label(fStreamingComposite, SWT.NONE); |
f3b33d40 BH |
542 | data = new GridData(GridData.FILL_HORIZONTAL); |
543 | data.horizontalSpan = 1; | |
544 | label.setLayoutData(data); | |
545 | ||
81d5dc3a | 546 | label = new Label(fStreamingComposite, SWT.NONE); |
f3b33d40 BH |
547 | label.setText(Messages.TraceControl_CreateSessionProtocolLabelText); |
548 | data = new GridData(GridData.FILL_HORIZONTAL); | |
549 | data.horizontalSpan = 1; | |
550 | label.setLayoutData(data); | |
551 | ||
81d5dc3a | 552 | label = new Label(fStreamingComposite, SWT.NONE); |
f3b33d40 BH |
553 | label.setText(Messages.TraceControl_CreateSessionAddressLabelText); |
554 | data = new GridData(GridData.FILL_HORIZONTAL); | |
555 | data.horizontalSpan = 4; | |
556 | label.setLayoutData(data); | |
557 | ||
81d5dc3a | 558 | label = new Label(fStreamingComposite, SWT.NONE); |
f3b33d40 BH |
559 | label.setText(Messages.TraceControl_CreateSessionPortLabelText); |
560 | data = new GridData(GridData.FILL_HORIZONTAL); | |
561 | data.horizontalSpan = 1; | |
562 | label.setLayoutData(data); | |
563 | ||
81d5dc3a | 564 | label = new Label(fStreamingComposite, SWT.RIGHT); |
f3b33d40 BH |
565 | label.setText(Messages.TraceControl_CreateSessionControlUrlLabel); |
566 | data = new GridData(GridData.FILL_HORIZONTAL); | |
567 | data.horizontalSpan = 1; | |
568 | label.setLayoutData(data); | |
569 | ||
81d5dc3a | 570 | fControlProtocolCombo = new CCombo(fStreamingComposite, SWT.READ_ONLY); |
f3b33d40 BH |
571 | fControlProtocolCombo.setToolTipText(Messages.TraceControl_CreateSessionCommonProtocolTooltip); |
572 | data = new GridData(GridData.FILL_HORIZONTAL); | |
573 | data.horizontalSpan = 1; | |
574 | fControlProtocolCombo.setLayoutData(data); | |
abb1f9a7 | 575 | fControlProtocolCombo.addModifyListener(fUpdateEnablementModifyListener); |
f3b33d40 | 576 | |
81d5dc3a | 577 | fControlHostAddressText = new Text(fStreamingComposite, SWT.NONE); |
f3b33d40 BH |
578 | fControlHostAddressText.setToolTipText(Messages.TraceControl_CreateSessionControlAddressTooltip); |
579 | data = new GridData(GridData.FILL_HORIZONTAL); | |
580 | data.horizontalSpan = 4; | |
581 | fControlHostAddressText.setLayoutData(data); | |
abb1f9a7 | 582 | fControlHostAddressText.addModifyListener(fUpdateEnablementModifyListener); |
f3b33d40 | 583 | |
81d5dc3a | 584 | fControlPortText = new Text(fStreamingComposite, SWT.NONE); |
f3b33d40 BH |
585 | fControlPortText.setToolTipText(Messages.TraceControl_CreateSessionControlPortTooltip); |
586 | data = new GridData(GridData.FILL_HORIZONTAL); | |
587 | data.horizontalSpan = 1; | |
588 | fControlPortText.setLayoutData(data); | |
abb1f9a7 | 589 | fControlPortText.addModifyListener(fUpdateEnablementModifyListener); |
f3b33d40 | 590 | |
81d5dc3a | 591 | label = new Label(fStreamingComposite, SWT.RIGHT); |
f3b33d40 BH |
592 | label.setText(Messages.TraceControl_CreateSessionDataUrlLabel); |
593 | data = new GridData(GridData.FILL_HORIZONTAL); | |
594 | data.horizontalSpan = 1; | |
595 | label.setLayoutData(data); | |
596 | ||
81d5dc3a | 597 | fDataProtocolCombo = new CCombo(fStreamingComposite, SWT.READ_ONLY); |
f3b33d40 BH |
598 | fDataProtocolCombo.setEnabled(false); |
599 | fDataProtocolCombo.setToolTipText(Messages.TraceControl_CreateSessionProtocolTooltip); | |
600 | data = new GridData(GridData.FILL_HORIZONTAL); | |
601 | data.horizontalSpan = 1; | |
602 | fDataProtocolCombo.setLayoutData(data); | |
abb1f9a7 | 603 | fDataProtocolCombo.addModifyListener(fUpdateEnablementModifyListener); |
f3b33d40 | 604 | |
81d5dc3a | 605 | updateProtocolComboItems(); |
f3b33d40 | 606 | |
81d5dc3a | 607 | fDataHostAddressText = new Text(fStreamingComposite, SWT.NONE); |
f3b33d40 BH |
608 | fDataHostAddressText.setEnabled(false); |
609 | fDataHostAddressText.setToolTipText(Messages.TraceControl_CreateSessionDataAddressTooltip); | |
610 | data = new GridData(GridData.FILL_HORIZONTAL); | |
611 | data.horizontalSpan = 4; | |
612 | fDataHostAddressText.setLayoutData(data); | |
abb1f9a7 | 613 | fDataHostAddressText.addModifyListener(fUpdateEnablementModifyListener); |
f3b33d40 | 614 | |
81d5dc3a | 615 | fDataPortText = new Text(fStreamingComposite, SWT.NONE); |
f3b33d40 BH |
616 | fDataPortText.setEnabled(true); |
617 | fDataPortText.setToolTipText(Messages.TraceControl_CreateSessionDataPortTooltip); | |
618 | data = new GridData(GridData.FILL_HORIZONTAL); | |
619 | data.horizontalSpan = 1; | |
620 | fDataPortText.setLayoutData(data); | |
abb1f9a7 | 621 | fDataPortText.addModifyListener(fUpdateEnablementModifyListener); |
f3b33d40 BH |
622 | |
623 | fCopyProtocolSelectionListener = new ControlProtocolSelectionListener(); | |
624 | fControlProtocolSelectionListener = new ProtocolComboSelectionListener(fControlProtocolCombo, fControlPortText); | |
625 | fDataProtocolSelectionListener = new ProtocolComboSelectionListener(fDataProtocolCombo, fDataPortText); | |
626 | ||
627 | fControlProtocolCombo.addSelectionListener(fCopyProtocolSelectionListener); | |
628 | ||
a30e79fe BH |
629 | fControlUrlKeyListener = new CopyModifyListener(fControlHostAddressText, fDataHostAddressText); |
630 | fControlHostAddressText.addModifyListener(fControlUrlKeyListener); | |
631 | ||
f3b33d40 BH |
632 | fControlProtocolCombo.select(DEFAULT_URL_INDEX); |
633 | fDataProtocolCombo.select(DEFAULT_URL_INDEX); | |
634 | ||
635 | fLinkDataWithControlButton.addSelectionListener(new SelectionAdapter() { | |
636 | @Override | |
637 | public void widgetSelected(SelectionEvent e) { | |
638 | if (fLinkDataWithControlButton.getSelection()) { | |
639 | // Set enablement control data channel inputs | |
640 | fDataProtocolCombo.setEnabled(false); | |
641 | fDataHostAddressText.setEnabled(false); | |
642 | fControlPortText.setEnabled(true); | |
643 | fDataPortText.setEnabled(true); | |
644 | ||
645 | // Update listeners | |
646 | fControlProtocolCombo.removeSelectionListener(fControlProtocolSelectionListener); | |
647 | fDataProtocolCombo.removeSelectionListener(fDataProtocolSelectionListener); | |
648 | fControlProtocolCombo.addSelectionListener(fCopyProtocolSelectionListener); | |
a30e79fe | 649 | fControlHostAddressText.addModifyListener(fControlUrlKeyListener); |
f3b33d40 | 650 | |
81d5dc3a | 651 | updateProtocolComboItems(); |
f3b33d40 | 652 | |
f3b33d40 BH |
653 | fDataHostAddressText.setText(fControlHostAddressText.getText()); |
654 | ||
655 | // Update tool tips | |
656 | fControlProtocolCombo.setToolTipText(Messages.TraceControl_CreateSessionCommonProtocolTooltip); | |
657 | } else { | |
658 | // Enable data channel inputs | |
659 | fDataProtocolCombo.setEnabled(true); | |
660 | fDataHostAddressText.setEnabled(true); | |
661 | ||
662 | // Update listeners | |
663 | fControlProtocolCombo.removeSelectionListener(fCopyProtocolSelectionListener); | |
664 | fControlProtocolCombo.addSelectionListener(fControlProtocolSelectionListener); | |
665 | fDataProtocolCombo.addSelectionListener(fDataProtocolSelectionListener); | |
a30e79fe | 666 | fControlHostAddressText.removeModifyListener(fControlUrlKeyListener); |
f3b33d40 | 667 | |
81d5dc3a | 668 | updateProtocolComboItems(); |
f3b33d40 BH |
669 | |
670 | // Update tool tips | |
671 | fDataProtocolCombo.setToolTipText(Messages.TraceControl_CreateSessionProtocolTooltip); | |
672 | fControlProtocolCombo.setToolTipText(Messages.TraceControl_CreateSessionProtocolTooltip); | |
673 | ||
674 | // Update control/data port enablement and input | |
675 | if (fControlProtocolCombo.getItem(fControlProtocolCombo.getSelectionIndex()).equals(StreamingProtocol.net.name()) || | |
676 | fControlProtocolCombo.getItem(fControlProtocolCombo.getSelectionIndex()).equals(StreamingProtocol.net6.name())) { | |
677 | fControlPortText.setText(""); //$NON-NLS-1$ | |
678 | fControlPortText.setEnabled(false); | |
679 | } else { | |
680 | fControlPortText.setEnabled(true); | |
681 | } | |
682 | ||
683 | if (fDataProtocolCombo.getItem(fDataProtocolCombo.getSelectionIndex()).equals(StreamingProtocol.net.name()) || | |
684 | fDataProtocolCombo.getItem(fDataProtocolCombo.getSelectionIndex()).equals(StreamingProtocol.net6.name())) { | |
685 | fDataPortText.setText(""); //$NON-NLS-1$ | |
686 | fDataPortText.setEnabled(false); | |
687 | } else { | |
688 | fDataPortText.setEnabled(true); | |
689 | } | |
690 | } | |
691 | } | |
692 | }); | |
693 | } | |
694 | } | |
695 | ||
81d5dc3a MAL |
696 | private void createAdvancedLiveGroup() { |
697 | if (fLiveGroup == null && fIsAdvancedEnabled) { | |
698 | GridLayout layout = new GridLayout(7, true); | |
699 | fLiveGroup = new Group(fAdvancedGroup, SWT.NONE); | |
700 | fLiveGroup.setLayout(layout); | |
701 | GridData layoutData = new GridData(GridData.FILL_BOTH); | |
702 | fLiveGroup.setLayoutData(layoutData); | |
703 | ||
6fd3c6e9 MAL |
704 | Label label = new Label(fLiveGroup, SWT.NONE); |
705 | label.setText(Messages.TraceControl_CreateSessionLiveConnectionLabel); | |
706 | layoutData = new GridData(GridData.FILL_HORIZONTAL); | |
707 | layoutData.horizontalSpan = 2; | |
708 | label.setLayoutData(layoutData); | |
709 | ||
710 | fLiveHostAddressText = new Text(fLiveGroup, SWT.NONE); | |
92fe6900 | 711 | fLiveHostAddressText.setText(SessionInfo.DEFAULT_LIVE_NETWORK_URL); |
6fd3c6e9 MAL |
712 | fLiveHostAddressText.setEnabled(false); |
713 | fLiveHostAddressText.setToolTipText(Messages.TraceControl_CreateSessionLiveConnectionUrlTooltip); | |
714 | layoutData = new GridData(GridData.FILL_HORIZONTAL); | |
715 | layoutData.horizontalSpan = 4; | |
716 | fLiveHostAddressText.setLayoutData(layoutData); | |
717 | ||
718 | fLivePortText = new Text(fLiveGroup, SWT.NONE); | |
92fe6900 | 719 | fLivePortText.setText(Integer.toString(SessionInfo.DEFAULT_LIVE_PORT)); |
6fd3c6e9 MAL |
720 | fLivePortText.setToolTipText(Messages.TraceControl_CreateSessionLiveConnectionPortTooltip); |
721 | layoutData = new GridData(GridData.FILL_HORIZONTAL); | |
722 | fLivePortText.setLayoutData(layoutData); | |
723 | ||
724 | Label liveDelayLabel = new Label(fLiveGroup, SWT.NONE); | |
81d5dc3a MAL |
725 | layoutData = new GridData(GridData.FILL_HORIZONTAL); |
726 | liveDelayLabel.setText(Messages.TraceControl_CreateSessionLiveDelayLabel); | |
727 | liveDelayLabel.setLayoutData(layoutData); | |
728 | fLiveDelayText = new Text(fLiveGroup, SWT.NONE); | |
729 | fLiveDelayText.setText(DEFAULT_TEXT); | |
730 | fLiveDelayText.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); | |
731 | fLiveDelayText.setToolTipText(Messages.TraceControl_CreateSessionLiveDelayTooltip); | |
732 | fLiveDelayText.addVerifyListener(new VerifyListener() { | |
733 | @Override | |
734 | public void verifyText(VerifyEvent e) { | |
735 | // only numbers and default are allowed. | |
736 | e.doit = e.text.matches("[0-9]*") || e.text.matches(DEFAULT_TEXT); //$NON-NLS-1$ | |
737 | updateEnablement(); | |
738 | } | |
739 | }); | |
740 | fLiveDelayText.addModifyListener(new ModifyListener() { | |
741 | @Override | |
742 | public void modifyText(ModifyEvent event) { | |
743 | updateEnablement(); | |
744 | } | |
745 | }); | |
746 | ||
747 | fLiveDelayText.addFocusListener(new FocusListener() { | |
748 | ||
749 | @Override | |
750 | public void focusLost(FocusEvent e) { | |
751 | Text focusLostWidget = (Text) e.widget; | |
752 | if (focusLostWidget.getText().isEmpty()) { | |
753 | focusLostWidget.setText(DEFAULT_TEXT); | |
754 | focusLostWidget.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); | |
755 | } | |
756 | } | |
757 | ||
758 | @Override | |
759 | public void focusGained(FocusEvent e) { | |
760 | Text focusGainedWidget = (Text) e.widget; | |
761 | if (focusGainedWidget.getText().equals(DEFAULT_TEXT)) { | |
762 | focusGainedWidget.setText(""); //$NON-NLS-1$ | |
763 | focusGainedWidget.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_BLACK)); | |
764 | } | |
765 | } | |
766 | }); | |
767 | ||
768 | layoutData = new GridData(GridData.FILL_HORIZONTAL); | |
769 | layoutData.grabExcessHorizontalSpace = true; | |
770 | layoutData.horizontalSpan = 6; | |
771 | fLiveDelayText.setLayoutData(layoutData); | |
772 | getShell().pack(); | |
773 | } | |
774 | } | |
775 | ||
776 | private void disposeLiveGroup() { | |
777 | if (fLiveGroup != null) { | |
778 | fLiveGroup.dispose(); | |
779 | fLiveGroup = null; | |
780 | getShell().pack(); | |
781 | } | |
782 | } | |
783 | ||
f3b33d40 BH |
784 | private void disposeConfigureStreamingComposite() { |
785 | if (fStreamingComposite != null) { | |
786 | fStreamingComposite.dispose(); | |
787 | fStreamingComposite = null; | |
788 | } | |
789 | } | |
790 | ||
bbb3538a BH |
791 | @Override |
792 | protected void createButtonsForButtonBar(Composite parent) { | |
79c3db85 | 793 | createButton(parent, IDialogConstants.CANCEL_ID, "&Cancel", true); //$NON-NLS-1$ |
bbb3538a BH |
794 | createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$ |
795 | } | |
796 | ||
abb1f9a7 MAL |
797 | private void updateEnablement() { |
798 | validate(); | |
799 | getButton(IDialogConstants.OK_ID).setEnabled(getErrorMessage() == null); | |
800 | } | |
801 | ||
802 | private void validate() { | |
bbb3538a BH |
803 | // Validate input data |
804 | fSessionName = fSessionNameText.getText(); | |
805 | fSessionPath = fSessionPathText.getText(); | |
abb1f9a7 | 806 | setErrorMessage(null); |
bbb3538a | 807 | |
81d5dc3a MAL |
808 | if (fParent.isLiveSupported() && fLiveButton != null) { |
809 | fIsLive = fLiveButton.getSelection(); | |
810 | fLiveDelay = LTTngControlServiceConstants.UNUSED_VALUE; | |
92fe6900 MAL |
811 | fLiveUrl = SessionInfo.DEFAULT_LIVE_NETWORK_URL; |
812 | fLivePort = SessionInfo.DEFAULT_LIVE_PORT; | |
81d5dc3a MAL |
813 | } |
814 | ||
bbb3538a BH |
815 | if (!"".equals(fSessionPath)) { //$NON-NLS-1$ |
816 | // validate sessionPath | |
81d5dc3a | 817 | if (!fIsAdvancedEnabled && !fIsLive) { |
f3b33d40 BH |
818 | TargetNodeComponent node = (TargetNodeComponent)fParent.getParent(); |
819 | IRemoteSystemProxy proxy = node.getRemoteSystemProxy(); | |
b732adaa | 820 | IRemoteFileManager fsss = proxy.getFileServiceSubSystem(); |
f3b33d40 | 821 | if (fsss != null) { |
b732adaa MS |
822 | IFileStore remoteFolder = fsss.getResource(fSessionPath); |
823 | if (remoteFolder == null) { | |
824 | setErrorMessage(Messages.TraceControl_InvalidSessionPathError + " (" + fSessionPath + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ | |
825 | return; | |
826 | } | |
827 | IFileInfo fileInfo = remoteFolder.fetchInfo(); | |
828 | if (fileInfo.exists()) { | |
829 | setErrorMessage(Messages.TraceControl_SessionPathAlreadyExistsError + " (" + fSessionPath + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ | |
bbb3538a BH |
830 | return; |
831 | } | |
f3b33d40 | 832 | } |
bbb3538a BH |
833 | } |
834 | fIsDefaultPath = false; | |
835 | } | |
836 | ||
abb1f9a7 | 837 | if (fParent.isSnapshotSupported()) { |
589d0d33 BH |
838 | fIsSnapshot = fSnapshotButton.getSelection(); |
839 | } | |
840 | ||
f3b33d40 BH |
841 | fNetworkUrl = null; |
842 | fControlUrl = null; | |
843 | fDataUrl = null; | |
844 | ||
81d5dc3a | 845 | if (fIsAdvancedEnabled && fStreamingComposite != null) { |
a30e79fe | 846 | // Validate input data |
81d5dc3a MAL |
847 | |
848 | if (fIsLive && fLiveGroup != null) { | |
849 | String liveDelayText = fLiveDelayText.getText(); | |
850 | try { | |
851 | fLiveDelay = liveDelayText.equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Integer.valueOf(liveDelayText); | |
6fd3c6e9 MAL |
852 | fLivePort = Integer.valueOf(fLivePortText.getText()); |
853 | fLiveUrl = fLiveHostAddressText.getText(); | |
81d5dc3a MAL |
854 | } catch (NumberFormatException e) { |
855 | setErrorMessage(Messages.TraceControl_InvalidLiveDelayError); | |
856 | return; | |
857 | } | |
858 | } | |
859 | ||
a30e79fe BH |
860 | fTracePath = fTracePathText.getText(); |
861 | ||
f3b33d40 | 862 | if (fControlProtocolCombo.getSelectionIndex() < 0) { |
abb1f9a7 | 863 | setErrorMessage("Control Protocol Text is empty\n"); //$NON-NLS-1$ |
f3b33d40 BH |
864 | return; |
865 | } | |
866 | ||
867 | if ("".equals(fControlHostAddressText.getText())) { //$NON-NLS-1$ | |
abb1f9a7 | 868 | setErrorMessage("Control Address Text is empty\n"); //$NON-NLS-1$ |
f3b33d40 BH |
869 | return; |
870 | } | |
871 | ||
abb1f9a7 | 872 | if (!fLinkDataWithControlButton.getSelection()) { |
f3b33d40 | 873 | if (fDataProtocolCombo.getSelectionIndex() < 0) { |
abb1f9a7 | 874 | setErrorMessage("Data Protocol Text is empty\n"); //$NON-NLS-1$ |
f3b33d40 BH |
875 | return; |
876 | } | |
877 | ||
878 | if ("".equals(fDataHostAddressText.getText())) { //$NON-NLS-1$ | |
abb1f9a7 | 879 | setErrorMessage("Data Address Text is empty\n"); //$NON-NLS-1$ |
f3b33d40 BH |
880 | return; |
881 | } | |
882 | ||
883 | fControlUrl = getUrlString(fControlProtocolCombo.getItem(fControlProtocolCombo.getSelectionIndex()), | |
884 | fControlHostAddressText.getText(), | |
885 | fControlPortText.getText(), | |
886 | null, | |
a30e79fe | 887 | fTracePath); |
f3b33d40 | 888 | |
abb1f9a7 | 889 | fDataUrl = getUrlString(fDataProtocolCombo.getItem(fDataProtocolCombo.getSelectionIndex()), |
f3b33d40 BH |
890 | fDataHostAddressText.getText(), |
891 | null, | |
892 | fDataPortText.getText(), | |
a30e79fe | 893 | fTracePath); |
f3b33d40 | 894 | } else { |
abb1f9a7 | 895 | fNetworkUrl = getUrlString(fControlProtocolCombo.getItem(fControlProtocolCombo.getSelectionIndex()), |
f3b33d40 BH |
896 | fControlHostAddressText.getText(), |
897 | fControlPortText.getText(), | |
898 | fDataPortText.getText(), | |
a30e79fe | 899 | fTracePath); |
f3b33d40 | 900 | } |
bbb3538a BH |
901 | } |
902 | ||
81d5dc3a | 903 | if (fIsLive && fNetworkUrl == null && fControlUrl == null && fDataUrl == null) { |
92fe6900 | 904 | fNetworkUrl = SessionInfo.DEFAULT_LIVE_NETWORK_URL; |
81d5dc3a MAL |
905 | } |
906 | ||
bbb3538a | 907 | // Check for invalid names |
f3b33d40 | 908 | if (!"".equals(fSessionName) && !fSessionName.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$ |
abb1f9a7 | 909 | setErrorMessage(Messages.TraceControl_InvalidSessionNameError + " (" + fSessionName + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ |
bbb3538a BH |
910 | return; |
911 | } | |
912 | ||
913 | // Check if node with name already exists in parent | |
914 | if(fParent.containsChild(fSessionName)) { | |
abb1f9a7 | 915 | setErrorMessage(Messages.TraceControl_SessionAlreadyExistsError + " (" + fSessionName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ |
bbb3538a BH |
916 | return; |
917 | } | |
bbb3538a | 918 | } |
f3b33d40 BH |
919 | |
920 | private static String getUrlString(String proto, String host, String ctrlPort, String dataPort, String sessionPath) { | |
921 | //proto://[HOST|IP][:PORT1[:PORT2]][/TRACE_PATH] | |
922 | StringBuilder stringBuilder = new StringBuilder(); | |
923 | stringBuilder.append(proto); | |
924 | stringBuilder.append("://"); //$NON-NLS-1$ | |
925 | stringBuilder.append(host); | |
926 | ||
927 | if ((ctrlPort != null) && (!"".equals(ctrlPort))) { //$NON-NLS-1$ | |
928 | stringBuilder.append(":"); //$NON-NLS-1$ | |
929 | stringBuilder.append(ctrlPort); | |
930 | } | |
931 | ||
932 | if ((dataPort != null) && (!"".equals(dataPort))) { //$NON-NLS-1$ | |
933 | stringBuilder.append(":"); //$NON-NLS-1$ | |
934 | stringBuilder.append(dataPort); | |
935 | } | |
936 | ||
937 | if ((sessionPath != null) && (!"".equals(sessionPath))) { //$NON-NLS-1$ | |
938 | stringBuilder.append("/"); //$NON-NLS-1$ | |
939 | stringBuilder.append(sessionPath); | |
940 | } | |
941 | return stringBuilder.toString(); | |
942 | } | |
943 | ||
a30e79fe | 944 | private static class CopyModifyListener implements ModifyListener { |
f3b33d40 BH |
945 | private Text fSource; |
946 | private Text fDestination; | |
947 | ||
a30e79fe | 948 | public CopyModifyListener(Text source, Text destination) { |
f3b33d40 BH |
949 | fSource = source; |
950 | fDestination = destination; | |
951 | } | |
952 | ||
953 | @Override | |
a30e79fe | 954 | public void modifyText(ModifyEvent e) { |
f3b33d40 BH |
955 | fDestination.setText(fSource.getText()); |
956 | } | |
957 | } | |
958 | ||
959 | private class ControlProtocolSelectionListener extends SelectionAdapter { | |
960 | ||
961 | @Override | |
962 | public void widgetSelected(SelectionEvent e) { | |
963 | fDataProtocolCombo.select(fControlProtocolCombo.getSelectionIndex()); | |
964 | if (fControlProtocolCombo.getItem(fControlProtocolCombo.getSelectionIndex()).equals(StreamingProtocol.file.name())) { | |
965 | fControlPortText.setText(""); //$NON-NLS-1$ | |
966 | fDataPortText.setText(""); //$NON-NLS-1$ | |
967 | fControlPortText.setEnabled(false); | |
968 | fDataPortText.setEnabled(false); | |
969 | } else { | |
970 | fControlPortText.setEnabled(true); | |
971 | fDataPortText.setEnabled(true); | |
972 | } | |
973 | } | |
974 | } | |
975 | ||
976 | private class ProtocolComboSelectionListener extends SelectionAdapter { | |
977 | ||
978 | private CCombo fCombo; | |
979 | private Text fPortText; | |
980 | ||
981 | public ProtocolComboSelectionListener(CCombo combo, Text portText) { | |
982 | fCombo = combo; | |
983 | fPortText = portText; | |
984 | } | |
985 | ||
986 | @Override | |
987 | public void widgetSelected(SelectionEvent e) { | |
988 | if (fCombo.getItem(fCombo.getSelectionIndex()).equals(StreamingProtocol.net.name()) || | |
989 | fCombo.getItem(fCombo.getSelectionIndex()).equals(StreamingProtocol.net6.name())) { | |
990 | fPortText.setText(""); //$NON-NLS-1$ | |
991 | fPortText.setEnabled(false); | |
992 | } else { | |
993 | fPortText.setEnabled(true); | |
994 | } | |
995 | } | |
996 | } | |
997 | ||
f7d4d450 MAL |
998 | @Override |
999 | public ISessionInfo getParameters() { | |
1000 | ISessionInfo sessionInfo = new SessionInfo(fSessionName); | |
1001 | ||
81d5dc3a MAL |
1002 | boolean isStreaming = (fIsAdvancedEnabled && fStreamingComposite != null) || fIsLive; |
1003 | if (isStreaming) { | |
f7d4d450 MAL |
1004 | sessionInfo.setNetworkUrl(fNetworkUrl); |
1005 | sessionInfo.setControlUrl(fControlUrl); | |
1006 | sessionInfo.setDataUrl(fDataUrl); | |
1007 | sessionInfo.setStreamedTrace(true); | |
1008 | } else if (!fIsDefaultPath) { | |
1009 | sessionInfo.setSessionPath(fSessionPath); | |
1010 | } | |
1011 | ||
81d5dc3a | 1012 | sessionInfo.setLive(fIsLive); |
6fd3c6e9 MAL |
1013 | sessionInfo.setLiveUrl(fLiveUrl); |
1014 | sessionInfo.setLivePort(fLivePort); | |
81d5dc3a | 1015 | sessionInfo.setLiveDelay(fLiveDelay); |
f7d4d450 MAL |
1016 | sessionInfo.setSnapshot(fIsSnapshot); |
1017 | ||
1018 | return sessionInfo; | |
1019 | } | |
abb1f9a7 MAL |
1020 | |
1021 | private final class UpdateEnablementModifyListener implements ModifyListener { | |
1022 | @Override | |
1023 | public void modifyText(ModifyEvent e) { | |
1024 | updateEnablement(); | |
1025 | } | |
1026 | } | |
bbb3538a | 1027 | } |