| 1 | /********************************************************************** |
| 2 | * Copyright (c) 2012, 2014 Ericsson |
| 3 | * |
| 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 |
| 8 | * |
| 9 | * Contributors: |
| 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 | **********************************************************************/ |
| 14 | |
| 15 | package org.eclipse.linuxtools.internal.lttng2.control.ui.views.dialogs; |
| 16 | |
| 17 | import org.eclipse.core.runtime.NullProgressMonitor; |
| 18 | import org.eclipse.jface.dialogs.IDialogConstants; |
| 19 | import org.eclipse.jface.dialogs.TitleAreaDialog; |
| 20 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.ISessionInfo; |
| 21 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.impl.SessionInfo; |
| 22 | import org.eclipse.linuxtools.internal.lttng2.control.ui.Activator; |
| 23 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.messages.Messages; |
| 24 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TargetNodeComponent; |
| 25 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl.TraceSessionGroup; |
| 26 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.remote.IRemoteSystemProxy; |
| 27 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.service.LTTngControlServiceConstants; |
| 28 | import org.eclipse.rse.services.clientserver.messages.SystemMessageException; |
| 29 | import org.eclipse.rse.subsystems.files.core.servicesubsystem.IFileServiceSubSystem; |
| 30 | import org.eclipse.rse.subsystems.files.core.subsystems.IRemoteFile; |
| 31 | import org.eclipse.swt.SWT; |
| 32 | import org.eclipse.swt.custom.CCombo; |
| 33 | import org.eclipse.swt.events.FocusEvent; |
| 34 | import org.eclipse.swt.events.FocusListener; |
| 35 | import org.eclipse.swt.events.ModifyEvent; |
| 36 | import org.eclipse.swt.events.ModifyListener; |
| 37 | import org.eclipse.swt.events.SelectionAdapter; |
| 38 | import org.eclipse.swt.events.SelectionEvent; |
| 39 | import org.eclipse.swt.events.VerifyEvent; |
| 40 | import org.eclipse.swt.events.VerifyListener; |
| 41 | import org.eclipse.swt.layout.GridData; |
| 42 | import org.eclipse.swt.layout.GridLayout; |
| 43 | import org.eclipse.swt.widgets.Button; |
| 44 | import org.eclipse.swt.widgets.Composite; |
| 45 | import org.eclipse.swt.widgets.Control; |
| 46 | import org.eclipse.swt.widgets.Group; |
| 47 | import org.eclipse.swt.widgets.Label; |
| 48 | import org.eclipse.swt.widgets.Shell; |
| 49 | import org.eclipse.swt.widgets.Text; |
| 50 | |
| 51 | /** |
| 52 | * <p> |
| 53 | * Dialog box for collecting session creation information. |
| 54 | * </p> |
| 55 | * |
| 56 | * @author Bernd Hufmann |
| 57 | */ |
| 58 | public class CreateSessionDialog extends TitleAreaDialog implements ICreateSessionDialog { |
| 59 | |
| 60 | // ------------------------------------------------------------------------ |
| 61 | // Constants |
| 62 | // ------------------------------------------------------------------------ |
| 63 | /** |
| 64 | * The icon file for this dialog box. |
| 65 | */ |
| 66 | public static final String CREATE_SESSION_ICON_FILE = "icons/elcl16/add_button.gif"; //$NON-NLS-1$ |
| 67 | |
| 68 | /** |
| 69 | * To indicate that the default value will be used for this field |
| 70 | */ |
| 71 | private static final String DEFAULT_TEXT = "<" + Messages.EnableChannelDialog_DefaultMessage + ">"; //$NON-NLS-1$ //$NON-NLS-2$ |
| 72 | |
| 73 | /** |
| 74 | * The default port for the connection to Relayd. This actual value is |
| 75 | * needed because this is not an optional argument to a command; this is |
| 76 | * what is used to connect directly to Relayd from Java through a socket. |
| 77 | * There is also currently no way to know the default value by issuing a |
| 78 | * command. |
| 79 | */ |
| 80 | private static final int DEFAULT_LIVE_PORT = 5344; |
| 81 | |
| 82 | /** |
| 83 | * The default address for the connection to Relayd. Only local is supported |
| 84 | * for now. See above comment for why it's needed. |
| 85 | */ |
| 86 | private static final String DEFAULT_LIVE_URL = "127.0.0.1"; //$NON-NLS-1$ |
| 87 | |
| 88 | /** |
| 89 | * Supported network protocols for streaming |
| 90 | */ |
| 91 | private enum StreamingProtocol { |
| 92 | /** Default network protocol for IPv4 (TCP)*/ |
| 93 | net, |
| 94 | /** Default network protocol for IPv6 (TCP)*/ |
| 95 | net6, |
| 96 | /** File */ |
| 97 | file, |
| 98 | } |
| 99 | |
| 100 | /** |
| 101 | * Supported network protocols for Live tracing |
| 102 | */ |
| 103 | private enum LiveProtocol { |
| 104 | /** Default network protocol for IPv4 (TCP)*/ |
| 105 | net, |
| 106 | /** Default network protocol for IPv6 (TCP)*/ |
| 107 | net6 |
| 108 | } |
| 109 | |
| 110 | private enum StreamingProtocol2 { |
| 111 | /** Default network protocol for IPv4 (TCP)*/ |
| 112 | net, |
| 113 | /** Default network protocol for IPv6 (TCP)*/ |
| 114 | net6, |
| 115 | /** TCP network protocol for IPv4*/ |
| 116 | tcp, |
| 117 | /** TCP network protocol for IPv6*/ |
| 118 | tcp6 } |
| 119 | |
| 120 | /** |
| 121 | * Index of last supported streaming protocol for common URL configuration. |
| 122 | */ |
| 123 | private static final int COMMON_URL_LAST_INDEX = 1; |
| 124 | /** |
| 125 | * Index of default streaming protocol. |
| 126 | */ |
| 127 | private static final int DEFAULT_URL_INDEX = 0; |
| 128 | |
| 129 | // ------------------------------------------------------------------------ |
| 130 | // Attributes |
| 131 | // ------------------------------------------------------------------------ |
| 132 | /** |
| 133 | * The dialog composite. |
| 134 | */ |
| 135 | private Composite fDialogComposite = null; |
| 136 | /** |
| 137 | * The text widget for the session name |
| 138 | */ |
| 139 | private Text fSessionNameText = null; |
| 140 | /** |
| 141 | * The label widget for the session path. |
| 142 | */ |
| 143 | private Label fSessionPathLabel = null; |
| 144 | /** |
| 145 | * The text widget for the session path. |
| 146 | */ |
| 147 | private Text fSessionPathText = null; |
| 148 | /** |
| 149 | * The button widget to select a normal session |
| 150 | */ |
| 151 | private Button fNormalModeButton = null; |
| 152 | /** |
| 153 | * The button widget to select a snapshot session |
| 154 | */ |
| 155 | private Button fSnapshotButton = null; |
| 156 | /** |
| 157 | * The group that contains the mutually exclusive mode buttons |
| 158 | */ |
| 159 | private Group fModeButtonGroup = null; |
| 160 | /** |
| 161 | * The button widget to select a live session |
| 162 | */ |
| 163 | private Button fLiveButton = null; |
| 164 | |
| 165 | /** |
| 166 | * The text widget to set a live delay |
| 167 | */ |
| 168 | private Text fLiveDelayText = null; |
| 169 | /** |
| 170 | * The Group for advanced configuration. |
| 171 | */ |
| 172 | private Group fAdvancedGroup = null; |
| 173 | /** |
| 174 | * The button to show advanced options. |
| 175 | */ |
| 176 | private Button fAdvancedButton = null; |
| 177 | /** |
| 178 | * The composite with streaming configuration parameter. |
| 179 | */ |
| 180 | private Composite fStreamingComposite = null; |
| 181 | /** |
| 182 | * The text widget for the trace path. |
| 183 | */ |
| 184 | private Text fTracePathText = null; |
| 185 | /** |
| 186 | * The button to link data protocol/Address with control protocol. |
| 187 | */ |
| 188 | private Button fLinkDataWithControlButton = null; |
| 189 | /** |
| 190 | * The Combo box for channel protocol selection. |
| 191 | */ |
| 192 | private CCombo fControlProtocolCombo = null; |
| 193 | /** |
| 194 | * A selection listener that copies the protocol from control to data when being linked. |
| 195 | */ |
| 196 | private ControlProtocolSelectionListener fCopyProtocolSelectionListener; |
| 197 | /** |
| 198 | * A selection listener updates the control port text depending on the control protocol selected. |
| 199 | */ |
| 200 | private ProtocolComboSelectionListener fControlProtocolSelectionListener; |
| 201 | /** |
| 202 | * A selection listener updates the data port text depending on the data protocol selected. |
| 203 | */ |
| 204 | private ProtocolComboSelectionListener fDataProtocolSelectionListener; |
| 205 | /** |
| 206 | * The text box for the host/IP address of the control channel. |
| 207 | */ |
| 208 | private Text fControlHostAddressText = null; |
| 209 | /** |
| 210 | * A key listener that copies the host address from control to data when being linked. |
| 211 | */ |
| 212 | private CopyModifyListener fControlUrlKeyListener; |
| 213 | /** |
| 214 | * A modify listener that updates the enablement of the dialog. |
| 215 | */ |
| 216 | private UpdateEnablementModifyListener fUpdateEnablementModifyListener; |
| 217 | /** |
| 218 | * The text box for the control port. |
| 219 | */ |
| 220 | private Text fControlPortText = null; |
| 221 | /** |
| 222 | * The Combo box for data protocol selection. |
| 223 | */ |
| 224 | private CCombo fDataProtocolCombo = null; |
| 225 | /** |
| 226 | * The text box for the host/IP address of the data channel. |
| 227 | */ |
| 228 | private Text fDataHostAddressText = null; |
| 229 | /** |
| 230 | * The text box for the data port. |
| 231 | */ |
| 232 | private Text fDataPortText = null; |
| 233 | /** |
| 234 | * The parent where the new node should be added. |
| 235 | */ |
| 236 | private TraceSessionGroup fParent = null; |
| 237 | /** |
| 238 | * The session name string. |
| 239 | */ |
| 240 | private String fSessionName = ""; //$NON-NLS-1$; |
| 241 | /** |
| 242 | * The session path string. |
| 243 | */ |
| 244 | private String fSessionPath = null; |
| 245 | /** |
| 246 | * Flag whether the session is snapshot or not |
| 247 | */ |
| 248 | private boolean fIsSnapshot = false; |
| 249 | /** |
| 250 | * Flag whether the session is live or not |
| 251 | */ |
| 252 | private boolean fIsLive = false; |
| 253 | /** |
| 254 | * The text box for the live address (relayd). |
| 255 | */ |
| 256 | private Text fLiveHostAddressText = null; |
| 257 | /** |
| 258 | * The text box for the live port (relayd). |
| 259 | */ |
| 260 | private Text fLivePortText = null; |
| 261 | /** |
| 262 | * The live delay |
| 263 | */ |
| 264 | private Integer fLiveDelay = 0; |
| 265 | /** |
| 266 | * The live url. |
| 267 | */ |
| 268 | private String fLiveUrl = null; |
| 269 | /** |
| 270 | * The live port. |
| 271 | */ |
| 272 | private Integer fLivePort = 0; |
| 273 | /** |
| 274 | * Flag whether default location (path) shall be used or not |
| 275 | */ |
| 276 | private boolean fIsDefaultPath = true; |
| 277 | /** |
| 278 | * Flag whether the advanced options are enabled or not |
| 279 | */ |
| 280 | private boolean fIsAdvancedEnabled = false; |
| 281 | /** |
| 282 | * The network URL in case control and data is configured together. |
| 283 | * If set, fControlUrl and fDataUrl will be null. |
| 284 | */ |
| 285 | private String fNetworkUrl = null; |
| 286 | /** |
| 287 | * The control URL in case control and data is configured separately. |
| 288 | * If set, fDataUrl will be set too and fNetworkUrl will be null. |
| 289 | */ |
| 290 | private String fControlUrl = null; |
| 291 | /** |
| 292 | * The data URL in case control and data is configured separately. |
| 293 | * If set, fControlUrl will be set too and fNetworkUrl will be null. |
| 294 | */ |
| 295 | private String fDataUrl = null; |
| 296 | /** |
| 297 | * The trace path string. |
| 298 | */ |
| 299 | private String fTracePath = null; |
| 300 | /** |
| 301 | * The Group for advanced configuration of Live mode. |
| 302 | */ |
| 303 | private Group fLiveGroup = null; |
| 304 | |
| 305 | // ------------------------------------------------------------------------ |
| 306 | // Constructors |
| 307 | // ------------------------------------------------------------------------ |
| 308 | /** |
| 309 | * Constructor |
| 310 | * @param shell - a shell for the display of the dialog |
| 311 | */ |
| 312 | public CreateSessionDialog(Shell shell) { |
| 313 | super(shell); |
| 314 | setShellStyle(SWT.RESIZE | getShellStyle()); |
| 315 | } |
| 316 | |
| 317 | // ------------------------------------------------------------------------ |
| 318 | // Accessors |
| 319 | // ------------------------------------------------------------------------ |
| 320 | |
| 321 | @Override |
| 322 | public void initialize(TraceSessionGroup group) { |
| 323 | fParent = group; |
| 324 | fStreamingComposite = null; |
| 325 | fLiveGroup = null; |
| 326 | fLiveButton = null; |
| 327 | fIsLive = false; |
| 328 | fSnapshotButton = null; |
| 329 | fSessionName = ""; //$NON-NLS-1$ |
| 330 | fSessionPath = null; |
| 331 | fIsSnapshot = false; |
| 332 | fIsDefaultPath = true; |
| 333 | fIsAdvancedEnabled = false; |
| 334 | fNetworkUrl = null; |
| 335 | fControlUrl = null; |
| 336 | fDataUrl = null; |
| 337 | } |
| 338 | // ------------------------------------------------------------------------ |
| 339 | // Operations |
| 340 | // ------------------------------------------------------------------------ |
| 341 | |
| 342 | @Override |
| 343 | protected void configureShell(Shell newShell) { |
| 344 | super.configureShell(newShell); |
| 345 | newShell.setText(Messages.TraceControl_CreateSessionDialogTitle); |
| 346 | newShell.setImage(Activator.getDefault().loadIcon(CREATE_SESSION_ICON_FILE)); |
| 347 | } |
| 348 | |
| 349 | @Override |
| 350 | protected Control createDialogArea(Composite parent) { |
| 351 | Composite dialogAreaa = (Composite) super.createDialogArea(parent); |
| 352 | setTitle(Messages.TraceControl_CreateSessionDialogTitle); |
| 353 | setMessage(Messages.TraceControl_CreateSessionDialogMessage); |
| 354 | |
| 355 | // Main dialog panel |
| 356 | fDialogComposite = new Composite(dialogAreaa, SWT.NONE); |
| 357 | GridLayout layout = new GridLayout(1, true); |
| 358 | fDialogComposite.setLayout(layout); |
| 359 | fDialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); |
| 360 | |
| 361 | Group sessionGroup = new Group(fDialogComposite, SWT.SHADOW_NONE); |
| 362 | sessionGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); |
| 363 | sessionGroup.setLayout(new GridLayout(4, true)); |
| 364 | |
| 365 | fUpdateEnablementModifyListener = new UpdateEnablementModifyListener(); |
| 366 | |
| 367 | Label sessionNameLabel = new Label(sessionGroup, SWT.RIGHT); |
| 368 | sessionNameLabel.setText(Messages.TraceControl_CreateSessionNameLabel); |
| 369 | fSessionNameText = new Text(sessionGroup, SWT.NONE); |
| 370 | fSessionNameText.setToolTipText(Messages.TraceControl_CreateSessionNameTooltip); |
| 371 | fSessionNameText.addModifyListener(fUpdateEnablementModifyListener); |
| 372 | GridData data = new GridData(GridData.FILL_HORIZONTAL); |
| 373 | data.horizontalSpan = 3; |
| 374 | fSessionNameText.setLayoutData(data); |
| 375 | |
| 376 | fSessionPathLabel = new Label(sessionGroup, SWT.RIGHT); |
| 377 | fSessionPathLabel.setText(Messages.TraceControl_CreateSessionPathLabel); |
| 378 | fSessionPathText = new Text(sessionGroup, SWT.NONE); |
| 379 | fSessionPathText.setToolTipText(Messages.TraceControl_CreateSessionPathTooltip); |
| 380 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 381 | data.horizontalSpan = 3; |
| 382 | fSessionPathText.setLayoutData(data); |
| 383 | fSessionPathText.addModifyListener(fUpdateEnablementModifyListener); |
| 384 | |
| 385 | if (fParent.isSnapshotSupported() || fParent.isLiveSupported()) { |
| 386 | fModeButtonGroup = new Group(sessionGroup, SWT.NONE); |
| 387 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 388 | data.horizontalSpan = 4; |
| 389 | fModeButtonGroup.setLayoutData(data); |
| 390 | fModeButtonGroup.setLayout(new GridLayout(3, true)); |
| 391 | |
| 392 | SelectionAdapter modeChangedListener = new SelectionAdapter() { |
| 393 | @Override |
| 394 | public void widgetSelected(SelectionEvent e) { |
| 395 | if (fLiveButton != null) { |
| 396 | if (fLiveButton.getSelection()) { |
| 397 | createAdvancedLiveGroup(); |
| 398 | updateSessionPathEnablement(); |
| 399 | updateProtocolComboItems(); |
| 400 | } else { |
| 401 | disposeLiveGroup(); |
| 402 | updateSessionPathEnablement(); |
| 403 | updateProtocolComboItems(); |
| 404 | } |
| 405 | } |
| 406 | updateEnablement(); |
| 407 | } |
| 408 | }; |
| 409 | |
| 410 | fNormalModeButton = new Button(fModeButtonGroup, SWT.RADIO); |
| 411 | fNormalModeButton.setText(Messages.TraceControl_CreateSessionNormalLabel); |
| 412 | fNormalModeButton.setToolTipText(Messages.TraceControl_CreateSessionNormalTooltip); |
| 413 | fNormalModeButton.setSelection(true); |
| 414 | fNormalModeButton.addSelectionListener(modeChangedListener); |
| 415 | |
| 416 | if (fParent.isSnapshotSupported()) { |
| 417 | fSnapshotButton = new Button(fModeButtonGroup, SWT.RADIO); |
| 418 | fSnapshotButton.setText(Messages.TraceControl_CreateSessionSnapshotLabel); |
| 419 | fSnapshotButton.setToolTipText(Messages.TraceControl_CreateSessionSnapshotTooltip); |
| 420 | fSnapshotButton.addSelectionListener(modeChangedListener); |
| 421 | } |
| 422 | |
| 423 | if (fParent.isLiveSupported()) { |
| 424 | fLiveButton = new Button(fModeButtonGroup, SWT.RADIO); |
| 425 | fLiveButton.setText(Messages.TraceControl_CreateSessionLiveLabel); |
| 426 | fLiveButton.setToolTipText(Messages.TraceControl_CreateSessionLiveTooltip); |
| 427 | fLiveButton.addSelectionListener(modeChangedListener); |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | if (fParent.isNetworkStreamingSupported() || fParent.isLiveSupported()) { |
| 432 | createAdvancedOptionsComposite(); |
| 433 | } |
| 434 | |
| 435 | return fDialogComposite; |
| 436 | } |
| 437 | |
| 438 | private void createAdvancedOptionsComposite() { |
| 439 | |
| 440 | fAdvancedGroup = new Group(fDialogComposite, SWT.SHADOW_NONE); |
| 441 | fAdvancedGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); |
| 442 | fAdvancedGroup.setLayout(new GridLayout(1, true)); |
| 443 | |
| 444 | fAdvancedButton = new Button(fAdvancedGroup, SWT.PUSH); |
| 445 | fAdvancedButton.setText(Messages.TraceControl_CreateSessionConfigureStreamingButtonText + " >>>"); //$NON-NLS-1$ |
| 446 | fAdvancedButton.setToolTipText(Messages.TraceControl_CreateSessionConfigureStreamingButtonTooltip); |
| 447 | fAdvancedButton.addSelectionListener(new SelectionAdapter() { |
| 448 | @Override |
| 449 | public void widgetSelected(SelectionEvent e) { |
| 450 | if (fIsAdvancedEnabled) { |
| 451 | fIsAdvancedEnabled = false; |
| 452 | fAdvancedButton.setText(">>> " + Messages.TraceControl_CreateSessionConfigureStreamingButtonText); //$NON-NLS-1$ |
| 453 | fAdvancedButton.setToolTipText(Messages.TraceControl_CreateSessionConfigureStreamingButtonTooltip); |
| 454 | |
| 455 | if (fParent.isNetworkStreamingSupported()) { |
| 456 | updateSessionPathEnablement(); |
| 457 | disposeConfigureStreamingComposite(); |
| 458 | } |
| 459 | |
| 460 | if (fParent.isLiveSupported()) { |
| 461 | disposeLiveGroup(); |
| 462 | } |
| 463 | } else { |
| 464 | fIsAdvancedEnabled = true; |
| 465 | fAdvancedButton.setText("<<< " + Messages.TraceControl_CreateSessionNoStreamingButtonText); //$NON-NLS-1$ |
| 466 | fAdvancedButton.setToolTipText(Messages.TraceControl_CreateSessionNoStreamingButtonTooltip); |
| 467 | |
| 468 | if (fParent.isNetworkStreamingSupported()) { |
| 469 | updateSessionPathEnablement(); |
| 470 | createConfigureStreamingComposite(); |
| 471 | } |
| 472 | if (fLiveButton != null && fLiveButton.getSelection()) { |
| 473 | createAdvancedLiveGroup(); |
| 474 | } |
| 475 | } |
| 476 | |
| 477 | updateEnablement(); |
| 478 | getShell().pack(); |
| 479 | } |
| 480 | }); |
| 481 | } |
| 482 | |
| 483 | private void updateSessionPathEnablement() { |
| 484 | if (fIsAdvancedEnabled || fIsLive) { |
| 485 | fSessionPathText.setEnabled(false); |
| 486 | fSessionPathText.setText(""); //$NON-NLS-1$ |
| 487 | fSessionPathLabel.setText(""); //$NON-NLS-1$ |
| 488 | } else { |
| 489 | fSessionPathText.setEnabled(true); |
| 490 | fSessionPathLabel.setText(Messages.TraceControl_CreateSessionPathLabel); |
| 491 | } |
| 492 | } |
| 493 | |
| 494 | private void updateProtocolComboItems() { |
| 495 | if (fControlProtocolCombo == null || fControlProtocolCombo.isDisposed()) { |
| 496 | return; |
| 497 | } |
| 498 | |
| 499 | int currentSelection = fControlProtocolCombo.getSelectionIndex() <= COMMON_URL_LAST_INDEX ? |
| 500 | fControlProtocolCombo.getSelectionIndex() : DEFAULT_URL_INDEX; |
| 501 | |
| 502 | fControlProtocolCombo.removeAll(); |
| 503 | Enum<? extends Enum<?>>[] values; |
| 504 | if (fIsLive) { |
| 505 | values = LiveProtocol.values(); |
| 506 | } else if (fLinkDataWithControlButton.getSelection()) { |
| 507 | values = StreamingProtocol.values(); |
| 508 | } else { |
| 509 | values = StreamingProtocol2.values(); |
| 510 | } |
| 511 | |
| 512 | String[] controlItems = new String[values.length]; |
| 513 | for (int i = 0; i < controlItems.length; i++) { |
| 514 | controlItems[i] = values[i].name(); |
| 515 | } |
| 516 | fControlProtocolCombo.setItems(controlItems); |
| 517 | fDataProtocolCombo.setItems(controlItems); |
| 518 | |
| 519 | // Set selection |
| 520 | if (currentSelection != -1) { |
| 521 | fControlProtocolCombo.select(currentSelection); |
| 522 | fDataProtocolCombo.select(currentSelection); |
| 523 | } |
| 524 | } |
| 525 | |
| 526 | private void createConfigureStreamingComposite() { |
| 527 | if (fStreamingComposite == null) { |
| 528 | fStreamingComposite = new Group(fAdvancedGroup, SWT.SHADOW_NONE); |
| 529 | GridLayout layout = new GridLayout(1, true); |
| 530 | fStreamingComposite.setLayout(layout); |
| 531 | fStreamingComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); |
| 532 | |
| 533 | layout = new GridLayout(7, true); |
| 534 | fStreamingComposite.setLayout(layout); |
| 535 | fStreamingComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); |
| 536 | |
| 537 | Label tracePathLabel = new Label(fStreamingComposite, SWT.RIGHT); |
| 538 | tracePathLabel.setText(Messages.TraceControl_CreateSessionTracePathText); |
| 539 | fTracePathText = new Text(fStreamingComposite, SWT.NONE); |
| 540 | fTracePathText.setToolTipText(Messages.TraceControl_CreateSessionTracePathTooltip); |
| 541 | |
| 542 | // layout widgets |
| 543 | GridData data = new GridData(GridData.FILL_HORIZONTAL); |
| 544 | data.horizontalSpan = 6; |
| 545 | fTracePathText.setLayoutData(data); |
| 546 | fTracePathText.addModifyListener(fUpdateEnablementModifyListener); |
| 547 | |
| 548 | fLinkDataWithControlButton = new Button(fStreamingComposite, SWT.CHECK); |
| 549 | fLinkDataWithControlButton.setText(Messages.TraceControl_CreateSessionLinkButtonText); |
| 550 | fLinkDataWithControlButton.setToolTipText(Messages.TraceControl_CreateSessionLinkButtonTooltip); |
| 551 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 552 | data.horizontalSpan = 7; |
| 553 | fLinkDataWithControlButton.setLayoutData(data); |
| 554 | fLinkDataWithControlButton.setSelection(true); |
| 555 | |
| 556 | Label label = new Label(fStreamingComposite, SWT.NONE); |
| 557 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 558 | data.horizontalSpan = 1; |
| 559 | label.setLayoutData(data); |
| 560 | |
| 561 | label = new Label(fStreamingComposite, SWT.NONE); |
| 562 | label.setText(Messages.TraceControl_CreateSessionProtocolLabelText); |
| 563 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 564 | data.horizontalSpan = 1; |
| 565 | label.setLayoutData(data); |
| 566 | |
| 567 | label = new Label(fStreamingComposite, SWT.NONE); |
| 568 | label.setText(Messages.TraceControl_CreateSessionAddressLabelText); |
| 569 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 570 | data.horizontalSpan = 4; |
| 571 | label.setLayoutData(data); |
| 572 | |
| 573 | label = new Label(fStreamingComposite, SWT.NONE); |
| 574 | label.setText(Messages.TraceControl_CreateSessionPortLabelText); |
| 575 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 576 | data.horizontalSpan = 1; |
| 577 | label.setLayoutData(data); |
| 578 | |
| 579 | label = new Label(fStreamingComposite, SWT.RIGHT); |
| 580 | label.setText(Messages.TraceControl_CreateSessionControlUrlLabel); |
| 581 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 582 | data.horizontalSpan = 1; |
| 583 | label.setLayoutData(data); |
| 584 | |
| 585 | fControlProtocolCombo = new CCombo(fStreamingComposite, SWT.READ_ONLY); |
| 586 | fControlProtocolCombo.setToolTipText(Messages.TraceControl_CreateSessionCommonProtocolTooltip); |
| 587 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 588 | data.horizontalSpan = 1; |
| 589 | fControlProtocolCombo.setLayoutData(data); |
| 590 | fControlProtocolCombo.addModifyListener(fUpdateEnablementModifyListener); |
| 591 | |
| 592 | fControlHostAddressText = new Text(fStreamingComposite, SWT.NONE); |
| 593 | fControlHostAddressText.setToolTipText(Messages.TraceControl_CreateSessionControlAddressTooltip); |
| 594 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 595 | data.horizontalSpan = 4; |
| 596 | fControlHostAddressText.setLayoutData(data); |
| 597 | fControlHostAddressText.addModifyListener(fUpdateEnablementModifyListener); |
| 598 | |
| 599 | fControlPortText = new Text(fStreamingComposite, SWT.NONE); |
| 600 | fControlPortText.setToolTipText(Messages.TraceControl_CreateSessionControlPortTooltip); |
| 601 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 602 | data.horizontalSpan = 1; |
| 603 | fControlPortText.setLayoutData(data); |
| 604 | fControlPortText.addModifyListener(fUpdateEnablementModifyListener); |
| 605 | |
| 606 | label = new Label(fStreamingComposite, SWT.RIGHT); |
| 607 | label.setText(Messages.TraceControl_CreateSessionDataUrlLabel); |
| 608 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 609 | data.horizontalSpan = 1; |
| 610 | label.setLayoutData(data); |
| 611 | |
| 612 | fDataProtocolCombo = new CCombo(fStreamingComposite, SWT.READ_ONLY); |
| 613 | fDataProtocolCombo.setEnabled(false); |
| 614 | fDataProtocolCombo.setToolTipText(Messages.TraceControl_CreateSessionProtocolTooltip); |
| 615 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 616 | data.horizontalSpan = 1; |
| 617 | fDataProtocolCombo.setLayoutData(data); |
| 618 | fDataProtocolCombo.addModifyListener(fUpdateEnablementModifyListener); |
| 619 | |
| 620 | updateProtocolComboItems(); |
| 621 | |
| 622 | fDataHostAddressText = new Text(fStreamingComposite, SWT.NONE); |
| 623 | fDataHostAddressText.setEnabled(false); |
| 624 | fDataHostAddressText.setToolTipText(Messages.TraceControl_CreateSessionDataAddressTooltip); |
| 625 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 626 | data.horizontalSpan = 4; |
| 627 | fDataHostAddressText.setLayoutData(data); |
| 628 | fDataHostAddressText.addModifyListener(fUpdateEnablementModifyListener); |
| 629 | |
| 630 | fDataPortText = new Text(fStreamingComposite, SWT.NONE); |
| 631 | fDataPortText.setEnabled(true); |
| 632 | fDataPortText.setToolTipText(Messages.TraceControl_CreateSessionDataPortTooltip); |
| 633 | data = new GridData(GridData.FILL_HORIZONTAL); |
| 634 | data.horizontalSpan = 1; |
| 635 | fDataPortText.setLayoutData(data); |
| 636 | fDataPortText.addModifyListener(fUpdateEnablementModifyListener); |
| 637 | |
| 638 | fCopyProtocolSelectionListener = new ControlProtocolSelectionListener(); |
| 639 | fControlProtocolSelectionListener = new ProtocolComboSelectionListener(fControlProtocolCombo, fControlPortText); |
| 640 | fDataProtocolSelectionListener = new ProtocolComboSelectionListener(fDataProtocolCombo, fDataPortText); |
| 641 | |
| 642 | fControlProtocolCombo.addSelectionListener(fCopyProtocolSelectionListener); |
| 643 | |
| 644 | fControlUrlKeyListener = new CopyModifyListener(fControlHostAddressText, fDataHostAddressText); |
| 645 | fControlHostAddressText.addModifyListener(fControlUrlKeyListener); |
| 646 | |
| 647 | fControlProtocolCombo.select(DEFAULT_URL_INDEX); |
| 648 | fDataProtocolCombo.select(DEFAULT_URL_INDEX); |
| 649 | |
| 650 | fLinkDataWithControlButton.addSelectionListener(new SelectionAdapter() { |
| 651 | @Override |
| 652 | public void widgetSelected(SelectionEvent e) { |
| 653 | if (fLinkDataWithControlButton.getSelection()) { |
| 654 | // Set enablement control data channel inputs |
| 655 | fDataProtocolCombo.setEnabled(false); |
| 656 | fDataHostAddressText.setEnabled(false); |
| 657 | fControlPortText.setEnabled(true); |
| 658 | fDataPortText.setEnabled(true); |
| 659 | |
| 660 | // Update listeners |
| 661 | fControlProtocolCombo.removeSelectionListener(fControlProtocolSelectionListener); |
| 662 | fDataProtocolCombo.removeSelectionListener(fDataProtocolSelectionListener); |
| 663 | fControlProtocolCombo.addSelectionListener(fCopyProtocolSelectionListener); |
| 664 | fControlHostAddressText.addModifyListener(fControlUrlKeyListener); |
| 665 | |
| 666 | updateProtocolComboItems(); |
| 667 | |
| 668 | fDataHostAddressText.setText(fControlHostAddressText.getText()); |
| 669 | |
| 670 | // Update tool tips |
| 671 | fControlProtocolCombo.setToolTipText(Messages.TraceControl_CreateSessionCommonProtocolTooltip); |
| 672 | } else { |
| 673 | // Enable data channel inputs |
| 674 | fDataProtocolCombo.setEnabled(true); |
| 675 | fDataHostAddressText.setEnabled(true); |
| 676 | |
| 677 | // Update listeners |
| 678 | fControlProtocolCombo.removeSelectionListener(fCopyProtocolSelectionListener); |
| 679 | fControlProtocolCombo.addSelectionListener(fControlProtocolSelectionListener); |
| 680 | fDataProtocolCombo.addSelectionListener(fDataProtocolSelectionListener); |
| 681 | fControlHostAddressText.removeModifyListener(fControlUrlKeyListener); |
| 682 | |
| 683 | updateProtocolComboItems(); |
| 684 | |
| 685 | // Update tool tips |
| 686 | fDataProtocolCombo.setToolTipText(Messages.TraceControl_CreateSessionProtocolTooltip); |
| 687 | fControlProtocolCombo.setToolTipText(Messages.TraceControl_CreateSessionProtocolTooltip); |
| 688 | |
| 689 | // Update control/data port enablement and input |
| 690 | if (fControlProtocolCombo.getItem(fControlProtocolCombo.getSelectionIndex()).equals(StreamingProtocol.net.name()) || |
| 691 | fControlProtocolCombo.getItem(fControlProtocolCombo.getSelectionIndex()).equals(StreamingProtocol.net6.name())) { |
| 692 | fControlPortText.setText(""); //$NON-NLS-1$ |
| 693 | fControlPortText.setEnabled(false); |
| 694 | } else { |
| 695 | fControlPortText.setEnabled(true); |
| 696 | } |
| 697 | |
| 698 | if (fDataProtocolCombo.getItem(fDataProtocolCombo.getSelectionIndex()).equals(StreamingProtocol.net.name()) || |
| 699 | fDataProtocolCombo.getItem(fDataProtocolCombo.getSelectionIndex()).equals(StreamingProtocol.net6.name())) { |
| 700 | fDataPortText.setText(""); //$NON-NLS-1$ |
| 701 | fDataPortText.setEnabled(false); |
| 702 | } else { |
| 703 | fDataPortText.setEnabled(true); |
| 704 | } |
| 705 | } |
| 706 | } |
| 707 | }); |
| 708 | } |
| 709 | } |
| 710 | |
| 711 | private void createAdvancedLiveGroup() { |
| 712 | if (fLiveGroup == null && fIsAdvancedEnabled) { |
| 713 | GridLayout layout = new GridLayout(7, true); |
| 714 | fLiveGroup = new Group(fAdvancedGroup, SWT.NONE); |
| 715 | fLiveGroup.setLayout(layout); |
| 716 | GridData layoutData = new GridData(GridData.FILL_BOTH); |
| 717 | fLiveGroup.setLayoutData(layoutData); |
| 718 | |
| 719 | Label label = new Label(fLiveGroup, SWT.NONE); |
| 720 | label.setText(Messages.TraceControl_CreateSessionLiveConnectionLabel); |
| 721 | layoutData = new GridData(GridData.FILL_HORIZONTAL); |
| 722 | layoutData.horizontalSpan = 2; |
| 723 | label.setLayoutData(layoutData); |
| 724 | |
| 725 | fLiveHostAddressText = new Text(fLiveGroup, SWT.NONE); |
| 726 | fLiveHostAddressText.setText(DEFAULT_LIVE_URL); |
| 727 | fLiveHostAddressText.setEnabled(false); |
| 728 | fLiveHostAddressText.setToolTipText(Messages.TraceControl_CreateSessionLiveConnectionUrlTooltip); |
| 729 | layoutData = new GridData(GridData.FILL_HORIZONTAL); |
| 730 | layoutData.horizontalSpan = 4; |
| 731 | fLiveHostAddressText.setLayoutData(layoutData); |
| 732 | |
| 733 | fLivePortText = new Text(fLiveGroup, SWT.NONE); |
| 734 | fLivePortText.setText(Integer.toString(DEFAULT_LIVE_PORT)); |
| 735 | fLivePortText.setToolTipText(Messages.TraceControl_CreateSessionLiveConnectionPortTooltip); |
| 736 | layoutData = new GridData(GridData.FILL_HORIZONTAL); |
| 737 | fLivePortText.setLayoutData(layoutData); |
| 738 | |
| 739 | Label liveDelayLabel = new Label(fLiveGroup, SWT.NONE); |
| 740 | layoutData = new GridData(GridData.FILL_HORIZONTAL); |
| 741 | liveDelayLabel.setText(Messages.TraceControl_CreateSessionLiveDelayLabel); |
| 742 | liveDelayLabel.setLayoutData(layoutData); |
| 743 | fLiveDelayText = new Text(fLiveGroup, SWT.NONE); |
| 744 | fLiveDelayText.setText(DEFAULT_TEXT); |
| 745 | fLiveDelayText.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); |
| 746 | fLiveDelayText.setToolTipText(Messages.TraceControl_CreateSessionLiveDelayTooltip); |
| 747 | fLiveDelayText.addVerifyListener(new VerifyListener() { |
| 748 | @Override |
| 749 | public void verifyText(VerifyEvent e) { |
| 750 | // only numbers and default are allowed. |
| 751 | e.doit = e.text.matches("[0-9]*") || e.text.matches(DEFAULT_TEXT); //$NON-NLS-1$ |
| 752 | updateEnablement(); |
| 753 | } |
| 754 | }); |
| 755 | fLiveDelayText.addModifyListener(new ModifyListener() { |
| 756 | @Override |
| 757 | public void modifyText(ModifyEvent event) { |
| 758 | updateEnablement(); |
| 759 | } |
| 760 | }); |
| 761 | |
| 762 | fLiveDelayText.addFocusListener(new FocusListener() { |
| 763 | |
| 764 | @Override |
| 765 | public void focusLost(FocusEvent e) { |
| 766 | Text focusLostWidget = (Text) e.widget; |
| 767 | if (focusLostWidget.getText().isEmpty()) { |
| 768 | focusLostWidget.setText(DEFAULT_TEXT); |
| 769 | focusLostWidget.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); |
| 770 | } |
| 771 | } |
| 772 | |
| 773 | @Override |
| 774 | public void focusGained(FocusEvent e) { |
| 775 | Text focusGainedWidget = (Text) e.widget; |
| 776 | if (focusGainedWidget.getText().equals(DEFAULT_TEXT)) { |
| 777 | focusGainedWidget.setText(""); //$NON-NLS-1$ |
| 778 | focusGainedWidget.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_BLACK)); |
| 779 | } |
| 780 | } |
| 781 | }); |
| 782 | |
| 783 | layoutData = new GridData(GridData.FILL_HORIZONTAL); |
| 784 | layoutData.grabExcessHorizontalSpace = true; |
| 785 | layoutData.horizontalSpan = 6; |
| 786 | fLiveDelayText.setLayoutData(layoutData); |
| 787 | getShell().pack(); |
| 788 | } |
| 789 | } |
| 790 | |
| 791 | private void disposeLiveGroup() { |
| 792 | if (fLiveGroup != null) { |
| 793 | fLiveGroup.dispose(); |
| 794 | fLiveGroup = null; |
| 795 | getShell().pack(); |
| 796 | } |
| 797 | } |
| 798 | |
| 799 | private void disposeConfigureStreamingComposite() { |
| 800 | if (fStreamingComposite != null) { |
| 801 | fStreamingComposite.dispose(); |
| 802 | fStreamingComposite = null; |
| 803 | } |
| 804 | } |
| 805 | |
| 806 | @Override |
| 807 | protected void createButtonsForButtonBar(Composite parent) { |
| 808 | createButton(parent, IDialogConstants.CANCEL_ID, "&Cancel", true); //$NON-NLS-1$ |
| 809 | createButton(parent, IDialogConstants.OK_ID, "&Ok", true); //$NON-NLS-1$ |
| 810 | } |
| 811 | |
| 812 | private void updateEnablement() { |
| 813 | validate(); |
| 814 | getButton(IDialogConstants.OK_ID).setEnabled(getErrorMessage() == null); |
| 815 | } |
| 816 | |
| 817 | private void validate() { |
| 818 | // Validate input data |
| 819 | fSessionName = fSessionNameText.getText(); |
| 820 | fSessionPath = fSessionPathText.getText(); |
| 821 | setErrorMessage(null); |
| 822 | |
| 823 | if (fParent.isLiveSupported() && fLiveButton != null) { |
| 824 | fIsLive = fLiveButton.getSelection(); |
| 825 | fLiveDelay = LTTngControlServiceConstants.UNUSED_VALUE; |
| 826 | fLiveUrl = DEFAULT_LIVE_URL; |
| 827 | fLivePort = DEFAULT_LIVE_PORT; |
| 828 | } |
| 829 | |
| 830 | if (!"".equals(fSessionPath)) { //$NON-NLS-1$ |
| 831 | // validate sessionPath |
| 832 | if (!fIsAdvancedEnabled && !fIsLive) { |
| 833 | TargetNodeComponent node = (TargetNodeComponent)fParent.getParent(); |
| 834 | IRemoteSystemProxy proxy = node.getRemoteSystemProxy(); |
| 835 | IFileServiceSubSystem fsss = proxy.getFileServiceSubSystem(); |
| 836 | if (fsss != null) { |
| 837 | try { |
| 838 | IRemoteFile remoteFolder = fsss.getRemoteFileObject(fSessionPath, new NullProgressMonitor()); |
| 839 | |
| 840 | if (remoteFolder == null) { |
| 841 | setErrorMessage(Messages.TraceControl_InvalidSessionPathError + " (" + fSessionPath + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 842 | return; |
| 843 | } |
| 844 | |
| 845 | if (remoteFolder.exists()) { |
| 846 | setErrorMessage(Messages.TraceControl_SessionPathAlreadyExistsError + " (" + fSessionPath + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 847 | return; |
| 848 | } |
| 849 | } catch (SystemMessageException e) { |
| 850 | setErrorMessage(Messages.TraceControl_FileSubSystemError + "\n" + e); //$NON-NLS-1$ |
| 851 | return; |
| 852 | } |
| 853 | } |
| 854 | } |
| 855 | fIsDefaultPath = false; |
| 856 | } |
| 857 | |
| 858 | if (fParent.isSnapshotSupported()) { |
| 859 | fIsSnapshot = fSnapshotButton.getSelection(); |
| 860 | } |
| 861 | |
| 862 | fNetworkUrl = null; |
| 863 | fControlUrl = null; |
| 864 | fDataUrl = null; |
| 865 | |
| 866 | if (fIsAdvancedEnabled && fStreamingComposite != null) { |
| 867 | // Validate input data |
| 868 | |
| 869 | if (fIsLive && fLiveGroup != null) { |
| 870 | String liveDelayText = fLiveDelayText.getText(); |
| 871 | try { |
| 872 | fLiveDelay = liveDelayText.equals(DEFAULT_TEXT) ? LTTngControlServiceConstants.UNUSED_VALUE : Integer.valueOf(liveDelayText); |
| 873 | fLivePort = Integer.valueOf(fLivePortText.getText()); |
| 874 | fLiveUrl = fLiveHostAddressText.getText(); |
| 875 | } catch (NumberFormatException e) { |
| 876 | setErrorMessage(Messages.TraceControl_InvalidLiveDelayError); |
| 877 | return; |
| 878 | } |
| 879 | } |
| 880 | |
| 881 | fTracePath = fTracePathText.getText(); |
| 882 | |
| 883 | if (fControlProtocolCombo.getSelectionIndex() < 0) { |
| 884 | setErrorMessage("Control Protocol Text is empty\n"); //$NON-NLS-1$ |
| 885 | return; |
| 886 | } |
| 887 | |
| 888 | if ("".equals(fControlHostAddressText.getText())) { //$NON-NLS-1$ |
| 889 | setErrorMessage("Control Address Text is empty\n"); //$NON-NLS-1$ |
| 890 | return; |
| 891 | } |
| 892 | |
| 893 | if (!fLinkDataWithControlButton.getSelection()) { |
| 894 | if (fDataProtocolCombo.getSelectionIndex() < 0) { |
| 895 | setErrorMessage("Data Protocol Text is empty\n"); //$NON-NLS-1$ |
| 896 | return; |
| 897 | } |
| 898 | |
| 899 | if ("".equals(fDataHostAddressText.getText())) { //$NON-NLS-1$ |
| 900 | setErrorMessage("Data Address Text is empty\n"); //$NON-NLS-1$ |
| 901 | return; |
| 902 | } |
| 903 | |
| 904 | fControlUrl = getUrlString(fControlProtocolCombo.getItem(fControlProtocolCombo.getSelectionIndex()), |
| 905 | fControlHostAddressText.getText(), |
| 906 | fControlPortText.getText(), |
| 907 | null, |
| 908 | fTracePath); |
| 909 | |
| 910 | fDataUrl = getUrlString(fDataProtocolCombo.getItem(fDataProtocolCombo.getSelectionIndex()), |
| 911 | fDataHostAddressText.getText(), |
| 912 | null, |
| 913 | fDataPortText.getText(), |
| 914 | fTracePath); |
| 915 | } else { |
| 916 | fNetworkUrl = getUrlString(fControlProtocolCombo.getItem(fControlProtocolCombo.getSelectionIndex()), |
| 917 | fControlHostAddressText.getText(), |
| 918 | fControlPortText.getText(), |
| 919 | fDataPortText.getText(), |
| 920 | fTracePath); |
| 921 | } |
| 922 | } |
| 923 | |
| 924 | if (fIsLive && fNetworkUrl == null && fControlUrl == null && fDataUrl == null) { |
| 925 | fNetworkUrl = SessionInfo.DEFAULT_LIVE_NETWORK_URK; |
| 926 | } |
| 927 | |
| 928 | // Check for invalid names |
| 929 | if (!"".equals(fSessionName) && !fSessionName.matches("^[a-zA-Z0-9\\-\\_]{1,}$")) { //$NON-NLS-1$ //$NON-NLS-2$ |
| 930 | setErrorMessage(Messages.TraceControl_InvalidSessionNameError + " (" + fSessionName + ") \n"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 931 | return; |
| 932 | } |
| 933 | |
| 934 | // Check if node with name already exists in parent |
| 935 | if(fParent.containsChild(fSessionName)) { |
| 936 | setErrorMessage(Messages.TraceControl_SessionAlreadyExistsError + " (" + fSessionName + ")"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 937 | return; |
| 938 | } |
| 939 | } |
| 940 | |
| 941 | private static String getUrlString(String proto, String host, String ctrlPort, String dataPort, String sessionPath) { |
| 942 | //proto://[HOST|IP][:PORT1[:PORT2]][/TRACE_PATH] |
| 943 | StringBuilder stringBuilder = new StringBuilder(); |
| 944 | stringBuilder.append(proto); |
| 945 | stringBuilder.append("://"); //$NON-NLS-1$ |
| 946 | stringBuilder.append(host); |
| 947 | |
| 948 | if ((ctrlPort != null) && (!"".equals(ctrlPort))) { //$NON-NLS-1$ |
| 949 | stringBuilder.append(":"); //$NON-NLS-1$ |
| 950 | stringBuilder.append(ctrlPort); |
| 951 | } |
| 952 | |
| 953 | if ((dataPort != null) && (!"".equals(dataPort))) { //$NON-NLS-1$ |
| 954 | stringBuilder.append(":"); //$NON-NLS-1$ |
| 955 | stringBuilder.append(dataPort); |
| 956 | } |
| 957 | |
| 958 | if ((sessionPath != null) && (!"".equals(sessionPath))) { //$NON-NLS-1$ |
| 959 | stringBuilder.append("/"); //$NON-NLS-1$ |
| 960 | stringBuilder.append(sessionPath); |
| 961 | } |
| 962 | return stringBuilder.toString(); |
| 963 | } |
| 964 | |
| 965 | private static class CopyModifyListener implements ModifyListener { |
| 966 | private Text fSource; |
| 967 | private Text fDestination; |
| 968 | |
| 969 | public CopyModifyListener(Text source, Text destination) { |
| 970 | fSource = source; |
| 971 | fDestination = destination; |
| 972 | } |
| 973 | |
| 974 | @Override |
| 975 | public void modifyText(ModifyEvent e) { |
| 976 | fDestination.setText(fSource.getText()); |
| 977 | } |
| 978 | } |
| 979 | |
| 980 | private class ControlProtocolSelectionListener extends SelectionAdapter { |
| 981 | |
| 982 | @Override |
| 983 | public void widgetSelected(SelectionEvent e) { |
| 984 | fDataProtocolCombo.select(fControlProtocolCombo.getSelectionIndex()); |
| 985 | if (fControlProtocolCombo.getItem(fControlProtocolCombo.getSelectionIndex()).equals(StreamingProtocol.file.name())) { |
| 986 | fControlPortText.setText(""); //$NON-NLS-1$ |
| 987 | fDataPortText.setText(""); //$NON-NLS-1$ |
| 988 | fControlPortText.setEnabled(false); |
| 989 | fDataPortText.setEnabled(false); |
| 990 | } else { |
| 991 | fControlPortText.setEnabled(true); |
| 992 | fDataPortText.setEnabled(true); |
| 993 | } |
| 994 | } |
| 995 | } |
| 996 | |
| 997 | private class ProtocolComboSelectionListener extends SelectionAdapter { |
| 998 | |
| 999 | private CCombo fCombo; |
| 1000 | private Text fPortText; |
| 1001 | |
| 1002 | public ProtocolComboSelectionListener(CCombo combo, Text portText) { |
| 1003 | fCombo = combo; |
| 1004 | fPortText = portText; |
| 1005 | } |
| 1006 | |
| 1007 | @Override |
| 1008 | public void widgetSelected(SelectionEvent e) { |
| 1009 | if (fCombo.getItem(fCombo.getSelectionIndex()).equals(StreamingProtocol.net.name()) || |
| 1010 | fCombo.getItem(fCombo.getSelectionIndex()).equals(StreamingProtocol.net6.name())) { |
| 1011 | fPortText.setText(""); //$NON-NLS-1$ |
| 1012 | fPortText.setEnabled(false); |
| 1013 | } else { |
| 1014 | fPortText.setEnabled(true); |
| 1015 | } |
| 1016 | } |
| 1017 | } |
| 1018 | |
| 1019 | @Override |
| 1020 | public ISessionInfo getParameters() { |
| 1021 | ISessionInfo sessionInfo = new SessionInfo(fSessionName); |
| 1022 | |
| 1023 | boolean isStreaming = (fIsAdvancedEnabled && fStreamingComposite != null) || fIsLive; |
| 1024 | if (isStreaming) { |
| 1025 | sessionInfo.setNetworkUrl(fNetworkUrl); |
| 1026 | sessionInfo.setControlUrl(fControlUrl); |
| 1027 | sessionInfo.setDataUrl(fDataUrl); |
| 1028 | sessionInfo.setStreamedTrace(true); |
| 1029 | } else if (!fIsDefaultPath) { |
| 1030 | sessionInfo.setSessionPath(fSessionPath); |
| 1031 | } |
| 1032 | |
| 1033 | sessionInfo.setLive(fIsLive); |
| 1034 | sessionInfo.setLiveUrl(fLiveUrl); |
| 1035 | sessionInfo.setLivePort(fLivePort); |
| 1036 | sessionInfo.setLiveDelay(fLiveDelay); |
| 1037 | sessionInfo.setSnapshot(fIsSnapshot); |
| 1038 | |
| 1039 | return sessionInfo; |
| 1040 | } |
| 1041 | |
| 1042 | private final class UpdateEnablementModifyListener implements ModifyListener { |
| 1043 | @Override |
| 1044 | public void modifyText(ModifyEvent e) { |
| 1045 | updateEnablement(); |
| 1046 | } |
| 1047 | } |
| 1048 | } |