# HG changeset patch # User dadubrow # Date 1263482024 21600 # Node ID 603d6ca035e89fa52e714397cd74cf8df2c17808 # Parent 751f5182b86614c7a962062d8c0109ffdb02bc14 updated set and reset current depending on ready state diff -r 751f5182b866 -r 603d6ca035e8 debuggercdi/com.nokia.carbide.trk.support/src/com/nokia/carbide/trk/support/status/ConnectionStatusReconciler.java --- a/debuggercdi/com.nokia.carbide.trk.support/src/com/nokia/carbide/trk/support/status/ConnectionStatusReconciler.java Wed Jan 13 11:51:07 2010 -0600 +++ b/debuggercdi/com.nokia.carbide.trk.support/src/com/nokia/carbide/trk/support/status/ConnectionStatusReconciler.java Thu Jan 14 09:13:44 2010 -0600 @@ -50,10 +50,15 @@ } public void connectionRemoved(IConnection connection) { + if (connection.equals(userSetCurrentConnection)) + userSetCurrentConnection = null; removeConnection(connection); } - public void currentConnectionSet(IConnection connection) {} + public void currentConnectionSet(IConnection connection) { + if (connection != null && !connection.equals(reconcilerSetCurrentConnection)) + userSetCurrentConnection = connection; + } } @@ -70,6 +75,8 @@ private IConnectionListener connectionListener; private List handledConnections; private ServiceStatusListener serviceStatusListener; + private IConnection reconcilerSetCurrentConnection; + private IConnection userSetCurrentConnection; private ConnectionStatusReconciler() { connectionListener = new ConnectionListener(); @@ -113,8 +120,24 @@ } private void reconcileAsCurrent(IConnection connection) { - if (canBeSetToCurrent(connection) && isReady(connection)) { - manager.setCurrentConnection(connection); + if (canBeSetToCurrent(connection)) { + if (isReady(connection)) { + reconcilerSetCurrentConnection = connection; + manager.setCurrentConnection(connection); + } + else if (isDynamic(connection) && connection.equals(manager.getCurrentConnection())) { // connection is NOT ready + manager.setCurrentConnection(userSetCurrentConnection); + } + else { + // look for some other existing connection that is ready + for (IConnection c : manager.getConnections()) { + if (canBeSetToCurrent(c) && isReady(c)) { + reconcilerSetCurrentConnection = connection; + manager.setCurrentConnection(connection); + break; + } + } + } } } @@ -228,7 +251,8 @@ if (connection instanceof IConnection2) { reconcileStatus((IConnection2) connection); } - reconcileAsCurrent(connection); + if (connection != null) + reconcileAsCurrent(connection); } }