--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/RemoteConnectionsActivator.java Tue Aug 17 14:51:17 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/RemoteConnectionsActivator.java Tue Aug 17 15:04:12 2010 -0500
@@ -27,6 +27,7 @@
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -44,6 +45,7 @@
import com.nokia.carbide.remoteconnections.internal.api.IDeviceDiscoveryAgent;
import com.nokia.carbide.remoteconnections.internal.api.IDeviceDiscoveryAgent.IPrerequisiteStatus;
import com.nokia.carbide.remoteconnections.internal.api.IStatusDisplay;
+import com.nokia.carbide.remoteconnections.internal.api.IToggleServicesTestingListener;
import com.nokia.carbide.remoteconnections.internal.registry.Registry;
import com.nokia.carbide.remoteconnections.internal.ui.DeviceDiscoveryPrequisiteErrorDialog;
import com.nokia.carbide.remoteconnections.internal.ui.StatusDisplay;
@@ -103,15 +105,18 @@
private Collection<IDeviceDiscoveryAgent> discoveryAgents;
private ListenerList<IDiscoveryAgentsLoadedListener> listeners;
+ private ListenerList<IToggleServicesTestingListener> toggleServicesListeners;
private static final String IGNORE_AGENT_LOAD_ERRORS_KEY = "ignoreAgentLoadErrors"; //$NON-NLS-1$
private static final String AGENT_STATE_KEY_PREFIX = "agentState."; //$NON-NLS-1$
+ private static final String SHOULD_TEST_SERVICES_PREF_ID = "shouldTestServices"; //$NON-NLS-1$
/**
* The constructor
*/
public RemoteConnectionsActivator() {
listeners = new ListenerList<IDiscoveryAgentsLoadedListener>();
+ toggleServicesListeners = new ListenerList<IToggleServicesTestingListener>();
}
public void start(BundleContext context) throws Exception {
@@ -120,7 +125,8 @@
Registry instance = Registry.instance();
instance.loadExtensions();
instance.loadConnections();
-
+ fireToggleServicesTestingListener(getShouldTestServices());
+
new WhenWorkbenchIsVisibleThread(new Runnable() {
public void run() {
if (!ignoreAgentLoadErrors())
@@ -343,4 +349,38 @@
listener.agentsAreLoaded();
}
}
+
+ public boolean getShouldTestServices() {
+ IEclipsePreferences eclipsePreferences = new InstanceScope().getNode(PLUGIN_ID);
+ return eclipsePreferences.getBoolean(SHOULD_TEST_SERVICES_PREF_ID, true);
+ }
+
+ public void setShouldTestServices(boolean shouldTest) {
+ boolean currentState = getShouldTestServices();
+ if (shouldTest == currentState)
+ return;
+ fireToggleServicesTestingListener(shouldTest);
+ try {
+ IEclipsePreferences eclipsePreferences = new InstanceScope().getNode(PLUGIN_ID);
+ eclipsePreferences.putBoolean(SHOULD_TEST_SERVICES_PREF_ID, shouldTest);
+ eclipsePreferences.flush();
+ } catch (BackingStoreException e) {
+ logError(e);
+ }
+ }
+
+ public void addToggleServicesTestingListener(IToggleServicesTestingListener listener) {
+ toggleServicesListeners.add(listener);
+ }
+
+ public void removeToggleServicesTestingListener(IToggleServicesTestingListener listener) {
+ toggleServicesListeners.remove(listener);
+ }
+
+ private void fireToggleServicesTestingListener(boolean enabled) {
+ for (IToggleServicesTestingListener listener : toggleServicesListeners) {
+ listener.servicesTestingToggled(enabled);
+ }
+ }
+
}
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/AbstractConnectedService2.java Tue Aug 17 14:51:17 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/interfaces/AbstractConnectedService2.java Tue Aug 17 15:04:12 2010 -0500
@@ -197,14 +197,14 @@
return ServiceTester.getInstance().isRegistered(this);
}
- public void setEnabled(boolean enabled) {
+ public void setEnabled(boolean enable) {
if (!service.isTestable())
return;
- if (enabled && !isEnabled()) {
+ if (enable && !isEnabled()) {
Check.checkState(connection.getSettings() != null);
ServiceTester.getInstance().register(this);
}
- else if (!enabled && isEnabled()) {
+ else if (!enable) {
ServiceTester.getInstance().unregister(this);
currentStatus.setEStatus(EStatus.UNKNOWN,
Messages.getString("AbstractConnectedService.NoTestingLabel"), //$NON-NLS-1$
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/api/IToggleServicesTestingListener.java Tue Aug 17 15:04:12 2010 -0500
@@ -0,0 +1,23 @@
+/*
+* 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.api;
+
+public interface IToggleServicesTestingListener {
+
+ void servicesTestingToggled(boolean enabled);
+
+}
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/registry/Registry.java Tue Aug 17 14:51:17 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/registry/Registry.java Tue Aug 17 15:04:12 2010 -0500
@@ -31,6 +31,7 @@
import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeSet;
import java.util.UUID;
@@ -59,6 +60,7 @@
import com.nokia.carbide.remoteconnections.interfaces.IService;
import com.nokia.carbide.remoteconnections.interfaces.AbstractConnection.ConnectionStatus;
import com.nokia.carbide.remoteconnections.internal.api.IConnection2;
+import com.nokia.carbide.remoteconnections.internal.api.IToggleServicesTestingListener;
import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatus;
import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatusChangedListener;
import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatus.EConnectionStatus;
@@ -119,6 +121,11 @@
loadServiceExtensions();
loadConnectedServiceFactoryExtensions();
mapConnectionTypeToServices();
+ RemoteConnectionsActivator.getDefault().addToggleServicesTestingListener(new IToggleServicesTestingListener() {
+ public void servicesTestingToggled(boolean enabled) {
+ setShouldTestServices(enabled);
+ }
+ });
}
private void loadConnectedServiceFactoryExtensions() {
@@ -338,6 +345,9 @@
fireConnectionAdded(connection);
setLastConnectionId(connection.getIdentifier());
+ for (IConnectedService connectedService : connectedServices) {
+ connectedService.setEnabled(RemoteConnectionsActivator.getDefault().getShouldTestServices());
+ }
}
private void ensureUniqueId(IConnection connection) {
@@ -690,4 +700,12 @@
return;
RemoteConnectionsActivator.getDefault().getPreferenceStore().setValue(LAST_CONNECTION_ID, id);
}
+
+ private void setShouldTestServices(boolean shouldTest) {
+ for (Entry<IConnection, List<IConnectedService>> entry : connectionToConnectedServices.entrySet()) {
+ for (IConnectedService connectedService : entry.getValue()) {
+ connectedService.setEnabled(shouldTest);
+ }
+ }
+ }
}
\ No newline at end of file
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ConnectionStatusSelectorContribution.java Tue Aug 17 14:51:17 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/internal/ui/ConnectionStatusSelectorContribution.java Tue Aug 17 15:04:12 2010 -0500
@@ -330,6 +330,20 @@
openConnectionsView();
}
});
+
+ new MenuItem(menu, SWT.SEPARATOR);
+
+ final MenuItem toggleServicesTestingItem = new MenuItem(menu, SWT.CHECK);
+ toggleServicesTestingItem.setText(Messages.getString("ConnectionStatusSelectorContribution.TestServicesMenuLabel")); //$NON-NLS-1$
+ toggleServicesTestingItem.setSelection(RemoteConnectionsActivator.getDefault().getShouldTestServices());
+ toggleServicesTestingItem.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ boolean state = !RemoteConnectionsActivator.getDefault().getShouldTestServices();
+ RemoteConnectionsActivator.getDefault().setShouldTestServices(state);
+ toggleServicesTestingItem.setSelection(state);
+ }
+ });
}
/**
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/messages.properties Tue Aug 17 14:51:17 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/messages.properties Tue Aug 17 15:04:12 2010 -0500
@@ -1,5 +1,5 @@
-AbstractConnectedService.UserDisabledMessage=User disabled active status testing
-AbstractConnectedService.NoTestingLabel=Not testing service
+AbstractConnectedService.UserDisabledMessage=Not testing service
+AbstractConnectedService.NoTestingLabel=Unknown
AbstractImportExportPage.BrowseButtonLabel=Browse...
AbstractImportExportPage.ConnectionColumnLabel=Connection
AbstractImportExportPage.TypeColumnLabel=Type
@@ -64,6 +64,7 @@
ConnectionsView.StatusColumnHeader=Status
ConnectionsView.EnableTestActionLabel=Enable Service Testing
ConnectionsView.DisableTestActionLabel=Disable Service Testing
+ConnectionsView.ToggleServicesLabel=Toggle periodic service testing
ConnectionsView.TypeColumnHeader=Type
ConnectionsView.InUseLabel=In use
ConnectionsView.InUseDesc=At least one service is using this connection
@@ -85,6 +86,7 @@
ConnectionStatusSelectorContribution.NoDynamicOrManualConnectionsTooltip=No current connection selected.
ConnectionStatusSelectorContribution.NotInUse=Not in use
ConnectionStatusSelectorContribution.StatusFormat=Connection is {0}: {1}
+ConnectionStatusSelectorContribution.TestServicesMenuLabel=Test services
DeviceDiscoveryPrequisiteErrorDialog_Description=At least one device discovery agent had load errors that prevent it from discovering connections to devices. Select one to get more information about its error.
DeviceDiscoveryPrequisiteErrorDialog_DontAskAgainLabel=Don't ask again
DeviceDiscoveryPrequisiteErrorDialog_DontAskAgainToolTipText=Check this to ignore further discovery agent load errors
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionSettingsPage.java Tue Aug 17 14:51:17 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/settings/ui/ConnectionSettingsPage.java Tue Aug 17 15:04:12 2010 -0500
@@ -1071,7 +1071,7 @@
private String getInitialNameText() {
IConnection connectionToEdit = settingsWizard.getConnectionToEdit();
if (connectionToEdit != null) {
- generatedName = "";
+ generatedName = ""; //$NON-NLS-1$
return connectionToEdit.getDisplayName();
}
--- a/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/view/ConnectionsView.java Tue Aug 17 14:51:17 2010 -0500
+++ b/connectivity/com.nokia.carbide.remoteConnections/src/com/nokia/carbide/remoteconnections/view/ConnectionsView.java Tue Aug 17 15:04:12 2010 -0500
@@ -89,6 +89,7 @@
import com.nokia.carbide.remoteconnections.interfaces.IConnectionsManager.IConnectionsManagerListener;
import com.nokia.carbide.remoteconnections.internal.ToggleDiscoveryAgentAction;
import com.nokia.carbide.remoteconnections.internal.api.IConnection2;
+import com.nokia.carbide.remoteconnections.internal.api.IToggleServicesTestingListener;
import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatus;
import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatus.EConnectionStatus;
import com.nokia.carbide.remoteconnections.internal.api.IConnection2.IConnectionStatusChangedListener;
@@ -110,6 +111,7 @@
private TreeViewer viewer;
private IConnectionsManagerListener connectionStoreChangedListener;
private IConnectionListener connectionListener;
+ private IToggleServicesTestingListener toggleServicesTestingListener;
private Map<IConnectedService, IStatusChangedListener> serviceToListenerMap;
private Map<IConnection2, IConnectionStatusChangedListener> connectionToListenerMap;
private List<Action> actions;
@@ -131,6 +133,7 @@
private static final String DELETE_ACTION = "ConnectionsView.delete"; //$NON-NLS-1$
private static final String HELP_ACTION = "ConnectionsView.help"; //$NON-NLS-1$
private static final String SET_CURRENT_ACTION = "ConnectionsView.makeCurrent"; //$NON-NLS-1$
+ private static final String TOGGLE_SERVICES_ACTION = "ConnectionsView.toggleServices"; //$NON-NLS-1$
private KeyAdapter keyListener;
private boolean isDisposed;
@@ -175,7 +178,6 @@
};
connectedService.addStatusChangedListener(statusChangedListener);
serviceToListenerMap.put(connectedService, statusChangedListener);
- connectedService.setEnabled(true);
serviceNodes.add(treeNode);
}
for (TreeNode serviceNode : serviceNodes) {
@@ -456,7 +458,8 @@
@Override
public boolean isEnabled() {
IConnectedService connectedService = getSelectedConnectedService();
- return connectedService != null && connectedService.getService().isTestable();
+ return connectedService != null && connectedService.getService().isTestable() &&
+ RemoteConnectionsActivator.getDefault().getShouldTestServices();
}
}
@@ -533,10 +536,12 @@
wizard.open(getViewSite().getShell());
}
else if (value instanceof IConnectedService) {
- IConnectedService connectedService = (IConnectedService) value;
- connectedService.setEnabled(true);
- connectedService.testStatus();
- ((EnableConnectedServiceAction) getAction(ENABLE_SERVICE_ACTION)).updateLabel();
+ if (RemoteConnectionsActivator.getDefault().getShouldTestServices()) {
+ IConnectedService connectedService = (IConnectedService) value;
+ connectedService.setEnabled(true);
+ connectedService.testStatus();
+ ((EnableConnectedServiceAction) getAction(ENABLE_SERVICE_ACTION)).updateLabel();
+ }
}
}
}
@@ -690,6 +695,7 @@
}
private void fillLocalToolBar(IToolBarManager manager) {
+ manager.add(getAction(TOGGLE_SERVICES_ACTION));
manager.add(getAction(REFRESH_ACTION));
manager.add(getAction(NEW_ACTION));
manager.add(getAction(EDIT_ACTION));
@@ -778,6 +784,7 @@
};
action.setAccelerator(SWT.F5);
action.setId(REFRESH_ACTION);
+ action.setEnabled(RemoteConnectionsActivator.getDefault().getShouldTestServices());
actions.add(action);
action = new Action(Messages.getString("ConnectionsView.DeleteActionLabel"), //$NON-NLS-1$
@@ -861,10 +868,31 @@
actions.add(action);
connectionSelectedActions.add(action);
+ action = new Action(Messages.getString("ConnectionsView.ToggleServicesLabel"), IAction.AS_CHECK_BOX) { //$NON-NLS-1$
+ public void setChecked(boolean checked) {
+ if (isChecked() != checked) {
+ super.setChecked(checked);
+ RemoteConnectionsActivator.getDefault().setShouldTestServices(checked);
+ }
+ };
+ };
+ action.setImageDescriptor(SERVICE_TEST_IMGDESC);
+ action.setId(TOGGLE_SERVICES_ACTION);
+ action.setChecked(RemoteConnectionsActivator.getDefault().getShouldTestServices());
+ actions.add(action);
+
enableConnectionSelectedActions(false);
enableServiceSelectedActions(false);
makeToggleDiscoveryAgentActions();
+
+ toggleServicesTestingListener = new IToggleServicesTestingListener() {
+ public void servicesTestingToggled(boolean enabled) {
+ getAction(TOGGLE_SERVICES_ACTION).setChecked(enabled);
+ getAction(REFRESH_ACTION).setEnabled(enabled);
+ }
+ };
+ RemoteConnectionsActivator.getDefault().addToggleServicesTestingListener(toggleServicesTestingListener);
}
private void makeToggleDiscoveryAgentActions() {
@@ -931,24 +959,12 @@
connectionToListenerMap.clear();
}
- private void disableAllConnectedServices() {
- Collection<IConnection> connections =
- Registry.instance().getConnections();
- for (IConnection connection : connections) {
- Collection<IConnectedService> connectedServicesForConnection =
- Registry.instance().getConnectedServices(connection);
- for (IConnectedService connectedService : connectedServicesForConnection) {
- connectedService.setEnabled(false);
- }
- }
- }
-
@Override
public void dispose() {
removeStatusListeners();
Registry.instance().removeConnectionStoreChangedListener(connectionStoreChangedListener);
Registry.instance().removeConnectionListener(connectionListener);
- disableAllConnectedServices();
+ RemoteConnectionsActivator.getDefault().removeToggleServicesTestingListener(toggleServicesTestingListener);
isDisposed = true;
super.dispose();
}