1 /**********************************************************************
2 * Copyright (c) 2012, 2015 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 * Marc-Andre Laperle - Support for creating a live session
13 * Markus Schorn - Bug 448058: Use org.eclipse.remote in favor of RSE
14 **********************************************************************/
16 package org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.dialogs
;
18 import org
.eclipse
.core
.filesystem
.IFileInfo
;
19 import org
.eclipse
.core
.filesystem
.IFileStore
;
20 import org
.eclipse
.jface
.dialogs
.IDialogConstants
;
21 import org
.eclipse
.jface
.dialogs
.TitleAreaDialog
;
22 import org
.eclipse
.remote
.core
.IRemoteFileService
;
23 import org
.eclipse
.swt
.SWT
;
24 import org
.eclipse
.swt
.custom
.CCombo
;
25 import org
.eclipse
.swt
.events
.FocusEvent
;
26 import org
.eclipse
.swt
.events
.FocusListener
;
27 import org
.eclipse
.swt
.events
.ModifyEvent
;
28 import org
.eclipse
.swt
.events
.ModifyListener
;
29 import org
.eclipse
.swt
.events
.SelectionAdapter
;
30 import org
.eclipse
.swt
.events
.SelectionEvent
;
31 import org
.eclipse
.swt
.events
.VerifyEvent
;
32 import org
.eclipse
.swt
.events
.VerifyListener
;
33 import org
.eclipse
.swt
.layout
.GridData
;
34 import org
.eclipse
.swt
.layout
.GridLayout
;
35 import org
.eclipse
.swt
.widgets
.Button
;
36 import org
.eclipse
.swt
.widgets
.Composite
;
37 import org
.eclipse
.swt
.widgets
.Control
;
38 import org
.eclipse
.swt
.widgets
.Group
;
39 import org
.eclipse
.swt
.widgets
.Label
;
40 import org
.eclipse
.swt
.widgets
.Shell
;
41 import org
.eclipse
.swt
.widgets
.Text
;
42 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.ISessionInfo
;
43 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.impl
.SessionInfo
;
44 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.Activator
;
45 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.messages
.Messages
;
46 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TargetNodeComponent
;
47 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceSessionGroup
;
48 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.service
.LTTngControlServiceConstants
;
49 import org
.eclipse
.tracecompass
.tmf
.remote
.core
.proxy
.IRemoteSystemProxy
;
53 * Dialog box for collecting session creation information.
56 * @author Bernd Hufmann
58 public class CreateSessionDialog
extends TitleAreaDialog
implements ICreateSessionDialog
{
60 // ------------------------------------------------------------------------
62 // ------------------------------------------------------------------------
64 * The icon file for this dialog box.
66 public static final String CREATE_SESSION_ICON_FILE
= "icons/elcl16/add_button.gif"; //$NON-NLS-1$
69 * To indicate that the default value will be used for this field
71 private static final String DEFAULT_TEXT
= "<" + Messages
.EnableChannelDialog_DefaultMessage
+ ">"; //$NON-NLS-1$ //$NON-NLS-2$
74 * Supported network protocols for streaming
76 private enum StreamingProtocol
{
77 /** Default network protocol for IPv4 (TCP)*/
79 /** Default network protocol for IPv6 (TCP)*/
86 * Supported network protocols for Live tracing
88 private enum LiveProtocol
{
89 /** Default network protocol for IPv4 (TCP)*/
91 /** Default network protocol for IPv6 (TCP)*/
95 private enum StreamingProtocol2
{
96 /** Default network protocol for IPv4 (TCP)*/
98 /** Default network protocol for IPv6 (TCP)*/
100 /** TCP network protocol for IPv4*/
102 /** TCP network protocol for IPv6*/
106 * Index of last supported streaming protocol for common URL configuration.
108 private static final int COMMON_URL_LAST_INDEX
= 1;
110 * Index of default streaming protocol.
112 private static final int DEFAULT_URL_INDEX
= 0;
114 // ------------------------------------------------------------------------
116 // ------------------------------------------------------------------------
118 * The dialog composite.
120 private Composite fDialogComposite
= null;
122 * The text widget for the session name
124 private Text fSessionNameText
= null;
126 * The label widget for the session path.
128 private Label fSessionPathLabel
= null;
130 * The text widget for the session path.
132 private Text fSessionPathText
= null;
134 * The button widget to select a normal session
136 private Button fNormalModeButton
= null;
138 * The button widget to select a snapshot session
140 private Button fSnapshotButton
= null;
142 * The group that contains the mutually exclusive mode buttons
144 private Group fModeButtonGroup
= null;
146 * The button widget to select a live session
148 private Button fLiveButton
= null;
151 * The text widget to set a live delay
153 private Text fLiveDelayText
= null;
155 * The Group for advanced configuration.
157 private Group fAdvancedGroup
= null;
159 * The button to show advanced options.
161 private Button fAdvancedButton
= null;
163 * The composite with streaming configuration parameter.
165 private Composite fStreamingComposite
= null;
167 * The text widget for the trace path.
169 private Text fTracePathText
= null;
171 * The button to link data protocol/Address with control protocol.
173 private Button fLinkDataWithControlButton
= null;
175 * The Combo box for channel protocol selection.
177 private CCombo fControlProtocolCombo
= null;
179 * A selection listener that copies the protocol from control to data when being linked.
181 private ControlProtocolSelectionListener fCopyProtocolSelectionListener
;
183 * A selection listener updates the control port text depending on the control protocol selected.
185 private ProtocolComboSelectionListener fControlProtocolSelectionListener
;
187 * A selection listener updates the data port text depending on the data protocol selected.
189 private ProtocolComboSelectionListener fDataProtocolSelectionListener
;
191 * The text box for the host/IP address of the control channel.
193 private Text fControlHostAddressText
= null;
195 * A key listener that copies the host address from control to data when being linked.
197 private CopyModifyListener fControlUrlKeyListener
;
199 * A modify listener that updates the enablement of the dialog.
201 private UpdateEnablementModifyListener fUpdateEnablementModifyListener
;
203 * The text box for the control port.
205 private Text fControlPortText
= null;
207 * The Combo box for data protocol selection.
209 private CCombo fDataProtocolCombo
= null;
211 * The text box for the host/IP address of the data channel.
213 private Text fDataHostAddressText
= null;
215 * The text box for the data port.
217 private Text fDataPortText
= null;
219 * The parent where the new node should be added.
221 private TraceSessionGroup fParent
= null;
223 * The session name string.
225 private String fSessionName
= ""; //$NON-NLS-1$;
227 * The session path string.
229 private String fSessionPath
= null;
231 * Flag whether the session is snapshot or not
233 private boolean fIsSnapshot
= false;
235 * Flag whether the session is live or not
237 private boolean fIsLive
= false;
239 * The text box for the live address (relayd).
241 private Text fLiveHostAddressText
= null;
243 * The text box for the live port (relayd).
245 private Text fLivePortText
= null;
249 private Long fLiveDelay
= 0L;
253 private String fLiveUrl
= null;
257 private Integer fLivePort
= 0;
259 * Flag whether default location (path) shall be used or not
261 private boolean fIsDefaultPath
= true;
263 * Flag whether the advanced options are enabled or not
265 private boolean fIsAdvancedEnabled
= false;
267 * The network URL in case control and data is configured together.
268 * If set, fControlUrl and fDataUrl will be null.
270 private String fNetworkUrl
= null;
272 * The control URL in case control and data is configured separately.
273 * If set, fDataUrl will be set too and fNetworkUrl will be null.
275 private String fControlUrl
= null;
277 * The data URL in case control and data is configured separately.
278 * If set, fControlUrl will be set too and fNetworkUrl will be null.
280 private String fDataUrl
= null;
282 * The trace path string.
284 private String fTracePath
= null;
286 * The Group for advanced configuration of Live mode.
288 private Group fLiveGroup
= null;
290 // ------------------------------------------------------------------------
292 // ------------------------------------------------------------------------
295 * @param shell - a shell for the display of the dialog
297 public CreateSessionDialog(Shell shell
) {
299 setShellStyle(SWT
.RESIZE
| getShellStyle());
302 // ------------------------------------------------------------------------
304 // ------------------------------------------------------------------------
307 public void initialize(TraceSessionGroup group
) {
309 fStreamingComposite
= null;
313 fSnapshotButton
= null;
314 fSessionName
= ""; //$NON-NLS-1$
317 fIsDefaultPath
= true;
318 fIsAdvancedEnabled
= false;
323 // ------------------------------------------------------------------------
325 // ------------------------------------------------------------------------
328 protected void configureShell(Shell newShell
) {
329 super.configureShell(newShell
);
330 newShell
.setText(Messages
.TraceControl_CreateSessionDialogTitle
);
331 newShell
.setImage(Activator
.getDefault().loadIcon(CREATE_SESSION_ICON_FILE
));
335 protected Control
createDialogArea(Composite parent
) {
336 Composite dialogAreaa
= (Composite
) super.createDialogArea(parent
);
337 setTitle(Messages
.TraceControl_CreateSessionDialogTitle
);
338 setMessage(Messages
.TraceControl_CreateSessionDialogMessage
);
341 fDialogComposite
= new Composite(dialogAreaa
, SWT
.NONE
);
342 GridLayout layout
= new GridLayout(1, true);
343 fDialogComposite
.setLayout(layout
);
344 fDialogComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
346 Group sessionGroup
= new Group(fDialogComposite
, SWT
.SHADOW_NONE
);
347 sessionGroup
.setLayoutData(new GridData(GridData
.FILL_HORIZONTAL
));
348 sessionGroup
.setLayout(new GridLayout(4, true));
350 fUpdateEnablementModifyListener
= new UpdateEnablementModifyListener();
352 Label sessionNameLabel
= new Label(sessionGroup
, SWT
.RIGHT
);
353 sessionNameLabel
.setText(Messages
.TraceControl_CreateSessionNameLabel
);
354 fSessionNameText
= new Text(sessionGroup
, SWT
.NONE
);
355 fSessionNameText
.setToolTipText(Messages
.TraceControl_CreateSessionNameTooltip
);
356 fSessionNameText
.addModifyListener(fUpdateEnablementModifyListener
);
357 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
358 data
.horizontalSpan
= 3;
359 fSessionNameText
.setLayoutData(data
);
361 fSessionPathLabel
= new Label(sessionGroup
, SWT
.RIGHT
);
362 fSessionPathLabel
.setText(Messages
.TraceControl_CreateSessionPathLabel
);
363 fSessionPathText
= new Text(sessionGroup
, SWT
.NONE
);
364 fSessionPathText
.setToolTipText(Messages
.TraceControl_CreateSessionPathTooltip
);
365 data
= new GridData(GridData
.FILL_HORIZONTAL
);
366 data
.horizontalSpan
= 3;
367 fSessionPathText
.setLayoutData(data
);
368 fSessionPathText
.addModifyListener(fUpdateEnablementModifyListener
);
370 if (fParent
.isSnapshotSupported() || fParent
.isLiveSupported()) {
371 fModeButtonGroup
= new Group(sessionGroup
, SWT
.NONE
);
372 data
= new GridData(GridData
.FILL_HORIZONTAL
);
373 data
.horizontalSpan
= 4;
374 fModeButtonGroup
.setLayoutData(data
);
375 fModeButtonGroup
.setLayout(new GridLayout(3, true));
377 SelectionAdapter modeChangedListener
= new SelectionAdapter() {
379 public void widgetSelected(SelectionEvent e
) {
380 if (fLiveButton
!= null) {
381 if (fLiveButton
.getSelection()) {
382 createAdvancedLiveGroup();
383 updateSessionPathEnablement();
384 updateProtocolComboItems();
387 updateSessionPathEnablement();
388 updateProtocolComboItems();
395 fNormalModeButton
= new Button(fModeButtonGroup
, SWT
.RADIO
);
396 fNormalModeButton
.setText(Messages
.TraceControl_CreateSessionNormalLabel
);
397 fNormalModeButton
.setToolTipText(Messages
.TraceControl_CreateSessionNormalTooltip
);
398 fNormalModeButton
.setSelection(true);
399 fNormalModeButton
.addSelectionListener(modeChangedListener
);
401 if (fParent
.isSnapshotSupported()) {
402 fSnapshotButton
= new Button(fModeButtonGroup
, SWT
.RADIO
);
403 fSnapshotButton
.setText(Messages
.TraceControl_CreateSessionSnapshotLabel
);
404 fSnapshotButton
.setToolTipText(Messages
.TraceControl_CreateSessionSnapshotTooltip
);
405 fSnapshotButton
.addSelectionListener(modeChangedListener
);
408 if (fParent
.isLiveSupported()) {
409 fLiveButton
= new Button(fModeButtonGroup
, SWT
.RADIO
);
410 fLiveButton
.setText(Messages
.TraceControl_CreateSessionLiveLabel
);
411 fLiveButton
.setToolTipText(Messages
.TraceControl_CreateSessionLiveTooltip
);
412 fLiveButton
.addSelectionListener(modeChangedListener
);
416 if (fParent
.isNetworkStreamingSupported() || fParent
.isLiveSupported()) {
417 createAdvancedOptionsComposite();
420 return fDialogComposite
;
423 private void createAdvancedOptionsComposite() {
425 fAdvancedGroup
= new Group(fDialogComposite
, SWT
.SHADOW_NONE
);
426 fAdvancedGroup
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
427 fAdvancedGroup
.setLayout(new GridLayout(1, true));
429 fAdvancedButton
= new Button(fAdvancedGroup
, SWT
.PUSH
);
430 fAdvancedButton
.setText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonText
+ " >>>"); //$NON-NLS-1$
431 fAdvancedButton
.setToolTipText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonTooltip
);
432 fAdvancedButton
.addSelectionListener(new SelectionAdapter() {
434 public void widgetSelected(SelectionEvent e
) {
435 if (fIsAdvancedEnabled
) {
436 fIsAdvancedEnabled
= false;
437 fAdvancedButton
.setText(">>> " + Messages
.TraceControl_CreateSessionConfigureStreamingButtonText
); //$NON-NLS-1$
438 fAdvancedButton
.setToolTipText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonTooltip
);
440 if (fParent
.isNetworkStreamingSupported()) {
441 updateSessionPathEnablement();
442 disposeConfigureStreamingComposite();
445 if (fParent
.isLiveSupported()) {
449 fIsAdvancedEnabled
= true;
450 fAdvancedButton
.setText("<<< " + Messages
.TraceControl_CreateSessionNoStreamingButtonText
); //$NON-NLS-1$
451 fAdvancedButton
.setToolTipText(Messages
.TraceControl_CreateSessionNoStreamingButtonTooltip
);
453 if (fParent
.isNetworkStreamingSupported()) {
454 updateSessionPathEnablement();
455 createConfigureStreamingComposite();
457 if (fLiveButton
!= null && fLiveButton
.getSelection()) {
458 createAdvancedLiveGroup();
468 private void updateSessionPathEnablement() {
469 if (fIsAdvancedEnabled
|| fIsLive
) {
470 fSessionPathText
.setEnabled(false);
471 fSessionPathText
.setText(""); //$NON-NLS-1$
472 fSessionPathLabel
.setText(""); //$NON-NLS-1$
474 fSessionPathText
.setEnabled(true);
475 fSessionPathLabel
.setText(Messages
.TraceControl_CreateSessionPathLabel
);
479 private void updateProtocolComboItems() {
480 if (fControlProtocolCombo
== null || fControlProtocolCombo
.isDisposed()) {
484 int currentSelection
= fControlProtocolCombo
.getSelectionIndex() <= COMMON_URL_LAST_INDEX ?
485 fControlProtocolCombo
.getSelectionIndex() : DEFAULT_URL_INDEX
;
487 fControlProtocolCombo
.removeAll();
488 Enum
<?
extends Enum
<?
>>[] values
;
490 values
= LiveProtocol
.values();
491 } else if (fLinkDataWithControlButton
.getSelection()) {
492 values
= StreamingProtocol
.values();
494 values
= StreamingProtocol2
.values();
497 String
[] controlItems
= new String
[values
.length
];
498 for (int i
= 0; i
< controlItems
.length
; i
++) {
499 controlItems
[i
] = values
[i
].name();
501 fControlProtocolCombo
.setItems(controlItems
);
502 fDataProtocolCombo
.setItems(controlItems
);
505 if (currentSelection
!= -1) {
506 fControlProtocolCombo
.select(currentSelection
);
507 fDataProtocolCombo
.select(currentSelection
);
511 private void createConfigureStreamingComposite() {
512 if (fStreamingComposite
== null) {
513 fStreamingComposite
= new Group(fAdvancedGroup
, SWT
.SHADOW_NONE
);
514 GridLayout layout
= new GridLayout(1, true);
515 fStreamingComposite
.setLayout(layout
);
516 fStreamingComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
518 layout
= new GridLayout(7, true);
519 fStreamingComposite
.setLayout(layout
);
520 fStreamingComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
522 Label tracePathLabel
= new Label(fStreamingComposite
, SWT
.RIGHT
);
523 tracePathLabel
.setText(Messages
.TraceControl_CreateSessionTracePathText
);
524 fTracePathText
= new Text(fStreamingComposite
, SWT
.NONE
);
525 fTracePathText
.setToolTipText(Messages
.TraceControl_CreateSessionTracePathTooltip
);
528 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
529 data
.horizontalSpan
= 6;
530 fTracePathText
.setLayoutData(data
);
531 fTracePathText
.addModifyListener(fUpdateEnablementModifyListener
);
533 fLinkDataWithControlButton
= new Button(fStreamingComposite
, SWT
.CHECK
);
534 fLinkDataWithControlButton
.setText(Messages
.TraceControl_CreateSessionLinkButtonText
);
535 fLinkDataWithControlButton
.setToolTipText(Messages
.TraceControl_CreateSessionLinkButtonTooltip
);
536 data
= new GridData(GridData
.FILL_HORIZONTAL
);
537 data
.horizontalSpan
= 7;
538 fLinkDataWithControlButton
.setLayoutData(data
);
539 fLinkDataWithControlButton
.setSelection(true);
541 Label label
= new Label(fStreamingComposite
, SWT
.NONE
);
542 data
= new GridData(GridData
.FILL_HORIZONTAL
);
543 data
.horizontalSpan
= 1;
544 label
.setLayoutData(data
);
546 label
= new Label(fStreamingComposite
, SWT
.NONE
);
547 label
.setText(Messages
.TraceControl_CreateSessionProtocolLabelText
);
548 data
= new GridData(GridData
.FILL_HORIZONTAL
);
549 data
.horizontalSpan
= 1;
550 label
.setLayoutData(data
);
552 label
= new Label(fStreamingComposite
, SWT
.NONE
);
553 label
.setText(Messages
.TraceControl_CreateSessionAddressLabelText
);
554 data
= new GridData(GridData
.FILL_HORIZONTAL
);
555 data
.horizontalSpan
= 4;
556 label
.setLayoutData(data
);
558 label
= new Label(fStreamingComposite
, SWT
.NONE
);
559 label
.setText(Messages
.TraceControl_CreateSessionPortLabelText
);
560 data
= new GridData(GridData
.FILL_HORIZONTAL
);
561 data
.horizontalSpan
= 1;
562 label
.setLayoutData(data
);
564 label
= new Label(fStreamingComposite
, SWT
.RIGHT
);
565 label
.setText(Messages
.TraceControl_CreateSessionControlUrlLabel
);
566 data
= new GridData(GridData
.FILL_HORIZONTAL
);
567 data
.horizontalSpan
= 1;
568 label
.setLayoutData(data
);
570 fControlProtocolCombo
= new CCombo(fStreamingComposite
, SWT
.READ_ONLY
);
571 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionCommonProtocolTooltip
);
572 data
= new GridData(GridData
.FILL_HORIZONTAL
);
573 data
.horizontalSpan
= 1;
574 fControlProtocolCombo
.setLayoutData(data
);
575 fControlProtocolCombo
.addModifyListener(fUpdateEnablementModifyListener
);
577 fControlHostAddressText
= new Text(fStreamingComposite
, SWT
.NONE
);
578 fControlHostAddressText
.setToolTipText(Messages
.TraceControl_CreateSessionControlAddressTooltip
);
579 data
= new GridData(GridData
.FILL_HORIZONTAL
);
580 data
.horizontalSpan
= 4;
581 fControlHostAddressText
.setLayoutData(data
);
582 fControlHostAddressText
.addModifyListener(fUpdateEnablementModifyListener
);
584 fControlPortText
= new Text(fStreamingComposite
, SWT
.NONE
);
585 fControlPortText
.setToolTipText(Messages
.TraceControl_CreateSessionControlPortTooltip
);
586 data
= new GridData(GridData
.FILL_HORIZONTAL
);
587 data
.horizontalSpan
= 1;
588 fControlPortText
.setLayoutData(data
);
589 fControlPortText
.addModifyListener(fUpdateEnablementModifyListener
);
591 label
= new Label(fStreamingComposite
, SWT
.RIGHT
);
592 label
.setText(Messages
.TraceControl_CreateSessionDataUrlLabel
);
593 data
= new GridData(GridData
.FILL_HORIZONTAL
);
594 data
.horizontalSpan
= 1;
595 label
.setLayoutData(data
);
597 fDataProtocolCombo
= new CCombo(fStreamingComposite
, SWT
.READ_ONLY
);
598 fDataProtocolCombo
.setEnabled(false);
599 fDataProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
600 data
= new GridData(GridData
.FILL_HORIZONTAL
);
601 data
.horizontalSpan
= 1;
602 fDataProtocolCombo
.setLayoutData(data
);
603 fDataProtocolCombo
.addModifyListener(fUpdateEnablementModifyListener
);
605 updateProtocolComboItems();
607 fDataHostAddressText
= new Text(fStreamingComposite
, SWT
.NONE
);
608 fDataHostAddressText
.setEnabled(false);
609 fDataHostAddressText
.setToolTipText(Messages
.TraceControl_CreateSessionDataAddressTooltip
);
610 data
= new GridData(GridData
.FILL_HORIZONTAL
);
611 data
.horizontalSpan
= 4;
612 fDataHostAddressText
.setLayoutData(data
);
613 fDataHostAddressText
.addModifyListener(fUpdateEnablementModifyListener
);
615 fDataPortText
= new Text(fStreamingComposite
, SWT
.NONE
);
616 fDataPortText
.setEnabled(true);
617 fDataPortText
.setToolTipText(Messages
.TraceControl_CreateSessionDataPortTooltip
);
618 data
= new GridData(GridData
.FILL_HORIZONTAL
);
619 data
.horizontalSpan
= 1;
620 fDataPortText
.setLayoutData(data
);
621 fDataPortText
.addModifyListener(fUpdateEnablementModifyListener
);
623 fCopyProtocolSelectionListener
= new ControlProtocolSelectionListener();
624 fControlProtocolSelectionListener
= new ProtocolComboSelectionListener(fControlProtocolCombo
, fControlPortText
);
625 fDataProtocolSelectionListener
= new ProtocolComboSelectionListener(fDataProtocolCombo
, fDataPortText
);
627 fControlProtocolCombo
.addSelectionListener(fCopyProtocolSelectionListener
);
629 fControlUrlKeyListener
= new CopyModifyListener(fControlHostAddressText
, fDataHostAddressText
);
630 fControlHostAddressText
.addModifyListener(fControlUrlKeyListener
);
632 fControlProtocolCombo
.select(DEFAULT_URL_INDEX
);
633 fDataProtocolCombo
.select(DEFAULT_URL_INDEX
);
635 fLinkDataWithControlButton
.addSelectionListener(new SelectionAdapter() {
637 public void widgetSelected(SelectionEvent e
) {
638 if (fLinkDataWithControlButton
.getSelection()) {
639 // Set enablement control data channel inputs
640 fDataProtocolCombo
.setEnabled(false);
641 fDataHostAddressText
.setEnabled(false);
642 fControlPortText
.setEnabled(true);
643 fDataPortText
.setEnabled(true);
646 fControlProtocolCombo
.removeSelectionListener(fControlProtocolSelectionListener
);
647 fDataProtocolCombo
.removeSelectionListener(fDataProtocolSelectionListener
);
648 fControlProtocolCombo
.addSelectionListener(fCopyProtocolSelectionListener
);
649 fControlHostAddressText
.addModifyListener(fControlUrlKeyListener
);
651 updateProtocolComboItems();
653 fDataHostAddressText
.setText(fControlHostAddressText
.getText());
656 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionCommonProtocolTooltip
);
658 // Enable data channel inputs
659 fDataProtocolCombo
.setEnabled(true);
660 fDataHostAddressText
.setEnabled(true);
663 fControlProtocolCombo
.removeSelectionListener(fCopyProtocolSelectionListener
);
664 fControlProtocolCombo
.addSelectionListener(fControlProtocolSelectionListener
);
665 fDataProtocolCombo
.addSelectionListener(fDataProtocolSelectionListener
);
666 fControlHostAddressText
.removeModifyListener(fControlUrlKeyListener
);
668 updateProtocolComboItems();
671 fDataProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
672 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
674 // Update control/data port enablement and input
675 if (fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
676 fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
677 fControlPortText
.setText(""); //$NON-NLS-1$
678 fControlPortText
.setEnabled(false);
680 fControlPortText
.setEnabled(true);
683 if (fDataProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
684 fDataProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
685 fDataPortText
.setText(""); //$NON-NLS-1$
686 fDataPortText
.setEnabled(false);
688 fDataPortText
.setEnabled(true);
696 private void createAdvancedLiveGroup() {
697 if (fLiveGroup
== null && fIsAdvancedEnabled
) {
698 GridLayout layout
= new GridLayout(7, true);
699 fLiveGroup
= new Group(fAdvancedGroup
, SWT
.NONE
);
700 fLiveGroup
.setLayout(layout
);
701 GridData layoutData
= new GridData(GridData
.FILL_BOTH
);
702 fLiveGroup
.setLayoutData(layoutData
);
704 Label label
= new Label(fLiveGroup
, SWT
.NONE
);
705 label
.setText(Messages
.TraceControl_CreateSessionLiveConnectionLabel
);
706 layoutData
= new GridData(GridData
.FILL_HORIZONTAL
);
707 layoutData
.horizontalSpan
= 2;
708 label
.setLayoutData(layoutData
);
710 fLiveHostAddressText
= new Text(fLiveGroup
, SWT
.NONE
);
711 fLiveHostAddressText
.setText(SessionInfo
.DEFAULT_LIVE_NETWORK_URL
);
712 fLiveHostAddressText
.setEnabled(false);
713 fLiveHostAddressText
.setToolTipText(Messages
.TraceControl_CreateSessionLiveConnectionUrlTooltip
);
714 layoutData
= new GridData(GridData
.FILL_HORIZONTAL
);
715 layoutData
.horizontalSpan
= 4;
716 fLiveHostAddressText
.setLayoutData(layoutData
);
718 fLivePortText
= new Text(fLiveGroup
, SWT
.NONE
);
719 fLivePortText
.setText(Integer
.toString(SessionInfo
.DEFAULT_LIVE_PORT
));
720 fLivePortText
.setToolTipText(Messages
.TraceControl_CreateSessionLiveConnectionPortTooltip
);
721 layoutData
= new GridData(GridData
.FILL_HORIZONTAL
);
722 fLivePortText
.setLayoutData(layoutData
);
724 Label liveDelayLabel
= new Label(fLiveGroup
, SWT
.NONE
);
725 layoutData
= new GridData(GridData
.FILL_HORIZONTAL
);
726 liveDelayLabel
.setText(Messages
.TraceControl_CreateSessionLiveDelayLabel
);
727 liveDelayLabel
.setLayoutData(layoutData
);
728 fLiveDelayText
= new Text(fLiveGroup
, SWT
.NONE
);
729 fLiveDelayText
.setText(DEFAULT_TEXT
);
730 fLiveDelayText
.setForeground(getShell().getDisplay().getSystemColor(SWT
.COLOR_GRAY
));
731 fLiveDelayText
.setToolTipText(Messages
.TraceControl_CreateSessionLiveDelayTooltip
);
732 fLiveDelayText
.addVerifyListener(new VerifyListener() {
734 public void verifyText(VerifyEvent e
) {
735 // only numbers and default are allowed.
736 e
.doit
= e
.text
.matches("[0-9]*") || e
.text
.matches(DEFAULT_TEXT
); //$NON-NLS-1$
740 fLiveDelayText
.addModifyListener(new ModifyListener() {
742 public void modifyText(ModifyEvent event
) {
747 fLiveDelayText
.addFocusListener(new FocusListener() {
750 public void focusLost(FocusEvent e
) {
751 Text focusLostWidget
= (Text
) e
.widget
;
752 if (focusLostWidget
.getText().isEmpty()) {
753 focusLostWidget
.setText(DEFAULT_TEXT
);
754 focusLostWidget
.setForeground(getShell().getDisplay().getSystemColor(SWT
.COLOR_GRAY
));
759 public void focusGained(FocusEvent e
) {
760 Text focusGainedWidget
= (Text
) e
.widget
;
761 if (focusGainedWidget
.getText().equals(DEFAULT_TEXT
)) {
762 focusGainedWidget
.setText(""); //$NON-NLS-1$
763 focusGainedWidget
.setForeground(getShell().getDisplay().getSystemColor(SWT
.COLOR_BLACK
));
768 layoutData
= new GridData(GridData
.FILL_HORIZONTAL
);
769 layoutData
.grabExcessHorizontalSpace
= true;
770 layoutData
.horizontalSpan
= 6;
771 fLiveDelayText
.setLayoutData(layoutData
);
776 private void disposeLiveGroup() {
777 if (fLiveGroup
!= null) {
778 fLiveGroup
.dispose();
784 private void disposeConfigureStreamingComposite() {
785 if (fStreamingComposite
!= null) {
786 fStreamingComposite
.dispose();
787 fStreamingComposite
= null;
792 protected void createButtonsForButtonBar(Composite parent
) {
793 createButton(parent
, IDialogConstants
.CANCEL_ID
, "&Cancel", true); //$NON-NLS-1$
794 createButton(parent
, IDialogConstants
.OK_ID
, "&Ok", true); //$NON-NLS-1$
797 private void updateEnablement() {
799 getButton(IDialogConstants
.OK_ID
).setEnabled(getErrorMessage() == null);
802 private void validate() {
803 // Validate input data
804 fSessionName
= fSessionNameText
.getText();
805 fSessionPath
= fSessionPathText
.getText();
806 setErrorMessage(null);
808 if (fParent
.isLiveSupported() && fLiveButton
!= null) {
809 fIsLive
= fLiveButton
.getSelection();
810 fLiveDelay
= Long
.valueOf(LTTngControlServiceConstants
.UNUSED_VALUE
);
811 fLiveUrl
= SessionInfo
.DEFAULT_LIVE_NETWORK_URL
;
812 fLivePort
= SessionInfo
.DEFAULT_LIVE_PORT
;
815 if (!"".equals(fSessionPath
)) { //$NON-NLS-1$
816 // validate sessionPath
817 if (!fIsAdvancedEnabled
&& !fIsLive
) {
818 TargetNodeComponent node
= (TargetNodeComponent
)fParent
.getParent();
819 IRemoteSystemProxy proxy
= node
.getRemoteSystemProxy();
820 IRemoteFileService fsss
= proxy
.getRemoteFileService();
822 IFileStore remoteFolder
= fsss
.getResource(fSessionPath
);
823 if (remoteFolder
== null) {
824 setErrorMessage(Messages
.TraceControl_InvalidSessionPathError
+ " (" + fSessionPath
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
827 IFileInfo fileInfo
= remoteFolder
.fetchInfo();
828 if (fileInfo
.exists()) {
829 setErrorMessage(Messages
.TraceControl_SessionPathAlreadyExistsError
+ " (" + fSessionPath
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
834 fIsDefaultPath
= false;
837 if (fParent
.isSnapshotSupported()) {
838 fIsSnapshot
= fSnapshotButton
.getSelection();
845 if (fIsAdvancedEnabled
&& fStreamingComposite
!= null) {
846 // Validate input data
848 if (fIsLive
&& fLiveGroup
!= null) {
849 String liveDelayText
= fLiveDelayText
.getText();
851 fLiveDelay
= liveDelayText
.equals(DEFAULT_TEXT
) ? LTTngControlServiceConstants
.UNUSED_VALUE
: Long
.valueOf(liveDelayText
);
852 fLivePort
= Integer
.valueOf(fLivePortText
.getText());
853 fLiveUrl
= fLiveHostAddressText
.getText();
854 } catch (NumberFormatException e
) {
855 setErrorMessage(Messages
.TraceControl_InvalidLiveDelayError
);
860 fTracePath
= fTracePathText
.getText();
862 if (fControlProtocolCombo
.getSelectionIndex() < 0) {
863 setErrorMessage("Control Protocol Text is empty\n"); //$NON-NLS-1$
867 if ("".equals(fControlHostAddressText
.getText())) { //$NON-NLS-1$
868 setErrorMessage("Control Address Text is empty\n"); //$NON-NLS-1$
872 if (!fLinkDataWithControlButton
.getSelection()) {
873 if (fDataProtocolCombo
.getSelectionIndex() < 0) {
874 setErrorMessage("Data Protocol Text is empty\n"); //$NON-NLS-1$
878 if ("".equals(fDataHostAddressText
.getText())) { //$NON-NLS-1$
879 setErrorMessage("Data Address Text is empty\n"); //$NON-NLS-1$
883 fControlUrl
= getUrlString(fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()),
884 fControlHostAddressText
.getText(),
885 fControlPortText
.getText(),
889 fDataUrl
= getUrlString(fDataProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()),
890 fDataHostAddressText
.getText(),
892 fDataPortText
.getText(),
895 fNetworkUrl
= getUrlString(fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()),
896 fControlHostAddressText
.getText(),
897 fControlPortText
.getText(),
898 fDataPortText
.getText(),
903 if (fIsLive
&& fNetworkUrl
== null && fControlUrl
== null && fDataUrl
== null) {
904 fNetworkUrl
= SessionInfo
.DEFAULT_LIVE_NETWORK_URL
;
907 // Check for invalid names
908 if (!"".equals(fSessionName
) && !fSessionName
.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
909 setErrorMessage(Messages
.TraceControl_InvalidSessionNameError
+ " (" + fSessionName
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
913 // Check if node with name already exists in parent
914 if(fParent
.containsChild(fSessionName
)) {
915 setErrorMessage(Messages
.TraceControl_SessionAlreadyExistsError
+ " (" + fSessionName
+ ")"); //$NON-NLS-1$ //$NON-NLS-2$
920 private static String
getUrlString(String proto
, String host
, String ctrlPort
, String dataPort
, String sessionPath
) {
921 //proto://[HOST|IP][:PORT1[:PORT2]][/TRACE_PATH]
922 StringBuilder stringBuilder
= new StringBuilder();
923 stringBuilder
.append(proto
);
924 stringBuilder
.append("://"); //$NON-NLS-1$
925 stringBuilder
.append(host
);
927 if ((ctrlPort
!= null) && (!"".equals(ctrlPort
))) { //$NON-NLS-1$
928 stringBuilder
.append(":"); //$NON-NLS-1$
929 stringBuilder
.append(ctrlPort
);
932 if ((dataPort
!= null) && (!"".equals(dataPort
))) { //$NON-NLS-1$
933 stringBuilder
.append(":"); //$NON-NLS-1$
934 stringBuilder
.append(dataPort
);
937 if ((sessionPath
!= null) && (!"".equals(sessionPath
))) { //$NON-NLS-1$
938 stringBuilder
.append("/"); //$NON-NLS-1$
939 stringBuilder
.append(sessionPath
);
941 return stringBuilder
.toString();
944 private static class CopyModifyListener
implements ModifyListener
{
945 private Text fSource
;
946 private Text fDestination
;
948 public CopyModifyListener(Text source
, Text destination
) {
950 fDestination
= destination
;
954 public void modifyText(ModifyEvent e
) {
955 fDestination
.setText(fSource
.getText());
959 private class ControlProtocolSelectionListener
extends SelectionAdapter
{
962 public void widgetSelected(SelectionEvent e
) {
963 fDataProtocolCombo
.select(fControlProtocolCombo
.getSelectionIndex());
964 if (fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.file
.name())) {
965 fControlPortText
.setText(""); //$NON-NLS-1$
966 fDataPortText
.setText(""); //$NON-NLS-1$
967 fControlPortText
.setEnabled(false);
968 fDataPortText
.setEnabled(false);
970 fControlPortText
.setEnabled(true);
971 fDataPortText
.setEnabled(true);
976 private class ProtocolComboSelectionListener
extends SelectionAdapter
{
978 private CCombo fCombo
;
979 private Text fPortText
;
981 public ProtocolComboSelectionListener(CCombo combo
, Text portText
) {
983 fPortText
= portText
;
987 public void widgetSelected(SelectionEvent e
) {
988 if (fCombo
.getItem(fCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
989 fCombo
.getItem(fCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
990 fPortText
.setText(""); //$NON-NLS-1$
991 fPortText
.setEnabled(false);
993 fPortText
.setEnabled(true);
999 public ISessionInfo
getParameters() {
1000 ISessionInfo sessionInfo
= new SessionInfo(fSessionName
);
1002 boolean isStreaming
= (fIsAdvancedEnabled
&& fStreamingComposite
!= null) || fIsLive
;
1004 sessionInfo
.setNetworkUrl(fNetworkUrl
);
1005 sessionInfo
.setControlUrl(fControlUrl
);
1006 sessionInfo
.setDataUrl(fDataUrl
);
1007 sessionInfo
.setStreamedTrace(true);
1008 } else if (!fIsDefaultPath
) {
1009 sessionInfo
.setSessionPath(fSessionPath
);
1012 sessionInfo
.setLive(fIsLive
);
1013 sessionInfo
.setLiveUrl(fLiveUrl
);
1014 sessionInfo
.setLivePort(fLivePort
);
1015 sessionInfo
.setLiveDelay(fLiveDelay
);
1016 sessionInfo
.setSnapshot(fIsSnapshot
);
1021 private final class UpdateEnablementModifyListener
implements ModifyListener
{
1023 public void modifyText(ModifyEvent e
) {