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 **********************************************************************/
14 package org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.dialogs
;
16 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
17 import org
.eclipse
.jface
.dialogs
.IDialogConstants
;
18 import org
.eclipse
.jface
.dialogs
.TitleAreaDialog
;
19 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.ISessionInfo
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.impl
.SessionInfo
;
21 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.Activator
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.messages
.Messages
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TargetNodeComponent
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceSessionGroup
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.remote
.IRemoteSystemProxy
;
26 import org
.eclipse
.rse
.services
.clientserver
.messages
.SystemMessageException
;
27 import org
.eclipse
.rse
.subsystems
.files
.core
.servicesubsystem
.IFileServiceSubSystem
;
28 import org
.eclipse
.rse
.subsystems
.files
.core
.subsystems
.IRemoteFile
;
29 import org
.eclipse
.swt
.SWT
;
30 import org
.eclipse
.swt
.custom
.CCombo
;
31 import org
.eclipse
.swt
.events
.ModifyEvent
;
32 import org
.eclipse
.swt
.events
.ModifyListener
;
33 import org
.eclipse
.swt
.events
.SelectionAdapter
;
34 import org
.eclipse
.swt
.events
.SelectionEvent
;
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 TitleAreaDialog
implements ICreateSessionDialog
{
54 // ------------------------------------------------------------------------
56 // ------------------------------------------------------------------------
58 * The icon file for this dialog box.
60 public static final String CREATE_SESSION_ICON_FILE
= "icons/elcl16/add_button.gif"; //$NON-NLS-1$
63 * Supported network protocols for streaming
65 private enum StreamingProtocol
{
66 /** Default network protocol for IPv4 (TCP)*/
68 /** Default network protocol for IPv6 (TCP)*/
74 private enum StreamingProtocol2
{
75 /** Default network protocol for IPv4 (TCP)*/
77 /** Default network protocol for IPv6 (TCP)*/
79 /** TCP network protocol for IPv4*/
81 /** TCP network protocol for IPv6*/
85 * Index of last supported streaming protocol for common URL configuration.
87 private static final int COMMON_URL_LAST_INDEX
= 1;
89 * Index of default streaming protocol.
91 private static final int DEFAULT_URL_INDEX
= 0;
93 // ------------------------------------------------------------------------
95 // ------------------------------------------------------------------------
97 * The dialog composite.
99 private Composite fDialogComposite
= null;
101 * The text widget for the session name
103 private Text fSessionNameText
= null;
105 * The label widget for the session path.
107 private Label fSessionPathLabel
= null;
109 * The text widget for the session path.
111 private Text fSessionPathText
= null;
113 * The button widget to select a snapshot session
115 private Button fSnapshotButton
= null;
117 * The Group for stream configuration.
119 private Group fMainStreamingGroup
= null;
121 * The button to show streaming options.
123 private Button fConfigureStreamingButton
= null;
125 * The composite with streaming configuration parameter.
127 private Composite fStreamingComposite
= null;
129 * The text widget for the trace path.
131 private Text fTracePathText
= null;
133 * The button to link data protocol/Address with control protocol.
135 private Button fLinkDataWithControlButton
= null;
137 * The Combo box for channel protocol selection.
139 private CCombo fControlProtocolCombo
= null;
141 * A selection listener that copies the protocol from control to data when being linked.
143 private ControlProtocolSelectionListener fCopyProtocolSelectionListener
;
145 * A selection listener updates the control port text depending on the control protocol selected.
147 private ProtocolComboSelectionListener fControlProtocolSelectionListener
;
149 * A selection listener updates the data port text depending on the data protocol selected.
151 private ProtocolComboSelectionListener fDataProtocolSelectionListener
;
153 * The text box for the host/IP address of the control channel.
155 private Text fControlHostAddressText
= null;
157 * A key listener that copies the host address from control to data when being linked.
159 private CopyModifyListener fControlUrlKeyListener
;
161 * A modify listener that updates the enablement of the dialog.
163 private UpdateEnablementModifyListener fUpdateEnablementModifyListener
;
165 * The text box for the control port.
167 private Text fControlPortText
= null;
169 * The Combo box for data protocol selection.
171 private CCombo fDataProtocolCombo
= null;
173 * The text box for the host/IP address of the data channel.
175 private Text fDataHostAddressText
= null;
177 * The text box for the data port.
179 private Text fDataPortText
= null;
181 * The parent where the new node should be added.
183 private TraceSessionGroup fParent
= null;
185 * The session name string.
187 private String fSessionName
= null;
189 * The session path string.
191 private String fSessionPath
= null;
193 * Flag whether the session is snapshot or not
195 private boolean fIsSnapshot
= false;
197 * Flag whether default location (path) shall be used or not
199 private boolean fIsDefaultPath
= true;
201 * Flag whether the trace is streamed or not
203 private boolean fIsStreamedTrace
= false;
205 * The network URL in case control and data is configured together.
206 * If set, fControlUrl and fDataUrl will be null.
208 private String fNetworkUrl
= null;
210 * The control URL in case control and data is configured separately.
211 * If set, fDataUrl will be set too and fNetworkUrl will be null.
213 private String fControlUrl
= null;
215 * The data URL in case control and data is configured separately.
216 * If set, fControlUrl will be set too and fNetworkUrl will be null.
218 private String fDataUrl
= null;
220 * The trace path string.
222 private String fTracePath
= null;
224 // ------------------------------------------------------------------------
226 // ------------------------------------------------------------------------
229 * @param shell - a shell for the display of the dialog
231 public CreateSessionDialog(Shell shell
) {
233 setShellStyle(SWT
.RESIZE
| getShellStyle());
236 // ------------------------------------------------------------------------
238 // ------------------------------------------------------------------------
241 public void initialize(TraceSessionGroup group
) {
243 fStreamingComposite
= null;
247 fIsDefaultPath
= true;
248 fIsStreamedTrace
= false;
253 // ------------------------------------------------------------------------
255 // ------------------------------------------------------------------------
258 protected void configureShell(Shell newShell
) {
259 super.configureShell(newShell
);
260 newShell
.setText(Messages
.TraceControl_CreateSessionDialogTitle
);
261 newShell
.setImage(Activator
.getDefault().loadIcon(CREATE_SESSION_ICON_FILE
));
265 protected Control
createDialogArea(Composite parent
) {
266 Composite dialogAreaa
= (Composite
) super.createDialogArea(parent
);
267 setTitle(Messages
.TraceControl_CreateSessionDialogTitle
);
268 setMessage(Messages
.TraceControl_CreateSessionDialogMessage
);
271 fDialogComposite
= new Composite(dialogAreaa
, SWT
.NONE
);
272 GridLayout layout
= new GridLayout(1, true);
273 fDialogComposite
.setLayout(layout
);
274 fDialogComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
276 Group sessionGroup
= new Group(fDialogComposite
, SWT
.SHADOW_NONE
);
277 sessionGroup
.setLayoutData(new GridData(GridData
.FILL_HORIZONTAL
));
278 sessionGroup
.setLayout(new GridLayout(4, true));
280 fUpdateEnablementModifyListener
= new UpdateEnablementModifyListener();
282 Label sessionNameLabel
= new Label(sessionGroup
, SWT
.RIGHT
);
283 sessionNameLabel
.setText(Messages
.TraceControl_CreateSessionNameLabel
);
284 fSessionNameText
= new Text(sessionGroup
, SWT
.NONE
);
285 fSessionNameText
.setToolTipText(Messages
.TraceControl_CreateSessionNameTooltip
);
286 fSessionNameText
.addModifyListener(fUpdateEnablementModifyListener
);
288 fSessionPathLabel
= new Label(sessionGroup
, SWT
.RIGHT
);
289 fSessionPathLabel
.setText(Messages
.TraceControl_CreateSessionPathLabel
);
290 fSessionPathText
= new Text(sessionGroup
, SWT
.NONE
);
291 fSessionPathText
.setToolTipText(Messages
.TraceControl_CreateSessionPathTooltip
);
292 fSessionPathText
.addModifyListener(fUpdateEnablementModifyListener
);
294 if (fParent
.isSnapshotSupported()) {
295 fSnapshotButton
= new Button(sessionGroup
, SWT
.CHECK
);
296 fSnapshotButton
.setText(Messages
.TraceControl_CreateSessionSnapshotLabel
);
297 fSnapshotButton
.setToolTipText(Messages
.TraceControl_CreateSessionSnapshotTooltip
);
298 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
299 data
.horizontalSpan
= 4;
300 fSnapshotButton
.setLayoutData(data
);
301 fSnapshotButton
.addSelectionListener(new SelectionAdapter() {
303 public void widgetSelected(SelectionEvent e
) {
310 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
311 data
.horizontalSpan
= 3;
313 fSessionNameText
.setLayoutData(data
);
315 data
= new GridData(GridData
.FILL_HORIZONTAL
);
316 data
.horizontalSpan
= 3;
317 fSessionPathText
.setLayoutData(data
);
319 if (fParent
.isNetworkStreamingSupported()) {
320 createAdvancedOptionsComposite();
323 return fDialogComposite
;
326 private void createAdvancedOptionsComposite() {
328 fMainStreamingGroup
= new Group(fDialogComposite
, SWT
.SHADOW_NONE
);
329 fMainStreamingGroup
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
330 fMainStreamingGroup
.setLayout(new GridLayout(1, true));
332 fConfigureStreamingButton
= new Button(fMainStreamingGroup
, SWT
.PUSH
);
333 fConfigureStreamingButton
.setText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonText
+ " >>>"); //$NON-NLS-1$
334 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonTooltip
);
335 fConfigureStreamingButton
.addSelectionListener(new SelectionAdapter() {
337 public void widgetSelected(SelectionEvent e
) {
338 if (fIsStreamedTrace
) {
339 fIsStreamedTrace
= false;
340 fConfigureStreamingButton
.setText(">>> " + Messages
.TraceControl_CreateSessionConfigureStreamingButtonText
); //$NON-NLS-1$
341 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonTooltip
);
342 fSessionPathText
.setEnabled(true);
343 fSessionPathLabel
.setText(Messages
.TraceControl_CreateSessionPathLabel
);
344 disposeConfigureStreamingComposite();
346 fIsStreamedTrace
= true;
347 fConfigureStreamingButton
.setText("<<< " + Messages
.TraceControl_CreateSessionNoStreamingButtonText
); //$NON-NLS-1$
348 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionNoStreamingButtonTooltip
);
349 fSessionPathText
.setEnabled(false);
350 fSessionPathText
.setText(""); //$NON-NLS-1$
351 fSessionPathLabel
.setText(""); //$NON-NLS-1$
352 createConfigureStreamingComposite();
361 private void createConfigureStreamingComposite() {
362 if (fStreamingComposite
== null) {
363 fStreamingComposite
= new Composite(fMainStreamingGroup
, SWT
.NONE
);
364 GridLayout layout
= new GridLayout(1, true);
365 fStreamingComposite
.setLayout(layout
);
366 fStreamingComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
368 Group urlGroup
= new Group(fStreamingComposite
, SWT
.SHADOW_NONE
);
369 layout
= new GridLayout(7, true);
370 urlGroup
.setLayout(layout
);
371 urlGroup
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
373 Label tracePathLabel
= new Label(urlGroup
, SWT
.RIGHT
);
374 tracePathLabel
.setText(Messages
.TraceControl_CreateSessionTracePathText
);
375 fTracePathText
= new Text(urlGroup
, SWT
.NONE
);
376 fTracePathText
.setToolTipText(Messages
.TraceControl_CreateSessionTracePathTooltip
);
379 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
380 data
.horizontalSpan
= 6;
381 fTracePathText
.setLayoutData(data
);
382 fTracePathText
.addModifyListener(fUpdateEnablementModifyListener
);
384 fLinkDataWithControlButton
= new Button(urlGroup
, SWT
.CHECK
);
385 fLinkDataWithControlButton
.setText(Messages
.TraceControl_CreateSessionLinkButtonText
);
386 fLinkDataWithControlButton
.setToolTipText(Messages
.TraceControl_CreateSessionLinkButtonTooltip
);
387 data
= new GridData(GridData
.FILL_HORIZONTAL
);
388 data
.horizontalSpan
= 7;
389 fLinkDataWithControlButton
.setLayoutData(data
);
390 fLinkDataWithControlButton
.setSelection(true);
392 Label label
= new Label(urlGroup
, SWT
.NONE
);
393 data
= new GridData(GridData
.FILL_HORIZONTAL
);
394 data
.horizontalSpan
= 1;
395 label
.setLayoutData(data
);
397 label
= new Label(urlGroup
, SWT
.NONE
);
398 label
.setText(Messages
.TraceControl_CreateSessionProtocolLabelText
);
399 data
= new GridData(GridData
.FILL_HORIZONTAL
);
400 data
.horizontalSpan
= 1;
401 label
.setLayoutData(data
);
403 label
= new Label(urlGroup
, SWT
.NONE
);
404 label
.setText(Messages
.TraceControl_CreateSessionAddressLabelText
);
405 data
= new GridData(GridData
.FILL_HORIZONTAL
);
406 data
.horizontalSpan
= 4;
407 label
.setLayoutData(data
);
409 label
= new Label(urlGroup
, SWT
.NONE
);
410 label
.setText(Messages
.TraceControl_CreateSessionPortLabelText
);
411 data
= new GridData(GridData
.FILL_HORIZONTAL
);
412 data
.horizontalSpan
= 1;
413 label
.setLayoutData(data
);
415 label
= new Label(urlGroup
, SWT
.RIGHT
);
416 label
.setText(Messages
.TraceControl_CreateSessionControlUrlLabel
);
417 data
= new GridData(GridData
.FILL_HORIZONTAL
);
418 data
.horizontalSpan
= 1;
419 label
.setLayoutData(data
);
421 fControlProtocolCombo
= new CCombo(urlGroup
, SWT
.READ_ONLY
);
422 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionCommonProtocolTooltip
);
423 data
= new GridData(GridData
.FILL_HORIZONTAL
);
424 data
.horizontalSpan
= 1;
425 fControlProtocolCombo
.setLayoutData(data
);
426 fControlProtocolCombo
.addModifyListener(fUpdateEnablementModifyListener
);
428 fControlHostAddressText
= new Text(urlGroup
, SWT
.NONE
);
429 fControlHostAddressText
.setToolTipText(Messages
.TraceControl_CreateSessionControlAddressTooltip
);
430 data
= new GridData(GridData
.FILL_HORIZONTAL
);
431 data
.horizontalSpan
= 4;
432 fControlHostAddressText
.setLayoutData(data
);
433 fControlHostAddressText
.addModifyListener(fUpdateEnablementModifyListener
);
435 fControlPortText
= new Text(urlGroup
, SWT
.NONE
);
436 fControlPortText
.setToolTipText(Messages
.TraceControl_CreateSessionControlPortTooltip
);
437 data
= new GridData(GridData
.FILL_HORIZONTAL
);
438 data
.horizontalSpan
= 1;
439 fControlPortText
.setLayoutData(data
);
440 fControlPortText
.addModifyListener(fUpdateEnablementModifyListener
);
442 label
= new Label(urlGroup
, SWT
.RIGHT
);
443 label
.setText(Messages
.TraceControl_CreateSessionDataUrlLabel
);
444 data
= new GridData(GridData
.FILL_HORIZONTAL
);
445 data
.horizontalSpan
= 1;
446 label
.setLayoutData(data
);
448 fDataProtocolCombo
= new CCombo(urlGroup
, SWT
.READ_ONLY
);
449 fDataProtocolCombo
.setEnabled(false);
450 fDataProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
451 data
= new GridData(GridData
.FILL_HORIZONTAL
);
452 data
.horizontalSpan
= 1;
453 fDataProtocolCombo
.setLayoutData(data
);
454 fDataProtocolCombo
.addModifyListener(fUpdateEnablementModifyListener
);
456 String items
[] = new String
[StreamingProtocol
.values().length
];
457 for (int i
= 0; i
< items
.length
; i
++) {
458 items
[i
] = StreamingProtocol
.values()[i
].name();
460 fControlProtocolCombo
.setItems(items
);
461 fDataProtocolCombo
.setItems(items
);
463 fDataHostAddressText
= new Text(urlGroup
, SWT
.NONE
);
464 fDataHostAddressText
.setEnabled(false);
465 fDataHostAddressText
.setToolTipText(Messages
.TraceControl_CreateSessionDataAddressTooltip
);
466 data
= new GridData(GridData
.FILL_HORIZONTAL
);
467 data
.horizontalSpan
= 4;
468 fDataHostAddressText
.setLayoutData(data
);
469 fDataHostAddressText
.addModifyListener(fUpdateEnablementModifyListener
);
471 fDataPortText
= new Text(urlGroup
, SWT
.NONE
);
472 fDataPortText
.setEnabled(true);
473 fDataPortText
.setToolTipText(Messages
.TraceControl_CreateSessionDataPortTooltip
);
474 data
= new GridData(GridData
.FILL_HORIZONTAL
);
475 data
.horizontalSpan
= 1;
476 fDataPortText
.setLayoutData(data
);
477 fDataPortText
.addModifyListener(fUpdateEnablementModifyListener
);
479 fCopyProtocolSelectionListener
= new ControlProtocolSelectionListener();
480 fControlProtocolSelectionListener
= new ProtocolComboSelectionListener(fControlProtocolCombo
, fControlPortText
);
481 fDataProtocolSelectionListener
= new ProtocolComboSelectionListener(fDataProtocolCombo
, fDataPortText
);
483 fControlProtocolCombo
.addSelectionListener(fCopyProtocolSelectionListener
);
485 fControlUrlKeyListener
= new CopyModifyListener(fControlHostAddressText
, fDataHostAddressText
);
486 fControlHostAddressText
.addModifyListener(fControlUrlKeyListener
);
488 fControlProtocolCombo
.select(DEFAULT_URL_INDEX
);
489 fDataProtocolCombo
.select(DEFAULT_URL_INDEX
);
491 fLinkDataWithControlButton
.addSelectionListener(new SelectionAdapter() {
493 public void widgetSelected(SelectionEvent e
) {
494 if (fLinkDataWithControlButton
.getSelection()) {
495 // Set enablement control data channel inputs
496 fDataProtocolCombo
.setEnabled(false);
497 fDataHostAddressText
.setEnabled(false);
498 fControlPortText
.setEnabled(true);
499 fDataPortText
.setEnabled(true);
502 fControlProtocolCombo
.removeSelectionListener(fControlProtocolSelectionListener
);
503 fDataProtocolCombo
.removeSelectionListener(fDataProtocolSelectionListener
);
504 fControlProtocolCombo
.addSelectionListener(fCopyProtocolSelectionListener
);
505 fControlHostAddressText
.addModifyListener(fControlUrlKeyListener
);
507 // Get previous selection and validate
508 int currentSelection
= fControlProtocolCombo
.getSelectionIndex() <= COMMON_URL_LAST_INDEX ?
509 fControlProtocolCombo
.getSelectionIndex() : DEFAULT_URL_INDEX
;
511 // Update combo box items
512 fControlProtocolCombo
.removeAll();
513 String
[] controlItems
= new String
[StreamingProtocol
.values().length
];
514 for (int i
= 0; i
< controlItems
.length
; i
++) {
515 controlItems
[i
] = StreamingProtocol
.values()[i
].name();
517 fControlProtocolCombo
.setItems(controlItems
);
518 fDataProtocolCombo
.setItems(controlItems
);
521 fControlProtocolCombo
.select(currentSelection
);
522 fDataProtocolCombo
.select(currentSelection
);
523 fDataHostAddressText
.setText(fControlHostAddressText
.getText());
526 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionCommonProtocolTooltip
);
528 // Enable data channel inputs
529 fDataProtocolCombo
.setEnabled(true);
530 fDataHostAddressText
.setEnabled(true);
533 fControlProtocolCombo
.removeSelectionListener(fCopyProtocolSelectionListener
);
534 fControlProtocolCombo
.addSelectionListener(fControlProtocolSelectionListener
);
535 fDataProtocolCombo
.addSelectionListener(fDataProtocolSelectionListener
);
536 fControlHostAddressText
.removeModifyListener(fControlUrlKeyListener
);
538 // Update combo box items
539 int currentSelection
= fControlProtocolCombo
.getSelectionIndex();
540 fControlProtocolCombo
.removeAll();
541 String
[] controlItems
= new String
[StreamingProtocol2
.values().length
];
542 for (int i
= 0; i
< controlItems
.length
; i
++) {
543 controlItems
[i
] = StreamingProtocol2
.values()[i
].name();
545 fControlProtocolCombo
.setItems(controlItems
);
546 fDataProtocolCombo
.setItems(controlItems
);
549 fControlProtocolCombo
.select(currentSelection
);
550 fDataProtocolCombo
.select(currentSelection
);
553 fDataProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
554 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
556 // Update control/data port enablement and input
557 if (fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
558 fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
559 fControlPortText
.setText(""); //$NON-NLS-1$
560 fControlPortText
.setEnabled(false);
562 fControlPortText
.setEnabled(true);
565 if (fDataProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
566 fDataProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
567 fDataPortText
.setText(""); //$NON-NLS-1$
568 fDataPortText
.setEnabled(false);
570 fDataPortText
.setEnabled(true);
578 private void disposeConfigureStreamingComposite() {
579 if (fStreamingComposite
!= null) {
580 fStreamingComposite
.dispose();
581 fStreamingComposite
= null;
586 protected void createButtonsForButtonBar(Composite parent
) {
587 createButton(parent
, IDialogConstants
.CANCEL_ID
, "&Cancel", true); //$NON-NLS-1$
588 createButton(parent
, IDialogConstants
.OK_ID
, "&Ok", true); //$NON-NLS-1$
591 private void updateEnablement() {
593 getButton(IDialogConstants
.OK_ID
).setEnabled(getErrorMessage() == null);
596 private void validate() {
597 // Validate input data
598 fSessionName
= fSessionNameText
.getText();
599 fSessionPath
= fSessionPathText
.getText();
600 setErrorMessage(null);
602 if (!"".equals(fSessionPath
)) { //$NON-NLS-1$
603 // validate sessionPath
604 if (!fIsStreamedTrace
) {
605 TargetNodeComponent node
= (TargetNodeComponent
)fParent
.getParent();
606 IRemoteSystemProxy proxy
= node
.getRemoteSystemProxy();
607 IFileServiceSubSystem fsss
= proxy
.getFileServiceSubSystem();
610 IRemoteFile remoteFolder
= fsss
.getRemoteFileObject(fSessionPath
, new NullProgressMonitor());
612 if (remoteFolder
== null) {
613 setErrorMessage(Messages
.TraceControl_InvalidSessionPathError
+ " (" + fSessionPath
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
617 if (remoteFolder
.exists()) {
618 setErrorMessage(Messages
.TraceControl_SessionPathAlreadyExistsError
+ " (" + fSessionPath
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
621 } catch (SystemMessageException e
) {
622 setErrorMessage(Messages
.TraceControl_FileSubSystemError
+ "\n" + e
); //$NON-NLS-1$
627 fIsDefaultPath
= false;
630 if (fParent
.isSnapshotSupported()) {
631 fIsSnapshot
= fSnapshotButton
.getSelection();
638 if (fIsStreamedTrace
&& fStreamingComposite
!= null) {
639 // Validate input data
640 fTracePath
= fTracePathText
.getText();
642 if (fControlProtocolCombo
.getSelectionIndex() < 0) {
643 setErrorMessage("Control Protocol Text is empty\n"); //$NON-NLS-1$
647 if ("".equals(fControlHostAddressText
.getText())) { //$NON-NLS-1$
648 setErrorMessage("Control Address Text is empty\n"); //$NON-NLS-1$
652 if (!fLinkDataWithControlButton
.getSelection()) {
653 if (fDataProtocolCombo
.getSelectionIndex() < 0) {
654 setErrorMessage("Data Protocol Text is empty\n"); //$NON-NLS-1$
658 if ("".equals(fDataHostAddressText
.getText())) { //$NON-NLS-1$
659 setErrorMessage("Data Address Text is empty\n"); //$NON-NLS-1$
663 fControlUrl
= getUrlString(fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()),
664 fControlHostAddressText
.getText(),
665 fControlPortText
.getText(),
669 fDataUrl
= getUrlString(fDataProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()),
670 fDataHostAddressText
.getText(),
672 fDataPortText
.getText(),
675 fNetworkUrl
= getUrlString(fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()),
676 fControlHostAddressText
.getText(),
677 fControlPortText
.getText(),
678 fDataPortText
.getText(),
683 // Check for invalid names
684 if (!"".equals(fSessionName
) && !fSessionName
.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
685 setErrorMessage(Messages
.TraceControl_InvalidSessionNameError
+ " (" + fSessionName
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
689 // Check if node with name already exists in parent
690 if(fParent
.containsChild(fSessionName
)) {
691 setErrorMessage(Messages
.TraceControl_SessionAlreadyExistsError
+ " (" + fSessionName
+ ")"); //$NON-NLS-1$ //$NON-NLS-2$
696 private static String
getUrlString(String proto
, String host
, String ctrlPort
, String dataPort
, String sessionPath
) {
697 //proto://[HOST|IP][:PORT1[:PORT2]][/TRACE_PATH]
698 StringBuilder stringBuilder
= new StringBuilder();
699 stringBuilder
.append(proto
);
700 stringBuilder
.append("://"); //$NON-NLS-1$
701 stringBuilder
.append(host
);
703 if ((ctrlPort
!= null) && (!"".equals(ctrlPort
))) { //$NON-NLS-1$
704 stringBuilder
.append(":"); //$NON-NLS-1$
705 stringBuilder
.append(ctrlPort
);
708 if ((dataPort
!= null) && (!"".equals(dataPort
))) { //$NON-NLS-1$
709 stringBuilder
.append(":"); //$NON-NLS-1$
710 stringBuilder
.append(dataPort
);
713 if ((sessionPath
!= null) && (!"".equals(sessionPath
))) { //$NON-NLS-1$
714 stringBuilder
.append("/"); //$NON-NLS-1$
715 stringBuilder
.append(sessionPath
);
717 return stringBuilder
.toString();
720 private static class CopyModifyListener
implements ModifyListener
{
721 private Text fSource
;
722 private Text fDestination
;
724 public CopyModifyListener(Text source
, Text destination
) {
726 fDestination
= destination
;
730 public void modifyText(ModifyEvent e
) {
731 fDestination
.setText(fSource
.getText());
735 private class ControlProtocolSelectionListener
extends SelectionAdapter
{
738 public void widgetSelected(SelectionEvent e
) {
739 fDataProtocolCombo
.select(fControlProtocolCombo
.getSelectionIndex());
740 if (fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.file
.name())) {
741 fControlPortText
.setText(""); //$NON-NLS-1$
742 fDataPortText
.setText(""); //$NON-NLS-1$
743 fControlPortText
.setEnabled(false);
744 fDataPortText
.setEnabled(false);
746 fControlPortText
.setEnabled(true);
747 fDataPortText
.setEnabled(true);
752 private class ProtocolComboSelectionListener
extends SelectionAdapter
{
754 private CCombo fCombo
;
755 private Text fPortText
;
757 public ProtocolComboSelectionListener(CCombo combo
, Text portText
) {
759 fPortText
= portText
;
763 public void widgetSelected(SelectionEvent e
) {
764 if (fCombo
.getItem(fCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
765 fCombo
.getItem(fCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
766 fPortText
.setText(""); //$NON-NLS-1$
767 fPortText
.setEnabled(false);
769 fPortText
.setEnabled(true);
775 public ISessionInfo
getParameters() {
776 ISessionInfo sessionInfo
= new SessionInfo(fSessionName
);
778 if (fIsStreamedTrace
) {
779 sessionInfo
.setNetworkUrl(fNetworkUrl
);
780 sessionInfo
.setControlUrl(fControlUrl
);
781 sessionInfo
.setDataUrl(fDataUrl
);
782 sessionInfo
.setStreamedTrace(true);
783 } else if (!fIsDefaultPath
) {
784 sessionInfo
.setSessionPath(fSessionPath
);
787 sessionInfo
.setSnapshot(fIsSnapshot
);
792 private final class UpdateEnablementModifyListener
implements ModifyListener
{
794 public void modifyText(ModifyEvent e
) {