debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/ui/StopModeMainTab.java
changeset 1702 c2c8b7393fe7
parent 273 c2533fd23253
child 1708 80696164153b
equal deleted inserted replaced
1697:51639112f4b2 1702:c2c8b7393fe7
    14 * Description: 
    14 * Description: 
    15 *
    15 *
    16 */
    16 */
    17 package com.nokia.cdt.internal.debug.launch.ui;
    17 package com.nokia.cdt.internal.debug.launch.ui;
    18 
    18 
       
    19 import org.eclipse.core.runtime.CoreException;
    19 import org.eclipse.debug.core.ILaunchConfiguration;
    20 import org.eclipse.debug.core.ILaunchConfiguration;
    20 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
    21 import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
    21 import org.eclipse.swt.SWT;
    22 import org.eclipse.swt.SWT;
    22 import org.eclipse.swt.layout.GridLayout;
    23 import org.eclipse.swt.layout.GridLayout;
    23 import org.eclipse.swt.widgets.Composite;
    24 import org.eclipse.swt.widgets.Composite;
    24 
    25 
       
    26 import com.freescale.cdt.debug.cw.core.RemoteConnectionsTRKHelper;
       
    27 import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
       
    28 import com.nokia.carbide.remoteconnections.interfaces.IClientServiceSiteUI2;
       
    29 import com.nokia.carbide.remoteconnections.interfaces.IClientServiceSiteUI2.IListener;
       
    30 import com.nokia.carbide.remoteconnections.interfaces.IConnection;
    25 import com.nokia.cdt.internal.debug.launch.LaunchPlugin;
    31 import com.nokia.cdt.internal.debug.launch.LaunchPlugin;
    26 
    32 
    27 public class StopModeMainTab extends CarbideMainTab {
    33 public class StopModeMainTab extends CarbideMainTab {
    28 
    34 
       
    35 	protected IClientServiceSiteUI2 clientSiteUI;
       
    36 	protected String connection;
    29 	
    37 	
    30 	public void createControl(Composite parent) {
    38 	public void createControl(Composite parent) {
    31 		Composite comp = new Composite(parent, SWT.NONE);
    39 		Composite comp = new Composite(parent, SWT.NONE);
    32 		setControl(comp);
    40 		setControl(comp);
    33 		
    41 		
    45 		fProgText.setToolTipText(Messages.getString("StopModeMainTab.1")); //$NON-NLS-1$
    53 		fProgText.setToolTipText(Messages.getString("StopModeMainTab.1")); //$NON-NLS-1$
    46 
    54 
    47 		fProjLabel.setToolTipText(Messages.getString("StopModeMainTab.2")); //$NON-NLS-1$
    55 		fProjLabel.setToolTipText(Messages.getString("StopModeMainTab.2")); //$NON-NLS-1$
    48 		fProjText.setToolTipText(Messages.getString("StopModeMainTab.2")); //$NON-NLS-1$
    56 		fProjText.setToolTipText(Messages.getString("StopModeMainTab.2")); //$NON-NLS-1$
    49 
    57 
       
    58 		clientSiteUI = RemoteConnectionsActivator.getConnectionsManager().getClientSiteUI2(LaunchPlugin.getPlatSimService());
       
    59 		clientSiteUI.createComposite(comp);
       
    60 		clientSiteUI.addListener(new IListener() {
       
    61 			public void connectionSelected() {
       
    62 				connection = clientSiteUI.getSelectedConnection();
       
    63 				updateLaunchConfigurationDialog();
       
    64 			}
       
    65 		});
       
    66 
    50 		createVerticalSpacer(comp, 1);
    67 		createVerticalSpacer(comp, 1);
    51 		if (wantsTerminalOption() /*&& ProcessFactory.supportesTerminal()*/) {
    68 		if (wantsTerminalOption() /*&& ProcessFactory.supportesTerminal()*/) {
    52 			createTerminalOption(comp, 1);
    69 			createTerminalOption(comp, 1);
    53 			createVerticalSpacer(comp, 1);
    70 			createVerticalSpacer(comp, 1);
    54 		}
    71 		}
    58 	public void setDefaults(ILaunchConfigurationWorkingCopy config) {
    75 	public void setDefaults(ILaunchConfigurationWorkingCopy config) {
    59 	}
    76 	}
    60 
    77 
    61 	public void initializeFrom(ILaunchConfiguration config) {
    78 	public void initializeFrom(ILaunchConfiguration config) {
    62 		super.initializeFrom(config);
    79 		super.initializeFrom(config);
       
    80 
       
    81 		// if a PlatSim stop mode launch does not have a connection,
       
    82 		// it may need to be converted to have a connection
       
    83 		try {
       
    84 			connection = RemoteConnectionsTRKHelper.getConnectionIdFromConfig(config);
       
    85 		} catch (CoreException e) {
       
    86 		}
       
    87 		
       
    88 		if (connection == null && config instanceof ILaunchConfigurationWorkingCopy) {
       
    89 			String location = null;
       
    90 			String instanceId = null;
       
    91 			try {
       
    92 				// for new launches, the remote connection holds the location and instance
       
    93 				// we can use "1" as the default PlatSim instanceId, but we won't create a new
       
    94 				// connection if we do not have a PlatSim_Location attribute
       
    95 				location = config.getAttribute("com.nokia.cdt.debug.launch.PlatSim_Location", (String) null);
       
    96 				instanceId = config.getAttribute("com.nokia.cdt.debug.launch.PlatSim_Instance_Id", "1");
       
    97 			} catch (CoreException ce) {
       
    98 				LaunchPlugin.log(ce);
       
    99 			}
       
   100 
       
   101 			if (location != null && location.length() > 0) {
       
   102 
       
   103 				ILaunchConfigurationWorkingCopy wcConfig = (ILaunchConfigurationWorkingCopy)config;
       
   104 				
       
   105 				// if an existing PlatSim connection matches, then use it
       
   106 				// if no connection matches, then create a new one
       
   107 				IConnection connectionToUse = RemoteConnectionsTRKHelper.findOrCreatePlatSimConnection(location, instanceId);
       
   108 				connection = connectionToUse.getIdentifier();
       
   109 				if (connection != null) {
       
   110 					wcConfig.setAttribute(RemoteConnectionsTRKHelper.CONNECTION_ATTRIBUTE, connection);
       
   111 				}		
       
   112 			}
       
   113 		}
       
   114 		 
       
   115 		if (clientSiteUI != null)
       
   116 		{
       
   117 			if (connection != null)
       
   118 				clientSiteUI.selectConnection(connection);
       
   119 			else {
       
   120 				connection = clientSiteUI.getSelectedConnection();
       
   121 			}
       
   122 		}
    63 	}
   123 	}
    64 
   124 
    65 	public void performApply(ILaunchConfigurationWorkingCopy config) {
   125 	public void performApply(ILaunchConfigurationWorkingCopy config) {
    66 		super.performApply(config);
   126 		super.performApply(config);
       
   127 		if (connection != null) {
       
   128 			config.setAttribute(RemoteConnectionsTRKHelper.CONNECTION_ATTRIBUTE, connection);
       
   129 		}		
    67 	}
   130 	}
    68 
   131 
    69 	/*
   132 	/*
    70 	 * (non-Javadoc)
   133 	 * (non-Javadoc)
    71 	 * 
   134 	 *