209 return ConnectionUIUtils.getConnectionImage((IConnection) value); |
209 return ConnectionUIUtils.getConnectionImage((IConnection) value); |
210 } |
210 } |
211 else if (value instanceof IConnectedService) { |
211 else if (value instanceof IConnectedService) { |
212 EStatus status = ((IConnectedService) value).getStatus().getEStatus(); |
212 EStatus status = ((IConnectedService) value).getStatus().getEStatus(); |
213 IConnection connection = findConnection((IConnectedService) value); |
213 IConnection connection = findConnection((IConnectedService) value); |
214 if (connection != null && isConnectionInUse(connection)) |
214 if (connection != null && ConnectionUIUtils.isSomeServiceInUse(connection)) |
215 status = EStatus.IN_USE; |
215 status = EStatus.IN_USE; |
216 return ConnectionUIUtils.getConnectedServiceStatusImage(status); |
216 return ConnectionUIUtils.getConnectedServiceStatusImage(status); |
217 } |
217 } |
218 return null; |
218 return null; |
219 } |
219 } |
225 Object value = node.getValue(); |
225 Object value = node.getValue(); |
226 if (value instanceof IConnectedService) { |
226 if (value instanceof IConnectedService) { |
227 IStatus status = null; |
227 IStatus status = null; |
228 IConnection connection = findConnection((IConnectedService) value); |
228 IConnection connection = findConnection((IConnectedService) value); |
229 if (connection != null) |
229 if (connection != null) |
230 status = getFirstInUseStatus(connection); |
230 status = ConnectionUIUtils.getFirstInUseServiceStatus(connection); |
231 if (status == null) { |
231 if (status == null) { |
232 status = ((IConnectedService) value).getStatus(); |
232 status = ((IConnectedService) value).getStatus(); |
233 return status.getShortDescription(); |
233 return status.getShortDescription(); |
234 } |
234 } |
235 } |
235 } |
236 else if (value instanceof IConnection) { |
236 else if (value instanceof IConnection) { |
237 IStatus status = getFirstInUseStatus((IConnection) value); |
237 IStatus status = ConnectionUIUtils.getFirstInUseServiceStatus((IConnection) value); |
238 if (status != null) |
238 if (status != null) |
239 return status.getShortDescription(); |
239 return status.getShortDescription(); |
240 } |
240 } |
241 |
241 |
242 return null; |
242 return null; |
272 Object value = node.getValue(); |
272 Object value = node.getValue(); |
273 if (value instanceof IConnectedService) { |
273 if (value instanceof IConnectedService) { |
274 IStatus status = ((IConnectedService) value).getStatus(); |
274 IStatus status = ((IConnectedService) value).getStatus(); |
275 IConnection connection = findConnection((IConnectedService) value); |
275 IConnection connection = findConnection((IConnectedService) value); |
276 if (!status.getEStatus().equals(EStatus.IN_USE) || |
276 if (!status.getEStatus().equals(EStatus.IN_USE) || |
277 !(connection != null && isConnectionInUse(connection))) { // if in-use, we show it in the connection row |
277 !(connection != null && ConnectionUIUtils.isSomeServiceInUse(connection))) { // if in-use, we show it in the connection row |
278 String longDescription = status.getLongDescription(); |
278 String longDescription = status.getLongDescription(); |
279 if (longDescription != null) |
279 if (longDescription != null) |
280 longDescription = TextUtils.canonicalizeNewlines(longDescription, " "); //$NON-NLS-1$ |
280 longDescription = TextUtils.canonicalizeNewlines(longDescription, " "); //$NON-NLS-1$ |
281 return longDescription; |
281 return longDescription; |
282 } |
282 } |
283 } |
283 } |
284 else if (value instanceof IConnection) { |
284 else if (value instanceof IConnection) { |
285 if (isConnectionInUse((IConnection) value)) { |
285 if (ConnectionUIUtils.isSomeServiceInUse((IConnection) value)) { |
286 return Messages.getString("ConnectionsView.InUseDesc"); |
286 return Messages.getString("ConnectionsView.InUseDesc"); |
287 } |
287 } |
288 } |
288 } |
289 |
289 |
290 return null; |
290 return null; |
756 } |
756 } |
757 } |
757 } |
758 return null; |
758 return null; |
759 } |
759 } |
760 |
760 |
761 private static IStatus getFirstInUseStatus(IConnection connection) { |
|
762 Collection<IConnectedService> connectedServices = |
|
763 Registry.instance().getConnectedServices(connection); |
|
764 // if any service is in-use, then connection is in-use |
|
765 for (IConnectedService connectedService : connectedServices) { |
|
766 IStatus status = connectedService.getStatus(); |
|
767 if (status.getEStatus().equals(EStatus.IN_USE)) |
|
768 return status; |
|
769 } |
|
770 |
|
771 return null; |
|
772 } |
|
773 |
|
774 private boolean isConnectionInUse(IConnection connection) { |
|
775 return getFirstInUseStatus(connection) != null; |
|
776 } |
|
777 |
|
778 private boolean isDynamicConnection(Object object) { |
761 private boolean isDynamicConnection(Object object) { |
779 return object instanceof IConnection2 && ((IConnection2) object).isDynamic(); |
762 return object instanceof IConnection2 && ((IConnection2) object).isDynamic(); |
780 } |
763 } |
781 |
764 |
782 private boolean selectionCanBeEdited() { |
765 private boolean selectionCanBeEdited() { |