aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Hochstein2013-06-20 15:53:26 (EDT)
committerPaul Webster2013-06-24 12:27:55 (EDT)
commit628269f5e83dac8a5eea458d9997d1a96c83f614 (patch)
tree04d5e5537154741dbb8e9539afeb69848fa26bbe
parent5fedb27bd48bb9aecfc9cd63649fc6188c61e210 (diff)
downloadeclipse.platform.ui-628269f5e83dac8a5eea458d9997d1a96c83f614.zip
eclipse.platform.ui-628269f5e83dac8a5eea458d9997d1a96c83f614.tar.gz
eclipse.platform.ui-628269f5e83dac8a5eea458d9997d1a96c83f614.tar.bz2
Bug 411287 - Quick Access > Build Project is offered even if no valid selection existsrefs/changes/13/14013/1
-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);
+ }
+
+}