Allow a null IService to be passed to IConnectionsManager#ensureConnection(), for cases where the service is not known or restricting connections by service is not needed.
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/IConnectionsManager.java Tue Jun 29 15:14:38 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/IConnectionsManager.java Tue Jun 29 18:12:13 2010 -0500
@@ -177,11 +177,13 @@
IConnection getCurrentConnection();
/**
- * Returns the IClientServiceSiteUI2 for a service. Filters connection types to those that
- * are supported by the service. Connection list UI as well as new and edit wizards are filtered.
+ * Returns the IClientServiceSiteUI2 for selecting a connection.
* Allows selecting a "current" connection which maps to #getCurrentConnection()
- * when you use #ensureConenction().
- * @param service IService
+ * when you use #ensureConnection().
+ * <p>
+ * Optionally filters connection types to those that are supported by the
+ * service. Connection list UI as well as new and edit wizards are filtered.
+ * @param service IService or <code>null</code>
* @return IClientServiceSiteUI2
* @since 2.5
*/
@@ -189,7 +191,7 @@
/**
* Can be called by specific service implementors (e.g., debugger) to ensure some connection
- * exists and supports this service. If the connection does not exist or does not support
+ * exists and optionally supports this service. If the connection does not exist or does not support
* the service, a CoreException may be thrown after the framework attempts to allow the user
* to correct the situation by showing a connection selection dialog.
* If an ISelectedConnectionInfo is returned, {@link ISelectedConnectionInfo#getConnection()}
@@ -197,7 +199,7 @@
* and {@link ISelectedConnectionInfo#getStorableId()} is the id that can
* be stored by the caller that represents the user's selection.
* @param connectionId String
- * @param service IService
+ * @param service IService or <code>null</code>
* @return ISelectedConnectionInfo
* @throws CoreException
* @since 2.5
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/registry/Registry.java Tue Jun 29 15:14:38 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/registry/Registry.java Tue Jun 29 18:12:13 2010 -0500
@@ -515,7 +515,6 @@
}
public ISelectedConnectionInfo ensureConnection(String id, IService service) throws CoreException {
- Check.checkArg(service);
final boolean wasCurrentConnection = CURRENT_CONNECTION_ID.equals(id);
final IConnection[] connectionHolder = { findConnection(id) };
final String[] storableIdHolder = { id };
@@ -566,7 +565,7 @@
private boolean isCompatibleConnection(IConnection connection, IService service) {
if (connection == null)
return false;
- return getCompatibleServices(connection.getConnectionType()).contains(service);
+ return service == null || getCompatibleServices(connection.getConnectionType()).contains(service);
}
public void setCurrentConnection(IConnection connection) {
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ClientServiceSiteUI2.java Tue Jun 29 15:14:38 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ClientServiceSiteUI2.java Tue Jun 29 18:12:13 2010 -0500
@@ -66,7 +66,6 @@
private Map<String, String> connectionNames;
public ClientServiceSiteUI2(IService service) {
- Check.checkArg(service);
this.service = service;
}
@@ -297,11 +296,15 @@
private void getCompatibleConnectionTypes() {
compatibleConnectionTypes = new HashSet<IConnectionType>();
- Collection<String> compatibleTypeIds =
- Registry.instance().getCompatibleConnectionTypeIds(service);
- for (String typeId : compatibleTypeIds) {
- compatibleConnectionTypes.add(
- Registry.instance().getConnectionType(typeId));
+ if (service != null) {
+ Collection<String> compatibleTypeIds =
+ Registry.instance().getCompatibleConnectionTypeIds(service);
+ for (String typeId : compatibleTypeIds) {
+ compatibleConnectionTypes.add(
+ Registry.instance().getConnectionType(typeId));
+ }
+ } else {
+ compatibleConnectionTypes.addAll(Registry.instance().getConnectionTypes());
}
}
@@ -317,12 +320,15 @@
public IStatus getSelectionStatus() {
String requiredConnectionTypes = getAllowedConnectionTypesString();
+ String serviceName = service != null ? service.getDisplayName()
+ : Messages.getString("ClientServiceSiteUI2.NoConnectionErrorPlaceholderForNoServiceName"); //$NON-NLS-1$
+
// no selection yet...?
if (connection == null) {
return new Status(IStatus.ERROR, RemoteConnectionsActivator.PLUGIN_ID,
MessageFormat.format(
Messages.getString("ClientServiceSiteUI2.NoConnectionError"), //$NON-NLS-1$
- service.getDisplayName(),
+ serviceName,
requiredConnectionTypes));
}
@@ -333,26 +339,28 @@
return new Status(IStatus.ERROR, RemoteConnectionsActivator.PLUGIN_ID,
MessageFormat.format(
Messages.getString("ClientServiceSiteUI2.NoCurrentConnection"), //$NON-NLS-1$
- service.getDisplayName(),
+ serviceName,
requiredConnectionTypes));
}
- // is the service supported?
- boolean found = false;
- for (IConnectedService aService : Registry.instance().getConnectedServices(actual)) {
- if (service.getIdentifier().equals(aService.getService().getIdentifier())) {
- found = true;
- break;
+ if (service != null) {
+ // is the service supported?
+ boolean found = false;
+ for (IConnectedService aService : Registry.instance().getConnectedServices(actual)) {
+ if (service.getIdentifier().equals(aService.getService().getIdentifier())) {
+ found = true;
+ break;
+ }
}
- }
- if (!found) {
- return new Status(IStatus.WARNING, RemoteConnectionsActivator.PLUGIN_ID,
- MessageFormat.format(
- Messages.getString("ClientServiceSiteUI2.IncompatibleCurrentConnectionService") //$NON-NLS-1$
- + "\n" //$NON-NLS-1$
- + Messages.getString("ClientServiceSiteUI2.IncompatibleCurrentConnectionFixupAdvice"), //$NON-NLS-1$
- actual.getDisplayName(),
- service.getDisplayName()));
+ if (!found) {
+ return new Status(IStatus.WARNING, RemoteConnectionsActivator.PLUGIN_ID,
+ MessageFormat.format(
+ Messages.getString("ClientServiceSiteUI2.IncompatibleCurrentConnectionService") //$NON-NLS-1$
+ + "\n" //$NON-NLS-1$
+ + Messages.getString("ClientServiceSiteUI2.IncompatibleCurrentConnectionFixupAdvice"), //$NON-NLS-1$
+ actual.getDisplayName(),
+ serviceName));
+ }
}
// is the hardware type supported by the service?
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/messages.properties Tue Jun 29 15:14:38 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/messages.properties Tue Jun 29 18:12:13 2010 -0500
@@ -16,6 +16,7 @@
ClientServiceSiteUI2.NewButtonLabel=New...
ClientServiceSiteUI2.UseConnectionGroupLabel=Use connection
ClientServiceSiteUI2.NoConnectionError=A valid remote connection must be selected. If none exist, connect a device or create a connection one supporting {0} via {1}.
+ClientServiceSiteUI2.NoConnectionErrorPlaceholderForNoServiceName=connecting
ClientServiceSiteUI2.NoCurrentConnection=No current connection is available. Connect a device or create a connection supporting {0} via {1}.
ClientServiceSiteUI2.IncompatibleCurrentConnectionType=The current connection ''{0}'' does not support connection type: ''{1}''.
ClientServiceSiteUI2.IncompatibleCurrentConnectionService=The current connection ''{0}'' does not support the service: ''{1}''.