Show in-use/not-in-use connection status icon, until real IConnectedStatus is available.
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ConnectionStatusSelectorContribution.java Fri Dec 18 14:48:52 2009 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ConnectionStatusSelectorContribution.java Fri Dec 18 15:05:20 2009 -0600
@@ -130,7 +130,7 @@
* @see com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatusChangedListener#statusChanged(com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus)
*/
public void statusChanged(IStatus status) {
- updateUI();
+ updateConnectionStatus(null);
}
/* (non-Javadoc)
@@ -274,8 +274,13 @@
statusString = status.getDescription();
}
- if (TextUtils.isEmpty(statusString))
- statusString = Messages.getString("ConnectionStatusSelectorContribution.NotInUse"); //$NON-NLS-1$
+ if (TextUtils.isEmpty(statusString)) {
+ // fallback string; the status should not be empty
+ if (ConnectionUIUtils.isSomeServiceInUse(defaultConnection))
+ statusString = Messages.getString("ConnectionStatusSelectorContribution.InUse"); //$NON-NLS-1$
+ else
+ statusString = Messages.getString("ConnectionStatusSelectorContribution.NotInUse"); //$NON-NLS-1$
+ }
return MessageFormat.format(Messages.getString("ConnectionStatusSelectorContribution.ConnectionStatusFormat"), defaultConnection.getDisplayName(), statusString); //$NON-NLS-1$
}
@@ -377,10 +382,23 @@
/**
* @param status
*/
- private void updateConnectionStatus(IConnectionStatus status) {
- Image statusImage = ConnectionUIUtils.getConnectionStatusImage(status);
- connectionInfo.setImage(statusImage);
- connectionInfo.setToolTipText(createConnectionStatusTooltip(defaultConnection, status));
+ private void updateConnectionStatus(final IConnectionStatus status) {
+ Display.getDefault().syncExec(new Runnable() {
+ public void run() {
+ if (connectionInfo.isDisposed())
+ return;
+
+ Image statusImage;
+ if (status != null)
+ statusImage = ConnectionUIUtils.getConnectionStatusImage(status);
+ else
+ statusImage = ConnectionUIUtils.getConnectionImage(defaultConnection);
+
+ connectionInfo.setImage(statusImage);
+ connectionInfo.setToolTipText(createConnectionStatusTooltip(defaultConnection, status));
+ }
+ });
+
}
/**
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ConnectionUIUtils.java Fri Dec 18 14:48:52 2009 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ConnectionUIUtils.java Fri Dec 18 15:05:20 2009 -0600
@@ -106,10 +106,15 @@
* @return Image, not to be disposed
*/
public static Image getConnectionImage(IConnection connection) {
+ // TODO: remove this when we have real statuses from a connection
+ if (isSomeServiceInUse(connection)) {
+ return ConnectionUIUtils.STATUS_INUSE_IMG;
+ }
if (connection instanceof IConnection2) {
IConnectionStatus status = ((IConnection2) connection).getStatus();
return getConnectionStatusImage(status);
} else {
+ // old connection logic
if (isSomeServiceInUse(connection)) {
return ConnectionUIUtils.STATUS_INUSE_IMG;
}
@@ -139,6 +144,9 @@
Collection<IConnectedService> connectedServices =
Registry.instance().getConnectedServices(connection);
// if any service is in-use, then connection is in-use
+ if (connectedServices == null)
+ return null;
+
for (IConnectedService connectedService : connectedServices) {
IStatus status = connectedService.getStatus();
if (status.getEStatus().equals(EStatus.IN_USE))
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/messages.properties Fri Dec 18 14:48:52 2009 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/messages.properties Fri Dec 18 15:05:20 2009 -0600
@@ -57,6 +57,7 @@
ConnectionStatusSelectorContribution_NoDefaultConnectionMessage=No default connection
ConnectionStatusSelectorContribution_SelectTheDefaultConnectionMessage=Select the default connection:
ConnectionStatusSelectorContribution.ConnectionStatusFormat={0}: {1}
+ConnectionStatusSelectorContribution.InUse=In use
ConnectionStatusSelectorContribution.NoConnectionsDefinedOrDetected=No connections defined or detected
ConnectionStatusSelectorContribution.NoDynamicOrManualConnectionsTooltip=No default connection selected.
ConnectionStatusSelectorContribution.NotInUse=Not in use