Bug 383497 - "Build Project" key binding no longer works in 4.2 / juno

Provide a default handler for Build Project
diff --git a/bundles/org.eclipse.ui.ide/META-INF/MANIFEST.MF b/bundles/org.eclipse.ui.ide/META-INF/MANIFEST.MF
index b299f6b..791f390 100644
--- a/bundles/org.eclipse.ui.ide/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.ui.ide/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %Plugin.name
 Bundle-SymbolicName: org.eclipse.ui.ide; singleton:=true
-Bundle-Version: 3.8.1.qualifier
+Bundle-Version: 3.8.2.qualifier
 Bundle-ClassPath: e4-ide.jar,
  .
 Bundle-Activator: org.eclipse.ui.internal.ide.IDEWorkbenchPlugin
diff --git a/bundles/org.eclipse.ui.ide/plugin.xml b/bundles/org.eclipse.ui.ide/plugin.xml
index 2a02a22..e8622b3 100644
--- a/bundles/org.eclipse.ui.ide/plugin.xml
+++ b/bundles/org.eclipse.ui.ide/plugin.xml
@@ -847,6 +847,7 @@
             name="%command.buildProject.name"
             description="%command.buildProject.description"
             categoryId="org.eclipse.ui.category.project"
+            defaultHandler="org.eclipse.ui.internal.ide.handlers.BuildProjectHandler"
             id="org.eclipse.ui.project.buildProject">
       </command>
       <command
diff --git a/bundles/org.eclipse.ui.ide/pom.xml b/bundles/org.eclipse.ui.ide/pom.xml
index cb6024f..786a586 100644
--- a/bundles/org.eclipse.ui.ide/pom.xml
+++ b/bundles/org.eclipse.ui.ide/pom.xml
@@ -21,6 +21,6 @@
   </parent>
   <groupId>eclipse.platform.ui</groupId>
   <artifactId>org.eclipse.ui.ide</artifactId>
-  <version>3.8.1-SNAPSHOT</version>
+  <version>3.8.2-SNAPSHOT</version>
   <packaging>eclipse-plugin</packaging>
 </project>
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
new file mode 100644
index 0000000..c69d87e
--- /dev/null
+++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/BuildProjectHandler.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ ******************************************************************************/
+
+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.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.IWorkbenchWindow;
+import org.eclipse.ui.actions.BuildAction;
+import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ * Default Handler for 'Build Project' command
+ * 
+ * @since 4.3
+ * 
+ */
+public class BuildProjectHandler extends AbstractHandler {
+
+	/**
+	 * @throws ExecutionException
+	 */
+	public Object execute(ExecutionEvent event) throws ExecutionException {
+		IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
+		if (window != null) {
+
+			ISelection currentSelection = HandlerUtil
+					.getCurrentSelection(event);
+
+			if (currentSelection instanceof IStructuredSelection) {
+				runBuildAction(window, currentSelection);
+			} else {
+				currentSelection = extractSelectionFromEditorInput(HandlerUtil
+						.getActiveEditorInput(event));
+				runBuildAction(window, currentSelection);
+			}
+		}
+		return null;
+	}
+
+	private ISelection extractSelectionFromEditorInput(
+			IEditorInput activeEditorInput) {
+		if (activeEditorInput instanceof FileEditorInput) {
+			IProject project = ((FileEditorInput) activeEditorInput).getFile()
+					.getProject();
+			return new StructuredSelection(project);
+		}
+
+		return null;
+	}
+
+	private void runBuildAction(IWorkbenchWindow window,
+			ISelection currentSelection) {
+		BuildAction buildAction = new BuildAction(window,
+				IncrementalProjectBuilder.INCREMENTAL_BUILD);
+		buildAction.selectionChanged((IStructuredSelection) currentSelection);
+		buildAction.run();
+	}
+
+}
\ No newline at end of file