connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ConnectionUIUtils.java
author dadubrow
Fri, 17 Sep 2010 10:34:07 -0500
changeset 2038 dd457404f42f
parent 2028 ff6b4aae1c1e
permissions -rw-r--r--
remove hypertext from other UIs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
     1
/*
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
     8
*
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    11
*
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    12
* Contributors:
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    13
*
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    14
* Description: 
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    15
*
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    16
*/
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    17
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    18
package com.nokia.carbide.remoteconnections.internal.ui;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    19
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    20
import java.util.Collection;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    21
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    22
import org.eclipse.jface.resource.ImageDescriptor;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    23
import org.eclipse.swt.graphics.Color;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    24
import org.eclipse.swt.graphics.Image;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    25
import org.eclipse.swt.widgets.Display;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    26
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    27
import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    28
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService;
711
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
    29
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus;
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
    30
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus.EStatus;
2038
dd457404f42f remove hypertext from other UIs
dadubrow
parents: 2028
diff changeset
    31
import com.nokia.carbide.remoteconnections.interfaces.IConnection;
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    32
import com.nokia.carbide.remoteconnections.internal.api.IConnection2;
709
c92b05bdc957 Update for IConnectionStatus changes
Ed Swartz <ed.swartz@nokia.com>
parents: 706
diff changeset
    33
import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatus;
c92b05bdc957 Update for IConnectionStatus changes
Ed Swartz <ed.swartz@nokia.com>
parents: 706
diff changeset
    34
import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatus.EConnectionStatus;
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    35
import com.nokia.carbide.remoteconnections.internal.registry.Registry;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    36
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    37
/**
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    38
 * 
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    39
 */
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    40
public class ConnectionUIUtils {
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    41
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    42
	private static final ImageDescriptor STATUS_AVAIL_IMGDESC = 
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    43
	RemoteConnectionsActivator.getImageDescriptor("icons/statusAvailable.png"); //$NON-NLS-1$
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    44
	private static final ImageDescriptor STATUS_UNAVAIL_IMGDESC = 
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    45
	RemoteConnectionsActivator.getImageDescriptor("icons/statusUnavailable.png"); //$NON-NLS-1$
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    46
	private static final ImageDescriptor STATUS_UNK_IMGDESC = 
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    47
	RemoteConnectionsActivator.getImageDescriptor("icons/statusUnknown.png"); //$NON-NLS-1$
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    48
	private static final ImageDescriptor STATUS_INUSE_IMGDESC =
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    49
		RemoteConnectionsActivator.getImageDescriptor("icons/statusInUse.png"); //$NON-NLS-1$
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    50
	
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    51
	private static final ImageDescriptor CONNECTION_READY_IMGDESC = 
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    52
		RemoteConnectionsActivator.getImageDescriptor("icons/connectionStatusReady.png"); //$NON-NLS-1$
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    53
	private static final ImageDescriptor CONNECTION_IN_USE_IMGDESC = 
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    54
		RemoteConnectionsActivator.getImageDescriptor("icons/connectionStatusInUse.png"); //$NON-NLS-1$
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    55
	private static final ImageDescriptor CONNECTION_NOT_READY_IMGDESC = 
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    56
		RemoteConnectionsActivator.getImageDescriptor("icons/connectionStatusNotReady.png"); //$NON-NLS-1$
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    57
	private static final ImageDescriptor CONNECTION_IN_USE_DISCONNECTED_IMGDESC =
709
c92b05bdc957 Update for IConnectionStatus changes
Ed Swartz <ed.swartz@nokia.com>
parents: 706
diff changeset
    58
		RemoteConnectionsActivator.getImageDescriptor("icons/connectionStatusInUseDisconnected.png"); //$NON-NLS-1$
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    59
	
732
c6b80e0b9fe2 In Remote Connections view, wire up indication of default connection and menu item for switching it.
Ed Swartz <ed.swartz@nokia.com>
parents: 721
diff changeset
    60
	public static final ImageDescriptor CONNECTION_IMGDESC = 
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    61
		RemoteConnectionsActivator.getImageDescriptor("icons/connection.png"); //$NON-NLS-1$
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    62
	
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    63
	private static final Image STATUS_AVAIL_IMG = STATUS_AVAIL_IMGDESC.createImage();
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    64
	private static final Image STATUS_UNAVAIL_IMG = STATUS_UNAVAIL_IMGDESC.createImage();
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    65
	private static final Image STATUS_INUSE_IMG = STATUS_INUSE_IMGDESC.createImage();
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    66
	private static final Image STATUS_UNK_IMG = STATUS_UNK_IMGDESC.createImage();
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    67
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    68
	private static final Image CONNECTION_READY_IMG = CONNECTION_READY_IMGDESC.createImage(); 
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    69
	private static final Image CONNECTION_IN_USE_IMG =  CONNECTION_IN_USE_IMGDESC.createImage();
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    70
	private static final Image CONNECTION_NOT_READY_IMG = CONNECTION_NOT_READY_IMGDESC.createImage();
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    71
	private static final Image CONNECTION_IN_USE_DISCONNECTED_IMG = CONNECTION_IN_USE_DISCONNECTED_IMGDESC.createImage();
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    72
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    73
	private static final Image CONNECTION_IMG = CONNECTION_IMGDESC.createImage();
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    74
	
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    75
	public static final Color COLOR_RED = new Color(Display.getDefault(), 192, 0, 0);
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    76
	public static final Color COLOR_GREEN = new Color(Display.getDefault(), 0, 128, 0);
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    77
	public static final Color COLOR_ELECTRIC = new Color(Display.getDefault(), 0, 0, 255);
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    78
	public static final Color COLOR_GREY = new Color(Display.getDefault(), 96, 96, 96);
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    79
	
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    80
	/**
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    81
	 * Get the image representing the connection status.
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    82
	 * @param connection
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    83
	 * @return Image, not to be disposed
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    84
	 */
709
c92b05bdc957 Update for IConnectionStatus changes
Ed Swartz <ed.swartz@nokia.com>
parents: 706
diff changeset
    85
	public static Image getConnectionStatusImage(IConnectionStatus status) {
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    86
		if (status != null) {
709
c92b05bdc957 Update for IConnectionStatus changes
Ed Swartz <ed.swartz@nokia.com>
parents: 706
diff changeset
    87
			EConnectionStatus severity = status.getEConnectionStatus();
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    88
			
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    89
			switch (severity) {
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    90
			case READY:
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    91
				return CONNECTION_READY_IMG;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    92
			case IN_USE:
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    93
				return CONNECTION_IN_USE_IMG;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    94
			case NOT_READY:
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    95
				return CONNECTION_NOT_READY_IMG;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    96
			case IN_USE_DISCONNECTED:
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    97
				return CONNECTION_IN_USE_DISCONNECTED_IMG;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    98
			}
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    99
		}
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   100
		return ConnectionUIUtils.CONNECTION_IMG;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   101
	}
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   102
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   103
	/**
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   104
	 * Get the image representing the connection status.
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   105
	 * @param connection
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   106
	 * @return Image, not to be disposed
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   107
	 */
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   108
	public static Image getConnectionImage(IConnection connection) {
721
dbd80b3d41cc Show in-use/not-in-use connection status icon, until real IConnectedStatus is available.
Ed Swartz <ed.swartz@nokia.com>
parents: 711
diff changeset
   109
		// TODO: remove this when we have real statuses from a connection
dbd80b3d41cc Show in-use/not-in-use connection status icon, until real IConnectedStatus is available.
Ed Swartz <ed.swartz@nokia.com>
parents: 711
diff changeset
   110
		if (isSomeServiceInUse(connection)) {
dbd80b3d41cc Show in-use/not-in-use connection status icon, until real IConnectedStatus is available.
Ed Swartz <ed.swartz@nokia.com>
parents: 711
diff changeset
   111
			return ConnectionUIUtils.STATUS_INUSE_IMG;
dbd80b3d41cc Show in-use/not-in-use connection status icon, until real IConnectedStatus is available.
Ed Swartz <ed.swartz@nokia.com>
parents: 711
diff changeset
   112
		}
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   113
		if (connection instanceof IConnection2) {
709
c92b05bdc957 Update for IConnectionStatus changes
Ed Swartz <ed.swartz@nokia.com>
parents: 706
diff changeset
   114
			IConnectionStatus status = ((IConnection2) connection).getStatus();
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   115
			return getConnectionStatusImage(status);
710
47bb893ba749 Attach listener to connection name changes, rename Device -> Connection
Ed Swartz <ed.swartz@nokia.com>
parents: 709
diff changeset
   116
		} else {
721
dbd80b3d41cc Show in-use/not-in-use connection status icon, until real IConnectedStatus is available.
Ed Swartz <ed.swartz@nokia.com>
parents: 711
diff changeset
   117
			// old connection logic
711
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   118
			if (isSomeServiceInUse(connection)) {
710
47bb893ba749 Attach listener to connection name changes, rename Device -> Connection
Ed Swartz <ed.swartz@nokia.com>
parents: 709
diff changeset
   119
				return ConnectionUIUtils.STATUS_INUSE_IMG;
47bb893ba749 Attach listener to connection name changes, rename Device -> Connection
Ed Swartz <ed.swartz@nokia.com>
parents: 709
diff changeset
   120
			}
47bb893ba749 Attach listener to connection name changes, rename Device -> Connection
Ed Swartz <ed.swartz@nokia.com>
parents: 709
diff changeset
   121
			return ConnectionUIUtils.CONNECTION_IMG;
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   122
		}
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   123
	}
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   124
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   125
	/**
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   126
	 * @param status
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   127
	 * @return
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   128
	 */
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   129
	public static Image getConnectedServiceStatusImage(IConnectedService.IStatus.EStatus status) {
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   130
		switch (status) {
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   131
		case DOWN:
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   132
			return ConnectionUIUtils.STATUS_UNAVAIL_IMG;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   133
		case UP:
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   134
			return ConnectionUIUtils.STATUS_AVAIL_IMG;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   135
		case IN_USE:
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   136
			return ConnectionUIUtils.CONNECTION_IMG;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   137
		case UNKNOWN:
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   138
			return ConnectionUIUtils.STATUS_UNK_IMG;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   139
		}
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   140
		return null;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   141
	}
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   142
711
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   143
	public static IStatus getFirstInUseServiceStatus(IConnection connection) {
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   144
		Collection<IConnectedService> connectedServices = 
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   145
			Registry.instance().getConnectedServices(connection);
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   146
		// if any service is in-use, then connection is in-use
981
77bc8173ce83 Fixes bug 10733. In Registry.getConnectedServices(IConnection), return empty collection instead of null. Use isEmpty() instead of == null for caller conditionals
John Dean <john.3.dean@nokia.com>
parents: 980
diff changeset
   147
		if (connectedServices.isEmpty())
721
dbd80b3d41cc Show in-use/not-in-use connection status icon, until real IConnectedStatus is available.
Ed Swartz <ed.swartz@nokia.com>
parents: 711
diff changeset
   148
			return null;
dbd80b3d41cc Show in-use/not-in-use connection status icon, until real IConnectedStatus is available.
Ed Swartz <ed.swartz@nokia.com>
parents: 711
diff changeset
   149
		
711
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   150
		for (IConnectedService connectedService : connectedServices) {
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   151
			IStatus status = connectedService.getStatus();
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   152
			if (status.getEStatus().equals(EStatus.IN_USE))
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   153
				return status;
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   154
		}
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   155
		
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   156
		return null;
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   157
	}
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   158
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   159
	public static boolean isSomeServiceInUse(IConnection connection) {
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   160
		return getFirstInUseServiceStatus(connection) != null;
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   161
	}
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   162
}