# HG changeset patch # User Ed Swartz # Date 1262196441 21600 # Node ID 68bc07acac96c35eed5bcece81379c9e05854c75 # Parent 8ecd45ef360e78c1e4251960784c4435872667a2 Improve error checking and messages when default connection is inappropriate or no connections exist. diff -r 8ecd45ef360e -r 68bc07acac96 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 Wed Dec 30 11:43:43 2009 -0600 +++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/registry/Registry.java Wed Dec 30 12:07:21 2009 -0600 @@ -416,8 +416,10 @@ private void disposeConnection(IConnection connection) { List connectedServices = connectionToConnectedServices.get(connection); - for (IConnectedService connectedService : connectedServices) { - connectedService.dispose(); + if (connectedServices != null) { + for (IConnectedService connectedService : connectedServices) { + connectedService.dispose(); + } } connection.dispose(); } diff -r 8ecd45ef360e -r 68bc07acac96 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 Wed Dec 30 11:43:43 2009 -0600 +++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ClientServiceSiteUI2.java Wed Dec 30 12:07:21 2009 -0600 @@ -262,9 +262,9 @@ * @return */ private String createDefaultConnectionName(IConnection defaultConnection) { - return MessageFormat.format("Default connection ({0})", + return MessageFormat.format(Messages.getString("ClientServiceSiteUI2.DefaultConnectionFormat"), //$NON-NLS-1$ defaultConnection != null ? defaultConnection.getDisplayName() : - "when defined"); + Messages.getString("ClientServiceSiteUI2.DefaultConnection_NoneDetected")); //$NON-NLS-1$ } private void initializeDialogUnits(Composite parent) { @@ -308,54 +308,77 @@ } public IStatus getSelectionStatus() { + String requiredConnectionTypes = getAllowedConnectionTypesString(); + // no selection yet...? if (connection == null) { return new Status(IStatus.ERROR, RemoteConnectionsActivator.PLUGIN_ID, - Messages.getString("ClientServiceSiteUI2.NoConnectionError")); + MessageFormat.format( + Messages.getString("ClientServiceSiteUI2.NoConnectionError"), //$NON-NLS-1$ + service.getDisplayName(), + requiredConnectionTypes)); } // check whether the default is compatible with the service and connection type if (Registry.DEFAULT_CONNECTION_ID.equals(connection)) { IConnection actual = getActualConnection(connection); - if (actual != 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.IncompatibleDefaultConnectionService"), - actual.getDisplayName(), - service.getDisplayName())); + if (actual == null) { + return new Status(IStatus.ERROR, RemoteConnectionsActivator.PLUGIN_ID, + MessageFormat.format( + Messages.getString("ClientServiceSiteUI2.NoDefaultConnection"), //$NON-NLS-1$ + service.getDisplayName(), + 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; } - - // is the hardware type supported by the service? - if (!isCompatibleConnection(actual)) { - String requiredConnectionTypes = ""; - for (IConnectionType type : compatibleConnectionTypes) { - if (requiredConnectionTypes.length() > 0) - requiredConnectionTypes += ", "; - requiredConnectionTypes += type.getDisplayName(); - } - return new Status(IStatus.WARNING, RemoteConnectionsActivator.PLUGIN_ID, - MessageFormat.format( - Messages.getString("ClientServiceSiteUI2.IncompatibleDefaultConnectionType"), - actual.getDisplayName(), - requiredConnectionTypes)); + } + if (!found) { + return new Status(IStatus.WARNING, RemoteConnectionsActivator.PLUGIN_ID, + MessageFormat.format( + Messages.getString("ClientServiceSiteUI2.IncompatibleDefaultConnectionService") //$NON-NLS-1$ + + "\n" //$NON-NLS-1$ + + Messages.getString("ClientServiceSiteUI2.IncompatibleDefaultConnectionFixupAdvice"), //$NON-NLS-1$ + actual.getDisplayName(), + service.getDisplayName())); + } - } - + // is the hardware type supported by the service? + if (!isCompatibleConnection(actual)) { + return new Status(IStatus.WARNING, RemoteConnectionsActivator.PLUGIN_ID, + MessageFormat.format( + Messages.getString("ClientServiceSiteUI2.IncompatibleDefaultConnectionType") //$NON-NLS-1$ + + "\n" //$NON-NLS-1$ + + Messages.getString("ClientServiceSiteUI2.IncompatibleDefaultConnectionFixupAdvice"), //$NON-NLS-1$ + actual.getDisplayName(), + requiredConnectionTypes)); + } } // otherwise, it's okay! return Status.OK_STATUS; } + + private String getAllowedConnectionTypesString() { + StringBuilder requiredConnectionTypes = new StringBuilder(); + IConnectionType[] connectionTypes = + (IConnectionType[]) compatibleConnectionTypes.toArray(new IConnectionType[compatibleConnectionTypes.size()]); + for (int i = 0; i < connectionTypes.length; i++) { + IConnectionType type = connectionTypes[i]; + if (requiredConnectionTypes.length() > 0) + requiredConnectionTypes.append(", "); //$NON-NLS-1$ + if (i == connectionTypes.length - 1) + requiredConnectionTypes.append(Messages.getString("ClientServiceSiteUI2.Or")); //$NON-NLS-1$ + requiredConnectionTypes.append(type.getDisplayName()); + } + return requiredConnectionTypes.toString(); + } /* (non-Javadoc) * @see com.nokia.carbide.remoteconnections.interfaces.IClientServiceSiteUI2#getConnectionDisplayName(java.lang.String) @@ -363,7 +386,7 @@ public String getConnectionDisplayName(String connection) { String display = connectionNames.get(connection); if (display == null) - display = MessageFormat.format("<>", connection); + display = MessageFormat.format(Messages.getString("ClientServiceSiteUI2.DeletedConnectionDisplayName"), connection); //$NON-NLS-1$ return display; } diff -r 8ecd45ef360e -r 68bc07acac96 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 Wed Dec 30 11:43:43 2009 -0600 +++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/messages.properties Wed Dec 30 12:07:21 2009 -0600 @@ -7,12 +7,18 @@ ClientServiceSiteUI.EditButtonLabel=Edit... ClientServiceSiteUI.NewButtonLabel=New... ClientServiceSiteUI.UseConnectionGroupLabel=Use connection +ClientServiceSiteUI2.DefaultConnection_NoneDetected=none detected or defined +ClientServiceSiteUI2.DefaultConnectionFormat=Default connection (currently: {0}) +ClientServiceSiteUI2.DeletedConnectionDisplayName=<> ClientServiceSiteUI2.EditButtonLabel=Edit... ClientServiceSiteUI2.NewButtonLabel=New... ClientServiceSiteUI2.UseConnectionGroupLabel=Use connection -ClientServiceSiteUI2.NoConnectionError=A valid remote connection must be selected. If none exist, create a new one. -ClientServiceSiteUI2.IncompatibleDefaultConnectionType=The default connection ''{0}'' does not support connection type: ''{1}''.\nEnsure you have selected a suitable default before launching. -ClientServiceSiteUI2.IncompatibleDefaultConnectionService=The default connection ''{0}'' does not support the service: ''{1}''.\nEnsure you have selected a suitable default before launching. +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.NoDefaultConnection=There is no default connection available. Connect a device or create a connection supporting {0} via {1}. +ClientServiceSiteUI2.IncompatibleDefaultConnectionType=The default connection ''{0}'' does not support connection type: ''{1}''. +ClientServiceSiteUI2.IncompatibleDefaultConnectionService=The default connection ''{0}'' does not support the service: ''{1}''. +ClientServiceSiteUI2.IncompatibleDefaultConnectionFixupAdvice=Either connect an appropriate device or select a compatible connection. +ClientServiceSiteUI2.Or=or ConnectionSettingsPage.AgentTestTabLabel=Set Connection Settings ConnectionSettingsPage.ConnectionSettingsGroupLabel=Connection Settings ConnectionSettingsPage.DeviceOSComboToolTip=Used to determine which installer version to compare against the version reported by the remote agent