# HG changeset patch # User Ed Swartz # Date 1277853133 18000 # Node ID c431b953b86395bc32571f98d4bec1e98b8e057b # Parent 707b5fa4c1437576a49a0d6e6b0f4a6c61613287 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. diff -r 707b5fa4c143 -r c431b953b863 connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/IConnectionsManager.java --- 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(). + *

+ * 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 null * @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 null * @return ISelectedConnectionInfo * @throws CoreException * @since 2.5 diff -r 707b5fa4c143 -r c431b953b863 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 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) { diff -r 707b5fa4c143 -r c431b953b863 connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ClientServiceSiteUI2.java --- 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 connectionNames; public ClientServiceSiteUI2(IService service) { - Check.checkArg(service); this.service = service; } @@ -297,11 +296,15 @@ private void getCompatibleConnectionTypes() { compatibleConnectionTypes = new HashSet(); - Collection compatibleTypeIds = - Registry.instance().getCompatibleConnectionTypeIds(service); - for (String typeId : compatibleTypeIds) { - compatibleConnectionTypes.add( - Registry.instance().getConnectionType(typeId)); + if (service != null) { + Collection 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? diff -r 707b5fa4c143 -r c431b953b863 connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/messages.properties --- 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}''.