17 |
17 |
18 |
18 |
19 package com.nokia.carbide.remoteconnections.ui; |
19 package com.nokia.carbide.remoteconnections.ui; |
20 |
20 |
21 import com.nokia.carbide.remoteconnections.Messages; |
21 import com.nokia.carbide.remoteconnections.Messages; |
22 import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator; |
|
23 import com.nokia.carbide.remoteconnections.interfaces.*; |
22 import com.nokia.carbide.remoteconnections.interfaces.*; |
|
23 import com.nokia.carbide.remoteconnections.internal.registry.Registry; |
24 import com.nokia.carbide.remoteconnections.settings.ui.SettingsWizard; |
24 import com.nokia.carbide.remoteconnections.settings.ui.SettingsWizard; |
25 import com.nokia.cpp.internal.api.utils.core.Check; |
25 import com.nokia.cpp.internal.api.utils.core.Check; |
26 import com.nokia.cpp.internal.api.utils.core.ListenerList; |
26 import com.nokia.cpp.internal.api.utils.core.ListenerList; |
27 |
27 |
28 import org.eclipse.jface.dialogs.Dialog; |
28 import org.eclipse.jface.dialogs.Dialog; |
40 import java.util.*; |
40 import java.util.*; |
41 import java.util.List; |
41 import java.util.List; |
42 |
42 |
43 /** |
43 /** |
44 * Implementation of IClientServiceSiteUI |
44 * Implementation of IClientServiceSiteUI |
|
45 * @deprecated |
45 */ |
46 */ |
46 public class ClientServiceSiteUI implements IClientServiceSiteUI { |
47 public class ClientServiceSiteUI implements IClientServiceSiteUI { |
47 |
48 |
48 private IService service; |
49 private IService service; |
49 private ComboViewer viewer; |
50 private ComboViewer viewer; |
174 |
175 |
175 private List<IConnection> getCompatibleConnections() { |
176 private List<IConnection> getCompatibleConnections() { |
176 getCompatibleConnectionTypes(); |
177 getCompatibleConnectionTypes(); |
177 |
178 |
178 List<IConnection> compatibleConnections = new ArrayList<IConnection>(); |
179 List<IConnection> compatibleConnections = new ArrayList<IConnection>(); |
179 for (IConnection connection : RemoteConnectionsActivator.getConnectionsManager().getConnections()) { |
180 for (IConnection connection : Registry.instance().getConnections()) { |
180 if (isCompatibleConnection(connection)) |
181 if (isCompatibleConnection(connection)) |
181 compatibleConnections.add(connection); |
182 compatibleConnections.add(connection); |
182 } |
183 } |
183 return compatibleConnections; |
184 return compatibleConnections; |
184 } |
185 } |
188 } |
189 } |
189 |
190 |
190 private void getCompatibleConnectionTypes() { |
191 private void getCompatibleConnectionTypes() { |
191 compatibleConnectionTypes = new HashSet<IConnectionType>(); |
192 compatibleConnectionTypes = new HashSet<IConnectionType>(); |
192 Collection<String> compatibleTypeIds = |
193 Collection<String> compatibleTypeIds = |
193 RemoteConnectionsActivator.getConnectionTypeProvider().getCompatibleConnectionTypeIds(service); |
194 Registry.instance().getCompatibleConnectionTypeIds(service); |
194 for (String typeId : compatibleTypeIds) { |
195 for (String typeId : compatibleTypeIds) { |
195 compatibleConnectionTypes.add( |
196 compatibleConnectionTypes.add( |
196 RemoteConnectionsActivator.getConnectionTypeProvider().getConnectionType(typeId)); |
197 Registry.instance().getConnectionType(typeId)); |
197 } |
198 } |
198 } |
199 } |
199 |
200 |
200 public void selectConnection(IConnection connection) { |
201 public void selectConnection(IConnection connection) { |
201 if (!viewerInputContainsConnection(connection)) { |
202 if (!viewerInputContainsConnection(connection)) { |
202 addConnectionToViewerInput(connection); |
203 addConnectionToViewerInput(connection); |
203 } |
204 } |
204 viewer.setSelection(new StructuredSelection(connection)); |
205 viewer.setSelection(new StructuredSelection(connection)); |
205 } |
206 } |
206 |
207 |
|
208 @SuppressWarnings("unchecked") |
207 private boolean viewerInputContainsConnection(IConnection connection) { |
209 private boolean viewerInputContainsConnection(IConnection connection) { |
208 Object input = viewer.getInput(); |
210 Object input = viewer.getInput(); |
209 if (input instanceof List) { |
211 if (input instanceof Collection) { |
210 return ((List) input).contains(connection); |
212 return ((Collection) input).contains(connection); |
211 } |
213 } |
212 return false; |
214 return false; |
213 } |
215 } |
214 |
216 |
|
217 @SuppressWarnings("unchecked") |
215 private void addConnectionToViewerInput(IConnection connection) { |
218 private void addConnectionToViewerInput(IConnection connection) { |
216 Object input = viewer.getInput(); |
219 Object input = viewer.getInput(); |
217 if (input instanceof Collection) { |
220 if (input instanceof Collection) { |
218 List<IConnection> newInput = new ArrayList<IConnection>((Collection) input); |
221 List<IConnection> newInput = new ArrayList<IConnection>((Collection) input); |
219 newInput.add(connection); |
222 newInput.add(connection); |