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
.KeyAdapter
;
30 import org
.eclipse
.swt
.events
.KeyEvent
;
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 text widget for the session path.
109 private Text fSessionPathText
= null;
111 * The Group for stream configuration.
113 private Group fMainStreamingGroup
= null;
115 * The button to show streaming options.
117 private Button fConfigureStreamingButton
= null;
119 * The composite with streaming configuration parameter.
121 private Composite fStreamingComposite
= null;
123 * The button to link data protocol/Address with control protocol.
125 private Button fLinkDataWithControlButton
= null;
127 * The Combo box for channel protocol selection.
129 private CCombo fControlProtocolCombo
= null;
131 * A selection listener that copies the protocol from control to data when being linked.
133 private ControlProtocolSelectionListener fCopyProtocolSelectionListener
;
135 private ProtocolComboSelectionListener fControlProtocolSelectionListener
;
136 private ProtocolComboSelectionListener fDataProtocolSelectionListener
;
139 * The text box for the host/IP address of the control channel.
141 private Text fControlHostAddressText
= null;
143 * A key listener that copies the host address from control to data when being linked.
145 private CopyKeyListener fControlUrlKeyListener
;
147 * The text box for the control port.
149 private Text fControlPortText
= null;
151 * The Combo box for data protocol selection.
153 private CCombo fDataProtocolCombo
= null;
155 * The text box for the host/IP address of the data channel.
157 private Text fDataHostAddressText
= null;
159 * The text box for the data port.
161 private Text fDataPortText
= null;
163 * The button to not activate a consumer.
165 private Button fNoConsumerButton
= null;
167 * The button to disable the consumer.
169 private Button fDisableConsumerButton
= null;
171 * The parent where the new node should be added.
173 private TraceSessionGroup fParent
= null;
175 * The session name string.
177 private String fSessionName
= null;
179 * The session path string.
181 private String fSessionPath
= null;
183 * Flag whether default location (path) shall be used or not
185 private boolean fIsDefaultPath
= true;
187 * Flag whether the trace is streamed or not
189 private boolean fIsStreamedTrace
= false;
191 * The network URL in case control and data is configured together.
192 * If set, fControlUrl and fDataUrl will be null.
194 private String fNetworkUrl
= null;
196 * The control URL in case control and data is configured separately.
197 * If set, fDataUrl will be set too and fNetworkUrl will be null.
199 private String fControlUrl
= null;
201 * The data URL in case control and data is configured separately.
202 * If set, fControlUrl will be set too and fNetworkUrl will be null.
204 private String fDataUrl
= null;
206 * Flag for not activating a consumer for this session.
208 private boolean fIsNoConsumer
= false;
210 * Flag for disabling a consumer for this session.
212 private boolean fIsDisableConsumer
= false;
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;
271 fIsNoConsumer
= false;
272 fIsDisableConsumer
= false;
276 public boolean isStreamedTrace() {
277 return fIsStreamedTrace
;
280 public String
getNetworkUrl() {
284 public String
getControlUrl() {
288 public String
getDataUrl() {
293 public boolean isNoConsumer() {
294 return fIsNoConsumer
;
298 public boolean isDisableConsumer() {
299 return fIsDisableConsumer
;
302 // ------------------------------------------------------------------------
304 // ------------------------------------------------------------------------
308 * @see org.eclipse.jface.dialogs.Dialog#createContents(org.eclipse.swt.widgets.Composite)
311 protected Control
createContents(Composite parent
) {
312 fControl
= super.createContents(parent
);
314 /* set the shell minimum size */
315 Point clientArea
= fControl
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
);
316 Rectangle trim
= getShell().computeTrim(0, 0, clientArea
.x
, clientArea
.y
);
317 getShell().setMinimumSize(trim
.width
, trim
.height
);
323 * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
326 protected void configureShell(Shell newShell
) {
327 super.configureShell(newShell
);
328 newShell
.setText(Messages
.TraceControl_CreateSessionDialogTitle
);
329 newShell
.setImage(Activator
.getDefault().loadIcon(CREATE_SESSION_ICON_FILE
));
334 * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
337 protected Control
createDialogArea(Composite parent
) {
340 fDialogComposite
= new Composite(parent
, SWT
.NONE
);
341 GridLayout layout
= new GridLayout(1, true);
342 fDialogComposite
.setLayout(layout
);
343 fDialogComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
345 Group sessionGroup
= new Group(fDialogComposite
, SWT
.SHADOW_NONE
);
346 sessionGroup
.setLayoutData(new GridData(GridData
.FILL_HORIZONTAL
));
347 sessionGroup
.setLayout(new GridLayout(4, true));
349 Label sessionNameLabel
= new Label(sessionGroup
, SWT
.RIGHT
);
350 sessionNameLabel
.setText(Messages
.TraceControl_CreateSessionNameLabel
);
351 fSessionNameText
= new Text(sessionGroup
, SWT
.NONE
);
352 fSessionNameText
.setToolTipText(Messages
.TraceControl_CreateSessionNameTooltip
);
354 Label sessionPath
= new Label(sessionGroup
, SWT
.RIGHT
);
355 sessionPath
.setText(Messages
.TraceControl_CreateSessionPathLabel
);
356 fSessionPathText
= new Text(sessionGroup
, SWT
.NONE
);
357 fSessionPathText
.setToolTipText(Messages
.TraceControl_CreateSessionPathTooltip
);
360 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
361 data
.horizontalSpan
= 3;
363 fSessionNameText
.setLayoutData(data
);
365 data
= new GridData(GridData
.FILL_HORIZONTAL
);
366 data
.horizontalSpan
= 3;
367 fSessionPathText
.setLayoutData(data
);
369 if (fParent
.isNetworkStreamingSupported()) {
370 fNoConsumerButton
= new Button(sessionGroup
, SWT
.CHECK
);
371 fNoConsumerButton
.setText(Messages
.TraceControl_CreateSessionNoConsumertText
);
372 fNoConsumerButton
.setToolTipText(Messages
.TraceControl_CreateSessionNoConsumertTooltip
);
373 data
= new GridData(GridData
.FILL_HORIZONTAL
);
374 data
.horizontalSpan
= 2;
375 fNoConsumerButton
.setLayoutData(data
);
377 fDisableConsumerButton
= new Button(sessionGroup
, SWT
.CHECK
);
378 fDisableConsumerButton
.setText(Messages
.TraceControl_CreateSessionDisableConsumertText
);
379 fDisableConsumerButton
.setToolTipText(Messages
.TraceControl_CreateSessionDisableConsumertTooltip
);
380 data
= new GridData(GridData
.FILL_HORIZONTAL
);
381 data
.horizontalSpan
= 2;
382 fDisableConsumerButton
.setLayoutData(data
);
384 fNoConsumerButton
.addSelectionListener(new SelectionAdapter() {
386 public void widgetSelected(SelectionEvent e
) {
387 if (fNoConsumerButton
.getSelection()) {
388 fDisableConsumerButton
.setSelection(false);
393 fDisableConsumerButton
.addSelectionListener(new SelectionAdapter() {
395 public void widgetSelected(SelectionEvent e
) {
396 if (fDisableConsumerButton
.getSelection()) {
397 fNoConsumerButton
.setSelection(false);
402 createAdvancedOptionsComposite();
405 return fDialogComposite
;
408 private void createAdvancedOptionsComposite() {
410 fMainStreamingGroup
= new Group(fDialogComposite
, SWT
.SHADOW_NONE
);
411 fMainStreamingGroup
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
412 fMainStreamingGroup
.setLayout(new GridLayout(1, true));
414 fConfigureStreamingButton
= new Button(fMainStreamingGroup
, SWT
.PUSH
);
415 fConfigureStreamingButton
.setText(">>> " + Messages
.TraceControl_CreateSessionConfigureStreamingButtonText
); //$NON-NLS-1$
416 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonTooltip
);
417 fConfigureStreamingButton
.addSelectionListener(new SelectionAdapter() {
419 public void widgetSelected(SelectionEvent e
) {
420 if (fIsStreamedTrace
) {
421 fIsStreamedTrace
= false;
422 fConfigureStreamingButton
.setText(">>> " + Messages
.TraceControl_CreateSessionConfigureStreamingButtonText
); //$NON-NLS-1$
423 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonTooltip
);
424 disposeConfigureStreamingComposite();
426 fIsStreamedTrace
= true;
427 fConfigureStreamingButton
.setText("<<< " + Messages
.TraceControl_CreateSessionNoStreamingButtonText
); //$NON-NLS-1$
428 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionNoStreamingButtonTooltip
);
429 createConfigureStreamingComposite();
432 fDialogComposite
.layout();
434 Point clientArea
= fControl
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
);
435 Rectangle trim
= getShell().computeTrim(0, 0, clientArea
.x
, clientArea
.y
);
436 getShell().setSize(trim
.width
, trim
.height
);
441 private void createConfigureStreamingComposite() {
442 if (fStreamingComposite
== null) {
443 fStreamingComposite
= new Composite(fMainStreamingGroup
, SWT
.NONE
);
444 GridLayout layout
= new GridLayout(1, true);
445 fStreamingComposite
.setLayout(layout
);
446 fStreamingComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
448 Group urlGroup
= new Group(fStreamingComposite
, SWT
.SHADOW_NONE
);
449 layout
= new GridLayout(7, true);
450 urlGroup
.setLayout(layout
);
451 urlGroup
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
453 fLinkDataWithControlButton
= new Button(urlGroup
, SWT
.CHECK
);
454 fLinkDataWithControlButton
.setText(Messages
.TraceControl_CreateSessionLinkButtonText
);
455 fLinkDataWithControlButton
.setToolTipText(Messages
.TraceControl_CreateSessionLinkButtonTooltip
);
456 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
457 data
.horizontalSpan
= 7;
458 fLinkDataWithControlButton
.setLayoutData(data
);
459 fLinkDataWithControlButton
.setSelection(true);
461 Label label
= new Label(urlGroup
, SWT
.NONE
);
462 data
= new GridData(GridData
.FILL_HORIZONTAL
);
463 data
.horizontalSpan
= 1;
464 label
.setLayoutData(data
);
466 label
= new Label(urlGroup
, SWT
.NONE
);
467 label
.setText(Messages
.TraceControl_CreateSessionProtocolLabelText
);
468 data
= new GridData(GridData
.FILL_HORIZONTAL
);
469 data
.horizontalSpan
= 1;
470 label
.setLayoutData(data
);
472 label
= new Label(urlGroup
, SWT
.NONE
);
473 label
.setText(Messages
.TraceControl_CreateSessionAddressLabelText
);
474 data
= new GridData(GridData
.FILL_HORIZONTAL
);
475 data
.horizontalSpan
= 4;
476 label
.setLayoutData(data
);
478 label
= new Label(urlGroup
, SWT
.NONE
);
479 label
.setText(Messages
.TraceControl_CreateSessionPortLabelText
);
480 data
= new GridData(GridData
.FILL_HORIZONTAL
);
481 data
.horizontalSpan
= 1;
482 label
.setLayoutData(data
);
484 label
= new Label(urlGroup
, SWT
.RIGHT
);
485 label
.setText(Messages
.TraceControl_CreateSessionControlUrlLabel
);
486 data
= new GridData(GridData
.FILL_HORIZONTAL
);
487 data
.horizontalSpan
= 1;
488 label
.setLayoutData(data
);
490 fControlProtocolCombo
= new CCombo(urlGroup
, SWT
.READ_ONLY
);
491 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionCommonProtocolTooltip
);
492 data
= new GridData(GridData
.FILL_HORIZONTAL
);
493 data
.horizontalSpan
= 1;
494 fControlProtocolCombo
.setLayoutData(data
);
496 fControlHostAddressText
= new Text(urlGroup
, SWT
.NONE
);
497 fControlHostAddressText
.setToolTipText(Messages
.TraceControl_CreateSessionControlAddressTooltip
);
498 data
= new GridData(GridData
.FILL_HORIZONTAL
);
499 data
.horizontalSpan
= 4;
500 fControlHostAddressText
.setLayoutData(data
);
502 fControlPortText
= new Text(urlGroup
, SWT
.NONE
);
503 fControlPortText
.setToolTipText(Messages
.TraceControl_CreateSessionControlPortTooltip
);
504 data
= new GridData(GridData
.FILL_HORIZONTAL
);
505 data
.horizontalSpan
= 1;
506 fControlPortText
.setLayoutData(data
);
508 label
= new Label(urlGroup
, SWT
.RIGHT
);
509 label
.setText(Messages
.TraceControl_CreateSessionDataUrlLabel
);
510 data
= new GridData(GridData
.FILL_HORIZONTAL
);
511 data
.horizontalSpan
= 1;
512 label
.setLayoutData(data
);
514 fDataProtocolCombo
= new CCombo(urlGroup
, SWT
.READ_ONLY
);
515 fDataProtocolCombo
.setEnabled(false);
516 fDataProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
517 data
= new GridData(GridData
.FILL_HORIZONTAL
);
518 data
.horizontalSpan
= 1;
519 fDataProtocolCombo
.setLayoutData(data
);
521 String items
[] = new String
[StreamingProtocol
.values().length
];
522 for (int i
= 0; i
< items
.length
; i
++) {
523 items
[i
] = StreamingProtocol
.values()[i
].name();
525 fControlProtocolCombo
.setItems(items
);
526 fDataProtocolCombo
.setItems(items
);
528 fDataHostAddressText
= new Text(urlGroup
, SWT
.NONE
);
529 fDataHostAddressText
.setEnabled(false);
530 fDataHostAddressText
.setToolTipText(Messages
.TraceControl_CreateSessionDataAddressTooltip
);
531 data
= new GridData(GridData
.FILL_HORIZONTAL
);
532 data
.horizontalSpan
= 4;
533 fDataHostAddressText
.setLayoutData(data
);
535 fDataPortText
= new Text(urlGroup
, SWT
.NONE
);
536 fDataPortText
.setEnabled(true);
537 fDataPortText
.setToolTipText(Messages
.TraceControl_CreateSessionDataPortTooltip
);
538 data
= new GridData(GridData
.FILL_HORIZONTAL
);
539 data
.horizontalSpan
= 1;
540 fDataPortText
.setLayoutData(data
);
542 fCopyProtocolSelectionListener
= new ControlProtocolSelectionListener();
543 fControlProtocolSelectionListener
= new ProtocolComboSelectionListener(fControlProtocolCombo
, fControlPortText
);
544 fDataProtocolSelectionListener
= new ProtocolComboSelectionListener(fDataProtocolCombo
, fDataPortText
);
546 fControlProtocolCombo
.addSelectionListener(fCopyProtocolSelectionListener
);
548 fControlUrlKeyListener
= new CopyKeyListener(fControlHostAddressText
, fDataHostAddressText
);
549 fControlHostAddressText
.addKeyListener(fControlUrlKeyListener
);
551 // InetAddress inet = null;
553 // inet = InetAddress.getLocalHost();
554 // inet = InetAddress.getByName(inet.getHostName());
555 // } catch (UnknownHostException e1) {
557 // if (inet != null) {
558 // fControlUrlAddressText.setText(inet.getHostAddress());
559 // fDataUrlAddressText.setText(inet.getHostAddress());
561 fControlProtocolCombo
.select(DEFAULT_URL_INDEX
);
562 fDataProtocolCombo
.select(DEFAULT_URL_INDEX
);
564 fLinkDataWithControlButton
.addSelectionListener(new SelectionAdapter() {
566 public void widgetSelected(SelectionEvent e
) {
567 if (fLinkDataWithControlButton
.getSelection()) {
568 // Set enablement control data channel inputs
569 fDataProtocolCombo
.setEnabled(false);
570 fDataHostAddressText
.setEnabled(false);
571 fControlPortText
.setEnabled(true);
572 fDataPortText
.setEnabled(true);
575 fControlProtocolCombo
.removeSelectionListener(fControlProtocolSelectionListener
);
576 fDataProtocolCombo
.removeSelectionListener(fDataProtocolSelectionListener
);
577 fControlProtocolCombo
.addSelectionListener(fCopyProtocolSelectionListener
);
578 fControlHostAddressText
.addKeyListener(fControlUrlKeyListener
);
580 // Get previous selection and validate
581 int currentSelection
= fControlProtocolCombo
.getSelectionIndex() <= COMMON_URL_LAST_INDEX ?
582 fControlProtocolCombo
.getSelectionIndex() : DEFAULT_URL_INDEX
;
584 // Update combo box items
585 fControlProtocolCombo
.removeAll();
586 String
[] controlItems
= new String
[StreamingProtocol
.values().length
];
587 for (int i
= 0; i
< controlItems
.length
; i
++) {
588 controlItems
[i
] = StreamingProtocol
.values()[i
].name();
590 fControlProtocolCombo
.setItems(controlItems
);
591 fDataProtocolCombo
.setItems(controlItems
);
594 fControlProtocolCombo
.select(currentSelection
);
595 fDataProtocolCombo
.select(currentSelection
);
596 fDataHostAddressText
.setText(fControlHostAddressText
.getText());
599 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionCommonProtocolTooltip
);
601 // Enable data channel inputs
602 fDataProtocolCombo
.setEnabled(true);
603 fDataHostAddressText
.setEnabled(true);
606 fControlProtocolCombo
.removeSelectionListener(fCopyProtocolSelectionListener
);
607 fControlProtocolCombo
.addSelectionListener(fControlProtocolSelectionListener
);
608 fDataProtocolCombo
.addSelectionListener(fDataProtocolSelectionListener
);
609 fControlHostAddressText
.removeKeyListener(fControlUrlKeyListener
);
611 // Update combo box items
612 int currentSelection
= fControlProtocolCombo
.getSelectionIndex();
613 fControlProtocolCombo
.removeAll();
614 String
[] controlItems
= new String
[StreamingProtocol2
.values().length
];
615 for (int i
= 0; i
< controlItems
.length
; i
++) {
616 controlItems
[i
] = StreamingProtocol2
.values()[i
].name();
618 fControlProtocolCombo
.setItems(controlItems
);
619 fDataProtocolCombo
.setItems(controlItems
);
622 fControlProtocolCombo
.select(currentSelection
);
623 fDataProtocolCombo
.select(currentSelection
);
626 fDataProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
627 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
629 // Update control/data port enablement and input
630 if (fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
631 fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
632 fControlPortText
.setText(""); //$NON-NLS-1$
633 fControlPortText
.setEnabled(false);
635 fControlPortText
.setEnabled(true);
638 if (fDataProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
639 fDataProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
640 fDataPortText
.setText(""); //$NON-NLS-1$
641 fDataPortText
.setEnabled(false);
643 fDataPortText
.setEnabled(true);
651 private void disposeConfigureStreamingComposite() {
652 if (fStreamingComposite
!= null) {
653 fStreamingComposite
.dispose();
654 fStreamingComposite
= null;
660 * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
663 protected void createButtonsForButtonBar(Composite parent
) {
664 createButton(parent
, IDialogConstants
.CANCEL_ID
, "&Cancel", true); //$NON-NLS-1$
665 createButton(parent
, IDialogConstants
.OK_ID
, "&Ok", true); //$NON-NLS-1$
670 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
673 protected void okPressed() {
674 // Validate input data
675 fSessionName
= fSessionNameText
.getText();
676 fSessionPath
= fSessionPathText
.getText();
678 if (!"".equals(fSessionPath
)) { //$NON-NLS-1$
679 // validate sessionPath
680 if (!fIsStreamedTrace
) {
681 TargetNodeComponent node
= (TargetNodeComponent
)fParent
.getParent();
682 IRemoteSystemProxy proxy
= node
.getRemoteSystemProxy();
683 IFileServiceSubSystem fsss
= proxy
.getFileServiceSubSystem();
686 IRemoteFile remoteFolder
= fsss
.getRemoteFileObject(fSessionPath
, new NullProgressMonitor());
687 if (remoteFolder
.exists()) {
688 MessageDialog
.openError(getShell(),
689 Messages
.TraceControl_CreateSessionDialogTitle
,
690 Messages
.TraceControl_SessionPathAlreadyExistsError
+ " (" + fSessionPath
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
693 } catch (SystemMessageException e
) {
694 MessageDialog
.openError(getShell(),
695 Messages
.TraceControl_CreateSessionDialogTitle
,
696 Messages
.TraceControl_FileSubSystemError
+ "\n" + e
); //$NON-NLS-1$
701 fIsDefaultPath
= false;
708 if (fIsStreamedTrace
) {
709 if (fControlProtocolCombo
.getSelectionIndex() < 0) {
710 MessageDialog
.openError(getShell(),
711 Messages
.TraceControl_CreateSessionDialogTitle
,
712 "Control Protocol Text is empty\n"); //$NON-NLS-1$
716 if ("".equals(fControlHostAddressText
.getText())) { //$NON-NLS-1$
717 MessageDialog
.openError(getShell(),
718 Messages
.TraceControl_CreateSessionDialogTitle
,
719 "Control Address Text is empty\n"); //$NON-NLS-1$
723 if(!fLinkDataWithControlButton
.getSelection()) {
724 if (fDataProtocolCombo
.getSelectionIndex() < 0) {
725 MessageDialog
.openError(getShell(),
726 Messages
.TraceControl_CreateSessionDialogTitle
,
727 "Control Protocol Text is empty\n"); //$NON-NLS-1$
731 if ("".equals(fDataHostAddressText
.getText())) { //$NON-NLS-1$
732 MessageDialog
.openError(getShell(),
733 Messages
.TraceControl_CreateSessionDialogTitle
,
734 "Control Address Text is empty\n"); //$NON-NLS-1$
738 fControlUrl
= getUrlString(fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()),
739 fControlHostAddressText
.getText(),
740 fControlPortText
.getText(),
744 fDataUrl
= getUrlString(fControlProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()),
745 fDataHostAddressText
.getText(),
747 fDataPortText
.getText(),
750 fNetworkUrl
= getUrlString(fControlProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()),
751 fControlHostAddressText
.getText(),
752 fControlPortText
.getText(),
753 fDataPortText
.getText(),
758 // Check for invalid names
759 if (!"".equals(fSessionName
) && !fSessionName
.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
760 MessageDialog
.openError(getShell(),
761 Messages
.TraceControl_CreateSessionDialogTitle
,
762 Messages
.TraceControl_InvalidSessionNameError
+ " (" + fSessionName
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
766 // Check if node with name already exists in parent
767 if(fParent
.containsChild(fSessionName
)) {
768 MessageDialog
.openError(getShell(),
769 Messages
.TraceControl_CreateSessionDialogTitle
,
770 Messages
.TraceControl_SessionAlreadyExistsError
+ " (" + fSessionName
+ ")"); //$NON-NLS-1$ //$NON-NLS-2$
774 if (fParent
.isNetworkStreamingSupported()) {
775 fIsNoConsumer
= fNoConsumerButton
.getSelection();
776 fIsDisableConsumer
= fDisableConsumerButton
.getSelection();
779 // validation successful -> call super.okPressed()
783 private static String
getUrlString(String proto
, String host
, String ctrlPort
, String dataPort
, String sessionPath
) {
784 //proto://[HOST|IP][:PORT1[:PORT2]][/TRACE_PATH]
785 StringBuilder stringBuilder
= new StringBuilder();
786 stringBuilder
.append(proto
);
787 stringBuilder
.append("://"); //$NON-NLS-1$
788 stringBuilder
.append(host
);
790 if ((ctrlPort
!= null) && (!"".equals(ctrlPort
))) { //$NON-NLS-1$
791 stringBuilder
.append(":"); //$NON-NLS-1$
792 stringBuilder
.append(ctrlPort
);
795 if ((dataPort
!= null) && (!"".equals(dataPort
))) { //$NON-NLS-1$
796 stringBuilder
.append(":"); //$NON-NLS-1$
797 stringBuilder
.append(dataPort
);
800 if ((sessionPath
!= null) && (!"".equals(sessionPath
))) { //$NON-NLS-1$
801 stringBuilder
.append("/"); //$NON-NLS-1$
802 stringBuilder
.append(sessionPath
);
804 return stringBuilder
.toString();
807 private static class CopyKeyListener
extends KeyAdapter
{
808 private Text fSource
;
809 private Text fDestination
;
811 public CopyKeyListener(Text source
, Text destination
) {
813 fDestination
= destination
;
817 public void keyReleased(KeyEvent e
) {
818 fDestination
.setText(fSource
.getText());
822 private class ControlProtocolSelectionListener
extends SelectionAdapter
{
825 public void widgetSelected(SelectionEvent e
) {
826 fDataProtocolCombo
.select(fControlProtocolCombo
.getSelectionIndex());
827 if (fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.file
.name())) {
828 fControlPortText
.setText(""); //$NON-NLS-1$
829 fDataPortText
.setText(""); //$NON-NLS-1$
830 fControlPortText
.setEnabled(false);
831 fDataPortText
.setEnabled(false);
833 fControlPortText
.setEnabled(true);
834 fDataPortText
.setEnabled(true);
839 private class ProtocolComboSelectionListener
extends SelectionAdapter
{
841 private CCombo fCombo
;
842 private Text fPortText
;
844 public ProtocolComboSelectionListener(CCombo combo
, Text portText
) {
846 fPortText
= portText
;
850 public void widgetSelected(SelectionEvent e
) {
851 if (fCombo
.getItem(fCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
852 fCombo
.getItem(fCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
853 fPortText
.setText(""); //$NON-NLS-1$
854 fPortText
.setEnabled(false);
856 fPortText
.setEnabled(true);