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 button widget to select a snapshot session
117 private Button fSnapshotButton
= null;
119 * The Group for stream configuration.
121 private Group fMainStreamingGroup
= null;
123 * The button to show streaming options.
125 private Button fConfigureStreamingButton
= null;
127 * The composite with streaming configuration parameter.
129 private Composite fStreamingComposite
= null;
131 * The text widget for the trace path.
133 private Text fTracePathText
= null;
135 * The button to link data protocol/Address with control protocol.
137 private Button fLinkDataWithControlButton
= null;
139 * The Combo box for channel protocol selection.
141 private CCombo fControlProtocolCombo
= null;
143 * A selection listener that copies the protocol from control to data when being linked.
145 private ControlProtocolSelectionListener fCopyProtocolSelectionListener
;
147 * A selection listener updates the control port text depending on the control protocol selected.
149 private ProtocolComboSelectionListener fControlProtocolSelectionListener
;
151 * A selection listener updates the data port text depending on the data protocol selected.
153 private ProtocolComboSelectionListener fDataProtocolSelectionListener
;
155 * The text box for the host/IP address of the control channel.
157 private Text fControlHostAddressText
= null;
159 * A key listener that copies the host address from control to data when being linked.
161 private CopyModifyListener fControlUrlKeyListener
;
163 * The text box for the control port.
165 private Text fControlPortText
= null;
167 * The Combo box for data protocol selection.
169 private CCombo fDataProtocolCombo
= null;
171 * The text box for the host/IP address of the data channel.
173 private Text fDataHostAddressText
= null;
175 * The text box for the data port.
177 private Text fDataPortText
= null;
179 * The parent where the new node should be added.
181 private TraceSessionGroup fParent
= null;
183 * The session name string.
185 private String fSessionName
= null;
187 * The session path string.
189 private String fSessionPath
= null;
191 * The session path string.
193 private boolean fIsSnapshot
= false;
195 * Flag whether default location (path) shall be used or not
197 private boolean fIsDefaultPath
= true;
199 * Flag whether the trace is streamed or not
201 private boolean fIsStreamedTrace
= false;
203 * The network URL in case control and data is configured together.
204 * If set, fControlUrl and fDataUrl will be null.
206 private String fNetworkUrl
= null;
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.
211 private String fControlUrl
= null;
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.
216 private String fDataUrl
= null;
218 * The trace path string.
220 private String fTracePath
= null;
222 // ------------------------------------------------------------------------
224 // ------------------------------------------------------------------------
227 * @param shell - a shell for the display of the dialog
229 public CreateSessionDialog(Shell shell
) {
231 setShellStyle(SWT
.RESIZE
| getShellStyle());
234 // ------------------------------------------------------------------------
236 // ------------------------------------------------------------------------
239 public String
getSessionName() {
244 public String
getSessionPath() {
249 public boolean isDefaultSessionPath() {
250 return fIsDefaultPath
;
254 public void initialize(TraceSessionGroup group
) {
256 fStreamingComposite
= null;
260 fIsDefaultPath
= true;
261 fIsStreamedTrace
= false;
268 public boolean isStreamedTrace() {
269 return fIsStreamedTrace
;
272 public String
getNetworkUrl() {
276 public String
getControlUrl() {
280 public String
getDataUrl() {
284 public boolean isSnapshot() {
287 // ------------------------------------------------------------------------
289 // ------------------------------------------------------------------------
292 protected Control
createContents(Composite parent
) {
293 fControl
= super.createContents(parent
);
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
);
304 protected void configureShell(Shell newShell
) {
305 super.configureShell(newShell
);
306 newShell
.setText(Messages
.TraceControl_CreateSessionDialogTitle
);
307 newShell
.setImage(Activator
.getDefault().loadIcon(CREATE_SESSION_ICON_FILE
));
311 protected Control
createDialogArea(Composite parent
) {
314 fDialogComposite
= new Composite(parent
, SWT
.NONE
);
315 GridLayout layout
= new GridLayout(1, true);
316 fDialogComposite
.setLayout(layout
);
317 fDialogComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
319 Group sessionGroup
= new Group(fDialogComposite
, SWT
.SHADOW_NONE
);
320 sessionGroup
.setLayoutData(new GridData(GridData
.FILL_HORIZONTAL
));
321 sessionGroup
.setLayout(new GridLayout(4, true));
323 Label sessionNameLabel
= new Label(sessionGroup
, SWT
.RIGHT
);
324 sessionNameLabel
.setText(Messages
.TraceControl_CreateSessionNameLabel
);
325 fSessionNameText
= new Text(sessionGroup
, SWT
.NONE
);
326 fSessionNameText
.setToolTipText(Messages
.TraceControl_CreateSessionNameTooltip
);
328 fSessionPathLabel
= new Label(sessionGroup
, SWT
.RIGHT
);
329 fSessionPathLabel
.setText(Messages
.TraceControl_CreateSessionPathLabel
);
330 fSessionPathText
= new Text(sessionGroup
, SWT
.NONE
);
331 fSessionPathText
.setToolTipText(Messages
.TraceControl_CreateSessionPathTooltip
);
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
);
343 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
344 data
.horizontalSpan
= 3;
346 fSessionNameText
.setLayoutData(data
);
348 data
= new GridData(GridData
.FILL_HORIZONTAL
);
349 data
.horizontalSpan
= 3;
350 fSessionPathText
.setLayoutData(data
);
352 if (fParent
.isNetworkStreamingSupported()) {
353 createAdvancedOptionsComposite();
356 return fDialogComposite
;
359 private void createAdvancedOptionsComposite() {
361 fMainStreamingGroup
= new Group(fDialogComposite
, SWT
.SHADOW_NONE
);
362 fMainStreamingGroup
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
363 fMainStreamingGroup
.setLayout(new GridLayout(1, true));
365 fConfigureStreamingButton
= new Button(fMainStreamingGroup
, SWT
.PUSH
);
366 fConfigureStreamingButton
.setText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonText
+ " >>>"); //$NON-NLS-1$
367 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonTooltip
);
368 fConfigureStreamingButton
.addSelectionListener(new SelectionAdapter() {
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
);
375 fSessionPathText
.setEnabled(true);
376 fSessionPathLabel
.setText(Messages
.TraceControl_CreateSessionPathLabel
);
377 disposeConfigureStreamingComposite();
379 fIsStreamedTrace
= true;
380 fConfigureStreamingButton
.setText("<<< " + Messages
.TraceControl_CreateSessionNoStreamingButtonText
); //$NON-NLS-1$
381 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionNoStreamingButtonTooltip
);
382 fSessionPathText
.setEnabled(false);
383 fSessionPathText
.setText(""); //$NON-NLS-1$
384 fSessionPathLabel
.setText(""); //$NON-NLS-1$
385 createConfigureStreamingComposite();
388 fDialogComposite
.layout();
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
);
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
));
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
));
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
);
415 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
416 data
.horizontalSpan
= 6;
417 fTracePathText
.setLayoutData(data
);
419 fLinkDataWithControlButton
= new Button(urlGroup
, SWT
.CHECK
);
420 fLinkDataWithControlButton
.setText(Messages
.TraceControl_CreateSessionLinkButtonText
);
421 fLinkDataWithControlButton
.setToolTipText(Messages
.TraceControl_CreateSessionLinkButtonTooltip
);
422 data
= new GridData(GridData
.FILL_HORIZONTAL
);
423 data
.horizontalSpan
= 7;
424 fLinkDataWithControlButton
.setLayoutData(data
);
425 fLinkDataWithControlButton
.setSelection(true);
427 Label label
= new Label(urlGroup
, SWT
.NONE
);
428 data
= new GridData(GridData
.FILL_HORIZONTAL
);
429 data
.horizontalSpan
= 1;
430 label
.setLayoutData(data
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
487 String items
[] = new String
[StreamingProtocol
.values().length
];
488 for (int i
= 0; i
< items
.length
; i
++) {
489 items
[i
] = StreamingProtocol
.values()[i
].name();
491 fControlProtocolCombo
.setItems(items
);
492 fDataProtocolCombo
.setItems(items
);
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
);
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
);
508 fCopyProtocolSelectionListener
= new ControlProtocolSelectionListener();
509 fControlProtocolSelectionListener
= new ProtocolComboSelectionListener(fControlProtocolCombo
, fControlPortText
);
510 fDataProtocolSelectionListener
= new ProtocolComboSelectionListener(fDataProtocolCombo
, fDataPortText
);
512 fControlProtocolCombo
.addSelectionListener(fCopyProtocolSelectionListener
);
514 fControlUrlKeyListener
= new CopyModifyListener(fControlHostAddressText
, fDataHostAddressText
);
515 fControlHostAddressText
.addModifyListener(fControlUrlKeyListener
);
517 fControlProtocolCombo
.select(DEFAULT_URL_INDEX
);
518 fDataProtocolCombo
.select(DEFAULT_URL_INDEX
);
520 fLinkDataWithControlButton
.addSelectionListener(new SelectionAdapter() {
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);
531 fControlProtocolCombo
.removeSelectionListener(fControlProtocolSelectionListener
);
532 fDataProtocolCombo
.removeSelectionListener(fDataProtocolSelectionListener
);
533 fControlProtocolCombo
.addSelectionListener(fCopyProtocolSelectionListener
);
534 fControlHostAddressText
.addModifyListener(fControlUrlKeyListener
);
536 // Get previous selection and validate
537 int currentSelection
= fControlProtocolCombo
.getSelectionIndex() <= COMMON_URL_LAST_INDEX ?
538 fControlProtocolCombo
.getSelectionIndex() : DEFAULT_URL_INDEX
;
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();
546 fControlProtocolCombo
.setItems(controlItems
);
547 fDataProtocolCombo
.setItems(controlItems
);
550 fControlProtocolCombo
.select(currentSelection
);
551 fDataProtocolCombo
.select(currentSelection
);
552 fDataHostAddressText
.setText(fControlHostAddressText
.getText());
555 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionCommonProtocolTooltip
);
557 // Enable data channel inputs
558 fDataProtocolCombo
.setEnabled(true);
559 fDataHostAddressText
.setEnabled(true);
562 fControlProtocolCombo
.removeSelectionListener(fCopyProtocolSelectionListener
);
563 fControlProtocolCombo
.addSelectionListener(fControlProtocolSelectionListener
);
564 fDataProtocolCombo
.addSelectionListener(fDataProtocolSelectionListener
);
565 fControlHostAddressText
.removeModifyListener(fControlUrlKeyListener
);
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();
574 fControlProtocolCombo
.setItems(controlItems
);
575 fDataProtocolCombo
.setItems(controlItems
);
578 fControlProtocolCombo
.select(currentSelection
);
579 fDataProtocolCombo
.select(currentSelection
);
582 fDataProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
583 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
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);
591 fControlPortText
.setEnabled(true);
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);
599 fDataPortText
.setEnabled(true);
607 private void disposeConfigureStreamingComposite() {
608 if (fStreamingComposite
!= null) {
609 fStreamingComposite
.dispose();
610 fStreamingComposite
= null;
615 protected void createButtonsForButtonBar(Composite parent
) {
616 createButton(parent
, IDialogConstants
.CANCEL_ID
, "&Cancel", true); //$NON-NLS-1$
617 createButton(parent
, IDialogConstants
.OK_ID
, "&Ok", true); //$NON-NLS-1$
621 protected void okPressed() {
622 // Validate input data
623 fSessionName
= fSessionNameText
.getText();
624 fSessionPath
= fSessionPathText
.getText();
626 if (!"".equals(fSessionPath
)) { //$NON-NLS-1$
627 // validate sessionPath
628 if (!fIsStreamedTrace
) {
629 TargetNodeComponent node
= (TargetNodeComponent
)fParent
.getParent();
630 IRemoteSystemProxy proxy
= node
.getRemoteSystemProxy();
631 IFileServiceSubSystem fsss
= proxy
.getFileServiceSubSystem();
634 IRemoteFile remoteFolder
= fsss
.getRemoteFileObject(fSessionPath
, new NullProgressMonitor());
636 if (remoteFolder
== null) {
637 MessageDialog
.openError(getShell(),
638 Messages
.TraceControl_CreateSessionDialogTitle
,
639 Messages
.TraceControl_InvalidSessionPathError
+ " (" + fSessionPath
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
643 if (remoteFolder
.exists()) {
644 MessageDialog
.openError(getShell(),
645 Messages
.TraceControl_CreateSessionDialogTitle
,
646 Messages
.TraceControl_SessionPathAlreadyExistsError
+ " (" + fSessionPath
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
649 } catch (SystemMessageException e
) {
650 MessageDialog
.openError(getShell(),
651 Messages
.TraceControl_CreateSessionDialogTitle
,
652 Messages
.TraceControl_FileSubSystemError
+ "\n" + e
); //$NON-NLS-1$
657 fIsDefaultPath
= false;
660 if(fParent
.isSnapshotSupported()) {
661 fIsSnapshot
= fSnapshotButton
.getSelection();
668 if (fIsStreamedTrace
) {
669 // Validate input data
670 fTracePath
= fTracePathText
.getText();
672 if (fControlProtocolCombo
.getSelectionIndex() < 0) {
673 MessageDialog
.openError(getShell(),
674 Messages
.TraceControl_CreateSessionDialogTitle
,
675 "Control Protocol Text is empty\n"); //$NON-NLS-1$
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$
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$
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$
701 fControlUrl
= getUrlString(fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()),
702 fControlHostAddressText
.getText(),
703 fControlPortText
.getText(),
707 fDataUrl
= getUrlString(fControlProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()),
708 fDataHostAddressText
.getText(),
710 fDataPortText
.getText(),
713 fNetworkUrl
= getUrlString(fControlProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()),
714 fControlHostAddressText
.getText(),
715 fControlPortText
.getText(),
716 fDataPortText
.getText(),
721 // Check for invalid names
722 if (!"".equals(fSessionName
) && !fSessionName
.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
723 MessageDialog
.openError(getShell(),
724 Messages
.TraceControl_CreateSessionDialogTitle
,
725 Messages
.TraceControl_InvalidSessionNameError
+ " (" + fSessionName
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
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$
737 // validation successful -> call super.okPressed()
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
);
748 if ((ctrlPort
!= null) && (!"".equals(ctrlPort
))) { //$NON-NLS-1$
749 stringBuilder
.append(":"); //$NON-NLS-1$
750 stringBuilder
.append(ctrlPort
);
753 if ((dataPort
!= null) && (!"".equals(dataPort
))) { //$NON-NLS-1$
754 stringBuilder
.append(":"); //$NON-NLS-1$
755 stringBuilder
.append(dataPort
);
758 if ((sessionPath
!= null) && (!"".equals(sessionPath
))) { //$NON-NLS-1$
759 stringBuilder
.append("/"); //$NON-NLS-1$
760 stringBuilder
.append(sessionPath
);
762 return stringBuilder
.toString();
765 private static class CopyModifyListener
implements ModifyListener
{
766 private Text fSource
;
767 private Text fDestination
;
769 public CopyModifyListener(Text source
, Text destination
) {
771 fDestination
= destination
;
775 public void modifyText(ModifyEvent e
) {
776 fDestination
.setText(fSource
.getText());
780 private class ControlProtocolSelectionListener
extends SelectionAdapter
{
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);
791 fControlPortText
.setEnabled(true);
792 fDataPortText
.setEnabled(true);
797 private class ProtocolComboSelectionListener
extends SelectionAdapter
{
799 private CCombo fCombo
;
800 private Text fPortText
;
802 public ProtocolComboSelectionListener(CCombo combo
, Text portText
) {
804 fPortText
= portText
;
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);
814 fPortText
.setEnabled(true);