[Bug 9392] Filter connection types with no compatible services from settings wizard (unless editing a connection of that type)
authordadubrow
Wed, 01 Jul 2009 11:31:17 -0500
changeset 337 c44c75698736
parent 336 0bdee354f078
child 338 b5a4b8b0b869
child 339 1884f0a9cb72
[Bug 9392] Filter connection types with no compatible services from settings wizard (unless editing a connection of that type)
connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionTypePage.java
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionTypePage.java	Wed Jul 01 10:48:15 2009 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionTypePage.java	Wed Jul 01 11:31:17 2009 -0500
@@ -174,8 +174,7 @@
 	}
 	
 	private Collection<IConnectionType> getConnectionTypes() {
-		Collection<IConnectionType> connectionTypes = 
-			RemoteConnectionsActivator.getConnectionTypeProvider().getConnectionTypes();
+		Collection<IConnectionType> connectionTypes = getValidConnectionTypes();
 		IService serviceToRestrict = settingsWizard.getServiceToRestrict();
 		if (serviceToRestrict != null) {
 			List<IConnectionType> restrictedConnectionTypes = new ArrayList<IConnectionType>();
@@ -193,6 +192,21 @@
 		return connectionTypes;
 	}
 
+	private Collection<IConnectionType> getValidConnectionTypes() {
+		// valid connection types have at least one compatible service, or are the actual connection type of the connection being edited
+		IConnection connectionToEdit = settingsWizard.getConnectionToEdit();
+		IConnectionType connectionTypeToEdit = connectionToEdit != null ? connectionToEdit.getConnectionType() : null;
+		Collection<IConnectionType> allConnectionTypes = 
+		RemoteConnectionsActivator.getConnectionTypeProvider().getConnectionTypes();
+		Collection<IConnectionType> connectionTypes = new ArrayList<IConnectionType>();
+		for (IConnectionType connectionType : allConnectionTypes) {
+			if (!RemoteConnectionsActivator.getConnectionTypeProvider().getCompatibleServices(connectionType).isEmpty() ||
+					connectionType.equals(connectionTypeToEdit))
+				connectionTypes.add(connectionType);
+		}
+		return connectionTypes;
+	}
+
 	private boolean validatePage() {
 		setErrorMessage(null);
 		String name = getName();