1 /**********************************************************************
2 * Copyright (c) 2012, 2013 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
12 **********************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.dialogs
;
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
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.Activator
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.messages
.Messages
;
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
;
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
;
28 import org
.eclipse
.swt
.custom
.CCombo
;
29 import org
.eclipse
.swt
.events
.ModifyEvent
;
30 import org
.eclipse
.swt
.events
.ModifyListener
;
31 import org
.eclipse
.swt
.events
.SelectionAdapter
;
32 import org
.eclipse
.swt
.events
.SelectionEvent
;
33 import org
.eclipse
.swt
.graphics
.Point
;
34 import org
.eclipse
.swt
.graphics
.Rectangle
;
35 import org
.eclipse
.swt
.layout
.GridData
;
36 import org
.eclipse
.swt
.layout
.GridLayout
;
37 import org
.eclipse
.swt
.widgets
.Button
;
38 import org
.eclipse
.swt
.widgets
.Composite
;
39 import org
.eclipse
.swt
.widgets
.Control
;
40 import org
.eclipse
.swt
.widgets
.Group
;
41 import org
.eclipse
.swt
.widgets
.Label
;
42 import org
.eclipse
.swt
.widgets
.Shell
;
43 import org
.eclipse
.swt
.widgets
.Text
;
47 * Dialog box for collecting session creation information.
50 * @author Bernd Hufmann
52 public class CreateSessionDialog
extends Dialog
implements ICreateSessionDialog
{
54 // ------------------------------------------------------------------------
56 // ------------------------------------------------------------------------
58 * The icon file for this dialog box.
60 public static final String CREATE_SESSION_ICON_FILE
= "icons/elcl16/add_button.gif"; //$NON-NLS-1$
63 * Supported network protocols for streaming
65 private enum StreamingProtocol
{
66 /** Default network protocol for IPv4 (TCP)*/
68 /** Default network protocol for IPv6 (TCP)*/
74 private enum StreamingProtocol2
{
75 /** Default network protocol for IPv4 (TCP)*/
77 /** Default network protocol for IPv6 (TCP)*/
79 /** TCP network protocol for IPv4*/
81 /** TCP network protocol for IPv6*/
85 * Index of last supported streaming protocol for common URL configuration.
87 private static final int COMMON_URL_LAST_INDEX
= 1;
89 * Index of default streaming protocol.
91 private static final int DEFAULT_URL_INDEX
= 0;
93 // ------------------------------------------------------------------------
95 // ------------------------------------------------------------------------
97 private Control fControl
= null;
99 * The dialog composite.
101 private Composite fDialogComposite
= null;
103 * The text widget for the session name
105 private Text fSessionNameText
= null;
107 * The label widget for the session path.
109 private Label fSessionPathLabel
= null;
111 * The text widget for the session path.
113 private Text fSessionPathText
= null;
115 * The Group for stream configuration.
117 private Group fMainStreamingGroup
= null;
119 * The button to show streaming options.
121 private Button fConfigureStreamingButton
= null;
123 * The composite with streaming configuration parameter.
125 private Composite fStreamingComposite
= null;
127 * The text widget for the trace path.
129 private Text fTracePathText
= null;
131 * The button to link data protocol/Address with control protocol.
133 private Button fLinkDataWithControlButton
= null;
135 * The Combo box for channel protocol selection.
137 private CCombo fControlProtocolCombo
= null;
139 * A selection listener that copies the protocol from control to data when being linked.
141 private ControlProtocolSelectionListener fCopyProtocolSelectionListener
;
143 * A selection listener updates the control port text depending on the control protocol selected.
145 private ProtocolComboSelectionListener fControlProtocolSelectionListener
;
147 * A selection listener updates the data port text depending on the data protocol selected.
149 private ProtocolComboSelectionListener fDataProtocolSelectionListener
;
151 * The text box for the host/IP address of the control channel.
153 private Text fControlHostAddressText
= null;
155 * A key listener that copies the host address from control to data when being linked.
157 private CopyModifyListener fControlUrlKeyListener
;
159 * The text box for the control port.
161 private Text fControlPortText
= null;
163 * The Combo box for data protocol selection.
165 private CCombo fDataProtocolCombo
= null;
167 * The text box for the host/IP address of the data channel.
169 private Text fDataHostAddressText
= null;
171 * The text box for the data port.
173 private Text fDataPortText
= null;
175 * The parent where the new node should be added.
177 private TraceSessionGroup fParent
= null;
179 * The session name string.
181 private String fSessionName
= null;
183 * The session path string.
185 private String fSessionPath
= null;
187 * Flag whether default location (path) shall be used or not
189 private boolean fIsDefaultPath
= true;
191 * Flag whether the trace is streamed or not
193 private boolean fIsStreamedTrace
= false;
195 * The network URL in case control and data is configured together.
196 * If set, fControlUrl and fDataUrl will be null.
198 private String fNetworkUrl
= null;
200 * The control URL in case control and data is configured separately.
201 * If set, fDataUrl will be set too and fNetworkUrl will be null.
203 private String fControlUrl
= null;
205 * The data URL in case control and data is configured separately.
206 * If set, fControlUrl will be set too and fNetworkUrl will be null.
208 private String fDataUrl
= null;
210 * The trace path string.
212 private String fTracePath
= null;
214 // ------------------------------------------------------------------------
216 // ------------------------------------------------------------------------
219 * @param shell - a shell for the display of the dialog
221 public CreateSessionDialog(Shell shell
) {
223 setShellStyle(SWT
.RESIZE
);
226 // ------------------------------------------------------------------------
228 // ------------------------------------------------------------------------
231 public String
getSessionName() {
236 public String
getSessionPath() {
241 public boolean isDefaultSessionPath() {
242 return fIsDefaultPath
;
246 public void initialize(TraceSessionGroup group
) {
248 fStreamingComposite
= null;
251 fIsDefaultPath
= true;
252 fIsStreamedTrace
= false;
259 public boolean isStreamedTrace() {
260 return fIsStreamedTrace
;
263 public String
getNetworkUrl() {
267 public String
getControlUrl() {
271 public String
getDataUrl() {
275 // ------------------------------------------------------------------------
277 // ------------------------------------------------------------------------
280 protected Control
createContents(Composite parent
) {
281 fControl
= super.createContents(parent
);
283 /* set the shell minimum size */
284 Point clientArea
= fControl
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
);
285 Rectangle trim
= getShell().computeTrim(0, 0, clientArea
.x
, clientArea
.y
);
286 getShell().setMinimumSize(trim
.width
, trim
.height
);
292 protected void configureShell(Shell newShell
) {
293 super.configureShell(newShell
);
294 newShell
.setText(Messages
.TraceControl_CreateSessionDialogTitle
);
295 newShell
.setImage(Activator
.getDefault().loadIcon(CREATE_SESSION_ICON_FILE
));
299 protected Control
createDialogArea(Composite parent
) {
302 fDialogComposite
= new Composite(parent
, SWT
.NONE
);
303 GridLayout layout
= new GridLayout(1, true);
304 fDialogComposite
.setLayout(layout
);
305 fDialogComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
307 Group sessionGroup
= new Group(fDialogComposite
, SWT
.SHADOW_NONE
);
308 sessionGroup
.setLayoutData(new GridData(GridData
.FILL_HORIZONTAL
));
309 sessionGroup
.setLayout(new GridLayout(4, true));
311 Label sessionNameLabel
= new Label(sessionGroup
, SWT
.RIGHT
);
312 sessionNameLabel
.setText(Messages
.TraceControl_CreateSessionNameLabel
);
313 fSessionNameText
= new Text(sessionGroup
, SWT
.NONE
);
314 fSessionNameText
.setToolTipText(Messages
.TraceControl_CreateSessionNameTooltip
);
316 fSessionPathLabel
= new Label(sessionGroup
, SWT
.RIGHT
);
317 fSessionPathLabel
.setText(Messages
.TraceControl_CreateSessionPathLabel
);
318 fSessionPathText
= new Text(sessionGroup
, SWT
.NONE
);
319 fSessionPathText
.setToolTipText(Messages
.TraceControl_CreateSessionPathTooltip
);
322 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
323 data
.horizontalSpan
= 3;
325 fSessionNameText
.setLayoutData(data
);
327 data
= new GridData(GridData
.FILL_HORIZONTAL
);
328 data
.horizontalSpan
= 3;
329 fSessionPathText
.setLayoutData(data
);
331 if (fParent
.isNetworkStreamingSupported()) {
332 createAdvancedOptionsComposite();
335 return fDialogComposite
;
338 private void createAdvancedOptionsComposite() {
340 fMainStreamingGroup
= new Group(fDialogComposite
, SWT
.SHADOW_NONE
);
341 fMainStreamingGroup
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
342 fMainStreamingGroup
.setLayout(new GridLayout(1, true));
344 fConfigureStreamingButton
= new Button(fMainStreamingGroup
, SWT
.PUSH
);
345 fConfigureStreamingButton
.setText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonText
+ " >>>"); //$NON-NLS-1$
346 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonTooltip
);
347 fConfigureStreamingButton
.addSelectionListener(new SelectionAdapter() {
349 public void widgetSelected(SelectionEvent e
) {
350 if (fIsStreamedTrace
) {
351 fIsStreamedTrace
= false;
352 fConfigureStreamingButton
.setText(">>> " + Messages
.TraceControl_CreateSessionConfigureStreamingButtonText
); //$NON-NLS-1$
353 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonTooltip
);
354 fSessionPathText
.setEnabled(true);
355 fSessionPathLabel
.setText(Messages
.TraceControl_CreateSessionPathLabel
);
356 disposeConfigureStreamingComposite();
358 fIsStreamedTrace
= true;
359 fConfigureStreamingButton
.setText("<<< " + Messages
.TraceControl_CreateSessionNoStreamingButtonText
); //$NON-NLS-1$
360 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionNoStreamingButtonTooltip
);
361 fSessionPathText
.setEnabled(false);
362 fSessionPathText
.setText(""); //$NON-NLS-1$
363 fSessionPathLabel
.setText(""); //$NON-NLS-1$
364 createConfigureStreamingComposite();
367 fDialogComposite
.layout();
369 Point clientArea
= fControl
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
);
370 Rectangle trim
= getShell().computeTrim(0, 0, clientArea
.x
, clientArea
.y
);
371 getShell().setSize(trim
.width
, trim
.height
);
376 private void createConfigureStreamingComposite() {
377 if (fStreamingComposite
== null) {
378 fStreamingComposite
= new Composite(fMainStreamingGroup
, SWT
.NONE
);
379 GridLayout layout
= new GridLayout(1, true);
380 fStreamingComposite
.setLayout(layout
);
381 fStreamingComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
383 Group urlGroup
= new Group(fStreamingComposite
, SWT
.SHADOW_NONE
);
384 layout
= new GridLayout(7, true);
385 urlGroup
.setLayout(layout
);
386 urlGroup
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
388 Label tracePathLabel
= new Label(urlGroup
, SWT
.RIGHT
);
389 tracePathLabel
.setText(Messages
.TraceControl_CreateSessionTracePathText
);
390 fTracePathText
= new Text(urlGroup
, SWT
.NONE
);
391 fTracePathText
.setToolTipText(Messages
.TraceControl_CreateSessionTracePathTooltip
);
394 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
395 data
.horizontalSpan
= 6;
396 fTracePathText
.setLayoutData(data
);
398 fLinkDataWithControlButton
= new Button(urlGroup
, SWT
.CHECK
);
399 fLinkDataWithControlButton
.setText(Messages
.TraceControl_CreateSessionLinkButtonText
);
400 fLinkDataWithControlButton
.setToolTipText(Messages
.TraceControl_CreateSessionLinkButtonTooltip
);
401 data
= new GridData(GridData
.FILL_HORIZONTAL
);
402 data
.horizontalSpan
= 7;
403 fLinkDataWithControlButton
.setLayoutData(data
);
404 fLinkDataWithControlButton
.setSelection(true);
406 Label label
= new Label(urlGroup
, SWT
.NONE
);
407 data
= new GridData(GridData
.FILL_HORIZONTAL
);
408 data
.horizontalSpan
= 1;
409 label
.setLayoutData(data
);
411 label
= new Label(urlGroup
, SWT
.NONE
);
412 label
.setText(Messages
.TraceControl_CreateSessionProtocolLabelText
);
413 data
= new GridData(GridData
.FILL_HORIZONTAL
);
414 data
.horizontalSpan
= 1;
415 label
.setLayoutData(data
);
417 label
= new Label(urlGroup
, SWT
.NONE
);
418 label
.setText(Messages
.TraceControl_CreateSessionAddressLabelText
);
419 data
= new GridData(GridData
.FILL_HORIZONTAL
);
420 data
.horizontalSpan
= 4;
421 label
.setLayoutData(data
);
423 label
= new Label(urlGroup
, SWT
.NONE
);
424 label
.setText(Messages
.TraceControl_CreateSessionPortLabelText
);
425 data
= new GridData(GridData
.FILL_HORIZONTAL
);
426 data
.horizontalSpan
= 1;
427 label
.setLayoutData(data
);
429 label
= new Label(urlGroup
, SWT
.RIGHT
);
430 label
.setText(Messages
.TraceControl_CreateSessionControlUrlLabel
);
431 data
= new GridData(GridData
.FILL_HORIZONTAL
);
432 data
.horizontalSpan
= 1;
433 label
.setLayoutData(data
);
435 fControlProtocolCombo
= new CCombo(urlGroup
, SWT
.READ_ONLY
);
436 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionCommonProtocolTooltip
);
437 data
= new GridData(GridData
.FILL_HORIZONTAL
);
438 data
.horizontalSpan
= 1;
439 fControlProtocolCombo
.setLayoutData(data
);
441 fControlHostAddressText
= new Text(urlGroup
, SWT
.NONE
);
442 fControlHostAddressText
.setToolTipText(Messages
.TraceControl_CreateSessionControlAddressTooltip
);
443 data
= new GridData(GridData
.FILL_HORIZONTAL
);
444 data
.horizontalSpan
= 4;
445 fControlHostAddressText
.setLayoutData(data
);
447 fControlPortText
= new Text(urlGroup
, SWT
.NONE
);
448 fControlPortText
.setToolTipText(Messages
.TraceControl_CreateSessionControlPortTooltip
);
449 data
= new GridData(GridData
.FILL_HORIZONTAL
);
450 data
.horizontalSpan
= 1;
451 fControlPortText
.setLayoutData(data
);
453 label
= new Label(urlGroup
, SWT
.RIGHT
);
454 label
.setText(Messages
.TraceControl_CreateSessionDataUrlLabel
);
455 data
= new GridData(GridData
.FILL_HORIZONTAL
);
456 data
.horizontalSpan
= 1;
457 label
.setLayoutData(data
);
459 fDataProtocolCombo
= new CCombo(urlGroup
, SWT
.READ_ONLY
);
460 fDataProtocolCombo
.setEnabled(false);
461 fDataProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
462 data
= new GridData(GridData
.FILL_HORIZONTAL
);
463 data
.horizontalSpan
= 1;
464 fDataProtocolCombo
.setLayoutData(data
);
466 String items
[] = new String
[StreamingProtocol
.values().length
];
467 for (int i
= 0; i
< items
.length
; i
++) {
468 items
[i
] = StreamingProtocol
.values()[i
].name();
470 fControlProtocolCombo
.setItems(items
);
471 fDataProtocolCombo
.setItems(items
);
473 fDataHostAddressText
= new Text(urlGroup
, SWT
.NONE
);
474 fDataHostAddressText
.setEnabled(false);
475 fDataHostAddressText
.setToolTipText(Messages
.TraceControl_CreateSessionDataAddressTooltip
);
476 data
= new GridData(GridData
.FILL_HORIZONTAL
);
477 data
.horizontalSpan
= 4;
478 fDataHostAddressText
.setLayoutData(data
);
480 fDataPortText
= new Text(urlGroup
, SWT
.NONE
);
481 fDataPortText
.setEnabled(true);
482 fDataPortText
.setToolTipText(Messages
.TraceControl_CreateSessionDataPortTooltip
);
483 data
= new GridData(GridData
.FILL_HORIZONTAL
);
484 data
.horizontalSpan
= 1;
485 fDataPortText
.setLayoutData(data
);
487 fCopyProtocolSelectionListener
= new ControlProtocolSelectionListener();
488 fControlProtocolSelectionListener
= new ProtocolComboSelectionListener(fControlProtocolCombo
, fControlPortText
);
489 fDataProtocolSelectionListener
= new ProtocolComboSelectionListener(fDataProtocolCombo
, fDataPortText
);
491 fControlProtocolCombo
.addSelectionListener(fCopyProtocolSelectionListener
);
493 fControlUrlKeyListener
= new CopyModifyListener(fControlHostAddressText
, fDataHostAddressText
);
494 fControlHostAddressText
.addModifyListener(fControlUrlKeyListener
);
496 fControlProtocolCombo
.select(DEFAULT_URL_INDEX
);
497 fDataProtocolCombo
.select(DEFAULT_URL_INDEX
);
499 fLinkDataWithControlButton
.addSelectionListener(new SelectionAdapter() {
501 public void widgetSelected(SelectionEvent e
) {
502 if (fLinkDataWithControlButton
.getSelection()) {
503 // Set enablement control data channel inputs
504 fDataProtocolCombo
.setEnabled(false);
505 fDataHostAddressText
.setEnabled(false);
506 fControlPortText
.setEnabled(true);
507 fDataPortText
.setEnabled(true);
510 fControlProtocolCombo
.removeSelectionListener(fControlProtocolSelectionListener
);
511 fDataProtocolCombo
.removeSelectionListener(fDataProtocolSelectionListener
);
512 fControlProtocolCombo
.addSelectionListener(fCopyProtocolSelectionListener
);
513 fControlHostAddressText
.addModifyListener(fControlUrlKeyListener
);
515 // Get previous selection and validate
516 int currentSelection
= fControlProtocolCombo
.getSelectionIndex() <= COMMON_URL_LAST_INDEX ?
517 fControlProtocolCombo
.getSelectionIndex() : DEFAULT_URL_INDEX
;
519 // Update combo box items
520 fControlProtocolCombo
.removeAll();
521 String
[] controlItems
= new String
[StreamingProtocol
.values().length
];
522 for (int i
= 0; i
< controlItems
.length
; i
++) {
523 controlItems
[i
] = StreamingProtocol
.values()[i
].name();
525 fControlProtocolCombo
.setItems(controlItems
);
526 fDataProtocolCombo
.setItems(controlItems
);
529 fControlProtocolCombo
.select(currentSelection
);
530 fDataProtocolCombo
.select(currentSelection
);
531 fDataHostAddressText
.setText(fControlHostAddressText
.getText());
534 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionCommonProtocolTooltip
);
536 // Enable data channel inputs
537 fDataProtocolCombo
.setEnabled(true);
538 fDataHostAddressText
.setEnabled(true);
541 fControlProtocolCombo
.removeSelectionListener(fCopyProtocolSelectionListener
);
542 fControlProtocolCombo
.addSelectionListener(fControlProtocolSelectionListener
);
543 fDataProtocolCombo
.addSelectionListener(fDataProtocolSelectionListener
);
544 fControlHostAddressText
.removeModifyListener(fControlUrlKeyListener
);
546 // Update combo box items
547 int currentSelection
= fControlProtocolCombo
.getSelectionIndex();
548 fControlProtocolCombo
.removeAll();
549 String
[] controlItems
= new String
[StreamingProtocol2
.values().length
];
550 for (int i
= 0; i
< controlItems
.length
; i
++) {
551 controlItems
[i
] = StreamingProtocol2
.values()[i
].name();
553 fControlProtocolCombo
.setItems(controlItems
);
554 fDataProtocolCombo
.setItems(controlItems
);
557 fControlProtocolCombo
.select(currentSelection
);
558 fDataProtocolCombo
.select(currentSelection
);
561 fDataProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
562 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
564 // Update control/data port enablement and input
565 if (fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
566 fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
567 fControlPortText
.setText(""); //$NON-NLS-1$
568 fControlPortText
.setEnabled(false);
570 fControlPortText
.setEnabled(true);
573 if (fDataProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
574 fDataProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
575 fDataPortText
.setText(""); //$NON-NLS-1$
576 fDataPortText
.setEnabled(false);
578 fDataPortText
.setEnabled(true);
586 private void disposeConfigureStreamingComposite() {
587 if (fStreamingComposite
!= null) {
588 fStreamingComposite
.dispose();
589 fStreamingComposite
= null;
594 protected void createButtonsForButtonBar(Composite parent
) {
595 createButton(parent
, IDialogConstants
.CANCEL_ID
, "&Cancel", true); //$NON-NLS-1$
596 createButton(parent
, IDialogConstants
.OK_ID
, "&Ok", true); //$NON-NLS-1$
600 protected void okPressed() {
601 // Validate input data
602 fSessionName
= fSessionNameText
.getText();
603 fSessionPath
= fSessionPathText
.getText();
605 if (!"".equals(fSessionPath
)) { //$NON-NLS-1$
606 // validate sessionPath
607 if (!fIsStreamedTrace
) {
608 TargetNodeComponent node
= (TargetNodeComponent
)fParent
.getParent();
609 IRemoteSystemProxy proxy
= node
.getRemoteSystemProxy();
610 IFileServiceSubSystem fsss
= proxy
.getFileServiceSubSystem();
613 IRemoteFile remoteFolder
= fsss
.getRemoteFileObject(fSessionPath
, new NullProgressMonitor());
615 if (remoteFolder
== null) {
616 MessageDialog
.openError(getShell(),
617 Messages
.TraceControl_CreateSessionDialogTitle
,
618 Messages
.TraceControl_InvalidSessionPathError
+ " (" + fSessionPath
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
622 if (remoteFolder
.exists()) {
623 MessageDialog
.openError(getShell(),
624 Messages
.TraceControl_CreateSessionDialogTitle
,
625 Messages
.TraceControl_SessionPathAlreadyExistsError
+ " (" + fSessionPath
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
628 } catch (SystemMessageException e
) {
629 MessageDialog
.openError(getShell(),
630 Messages
.TraceControl_CreateSessionDialogTitle
,
631 Messages
.TraceControl_FileSubSystemError
+ "\n" + e
); //$NON-NLS-1$
636 fIsDefaultPath
= false;
643 if (fIsStreamedTrace
) {
644 // Validate input data
645 fTracePath
= fTracePathText
.getText();
647 if (fControlProtocolCombo
.getSelectionIndex() < 0) {
648 MessageDialog
.openError(getShell(),
649 Messages
.TraceControl_CreateSessionDialogTitle
,
650 "Control Protocol Text is empty\n"); //$NON-NLS-1$
654 if ("".equals(fControlHostAddressText
.getText())) { //$NON-NLS-1$
655 MessageDialog
.openError(getShell(),
656 Messages
.TraceControl_CreateSessionDialogTitle
,
657 "Control Address Text is empty\n"); //$NON-NLS-1$
661 if(!fLinkDataWithControlButton
.getSelection()) {
662 if (fDataProtocolCombo
.getSelectionIndex() < 0) {
663 MessageDialog
.openError(getShell(),
664 Messages
.TraceControl_CreateSessionDialogTitle
,
665 "Control Protocol Text is empty\n"); //$NON-NLS-1$
669 if ("".equals(fDataHostAddressText
.getText())) { //$NON-NLS-1$
670 MessageDialog
.openError(getShell(),
671 Messages
.TraceControl_CreateSessionDialogTitle
,
672 "Control Address Text is empty\n"); //$NON-NLS-1$
676 fControlUrl
= getUrlString(fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()),
677 fControlHostAddressText
.getText(),
678 fControlPortText
.getText(),
682 fDataUrl
= getUrlString(fControlProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()),
683 fDataHostAddressText
.getText(),
685 fDataPortText
.getText(),
688 fNetworkUrl
= getUrlString(fControlProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()),
689 fControlHostAddressText
.getText(),
690 fControlPortText
.getText(),
691 fDataPortText
.getText(),
696 // Check for invalid names
697 if (!"".equals(fSessionName
) && !fSessionName
.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
698 MessageDialog
.openError(getShell(),
699 Messages
.TraceControl_CreateSessionDialogTitle
,
700 Messages
.TraceControl_InvalidSessionNameError
+ " (" + fSessionName
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
704 // Check if node with name already exists in parent
705 if(fParent
.containsChild(fSessionName
)) {
706 MessageDialog
.openError(getShell(),
707 Messages
.TraceControl_CreateSessionDialogTitle
,
708 Messages
.TraceControl_SessionAlreadyExistsError
+ " (" + fSessionName
+ ")"); //$NON-NLS-1$ //$NON-NLS-2$
712 // validation successful -> call super.okPressed()
716 private static String
getUrlString(String proto
, String host
, String ctrlPort
, String dataPort
, String sessionPath
) {
717 //proto://[HOST|IP][:PORT1[:PORT2]][/TRACE_PATH]
718 StringBuilder stringBuilder
= new StringBuilder();
719 stringBuilder
.append(proto
);
720 stringBuilder
.append("://"); //$NON-NLS-1$
721 stringBuilder
.append(host
);
723 if ((ctrlPort
!= null) && (!"".equals(ctrlPort
))) { //$NON-NLS-1$
724 stringBuilder
.append(":"); //$NON-NLS-1$
725 stringBuilder
.append(ctrlPort
);
728 if ((dataPort
!= null) && (!"".equals(dataPort
))) { //$NON-NLS-1$
729 stringBuilder
.append(":"); //$NON-NLS-1$
730 stringBuilder
.append(dataPort
);
733 if ((sessionPath
!= null) && (!"".equals(sessionPath
))) { //$NON-NLS-1$
734 stringBuilder
.append("/"); //$NON-NLS-1$
735 stringBuilder
.append(sessionPath
);
737 return stringBuilder
.toString();
740 private static class CopyModifyListener
implements ModifyListener
{
741 private Text fSource
;
742 private Text fDestination
;
744 public CopyModifyListener(Text source
, Text destination
) {
746 fDestination
= destination
;
750 public void modifyText(ModifyEvent e
) {
751 fDestination
.setText(fSource
.getText());
755 private class ControlProtocolSelectionListener
extends SelectionAdapter
{
758 public void widgetSelected(SelectionEvent e
) {
759 fDataProtocolCombo
.select(fControlProtocolCombo
.getSelectionIndex());
760 if (fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.file
.name())) {
761 fControlPortText
.setText(""); //$NON-NLS-1$
762 fDataPortText
.setText(""); //$NON-NLS-1$
763 fControlPortText
.setEnabled(false);
764 fDataPortText
.setEnabled(false);
766 fControlPortText
.setEnabled(true);
767 fDataPortText
.setEnabled(true);
772 private class ProtocolComboSelectionListener
extends SelectionAdapter
{
774 private CCombo fCombo
;
775 private Text fPortText
;
777 public ProtocolComboSelectionListener(CCombo combo
, Text portText
) {
779 fPortText
= portText
;
783 public void widgetSelected(SelectionEvent e
) {
784 if (fCombo
.getItem(fCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
785 fCombo
.getItem(fCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
786 fPortText
.setText(""); //$NON-NLS-1$
787 fPortText
.setEnabled(false);
789 fPortText
.setEnabled(true);