Binary file connectivity/com.nokia.carbide.remoteConnections/icons/connectionStatusInUse.png has changed
Binary file connectivity/com.nokia.carbide.remoteConnections/icons/connectionStatusInUseDisconnected.png has changed
Binary file connectivity/com.nokia.carbide.remoteConnections/icons/connectionStatusNotReady.png has changed
Binary file connectivity/com.nokia.carbide.remoteConnections/icons/connectionStatusReady.png has changed
--- a/connectivity/com.nokia.carbide.remoteConnections/plugin.xml Fri Dec 18 09:30:04 2009 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections/plugin.xml Fri Dec 18 09:34:19 2009 -0600
@@ -77,4 +77,17 @@
</actionSet>
</extension>
+<extension point="org.eclipse.ui.menus">
+ <!-- Defines a new menu contribution to the Eclipse trim area -->
+ <menuContribution
+ locationURI="toolbar:org.eclipse.ui.trim.status">
+ <toolbar
+ id="com.nokia.carbide.cpp.news.contributions.toolbar.trim">
+ <control
+ class="com.nokia.carbide.remoteconnections.internal.ui.DeviceStatusSelectorContribution"
+ id="controlContribtion">
+ </control>
+ </toolbar>
+ </menuContribution>
+</extension>
</plugin>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ConnectionUIUtils.java Fri Dec 18 09:34:19 2009 -0600
@@ -0,0 +1,150 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+package com.nokia.carbide.remoteconnections.internal.ui;
+
+import java.util.Collection;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
+import com.nokia.carbide.remoteconnections.interfaces.IConnectedService;
+import com.nokia.carbide.remoteconnections.interfaces.IConnection;
+import com.nokia.carbide.remoteconnections.internal.api.IConnection2;
+import com.nokia.carbide.remoteconnections.internal.registry.Registry;
+
+/**
+ *
+ */
+public class ConnectionUIUtils {
+
+ public static IConnectedService.IStatus getFirstInUseStatus(IConnection connection) {
+ Collection<IConnectedService> connectedServices =
+ Registry.instance().getConnectedServices(connection);
+ // if any service is in-use, then connection is in-use
+ for (IConnectedService connectedService : connectedServices) {
+ IConnectedService.IStatus status = connectedService.getStatus();
+ if (status.getEStatus().equals(IConnectedService.IStatus.EStatus.IN_USE))
+ return status;
+ }
+
+ return null;
+ }
+
+ public static boolean isConnectionInUse(IConnection connection) {
+ return getFirstInUseStatus(connection) != null;
+ }
+
+ private static final ImageDescriptor STATUS_AVAIL_IMGDESC =
+ RemoteConnectionsActivator.getImageDescriptor("icons/statusAvailable.png"); //$NON-NLS-1$
+ private static final ImageDescriptor STATUS_UNAVAIL_IMGDESC =
+ RemoteConnectionsActivator.getImageDescriptor("icons/statusUnavailable.png"); //$NON-NLS-1$
+ private static final ImageDescriptor STATUS_UNK_IMGDESC =
+ RemoteConnectionsActivator.getImageDescriptor("icons/statusUnknown.png"); //$NON-NLS-1$
+ private static final ImageDescriptor STATUS_INUSE_IMGDESC =
+ RemoteConnectionsActivator.getImageDescriptor("icons/statusInUse.png"); //$NON-NLS-1$
+
+ private static final ImageDescriptor CONNECTION_READY_IMGDESC =
+ RemoteConnectionsActivator.getImageDescriptor("icons/connectionStatusReady.png"); //$NON-NLS-1$
+ private static final ImageDescriptor CONNECTION_IN_USE_IMGDESC =
+ RemoteConnectionsActivator.getImageDescriptor("icons/connectionStatusInUse.png"); //$NON-NLS-1$
+ private static final ImageDescriptor CONNECTION_NOT_READY_IMGDESC =
+ RemoteConnectionsActivator.getImageDescriptor("icons/connectionStatusNotReady.png"); //$NON-NLS-1$
+ private static final ImageDescriptor CONNECTION_IN_USE_DISCONNECTED_IMGDESC =
+ RemoteConnectionsActivator.getImageDescriptor("icons/connectionStatusDisconnected.png"); //$NON-NLS-1$
+
+ private static final ImageDescriptor CONNECTION_IMGDESC =
+ RemoteConnectionsActivator.getImageDescriptor("icons/connection.png"); //$NON-NLS-1$
+
+ private static final Image STATUS_AVAIL_IMG = STATUS_AVAIL_IMGDESC.createImage();
+ private static final Image STATUS_UNAVAIL_IMG = STATUS_UNAVAIL_IMGDESC.createImage();
+ private static final Image STATUS_INUSE_IMG = STATUS_INUSE_IMGDESC.createImage();
+ private static final Image STATUS_UNK_IMG = STATUS_UNK_IMGDESC.createImage();
+
+ private static final Image CONNECTION_READY_IMG = CONNECTION_READY_IMGDESC.createImage();
+ private static final Image CONNECTION_IN_USE_IMG = CONNECTION_IN_USE_IMGDESC.createImage();
+ private static final Image CONNECTION_NOT_READY_IMG = CONNECTION_NOT_READY_IMGDESC.createImage();
+ private static final Image CONNECTION_IN_USE_DISCONNECTED_IMG = CONNECTION_IN_USE_DISCONNECTED_IMGDESC.createImage();
+
+ private static final Image CONNECTION_IMG = CONNECTION_IMGDESC.createImage();
+
+ public static final Color COLOR_RED = new Color(Display.getDefault(), 192, 0, 0);
+ public static final Color COLOR_GREEN = new Color(Display.getDefault(), 0, 128, 0);
+ public static final Color COLOR_ELECTRIC = new Color(Display.getDefault(), 0, 0, 255);
+ public static final Color COLOR_GREY = new Color(Display.getDefault(), 96, 96, 96);
+
+ /**
+ * Get the image representing the connection status.
+ * @param connection
+ * @return Image, not to be disposed
+ */
+ public static Image getConnectionStatusImage(IConnection2.IStatus status) {
+ if (status != null) {
+ IConnection2.IStatus.EStatus severity = status.getEStatus();
+
+ switch (severity) {
+ case READY:
+ return CONNECTION_READY_IMG;
+ case IN_USE:
+ return CONNECTION_IN_USE_IMG;
+ case NOT_READY:
+ return CONNECTION_NOT_READY_IMG;
+ case IN_USE_DISCONNECTED:
+ return CONNECTION_IN_USE_DISCONNECTED_IMG;
+ }
+ }
+ return ConnectionUIUtils.CONNECTION_IMG;
+ }
+
+ /**
+ * Get the image representing the connection status.
+ * @param connection
+ * @return Image, not to be disposed
+ */
+ public static Image getConnectionImage(IConnection connection) {
+ if (connection instanceof IConnection2) {
+ IConnection2.IStatus status = ((IConnection2) connection).getStatus();
+ return getConnectionStatusImage(status);
+ }
+ if (isConnectionInUse(connection)) {
+ return ConnectionUIUtils.STATUS_INUSE_IMG;
+ }
+ return ConnectionUIUtils.CONNECTION_IMG;
+ }
+
+ /**
+ * @param status
+ * @return
+ */
+ public static Image getConnectedServiceStatusImage(IConnectedService.IStatus.EStatus status) {
+ switch (status) {
+ case DOWN:
+ return ConnectionUIUtils.STATUS_UNAVAIL_IMG;
+ case UP:
+ return ConnectionUIUtils.STATUS_AVAIL_IMG;
+ case IN_USE:
+ return ConnectionUIUtils.CONNECTION_IMG;
+ case UNKNOWN:
+ return ConnectionUIUtils.STATUS_UNK_IMG;
+ }
+ return null;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/DeviceStatusSelectorContribution.java Fri Dec 18 09:34:19 2009 -0600
@@ -0,0 +1,357 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of the License "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+package com.nokia.carbide.remoteconnections.internal.ui;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.CLabel;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.menus.WorkbenchWindowControlContribution;
+
+import com.nokia.carbide.remoteconnections.Messages;
+import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
+import com.nokia.carbide.remoteconnections.interfaces.IConnection;
+import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager;
+import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionListener;
+import com.nokia.carbide.remoteconnections.internal.api.IConnection2;
+import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IStatus;
+import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IStatusChangedListener;
+import com.nokia.carbide.remoteconnections.view.ConnectionsView;
+import com.nokia.cpp.internal.api.utils.core.TextUtils;
+import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils;
+
+
+/**
+ * This widget appears in the Eclipse trim and allows the user to select the
+ * "default" device connection and also see its status at a glance.
+ */
+public class DeviceStatusSelectorContribution extends WorkbenchWindowControlContribution
+ implements IConnectionListener, IStatusChangedListener {
+
+ private Composite container;
+ private CLabel deviceInfo;
+ private IConnectionsManager manager;
+ private Image deviceImage;
+ private IConnection defaultConnection;
+
+ public DeviceStatusSelectorContribution() {
+ manager = RemoteConnectionsActivator.getConnectionsManager();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.ControlContribution#createControl(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createControl(Composite parent) {
+
+ // This UI is recreated whenever the default connection changes.
+
+ manager.addConnectionListener(this);
+
+ container = new Composite(parent, SWT.NONE);
+ GridLayoutFactory.fillDefaults().margins(2, 0).applyTo(container);
+
+ // Create a label for the trim.
+ deviceInfo = new CLabel(container, SWT.FLAT);
+ GridDataFactory.fillDefaults().grab(false, true).applyTo(deviceInfo);
+
+ String text = Messages.getString("DeviceStatusSelectorContribution_NoDefaultConnectionMessage"); //$NON-NLS-1$
+ defaultConnection = manager.getDefaultConnection();
+ if (defaultConnection != null) {
+ text = defaultConnection.getDisplayName();
+ if (defaultConnection instanceof IConnection2) {
+ ((IConnection2) defaultConnection).addStatusChangedListener(DeviceStatusSelectorContribution.this);
+ }
+ }
+
+ deviceInfo.setText(text);
+
+ updateDeviceStatus(getDeviceStatus(defaultConnection));
+
+ deviceInfo.addMouseListener (new MouseAdapter() {
+ public void mouseDown(MouseEvent event) {
+ Shell shell = deviceInfo.getShell();
+ final Display display = shell.getDisplay();
+
+ final Menu menu = new Menu(shell, SWT.POP_UP);
+ populateConnectionMenu(menu);
+
+ Point screenLoc = deviceInfo.toDisplay(event.x, event.y);
+ menu.setLocation(screenLoc.x, screenLoc.y);
+ menu.setVisible(true);
+
+ while (!menu.isDisposed() && menu.isVisible()) {
+ if (!display.readAndDispatch())
+ display.sleep();
+ }
+ menu.dispose();
+ }
+ /* (non-Javadoc)
+ * @see org.eclipse.swt.events.MouseAdapter#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
+ */
+ @Override
+ public void mouseDoubleClick(MouseEvent ev) {
+ // NOTE: the menu usually comes up before double-click is seen
+ if (ev.button == 1) {
+ openConnectionsView();
+ }
+ }
+ });
+
+ // TODO PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, null);
+ return container;
+ }
+
+ /**
+ * @param ev
+ */
+ protected void openConnectionsView() {
+ try {
+ WorkbenchUtils.getView(ConnectionsView.VIEW_ID);
+ }
+ catch (PartInitException e) {
+ RemoteConnectionsActivator.logError(e);
+ }
+ }
+
+ /**
+ * @param defaultConnection
+ * @param status
+ * @return
+ */
+ private String createDeviceStatusTooltip(IConnection defaultConnection,
+ IStatus status) {
+ if (defaultConnection == null) {
+ return Messages.getString("DeviceStatusSelectorContribution.NoDynamicOrManualConnectionsTooltip"); //$NON-NLS-1$
+ }
+
+ String statusString = null;
+ if (status != null) {
+ statusString = status.getDescription();
+ }
+
+ if (TextUtils.isEmpty(statusString))
+ statusString = Messages.getString("DeviceStatusSelectorContribution.UnknownStatus"); //$NON-NLS-1$
+
+ return MessageFormat.format(Messages.getString("DeviceStatusSelectorContribution.DeviceStatusFormat"), defaultConnection.getDisplayName(), statusString); //$NON-NLS-1$
+ }
+
+ /**
+ * Get the image representing the device status.
+ * @param connection
+ * @return Image, to be disposed
+ */
+ private IStatus getDeviceStatus(IConnection connection) {
+ if (!(connection instanceof IConnection2)) {
+ return null;
+ } else {
+ return ((IConnection2) connection).getStatus();
+ }
+ }
+
+ /**
+ * @return
+ */
+ protected void populateConnectionMenu(Menu menu) {
+ IConnection defaultConnection = manager.getDefaultConnection();
+
+ // Display the connections with dynamic ones first,
+ // then static ones, separated by a separator
+
+ List<IConnection> dynamicConnections = new ArrayList<IConnection>();
+ List<IConnection> staticConnections = new ArrayList<IConnection>();
+ for (IConnection connection : RemoteConnectionsActivator.getConnectionsManager().getConnections()) {
+ if (connection instanceof IConnection2 && ((IConnection2)connection).isDynamic())
+ dynamicConnections.add(connection);
+ else
+ staticConnections.add(connection);
+ }
+
+
+ Comparator<IConnection> connectionComparator = new Comparator<IConnection>() {
+ public int compare(IConnection o1, IConnection o2) {
+ return o1.getDisplayName().compareToIgnoreCase(o2.getDisplayName());
+ }
+ };
+ Collections.sort(dynamicConnections, connectionComparator);
+ Collections.sort(staticConnections, connectionComparator);
+
+ MenuItem label = new MenuItem(menu, SWT.NONE);
+ label.setEnabled(false);
+ label.setText(Messages.getString("DeviceStatusSelectorContribution_SelectTheDefaultConnectionMessage")); //$NON-NLS-1$
+
+ for (IConnection connection : dynamicConnections) {
+ createConnectionMenuItem(menu, connection, defaultConnection);
+ }
+
+ new MenuItem(menu, SWT.SEPARATOR);
+
+ for (IConnection connection : staticConnections) {
+ createConnectionMenuItem(menu, connection, defaultConnection);
+ }
+
+ new MenuItem(menu, SWT.SEPARATOR);
+
+ MenuItem openView = new MenuItem(menu, SWT.PUSH);
+ openView.setText("Open Remote Connections view");
+ openView.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ openConnectionsView();
+ }
+ });
+ }
+
+ /**
+ * @param menu
+ * @param connection
+ * @param defaultConnection
+ */
+ private MenuItem createConnectionMenuItem(Menu menu, final IConnection connection, IConnection defaultConnection) {
+ MenuItem item = new MenuItem(menu, SWT.CHECK);
+
+ boolean isDefault = false;
+ isDefault = connection.equals(defaultConnection);
+
+ item.setSelection(isDefault);
+
+ item.setText(connection.getDisplayName());
+
+ item.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ manager.setDefaultConnection(connection);
+ }
+ });
+
+ return item;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.ContributionItem#dispose()
+ */
+ public void dispose() {
+ if (deviceImage != null) {
+ deviceImage.dispose();
+ deviceImage = null;
+ }
+ if (defaultConnection instanceof IConnection2)
+ ((IConnection2) defaultConnection).removeStatusChangedListener(this);
+
+ manager.removeConnectionListener(this);
+ super.dispose();
+ }
+
+ /* (non-Javadoc)
+ * @see com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionListener#connectionAdded(com.nokia.carbide.remoteconnections.interfaces.IConnection)
+ */
+ public void connectionAdded(IConnection connection) {
+ updateUI();
+ }
+
+ /* (non-Javadoc)
+ * @see com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionListener#connectionRemoved(com.nokia.carbide.remoteconnections.interfaces.IConnection)
+ */
+ public void connectionRemoved(IConnection connection) {
+ updateUI();
+ }
+ /* (non-Javadoc)
+ * @see com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionListener#defaultConnectionSet(com.nokia.carbide.remoteconnections.interfaces.IConnection)
+ */
+ public void defaultConnectionSet(IConnection connection) {
+ updateUI();
+ }
+
+ /* (non-Javadoc)
+ * @see com.nokia.carbide.remoteconnections.internal.IConnection2.IStatusChangedListener#statusChanged(com.nokia.carbide.remoteconnections.internal.IConnection2.IStatus)
+ */
+ public void statusChanged(IStatus status) {
+ updateDeviceStatus(status);
+ }
+
+ /**
+ * @param status
+ */
+ private void updateDeviceStatus(IStatus status) {
+ if (deviceImage != null)
+ deviceImage.dispose();
+
+ deviceImage = ConnectionUIUtils.getConnectionStatusImage(status);
+ deviceInfo.setImage(deviceImage);
+ deviceInfo.setToolTipText(createDeviceStatusTooltip(defaultConnection, status));
+ }
+
+ /**
+ *
+ */
+ private void updateUI() {
+ // perform update in UI thread
+ final IWorkbench workbench = PlatformUI.getWorkbench();
+ workbench.getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
+ if (window != null) {
+ update();
+ }
+ }
+ });
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.ContributionItem#isDynamic()
+ */
+ @Override
+ public boolean isDynamic() {
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.action.ContributionItem#update()
+ */
+ @Override
+ public void update() {
+ getParent().update(true);
+ }
+
+}
\ No newline at end of file
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/messages.properties Fri Dec 18 09:30:04 2009 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/messages.properties Fri Dec 18 09:34:19 2009 -0600
@@ -51,6 +51,11 @@
ConnectionTypePage.SupportedServicesLabel=Supported Services: {0}
ConnectionTypePage.Title=Edit connection name and type
ConnectionTypePage.ViewerLabel=Connection Type:
+DeviceStatusSelectorContribution_NoDefaultConnectionMessage=No default connection
+DeviceStatusSelectorContribution_SelectTheDefaultConnectionMessage=Select the default connection:
+DeviceStatusSelectorContribution.DeviceStatusFormat={0}: {1}
+DeviceStatusSelectorContribution.NoDynamicOrManualConnectionsTooltip=No default connection selected.
+DeviceStatusSelectorContribution.UnknownStatus=Unknown status
ExportPage.BrowseGroupLabel=Connections file:
ExportPage.Description=Select connections to export
ExportPage.FileDialogTitle=Save As
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/OnDeviceConnectionAction.java Fri Dec 18 09:30:04 2009 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/OnDeviceConnectionAction.java Fri Dec 18 09:34:19 2009 -0600
@@ -19,6 +19,8 @@
package com.nokia.carbide.remoteconnections.settings.ui;
import com.nokia.carbide.remoteconnections.RemoteConnectionsActivator;
+import com.nokia.carbide.remoteconnections.view.ConnectionsView;
+import com.nokia.cpp.internal.api.utils.ui.WorkbenchUtils;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
@@ -37,14 +39,11 @@
public void run(IAction action) {
// Ensure the remote connections view is visible
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- try {
- page.showView("com.nokia.carbide.remoteconnections.view.ConnectionsView"); //$NON-NLS-1$
- }
- catch (PartInitException e) {
- RemoteConnectionsActivator.logError(e);
- }
+ try {
+ WorkbenchUtils.getView(ConnectionsView.VIEW_ID);
+ }
+ catch (PartInitException e) {
+ RemoteConnectionsActivator.logError(e);
}
// Launch the new connection wizard
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/view/ConnectionsView.java Fri Dec 18 09:30:04 2009 -0600
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/view/ConnectionsView.java Fri Dec 18 09:34:19 2009 -0600
@@ -80,6 +80,7 @@
import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionsManagerListener;
import com.nokia.carbide.remoteconnections.internal.api.IConnection2;
import com.nokia.carbide.remoteconnections.internal.registry.Registry;
+import com.nokia.carbide.remoteconnections.internal.ui.ConnectionUIUtils;
import com.nokia.carbide.remoteconnections.settings.ui.SettingsWizard;
import com.nokia.cpp.internal.api.utils.core.TextUtils;
@@ -89,6 +90,7 @@
*/
@SuppressWarnings("deprecation")
public class ConnectionsView extends ViewPart {
+ public static final String VIEW_ID = "com.nokia.carbide.remoteconnections.view.ConnectionsView"; //$NON-NLS-1$
private TreeViewer viewer;
private IConnectionsManagerListener connectionStoreChangedListener;
@@ -98,33 +100,11 @@
private List<Action> serviceSelectedActions;
private static final String UID = ".uid"; //$NON-NLS-1$
- private static final ImageDescriptor STATUS_AVAIL_IMGDESC =
- RemoteConnectionsActivator.getImageDescriptor("icons/statusAvailable.png"); //$NON-NLS-1$
- private static final ImageDescriptor STATUS_UNAVAIL_IMGDESC =
- RemoteConnectionsActivator.getImageDescriptor("icons/statusUnavailable.png"); //$NON-NLS-1$
- private static final ImageDescriptor STATUS_UNK_IMGDESC =
- RemoteConnectionsActivator.getImageDescriptor("icons/statusUnknown.png"); //$NON-NLS-1$
- private static final ImageDescriptor CONNECTION_IMGDESC =
- RemoteConnectionsActivator.getImageDescriptor("icons/connection.png"); //$NON-NLS-1$
- private static final ImageDescriptor CONNECTION_NEW_IMGDESC =
- RemoteConnectionsActivator.getImageDescriptor("icons/connectionNew.png"); //$NON-NLS-1$
- private static final ImageDescriptor CONNECTION_EDIT_IMGDESC =
- RemoteConnectionsActivator.getImageDescriptor("icons/connectionEdit.png"); //$NON-NLS-1$
- private static final ImageDescriptor SERVICE_TEST_IMGDESC =
- RemoteConnectionsActivator.getImageDescriptor("icons/serviceTest.png"); //$NON-NLS-1$
- private static final ImageDescriptor STATUS_INUSE_IMGDESC =
- RemoteConnectionsActivator.getImageDescriptor("icons/statusInUse.png"); //$NON-NLS-1$
- private static final ImageDescriptor CONNECTION_REFRESH_IMGDESC =
- RemoteConnectionsActivator.getImageDescriptor("icons/connectionRefresh.png"); //$NON-NLS-1$
- private static final Image STATUS_AVAIL_IMG = STATUS_AVAIL_IMGDESC.createImage();
- private static final Image STATUS_UNAVAIL_IMG = STATUS_UNAVAIL_IMGDESC.createImage();
- private static final Image STATUS_INUSE_IMG = STATUS_INUSE_IMGDESC.createImage();
- private static final Image STATUS_UNK_IMG = STATUS_UNK_IMGDESC.createImage();
- private static final Image CONNECTION_IMG = CONNECTION_IMGDESC.createImage();
- private static final Color COLOR_RED = new Color(Display.getDefault(), 192, 0, 0);
- private static final Color COLOR_GREEN = new Color(Display.getDefault(), 0, 128, 0);
- private static final Color COLOR_ELECTRIC = new Color(Display.getDefault(), 0, 0, 255);
- private static final Color COLOR_GREY = new Color(Display.getDefault(), 96, 96, 96);
+ private static final ImageDescriptor CONNECTION_NEW_IMGDESC = RemoteConnectionsActivator.getImageDescriptor("icons/connectionNew.png"); //$NON-NLS-1$
+ private static final ImageDescriptor CONNECTION_EDIT_IMGDESC = RemoteConnectionsActivator.getImageDescriptor("icons/connectionEdit.png"); //$NON-NLS-1$
+ private static final ImageDescriptor SERVICE_TEST_IMGDESC = RemoteConnectionsActivator.getImageDescriptor("icons/serviceTest.png"); //$NON-NLS-1$
+ private static final ImageDescriptor CONNECTION_REFRESH_IMGDESC = RemoteConnectionsActivator.getImageDescriptor("icons/connectionRefresh.png"); //$NON-NLS-1$
+
private static final String NEW_ACTION = "ConnectionsView.new"; //$NON-NLS-1$
private static final String EDIT_ACTION = "ConnectionsView.edit"; //$NON-NLS-1$
private static final String RENAME_ACTION = "ConnectionsView.rename"; //$NON-NLS-1$
@@ -225,26 +205,14 @@
TreeNode node = (TreeNode) obj;
Object value = node.getValue();
if (value instanceof IConnection) {
- if (isConnectionInUse((IConnection) value)) {
- return STATUS_INUSE_IMG;
- }
- return CONNECTION_IMG;
+ return ConnectionUIUtils.getConnectionImage((IConnection) value);
}
else if (value instanceof IConnectedService) {
EStatus status = ((IConnectedService) value).getStatus().getEStatus();
IConnection connection = findConnection((IConnectedService) value);
if (connection != null && isConnectionInUse(connection))
status = EStatus.IN_USE;
- switch (status) {
- case DOWN:
- return STATUS_UNAVAIL_IMG;
- case UP:
- return STATUS_AVAIL_IMG;
- case IN_USE:
- return CONNECTION_IMG;
- case UNKNOWN:
- return STATUS_UNK_IMG;
- }
+ return ConnectionUIUtils.getConnectedServiceStatusImage(status);
}
return null;
}
@@ -281,15 +249,15 @@
EStatus status = ((IConnectedService) value).getStatus().getEStatus();
switch (status) {
case DOWN:
- return COLOR_RED;
+ return ConnectionUIUtils.COLOR_RED;
case UP:
- return COLOR_GREEN;
+ return ConnectionUIUtils.COLOR_GREEN;
case UNKNOWN:
- return COLOR_GREY;
+ return ConnectionUIUtils.COLOR_GREY;
}
}
else if (value instanceof IConnection) // only showing in-use for connections
- return COLOR_ELECTRIC;
+ return ConnectionUIUtils.COLOR_ELECTRIC;
return null;
}
--- a/core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/ui/NewsControlContribution.java Fri Dec 18 09:30:04 2009 -0600
+++ b/core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/ui/NewsControlContribution.java Fri Dec 18 09:34:19 2009 -0600
@@ -45,6 +45,7 @@
private static NewsControlContribution sharedInstance;
private Label label;
private boolean alert;
+ private Composite container;
/**
* The constructor.
@@ -61,12 +62,12 @@
*/
@Override
protected Control createControl(Composite parent) {
- Composite container = new Composite(parent, SWT.NONE);
+ container = new Composite(parent, SWT.NONE);
GridLayoutFactory.fillDefaults().margins(2, 2).applyTo(container);
// Create a label for the trim.
- label = new Label(container, SWT.CENTER);
- GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).applyTo(label);
+ label = new Label(container, SWT.BOTTOM);
+ GridDataFactory.swtDefaults().grab(false, true).applyTo(label);
String text = CarbideNewsReaderPlugin.getFeedManager().getUnreadEntriesCount() + " unread";
label.setText(text);
if (alert) {
@@ -74,7 +75,7 @@
label.setFont(font);
alert = false;
}
-
+
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, NewsUIHelpIDs.NEWSREADER_TRIM_COMMAND);
return container;
}