honor current connection id in ensureConnection RCL_2_4
authordadubrow
Thu, 11 Feb 2010 13:39:38 -0600
branchRCL_2_4
changeset 937 c2a0b0241151
parent 933 62a61caee614
child 940 949823a0e5df
honor current connection id in ensureConnection
connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/registry/Registry.java
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/registry/Registry.java	Thu Feb 11 11:48:46 2010 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/registry/Registry.java	Thu Feb 11 13:39:38 2010 -0600
@@ -517,6 +517,7 @@
 	
 	public ISelectedConnectionInfo ensureConnection(String id, IService service) throws CoreException {
 		Check.checkArg(service);
+		final boolean wasCurrentConnection = id.equals(CURRENT_CONNECTION_ID);
 		final IConnection[] connectionHolder = { findConnection(id) };
 		final String[] storableIdHolder = { id };
 		if (!isCompatibleConnection(connectionHolder[0], service)) {
@@ -526,6 +527,10 @@
 						Logging.newStatus(RemoteConnectionsActivator.getDefault(), IStatus.ERROR, 
 								Messages.getString("Registry.NoCompatibleConnectionMsg"))); //$NON-NLS-1$
 			}
+			else if (wasCurrentConnection && !connectionHolder[0].getIdentifier().equals(CURRENT_CONNECTION_ID)) {
+				setCurrentConnection(connectionHolder[0]);
+				storableIdHolder[0] = CURRENT_CONNECTION_ID;
+			}
 		}
 		return new ISelectedConnectionInfo() {
 			public String getStorableId() {