connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ConnectionUIUtils.java
author dadubrow
Thu, 16 Sep 2010 09:17:01 -0500
changeset 2028 ff6b4aae1c1e
parent 981 77bc8173ce83
child 2038 dd457404f42f
permissions -rw-r--r--
Bug 11620 - provide support for links (including special support for installer page link) in description column of remote connections view
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;
2028
ff6b4aae1c1e Bug 11620 - provide support for links (including special support for installer page link) in description column of remote connections view
dadubrow
parents: 981
diff changeset
    23
import org.eclipse.jface.resource.JFaceColors;
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    24
import org.eclipse.swt.graphics.Color;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    25
import org.eclipse.swt.graphics.Image;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    26
import org.eclipse.swt.widgets.Display;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    27
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    28
import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    29
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    30
import com.nokia.carbide.remoteconnections.interfaces.IConnection;
711
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
    31
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus;
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
    32
import com.nokia.carbide.remoteconnections.interfaces.IConnectedService.IStatus.EStatus;
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    33
import com.nokia.carbide.remoteconnections.internal.api.IConnection2;
709
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;
c92b05bdc957 Update for IConnectionStatus changes
Ed Swartz <ed.swartz@nokia.com>
parents: 706
diff changeset
    35
import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatus.EConnectionStatus;
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    36
import com.nokia.carbide.remoteconnections.internal.registry.Registry;
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
 */
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    41
public class ConnectionUIUtils {
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    42
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    43
	private static final ImageDescriptor STATUS_AVAIL_IMGDESC = 
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    44
	RemoteConnectionsActivator.getImageDescriptor("icons/statusAvailable.png"); //$NON-NLS-1$
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    45
	private static final ImageDescriptor STATUS_UNAVAIL_IMGDESC = 
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    46
	RemoteConnectionsActivator.getImageDescriptor("icons/statusUnavailable.png"); //$NON-NLS-1$
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    47
	private static final ImageDescriptor STATUS_UNK_IMGDESC = 
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    48
	RemoteConnectionsActivator.getImageDescriptor("icons/statusUnknown.png"); //$NON-NLS-1$
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    49
	private static final ImageDescriptor STATUS_INUSE_IMGDESC =
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    50
		RemoteConnectionsActivator.getImageDescriptor("icons/statusInUse.png"); //$NON-NLS-1$
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    51
	
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    52
	private static final ImageDescriptor CONNECTION_READY_IMGDESC = 
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    53
		RemoteConnectionsActivator.getImageDescriptor("icons/connectionStatusReady.png"); //$NON-NLS-1$
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    54
	private static final ImageDescriptor CONNECTION_IN_USE_IMGDESC = 
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    55
		RemoteConnectionsActivator.getImageDescriptor("icons/connectionStatusInUse.png"); //$NON-NLS-1$
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    56
	private static final ImageDescriptor CONNECTION_NOT_READY_IMGDESC = 
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    57
		RemoteConnectionsActivator.getImageDescriptor("icons/connectionStatusNotReady.png"); //$NON-NLS-1$
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    58
	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
    59
		RemoteConnectionsActivator.getImageDescriptor("icons/connectionStatusInUseDisconnected.png"); //$NON-NLS-1$
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    60
	
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
    61
	public static final ImageDescriptor CONNECTION_IMGDESC = 
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    62
		RemoteConnectionsActivator.getImageDescriptor("icons/connection.png"); //$NON-NLS-1$
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    63
	
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    64
	private static final Image STATUS_AVAIL_IMG = STATUS_AVAIL_IMGDESC.createImage();
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    65
	private static final Image STATUS_UNAVAIL_IMG = STATUS_UNAVAIL_IMGDESC.createImage();
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    66
	private static final Image STATUS_INUSE_IMG = STATUS_INUSE_IMGDESC.createImage();
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    67
	private static final Image STATUS_UNK_IMG = STATUS_UNK_IMGDESC.createImage();
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    68
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    69
	private static final Image CONNECTION_READY_IMG = CONNECTION_READY_IMGDESC.createImage(); 
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    70
	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
    71
	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
    72
	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
    73
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    74
	private static final Image CONNECTION_IMG = CONNECTION_IMGDESC.createImage();
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    75
	
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    76
	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
    77
	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
    78
	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
    79
	public static final Color COLOR_GREY = new Color(Display.getDefault(), 96, 96, 96);
2028
ff6b4aae1c1e Bug 11620 - provide support for links (including special support for installer page link) in description column of remote connections view
dadubrow
parents: 981
diff changeset
    80
	public static final Color COLOR_HYPERLINK = JFaceColors.getHyperlinkText(Display.getDefault());
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    81
	
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    82
	/**
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    83
	 * Get the image representing the connection status.
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    84
	 * @param connection
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    85
	 * @return Image, not to be disposed
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    86
	 */
709
c92b05bdc957 Update for IConnectionStatus changes
Ed Swartz <ed.swartz@nokia.com>
parents: 706
diff changeset
    87
	public static Image getConnectionStatusImage(IConnectionStatus status) {
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    88
		if (status != null) {
709
c92b05bdc957 Update for IConnectionStatus changes
Ed Swartz <ed.swartz@nokia.com>
parents: 706
diff changeset
    89
			EConnectionStatus severity = status.getEConnectionStatus();
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    90
			
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    91
			switch (severity) {
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    92
			case READY:
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    93
				return CONNECTION_READY_IMG;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    94
			case IN_USE:
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    95
				return CONNECTION_IN_USE_IMG;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    96
			case NOT_READY:
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    97
				return CONNECTION_NOT_READY_IMG;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    98
			case IN_USE_DISCONNECTED:
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
    99
				return CONNECTION_IN_USE_DISCONNECTED_IMG;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   100
			}
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
		return ConnectionUIUtils.CONNECTION_IMG;
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
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   105
	/**
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   106
	 * Get the image representing the connection status.
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   107
	 * @param connection
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   108
	 * @return Image, not to be disposed
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   109
	 */
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   110
	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
   111
		// 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
   112
		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
   113
			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
   114
		}
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   115
		if (connection instanceof IConnection2) {
709
c92b05bdc957 Update for IConnectionStatus changes
Ed Swartz <ed.swartz@nokia.com>
parents: 706
diff changeset
   116
			IConnectionStatus status = ((IConnection2) connection).getStatus();
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   117
			return getConnectionStatusImage(status);
710
47bb893ba749 Attach listener to connection name changes, rename Device -> Connection
Ed Swartz <ed.swartz@nokia.com>
parents: 709
diff changeset
   118
		} 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
   119
			// old connection logic
711
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   120
			if (isSomeServiceInUse(connection)) {
710
47bb893ba749 Attach listener to connection name changes, rename Device -> Connection
Ed Swartz <ed.swartz@nokia.com>
parents: 709
diff changeset
   121
				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
   122
			}
47bb893ba749 Attach listener to connection name changes, rename Device -> Connection
Ed Swartz <ed.swartz@nokia.com>
parents: 709
diff changeset
   123
			return ConnectionUIUtils.CONNECTION_IMG;
706
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
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   127
	/**
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   128
	 * @param status
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   129
	 * @return
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   130
	 */
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   131
	public static Image getConnectedServiceStatusImage(IConnectedService.IStatus.EStatus status) {
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   132
		switch (status) {
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   133
		case DOWN:
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   134
			return ConnectionUIUtils.STATUS_UNAVAIL_IMG;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   135
		case UP:
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   136
			return ConnectionUIUtils.STATUS_AVAIL_IMG;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   137
		case IN_USE:
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   138
			return ConnectionUIUtils.CONNECTION_IMG;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   139
		case UNKNOWN:
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   140
			return ConnectionUIUtils.STATUS_UNK_IMG;
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
		return null;
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   143
	}
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   144
711
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   145
	public static IStatus getFirstInUseServiceStatus(IConnection connection) {
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   146
		Collection<IConnectedService> connectedServices = 
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   147
			Registry.instance().getConnectedServices(connection);
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   148
		// 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
   149
		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
   150
			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
   151
		
711
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   152
		for (IConnectedService connectedService : connectedServices) {
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   153
			IStatus status = connectedService.getStatus();
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   154
			if (status.getEStatus().equals(EStatus.IN_USE))
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   155
				return status;
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   156
		}
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
		return null;
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   159
	}
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   160
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   161
	public static boolean isSomeServiceInUse(IConnection connection) {
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   162
		return getFirstInUseServiceStatus(connection) != null;
d97b8b6bce37 add logic for disconnect and reconnect
dadubrow
parents: 710
diff changeset
   163
	}
706
bba29393db80 Checkpoint commit
Ed Swartz <ed.swartz@nokia.com>
parents:
diff changeset
   164
}