summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorTom Hochstein2013-06-20 15:53:26 (EDT)
committer Paul Webster2013-08-01 10:55:27 (EDT)
commitbc7a94f2deaf9839d2b27e5bd0f224fb2d7017df (patch)
tree6645a79aaee7dfdfdb5e628b5ada5318979fad83
parent1502559fa72c7786159fc0cd7fb626b4b09149a5 (diff)
downloadeclipse.platform.ui-bc7a94f2deaf9839d2b27e5bd0f224fb2d7017df.zip
eclipse.platform.ui-bc7a94f2deaf9839d2b27e5bd0f224fb2d7017df.tar.gz
eclipse.platform.ui-bc7a94f2deaf9839d2b27e5bd0f224fb2d7017df.tar.bz2
Bug 411287 - Quick Access > Build Project is offered even if no valid selection exists
Signed-off-by: Tom Hochstein <tom.hochstein@freescale.com>
-rw-r--r--bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/BuildProjectHandler.java31
1 files changed, 27 insertions, 4 deletions
diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/BuildProjectHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/BuildProjectHandler.java
index c69d87e..bb17a94 100644
--- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/BuildProjectHandler.java
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/BuildProjectHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 IBM Corporation and others.
+ * Copyright (c) 2012-3 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Freescale - Bug 411287 - Quick Access > Build Project is offered even if no valid selection exists
******************************************************************************/
package org.eclipse.ui.internal.ide.handlers;
@@ -14,12 +15,14 @@ package org.eclipse.ui.internal.ide.handlers;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.expressions.IEvaluationContext;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.ISources;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.actions.BuildAction;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -67,10 +70,30 @@ public class BuildProjectHandler extends AbstractHandler {
private void runBuildAction(IWorkbenchWindow window,
ISelection currentSelection) {
- BuildAction buildAction = new BuildAction(window,
- IncrementalProjectBuilder.INCREMENTAL_BUILD);
+ BuildAction buildAction = newBuildAction(window);
buildAction.selectionChanged((IStructuredSelection) currentSelection);
buildAction.run();
}
-} \ No newline at end of file
+ private BuildAction newBuildAction(IWorkbenchWindow window) {
+ return new BuildAction(window,
+ IncrementalProjectBuilder.INCREMENTAL_BUILD);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.commands.AbstractHandler#setEnabled(java.lang.Object)
+ */
+ public void setEnabled(Object evaluationContext) {
+ boolean enabled = false;
+ if ((evaluationContext instanceof IEvaluationContext)) {
+ IEvaluationContext context = (IEvaluationContext) evaluationContext;
+ Object object = context.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME);
+ if (object instanceof IWorkbenchWindow) {
+ BuildAction buildAction = newBuildAction((IWorkbenchWindow) object);
+ enabled = buildAction.isEnabled();
+ }
+ }
+ setBaseEnabled(enabled);
+ }
+
+}