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 final static int COMMON_URL_LAST_INDEX
= 1;
89 * Index of default streaming protocol.
91 private final static 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 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateSessionDialog#getSessionName()
234 public String
getSessionName() {
240 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateSessionDialog#getSessionPath()
243 public String
getSessionPath() {
249 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateSessionDialog#isDefaultSessionPath()
252 public boolean isDefaultSessionPath() {
253 return fIsDefaultPath
;
258 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateSessionDialog#initialze(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionGroup)
261 public void initialize(TraceSessionGroup group
) {
263 fStreamingComposite
= null;
266 fIsDefaultPath
= true;
267 fIsStreamedTrace
= false;
274 public boolean isStreamedTrace() {
275 return fIsStreamedTrace
;
278 public String
getNetworkUrl() {
282 public String
getControlUrl() {
286 public String
getDataUrl() {
290 // ------------------------------------------------------------------------
292 // ------------------------------------------------------------------------
296 * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite)
299 protected Control
createContents(Composite parent
) {
300 fControl
= super.createContents(parent
);
302 /* set the shell minimum size */
303 Point clientArea
= fControl
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
);
304 Rectangle trim
= getShell().computeTrim(0, 0, clientArea
.x
, clientArea
.y
);
305 getShell().setMinimumSize(trim
.width
, trim
.height
);
311 * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
314 protected void configureShell(Shell newShell
) {
315 super.configureShell(newShell
);
316 newShell
.setText(Messages
.TraceControl_CreateSessionDialogTitle
);
317 newShell
.setImage(Activator
.getDefault().loadIcon(CREATE_SESSION_ICON_FILE
));
322 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
325 protected Control
createDialogArea(Composite parent
) {
328 fDialogComposite
= new Composite(parent
, SWT
.NONE
);
329 GridLayout layout
= new GridLayout(1, true);
330 fDialogComposite
.setLayout(layout
);
331 fDialogComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
333 Group sessionGroup
= new Group(fDialogComposite
, SWT
.SHADOW_NONE
);
334 sessionGroup
.setLayoutData(new GridData(GridData
.FILL_HORIZONTAL
));
335 sessionGroup
.setLayout(new GridLayout(4, true));
337 Label sessionNameLabel
= new Label(sessionGroup
, SWT
.RIGHT
);
338 sessionNameLabel
.setText(Messages
.TraceControl_CreateSessionNameLabel
);
339 fSessionNameText
= new Text(sessionGroup
, SWT
.NONE
);
340 fSessionNameText
.setToolTipText(Messages
.TraceControl_CreateSessionNameTooltip
);
342 fSessionPathLabel
= new Label(sessionGroup
, SWT
.RIGHT
);
343 fSessionPathLabel
.setText(Messages
.TraceControl_CreateSessionPathLabel
);
344 fSessionPathText
= new Text(sessionGroup
, SWT
.NONE
);
345 fSessionPathText
.setToolTipText(Messages
.TraceControl_CreateSessionPathTooltip
);
348 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
349 data
.horizontalSpan
= 3;
351 fSessionNameText
.setLayoutData(data
);
353 data
= new GridData(GridData
.FILL_HORIZONTAL
);
354 data
.horizontalSpan
= 3;
355 fSessionPathText
.setLayoutData(data
);
357 if (fParent
.isNetworkStreamingSupported()) {
358 createAdvancedOptionsComposite();
361 return fDialogComposite
;
364 private void createAdvancedOptionsComposite() {
366 fMainStreamingGroup
= new Group(fDialogComposite
, SWT
.SHADOW_NONE
);
367 fMainStreamingGroup
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
368 fMainStreamingGroup
.setLayout(new GridLayout(1, true));
370 fConfigureStreamingButton
= new Button(fMainStreamingGroup
, SWT
.PUSH
);
371 fConfigureStreamingButton
.setText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonText
+ " >>>"); //$NON-NLS-1$
372 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonTooltip
);
373 fConfigureStreamingButton
.addSelectionListener(new SelectionAdapter() {
375 public void widgetSelected(SelectionEvent e
) {
376 if (fIsStreamedTrace
) {
377 fIsStreamedTrace
= false;
378 fConfigureStreamingButton
.setText(">>> " + Messages
.TraceControl_CreateSessionConfigureStreamingButtonText
); //$NON-NLS-1$
379 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonTooltip
);
380 fSessionPathText
.setEnabled(true);
381 fSessionPathLabel
.setText(Messages
.TraceControl_CreateSessionPathLabel
);
382 disposeConfigureStreamingComposite();
384 fIsStreamedTrace
= true;
385 fConfigureStreamingButton
.setText("<<< " + Messages
.TraceControl_CreateSessionNoStreamingButtonText
); //$NON-NLS-1$
386 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionNoStreamingButtonTooltip
);
387 fSessionPathText
.setEnabled(false);
388 fSessionPathText
.setText(""); //$NON-NLS-1$
389 fSessionPathLabel
.setText(""); //$NON-NLS-1$
390 createConfigureStreamingComposite();
393 fDialogComposite
.layout();
395 Point clientArea
= fControl
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
);
396 Rectangle trim
= getShell().computeTrim(0, 0, clientArea
.x
, clientArea
.y
);
397 getShell().setSize(trim
.width
, trim
.height
);
402 private void createConfigureStreamingComposite() {
403 if (fStreamingComposite
== null) {
404 fStreamingComposite
= new Composite(fMainStreamingGroup
, SWT
.NONE
);
405 GridLayout layout
= new GridLayout(1, true);
406 fStreamingComposite
.setLayout(layout
);
407 fStreamingComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
409 Group urlGroup
= new Group(fStreamingComposite
, SWT
.SHADOW_NONE
);
410 layout
= new GridLayout(7, true);
411 urlGroup
.setLayout(layout
);
412 urlGroup
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
414 Label tracePathLabel
= new Label(urlGroup
, SWT
.RIGHT
);
415 tracePathLabel
.setText(Messages
.TraceControl_CreateSessionTracePathText
);
416 fTracePathText
= new Text(urlGroup
, SWT
.NONE
);
417 fTracePathText
.setToolTipText(Messages
.TraceControl_CreateSessionTracePathTooltip
);
420 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
421 data
.horizontalSpan
= 6;
422 fTracePathText
.setLayoutData(data
);
424 fLinkDataWithControlButton
= new Button(urlGroup
, SWT
.CHECK
);
425 fLinkDataWithControlButton
.setText(Messages
.TraceControl_CreateSessionLinkButtonText
);
426 fLinkDataWithControlButton
.setToolTipText(Messages
.TraceControl_CreateSessionLinkButtonTooltip
);
427 data
= new GridData(GridData
.FILL_HORIZONTAL
);
428 data
.horizontalSpan
= 7;
429 fLinkDataWithControlButton
.setLayoutData(data
);
430 fLinkDataWithControlButton
.setSelection(true);
432 Label label
= new Label(urlGroup
, SWT
.NONE
);
433 data
= new GridData(GridData
.FILL_HORIZONTAL
);
434 data
.horizontalSpan
= 1;
435 label
.setLayoutData(data
);
437 label
= new Label(urlGroup
, SWT
.NONE
);
438 label
.setText(Messages
.TraceControl_CreateSessionProtocolLabelText
);
439 data
= new GridData(GridData
.FILL_HORIZONTAL
);
440 data
.horizontalSpan
= 1;
441 label
.setLayoutData(data
);
443 label
= new Label(urlGroup
, SWT
.NONE
);
444 label
.setText(Messages
.TraceControl_CreateSessionAddressLabelText
);
445 data
= new GridData(GridData
.FILL_HORIZONTAL
);
446 data
.horizontalSpan
= 4;
447 label
.setLayoutData(data
);
449 label
= new Label(urlGroup
, SWT
.NONE
);
450 label
.setText(Messages
.TraceControl_CreateSessionPortLabelText
);
451 data
= new GridData(GridData
.FILL_HORIZONTAL
);
452 data
.horizontalSpan
= 1;
453 label
.setLayoutData(data
);
455 label
= new Label(urlGroup
, SWT
.RIGHT
);
456 label
.setText(Messages
.TraceControl_CreateSessionControlUrlLabel
);
457 data
= new GridData(GridData
.FILL_HORIZONTAL
);
458 data
.horizontalSpan
= 1;
459 label
.setLayoutData(data
);
461 fControlProtocolCombo
= new CCombo(urlGroup
, SWT
.READ_ONLY
);
462 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionCommonProtocolTooltip
);
463 data
= new GridData(GridData
.FILL_HORIZONTAL
);
464 data
.horizontalSpan
= 1;
465 fControlProtocolCombo
.setLayoutData(data
);
467 fControlHostAddressText
= new Text(urlGroup
, SWT
.NONE
);
468 fControlHostAddressText
.setToolTipText(Messages
.TraceControl_CreateSessionControlAddressTooltip
);
469 data
= new GridData(GridData
.FILL_HORIZONTAL
);
470 data
.horizontalSpan
= 4;
471 fControlHostAddressText
.setLayoutData(data
);
473 fControlPortText
= new Text(urlGroup
, SWT
.NONE
);
474 fControlPortText
.setToolTipText(Messages
.TraceControl_CreateSessionControlPortTooltip
);
475 data
= new GridData(GridData
.FILL_HORIZONTAL
);
476 data
.horizontalSpan
= 1;
477 fControlPortText
.setLayoutData(data
);
479 label
= new Label(urlGroup
, SWT
.RIGHT
);
480 label
.setText(Messages
.TraceControl_CreateSessionDataUrlLabel
);
481 data
= new GridData(GridData
.FILL_HORIZONTAL
);
482 data
.horizontalSpan
= 1;
483 label
.setLayoutData(data
);
485 fDataProtocolCombo
= new CCombo(urlGroup
, SWT
.READ_ONLY
);
486 fDataProtocolCombo
.setEnabled(false);
487 fDataProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
488 data
= new GridData(GridData
.FILL_HORIZONTAL
);
489 data
.horizontalSpan
= 1;
490 fDataProtocolCombo
.setLayoutData(data
);
492 String items
[] = new String
[StreamingProtocol
.values().length
];
493 for (int i
= 0; i
< items
.length
; i
++) {
494 items
[i
] = StreamingProtocol
.values()[i
].name();
496 fControlProtocolCombo
.setItems(items
);
497 fDataProtocolCombo
.setItems(items
);
499 fDataHostAddressText
= new Text(urlGroup
, SWT
.NONE
);
500 fDataHostAddressText
.setEnabled(false);
501 fDataHostAddressText
.setToolTipText(Messages
.TraceControl_CreateSessionDataAddressTooltip
);
502 data
= new GridData(GridData
.FILL_HORIZONTAL
);
503 data
.horizontalSpan
= 4;
504 fDataHostAddressText
.setLayoutData(data
);
506 fDataPortText
= new Text(urlGroup
, SWT
.NONE
);
507 fDataPortText
.setEnabled(true);
508 fDataPortText
.setToolTipText(Messages
.TraceControl_CreateSessionDataPortTooltip
);
509 data
= new GridData(GridData
.FILL_HORIZONTAL
);
510 data
.horizontalSpan
= 1;
511 fDataPortText
.setLayoutData(data
);
513 fCopyProtocolSelectionListener
= new ControlProtocolSelectionListener();
514 fControlProtocolSelectionListener
= new ProtocolComboSelectionListener(fControlProtocolCombo
, fControlPortText
);
515 fDataProtocolSelectionListener
= new ProtocolComboSelectionListener(fDataProtocolCombo
, fDataPortText
);
517 fControlProtocolCombo
.addSelectionListener(fCopyProtocolSelectionListener
);
519 fControlUrlKeyListener
= new CopyModifyListener(fControlHostAddressText
, fDataHostAddressText
);
520 fControlHostAddressText
.addModifyListener(fControlUrlKeyListener
);
522 fControlProtocolCombo
.select(DEFAULT_URL_INDEX
);
523 fDataProtocolCombo
.select(DEFAULT_URL_INDEX
);
525 fLinkDataWithControlButton
.addSelectionListener(new SelectionAdapter() {
527 public void widgetSelected(SelectionEvent e
) {
528 if (fLinkDataWithControlButton
.getSelection()) {
529 // Set enablement control data channel inputs
530 fDataProtocolCombo
.setEnabled(false);
531 fDataHostAddressText
.setEnabled(false);
532 fControlPortText
.setEnabled(true);
533 fDataPortText
.setEnabled(true);
536 fControlProtocolCombo
.removeSelectionListener(fControlProtocolSelectionListener
);
537 fDataProtocolCombo
.removeSelectionListener(fDataProtocolSelectionListener
);
538 fControlProtocolCombo
.addSelectionListener(fCopyProtocolSelectionListener
);
539 fControlHostAddressText
.addModifyListener(fControlUrlKeyListener
);
541 // Get previous selection and validate
542 int currentSelection
= fControlProtocolCombo
.getSelectionIndex() <= COMMON_URL_LAST_INDEX ?
543 fControlProtocolCombo
.getSelectionIndex() : DEFAULT_URL_INDEX
;
545 // Update combo box items
546 fControlProtocolCombo
.removeAll();
547 String
[] controlItems
= new String
[StreamingProtocol
.values().length
];
548 for (int i
= 0; i
< controlItems
.length
; i
++) {
549 controlItems
[i
] = StreamingProtocol
.values()[i
].name();
551 fControlProtocolCombo
.setItems(controlItems
);
552 fDataProtocolCombo
.setItems(controlItems
);
555 fControlProtocolCombo
.select(currentSelection
);
556 fDataProtocolCombo
.select(currentSelection
);
557 fDataHostAddressText
.setText(fControlHostAddressText
.getText());
560 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionCommonProtocolTooltip
);
562 // Enable data channel inputs
563 fDataProtocolCombo
.setEnabled(true);
564 fDataHostAddressText
.setEnabled(true);
567 fControlProtocolCombo
.removeSelectionListener(fCopyProtocolSelectionListener
);
568 fControlProtocolCombo
.addSelectionListener(fControlProtocolSelectionListener
);
569 fDataProtocolCombo
.addSelectionListener(fDataProtocolSelectionListener
);
570 fControlHostAddressText
.removeModifyListener(fControlUrlKeyListener
);
572 // Update combo box items
573 int currentSelection
= fControlProtocolCombo
.getSelectionIndex();
574 fControlProtocolCombo
.removeAll();
575 String
[] controlItems
= new String
[StreamingProtocol2
.values().length
];
576 for (int i
= 0; i
< controlItems
.length
; i
++) {
577 controlItems
[i
] = StreamingProtocol2
.values()[i
].name();
579 fControlProtocolCombo
.setItems(controlItems
);
580 fDataProtocolCombo
.setItems(controlItems
);
583 fControlProtocolCombo
.select(currentSelection
);
584 fDataProtocolCombo
.select(currentSelection
);
587 fDataProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
588 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
590 // Update control/data port enablement and input
591 if (fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
592 fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
593 fControlPortText
.setText(""); //$NON-NLS-1$
594 fControlPortText
.setEnabled(false);
596 fControlPortText
.setEnabled(true);
599 if (fDataProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
600 fDataProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
601 fDataPortText
.setText(""); //$NON-NLS-1$
602 fDataPortText
.setEnabled(false);
604 fDataPortText
.setEnabled(true);
612 private void disposeConfigureStreamingComposite() {
613 if (fStreamingComposite
!= null) {
614 fStreamingComposite
.dispose();
615 fStreamingComposite
= null;
621 * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
624 protected void createButtonsForButtonBar(Composite parent
) {
625 createButton(parent
, IDialogConstants
.CANCEL_ID
, "&Cancel", true); //$NON-NLS-1$
626 createButton(parent
, IDialogConstants
.OK_ID
, "&Ok", true); //$NON-NLS-1$
631 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
634 protected void okPressed() {
635 // Validate input data
636 fSessionName
= fSessionNameText
.getText();
637 fSessionPath
= fSessionPathText
.getText();
639 if (!"".equals(fSessionPath
)) { //$NON-NLS-1$
640 // validate sessionPath
641 if (!fIsStreamedTrace
) {
642 TargetNodeComponent node
= (TargetNodeComponent
)fParent
.getParent();
643 IRemoteSystemProxy proxy
= node
.getRemoteSystemProxy();
644 IFileServiceSubSystem fsss
= proxy
.getFileServiceSubSystem();
647 IRemoteFile remoteFolder
= fsss
.getRemoteFileObject(fSessionPath
, new NullProgressMonitor());
648 if (remoteFolder
.exists()) {
649 MessageDialog
.openError(getShell(),
650 Messages
.TraceControl_CreateSessionDialogTitle
,
651 Messages
.TraceControl_SessionPathAlreadyExistsError
+ " (" + fSessionPath
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
654 } catch (SystemMessageException e
) {
655 MessageDialog
.openError(getShell(),
656 Messages
.TraceControl_CreateSessionDialogTitle
,
657 Messages
.TraceControl_FileSubSystemError
+ "\n" + e
); //$NON-NLS-1$
662 fIsDefaultPath
= false;
669 if (fIsStreamedTrace
) {
670 // Validate input data
671 fTracePath
= fTracePathText
.getText();
673 if (fControlProtocolCombo
.getSelectionIndex() < 0) {
674 MessageDialog
.openError(getShell(),
675 Messages
.TraceControl_CreateSessionDialogTitle
,
676 "Control Protocol Text is empty\n"); //$NON-NLS-1$
680 if ("".equals(fControlHostAddressText
.getText())) { //$NON-NLS-1$
681 MessageDialog
.openError(getShell(),
682 Messages
.TraceControl_CreateSessionDialogTitle
,
683 "Control Address Text is empty\n"); //$NON-NLS-1$
687 if(!fLinkDataWithControlButton
.getSelection()) {
688 if (fDataProtocolCombo
.getSelectionIndex() < 0) {
689 MessageDialog
.openError(getShell(),
690 Messages
.TraceControl_CreateSessionDialogTitle
,
691 "Control Protocol Text is empty\n"); //$NON-NLS-1$
695 if ("".equals(fDataHostAddressText
.getText())) { //$NON-NLS-1$
696 MessageDialog
.openError(getShell(),
697 Messages
.TraceControl_CreateSessionDialogTitle
,
698 "Control Address Text is empty\n"); //$NON-NLS-1$
702 fControlUrl
= getUrlString(fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()),
703 fControlHostAddressText
.getText(),
704 fControlPortText
.getText(),
708 fDataUrl
= getUrlString(fControlProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()),
709 fDataHostAddressText
.getText(),
711 fDataPortText
.getText(),
714 fNetworkUrl
= getUrlString(fControlProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()),
715 fControlHostAddressText
.getText(),
716 fControlPortText
.getText(),
717 fDataPortText
.getText(),
722 // Check for invalid names
723 if (!"".equals(fSessionName
) && !fSessionName
.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
724 MessageDialog
.openError(getShell(),
725 Messages
.TraceControl_CreateSessionDialogTitle
,
726 Messages
.TraceControl_InvalidSessionNameError
+ " (" + fSessionName
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
730 // Check if node with name already exists in parent
731 if(fParent
.containsChild(fSessionName
)) {
732 MessageDialog
.openError(getShell(),
733 Messages
.TraceControl_CreateSessionDialogTitle
,
734 Messages
.TraceControl_SessionAlreadyExistsError
+ " (" + fSessionName
+ ")"); //$NON-NLS-1$ //$NON-NLS-2$
738 // validation successful -> call super.okPressed()
742 private static String
getUrlString(String proto
, String host
, String ctrlPort
, String dataPort
, String sessionPath
) {
743 //proto://[HOST|IP][:PORT1[:PORT2]][/TRACE_PATH]
744 StringBuilder stringBuilder
= new StringBuilder();
745 stringBuilder
.append(proto
);
746 stringBuilder
.append("://"); //$NON-NLS-1$
747 stringBuilder
.append(host
);
749 if ((ctrlPort
!= null) && (!"".equals(ctrlPort
))) { //$NON-NLS-1$
750 stringBuilder
.append(":"); //$NON-NLS-1$
751 stringBuilder
.append(ctrlPort
);
754 if ((dataPort
!= null) && (!"".equals(dataPort
))) { //$NON-NLS-1$
755 stringBuilder
.append(":"); //$NON-NLS-1$
756 stringBuilder
.append(dataPort
);
759 if ((sessionPath
!= null) && (!"".equals(sessionPath
))) { //$NON-NLS-1$
760 stringBuilder
.append("/"); //$NON-NLS-1$
761 stringBuilder
.append(sessionPath
);
763 return stringBuilder
.toString();
766 private static class CopyModifyListener
implements ModifyListener
{
767 private Text fSource
;
768 private Text fDestination
;
770 public CopyModifyListener(Text source
, Text destination
) {
772 fDestination
= destination
;
776 public void modifyText(ModifyEvent e
) {
777 fDestination
.setText(fSource
.getText());
781 private class ControlProtocolSelectionListener
extends SelectionAdapter
{
784 public void widgetSelected(SelectionEvent e
) {
785 fDataProtocolCombo
.select(fControlProtocolCombo
.getSelectionIndex());
786 if (fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.file
.name())) {
787 fControlPortText
.setText(""); //$NON-NLS-1$
788 fDataPortText
.setText(""); //$NON-NLS-1$
789 fControlPortText
.setEnabled(false);
790 fDataPortText
.setEnabled(false);
792 fControlPortText
.setEnabled(true);
793 fDataPortText
.setEnabled(true);
798 private class ProtocolComboSelectionListener
extends SelectionAdapter
{
800 private CCombo fCombo
;
801 private Text fPortText
;
803 public ProtocolComboSelectionListener(CCombo combo
, Text portText
) {
805 fPortText
= portText
;
809 public void widgetSelected(SelectionEvent e
) {
810 if (fCombo
.getItem(fCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
811 fCombo
.getItem(fCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
812 fPortText
.setText(""); //$NON-NLS-1$
813 fPortText
.setEnabled(false);
815 fPortText
.setEnabled(true);