Commit | Line | Data |
---|---|---|
bbb3538a | 1 | /********************************************************************** |
ba3a9bd2 | 2 | * Copyright (c) 2012, 2013 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 |
bbb3538a | 12 | **********************************************************************/ |
115b4a01 | 13 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs; |
bbb3538a BH |
14 | |
15 | import org.eclipse.core.runtime.NullProgressMonitor; | |
16 | import org.eclipse.jface.dialogs.Dialog; | |
17 | import org.eclipse.jface.dialogs.IDialogConstants; | |
18 | import org.eclipse.jface.dialogs.MessageDialog; | |
115b4a01 | 19 | import org.eclipse.linuxtools.internal.lttng2.ui.Activator; |
9315aeee | 20 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages; |
115b4a01 BH |
21 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TargetNodeComponent; |
22 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionGroup; | |
23 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.IRemoteSystemProxy; | |
bbb3538a BH |
24 | import org.eclipse.rse.services.clientserver.messages.SystemMessageException; |
25 | import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem; | |
26 | import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; | |
27 | import org.eclipse.swt.SWT; | |
f3b33d40 | 28 | import org.eclipse.swt.custom.CCombo; |
a30e79fe BH |
29 | import org.eclipse.swt.events.ModifyEvent; |
30 | import org.eclipse.swt.events.ModifyListener; | |
f3b33d40 BH |
31 | import org.eclipse.swt.events.SelectionAdapter; |
32 | import org.eclipse.swt.events.SelectionEvent; | |
bbb3538a | 33 | import org.eclipse.swt.graphics.Point; |
f3b33d40 | 34 | import org.eclipse.swt.graphics.Rectangle; |
bbb3538a BH |
35 | import org.eclipse.swt.layout.GridData; |
36 | import org.eclipse.swt.layout.GridLayout; | |
f3b33d40 | 37 | import org.eclipse.swt.widgets.Button; |
bbb3538a BH |
38 | import org.eclipse.swt.widgets.Composite; |
39 | import org.eclipse.swt.widgets.Control; | |
f3b33d40 | 40 | import org.eclipse.swt.widgets.Group; |
bbb3538a BH |
41 | import org.eclipse.swt.widgets.Label; |
42 | import org.eclipse.swt.widgets.Shell; | |
43 | import org.eclipse.swt.widgets.Text; | |
44 | ||
45 | /** | |
bbb3538a BH |
46 | * <p> |
47 | * Dialog box for collecting session creation information. | |
48 | * </p> | |
f3b33d40 | 49 | * |
dbd4432d | 50 | * @author Bernd Hufmann |
bbb3538a BH |
51 | */ |
52 | public class CreateSessionDialog extends Dialog implements ICreateSessionDialog { | |
53 | ||
54 | // ------------------------------------------------------------------------ | |
55 | // Constants | |
56 | // ------------------------------------------------------------------------ | |
57 | /** | |
58 | * The icon file for this dialog box. | |
59 | */ | |
f3b33d40 BH |
60 | public static final String CREATE_SESSION_ICON_FILE = "icons/elcl16/add_button.gif"; //$NON-NLS-1$ |
61 | ||
62 | /** | |
63 | * Supported network protocols for streaming | |
64 | */ | |
65 | private enum StreamingProtocol { | |
66 | /** Default network protocol for IPv4 (TCP)*/ | |
67 | net, | |
68 | /** Default network protocol for IPv6 (TCP)*/ | |
69 | net6, | |
70 | /** File */ | |
71 | file, | |
72 | } | |
73 | ||
74 | private enum StreamingProtocol2 { | |
75 | /** Default network protocol for IPv4 (TCP)*/ | |
76 | net, | |
77 | /** Default network protocol for IPv6 (TCP)*/ | |
78 | net6, | |
79 | /** TCP network protocol for IPv4*/ | |
80 | tcp, | |
81 | /** TCP network protocol for IPv6*/ | |
82 | tcp6 } | |
83 | ||
84 | /** | |
85 | * Index of last supported streaming protocol for common URL configuration. | |
86 | */ | |
77735e82 | 87 | private static final int COMMON_URL_LAST_INDEX = 1; |
f3b33d40 BH |
88 | /** |
89 | * Index of default streaming protocol. | |
90 | */ | |
77735e82 | 91 | private static final int DEFAULT_URL_INDEX = 0; |
bbb3538a BH |
92 | |
93 | // ------------------------------------------------------------------------ | |
94 | // Attributes | |
95 | // ------------------------------------------------------------------------ | |
f3b33d40 BH |
96 | |
97 | private Control fControl = null; | |
bbb3538a BH |
98 | /** |
99 | * The dialog composite. | |
100 | */ | |
101 | private Composite fDialogComposite = null; | |
102 | /** | |
103 | * The text widget for the session name | |
104 | */ | |
105 | private Text fSessionNameText = null; | |
a30e79fe BH |
106 | /** |
107 | * The label widget for the session path. | |
108 | */ | |
109 | private Label fSessionPathLabel = null; | |
bbb3538a | 110 | /** |
f3b33d40 | 111 | * The text widget for the session path. |
bbb3538a BH |
112 | */ |
113 | private Text fSessionPathText = null; | |
589d0d33 BH |
114 | /** |
115 | * The button widget to select a snapshot session | |
116 | */ | |
117 | private Button fSnapshotButton = null; | |
f3b33d40 BH |
118 | /** |
119 | * The Group for stream configuration. | |
120 | */ | |
121 | private Group fMainStreamingGroup = null; | |
122 | /** | |
123 | * The button to show streaming options. | |
124 | */ | |
125 | private Button fConfigureStreamingButton = null; | |
126 | /** | |
127 | * The composite with streaming configuration parameter. | |
128 | */ | |
129 | private Composite fStreamingComposite = null; | |
a30e79fe BH |
130 | /** |
131 | * The text widget for the trace path. | |
132 | */ | |
133 | private Text fTracePathText = null; | |
f3b33d40 BH |
134 | /** |
135 | * The button to link data protocol/Address with control protocol. | |
136 | */ | |
137 | private Button fLinkDataWithControlButton = null; | |
138 | /** | |
139 | * The Combo box for channel protocol selection. | |
140 | */ | |
141 | private CCombo fControlProtocolCombo = null; | |
142 | /** | |
143 | * A selection listener that copies the protocol from control to data when being linked. | |
144 | */ | |
145 | private ControlProtocolSelectionListener fCopyProtocolSelectionListener; | |
a30e79fe BH |
146 | /** |
147 | * A selection listener updates the control port text depending on the control protocol selected. | |
148 | */ | |
f3b33d40 | 149 | private ProtocolComboSelectionListener fControlProtocolSelectionListener; |
a30e79fe BH |
150 | /** |
151 | * A selection listener updates the data port text depending on the data protocol selected. | |
152 | */ | |
f3b33d40 | 153 | private ProtocolComboSelectionListener fDataProtocolSelectionListener; |
f3b33d40 BH |
154 | /** |
155 | * The text box for the host/IP address of the control channel. | |
156 | */ | |
157 | private Text fControlHostAddressText = null; | |
158 | /** | |
159 | * A key listener that copies the host address from control to data when being linked. | |
160 | */ | |
a30e79fe | 161 | private CopyModifyListener fControlUrlKeyListener; |
f3b33d40 BH |
162 | /** |
163 | * The text box for the control port. | |
164 | */ | |
165 | private Text fControlPortText = null; | |
166 | /** | |
167 | * The Combo box for data protocol selection. | |
168 | */ | |
169 | private CCombo fDataProtocolCombo = null; | |
170 | /** | |
171 | * The text box for the host/IP address of the data channel. | |
172 | */ | |
173 | private Text fDataHostAddressText = null; | |
174 | /** | |
175 | * The text box for the data port. | |
176 | */ | |
177 | private Text fDataPortText = null; | |
bbb3538a BH |
178 | /** |
179 | * The parent where the new node should be added. | |
180 | */ | |
c56972bb | 181 | private TraceSessionGroup fParent = null; |
bbb3538a BH |
182 | /** |
183 | * The session name string. | |
184 | */ | |
185 | private String fSessionName = null; | |
186 | /** | |
187 | * The session path string. | |
188 | */ | |
189 | private String fSessionPath = null; | |
589d0d33 BH |
190 | /** |
191 | * The session path string. | |
192 | */ | |
193 | private boolean fIsSnapshot = false; | |
bbb3538a BH |
194 | /** |
195 | * Flag whether default location (path) shall be used or not | |
196 | */ | |
197 | private boolean fIsDefaultPath = true; | |
f3b33d40 BH |
198 | /** |
199 | * Flag whether the trace is streamed or not | |
200 | */ | |
201 | private boolean fIsStreamedTrace = false; | |
202 | /** | |
203 | * The network URL in case control and data is configured together. | |
204 | * If set, fControlUrl and fDataUrl will be null. | |
205 | */ | |
206 | private String fNetworkUrl = null; | |
207 | /** | |
208 | * The control URL in case control and data is configured separately. | |
209 | * If set, fDataUrl will be set too and fNetworkUrl will be null. | |
210 | */ | |
211 | private String fControlUrl = null; | |
212 | /** | |
213 | * The data URL in case control and data is configured separately. | |
214 | * If set, fControlUrl will be set too and fNetworkUrl will be null. | |
215 | */ | |
216 | private String fDataUrl = null; | |
217 | /** | |
a30e79fe | 218 | * The trace path string. |
f3b33d40 | 219 | */ |
a30e79fe | 220 | private String fTracePath = null; |
bbb3538a BH |
221 | |
222 | // ------------------------------------------------------------------------ | |
223 | // Constructors | |
224 | // ------------------------------------------------------------------------ | |
225 | /** | |
226 | * Constructor | |
227 | * @param shell - a shell for the display of the dialog | |
bbb3538a | 228 | */ |
d132bcc7 | 229 | public CreateSessionDialog(Shell shell) { |
bbb3538a | 230 | super(shell); |
8a396998 | 231 | setShellStyle(SWT.RESIZE | getShellStyle()); |
bbb3538a BH |
232 | } |
233 | ||
234 | // ------------------------------------------------------------------------ | |
235 | // Accessors | |
236 | // ------------------------------------------------------------------------ | |
11252342 | 237 | |
bbb3538a BH |
238 | @Override |
239 | public String getSessionName() { | |
240 | return fSessionName; | |
241 | } | |
242 | ||
bbb3538a BH |
243 | @Override |
244 | public String getSessionPath() { | |
245 | return fSessionPath; | |
246 | } | |
f3b33d40 | 247 | |
bbb3538a BH |
248 | @Override |
249 | public boolean isDefaultSessionPath() { | |
250 | return fIsDefaultPath; | |
251 | } | |
252 | ||
d132bcc7 | 253 | @Override |
f3b33d40 BH |
254 | public void initialize(TraceSessionGroup group) { |
255 | fParent = group; | |
256 | fStreamingComposite = null; | |
257 | fSessionName = null; | |
258 | fSessionPath = null; | |
589d0d33 | 259 | fIsSnapshot = false; |
f3b33d40 BH |
260 | fIsDefaultPath = true; |
261 | fIsStreamedTrace = false; | |
262 | fNetworkUrl = null; | |
263 | fControlUrl = null; | |
264 | fDataUrl = null; | |
f3b33d40 BH |
265 | } |
266 | ||
267 | @Override | |
268 | public boolean isStreamedTrace() { | |
269 | return fIsStreamedTrace; | |
270 | } | |
271 | @Override | |
272 | public String getNetworkUrl() { | |
273 | return fNetworkUrl; | |
274 | } | |
275 | @Override | |
276 | public String getControlUrl() { | |
277 | return fControlUrl; | |
278 | } | |
279 | @Override | |
280 | public String getDataUrl() { | |
281 | return fDataUrl; | |
282 | } | |
589d0d33 BH |
283 | @Override |
284 | public boolean isSnapshot() { | |
285 | return fIsSnapshot; | |
286 | } | |
bbb3538a BH |
287 | // ------------------------------------------------------------------------ |
288 | // Operations | |
289 | // ------------------------------------------------------------------------ | |
f3b33d40 | 290 | |
f3b33d40 BH |
291 | @Override |
292 | protected Control createContents(Composite parent) { | |
293 | fControl = super.createContents(parent); | |
294 | ||
295 | /* set the shell minimum size */ | |
296 | Point clientArea = fControl.computeSize(SWT.DEFAULT, SWT.DEFAULT); | |
297 | Rectangle trim = getShell().computeTrim(0, 0, clientArea.x, clientArea.y); | |
298 | getShell().setMinimumSize(trim.width, trim.height); | |
299 | ||
300 | return fControl; | |
301 | } | |
11252342 | 302 | |
bbb3538a BH |
303 | @Override |
304 | protected void configureShell(Shell newShell) { | |
305 | super.configureShell(newShell); | |
306 | newShell.setText(Messages.TraceControl_CreateSessionDialogTitle); | |
31a6a4e4 | 307 | newShell.setImage(Activator.getDefault().loadIcon(CREATE_SESSION_ICON_FILE)); |
bbb3538a BH |
308 | } |
309 | ||
bbb3538a BH |
310 | @Override |
311 | protected Control createDialogArea(Composite parent) { | |
f3b33d40 | 312 | |
bbb3538a BH |
313 | // Main dialog panel |
314 | fDialogComposite = new Composite(parent, SWT.NONE); | |
f3b33d40 | 315 | GridLayout layout = new GridLayout(1, true); |
5f1f22f8 BH |
316 | fDialogComposite.setLayout(layout); |
317 | fDialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); | |
bbb3538a | 318 | |
f3b33d40 BH |
319 | Group sessionGroup = new Group(fDialogComposite, SWT.SHADOW_NONE); |
320 | sessionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); | |
321 | sessionGroup.setLayout(new GridLayout(4, true)); | |
322 | ||
323 | Label sessionNameLabel = new Label(sessionGroup, SWT.RIGHT); | |
bbb3538a | 324 | sessionNameLabel.setText(Messages.TraceControl_CreateSessionNameLabel); |
f3b33d40 | 325 | fSessionNameText = new Text(sessionGroup, SWT.NONE); |
bbb3538a | 326 | fSessionNameText.setToolTipText(Messages.TraceControl_CreateSessionNameTooltip); |
f3b33d40 | 327 | |
a30e79fe BH |
328 | fSessionPathLabel = new Label(sessionGroup, SWT.RIGHT); |
329 | fSessionPathLabel.setText(Messages.TraceControl_CreateSessionPathLabel); | |
f3b33d40 | 330 | fSessionPathText = new Text(sessionGroup, SWT.NONE); |
bbb3538a BH |
331 | fSessionPathText.setToolTipText(Messages.TraceControl_CreateSessionPathTooltip); |
332 | ||
589d0d33 BH |
333 | if (fParent.isSnapshotSupported()) { |
334 | fSnapshotButton = new Button(sessionGroup, SWT.CHECK); | |
335 | fSnapshotButton.setText(Messages.TraceControl_CreateSessionSnapshotLabel); | |
336 | fSnapshotButton.setToolTipText(Messages.TraceControl_CreateSessionSnapshotTooltip); | |
337 | GridData data = new GridData(GridData.FILL_HORIZONTAL); | |
338 | data.horizontalSpan = 4; | |
339 | fSnapshotButton.setData(data); | |
340 | } | |
341 | ||
bbb3538a | 342 | // layout widgets |
5f1f22f8 BH |
343 | GridData data = new GridData(GridData.FILL_HORIZONTAL); |
344 | data.horizontalSpan = 3; | |
f3b33d40 | 345 | |
bbb3538a | 346 | fSessionNameText.setLayoutData(data); |
f3b33d40 BH |
347 | |
348 | data = new GridData(GridData.FILL_HORIZONTAL); | |
349 | data.horizontalSpan = 3; | |
bbb3538a | 350 | fSessionPathText.setLayoutData(data); |
bbb3538a | 351 | |
f3b33d40 | 352 | if (fParent.isNetworkStreamingSupported()) { |
f3b33d40 BH |
353 | createAdvancedOptionsComposite(); |
354 | } | |
355 | ||
bbb3538a BH |
356 | return fDialogComposite; |
357 | } | |
358 | ||
f3b33d40 BH |
359 | private void createAdvancedOptionsComposite() { |
360 | ||
361 | fMainStreamingGroup = new Group(fDialogComposite, SWT.SHADOW_NONE); | |
362 | fMainStreamingGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); | |
363 | fMainStreamingGroup.setLayout(new GridLayout(1, true)); | |
364 | ||
365 | fConfigureStreamingButton = new Button(fMainStreamingGroup, SWT.PUSH); | |
a30e79fe | 366 | fConfigureStreamingButton.setText(Messages.TraceControl_CreateSessionConfigureStreamingButtonText + " >>>"); //$NON-NLS-1$ |
f3b33d40 BH |
367 | fConfigureStreamingButton.setToolTipText(Messages.TraceControl_CreateSessionConfigureStreamingButtonTooltip); |
368 | fConfigureStreamingButton.addSelectionListener(new SelectionAdapter() { | |
369 | @Override | |
370 | public void widgetSelected(SelectionEvent e) { | |
371 | if (fIsStreamedTrace) { | |
372 | fIsStreamedTrace = false; | |
373 | fConfigureStreamingButton.setText(">>> " + Messages.TraceControl_CreateSessionConfigureStreamingButtonText); //$NON-NLS-1$ | |
374 | fConfigureStreamingButton.setToolTipText(Messages.TraceControl_CreateSessionConfigureStreamingButtonTooltip); | |
a30e79fe BH |
375 | fSessionPathText.setEnabled(true); |
376 | fSessionPathLabel.setText(Messages.TraceControl_CreateSessionPathLabel); | |
f3b33d40 BH |
377 | disposeConfigureStreamingComposite(); |
378 | } else { | |
379 | fIsStreamedTrace = true; | |
380 | fConfigureStreamingButton.setText("<<< " + Messages.TraceControl_CreateSessionNoStreamingButtonText); //$NON-NLS-1$ | |
381 | fConfigureStreamingButton.setToolTipText(Messages.TraceControl_CreateSessionNoStreamingButtonTooltip); | |
a30e79fe BH |
382 | fSessionPathText.setEnabled(false); |
383 | fSessionPathText.setText(""); //$NON-NLS-1$ | |
384 | fSessionPathLabel.setText(""); //$NON-NLS-1$ | |
f3b33d40 BH |
385 | createConfigureStreamingComposite(); |
386 | } | |
387 | ||
388 | fDialogComposite.layout(); | |
389 | ||
390 | Point clientArea = fControl.computeSize(SWT.DEFAULT, SWT.DEFAULT); | |
391 | Rectangle trim = getShell().computeTrim(0, 0, clientArea.x, clientArea.y); | |
392 | getShell().setSize(trim.width, trim.height); | |
393 | } | |
394 | }); | |
395 | } | |
396 | ||
397 | private void createConfigureStreamingComposite() { | |
398 | if (fStreamingComposite == null) { | |
399 | fStreamingComposite = new Composite(fMainStreamingGroup, SWT.NONE); | |
400 | GridLayout layout = new GridLayout(1, true); | |
401 | fStreamingComposite.setLayout(layout); | |
402 | fStreamingComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); | |
403 | ||
404 | Group urlGroup = new Group(fStreamingComposite, SWT.SHADOW_NONE); | |
405 | layout = new GridLayout(7, true); | |
406 | urlGroup.setLayout(layout); | |
407 | urlGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); | |
408 | ||
a30e79fe BH |
409 | Label tracePathLabel = new Label(urlGroup, SWT.RIGHT); |
410 | tracePathLabel.setText(Messages.TraceControl_CreateSessionTracePathText); | |
411 | fTracePathText = new Text(urlGroup, SWT.NONE); | |
412 | fTracePathText.setToolTipText(Messages.TraceControl_CreateSessionTracePathTooltip); | |
413 | ||
414 | // layout widgets | |
415 | GridData data = new GridData(GridData.FILL_HORIZONTAL); | |
416 | data.horizontalSpan = 6; | |
417 | fTracePathText.setLayoutData(data); | |
418 | ||
f3b33d40 BH |
419 | fLinkDataWithControlButton = new Button(urlGroup, SWT.CHECK); |
420 | fLinkDataWithControlButton.setText(Messages.TraceControl_CreateSessionLinkButtonText); | |
421 | fLinkDataWithControlButton.setToolTipText(Messages.TraceControl_CreateSessionLinkButtonTooltip); | |
a30e79fe | 422 | data = new GridData(GridData.FILL_HORIZONTAL); |
f3b33d40 BH |
423 | data.horizontalSpan = 7; |
424 | fLinkDataWithControlButton.setLayoutData(data); | |
425 | fLinkDataWithControlButton.setSelection(true); | |
426 | ||
427 | Label label = new Label(urlGroup, SWT.NONE); | |
428 | data = new GridData(GridData.FILL_HORIZONTAL); | |
429 | data.horizontalSpan = 1; | |
430 | label.setLayoutData(data); | |
431 | ||
432 | label = new Label(urlGroup, SWT.NONE); | |
433 | label.setText(Messages.TraceControl_CreateSessionProtocolLabelText); | |
434 | data = new GridData(GridData.FILL_HORIZONTAL); | |
435 | data.horizontalSpan = 1; | |
436 | label.setLayoutData(data); | |
437 | ||
438 | label = new Label(urlGroup, SWT.NONE); | |
439 | label.setText(Messages.TraceControl_CreateSessionAddressLabelText); | |
440 | data = new GridData(GridData.FILL_HORIZONTAL); | |
441 | data.horizontalSpan = 4; | |
442 | label.setLayoutData(data); | |
443 | ||
444 | label = new Label(urlGroup, SWT.NONE); | |
445 | label.setText(Messages.TraceControl_CreateSessionPortLabelText); | |
446 | data = new GridData(GridData.FILL_HORIZONTAL); | |
447 | data.horizontalSpan = 1; | |
448 | label.setLayoutData(data); | |
449 | ||
450 | label = new Label(urlGroup, SWT.RIGHT); | |
451 | label.setText(Messages.TraceControl_CreateSessionControlUrlLabel); | |
452 | data = new GridData(GridData.FILL_HORIZONTAL); | |
453 | data.horizontalSpan = 1; | |
454 | label.setLayoutData(data); | |
455 | ||
456 | fControlProtocolCombo = new CCombo(urlGroup, SWT.READ_ONLY); | |
457 | fControlProtocolCombo.setToolTipText(Messages.TraceControl_CreateSessionCommonProtocolTooltip); | |
458 | data = new GridData(GridData.FILL_HORIZONTAL); | |
459 | data.horizontalSpan = 1; | |
460 | fControlProtocolCombo.setLayoutData(data); | |
461 | ||
462 | fControlHostAddressText = new Text(urlGroup, SWT.NONE); | |
463 | fControlHostAddressText.setToolTipText(Messages.TraceControl_CreateSessionControlAddressTooltip); | |
464 | data = new GridData(GridData.FILL_HORIZONTAL); | |
465 | data.horizontalSpan = 4; | |
466 | fControlHostAddressText.setLayoutData(data); | |
467 | ||
468 | fControlPortText = new Text(urlGroup, SWT.NONE); | |
469 | fControlPortText.setToolTipText(Messages.TraceControl_CreateSessionControlPortTooltip); | |
470 | data = new GridData(GridData.FILL_HORIZONTAL); | |
471 | data.horizontalSpan = 1; | |
472 | fControlPortText.setLayoutData(data); | |
473 | ||
474 | label = new Label(urlGroup, SWT.RIGHT); | |
475 | label.setText(Messages.TraceControl_CreateSessionDataUrlLabel); | |
476 | data = new GridData(GridData.FILL_HORIZONTAL); | |
477 | data.horizontalSpan = 1; | |
478 | label.setLayoutData(data); | |
479 | ||
480 | fDataProtocolCombo = new CCombo(urlGroup, SWT.READ_ONLY); | |
481 | fDataProtocolCombo.setEnabled(false); | |
482 | fDataProtocolCombo.setToolTipText(Messages.TraceControl_CreateSessionProtocolTooltip); | |
483 | data = new GridData(GridData.FILL_HORIZONTAL); | |
484 | data.horizontalSpan = 1; | |
485 | fDataProtocolCombo.setLayoutData(data); | |
486 | ||
487 | String items[] = new String[StreamingProtocol.values().length]; | |
488 | for (int i = 0; i < items.length; i++) { | |
489 | items[i] = StreamingProtocol.values()[i].name(); | |
490 | } | |
491 | fControlProtocolCombo.setItems(items); | |
492 | fDataProtocolCombo.setItems(items); | |
493 | ||
494 | fDataHostAddressText = new Text(urlGroup, SWT.NONE); | |
495 | fDataHostAddressText.setEnabled(false); | |
496 | fDataHostAddressText.setToolTipText(Messages.TraceControl_CreateSessionDataAddressTooltip); | |
497 | data = new GridData(GridData.FILL_HORIZONTAL); | |
498 | data.horizontalSpan = 4; | |
499 | fDataHostAddressText.setLayoutData(data); | |
500 | ||
501 | fDataPortText = new Text(urlGroup, SWT.NONE); | |
502 | fDataPortText.setEnabled(true); | |
503 | fDataPortText.setToolTipText(Messages.TraceControl_CreateSessionDataPortTooltip); | |
504 | data = new GridData(GridData.FILL_HORIZONTAL); | |
505 | data.horizontalSpan = 1; | |
506 | fDataPortText.setLayoutData(data); | |
507 | ||
508 | fCopyProtocolSelectionListener = new ControlProtocolSelectionListener(); | |
509 | fControlProtocolSelectionListener = new ProtocolComboSelectionListener(fControlProtocolCombo, fControlPortText); | |
510 | fDataProtocolSelectionListener = new ProtocolComboSelectionListener(fDataProtocolCombo, fDataPortText); | |
511 | ||
512 | fControlProtocolCombo.addSelectionListener(fCopyProtocolSelectionListener); | |
513 | ||
a30e79fe BH |
514 | fControlUrlKeyListener = new CopyModifyListener(fControlHostAddressText, fDataHostAddressText); |
515 | fControlHostAddressText.addModifyListener(fControlUrlKeyListener); | |
516 | ||
f3b33d40 BH |
517 | fControlProtocolCombo.select(DEFAULT_URL_INDEX); |
518 | fDataProtocolCombo.select(DEFAULT_URL_INDEX); | |
519 | ||
520 | fLinkDataWithControlButton.addSelectionListener(new SelectionAdapter() { | |
521 | @Override | |
522 | public void widgetSelected(SelectionEvent e) { | |
523 | if (fLinkDataWithControlButton.getSelection()) { | |
524 | // Set enablement control data channel inputs | |
525 | fDataProtocolCombo.setEnabled(false); | |
526 | fDataHostAddressText.setEnabled(false); | |
527 | fControlPortText.setEnabled(true); | |
528 | fDataPortText.setEnabled(true); | |
529 | ||
530 | // Update listeners | |
531 | fControlProtocolCombo.removeSelectionListener(fControlProtocolSelectionListener); | |
532 | fDataProtocolCombo.removeSelectionListener(fDataProtocolSelectionListener); | |
533 | fControlProtocolCombo.addSelectionListener(fCopyProtocolSelectionListener); | |
a30e79fe | 534 | fControlHostAddressText.addModifyListener(fControlUrlKeyListener); |
f3b33d40 BH |
535 | |
536 | // Get previous selection and validate | |
537 | int currentSelection = fControlProtocolCombo.getSelectionIndex() <= COMMON_URL_LAST_INDEX ? | |
538 | fControlProtocolCombo.getSelectionIndex() : DEFAULT_URL_INDEX; | |
539 | ||
540 | // Update combo box items | |
541 | fControlProtocolCombo.removeAll(); | |
542 | String[] controlItems = new String[StreamingProtocol.values().length]; | |
543 | for (int i = 0; i < controlItems.length; i++) { | |
544 | controlItems[i] = StreamingProtocol.values()[i].name(); | |
545 | } | |
546 | fControlProtocolCombo.setItems(controlItems); | |
547 | fDataProtocolCombo.setItems(controlItems); | |
548 | ||
549 | // Set selection | |
550 | fControlProtocolCombo.select(currentSelection); | |
551 | fDataProtocolCombo.select(currentSelection); | |
552 | fDataHostAddressText.setText(fControlHostAddressText.getText()); | |
553 | ||
554 | // Update tool tips | |
555 | fControlProtocolCombo.setToolTipText(Messages.TraceControl_CreateSessionCommonProtocolTooltip); | |
556 | } else { | |
557 | // Enable data channel inputs | |
558 | fDataProtocolCombo.setEnabled(true); | |
559 | fDataHostAddressText.setEnabled(true); | |
560 | ||
561 | // Update listeners | |
562 | fControlProtocolCombo.removeSelectionListener(fCopyProtocolSelectionListener); | |
563 | fControlProtocolCombo.addSelectionListener(fControlProtocolSelectionListener); | |
564 | fDataProtocolCombo.addSelectionListener(fDataProtocolSelectionListener); | |
a30e79fe | 565 | fControlHostAddressText.removeModifyListener(fControlUrlKeyListener); |
f3b33d40 BH |
566 | |
567 | // Update combo box items | |
568 | int currentSelection = fControlProtocolCombo.getSelectionIndex(); | |
569 | fControlProtocolCombo.removeAll(); | |
570 | String[] controlItems = new String[StreamingProtocol2.values().length]; | |
571 | for (int i = 0; i < controlItems.length; i++) { | |
572 | controlItems[i] = StreamingProtocol2.values()[i].name(); | |
573 | } | |
574 | fControlProtocolCombo.setItems(controlItems); | |
575 | fDataProtocolCombo.setItems(controlItems); | |
576 | ||
577 | // Set selection | |
578 | fControlProtocolCombo.select(currentSelection); | |
579 | fDataProtocolCombo.select(currentSelection); | |
580 | ||
581 | // Update tool tips | |
582 | fDataProtocolCombo.setToolTipText(Messages.TraceControl_CreateSessionProtocolTooltip); | |
583 | fControlProtocolCombo.setToolTipText(Messages.TraceControl_CreateSessionProtocolTooltip); | |
584 | ||
585 | // Update control/data port enablement and input | |
586 | if (fControlProtocolCombo.getItem(fControlProtocolCombo.getSelectionIndex()).equals(StreamingProtocol.net.name()) || | |
587 | fControlProtocolCombo.getItem(fControlProtocolCombo.getSelectionIndex()).equals(StreamingProtocol.net6.name())) { | |
588 | fControlPortText.setText(""); //$NON-NLS-1$ | |
589 | fControlPortText.setEnabled(false); | |
590 | } else { | |
591 | fControlPortText.setEnabled(true); | |
592 | } | |
593 | ||
594 | if (fDataProtocolCombo.getItem(fDataProtocolCombo.getSelectionIndex()).equals(StreamingProtocol.net.name()) || | |
595 | fDataProtocolCombo.getItem(fDataProtocolCombo.getSelectionIndex()).equals(StreamingProtocol.net6.name())) { | |
596 | fDataPortText.setText(""); //$NON-NLS-1$ | |
597 | fDataPortText.setEnabled(false); | |
598 | } else { | |
599 | fDataPortText.setEnabled(true); | |
600 | } | |
601 | } | |
602 | } | |
603 | }); | |
604 | } | |
605 | } | |
606 | ||
607 | private void disposeConfigureStreamingComposite() { | |
608 | if (fStreamingComposite != null) { | |
609 | fStreamingComposite.dispose(); | |
610 | fStreamingComposite = null; | |
611 | } | |
612 | } | |
613 | ||
bbb3538a BH |
614 | @Override |
615 | protected void createButtonsForButtonBar(Composite parent) { | |
79c3db85 | 616 | createButton(parent, IDialogConstants.CANCEL_ID, "&Cancel", true); //$NON-NLS-1$ |
bbb3538a BH |
617 | createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$ |
618 | } | |
619 | ||
bbb3538a BH |
620 | @Override |
621 | protected void okPressed() { | |
622 | // Validate input data | |
623 | fSessionName = fSessionNameText.getText(); | |
624 | fSessionPath = fSessionPathText.getText(); | |
625 | ||
626 | if (!"".equals(fSessionPath)) { //$NON-NLS-1$ | |
627 | // validate sessionPath | |
f3b33d40 BH |
628 | if (!fIsStreamedTrace) { |
629 | TargetNodeComponent node = (TargetNodeComponent)fParent.getParent(); | |
630 | IRemoteSystemProxy proxy = node.getRemoteSystemProxy(); | |
631 | IFileServiceSubSystem fsss = proxy.getFileServiceSubSystem(); | |
632 | if (fsss != null) { | |
633 | try { | |
634 | IRemoteFile remoteFolder = fsss.getRemoteFileObject(fSessionPath, new NullProgressMonitor()); | |
b68f311b BH |
635 | |
636 | if (remoteFolder == null) { | |
637 | MessageDialog.openError(getShell(), | |
638 | Messages.TraceControl_CreateSessionDialogTitle, | |
639 | Messages.TraceControl_InvalidSessionPathError + " (" + fSessionPath + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ | |
640 | return; | |
641 | } | |
642 | ||
f3b33d40 BH |
643 | if (remoteFolder.exists()) { |
644 | MessageDialog.openError(getShell(), | |
645 | Messages.TraceControl_CreateSessionDialogTitle, | |
646 | Messages.TraceControl_SessionPathAlreadyExistsError + " (" + fSessionPath + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ | |
647 | return; | |
648 | } | |
649 | } catch (SystemMessageException e) { | |
bbb3538a BH |
650 | MessageDialog.openError(getShell(), |
651 | Messages.TraceControl_CreateSessionDialogTitle, | |
f3b33d40 | 652 | Messages.TraceControl_FileSubSystemError + "\n" + e); //$NON-NLS-1$ |
bbb3538a BH |
653 | return; |
654 | } | |
f3b33d40 | 655 | } |
bbb3538a BH |
656 | } |
657 | fIsDefaultPath = false; | |
658 | } | |
659 | ||
589d0d33 BH |
660 | if(fParent.isSnapshotSupported()) { |
661 | fIsSnapshot = fSnapshotButton.getSelection(); | |
662 | } | |
663 | ||
f3b33d40 BH |
664 | fNetworkUrl = null; |
665 | fControlUrl = null; | |
666 | fDataUrl = null; | |
667 | ||
668 | if (fIsStreamedTrace) { | |
a30e79fe BH |
669 | // Validate input data |
670 | fTracePath = fTracePathText.getText(); | |
671 | ||
f3b33d40 BH |
672 | if (fControlProtocolCombo.getSelectionIndex() < 0) { |
673 | MessageDialog.openError(getShell(), | |
674 | Messages.TraceControl_CreateSessionDialogTitle, | |
675 | "Control Protocol Text is empty\n"); //$NON-NLS-1$ | |
676 | return; | |
677 | } | |
678 | ||
679 | if ("".equals(fControlHostAddressText.getText())) { //$NON-NLS-1$ | |
680 | MessageDialog.openError(getShell(), | |
681 | Messages.TraceControl_CreateSessionDialogTitle, | |
682 | "Control Address Text is empty\n"); //$NON-NLS-1$ | |
683 | return; | |
684 | } | |
685 | ||
686 | if(!fLinkDataWithControlButton.getSelection()) { | |
687 | if (fDataProtocolCombo.getSelectionIndex() < 0) { | |
688 | MessageDialog.openError(getShell(), | |
689 | Messages.TraceControl_CreateSessionDialogTitle, | |
690 | "Control Protocol Text is empty\n"); //$NON-NLS-1$ | |
691 | return; | |
692 | } | |
693 | ||
694 | if ("".equals(fDataHostAddressText.getText())) { //$NON-NLS-1$ | |
695 | MessageDialog.openError(getShell(), | |
696 | Messages.TraceControl_CreateSessionDialogTitle, | |
697 | "Control Address Text is empty\n"); //$NON-NLS-1$ | |
698 | return; | |
699 | } | |
700 | ||
701 | fControlUrl = getUrlString(fControlProtocolCombo.getItem(fControlProtocolCombo.getSelectionIndex()), | |
702 | fControlHostAddressText.getText(), | |
703 | fControlPortText.getText(), | |
704 | null, | |
a30e79fe | 705 | fTracePath); |
f3b33d40 BH |
706 | |
707 | fDataUrl = getUrlString(fControlProtocolCombo.getItem(fDataProtocolCombo.getSelectionIndex()), | |
708 | fDataHostAddressText.getText(), | |
709 | null, | |
710 | fDataPortText.getText(), | |
a30e79fe | 711 | fTracePath); |
f3b33d40 BH |
712 | } else { |
713 | fNetworkUrl = getUrlString(fControlProtocolCombo.getItem(fDataProtocolCombo.getSelectionIndex()), | |
714 | fControlHostAddressText.getText(), | |
715 | fControlPortText.getText(), | |
716 | fDataPortText.getText(), | |
a30e79fe | 717 | fTracePath); |
f3b33d40 | 718 | } |
bbb3538a BH |
719 | } |
720 | ||
721 | // Check for invalid names | |
f3b33d40 | 722 | if (!"".equals(fSessionName) && !fSessionName.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$ |
bbb3538a BH |
723 | MessageDialog.openError(getShell(), |
724 | Messages.TraceControl_CreateSessionDialogTitle, | |
725 | Messages.TraceControl_InvalidSessionNameError + " (" + fSessionName + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ | |
726 | return; | |
727 | } | |
728 | ||
729 | // Check if node with name already exists in parent | |
730 | if(fParent.containsChild(fSessionName)) { | |
731 | MessageDialog.openError(getShell(), | |
732 | Messages.TraceControl_CreateSessionDialogTitle, | |
733 | Messages.TraceControl_SessionAlreadyExistsError + " (" + fSessionName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ | |
734 | return; | |
735 | } | |
f3b33d40 | 736 | |
bbb3538a BH |
737 | // validation successful -> call super.okPressed() |
738 | super.okPressed(); | |
739 | } | |
f3b33d40 BH |
740 | |
741 | private static String getUrlString(String proto, String host, String ctrlPort, String dataPort, String sessionPath) { | |
742 | //proto://[HOST|IP][:PORT1[:PORT2]][/TRACE_PATH] | |
743 | StringBuilder stringBuilder = new StringBuilder(); | |
744 | stringBuilder.append(proto); | |
745 | stringBuilder.append("://"); //$NON-NLS-1$ | |
746 | stringBuilder.append(host); | |
747 | ||
748 | if ((ctrlPort != null) && (!"".equals(ctrlPort))) { //$NON-NLS-1$ | |
749 | stringBuilder.append(":"); //$NON-NLS-1$ | |
750 | stringBuilder.append(ctrlPort); | |
751 | } | |
752 | ||
753 | if ((dataPort != null) && (!"".equals(dataPort))) { //$NON-NLS-1$ | |
754 | stringBuilder.append(":"); //$NON-NLS-1$ | |
755 | stringBuilder.append(dataPort); | |
756 | } | |
757 | ||
758 | if ((sessionPath != null) && (!"".equals(sessionPath))) { //$NON-NLS-1$ | |
759 | stringBuilder.append("/"); //$NON-NLS-1$ | |
760 | stringBuilder.append(sessionPath); | |
761 | } | |
762 | return stringBuilder.toString(); | |
763 | } | |
764 | ||
a30e79fe | 765 | private static class CopyModifyListener implements ModifyListener { |
f3b33d40 BH |
766 | private Text fSource; |
767 | private Text fDestination; | |
768 | ||
a30e79fe | 769 | public CopyModifyListener(Text source, Text destination) { |
f3b33d40 BH |
770 | fSource = source; |
771 | fDestination = destination; | |
772 | } | |
773 | ||
774 | @Override | |
a30e79fe | 775 | public void modifyText(ModifyEvent e) { |
f3b33d40 BH |
776 | fDestination.setText(fSource.getText()); |
777 | } | |
778 | } | |
779 | ||
780 | private class ControlProtocolSelectionListener extends SelectionAdapter { | |
781 | ||
782 | @Override | |
783 | public void widgetSelected(SelectionEvent e) { | |
784 | fDataProtocolCombo.select(fControlProtocolCombo.getSelectionIndex()); | |
785 | if (fControlProtocolCombo.getItem(fControlProtocolCombo.getSelectionIndex()).equals(StreamingProtocol.file.name())) { | |
786 | fControlPortText.setText(""); //$NON-NLS-1$ | |
787 | fDataPortText.setText(""); //$NON-NLS-1$ | |
788 | fControlPortText.setEnabled(false); | |
789 | fDataPortText.setEnabled(false); | |
790 | } else { | |
791 | fControlPortText.setEnabled(true); | |
792 | fDataPortText.setEnabled(true); | |
793 | } | |
794 | } | |
795 | } | |
796 | ||
797 | private class ProtocolComboSelectionListener extends SelectionAdapter { | |
798 | ||
799 | private CCombo fCombo; | |
800 | private Text fPortText; | |
801 | ||
802 | public ProtocolComboSelectionListener(CCombo combo, Text portText) { | |
803 | fCombo = combo; | |
804 | fPortText = portText; | |
805 | } | |
806 | ||
807 | @Override | |
808 | public void widgetSelected(SelectionEvent e) { | |
809 | if (fCombo.getItem(fCombo.getSelectionIndex()).equals(StreamingProtocol.net.name()) || | |
810 | fCombo.getItem(fCombo.getSelectionIndex()).equals(StreamingProtocol.net6.name())) { | |
811 | fPortText.setText(""); //$NON-NLS-1$ | |
812 | fPortText.setEnabled(false); | |
813 | } else { | |
814 | fPortText.setEnabled(true); | |
815 | } | |
816 | } | |
817 | } | |
818 | ||
bbb3538a | 819 | } |