merge commit RCL_2_4
authortimkelly
Fri, 23 Apr 2010 11:37:46 -0500
branchRCL_2_4
changeset 1269 6cad88a59c38
parent 1268 75a3be8a0480 (current diff)
parent 1263 1bbab141155c (diff)
child 1271 6a0e8b610695
merge commit
--- a/connectivity/com.nokia.carbide.remoteConnections/META-INF/MANIFEST.MF	Fri Apr 23 11:36:29 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/META-INF/MANIFEST.MF	Fri Apr 23 11:37:46 2010 -0500
@@ -21,7 +21,7 @@
  com.nokia.carbide.remoteconnections.interfaces,
  com.nokia.carbide.remoteconnections.internal.api,
  com.nokia.carbide.remoteconnections.internal.registry;x-friends:="com.nokia.carbide.remoteConnections.tests,com.nokia.carbide.tests.debug",
- com.nokia.carbide.remoteconnections.settings.ui;x-friends:="com.nokia.carbide.tests.debug"
+ com.nokia.carbide.remoteconnections.settings.ui;x-friends:="com.nokia.carbide.tests.debug,com.nokia.cdt.debug.launch"
 Bundle-ClassPath: .,
  lib/commons-codec-1.3.jar,
  lib/commons-httpclient-3.1.jar,
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ServiceTester.java	Fri Apr 23 11:36:29 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ServiceTester.java	Fri Apr 23 11:37:46 2010 -0500
@@ -18,6 +18,7 @@
 package com.nokia.carbide.remoteconnections.internal;
 
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -89,13 +90,15 @@
 	}
 	
 	private ServiceTester() {
-		registry = new HashSet<AbstractConnectedService2>();
+		registry = Collections.synchronizedSet(new HashSet<AbstractConnectedService2>());
 		runningThreads = new HashSet<TestRunner>();
 		Thread t = new Thread(new Runnable() {
 			public void run() {
 				while (true) {
-					Collection<Set<AbstractConnectedService2>> csSetsByResource = 
-						createConnectedServiceSetsByResource(new HashSet<AbstractConnectedService2>(registry));
+					Collection<Set<AbstractConnectedService2>> csSetsByResource;
+					synchronized (registry) {
+						csSetsByResource = createConnectedServiceSetsByResource(new HashSet<AbstractConnectedService2>(registry));
+					}
 					for (Set<AbstractConnectedService2> set : csSetsByResource) {
 						Collection<Set<AbstractConnectedService2>> csSetsByService = 
 							createConnectedServiceSetsByService(set);
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/registry/Registry.java	Fri Apr 23 11:36:29 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/registry/Registry.java	Fri Apr 23 11:37:46 2010 -0500
@@ -41,14 +41,9 @@
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IMessageProvider;
 import org.eclipse.jface.dialogs.TitleAreaDialog;
 import org.eclipse.jface.viewers.IFilter;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
 
 import com.nokia.carbide.remoteconnections.Messages;
 import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
@@ -63,13 +58,13 @@
 import com.nokia.carbide.remoteconnections.interfaces.IExtensionFilter;
 import com.nokia.carbide.remoteconnections.interfaces.IService;
 import com.nokia.carbide.remoteconnections.interfaces.AbstractConnection.ConnectionStatus;
-import com.nokia.carbide.remoteconnections.interfaces.IClientServiceSiteUI2.IListener;
 import com.nokia.carbide.remoteconnections.internal.api.IConnection2;
 import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatus;
 import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatusChangedListener;
 import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatus.EConnectionStatus;
 import com.nokia.carbide.remoteconnections.internal.ui.ClientServiceSiteUI2;
 import com.nokia.carbide.remoteconnections.internal.ui.ConnectionUIUtils;
+import com.nokia.carbide.remoteconnections.internal.ui.SelectConnectionDialog;
 import com.nokia.carbide.remoteconnections.ui.ClientServiceSiteUI;
 import com.nokia.cpp.internal.api.utils.core.Check;
 import com.nokia.cpp.internal.api.utils.core.ListenerList;
@@ -93,6 +88,8 @@
 	// this is exposed to other clients inside this plugin but it is not public knowledge
 	public static final String CURRENT_CONNECTION_ID = RemoteConnectionsActivator.PLUGIN_ID + ".currentConnection"; //$NON-NLS-1$
 	
+	private static final String LAST_CONNECTION_ID = "last_connection_id"; //$NON-NLS-1$
+	
 	private static Registry instance = new Registry();
 	
 	private List<IExtensionFilter> extensionFilters;
@@ -335,6 +332,8 @@
 		connectionToConnectedServices.put(connection, connectedServices);
 		fireConnectionStoreChanged();
 		fireConnectionAdded(connection);
+		
+		setLastConnectionId(connection.getIdentifier());
 	}
 	
 	private void ensureUniqueId(IConnection connection) {
@@ -524,7 +523,7 @@
 			connectionHolder[0] = getCompatibleConnectionFromUser(service, storableIdHolder);
 			if (connectionHolder[0] == null) {
 				throw new CoreException(
-						Logging.newStatus(RemoteConnectionsActivator.getDefault(), IStatus.ERROR, 
+						Logging.newStatus(RemoteConnectionsActivator.getDefault(), IStatus.CANCEL, 
 								Messages.getString("Registry.NoCompatibleConnectionMsg"))); //$NON-NLS-1$
 			}
 			else if (wasCurrentConnection && !connectionHolder[0].getIdentifier().equals(CURRENT_CONNECTION_ID)) {
@@ -548,60 +547,11 @@
 		if (!WorkbenchUtils.isJUnitRunning()) {
 			Display.getDefault().syncExec(new Runnable() {
 				public void run() {
+					// First, see if any connections could possibly be selected.
+					// If not, immediately offer to create a new connection.
+					
 					final IClientServiceSiteUI2 ui = getClientSiteUI2(service);
-					final TitleAreaDialog dialog = new TitleAreaDialog(WorkbenchUtils.getSafeShell()) {
-						@Override
-						protected Control createDialogArea(Composite parent) {
-							final Composite c = (Composite) super.createDialogArea(parent);
-							ui.createComposite(c);
-							ui.addListener(new IListener() {
-								public void connectionSelected() {
-									updateStatus(ui.getSelectionStatus());
-								}
-
-							});
-							
-							return c;
-						}
-
-						private void updateStatus(IStatus selectionStatus) {
-							setTitle(Messages.getString("Registry.EnsureConnection.TitleLabel")); //$NON-NLS-1$
-							setMessage(Messages.getString("Registry.EnsureConnection.Description")); //$NON-NLS-1$
-							switch (selectionStatus.getSeverity()) {
-							case IStatus.ERROR:
-								setMessage(selectionStatus.getMessage(), IMessageProvider.ERROR);
-								getButton(IDialogConstants.OK_ID).setEnabled(false);
-								break;
-							case IStatus.WARNING:
-								setMessage(selectionStatus.getMessage(), IMessageProvider.WARNING);
-								getButton(IDialogConstants.OK_ID).setEnabled(true);
-								break;
-							case IStatus.INFO:
-								setMessage(selectionStatus.getMessage(), IMessageProvider.INFORMATION);
-								getButton(IDialogConstants.OK_ID).setEnabled(true);
-								break;
-							default:
-								getButton(IDialogConstants.OK_ID).setEnabled(true);
-							}
-						}
-						
-						@Override
-						public void create() {
-							super.create();
-							updateStatus(ui.getSelectionStatus());
-						}
-						
-						@Override
-						protected void configureShell(Shell newShell) {
-							super.configureShell(newShell);
-							newShell.setText(Messages.getString("Registry.EnsureConnection.DialogTitle")); //$NON-NLS-1$
-						}
-						
-						@Override
-						protected boolean isResizable() {
-							return true;
-						}
-					};
+					final TitleAreaDialog dialog = new SelectConnectionDialog(WorkbenchUtils.getSafeShell(), ui);
 					dialog.setBlockOnOpen(true);
 					if (dialog.open() == Dialog.OK) {
 						storableIdHolder[0] = ui.getSelectedConnection();
@@ -700,4 +650,25 @@
 		
 		return false;
 	}
+
+	/**
+	 * Internal method:  get the last id of a connection created or selected in UI.  
+	 * Used to prepopulate UI for selecting connections.
+	 * @return connection id (not "current") or <code>null</code>
+	 */
+	public String getLastConnectionId() {
+		return RemoteConnectionsActivator.getDefault().getPreferenceStore().getString(LAST_CONNECTION_ID);
+	}
+	
+	/**
+	 * Internal method:  remember the last id of a connection created or selected in UI.  
+	 * @param id connection id.  Current connection is converted to an actual connection id.
+	 */
+	public void setLastConnectionId(String id) {
+		if (CURRENT_CONNECTION_ID.equals(id)) 
+			id = currentConnection != null ? currentConnection.getIdentifier() : null;
+		if (id == null) 
+			return;
+		RemoteConnectionsActivator.getDefault().getPreferenceStore().setValue(LAST_CONNECTION_ID, id);
+	}
 }
\ No newline at end of file
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ClientServiceSiteUI2.java	Fri Apr 23 11:36:29 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ClientServiceSiteUI2.java	Fri Apr 23 11:37:46 2010 -0500
@@ -223,8 +223,13 @@
 		else {
 			viewer.getCombo().setEnabled(true);
 			if (connection == null) {
-				viewer.getCombo().select(0);
-				viewer.setSelection(viewer.getSelection());
+				String lastConnectionId = Registry.instance().getLastConnectionId();
+				if (lastConnectionId != null) {
+					selectConnection(lastConnectionId);
+				} else {
+					viewer.getCombo().select(0);
+					viewer.setSelection(viewer.getSelection());
+				}
 			}
 			else
 				selectConnection(connection.getIdentifier());
@@ -304,6 +309,7 @@
 	}
 	
 	public String getSelectedConnection() {
+		Registry.instance().setLastConnectionId(connection);
 		return connection;
 	}
 	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/SelectConnectionDialog.java	Fri Apr 23 11:37:46 2010 -0500
@@ -0,0 +1,90 @@
+package com.nokia.carbide.remoteconnections.internal.ui;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+import com.nokia.carbide.remoteconnections.Messages;
+import com.nokia.carbide.remoteconnections.interfaces.IClientServiceSiteUI2;
+import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager;
+import com.nokia.carbide.remoteconnections.interfaces.IClientServiceSiteUI2.IListener;
+
+/**
+ * Dialog for selecting a connection (via {@link IConnectionsManager#ensureConnection(String, com.nokia.carbide.remoteconnections.interfaces.IService)}.
+ */
+public class SelectConnectionDialog extends TitleAreaDialog {
+	/**
+	 * 
+	 */
+	private final IClientServiceSiteUI2 ui;
+
+	/**
+	 * @param parentShell
+	 * @param ui
+	 */
+	public SelectConnectionDialog(Shell parentShell,
+			IClientServiceSiteUI2 ui) {
+		super(parentShell);
+		this.ui = ui;
+	}
+
+	@Override
+	protected Control createDialogArea(Composite parent) {
+		final Composite c = (Composite) super.createDialogArea(parent);
+		GridLayout layout = (GridLayout) c.getLayout();
+		layout.marginWidth = 6;
+		layout.marginHeight = 6;
+		ui.createComposite(c);
+		ui.addListener(new IListener() {
+			public void connectionSelected() {
+				updateStatus(ui.getSelectionStatus());
+			}
+
+		});
+		
+		return c;
+	}
+
+	private void updateStatus(IStatus selectionStatus) {
+		setTitle(Messages.getString("SelectConnectionDialog.TitleLabel")); //$NON-NLS-1$
+		setMessage(Messages.getString("SelectConnectionDialog.Description")); //$NON-NLS-1$
+		switch (selectionStatus.getSeverity()) {
+		case IStatus.ERROR:
+			setMessage(selectionStatus.getMessage(), IMessageProvider.ERROR);
+			getButton(IDialogConstants.OK_ID).setEnabled(false);
+			break;
+		case IStatus.WARNING:
+			setMessage(selectionStatus.getMessage(), IMessageProvider.WARNING);
+			getButton(IDialogConstants.OK_ID).setEnabled(true);
+			break;
+		case IStatus.INFO:
+			setMessage(selectionStatus.getMessage(), IMessageProvider.INFORMATION);
+			getButton(IDialogConstants.OK_ID).setEnabled(true);
+			break;
+		default:
+			getButton(IDialogConstants.OK_ID).setEnabled(true);
+		}
+	}
+
+	@Override
+	public void create() {
+		super.create();
+		updateStatus(ui.getSelectionStatus());
+	}
+
+	@Override
+	protected void configureShell(Shell newShell) {
+		super.configureShell(newShell);
+		newShell.setText(Messages.getString("SelectConnectionDialog.DialogTitle")); //$NON-NLS-1$
+	}
+
+	@Override
+	protected boolean isResizable() {
+		return true;
+	}
+}
\ No newline at end of file
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/messages.properties	Fri Apr 23 11:36:29 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/messages.properties	Fri Apr 23 11:37:46 2010 -0500
@@ -121,9 +121,9 @@
 Registry.ConnectionStoreError=Could not store connections
 Registry.FilterExtensionLoadError=Could not load filter extensions
 Registry.ConnectionTypeExtensionLoadError=Could not load connection type extensions
-Registry.EnsureConnection.DialogTitle=Invalid Connection Stored
-Registry.EnsureConnection.TitleLabel=Select a connection to use
-Registry.EnsureConnection.Description=Select a connection, create a new one or attach a device
+SelectConnectionDialog.DialogTitle=Select Connection
+SelectConnectionDialog.TitleLabel=Select a connection to use
+SelectConnectionDialog.Description=Select a connection, create a new one or attach a device
 Registry.NoCompatibleConnectionMsg=No compatible connection found for this id
 Registry.ServiceExtensionLoadError=Could not load service extensions
 Registry.ServiceListUnknownConnectionTypeError=Service ''{0}'' lists unknown connection type ''{1}'' as compatible
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/view/ConnectionsView.java	Fri Apr 23 11:36:29 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/view/ConnectionsView.java	Fri Apr 23 11:37:46 2010 -0500
@@ -87,6 +87,7 @@
 import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionsManagerListener;
 import com.nokia.carbide.remoteconnections.internal.api.IConnection2;
 import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatus;
+import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatusChangedListener;
 import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatus.EConnectionStatus;
 import com.nokia.carbide.remoteconnections.internal.registry.Registry;
 import com.nokia.carbide.remoteconnections.internal.ui.ConnectionUIUtils;
@@ -106,6 +107,7 @@
 	private IConnectionsManagerListener connectionStoreChangedListener;
 	private IConnectionListener connectionListener;
 	private Map<IConnectedService, IStatusChangedListener> serviceToListenerMap;
+	private Map<IConnection2, IConnectionStatusChangedListener> connectionToListenerMap;
 	private List<Action> actions;
 	private List<Action> connectionSelectedActions;
 	private List<Action> serviceSelectedActions;
@@ -133,11 +135,24 @@
 	private TreeNode[] loadConnections() {
 		if (serviceToListenerMap == null)
 			serviceToListenerMap = new HashMap<IConnectedService, IStatusChangedListener>();
-		removeServiceListeners();
+		if (connectionToListenerMap == null)
+			connectionToListenerMap = new HashMap<IConnection2, IConnectionStatusChangedListener>();
+		removeStatusListeners();
 		List<TreeNode> connectionNodes = new ArrayList<TreeNode>();
 		Collection<IConnection> connections = 
 			Registry.instance().getConnections();
 		for (IConnection connection : connections) {
+			if (connection instanceof IConnection2) {
+				IConnectionStatusChangedListener statusChangedListener = 
+					new IConnectionStatusChangedListener() {
+						public void statusChanged(IConnectionStatus status) {
+							handleStatusChanged();
+						}
+					};
+				IConnection2 connection2 = (IConnection2) connection;
+				connection2.addStatusChangedListener(statusChangedListener);
+				connectionToListenerMap.put(connection2, statusChangedListener);
+			}
 			// create a node for the connection
 			TreeNode connectionNode = new TreeNode(connection);
 			// create subnodes for the connected services
@@ -148,14 +163,7 @@
 				final TreeNode treeNode = new TreeNode(connectedService);
 				IStatusChangedListener statusChangedListener = new IStatusChangedListener() {
 					public void statusChanged(final IStatus status) {
-						Display.getDefault().asyncExec(new Runnable() {
-							public void run() {
-								if (!isDisposed) {
-									viewer.refresh(true);
-									packColumns();
-								}
-							}
-						});
+						handleStatusChanged();
 					}
 				};
 				connectedService.addStatusChangedListener(statusChangedListener);
@@ -173,6 +181,17 @@
 		return (TreeNode[]) connectionNodes.toArray(new TreeNode[connectionNodes.size()]);
 	}
 
+	private void handleStatusChanged() {
+		Display.getDefault().asyncExec(new Runnable() {
+			public void run() {
+				if (!isDisposed) {
+					viewer.refresh(true);
+					packColumns();
+				}
+			}
+		});
+	}
+
 	private class NameEditingSupport extends EditingSupport {
 		private TextCellEditor editor;
 
@@ -852,12 +871,17 @@
 		viewer.getControl().setFocus();
 	}
 	
-	private void removeServiceListeners() {
+	private void removeStatusListeners() {
 		for (IConnectedService connectedService : serviceToListenerMap.keySet()) {
 			IStatusChangedListener listener = serviceToListenerMap.get(connectedService);
 			connectedService.removeStatusChangedListener(listener);
 		}
 		serviceToListenerMap.clear();
+		for (IConnection2 connection : connectionToListenerMap.keySet()) {
+			IConnectionStatusChangedListener listener = connectionToListenerMap.get(connection);
+			connection.removeStatusChangedListener(listener);
+		}
+		connectionToListenerMap.clear();
 	}
 	
 	private void disableAllConnectedServices() {
@@ -874,7 +898,7 @@
 	
 	@Override
 	public void dispose() {
-		removeServiceListeners();
+		removeStatusListeners();
 		Registry.instance().removeConnectionStoreChangedListener(connectionStoreChangedListener);
 		Registry.instance().removeConnectionListener(connectionListener);
 		disableAllConnectedServices();
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceDialog.java	Fri Apr 23 11:36:29 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceDialog.java	Fri Apr 23 11:37:46 2010 -0500
@@ -70,7 +70,6 @@
 /**
  *	This dialog allows in-depth configuration of the connection settings.
  */
-@SuppressWarnings("restriction")
 public class ConnectToDeviceDialog extends AbstractLaunchSettingsDialog implements IConnectionListener, IStatusChangedListener {
 	private IConnectionsManager manager;
 	private IConnectionTypeProvider typeProvider;
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceSection.java	Fri Apr 23 11:36:29 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/ConnectToDeviceSection.java	Fri Apr 23 11:37:46 2010 -0500
@@ -1,137 +1,148 @@
-/*
-* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of the License "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
-
-package com.nokia.cdt.internal.debug.launch.newwizard;
-
-import java.text.MessageFormat;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
-import com.nokia.carbide.remoteconnections.interfaces.IConnection;
-import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager;
-import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionListener;
-
-/**
- * Present the "Connect to device" section with a short description.
- */
-public class ConnectToDeviceSection extends AbstractLaunchWizardSection implements IConnectionListener {
-
-	private static final String NO_CURRENT_CONNECTION_MSG = Messages.getString("ConnectToDeviceSection.NoConnectionMsg"); //$NON-NLS-1$
-	private final IConnectionsManager manager;
-
-	/**
-	 * @param unifiedLaunchOptionsPage 
-	 * 
-	 */
-	public ConnectToDeviceSection(LaunchWizardData data, UnifiedLaunchOptionsPage launchOptionsPage) {
-		super(data, Messages.getString("ConnectToDeviceSection.Title"), launchOptionsPage); //$NON-NLS-1$
-		manager = RemoteConnectionsActivator.getConnectionsManager();
-	}
-	
-	public void createControl(Composite parent) {
-		createSection(parent, 0);
-		manager.addConnectionListener(this);
-	}
-	
-	@Override
-	protected void dispose() {
-		manager.removeConnectionListener(this);
-	}
-	
-	public void initializeSettings() {
-		data.setConnection(manager.getCurrentConnection());
-	}
-
-	@Override
-	protected void validate() {
-		status = revalidate(data);
-	}
-
-	/** Get the simple status for the connection state */
-	static IStatus revalidate(LaunchWizardData data) {
-		IStatus status = Status.OK_STATUS;
-		
-		if (data.getConnection() == null) {
-			status = error(NO_CURRENT_CONNECTION_MSG);
-		}
-		
-		return status;
-	}
-	
-	static String getStandardPNPMessage() {
-		return Messages.getString("ConnectToDeviceSection.StdPNPMsg"); //$NON-NLS-1$
-	}
-
-	@Override
-	protected void updateUI() {
-		if (control == null || control.isDisposed())
-			return;
-		
-		String msg;
-		if (data.getConnection() != null)
-			msg = MessageFormat.format(Messages.getString("ConnectToDeviceSection.CurrentConnectionLabel"), data.getConnectionName()); //$NON-NLS-1$
-		else
-			msg = MessageFormat.format("{0} {1}", NO_CURRENT_CONNECTION_MSG, getStandardPNPMessage()); //$NON-NLS-1$
-			
-		descriptionLabel.setText(msg);
-		launchOptionsPage.changed();
-	}
-	
-	@Override
-	protected AbstractLaunchSettingsDialog createChangeSettingsDialog(Shell shell, LaunchWizardData dialogData) {
-		return new ConnectToDeviceDialog(shell, dialogData);
-	}
-	
-	protected void refresh() {
-		Display.getDefault().syncExec(new Runnable() {
-			public void run() {
-				validate();
-				updateUI();
-			}
-		});
-	}
-	
-	private void doConnectionsChanged() {
-		data.setConnection(manager.getCurrentConnection());
-		refresh();
-	}
-	
-	public void connectionAdded(IConnection connection) {
-		doConnectionsChanged();
-	}
-	
-	public void connectionRemoved(IConnection connection) {
-		doConnectionsChanged();
-	}
-	
-	public void currentConnectionSet(IConnection connection) {
-		doConnectionsChanged();
-	}
-	
-	@Override
-	protected void doChange() {
-		super.doChange();
-		IConnection connection = data.getConnection();
-		if (connection != null && !connection.equals(manager.getCurrentConnection()))
-			manager.setCurrentConnection(connection);
-	}
-}
+/*
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: 
+*
+*/
+
+package com.nokia.cdt.internal.debug.launch.newwizard;
+
+import java.text.MessageFormat;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
+import com.nokia.carbide.remoteconnections.interfaces.IConnection;
+import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager;
+import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionListener;
+import com.nokia.carbide.remoteconnections.settings.ui.SettingsWizard;
+
+/**
+ * Present the "Connect to device" section with a short description.
+ */
+public class ConnectToDeviceSection extends AbstractLaunchWizardSection implements IConnectionListener {
+
+	private static final String NO_CURRENT_CONNECTION_MSG = Messages.getString("ConnectToDeviceSection.NoConnectionMsg"); //$NON-NLS-1$
+	private final IConnectionsManager manager;
+
+	/**
+	 * @param unifiedLaunchOptionsPage 
+	 * 
+	 */
+	public ConnectToDeviceSection(LaunchWizardData data, UnifiedLaunchOptionsPage launchOptionsPage) {
+		super(data, Messages.getString("ConnectToDeviceSection.Title"), launchOptionsPage); //$NON-NLS-1$
+		manager = RemoteConnectionsActivator.getConnectionsManager();
+	}
+	
+	public void createControl(Composite parent) {
+		createSection(parent, 0);
+		manager.addConnectionListener(this);
+	}
+	
+	@Override
+	protected void dispose() {
+		manager.removeConnectionListener(this);
+	}
+	
+	public void initializeSettings() {
+		data.setConnection(manager.getCurrentConnection());
+	}
+
+	@Override
+	protected void validate() {
+		status = revalidate(data);
+	}
+
+	/** Get the simple status for the connection state */
+	static IStatus revalidate(LaunchWizardData data) {
+		IStatus status = Status.OK_STATUS;
+		
+		if (data.getConnection() == null) {
+			status = error(NO_CURRENT_CONNECTION_MSG);
+		}
+		
+		return status;
+	}
+	
+	static String getStandardPNPMessage() {
+		return Messages.getString("ConnectToDeviceSection.StdPNPMsg"); //$NON-NLS-1$
+	}
+
+	@Override
+	protected void updateUI() {
+		if (control == null || control.isDisposed())
+			return;
+		
+		String msg;
+		if (data.getConnection() != null)
+			msg = MessageFormat.format(Messages.getString("ConnectToDeviceSection.CurrentConnectionLabel"), data.getConnectionName()); //$NON-NLS-1$
+		else
+			msg = MessageFormat.format("{0} {1}", NO_CURRENT_CONNECTION_MSG, getStandardPNPMessage()); //$NON-NLS-1$
+			
+		descriptionLabel.setText(msg);
+		launchOptionsPage.changed();
+	}
+	
+	@Override
+	protected AbstractLaunchSettingsDialog createChangeSettingsDialog(Shell shell, LaunchWizardData dialogData) {
+		return new ConnectToDeviceDialog(shell, dialogData);
+	}
+	
+	protected void refresh() {
+		Display.getDefault().syncExec(new Runnable() {
+			public void run() {
+				validate();
+				updateUI();
+			}
+		});
+	}
+	
+	private void doConnectionsChanged() {
+		data.setConnection(manager.getCurrentConnection());
+		refresh();
+	}
+	
+	public void connectionAdded(IConnection connection) {
+		doConnectionsChanged();
+	}
+	
+	public void connectionRemoved(IConnection connection) {
+		doConnectionsChanged();
+	}
+	
+	public void currentConnectionSet(IConnection connection) {
+		doConnectionsChanged();
+	}
+	
+	@Override
+	protected void doChange() {
+		// if no connections are available, immediately offer to create a connection
+		
+		if (manager.getConnections().isEmpty()) {
+			SettingsWizard wizard = new SettingsWizard(null, data.getService());
+			wizard.open(getControl().getShell());
+			IConnection newConnection = wizard.getConnectionToEdit();
+			data.setConnection(newConnection);
+		} else {
+			super.doChange();
+		}
+		
+		IConnection connection = data.getConnection();
+		if (connection != null && !connection.equals(manager.getCurrentConnection()))
+			manager.setCurrentConnection(connection);
+	}
+}
--- a/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/UnifiedLaunchOptionsPage.java	Fri Apr 23 11:36:29 2010 -0500
+++ b/debuggercdi/com.nokia.cdt.debug.launch/src/com/nokia/cdt/internal/debug/launch/newwizard/UnifiedLaunchOptionsPage.java	Fri Apr 23 11:37:46 2010 -0500
@@ -45,8 +45,11 @@
  * allowing selecting different process to launch, and a button allowing more
  * in-depth configuration.
  * <p>
- * Build before debug: section with the build-before-debug preference for this
+ * Other settings: section with (currently only) the build-before-debug preference for this
  * launch configuration.
+ * <p>
+ * Each section is validated separately and editable with its own dialog.  Changes in
+ * the dialog are not applied until the dialog is accepted.
  */
 public class UnifiedLaunchOptionsPage extends WizardPage implements ISectionChangeListener {