418648: The "quick context view" menu item shows an empty dialog when no
Mylyn context is active

Change-Id: Id3c57b9de7597ab2a21ac5101926bfabc0b1ab3c
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=418648
Signed-off-by: Frank Becker <Frank@Frank-Becker.de>
diff --git a/org.eclipse.mylyn.context.core/src/org/eclipse/mylyn/internal/context/core/InteractionContextManager.java b/org.eclipse.mylyn.context.core/src/org/eclipse/mylyn/internal/context/core/InteractionContextManager.java
index ee5e944..0960e1e 100644
--- a/org.eclipse.mylyn.context.core/src/org/eclipse/mylyn/internal/context/core/InteractionContextManager.java
+++ b/org.eclipse.mylyn.context.core/src/org/eclipse/mylyn/internal/context/core/InteractionContextManager.java
@@ -54,7 +54,7 @@
 
 /**
  * This is the core class resposible for context management.
- * 
+ *
  * @author Mik Kersten
  * @author Jevgeni Holodkov
  * @author Shawn Minto
@@ -286,7 +286,7 @@
 						public void handleException(Throwable e) {
 							StatusHandler.log(new Status(IStatus.WARNING, ContextCorePlugin.ID_PLUGIN,
 									"Listener failed: " //$NON-NLS-1$
-											+ listener.getClass(), e));
+									+ listener.getClass(), e));
 						}
 
 						public void run() throws Exception {
@@ -305,7 +305,7 @@
 						public void handleException(Throwable e) {
 							StatusHandler.log(new Status(IStatus.WARNING, ContextCorePlugin.ID_PLUGIN,
 									"Listener failed: " //$NON-NLS-1$
-											+ listener.getClass(), e));
+									+ listener.getClass(), e));
 						}
 
 						public void run() throws Exception {
@@ -458,7 +458,7 @@
 						public void handleException(Throwable e) {
 							StatusHandler.log(new Status(IStatus.WARNING, ContextCorePlugin.ID_PLUGIN,
 									"Listener failed: " //$NON-NLS-1$
-											+ listener.getClass(), e));
+									+ listener.getClass(), e));
 						}
 
 						public void run() throws Exception {
@@ -769,7 +769,7 @@
 		return activationHistorySuppressed;
 	}
 
-	// TODO consider removing check for pause and making clients explicitly determine this, 
+	// TODO consider removing check for pause and making clients explicitly determine this,
 	// or provide a separate method
 	public boolean isContextActive() {
 		return !contextCapturePaused && activeContext.getContextMap().values().size() > 0;
@@ -1079,7 +1079,7 @@
 
 	/**
 	 * Used to migrate old activity to new activity events
-	 * 
+	 *
 	 * @since 2.1
 	 */
 	public InteractionContext migrateLegacyActivity(InteractionContext context) {
@@ -1141,7 +1141,7 @@
 
 	/**
 	 * Copy the listener list in case it is modified during the notificiation.
-	 * 
+	 *
 	 * @param element
 	 */
 	public void notifyRelationshipsChanged(final IInteractionElement element) {
@@ -1256,7 +1256,7 @@
 	 * Policy is that a parent should not have an interest lower than that of one of its children. This meets our goal
 	 * of having them decay no faster than the children while having their interest be proportional to the interest of
 	 * their children.
-	 * 
+	 *
 	 * @param forcedBridge
 	 *            The structure bridge that we should use. Can be null, then we will automatically select
 	 * @param handles
@@ -1434,7 +1434,7 @@
 						public void handleException(Throwable e) {
 							StatusHandler.log(new Status(IStatus.WARNING, ContextCorePlugin.ID_PLUGIN,
 									"Listener failed: " //$NON-NLS-1$
-											+ listener.getClass(), e));
+									+ listener.getClass(), e));
 						}
 
 						public void run() throws Exception {
diff --git a/org.eclipse.mylyn.context.tasks.ui/src/org/eclipse/mylyn/internal/context/tasks/ui/ContextTasksStartupHandler.java b/org.eclipse.mylyn.context.tasks.ui/src/org/eclipse/mylyn/internal/context/tasks/ui/ContextTasksStartupHandler.java
index 9ddb782..e432833 100644
--- a/org.eclipse.mylyn.context.tasks.ui/src/org/eclipse/mylyn/internal/context/tasks/ui/ContextTasksStartupHandler.java
+++ b/org.eclipse.mylyn.context.tasks.ui/src/org/eclipse/mylyn/internal/context/tasks/ui/ContextTasksStartupHandler.java
@@ -32,6 +32,7 @@
 import org.eclipse.mylyn.context.ui.IContextUiStartup;
 import org.eclipse.mylyn.internal.context.ui.ContextPopulationStrategy;
 import org.eclipse.mylyn.internal.context.ui.ContextUiPlugin;
+import org.eclipse.mylyn.internal.context.ui.IContextUiConstants;
 import org.eclipse.mylyn.internal.context.ui.IContextUiPreferenceContstants;
 import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
 import org.eclipse.mylyn.internal.tasks.core.externalization.ExternalizationManager;
@@ -110,9 +111,17 @@
 				break;
 			case ACTIVATED:
 				getStateHandler().activated(event.getContext());
+				PlatformUI.getWorkbench()
+						.getActiveWorkbenchWindow()
+						.getActivePage()
+						.showActionSet(IContextUiConstants.ID_CONTEXT_UI_ACTION_SET);
 				break;
 			case DEACTIVATED:
 				getStateHandler().deactivated(event.getContext());
+				PlatformUI.getWorkbench()
+						.getActiveWorkbenchWindow()
+						.getActivePage()
+						.hideActionSet(IContextUiConstants.ID_CONTEXT_UI_ACTION_SET);
 				break;
 			case CLEARED:
 				getStateHandler().clear(event.getContextHandle(), event.isActiveContext());
@@ -213,8 +222,8 @@
 				.getPreferenceStore()
 				.getBoolean(IContextUiPreferenceContstants.AUTO_MANAGE_EXPANSION);
 		TasksUiPlugin.getDefault()
-				.getPreferenceStore()
-				.setValue(ITasksUiPreferenceConstants.AUTO_EXPAND_TASK_LIST, value);
+		.getPreferenceStore()
+		.setValue(ITasksUiPreferenceConstants.AUTO_EXPAND_TASK_LIST, value);
 	}
 
 	void contextActivated(ContextChangeEvent event) {
diff --git a/org.eclipse.mylyn.context.ui/plugin.xml b/org.eclipse.mylyn.context.ui/plugin.xml
index 583d546..2275418 100644
--- a/org.eclipse.mylyn.context.ui/plugin.xml
+++ b/org.eclipse.mylyn.context.ui/plugin.xml
@@ -124,7 +124,7 @@
    	  <actionSet
             label="%actionSet.label"
             description="%actionSet.description"
-            visible="true"
+            visible="false"
             id="org.eclipse.mylyn.context.ui.actionSet">
          <!--
          <action
diff --git a/org.eclipse.mylyn.context.ui/src/org/eclipse/mylyn/internal/context/ui/IContextUiConstants.java b/org.eclipse.mylyn.context.ui/src/org/eclipse/mylyn/internal/context/ui/IContextUiConstants.java
index 3be1dca..9303508 100644
--- a/org.eclipse.mylyn.context.ui/src/org/eclipse/mylyn/internal/context/ui/IContextUiConstants.java
+++ b/org.eclipse.mylyn.context.ui/src/org/eclipse/mylyn/internal/context/ui/IContextUiConstants.java
@@ -24,4 +24,5 @@
 
 	public static String ID_COMMAND_CLEAR_CONTEXT = "org.eclipse.mylyn.context.ui.commands.task.clearContext"; //$NON-NLS-1$
 
+	public static String ID_CONTEXT_UI_ACTION_SET = "org.eclipse.mylyn.context.ui.actionSet";
 }