Simplify new IConnectionFactory2
authordadubrow
Fri, 16 Apr 2010 11:32:51 -0500
changeset 1230 71146ed4b8a1
parent 1223 10a0a5ba7be1
child 1231 56b5cd0c538d
Simplify new IConnectionFactory2
connectivity/com.nokia.carbide.remoteConnections/META-INF/MANIFEST.MF
connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/IConnectionFactory.java
connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/IConnectionFactory2.java
connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/registry/Registry.java
connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionSettingsPage.java
--- a/connectivity/com.nokia.carbide.remoteConnections/META-INF/MANIFEST.MF	Thu Apr 15 17:59:16 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/META-INF/MANIFEST.MF	Fri Apr 16 11:32:51 2010 -0500
@@ -11,7 +11,8 @@
  com.nokia.cpp.utils.core,
  org.eclipse.emf.ecore.xmi;bundle-version="2.4.0",
  org.eclipse.core.net;bundle-version="1.1.0",
- com.nokia.cpp.utils.ui
+ com.nokia.cpp.utils.ui,
+ org.eclipse.help;bundle-version="3.5.0"
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
 Bundle-ActivationPolicy: lazy
 Export-Package: com.nokia.carbide.installpackages,
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/IConnectionFactory.java	Thu Apr 15 17:59:16 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/IConnectionFactory.java	Fri Apr 16 11:32:51 2010 -0500
@@ -37,14 +37,12 @@
 	 * @param parent Composite
 	 * @param errorReporter IValidationErrorReporter
 	 * @param initialSettings Map may be <code>null</code>
-	 * @deprecated use IConnectionFactory2.createEditingUI(Composite, IValidationErrorReporter, Map, com.nokia.carbide.remoteconnections.interfaces.IConnectionFactory2.ISettingsChangedListener)
 	 */
 	void createEditingUI(Composite parent, IValidationErrorReporter errorReporter, Map<String, String> initialSettings);
 
 	/**
 	 * Returns the settings from the editing UI as name value pairs
 	 * @return Map
-	 * @deprecated use IConnectionFactory2.IEditingUI.getSettings() or IConnectionFactory2.getDefaultSettings()
 	 */
 	Map<String, String> getSettingsFromUI();
 
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/IConnectionFactory2.java	Thu Apr 15 17:59:16 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/IConnectionFactory2.java	Fri Apr 16 11:32:51 2010 -0500
@@ -32,10 +32,6 @@
 		void settingsChanged();
 	}
 
-	public interface IEditingUI {
-		Map<String, String> getSettings();
-	}
-
 	/**
 	 * Creates a composite with UI for editing settings, optionally initialized with initialSettings.<br>
 	 * Can provide optional errorReporter and optional listener. Assumes parent has GridLayout
@@ -43,10 +39,7 @@
 	 * @param errorReporter IValidationErrorReporter
 	 * @param initialSettings Map may be <code>null</code>
 	 * @param settingsListener ISettingsChangedListener
-	 * @return IEditingUI
 	 */
-	IEditingUI createEditingUI(Composite parent, IValidationErrorReporter errorReporter, 
+	void createEditingUI(Composite parent, IValidationErrorReporter errorReporter, 
 			Map<String, String> initialSettings, ISettingsChangedListener settingsListener);
-	
-	Map<String, String> getDefaultSettings();
 }
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/registry/Registry.java	Thu Apr 15 17:59:16 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/registry/Registry.java	Fri Apr 16 11:32:51 2010 -0500
@@ -240,7 +240,7 @@
 			}
 			fireConnectionStoreChanged();
 		} 
-		catch (Exception e) {
+		catch (Throwable e) {
 			RemoteConnectionsActivator.log(Messages.getString("Registry.ConnectionLoadError"), e); //$NON-NLS-1$
 		}
 		
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionSettingsPage.java	Thu Apr 15 17:59:16 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionSettingsPage.java	Fri Apr 16 11:32:51 2010 -0500
@@ -100,7 +100,6 @@
 import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatusChangedListener;
 import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus.EStatus;
 import com.nokia.carbide.remoteconnections.interfaces.IConnectionFactory.IValidationErrorReporter;
-import com.nokia.carbide.remoteconnections.interfaces.IConnectionFactory2.IEditingUI;
 import com.nokia.carbide.remoteconnections.interfaces.IConnectionFactory2.ISettingsChangedListener;
 import com.nokia.carbide.remoteconnections.interfaces.IRemoteAgentInstallerProvider.IRemoteAgentInstaller;
 import com.nokia.carbide.remoteconnections.interfaces.IRemoteAgentInstallerProvider.IRemoteAgentInstaller.IPackageContents;
@@ -158,7 +157,6 @@
 	private Label statusLabel;
 	private Text statusText;
 	private IConnectionFactory connectionFactory;
-	private IEditingUI editingUI;
 	private IConnection connection;
 	private IService service;
 	private volatile IConnectedService connectedService;
@@ -564,7 +562,6 @@
 		}
 	}
 
-	@SuppressWarnings("deprecation")
 	public void updateDynamicUI() {
 		IConnectionType currentConnectionType = getConnectionType();
 		if (currentConnectionType != null && !currentConnectionType.equals(connectionType)) {
@@ -598,7 +595,7 @@
 				}
 			};
 			if (connectionFactory instanceof IConnectionFactory2) {
-				editingUI = ((IConnectionFactory2)connectionFactory).createEditingUI(
+				((IConnectionFactory2)connectionFactory).createEditingUI(
 						settingsGroup, errorReporter, initialSettings, this);
 				settingsChanged();
 			}
@@ -654,16 +651,13 @@
 
 	public void settingsChanged() {
 		if (!modifiedName) {
-			if (editingUI != null) {
-				String preferredName = editingUI.getSettings().get(IConnectionFactory2.PREFERRED_CONNECTION_NAME);
-				if (preferredName != null) {
-					nameText.setText(getPreferredNameText(preferredName));
-					modifiedName = false;
-					return;
-				}
+			String preferredName = connectionFactory.getSettingsFromUI().get(IConnectionFactory2.PREFERRED_CONNECTION_NAME);
+			if (preferredName != null) {
+				nameText.setText(ensureUniquePreferredName(preferredName));
 			}
-			// when editingUI or preferredName is null
-			nameText.setText(getInitialNameText());
+			else {
+				nameText.setText(getInitialNameText());
+			}
 			modifiedName = false;
 		}
 	}
@@ -776,13 +770,7 @@
 
 	@SuppressWarnings("unchecked")
 	protected void testService() {
-		Map<String, String> settings;
-		if (connectionFactory instanceof IConnectionFactory2 && editingUI != null) {
-			settings = editingUI.getSettings();
-		}
-		else {
-			settings = connectionFactory.getSettingsFromUI();
-		}
+		Map<String, String> settings = connectionFactory.getSettingsFromUI();
 		boolean newConnection = connection == null || !connectionType.equals(connection.getConnectionType());
 		if (newConnection) {
 			if (connection != null)
@@ -840,9 +828,6 @@
 	}
 	
 	public Map<String, String> getSettings() {
-		if (editingUI != null)
-			return editingUI.getSettings();
-		
 		if (connectionFactory == null) {
 			IConnection connectionToEdit = settingsWizard.getConnectionToEdit();
 			if (connectionToEdit == null || !connectionToEdit.getConnectionType().equals(getConnectionType())) {
@@ -1093,7 +1078,7 @@
 		}
 	}
 
-	private String getPreferredNameText(String preferredName) {
+	private String ensureUniquePreferredName(String preferredName) {
 		if (isNameUnique(preferredName)) {
 			return preferredName;
 		}