47 |
47 |
48 protected abstract String getServiceId(); |
48 protected abstract String getServiceId(); |
49 |
49 |
50 public void run(IAction action) { |
50 public void run(IAction action) { |
51 IService service = findService(getServiceId()); |
51 IService service = findService(getServiceId()); |
52 IConnection connection = getPersistedConnection(getServiceId()); |
52 String connection = getPersistedConnection(getServiceId()); |
53 POUConnectionDialog dialog = new POUConnectionDialog(service, connection); |
53 POUConnectionDialog dialog = new POUConnectionDialog(service, connection); |
54 dialog.open(); |
54 dialog.open(); |
55 connection = dialog.getSelectedConnection(); |
55 connection = dialog.getSelectedConnection(); |
56 persistConnection(getServiceId(), connection); |
56 persistConnection(getServiceId(), connection); |
57 } |
57 } |
58 |
58 |
59 protected void persistConnection(String key, IConnection connection) { |
59 protected void persistConnection(String key, String connection) { |
60 if (connection != null) { |
60 if (connection != null) { |
61 Activator.getDefault().getPreferenceStore().putValue(key, connection.getIdentifier()); |
61 Activator.getDefault().getPreferenceStore().putValue(key, connection); |
62 Activator.getDefault().savePluginPreferences(); |
62 Activator.getDefault().savePluginPreferences(); |
63 } |
63 } |
64 } |
64 } |
65 |
65 |
66 protected IConnection getPersistedConnection(String key) { |
66 protected String getPersistedConnection(String key) { |
67 String connectionId = Activator.getDefault().getPreferenceStore().getString(key); |
67 String connectionId = Activator.getDefault().getPreferenceStore().getString(key); |
68 if (connectionId != null) { |
68 return connectionId; |
69 Collection<IConnection> connections = RemoteConnectionsActivator.getConnectionsManager().getConnections(); |
|
70 for (IConnection connection : connections) { |
|
71 if (connection.getIdentifier().equals(connectionId)) |
|
72 return connection; |
|
73 } |
|
74 } |
|
75 return null; |
|
76 } |
69 } |
77 |
70 |
78 protected IService findService(String serviceId) { |
71 protected IService findService(String serviceId) { |
79 Collection<IService> services = Registry.instance().getServices(); |
72 Collection<IService> services = Registry.instance().getServices(); |
80 for (IService service : services) { |
73 for (IService service : services) { |