fix bug 9928 - issues with platform project > build (ctrl+b)- removes workaround
authortimkelly
Mon, 13 Sep 2010 10:29:40 -0500
changeset 1989 4325bb87befb
parent 1988 5b598b1fcc3e
child 1990 7a179f8bd827
fix bug 9928 - issues with platform project > build (ctrl+b)- removes workaround
core/com.nokia.carbide.cpp/plugin.xml
project/com.nokia.carbide.cpp.project.ui/plugin.xml
project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/actions/CarbideBuildAction.java
--- a/core/com.nokia.carbide.cpp/plugin.xml	Mon Sep 13 10:25:00 2010 -0500
+++ b/core/com.nokia.carbide.cpp/plugin.xml	Mon Sep 13 10:29:40 2010 -0500
@@ -266,6 +266,10 @@
             commandId="org.eclipse.ui.edit.addBookmark"
             schemeId="com.nokia.carbide.cpp.carbidedefault" />
 		
+		<key
+			sequence="M1+B"
+			commandId="org.eclipse.ui.project.buildProject"
+			schemeId="com.nokia.carbide.cpp.carbidedefault"/>	
 	   
 <!-- =================================================================================== -->
 <!-- MICROSOFT VISUAL STUDIO KEY SHORTCUTS                                               -->
@@ -275,7 +279,7 @@
 		<!-- MSVS BuildSolution -->
 		<key
 			sequence="F7"
-			commandId="com.nokia.carbide.cpp.buildProject"
+			commandId="org.eclipse.ui.project.buildProject"
 			schemeId="org.eclipse.cdt.ui.visualstudio"/>	
 		<key
 			sequence="M1+F7"
--- a/project/com.nokia.carbide.cpp.project.ui/plugin.xml	Mon Sep 13 10:25:00 2010 -0500
+++ b/project/com.nokia.carbide.cpp.project.ui/plugin.xml	Mon Sep 13 10:29:40 2010 -0500
@@ -365,16 +365,7 @@
          </enablement>
 	 </commonWizard>
 	</extension>
- <extension
-       point="org.eclipse.ui.commands">
-    <command
-          categoryId="org.eclipse.ui.category.project"
-          defaultHandler="com.nokia.carbide.cpp.internal.project.ui.actions.CarbideBuildAction"
-          id="com.nokia.carbide.cpp.buildProject"
-          name="%buildProject">
-    </command>
- </extension>
-
+ 
 <!-- =================================================================================== -->
 <!-- CarbideFormEditor specific problem marker                                           -->
 <!-- =================================================================================== -->
--- a/project/com.nokia.carbide.cpp.project.ui/src/com/nokia/carbide/cpp/internal/project/ui/actions/CarbideBuildAction.java	Mon Sep 13 10:25:00 2010 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,118 +0,0 @@
-/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
-* All rights reserved.
-* This component and the accompanying materials are made available
-* under the terms of the License "Eclipse Public License v1.0"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: 
-*
-*/
-package com.nokia.carbide.cpp.internal.project.ui.actions;
-
-import org.eclipse.core.commands.*;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.commands.ActionHandler;
-import org.eclipse.ui.*;
-import org.eclipse.ui.actions.BuildAction;
-
-/**
- * This class exists to allow CTRL+B to build the current project to be decoupled from the platform's
- * build project action, because the latter has enablement bugs (shown disabled when should be enabled)
- * that will probably not be addressed in the immediate future. The idea is that in the com.nokia.carbide.cpp 
- * plugin, we now create a binding to an internal command id (com.nokia.carbide.cpp.buildProject) 
- * rather than the platform's build project command id. Then in this plugin,
- * a command is declared to handle it with this class as the handler.
- *  
- * This class wraps the same object as the platform's build project action, and enhances enablement
- * such that if a cdt editor is the active part, the command is enabled.
- * The decision about which projects to build and the actual building is delegated to the original build action.
- */
-public class CarbideBuildAction implements IHandler {
-	private ActionHandler buildActionHandler;
-
-	public CarbideBuildAction() {
-	}
-
-	/**
-	 * Create the action handler lazily, since it requires a non-null shell at construction time,
-	 * and by the time the user invokes this command, we should be certain that the workbench is fully open.
-	 * @return ActionHandler
-	 */
-	private ActionHandler getBuildAction() {
-		if (buildActionHandler == null) {
-			IWorkbench workbench = PlatformUI.getWorkbench();
-			if (workbench == null)
-				return null;
-			IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
-			if (window == null)
-				return null;
-			IAction action = new BuildAction(window, IncrementalProjectBuilder.INCREMENTAL_BUILD);
-			buildActionHandler = new ActionHandler(action);
-		}
-		
-		return buildActionHandler;
-	}
-
-	public boolean isEnabled() {
-		if (getBuildAction() == null)
-			return false;
-		
-		// allow the build action to check enablement
-		boolean enabled = getBuildAction().isEnabled();
-		if (!enabled) {
-			// if showing disabled (potentially due to the bug), check the active editor
-			IWorkbench workbench = PlatformUI.getWorkbench();
-			if (workbench != null) {
-				IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
-				if (workbenchWindow != null) {
-					IWorkbenchPage activePage = workbenchWindow.getActivePage();
-					if (activePage != null) {
-						IWorkbenchPart activePart = activePage.getActivePart();
-						// enabled if active part is an editor and it is a cdt editor
-						enabled = activePart instanceof IEditorPart && 
-							activePart.getSite().getId().contains("org.eclipse.cdt"); //$NON-NLS-1$
-					}
-				}
-			}
-		}
-		return enabled;
-	}
-	
-	public boolean isHandled() {
-		if (getBuildAction() == null)
-			return false;
-		
-		return getBuildAction().isHandled();
-	}
-	
-	public void addHandlerListener(IHandlerListener handlerListener) {
-		if (getBuildAction() != null)
-			getBuildAction().addHandlerListener(handlerListener);
-	}
-	
-	public void removeHandlerListener(IHandlerListener handlerListener) {
-		if (getBuildAction() != null)
-			getBuildAction().removeHandlerListener(handlerListener);
-	}
-	
-	public void dispose() {
-		if (getBuildAction() != null)
-			getBuildAction().dispose();
-	}
-
-	public Object execute(ExecutionEvent event) throws ExecutionException {
-		if (getBuildAction() != null)
-			return getBuildAction().execute(event);
-		
-		return null;
-	}
-
-}