debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/ui/AttachMainTab.java
branchRCL_2_4
changeset 857 d66843399035
parent 273 c2533fd23253
equal deleted inserted replaced
855:3f37e327885c 857:d66843399035
    16 */
    16 */
    17 package com.nokia.cdt.internal.debug.launch.ui;
    17 package com.nokia.cdt.internal.debug.launch.ui;
    18 
    18 
    19 import com.freescale.cdt.debug.cw.core.RemoteConnectionsTRKHelper;
    19 import com.freescale.cdt.debug.cw.core.RemoteConnectionsTRKHelper;
    20 import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
    20 import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
    21 import com.nokia.carbide.remoteconnections.interfaces.IClientServiceSiteUI;
    21 import com.nokia.carbide.remoteconnections.interfaces.IClientServiceSiteUI2;
    22 import com.nokia.carbide.remoteconnections.interfaces.IConnection;
    22 import com.nokia.carbide.remoteconnections.interfaces.IClientServiceSiteUI2.IListener;
    23 import com.nokia.carbide.remoteconnections.interfaces.IClientServiceSiteUI.IListener;
       
    24 import com.nokia.cdt.internal.debug.launch.LaunchPlugin;
    23 import com.nokia.cdt.internal.debug.launch.LaunchPlugin;
    25 
    24 
    26 import org.eclipse.core.runtime.CoreException;
    25 import org.eclipse.core.runtime.CoreException;
       
    26 import org.eclipse.core.runtime.IStatus;
    27 import org.eclipse.debug.core.ILaunchConfiguration;
    27 import org.eclipse.debug.core.ILaunchConfiguration;
    28 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
    28 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
    29 import org.eclipse.swt.SWT;
    29 import org.eclipse.swt.SWT;
    30 import org.eclipse.swt.layout.GridLayout;
    30 import org.eclipse.swt.layout.GridLayout;
    31 import org.eclipse.swt.widgets.*;
    31 import org.eclipse.swt.widgets.*;
    34 
    34 
    35 	protected Label remoteLabel;
    35 	protected Label remoteLabel;
    36 	protected Text remoteText;
    36 	protected Text remoteText;
    37 	protected Label argsLabel;
    37 	protected Label argsLabel;
    38 	protected Text argsText;
    38 	protected Text argsText;
    39 	protected IConnection connection;
    39 	protected String connection;
    40 	protected IClientServiceSiteUI clientSiteUI;
    40 	protected IClientServiceSiteUI2 clientSiteUI;
    41 	
    41 	
    42 	public AttachMainTab() {
    42 	public AttachMainTab() {
    43 		super(DONT_CHECK_PROGRAM);
    43 		super(DONT_CHECK_PROGRAM);
    44 	}
    44 	}
    45 
    45 
    57 
    57 
    58 		fProjLabel.setToolTipText(Messages.getString("RunModeMainTab.8")); //$NON-NLS-1$
    58 		fProjLabel.setToolTipText(Messages.getString("RunModeMainTab.8")); //$NON-NLS-1$
    59 		fProjText.setToolTipText(Messages.getString("RunModeMainTab.8")); //$NON-NLS-1$
    59 		fProjText.setToolTipText(Messages.getString("RunModeMainTab.8")); //$NON-NLS-1$
    60 
    60 
    61 		createVerticalSpacer(comp, 1);
    61 		createVerticalSpacer(comp, 1);
    62 		clientSiteUI = RemoteConnectionsActivator.getConnectionsManager().getClientSiteUI(LaunchPlugin.getTRKService());
    62 		clientSiteUI = RemoteConnectionsActivator.getConnectionsManager().getClientSiteUI2(LaunchPlugin.getTRKService());
    63 		clientSiteUI.createComposite(comp);
    63 		clientSiteUI.createComposite(comp);
    64 		clientSiteUI.addListener(new IListener() {
    64 		clientSiteUI.addListener(new IListener() {
    65 			public void connectionSelected() {
    65 			public void connectionSelected() {
    66 				connection = clientSiteUI.getSelectedConnection();
    66 				connection = clientSiteUI.getSelectedConnection();
    67 				updateLaunchConfigurationDialog();
    67 				updateLaunchConfigurationDialog();
    83 		super.initializeFrom(config);
    83 		super.initializeFrom(config);
    84 		try {
    84 		try {
    85 	        if (!RemoteConnectionsTRKHelper.configUsesConnectionAttribute(config)) {
    85 	        if (!RemoteConnectionsTRKHelper.configUsesConnectionAttribute(config)) {
    86 	        	config = RemoteConnectionsTRKHelper.attemptUpdateLaunchConfiguration(config.getWorkingCopy());
    86 	        	config = RemoteConnectionsTRKHelper.attemptUpdateLaunchConfiguration(config.getWorkingCopy());
    87 	        }
    87 	        }
    88 			connection = RemoteConnectionsTRKHelper.getConnectionFromConfig(config);
    88 			connection = RemoteConnectionsTRKHelper.getConnectionIdFromConfig(config);
    89 		} catch (CoreException e) {
    89 		} catch (CoreException e) {
    90 		}
    90 		}
    91 		if (connection != null)
    91 		if (connection != null)
    92 			clientSiteUI.selectConnection(connection);
    92 			clientSiteUI.selectConnection(connection);
    93 		else {
    93 		else {
    96 	}
    96 	}
    97 
    97 
    98 	public void performApply(ILaunchConfigurationWorkingCopy config) {
    98 	public void performApply(ILaunchConfigurationWorkingCopy config) {
    99 		super.performApply(config);
    99 		super.performApply(config);
   100 		if (connection != null) {
   100 		if (connection != null) {
   101 			config.setAttribute(RemoteConnectionsTRKHelper.CONNECTION_ATTRIBUTE, connection.getIdentifier());
   101 			config.setAttribute(RemoteConnectionsTRKHelper.CONNECTION_ATTRIBUTE, connection);
   102 		}
   102 		}
   103 	}
   103 	}
   104 
   104 
   105 	/*
   105 	/*
   106 	 * (non-Javadoc)
   106 	 * (non-Javadoc)
   108 	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
   108 	 * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration)
   109 	 */
   109 	 */
   110 	public boolean isValid(ILaunchConfiguration config) {
   110 	public boolean isValid(ILaunchConfiguration config) {
   111 		boolean result = super.isValid(config);
   111 		boolean result = super.isValid(config);
   112 		if (result) {
   112 		if (result) {
   113 			connection = clientSiteUI.getSelectedConnection();
   113 			IStatus status = clientSiteUI.getSelectionStatus();
   114 			if (connection == null) {
   114 			if (!status.isOK()) {
   115 				setErrorMessage(Messages.getString("AttachMainTab.NoConnectionError")); //$NON-NLS-1$
   115 				// unfortunately, no way to display a warning here...
   116 				result = false;
   116 				setErrorMessage(status.getMessage());
       
   117 				result = status.getSeverity() != IStatus.ERROR;
   117 			}
   118 			}
   118 		}
   119 		}
   119 		return result;
   120 		return result;
   120 	}
   121 	}
   121 
   122