1 /**********************************************************************
2 * Copyright (c) 2012 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 **********************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.dialogs
;
14 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
15 import org
.eclipse
.jface
.dialogs
.Dialog
;
16 import org
.eclipse
.jface
.dialogs
.IDialogConstants
;
17 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
18 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.Activator
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.messages
.Messages
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TargetNodeComponent
;
21 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceSessionGroup
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.remote
.IRemoteSystemProxy
;
23 import org
.eclipse
.rse
.services
.clientserver
.messages
.SystemMessageException
;
24 import org
.eclipse
.rse
.subsystems
.files
.core
.servicesubsystem
.IFileServiceSubSystem
;
25 import org
.eclipse
.rse
.subsystems
.files
.core
.subsystems
.IRemoteFile
;
26 import org
.eclipse
.swt
.SWT
;
27 import org
.eclipse
.swt
.custom
.CCombo
;
28 import org
.eclipse
.swt
.events
.KeyAdapter
;
29 import org
.eclipse
.swt
.events
.KeyEvent
;
30 import org
.eclipse
.swt
.events
.SelectionAdapter
;
31 import org
.eclipse
.swt
.events
.SelectionEvent
;
32 import org
.eclipse
.swt
.graphics
.Point
;
33 import org
.eclipse
.swt
.graphics
.Rectangle
;
34 import org
.eclipse
.swt
.layout
.GridData
;
35 import org
.eclipse
.swt
.layout
.GridLayout
;
36 import org
.eclipse
.swt
.widgets
.Button
;
37 import org
.eclipse
.swt
.widgets
.Composite
;
38 import org
.eclipse
.swt
.widgets
.Control
;
39 import org
.eclipse
.swt
.widgets
.Group
;
40 import org
.eclipse
.swt
.widgets
.Label
;
41 import org
.eclipse
.swt
.widgets
.Shell
;
42 import org
.eclipse
.swt
.widgets
.Text
;
46 * Dialog box for collecting session creation information.
49 * @author Bernd Hufmann
51 public class CreateSessionDialog
extends Dialog
implements ICreateSessionDialog
{
53 // ------------------------------------------------------------------------
55 // ------------------------------------------------------------------------
57 * The icon file for this dialog box.
59 public static final String CREATE_SESSION_ICON_FILE
= "icons/elcl16/add_button.gif"; //$NON-NLS-1$
62 * Supported network protocols for streaming
64 private enum StreamingProtocol
{
65 /** Default network protocol for IPv4 (TCP)*/
67 /** Default network protocol for IPv6 (TCP)*/
73 private enum StreamingProtocol2
{
74 /** Default network protocol for IPv4 (TCP)*/
76 /** Default network protocol for IPv6 (TCP)*/
78 /** TCP network protocol for IPv4*/
80 /** TCP network protocol for IPv6*/
84 * Index of last supported streaming protocol for common URL configuration.
86 private final static int COMMON_URL_LAST_INDEX
= 1;
88 * Index of default streaming protocol.
90 private final static int DEFAULT_URL_INDEX
= 0;
92 // ------------------------------------------------------------------------
94 // ------------------------------------------------------------------------
96 private Control fControl
= null;
98 * The dialog composite.
100 private Composite fDialogComposite
= null;
102 * The text widget for the session name
104 private Text fSessionNameText
= null;
106 * The text widget for the session path.
108 private Text fSessionPathText
= null;
110 * The Group for stream configuration.
112 private Group fMainStreamingGroup
= null;
114 * The button to show streaming options.
116 private Button fConfigureStreamingButton
= null;
118 * The composite with streaming configuration parameter.
120 private Composite fStreamingComposite
= null;
122 * The button to link data protocol/Address with control protocol.
124 private Button fLinkDataWithControlButton
= null;
126 * The Combo box for channel protocol selection.
128 private CCombo fControlProtocolCombo
= null;
130 * A selection listener that copies the protocol from control to data when being linked.
132 private ControlProtocolSelectionListener fCopyProtocolSelectionListener
;
134 private ProtocolComboSelectionListener fControlProtocolSelectionListener
;
135 private ProtocolComboSelectionListener fDataProtocolSelectionListener
;
138 * The text box for the host/IP address of the control channel.
140 private Text fControlHostAddressText
= null;
142 * A key listener that copies the host address from control to data when being linked.
144 private CopyKeyListener fControlUrlKeyListener
;
146 * The text box for the control port.
148 private Text fControlPortText
= null;
150 * The Combo box for data protocol selection.
152 private CCombo fDataProtocolCombo
= null;
154 * The text box for the host/IP address of the data channel.
156 private Text fDataHostAddressText
= null;
158 * The text box for the data port.
160 private Text fDataPortText
= null;
162 * The button to not activate a consumer.
164 private Button fNoConsumerButton
= null;
166 * The button to disable the consumer.
168 private Button fDisableConsumerButton
= null;
170 * The parent where the new node should be added.
172 private TraceSessionGroup fParent
= null;
174 * The session name string.
176 private String fSessionName
= null;
178 * The session path string.
180 private String fSessionPath
= null;
182 * Flag whether default location (path) shall be used or not
184 private boolean fIsDefaultPath
= true;
186 * Flag whether the trace is streamed or not
188 private boolean fIsStreamedTrace
= false;
190 * The network URL in case control and data is configured together.
191 * If set, fControlUrl and fDataUrl will be null.
193 private String fNetworkUrl
= null;
195 * The control URL in case control and data is configured separately.
196 * If set, fDataUrl will be set too and fNetworkUrl will be null.
198 private String fControlUrl
= null;
200 * The data URL in case control and data is configured separately.
201 * If set, fControlUrl will be set too and fNetworkUrl will be null.
203 private String fDataUrl
= null;
205 * Flag for not activating a consumer for this session.
207 private boolean fIsNoConsumer
= false;
209 * Flag for disabling a consumer for this session.
211 private boolean fIsDisableConsumer
= false;
213 // ------------------------------------------------------------------------
215 // ------------------------------------------------------------------------
218 * @param shell - a shell for the display of the dialog
220 public CreateSessionDialog(Shell shell
) {
222 setShellStyle(SWT
.RESIZE
);
225 // ------------------------------------------------------------------------
227 // ------------------------------------------------------------------------
230 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateSessionDialog#getSessionName()
233 public String
getSessionName() {
239 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateSessionDialog#getSessionPath()
242 public String
getSessionPath() {
248 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateSessionDialog#isDefaultSessionPath()
251 public boolean isDefaultSessionPath() {
252 return fIsDefaultPath
;
257 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.ICreateSessionDialog#initialze(org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionGroup)
260 public void initialize(TraceSessionGroup group
) {
262 fStreamingComposite
= null;
265 fIsDefaultPath
= true;
266 fIsStreamedTrace
= false;
270 fIsNoConsumer
= false;
271 fIsDisableConsumer
= false;
275 public boolean isStreamedTrace() {
276 return fIsStreamedTrace
;
279 public String
getNetworkUrl() {
283 public String
getControlUrl() {
287 public String
getDataUrl() {
292 public boolean isNoConsumer() {
293 return fIsNoConsumer
;
297 public boolean isDisableConsumer() {
298 return fIsDisableConsumer
;
301 // ------------------------------------------------------------------------
303 // ------------------------------------------------------------------------
307 * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite)
310 protected Control
createContents(Composite parent
) {
311 fControl
= super.createContents(parent
);
313 /* set the shell minimum size */
314 Point clientArea
= fControl
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
);
315 Rectangle trim
= getShell().computeTrim(0, 0, clientArea
.x
, clientArea
.y
);
316 getShell().setMinimumSize(trim
.width
, trim
.height
);
322 * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
325 protected void configureShell(Shell newShell
) {
326 super.configureShell(newShell
);
327 newShell
.setText(Messages
.TraceControl_CreateSessionDialogTitle
);
328 newShell
.setImage(Activator
.getDefault().loadIcon(CREATE_SESSION_ICON_FILE
));
333 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
336 protected Control
createDialogArea(Composite parent
) {
339 fDialogComposite
= new Composite(parent
, SWT
.NONE
);
340 GridLayout layout
= new GridLayout(1, true);
341 fDialogComposite
.setLayout(layout
);
342 fDialogComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
344 Group sessionGroup
= new Group(fDialogComposite
, SWT
.SHADOW_NONE
);
345 sessionGroup
.setLayoutData(new GridData(GridData
.FILL_HORIZONTAL
));
346 sessionGroup
.setLayout(new GridLayout(4, true));
348 Label sessionNameLabel
= new Label(sessionGroup
, SWT
.RIGHT
);
349 sessionNameLabel
.setText(Messages
.TraceControl_CreateSessionNameLabel
);
350 fSessionNameText
= new Text(sessionGroup
, SWT
.NONE
);
351 fSessionNameText
.setToolTipText(Messages
.TraceControl_CreateSessionNameTooltip
);
353 Label sessionPath
= new Label(sessionGroup
, SWT
.RIGHT
);
354 sessionPath
.setText(Messages
.TraceControl_CreateSessionPathLabel
);
355 fSessionPathText
= new Text(sessionGroup
, SWT
.NONE
);
356 fSessionPathText
.setToolTipText(Messages
.TraceControl_CreateSessionPathTooltip
);
359 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
360 data
.horizontalSpan
= 3;
362 fSessionNameText
.setLayoutData(data
);
364 data
= new GridData(GridData
.FILL_HORIZONTAL
);
365 data
.horizontalSpan
= 3;
366 fSessionPathText
.setLayoutData(data
);
368 if (fParent
.isNetworkStreamingSupported()) {
369 fNoConsumerButton
= new Button(sessionGroup
, SWT
.CHECK
);
370 fNoConsumerButton
.setText(Messages
.TraceControl_CreateSessionNoConsumertText
);
371 fNoConsumerButton
.setToolTipText(Messages
.TraceControl_CreateSessionNoConsumertTooltip
);
372 data
= new GridData(GridData
.FILL_HORIZONTAL
);
373 data
.horizontalSpan
= 2;
374 fNoConsumerButton
.setLayoutData(data
);
376 fDisableConsumerButton
= new Button(sessionGroup
, SWT
.CHECK
);
377 fDisableConsumerButton
.setText(Messages
.TraceControl_CreateSessionDisableConsumertText
);
378 fDisableConsumerButton
.setToolTipText(Messages
.TraceControl_CreateSessionDisableConsumertTooltip
);
379 data
= new GridData(GridData
.FILL_HORIZONTAL
);
380 data
.horizontalSpan
= 2;
381 fDisableConsumerButton
.setLayoutData(data
);
383 fNoConsumerButton
.addSelectionListener(new SelectionAdapter() {
385 public void widgetSelected(SelectionEvent e
) {
386 if (fNoConsumerButton
.getSelection()) {
387 fDisableConsumerButton
.setSelection(false);
392 fDisableConsumerButton
.addSelectionListener(new SelectionAdapter() {
394 public void widgetSelected(SelectionEvent e
) {
395 if (fDisableConsumerButton
.getSelection()) {
396 fNoConsumerButton
.setSelection(false);
401 createAdvancedOptionsComposite();
404 return fDialogComposite
;
407 private void createAdvancedOptionsComposite() {
409 fMainStreamingGroup
= new Group(fDialogComposite
, SWT
.SHADOW_NONE
);
410 fMainStreamingGroup
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
411 fMainStreamingGroup
.setLayout(new GridLayout(1, true));
413 fConfigureStreamingButton
= new Button(fMainStreamingGroup
, SWT
.PUSH
);
414 fConfigureStreamingButton
.setText(">>> " + Messages
.TraceControl_CreateSessionConfigureStreamingButtonText
); //$NON-NLS-1$
415 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonTooltip
);
416 fConfigureStreamingButton
.addSelectionListener(new SelectionAdapter() {
418 public void widgetSelected(SelectionEvent e
) {
419 if (fIsStreamedTrace
) {
420 fIsStreamedTrace
= false;
421 fConfigureStreamingButton
.setText(">>> " + Messages
.TraceControl_CreateSessionConfigureStreamingButtonText
); //$NON-NLS-1$
422 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonTooltip
);
423 disposeConfigureStreamingComposite();
425 fIsStreamedTrace
= true;
426 fConfigureStreamingButton
.setText("<<< " + Messages
.TraceControl_CreateSessionNoStreamingButtonText
); //$NON-NLS-1$
427 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionNoStreamingButtonTooltip
);
428 createConfigureStreamingComposite();
431 fDialogComposite
.layout();
433 Point clientArea
= fControl
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
);
434 Rectangle trim
= getShell().computeTrim(0, 0, clientArea
.x
, clientArea
.y
);
435 getShell().setSize(trim
.width
, trim
.height
);
440 private void createConfigureStreamingComposite() {
441 if (fStreamingComposite
== null) {
442 fStreamingComposite
= new Composite(fMainStreamingGroup
, SWT
.NONE
);
443 GridLayout layout
= new GridLayout(1, true);
444 fStreamingComposite
.setLayout(layout
);
445 fStreamingComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
447 Group urlGroup
= new Group(fStreamingComposite
, SWT
.SHADOW_NONE
);
448 layout
= new GridLayout(7, true);
449 urlGroup
.setLayout(layout
);
450 urlGroup
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
452 fLinkDataWithControlButton
= new Button(urlGroup
, SWT
.CHECK
);
453 fLinkDataWithControlButton
.setText(Messages
.TraceControl_CreateSessionLinkButtonText
);
454 fLinkDataWithControlButton
.setToolTipText(Messages
.TraceControl_CreateSessionLinkButtonTooltip
);
455 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
456 data
.horizontalSpan
= 7;
457 fLinkDataWithControlButton
.setLayoutData(data
);
458 fLinkDataWithControlButton
.setSelection(true);
460 Label label
= new Label(urlGroup
, SWT
.NONE
);
461 data
= new GridData(GridData
.FILL_HORIZONTAL
);
462 data
.horizontalSpan
= 1;
463 label
.setLayoutData(data
);
465 label
= new Label(urlGroup
, SWT
.NONE
);
466 label
.setText(Messages
.TraceControl_CreateSessionProtocolLabelText
);
467 data
= new GridData(GridData
.FILL_HORIZONTAL
);
468 data
.horizontalSpan
= 1;
469 label
.setLayoutData(data
);
471 label
= new Label(urlGroup
, SWT
.NONE
);
472 label
.setText(Messages
.TraceControl_CreateSessionAddressLabelText
);
473 data
= new GridData(GridData
.FILL_HORIZONTAL
);
474 data
.horizontalSpan
= 4;
475 label
.setLayoutData(data
);
477 label
= new Label(urlGroup
, SWT
.NONE
);
478 label
.setText(Messages
.TraceControl_CreateSessionPortLabelText
);
479 data
= new GridData(GridData
.FILL_HORIZONTAL
);
480 data
.horizontalSpan
= 1;
481 label
.setLayoutData(data
);
483 label
= new Label(urlGroup
, SWT
.RIGHT
);
484 label
.setText(Messages
.TraceControl_CreateSessionControlUrlLabel
);
485 data
= new GridData(GridData
.FILL_HORIZONTAL
);
486 data
.horizontalSpan
= 1;
487 label
.setLayoutData(data
);
489 fControlProtocolCombo
= new CCombo(urlGroup
, SWT
.READ_ONLY
);
490 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionCommonProtocolTooltip
);
491 data
= new GridData(GridData
.FILL_HORIZONTAL
);
492 data
.horizontalSpan
= 1;
493 fControlProtocolCombo
.setLayoutData(data
);
495 fControlHostAddressText
= new Text(urlGroup
, SWT
.NONE
);
496 fControlHostAddressText
.setToolTipText(Messages
.TraceControl_CreateSessionControlAddressTooltip
);
497 data
= new GridData(GridData
.FILL_HORIZONTAL
);
498 data
.horizontalSpan
= 4;
499 fControlHostAddressText
.setLayoutData(data
);
501 fControlPortText
= new Text(urlGroup
, SWT
.NONE
);
502 fControlPortText
.setToolTipText(Messages
.TraceControl_CreateSessionControlPortTooltip
);
503 data
= new GridData(GridData
.FILL_HORIZONTAL
);
504 data
.horizontalSpan
= 1;
505 fControlPortText
.setLayoutData(data
);
507 label
= new Label(urlGroup
, SWT
.RIGHT
);
508 label
.setText(Messages
.TraceControl_CreateSessionDataUrlLabel
);
509 data
= new GridData(GridData
.FILL_HORIZONTAL
);
510 data
.horizontalSpan
= 1;
511 label
.setLayoutData(data
);
513 fDataProtocolCombo
= new CCombo(urlGroup
, SWT
.READ_ONLY
);
514 fDataProtocolCombo
.setEnabled(false);
515 fDataProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
516 data
= new GridData(GridData
.FILL_HORIZONTAL
);
517 data
.horizontalSpan
= 1;
518 fDataProtocolCombo
.setLayoutData(data
);
520 String items
[] = new String
[StreamingProtocol
.values().length
];
521 for (int i
= 0; i
< items
.length
; i
++) {
522 items
[i
] = StreamingProtocol
.values()[i
].name();
524 fControlProtocolCombo
.setItems(items
);
525 fDataProtocolCombo
.setItems(items
);
527 fDataHostAddressText
= new Text(urlGroup
, SWT
.NONE
);
528 fDataHostAddressText
.setEnabled(false);
529 fDataHostAddressText
.setToolTipText(Messages
.TraceControl_CreateSessionDataAddressTooltip
);
530 data
= new GridData(GridData
.FILL_HORIZONTAL
);
531 data
.horizontalSpan
= 4;
532 fDataHostAddressText
.setLayoutData(data
);
534 fDataPortText
= new Text(urlGroup
, SWT
.NONE
);
535 fDataPortText
.setEnabled(true);
536 fDataPortText
.setToolTipText(Messages
.TraceControl_CreateSessionDataPortTooltip
);
537 data
= new GridData(GridData
.FILL_HORIZONTAL
);
538 data
.horizontalSpan
= 1;
539 fDataPortText
.setLayoutData(data
);
541 fCopyProtocolSelectionListener
= new ControlProtocolSelectionListener();
542 fControlProtocolSelectionListener
= new ProtocolComboSelectionListener(fControlProtocolCombo
, fControlPortText
);
543 fDataProtocolSelectionListener
= new ProtocolComboSelectionListener(fDataProtocolCombo
, fDataPortText
);
545 fControlProtocolCombo
.addSelectionListener(fCopyProtocolSelectionListener
);
547 fControlUrlKeyListener
= new CopyKeyListener(fControlHostAddressText
, fDataHostAddressText
);
548 fControlHostAddressText
.addKeyListener(fControlUrlKeyListener
);
550 // InetAddress inet = null;
552 // inet = InetAddress.getLocalHost();
553 // inet = InetAddress.getByName(inet.getHostName());
554 // } catch (UnknownHostException e1) {
556 // if (inet != null) {
557 // fControlUrlAddressText.setText(inet.getHostAddress());
558 // fDataUrlAddressText.setText(inet.getHostAddress());
560 fControlProtocolCombo
.select(DEFAULT_URL_INDEX
);
561 fDataProtocolCombo
.select(DEFAULT_URL_INDEX
);
563 fLinkDataWithControlButton
.addSelectionListener(new SelectionAdapter() {
565 public void widgetSelected(SelectionEvent e
) {
566 if (fLinkDataWithControlButton
.getSelection()) {
567 // Set enablement control data channel inputs
568 fDataProtocolCombo
.setEnabled(false);
569 fDataHostAddressText
.setEnabled(false);
570 fControlPortText
.setEnabled(true);
571 fDataPortText
.setEnabled(true);
574 fControlProtocolCombo
.removeSelectionListener(fControlProtocolSelectionListener
);
575 fDataProtocolCombo
.removeSelectionListener(fDataProtocolSelectionListener
);
576 fControlProtocolCombo
.addSelectionListener(fCopyProtocolSelectionListener
);
577 fControlHostAddressText
.addKeyListener(fControlUrlKeyListener
);
579 // Get previous selection and validate
580 int currentSelection
= fControlProtocolCombo
.getSelectionIndex() <= COMMON_URL_LAST_INDEX ?
581 fControlProtocolCombo
.getSelectionIndex() : DEFAULT_URL_INDEX
;
583 // Update combo box items
584 fControlProtocolCombo
.removeAll();
585 String
[] controlItems
= new String
[StreamingProtocol
.values().length
];
586 for (int i
= 0; i
< controlItems
.length
; i
++) {
587 controlItems
[i
] = StreamingProtocol
.values()[i
].name();
589 fControlProtocolCombo
.setItems(controlItems
);
590 fDataProtocolCombo
.setItems(controlItems
);
593 fControlProtocolCombo
.select(currentSelection
);
594 fDataProtocolCombo
.select(currentSelection
);
595 fDataHostAddressText
.setText(fControlHostAddressText
.getText());
598 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionCommonProtocolTooltip
);
600 // Enable data channel inputs
601 fDataProtocolCombo
.setEnabled(true);
602 fDataHostAddressText
.setEnabled(true);
605 fControlProtocolCombo
.removeSelectionListener(fCopyProtocolSelectionListener
);
606 fControlProtocolCombo
.addSelectionListener(fControlProtocolSelectionListener
);
607 fDataProtocolCombo
.addSelectionListener(fDataProtocolSelectionListener
);
608 fControlHostAddressText
.removeKeyListener(fControlUrlKeyListener
);
610 // Update combo box items
611 int currentSelection
= fControlProtocolCombo
.getSelectionIndex();
612 fControlProtocolCombo
.removeAll();
613 String
[] controlItems
= new String
[StreamingProtocol2
.values().length
];
614 for (int i
= 0; i
< controlItems
.length
; i
++) {
615 controlItems
[i
] = StreamingProtocol2
.values()[i
].name();
617 fControlProtocolCombo
.setItems(controlItems
);
618 fDataProtocolCombo
.setItems(controlItems
);
621 fControlProtocolCombo
.select(currentSelection
);
622 fDataProtocolCombo
.select(currentSelection
);
625 fDataProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
626 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
628 // Update control/data port enablement and input
629 if (fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
630 fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
631 fControlPortText
.setText(""); //$NON-NLS-1$
632 fControlPortText
.setEnabled(false);
634 fControlPortText
.setEnabled(true);
637 if (fDataProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
638 fDataProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
639 fDataPortText
.setText(""); //$NON-NLS-1$
640 fDataPortText
.setEnabled(false);
642 fDataPortText
.setEnabled(true);
650 private void disposeConfigureStreamingComposite() {
651 if (fStreamingComposite
!= null) {
652 fStreamingComposite
.dispose();
653 fStreamingComposite
= null;
659 * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
662 protected void createButtonsForButtonBar(Composite parent
) {
663 createButton(parent
, IDialogConstants
.CANCEL_ID
, "&Cancel", true); //$NON-NLS-1$
664 createButton(parent
, IDialogConstants
.OK_ID
, "&Ok", true); //$NON-NLS-1$
669 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
672 protected void okPressed() {
673 // Validate input data
674 fSessionName
= fSessionNameText
.getText();
675 fSessionPath
= fSessionPathText
.getText();
677 if (!"".equals(fSessionPath
)) { //$NON-NLS-1$
678 // validate sessionPath
679 if (!fIsStreamedTrace
) {
680 TargetNodeComponent node
= (TargetNodeComponent
)fParent
.getParent();
681 IRemoteSystemProxy proxy
= node
.getRemoteSystemProxy();
682 IFileServiceSubSystem fsss
= proxy
.getFileServiceSubSystem();
685 IRemoteFile remoteFolder
= fsss
.getRemoteFileObject(fSessionPath
, new NullProgressMonitor());
686 if (remoteFolder
.exists()) {
687 MessageDialog
.openError(getShell(),
688 Messages
.TraceControl_CreateSessionDialogTitle
,
689 Messages
.TraceControl_SessionPathAlreadyExistsError
+ " (" + fSessionPath
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
692 } catch (SystemMessageException e
) {
693 MessageDialog
.openError(getShell(),
694 Messages
.TraceControl_CreateSessionDialogTitle
,
695 Messages
.TraceControl_FileSubSystemError
+ "\n" + e
); //$NON-NLS-1$
700 fIsDefaultPath
= false;
707 if (fIsStreamedTrace
) {
708 if (fControlProtocolCombo
.getSelectionIndex() < 0) {
709 MessageDialog
.openError(getShell(),
710 Messages
.TraceControl_CreateSessionDialogTitle
,
711 "Control Protocol Text is empty\n"); //$NON-NLS-1$
715 if ("".equals(fControlHostAddressText
.getText())) { //$NON-NLS-1$
716 MessageDialog
.openError(getShell(),
717 Messages
.TraceControl_CreateSessionDialogTitle
,
718 "Control Address Text is empty\n"); //$NON-NLS-1$
722 if(!fLinkDataWithControlButton
.getSelection()) {
723 if (fDataProtocolCombo
.getSelectionIndex() < 0) {
724 MessageDialog
.openError(getShell(),
725 Messages
.TraceControl_CreateSessionDialogTitle
,
726 "Control Protocol Text is empty\n"); //$NON-NLS-1$
730 if ("".equals(fDataHostAddressText
.getText())) { //$NON-NLS-1$
731 MessageDialog
.openError(getShell(),
732 Messages
.TraceControl_CreateSessionDialogTitle
,
733 "Control Address Text is empty\n"); //$NON-NLS-1$
737 fControlUrl
= getUrlString(fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()),
738 fControlHostAddressText
.getText(),
739 fControlPortText
.getText(),
743 fDataUrl
= getUrlString(fControlProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()),
744 fDataHostAddressText
.getText(),
746 fDataPortText
.getText(),
749 fNetworkUrl
= getUrlString(fControlProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()),
750 fControlHostAddressText
.getText(),
751 fControlPortText
.getText(),
752 fDataPortText
.getText(),
757 // Check for invalid names
758 if (!"".equals(fSessionName
) && !fSessionName
.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
759 MessageDialog
.openError(getShell(),
760 Messages
.TraceControl_CreateSessionDialogTitle
,
761 Messages
.TraceControl_InvalidSessionNameError
+ " (" + fSessionName
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
765 // Check if node with name already exists in parent
766 if(fParent
.containsChild(fSessionName
)) {
767 MessageDialog
.openError(getShell(),
768 Messages
.TraceControl_CreateSessionDialogTitle
,
769 Messages
.TraceControl_SessionAlreadyExistsError
+ " (" + fSessionName
+ ")"); //$NON-NLS-1$ //$NON-NLS-2$
773 if (fParent
.isNetworkStreamingSupported()) {
774 fIsNoConsumer
= fNoConsumerButton
.getSelection();
775 fIsDisableConsumer
= fDisableConsumerButton
.getSelection();
778 // validation successful -> call super.okPressed()
782 private static String
getUrlString(String proto
, String host
, String ctrlPort
, String dataPort
, String sessionPath
) {
783 //proto://[HOST|IP][:PORT1[:PORT2]][/TRACE_PATH]
784 StringBuilder stringBuilder
= new StringBuilder();
785 stringBuilder
.append(proto
);
786 stringBuilder
.append("://"); //$NON-NLS-1$
787 stringBuilder
.append(host
);
789 if ((ctrlPort
!= null) && (!"".equals(ctrlPort
))) { //$NON-NLS-1$
790 stringBuilder
.append(":"); //$NON-NLS-1$
791 stringBuilder
.append(ctrlPort
);
794 if ((dataPort
!= null) && (!"".equals(dataPort
))) { //$NON-NLS-1$
795 stringBuilder
.append(":"); //$NON-NLS-1$
796 stringBuilder
.append(dataPort
);
799 if ((sessionPath
!= null) && (!"".equals(sessionPath
))) { //$NON-NLS-1$
800 stringBuilder
.append("/"); //$NON-NLS-1$
801 stringBuilder
.append(sessionPath
);
803 return stringBuilder
.toString();
806 private static class CopyKeyListener
extends KeyAdapter
{
807 private Text fSource
;
808 private Text fDestination
;
810 public CopyKeyListener(Text source
, Text destination
) {
812 fDestination
= destination
;
816 public void keyReleased(KeyEvent e
) {
817 fDestination
.setText(fSource
.getText());
821 private class ControlProtocolSelectionListener
extends SelectionAdapter
{
824 public void widgetSelected(SelectionEvent e
) {
825 fDataProtocolCombo
.select(fControlProtocolCombo
.getSelectionIndex());
826 if (fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.file
.name())) {
827 fControlPortText
.setText(""); //$NON-NLS-1$
828 fDataPortText
.setText(""); //$NON-NLS-1$
829 fControlPortText
.setEnabled(false);
830 fDataPortText
.setEnabled(false);
832 fControlPortText
.setEnabled(true);
833 fDataPortText
.setEnabled(true);
838 private class ProtocolComboSelectionListener
extends SelectionAdapter
{
840 private CCombo fCombo
;
841 private Text fPortText
;
843 public ProtocolComboSelectionListener(CCombo combo
, Text portText
) {
845 fPortText
= portText
;
849 public void widgetSelected(SelectionEvent e
) {
850 if (fCombo
.getItem(fCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
851 fCombo
.getItem(fCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
852 fPortText
.setText(""); //$NON-NLS-1$
853 fPortText
.setEnabled(false);
855 fPortText
.setEnabled(true);