Bug 568721 Remove MarketPlaceClientUi activator

The Bundle-Activator is only used to stop the jobs associated with this
bundle; but the only one that looks out for the `belongsTo` call is the
`MarketPlaceDiscoveryStrategy` which doesn't check for cancellation via
the passed `IProgressMonitor`. As a result, it will run to completion
regardless of whether it's cancelled or not.

Once this call becomes unnecessary, we can remove the Bundle-Activator
from the manifest completely.

Change-Id: I586669078516aa1a382a97a5cd24da0732936a1f
Signed-off-by: Alex Blewitt <alex.blewitt@gmail.com>
diff --git a/org.eclipse.epp.mpc.ui/META-INF/MANIFEST.MF b/org.eclipse.epp.mpc.ui/META-INF/MANIFEST.MF
index 99b4dc3..077ce7d 100644
--- a/org.eclipse.epp.mpc.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.epp.mpc.ui/META-INF/MANIFEST.MF
@@ -39,6 +39,6 @@
  org.eclipse.epp.internal.mpc.ui.wizards;x-internal:=true,
  org.eclipse.epp.mpc.ui
 Bundle-ActivationPolicy: lazy
-Bundle-Activator: org.eclipse.epp.internal.mpc.ui.MarketplaceClientUiPlugin
+Bundle-Activator: org.eclipse.epp.internal.mpc.ui.MarketplaceClientDebug
 Service-Component: OSGI-INF/services/*.xml
 Import-Package: org.w3c.css.sac;version="[1.3.0,2.0.0)"
diff --git a/org.eclipse.epp.mpc.ui/OSGI-INF/services/org.eclipse.epp.mpc.ui.debug.options.xml b/org.eclipse.epp.mpc.ui/OSGI-INF/services/org.eclipse.epp.mpc.ui.debug.options.xml
index fa1713a..8e261ad 100644
--- a/org.eclipse.epp.mpc.ui/OSGI-INF/services/org.eclipse.epp.mpc.ui.debug.options.xml
+++ b/org.eclipse.epp.mpc.ui/OSGI-INF/services/org.eclipse.epp.mpc.ui.debug.options.xml
@@ -4,5 +4,5 @@
    <service>

       <provide interface="org.eclipse.osgi.service.debug.DebugOptionsListener"/>

    </service>

-   <implementation class="org.eclipse.epp.internal.mpc.ui.MarketplaceClientUiPlugin$DebugOptionsInitializer"/>

+   <implementation class="org.eclipse.epp.internal.mpc.ui.MarketplaceClientDebug$DebugOptionsInitializer"/>

 </scr:component>
\ No newline at end of file
diff --git a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/MarketplaceClientUiPlugin.java b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/MarketplaceClientDebug.java
similarity index 77%
rename from org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/MarketplaceClientUiPlugin.java
rename to org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/MarketplaceClientDebug.java
index 63b63ba..9c55ebe 100644
--- a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/MarketplaceClientUiPlugin.java
+++ b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/MarketplaceClientDebug.java
@@ -13,22 +13,18 @@
  *******************************************************************************/
 package org.eclipse.epp.internal.mpc.ui;
 
-import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.epp.internal.mpc.core.util.DebugTraceUtil;
 import org.eclipse.osgi.service.debug.DebugOptions;
 import org.eclipse.osgi.service.debug.DebugOptionsListener;
 import org.eclipse.osgi.service.debug.DebugTrace;
-import org.osgi.framework.BundleActivator;
-import org.osgi.framework.BundleContext;
 import org.osgi.service.component.annotations.Component;
 
 /**
- * bundle activator. Prefer {@link MarketplaceClientUi} where possible.
+ * Used to centralise the debug message processing.
  *
  * @author David Green
  */
-public class MarketplaceClientUiPlugin implements BundleActivator {
-
+public class MarketplaceClientDebug {
 
 	public static final String DEBUG_OPTION = "/debug"; //$NON-NLS-1$
 
@@ -38,19 +34,6 @@
 
 	private static DebugTrace debugTrace;
 
-	public MarketplaceClientUiPlugin() {
-	}
-
-	@Override
-	public void start(BundleContext context) throws Exception {
-	}
-
-	@Override
-	public void stop(BundleContext context) throws Exception {
-		Job.getJobManager().cancel(context.getBundle());
-		debugTrace = null;
-	}
-
 	public static void trace(String option, String message, Object... parameters) {
 		final DebugTrace trace = debugTrace;
 		if (DEBUG && trace != null) {
@@ -70,7 +53,7 @@
 				debugTrace = options.newDebugTrace(MarketplaceClientUi.BUNDLE_ID);
 			}
 			DEBUG = debug;
-			MarketplaceClientUiPlugin.debugTrace = debugTrace;
+			MarketplaceClientDebug.debugTrace = debugTrace;
 		}
 
 	}
diff --git a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/MarketplaceClientUi.java b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/MarketplaceClientUi.java
index 6e0c96c..9b95846 100644
--- a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/MarketplaceClientUi.java
+++ b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/MarketplaceClientUi.java
@@ -136,7 +136,7 @@
 	}
 
 	public static BundleContext getBundleContext() {
-		return FrameworkUtil.getBundle(MarketplaceClientUiPlugin.class).getBundleContext();
+		return FrameworkUtil.getBundle(MarketplaceClientDebug.class).getBundleContext();
 	}
 
 	public static Map<String, IInstallableUnit> computeInstalledIUsById(IProgressMonitor monitor) {
diff --git a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/catalog/MarketplaceDiscoveryStrategy.java b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/catalog/MarketplaceDiscoveryStrategy.java
index 5d5c89b..ec0b420 100644
--- a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/catalog/MarketplaceDiscoveryStrategy.java
+++ b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/catalog/MarketplaceDiscoveryStrategy.java
@@ -165,12 +165,6 @@
 					setUser(false);
 				}
 				@Override
-				public boolean belongsTo(Object family) {
-					BundleContext bundleContext = MarketplaceClientUi.getBundleContext();
-					return bundleContext != null && (family == bundleContext || family == bundleContext.getBundle());
-				}
-
-				@Override
 				protected IStatus run(IProgressMonitor monitor) {
 					try {
 						fMarketplaceInfo.save();
diff --git a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/discovery/DiscoverNatureSupportJob.java b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/discovery/DiscoverNatureSupportJob.java
index 4d4e162..86e97bc 100644
--- a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/discovery/DiscoverNatureSupportJob.java
+++ b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/discovery/DiscoverNatureSupportJob.java
@@ -21,7 +21,7 @@
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.epp.internal.mpc.ui.MarketplaceClientUi;
-import org.eclipse.epp.internal.mpc.ui.MarketplaceClientUiPlugin;
+import org.eclipse.epp.internal.mpc.ui.MarketplaceClientDebug;
 import org.eclipse.epp.internal.mpc.ui.Messages;
 import org.eclipse.epp.mpc.core.model.INode;
 import org.eclipse.epp.mpc.core.model.ISearchResult;
diff --git a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/urlhandling/MarketplaceUriSchemeHandler.java b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/urlhandling/MarketplaceUriSchemeHandler.java
index 7fc2df0..0482775 100644
--- a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/urlhandling/MarketplaceUriSchemeHandler.java
+++ b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/urlhandling/MarketplaceUriSchemeHandler.java
@@ -12,7 +12,7 @@
  *******************************************************************************/
 package org.eclipse.epp.internal.mpc.ui.urlhandling;
 
-import org.eclipse.epp.internal.mpc.ui.MarketplaceClientUiPlugin;
+import org.eclipse.epp.internal.mpc.ui.MarketplaceClientDebug;
 import org.eclipse.epp.mpc.ui.MarketplaceUrlHandler;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.urischeme.IUriSchemeHandler;
@@ -60,8 +60,8 @@
 	}
 
 	private void traceInvalidUrl(String url) {
-		if (MarketplaceClientUiPlugin.DEBUG) {
-			MarketplaceClientUiPlugin.trace(MarketplaceClientUiPlugin.DROP_ADAPTER_DEBUG_OPTION,
+		if (MarketplaceClientDebug.DEBUG) {
+			MarketplaceClientDebug.trace(MarketplaceClientDebug.DROP_ADAPTER_DEBUG_OPTION,
 					"URL handler: Data is not a solution url: {0}", url, new Throwable()); //$NON-NLS-1$
 		}
 	}
diff --git a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/MarketplaceDropAdapter.java b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/MarketplaceDropAdapter.java
index 00ab3d8..3d268d8 100644
--- a/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/MarketplaceDropAdapter.java
+++ b/org.eclipse.epp.mpc.ui/src/org/eclipse/epp/internal/mpc/ui/wizards/MarketplaceDropAdapter.java
@@ -20,7 +20,7 @@
 import org.eclipse.core.runtime.Status;
 import org.eclipse.core.runtime.jobs.Job;
 import org.eclipse.epp.internal.mpc.ui.MarketplaceClientUi;
-import org.eclipse.epp.internal.mpc.ui.MarketplaceClientUiPlugin;
+import org.eclipse.epp.internal.mpc.ui.MarketplaceClientDebug;
 import org.eclipse.epp.mpc.ui.MarketplaceUrlHandler;
 import org.eclipse.jface.util.Util;
 import org.eclipse.swt.SWT;
@@ -323,35 +323,35 @@
 		}
 
 		private void traceDropOperation(int op) {
-			if (MarketplaceClientUiPlugin.DEBUG) {
-				MarketplaceClientUiPlugin.trace(MarketplaceClientUiPlugin.DROP_ADAPTER_DEBUG_OPTION,
+			if (MarketplaceClientDebug.DEBUG) {
+				MarketplaceClientDebug.trace(MarketplaceClientDebug.DROP_ADAPTER_DEBUG_OPTION,
 						"Updating drop event: Setting drop operation to {0}", op); //$NON-NLS-1$
 			}
 		}
 
 		private void traceInvalidEventData(DropTargetEvent event) {
-			if (MarketplaceClientUiPlugin.DEBUG) {
-				MarketplaceClientUiPlugin.trace(MarketplaceClientUiPlugin.DROP_ADAPTER_DEBUG_OPTION,
+			if (MarketplaceClientDebug.DEBUG) {
+				MarketplaceClientDebug.trace(MarketplaceClientDebug.DROP_ADAPTER_DEBUG_OPTION,
 						"Drop event: Data is not a solution url: {0}", event.data, new Throwable()); //$NON-NLS-1$
 			}
 		}
 
 		private void traceMissingEventData(DropTargetEvent event) {
-			if (MarketplaceClientUiPlugin.DEBUG) {
-				MarketplaceClientUiPlugin.trace(MarketplaceClientUiPlugin.DROP_ADAPTER_DEBUG_OPTION,
+			if (MarketplaceClientDebug.DEBUG) {
+				MarketplaceClientDebug.trace(MarketplaceClientDebug.DROP_ADAPTER_DEBUG_OPTION,
 						"Missing drop event data {0}", event.data, new Throwable()); //$NON-NLS-1$
 			}
 		}
 
 		private void traceUnsupportedDataType(DropTargetEvent event) {
-			if (MarketplaceClientUiPlugin.DEBUG) {
-				MarketplaceClientUiPlugin.trace(MarketplaceClientUiPlugin.DROP_ADAPTER_DEBUG_OPTION,
+			if (MarketplaceClientDebug.DEBUG) {
+				MarketplaceClientDebug.trace(MarketplaceClientDebug.DROP_ADAPTER_DEBUG_OPTION,
 						"Unsupported drop data type {0}", traceTransferData(event.currentDataType), new Throwable()); //$NON-NLS-1$
 			}
 		}
 
 		private Object traceTransferData(TransferData data) {
-			if (MarketplaceClientUiPlugin.DEBUG) {
+			if (MarketplaceClientDebug.DEBUG) {
 				return new TransferDataTraceFormatter(data);
 			}
 			return null;