19 package com.nokia.carbide.remoteconnections.settings.ui; |
19 package com.nokia.carbide.remoteconnections.settings.ui; |
20 |
20 |
21 import com.nokia.carbide.remoteconnections.Messages; |
21 import com.nokia.carbide.remoteconnections.Messages; |
22 import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator; |
22 import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator; |
23 import com.nokia.carbide.remoteconnections.interfaces.*; |
23 import com.nokia.carbide.remoteconnections.interfaces.*; |
|
24 import com.nokia.carbide.remoteconnections.internal.registry.Registry; |
24 import com.nokia.cpp.internal.api.utils.core.Check; |
25 import com.nokia.cpp.internal.api.utils.core.Check; |
25 |
26 |
26 import org.eclipse.jface.viewers.*; |
27 import org.eclipse.jface.viewers.*; |
27 import org.eclipse.jface.wizard.WizardPage; |
28 import org.eclipse.jface.wizard.WizardPage; |
28 import org.eclipse.swt.SWT; |
29 import org.eclipse.swt.SWT; |
139 } |
140 } |
140 |
141 |
141 private String getServicesString() { |
142 private String getServicesString() { |
142 StringBuilder servicesString = new StringBuilder(); |
143 StringBuilder servicesString = new StringBuilder(); |
143 Collection<IService> services = |
144 Collection<IService> services = |
144 RemoteConnectionsActivator.getConnectionTypeProvider().getCompatibleServices(getConnectionType()); |
145 Registry.instance().getCompatibleServices(getConnectionType()); |
145 if (services == null || services.isEmpty()) |
146 if (services == null || services.isEmpty()) |
146 return ""; //$NON-NLS-1$ |
147 return ""; //$NON-NLS-1$ |
147 for (Iterator<IService> iterator = services.iterator(); iterator.hasNext();) { |
148 for (Iterator<IService> iterator = services.iterator(); iterator.hasNext();) { |
148 servicesString.append(iterator.next().getDisplayName()); |
149 servicesString.append(iterator.next().getDisplayName()); |
149 if (iterator.hasNext()) |
150 if (iterator.hasNext()) |
177 Collection<IConnectionType> connectionTypes = getValidConnectionTypes(); |
178 Collection<IConnectionType> connectionTypes = getValidConnectionTypes(); |
178 IService serviceToRestrict = settingsWizard.getServiceToRestrict(); |
179 IService serviceToRestrict = settingsWizard.getServiceToRestrict(); |
179 if (serviceToRestrict != null) { |
180 if (serviceToRestrict != null) { |
180 List<IConnectionType> restrictedConnectionTypes = new ArrayList<IConnectionType>(); |
181 List<IConnectionType> restrictedConnectionTypes = new ArrayList<IConnectionType>(); |
181 Collection<String> compatibleConnectionTypeIds = |
182 Collection<String> compatibleConnectionTypeIds = |
182 RemoteConnectionsActivator.getConnectionTypeProvider().getCompatibleConnectionTypeIds(serviceToRestrict); |
183 Registry.instance().getCompatibleConnectionTypeIds(serviceToRestrict); |
183 for (String connectionTypeId : compatibleConnectionTypeIds) { |
184 for (String connectionTypeId : compatibleConnectionTypeIds) { |
184 IConnectionType connectionType = |
185 IConnectionType connectionType = |
185 RemoteConnectionsActivator.getConnectionTypeProvider().getConnectionType(connectionTypeId); |
186 Registry.instance().getConnectionType(connectionTypeId); |
186 if (connectionTypes.contains(connectionType)) |
187 if (connectionTypes.contains(connectionType)) |
187 restrictedConnectionTypes.add(connectionType); |
188 restrictedConnectionTypes.add(connectionType); |
188 } |
189 } |
189 return restrictedConnectionTypes; |
190 return restrictedConnectionTypes; |
190 } |
191 } |
195 private Collection<IConnectionType> getValidConnectionTypes() { |
196 private Collection<IConnectionType> getValidConnectionTypes() { |
196 // valid connection types have at least one compatible service, or are the actual connection type of the connection being edited |
197 // valid connection types have at least one compatible service, or are the actual connection type of the connection being edited |
197 IConnection connectionToEdit = settingsWizard.getConnectionToEdit(); |
198 IConnection connectionToEdit = settingsWizard.getConnectionToEdit(); |
198 IConnectionType connectionTypeToEdit = connectionToEdit != null ? connectionToEdit.getConnectionType() : null; |
199 IConnectionType connectionTypeToEdit = connectionToEdit != null ? connectionToEdit.getConnectionType() : null; |
199 Collection<IConnectionType> allConnectionTypes = |
200 Collection<IConnectionType> allConnectionTypes = |
200 RemoteConnectionsActivator.getConnectionTypeProvider().getConnectionTypes(); |
201 Registry.instance().getConnectionTypes(); |
201 Collection<IConnectionType> connectionTypes = new ArrayList<IConnectionType>(); |
202 Collection<IConnectionType> connectionTypes = new ArrayList<IConnectionType>(); |
202 for (IConnectionType connectionType : allConnectionTypes) { |
203 for (IConnectionType connectionType : allConnectionTypes) { |
203 if (!RemoteConnectionsActivator.getConnectionTypeProvider().getCompatibleServices(connectionType).isEmpty() || |
204 if (!Registry.instance().getCompatibleServices(connectionType).isEmpty() || |
204 connectionType.equals(connectionTypeToEdit)) |
205 connectionType.equals(connectionTypeToEdit)) |
205 connectionTypes.add(connectionType); |
206 connectionTypes.add(connectionType); |
206 } |
207 } |
207 return connectionTypes; |
208 return connectionTypes; |
208 } |
209 } |
217 |
218 |
218 return isValid; |
219 return isValid; |
219 } |
220 } |
220 |
221 |
221 private boolean isNameUnique(String name) { |
222 private boolean isNameUnique(String name) { |
222 boolean inUse = RemoteConnectionsActivator.getConnectionsManager().connectionNameInUse(name); |
223 boolean inUse = Registry.instance().connectionNameInUse(name); |
223 IConnection connectionToEdit = settingsWizard.getConnectionToEdit(); |
224 IConnection connectionToEdit = settingsWizard.getConnectionToEdit(); |
224 if (connectionToEdit != null && inUse) |
225 if (connectionToEdit != null && inUse) |
225 inUse = !name.equals(connectionToEdit.getDisplayName()); |
226 inUse = !name.equals(connectionToEdit.getDisplayName()); |
226 |
227 |
227 return !inUse; |
228 return !inUse; |