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