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
.core
.control
.model
.ISessionInfo
;
20 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.impl
.SessionInfo
;
21 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.Activator
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.messages
.Messages
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TargetNodeComponent
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceSessionGroup
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.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
.graphics
.Point
;
36 import org
.eclipse
.swt
.graphics
.Rectangle
;
37 import org
.eclipse
.swt
.layout
.GridData
;
38 import org
.eclipse
.swt
.layout
.GridLayout
;
39 import org
.eclipse
.swt
.widgets
.Button
;
40 import org
.eclipse
.swt
.widgets
.Composite
;
41 import org
.eclipse
.swt
.widgets
.Control
;
42 import org
.eclipse
.swt
.widgets
.Group
;
43 import org
.eclipse
.swt
.widgets
.Label
;
44 import org
.eclipse
.swt
.widgets
.Shell
;
45 import org
.eclipse
.swt
.widgets
.Text
;
49 * Dialog box for collecting session creation information.
52 * @author Bernd Hufmann
54 public class CreateSessionDialog
extends Dialog
implements ICreateSessionDialog
{
56 // ------------------------------------------------------------------------
58 // ------------------------------------------------------------------------
60 * The icon file for this dialog box.
62 public static final String CREATE_SESSION_ICON_FILE
= "icons/elcl16/add_button.gif"; //$NON-NLS-1$
65 * Supported network protocols for streaming
67 private enum StreamingProtocol
{
68 /** Default network protocol for IPv4 (TCP)*/
70 /** Default network protocol for IPv6 (TCP)*/
76 private enum StreamingProtocol2
{
77 /** Default network protocol for IPv4 (TCP)*/
79 /** Default network protocol for IPv6 (TCP)*/
81 /** TCP network protocol for IPv4*/
83 /** TCP network protocol for IPv6*/
87 * Index of last supported streaming protocol for common URL configuration.
89 private static final int COMMON_URL_LAST_INDEX
= 1;
91 * Index of default streaming protocol.
93 private static final int DEFAULT_URL_INDEX
= 0;
95 // ------------------------------------------------------------------------
97 // ------------------------------------------------------------------------
99 private Control fControl
= null;
101 * The dialog composite.
103 private Composite fDialogComposite
= null;
105 * The text widget for the session name
107 private Text fSessionNameText
= null;
109 * The label widget for the session path.
111 private Label fSessionPathLabel
= null;
113 * The text widget for the session path.
115 private Text fSessionPathText
= null;
117 * The button widget to select a snapshot session
119 private Button fSnapshotButton
= null;
121 * The Group for stream configuration.
123 private Group fMainStreamingGroup
= null;
125 * The button to show streaming options.
127 private Button fConfigureStreamingButton
= null;
129 * The composite with streaming configuration parameter.
131 private Composite fStreamingComposite
= null;
133 * The text widget for the trace path.
135 private Text fTracePathText
= null;
137 * The button to link data protocol/Address with control protocol.
139 private Button fLinkDataWithControlButton
= null;
141 * The Combo box for channel protocol selection.
143 private CCombo fControlProtocolCombo
= null;
145 * A selection listener that copies the protocol from control to data when being linked.
147 private ControlProtocolSelectionListener fCopyProtocolSelectionListener
;
149 * A selection listener updates the control port text depending on the control protocol selected.
151 private ProtocolComboSelectionListener fControlProtocolSelectionListener
;
153 * A selection listener updates the data port text depending on the data protocol selected.
155 private ProtocolComboSelectionListener fDataProtocolSelectionListener
;
157 * The text box for the host/IP address of the control channel.
159 private Text fControlHostAddressText
= null;
161 * A key listener that copies the host address from control to data when being linked.
163 private CopyModifyListener fControlUrlKeyListener
;
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 * The session path string.
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 Control
createContents(Composite parent
) {
259 fControl
= super.createContents(parent
);
261 /* set the shell minimum size */
262 Point clientArea
= fControl
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
);
263 Rectangle trim
= getShell().computeTrim(0, 0, clientArea
.x
, clientArea
.y
);
264 getShell().setMinimumSize(trim
.width
, trim
.height
);
270 protected void configureShell(Shell newShell
) {
271 super.configureShell(newShell
);
272 newShell
.setText(Messages
.TraceControl_CreateSessionDialogTitle
);
273 newShell
.setImage(Activator
.getDefault().loadIcon(CREATE_SESSION_ICON_FILE
));
277 protected Control
createDialogArea(Composite parent
) {
280 fDialogComposite
= new Composite(parent
, SWT
.NONE
);
281 GridLayout layout
= new GridLayout(1, true);
282 fDialogComposite
.setLayout(layout
);
283 fDialogComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
285 Group sessionGroup
= new Group(fDialogComposite
, SWT
.SHADOW_NONE
);
286 sessionGroup
.setLayoutData(new GridData(GridData
.FILL_HORIZONTAL
));
287 sessionGroup
.setLayout(new GridLayout(4, true));
289 Label sessionNameLabel
= new Label(sessionGroup
, SWT
.RIGHT
);
290 sessionNameLabel
.setText(Messages
.TraceControl_CreateSessionNameLabel
);
291 fSessionNameText
= new Text(sessionGroup
, SWT
.NONE
);
292 fSessionNameText
.setToolTipText(Messages
.TraceControl_CreateSessionNameTooltip
);
294 fSessionPathLabel
= new Label(sessionGroup
, SWT
.RIGHT
);
295 fSessionPathLabel
.setText(Messages
.TraceControl_CreateSessionPathLabel
);
296 fSessionPathText
= new Text(sessionGroup
, SWT
.NONE
);
297 fSessionPathText
.setToolTipText(Messages
.TraceControl_CreateSessionPathTooltip
);
299 if (fParent
.isSnapshotSupported()) {
300 fSnapshotButton
= new Button(sessionGroup
, SWT
.CHECK
);
301 fSnapshotButton
.setText(Messages
.TraceControl_CreateSessionSnapshotLabel
);
302 fSnapshotButton
.setToolTipText(Messages
.TraceControl_CreateSessionSnapshotTooltip
);
303 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
304 data
.horizontalSpan
= 4;
305 fSnapshotButton
.setData(data
);
309 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
310 data
.horizontalSpan
= 3;
312 fSessionNameText
.setLayoutData(data
);
314 data
= new GridData(GridData
.FILL_HORIZONTAL
);
315 data
.horizontalSpan
= 3;
316 fSessionPathText
.setLayoutData(data
);
318 if (fParent
.isNetworkStreamingSupported()) {
319 createAdvancedOptionsComposite();
322 return fDialogComposite
;
325 private void createAdvancedOptionsComposite() {
327 fMainStreamingGroup
= new Group(fDialogComposite
, SWT
.SHADOW_NONE
);
328 fMainStreamingGroup
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
329 fMainStreamingGroup
.setLayout(new GridLayout(1, true));
331 fConfigureStreamingButton
= new Button(fMainStreamingGroup
, SWT
.PUSH
);
332 fConfigureStreamingButton
.setText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonText
+ " >>>"); //$NON-NLS-1$
333 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonTooltip
);
334 fConfigureStreamingButton
.addSelectionListener(new SelectionAdapter() {
336 public void widgetSelected(SelectionEvent e
) {
337 if (fIsStreamedTrace
) {
338 fIsStreamedTrace
= false;
339 fConfigureStreamingButton
.setText(">>> " + Messages
.TraceControl_CreateSessionConfigureStreamingButtonText
); //$NON-NLS-1$
340 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionConfigureStreamingButtonTooltip
);
341 fSessionPathText
.setEnabled(true);
342 fSessionPathLabel
.setText(Messages
.TraceControl_CreateSessionPathLabel
);
343 disposeConfigureStreamingComposite();
345 fIsStreamedTrace
= true;
346 fConfigureStreamingButton
.setText("<<< " + Messages
.TraceControl_CreateSessionNoStreamingButtonText
); //$NON-NLS-1$
347 fConfigureStreamingButton
.setToolTipText(Messages
.TraceControl_CreateSessionNoStreamingButtonTooltip
);
348 fSessionPathText
.setEnabled(false);
349 fSessionPathText
.setText(""); //$NON-NLS-1$
350 fSessionPathLabel
.setText(""); //$NON-NLS-1$
351 createConfigureStreamingComposite();
354 fDialogComposite
.layout();
356 Point clientArea
= fControl
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
);
357 Rectangle trim
= getShell().computeTrim(0, 0, clientArea
.x
, clientArea
.y
);
358 getShell().setSize(trim
.width
, trim
.height
);
363 private void createConfigureStreamingComposite() {
364 if (fStreamingComposite
== null) {
365 fStreamingComposite
= new Composite(fMainStreamingGroup
, SWT
.NONE
);
366 GridLayout layout
= new GridLayout(1, true);
367 fStreamingComposite
.setLayout(layout
);
368 fStreamingComposite
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
370 Group urlGroup
= new Group(fStreamingComposite
, SWT
.SHADOW_NONE
);
371 layout
= new GridLayout(7, true);
372 urlGroup
.setLayout(layout
);
373 urlGroup
.setLayoutData(new GridData(GridData
.FILL_BOTH
));
375 Label tracePathLabel
= new Label(urlGroup
, SWT
.RIGHT
);
376 tracePathLabel
.setText(Messages
.TraceControl_CreateSessionTracePathText
);
377 fTracePathText
= new Text(urlGroup
, SWT
.NONE
);
378 fTracePathText
.setToolTipText(Messages
.TraceControl_CreateSessionTracePathTooltip
);
381 GridData data
= new GridData(GridData
.FILL_HORIZONTAL
);
382 data
.horizontalSpan
= 6;
383 fTracePathText
.setLayoutData(data
);
385 fLinkDataWithControlButton
= new Button(urlGroup
, SWT
.CHECK
);
386 fLinkDataWithControlButton
.setText(Messages
.TraceControl_CreateSessionLinkButtonText
);
387 fLinkDataWithControlButton
.setToolTipText(Messages
.TraceControl_CreateSessionLinkButtonTooltip
);
388 data
= new GridData(GridData
.FILL_HORIZONTAL
);
389 data
.horizontalSpan
= 7;
390 fLinkDataWithControlButton
.setLayoutData(data
);
391 fLinkDataWithControlButton
.setSelection(true);
393 Label label
= new Label(urlGroup
, SWT
.NONE
);
394 data
= new GridData(GridData
.FILL_HORIZONTAL
);
395 data
.horizontalSpan
= 1;
396 label
.setLayoutData(data
);
398 label
= new Label(urlGroup
, SWT
.NONE
);
399 label
.setText(Messages
.TraceControl_CreateSessionProtocolLabelText
);
400 data
= new GridData(GridData
.FILL_HORIZONTAL
);
401 data
.horizontalSpan
= 1;
402 label
.setLayoutData(data
);
404 label
= new Label(urlGroup
, SWT
.NONE
);
405 label
.setText(Messages
.TraceControl_CreateSessionAddressLabelText
);
406 data
= new GridData(GridData
.FILL_HORIZONTAL
);
407 data
.horizontalSpan
= 4;
408 label
.setLayoutData(data
);
410 label
= new Label(urlGroup
, SWT
.NONE
);
411 label
.setText(Messages
.TraceControl_CreateSessionPortLabelText
);
412 data
= new GridData(GridData
.FILL_HORIZONTAL
);
413 data
.horizontalSpan
= 1;
414 label
.setLayoutData(data
);
416 label
= new Label(urlGroup
, SWT
.RIGHT
);
417 label
.setText(Messages
.TraceControl_CreateSessionControlUrlLabel
);
418 data
= new GridData(GridData
.FILL_HORIZONTAL
);
419 data
.horizontalSpan
= 1;
420 label
.setLayoutData(data
);
422 fControlProtocolCombo
= new CCombo(urlGroup
, SWT
.READ_ONLY
);
423 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionCommonProtocolTooltip
);
424 data
= new GridData(GridData
.FILL_HORIZONTAL
);
425 data
.horizontalSpan
= 1;
426 fControlProtocolCombo
.setLayoutData(data
);
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
);
434 fControlPortText
= new Text(urlGroup
, SWT
.NONE
);
435 fControlPortText
.setToolTipText(Messages
.TraceControl_CreateSessionControlPortTooltip
);
436 data
= new GridData(GridData
.FILL_HORIZONTAL
);
437 data
.horizontalSpan
= 1;
438 fControlPortText
.setLayoutData(data
);
440 label
= new Label(urlGroup
, SWT
.RIGHT
);
441 label
.setText(Messages
.TraceControl_CreateSessionDataUrlLabel
);
442 data
= new GridData(GridData
.FILL_HORIZONTAL
);
443 data
.horizontalSpan
= 1;
444 label
.setLayoutData(data
);
446 fDataProtocolCombo
= new CCombo(urlGroup
, SWT
.READ_ONLY
);
447 fDataProtocolCombo
.setEnabled(false);
448 fDataProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
449 data
= new GridData(GridData
.FILL_HORIZONTAL
);
450 data
.horizontalSpan
= 1;
451 fDataProtocolCombo
.setLayoutData(data
);
453 String items
[] = new String
[StreamingProtocol
.values().length
];
454 for (int i
= 0; i
< items
.length
; i
++) {
455 items
[i
] = StreamingProtocol
.values()[i
].name();
457 fControlProtocolCombo
.setItems(items
);
458 fDataProtocolCombo
.setItems(items
);
460 fDataHostAddressText
= new Text(urlGroup
, SWT
.NONE
);
461 fDataHostAddressText
.setEnabled(false);
462 fDataHostAddressText
.setToolTipText(Messages
.TraceControl_CreateSessionDataAddressTooltip
);
463 data
= new GridData(GridData
.FILL_HORIZONTAL
);
464 data
.horizontalSpan
= 4;
465 fDataHostAddressText
.setLayoutData(data
);
467 fDataPortText
= new Text(urlGroup
, SWT
.NONE
);
468 fDataPortText
.setEnabled(true);
469 fDataPortText
.setToolTipText(Messages
.TraceControl_CreateSessionDataPortTooltip
);
470 data
= new GridData(GridData
.FILL_HORIZONTAL
);
471 data
.horizontalSpan
= 1;
472 fDataPortText
.setLayoutData(data
);
474 fCopyProtocolSelectionListener
= new ControlProtocolSelectionListener();
475 fControlProtocolSelectionListener
= new ProtocolComboSelectionListener(fControlProtocolCombo
, fControlPortText
);
476 fDataProtocolSelectionListener
= new ProtocolComboSelectionListener(fDataProtocolCombo
, fDataPortText
);
478 fControlProtocolCombo
.addSelectionListener(fCopyProtocolSelectionListener
);
480 fControlUrlKeyListener
= new CopyModifyListener(fControlHostAddressText
, fDataHostAddressText
);
481 fControlHostAddressText
.addModifyListener(fControlUrlKeyListener
);
483 fControlProtocolCombo
.select(DEFAULT_URL_INDEX
);
484 fDataProtocolCombo
.select(DEFAULT_URL_INDEX
);
486 fLinkDataWithControlButton
.addSelectionListener(new SelectionAdapter() {
488 public void widgetSelected(SelectionEvent e
) {
489 if (fLinkDataWithControlButton
.getSelection()) {
490 // Set enablement control data channel inputs
491 fDataProtocolCombo
.setEnabled(false);
492 fDataHostAddressText
.setEnabled(false);
493 fControlPortText
.setEnabled(true);
494 fDataPortText
.setEnabled(true);
497 fControlProtocolCombo
.removeSelectionListener(fControlProtocolSelectionListener
);
498 fDataProtocolCombo
.removeSelectionListener(fDataProtocolSelectionListener
);
499 fControlProtocolCombo
.addSelectionListener(fCopyProtocolSelectionListener
);
500 fControlHostAddressText
.addModifyListener(fControlUrlKeyListener
);
502 // Get previous selection and validate
503 int currentSelection
= fControlProtocolCombo
.getSelectionIndex() <= COMMON_URL_LAST_INDEX ?
504 fControlProtocolCombo
.getSelectionIndex() : DEFAULT_URL_INDEX
;
506 // Update combo box items
507 fControlProtocolCombo
.removeAll();
508 String
[] controlItems
= new String
[StreamingProtocol
.values().length
];
509 for (int i
= 0; i
< controlItems
.length
; i
++) {
510 controlItems
[i
] = StreamingProtocol
.values()[i
].name();
512 fControlProtocolCombo
.setItems(controlItems
);
513 fDataProtocolCombo
.setItems(controlItems
);
516 fControlProtocolCombo
.select(currentSelection
);
517 fDataProtocolCombo
.select(currentSelection
);
518 fDataHostAddressText
.setText(fControlHostAddressText
.getText());
521 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionCommonProtocolTooltip
);
523 // Enable data channel inputs
524 fDataProtocolCombo
.setEnabled(true);
525 fDataHostAddressText
.setEnabled(true);
528 fControlProtocolCombo
.removeSelectionListener(fCopyProtocolSelectionListener
);
529 fControlProtocolCombo
.addSelectionListener(fControlProtocolSelectionListener
);
530 fDataProtocolCombo
.addSelectionListener(fDataProtocolSelectionListener
);
531 fControlHostAddressText
.removeModifyListener(fControlUrlKeyListener
);
533 // Update combo box items
534 int currentSelection
= fControlProtocolCombo
.getSelectionIndex();
535 fControlProtocolCombo
.removeAll();
536 String
[] controlItems
= new String
[StreamingProtocol2
.values().length
];
537 for (int i
= 0; i
< controlItems
.length
; i
++) {
538 controlItems
[i
] = StreamingProtocol2
.values()[i
].name();
540 fControlProtocolCombo
.setItems(controlItems
);
541 fDataProtocolCombo
.setItems(controlItems
);
544 fControlProtocolCombo
.select(currentSelection
);
545 fDataProtocolCombo
.select(currentSelection
);
548 fDataProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
549 fControlProtocolCombo
.setToolTipText(Messages
.TraceControl_CreateSessionProtocolTooltip
);
551 // Update control/data port enablement and input
552 if (fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
553 fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
554 fControlPortText
.setText(""); //$NON-NLS-1$
555 fControlPortText
.setEnabled(false);
557 fControlPortText
.setEnabled(true);
560 if (fDataProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
561 fDataProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
562 fDataPortText
.setText(""); //$NON-NLS-1$
563 fDataPortText
.setEnabled(false);
565 fDataPortText
.setEnabled(true);
573 private void disposeConfigureStreamingComposite() {
574 if (fStreamingComposite
!= null) {
575 fStreamingComposite
.dispose();
576 fStreamingComposite
= null;
581 protected void createButtonsForButtonBar(Composite parent
) {
582 createButton(parent
, IDialogConstants
.CANCEL_ID
, "&Cancel", true); //$NON-NLS-1$
583 createButton(parent
, IDialogConstants
.OK_ID
, "&Ok", true); //$NON-NLS-1$
587 protected void okPressed() {
588 // Validate input data
589 fSessionName
= fSessionNameText
.getText();
590 fSessionPath
= fSessionPathText
.getText();
592 if (!"".equals(fSessionPath
)) { //$NON-NLS-1$
593 // validate sessionPath
594 if (!fIsStreamedTrace
) {
595 TargetNodeComponent node
= (TargetNodeComponent
)fParent
.getParent();
596 IRemoteSystemProxy proxy
= node
.getRemoteSystemProxy();
597 IFileServiceSubSystem fsss
= proxy
.getFileServiceSubSystem();
600 IRemoteFile remoteFolder
= fsss
.getRemoteFileObject(fSessionPath
, new NullProgressMonitor());
602 if (remoteFolder
== null) {
603 MessageDialog
.openError(getShell(),
604 Messages
.TraceControl_CreateSessionDialogTitle
,
605 Messages
.TraceControl_InvalidSessionPathError
+ " (" + fSessionPath
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
609 if (remoteFolder
.exists()) {
610 MessageDialog
.openError(getShell(),
611 Messages
.TraceControl_CreateSessionDialogTitle
,
612 Messages
.TraceControl_SessionPathAlreadyExistsError
+ " (" + fSessionPath
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
615 } catch (SystemMessageException e
) {
616 MessageDialog
.openError(getShell(),
617 Messages
.TraceControl_CreateSessionDialogTitle
,
618 Messages
.TraceControl_FileSubSystemError
+ "\n" + e
); //$NON-NLS-1$
623 fIsDefaultPath
= false;
626 if(fParent
.isSnapshotSupported()) {
627 fIsSnapshot
= fSnapshotButton
.getSelection();
634 if (fIsStreamedTrace
) {
635 // Validate input data
636 fTracePath
= fTracePathText
.getText();
638 if (fControlProtocolCombo
.getSelectionIndex() < 0) {
639 MessageDialog
.openError(getShell(),
640 Messages
.TraceControl_CreateSessionDialogTitle
,
641 "Control Protocol Text is empty\n"); //$NON-NLS-1$
645 if ("".equals(fControlHostAddressText
.getText())) { //$NON-NLS-1$
646 MessageDialog
.openError(getShell(),
647 Messages
.TraceControl_CreateSessionDialogTitle
,
648 "Control Address Text is empty\n"); //$NON-NLS-1$
652 if(!fLinkDataWithControlButton
.getSelection()) {
653 if (fDataProtocolCombo
.getSelectionIndex() < 0) {
654 MessageDialog
.openError(getShell(),
655 Messages
.TraceControl_CreateSessionDialogTitle
,
656 "Control Protocol Text is empty\n"); //$NON-NLS-1$
660 if ("".equals(fDataHostAddressText
.getText())) { //$NON-NLS-1$
661 MessageDialog
.openError(getShell(),
662 Messages
.TraceControl_CreateSessionDialogTitle
,
663 "Control Address Text is empty\n"); //$NON-NLS-1$
667 fControlUrl
= getUrlString(fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()),
668 fControlHostAddressText
.getText(),
669 fControlPortText
.getText(),
673 fDataUrl
= getUrlString(fControlProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()),
674 fDataHostAddressText
.getText(),
676 fDataPortText
.getText(),
679 fNetworkUrl
= getUrlString(fControlProtocolCombo
.getItem(fDataProtocolCombo
.getSelectionIndex()),
680 fControlHostAddressText
.getText(),
681 fControlPortText
.getText(),
682 fDataPortText
.getText(),
687 // Check for invalid names
688 if (!"".equals(fSessionName
) && !fSessionName
.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$
689 MessageDialog
.openError(getShell(),
690 Messages
.TraceControl_CreateSessionDialogTitle
,
691 Messages
.TraceControl_InvalidSessionNameError
+ " (" + fSessionName
+ ") \n"); //$NON-NLS-1$ //$NON-NLS-2$
695 // Check if node with name already exists in parent
696 if(fParent
.containsChild(fSessionName
)) {
697 MessageDialog
.openError(getShell(),
698 Messages
.TraceControl_CreateSessionDialogTitle
,
699 Messages
.TraceControl_SessionAlreadyExistsError
+ " (" + fSessionName
+ ")"); //$NON-NLS-1$ //$NON-NLS-2$
703 // validation successful -> call super.okPressed()
707 private static String
getUrlString(String proto
, String host
, String ctrlPort
, String dataPort
, String sessionPath
) {
708 //proto://[HOST|IP][:PORT1[:PORT2]][/TRACE_PATH]
709 StringBuilder stringBuilder
= new StringBuilder();
710 stringBuilder
.append(proto
);
711 stringBuilder
.append("://"); //$NON-NLS-1$
712 stringBuilder
.append(host
);
714 if ((ctrlPort
!= null) && (!"".equals(ctrlPort
))) { //$NON-NLS-1$
715 stringBuilder
.append(":"); //$NON-NLS-1$
716 stringBuilder
.append(ctrlPort
);
719 if ((dataPort
!= null) && (!"".equals(dataPort
))) { //$NON-NLS-1$
720 stringBuilder
.append(":"); //$NON-NLS-1$
721 stringBuilder
.append(dataPort
);
724 if ((sessionPath
!= null) && (!"".equals(sessionPath
))) { //$NON-NLS-1$
725 stringBuilder
.append("/"); //$NON-NLS-1$
726 stringBuilder
.append(sessionPath
);
728 return stringBuilder
.toString();
731 private static class CopyModifyListener
implements ModifyListener
{
732 private Text fSource
;
733 private Text fDestination
;
735 public CopyModifyListener(Text source
, Text destination
) {
737 fDestination
= destination
;
741 public void modifyText(ModifyEvent e
) {
742 fDestination
.setText(fSource
.getText());
746 private class ControlProtocolSelectionListener
extends SelectionAdapter
{
749 public void widgetSelected(SelectionEvent e
) {
750 fDataProtocolCombo
.select(fControlProtocolCombo
.getSelectionIndex());
751 if (fControlProtocolCombo
.getItem(fControlProtocolCombo
.getSelectionIndex()).equals(StreamingProtocol
.file
.name())) {
752 fControlPortText
.setText(""); //$NON-NLS-1$
753 fDataPortText
.setText(""); //$NON-NLS-1$
754 fControlPortText
.setEnabled(false);
755 fDataPortText
.setEnabled(false);
757 fControlPortText
.setEnabled(true);
758 fDataPortText
.setEnabled(true);
763 private class ProtocolComboSelectionListener
extends SelectionAdapter
{
765 private CCombo fCombo
;
766 private Text fPortText
;
768 public ProtocolComboSelectionListener(CCombo combo
, Text portText
) {
770 fPortText
= portText
;
774 public void widgetSelected(SelectionEvent e
) {
775 if (fCombo
.getItem(fCombo
.getSelectionIndex()).equals(StreamingProtocol
.net
.name()) ||
776 fCombo
.getItem(fCombo
.getSelectionIndex()).equals(StreamingProtocol
.net6
.name())) {
777 fPortText
.setText(""); //$NON-NLS-1$
778 fPortText
.setEnabled(false);
780 fPortText
.setEnabled(true);
786 public ISessionInfo
getParameters() {
787 ISessionInfo sessionInfo
= new SessionInfo(fSessionName
);
789 if (fIsStreamedTrace
) {
790 sessionInfo
.setNetworkUrl(fNetworkUrl
);
791 sessionInfo
.setControlUrl(fControlUrl
);
792 sessionInfo
.setDataUrl(fDataUrl
);
793 sessionInfo
.setStreamedTrace(true);
794 } else if (!fIsDefaultPath
) {
795 sessionInfo
.setSessionPath(fSessionPath
);
798 sessionInfo
.setSnapshot(fIsSnapshot
);