mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 291751 Build project action causes referenced projects to be built twice.
This commit is contained in:
parent
16944a0de7
commit
f9aa9d90d7
3 changed files with 54 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2008 IBM Corporation and others.
|
||||
* Copyright (c) 2000, 2009 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
|
||||
|
@ -29,12 +29,33 @@ import org.eclipse.ui.IWorkbenchPartSite;
|
|||
import org.eclipse.ui.actions.BuildAction;
|
||||
import org.eclipse.ui.ide.IDEActionFactory;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
|
||||
/**
|
||||
* This is the action group for workspace actions such as Build
|
||||
*/
|
||||
public class BuildGroup extends CViewActionGroup {
|
||||
|
||||
private class RebuildAction extends BuildAction {
|
||||
/**
|
||||
* An internal class which overrides the 'shouldPerformResourcePruning'
|
||||
* method so that referenced projects aren't build twice
|
||||
*/
|
||||
public static class CDTBuildAction extends BuildAction {
|
||||
public CDTBuildAction(IShellProvider shell, int kind) {
|
||||
super(shell, kind);
|
||||
}
|
||||
@Override
|
||||
protected boolean shouldPerformResourcePruning() {
|
||||
// If the selected resources aren't new-style CDT projects, then
|
||||
// fall-back to parent behaviour
|
||||
for (Object res : getSelectedResources())
|
||||
if (!(res instanceof IProject) || !CCorePlugin.getDefault().isNewStyleProject((IProject)res))
|
||||
return super.shouldPerformResourcePruning();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static class RebuildAction extends CDTBuildAction {
|
||||
public RebuildAction(IShellProvider shell) {
|
||||
super(shell, IncrementalProjectBuilder.FULL_BUILD);
|
||||
}
|
||||
|
@ -157,10 +178,10 @@ public class BuildGroup extends CViewActionGroup {
|
|||
protected void makeActions() {
|
||||
final IWorkbenchPartSite site = getCView().getSite();
|
||||
|
||||
buildAction = new BuildAction(site, IncrementalProjectBuilder.INCREMENTAL_BUILD);
|
||||
buildAction = new CDTBuildAction(site, IncrementalProjectBuilder.INCREMENTAL_BUILD);
|
||||
buildAction.setText(CViewMessages.BuildAction_label);
|
||||
|
||||
cleanAction = new BuildAction(site, IncrementalProjectBuilder.CLEAN_BUILD);
|
||||
cleanAction = new CDTBuildAction(site, IncrementalProjectBuilder.CLEAN_BUILD);
|
||||
cleanAction.setText(CViewMessages.CleanAction_label);
|
||||
|
||||
rebuildAction = new RebuildAction(site);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2000, 2008 IBM Corporation and others.
|
||||
* Copyright (c) 2000, 2009 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
|
||||
|
@ -19,15 +19,19 @@ import org.eclipse.core.resources.IResource;
|
|||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
import org.eclipse.jface.action.ActionContributionItem;
|
||||
import org.eclipse.jface.action.GroupMarker;
|
||||
import org.eclipse.jface.action.IContributionItem;
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
import org.eclipse.jface.action.Separator;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.ui.IActionBars;
|
||||
import org.eclipse.ui.IViewPart;
|
||||
import org.eclipse.ui.actions.BuildAction;
|
||||
import org.eclipse.ui.ide.IDEActionFactory;
|
||||
import org.eclipse.ui.navigator.ICommonMenuConstants;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.cview.BuildGroup;
|
||||
import org.eclipse.cdt.internal.ui.cview.CViewMessages;
|
||||
|
||||
/**
|
||||
|
@ -40,6 +44,7 @@ import org.eclipse.cdt.internal.ui.cview.CViewMessages;
|
|||
*/
|
||||
public class CNavigatorBuildActionGroup extends AbstractCNavigatorActionGroup {
|
||||
|
||||
private BuildAction fBuildAction;
|
||||
private BuildAction fCleanAction;
|
||||
|
||||
// Menu tags for the build
|
||||
|
@ -56,6 +61,9 @@ public class CNavigatorBuildActionGroup extends AbstractCNavigatorActionGroup {
|
|||
|
||||
@Override
|
||||
public void fillActionBars(IActionBars actionBars) {
|
||||
// register a CDT Build project action which prevents projects with refs from being built twice
|
||||
actionBars.setGlobalActionHandler(IDEActionFactory.BUILD_PROJECT.getId(), fBuildAction);
|
||||
updateActionBars();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,7 +75,7 @@ public class CNavigatorBuildActionGroup extends AbstractCNavigatorActionGroup {
|
|||
* <p>
|
||||
* No disabled action should be on the context menu.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @param menu
|
||||
* context menu to add actions to
|
||||
*/
|
||||
|
@ -112,10 +120,18 @@ public class CNavigatorBuildActionGroup extends AbstractCNavigatorActionGroup {
|
|||
if (!selection.isEmpty() && isProjectSelection && hasBuilder) {
|
||||
fCleanAction.selectionChanged(selection);
|
||||
if (fCleanAction.isEnabled()) {
|
||||
if (menu.find(BuildAction.ID_BUILD) != null) {
|
||||
IContributionItem oldBuild = menu.find(BuildAction.ID_BUILD);
|
||||
if (oldBuild != null) {
|
||||
menu.insertAfter(BuildAction.ID_BUILD, fCleanAction);
|
||||
// Replace ResourceMgmtActionProvier's build action with our own
|
||||
if (oldBuild instanceof ActionContributionItem &&
|
||||
((ActionContributionItem)oldBuild).getAction() instanceof BuildAction) {
|
||||
menu.remove(oldBuild);
|
||||
menu.insertBefore(fCleanAction.getId(), fBuildAction);
|
||||
}
|
||||
} else {
|
||||
menu.insertAfter(ICommonMenuConstants.GROUP_BUILD, fCleanAction);
|
||||
menu.insertAfter(ICommonMenuConstants.GROUP_BUILD, fBuildAction);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +141,7 @@ public class CNavigatorBuildActionGroup extends AbstractCNavigatorActionGroup {
|
|||
|
||||
/**
|
||||
* Returns whether there are builders configured on the given project.
|
||||
*
|
||||
*
|
||||
* @return <code>true</code> if it has builders, <code>false</code> if
|
||||
* not, or if this could not be determined
|
||||
*/
|
||||
|
@ -142,11 +158,15 @@ public class CNavigatorBuildActionGroup extends AbstractCNavigatorActionGroup {
|
|||
|
||||
@Override
|
||||
protected void makeActions() {
|
||||
fCleanAction= new BuildAction(getViewPart().getSite(), IncrementalProjectBuilder.CLEAN_BUILD);
|
||||
fCleanAction.setText(CViewMessages.CleanAction_label);
|
||||
fBuildAction = new BuildGroup.CDTBuildAction(getViewPart().getSite(), IncrementalProjectBuilder.INCREMENTAL_BUILD);
|
||||
fCleanAction= new BuildGroup.CDTBuildAction(getViewPart().getSite(), IncrementalProjectBuilder.CLEAN_BUILD);
|
||||
fCleanAction.setText(CViewMessages.CleanAction_label);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateActionBars() {
|
||||
IStructuredSelection selection = (IStructuredSelection) getContext().getSelection();
|
||||
fBuildAction.selectionChanged(selection);
|
||||
fCleanAction.selectionChanged(selection);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 Nokia and others.
|
||||
* Copyright (c) 2007, 2009 Nokia 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
|
||||
|
@ -30,6 +30,7 @@ import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener;
|
|||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.actions.ActionMessages;
|
||||
import org.eclipse.cdt.internal.ui.cview.BuildGroup;
|
||||
|
||||
/**
|
||||
* Implements a toolbar button that builds the active configuration
|
||||
|
@ -73,7 +74,7 @@ public class BuildActiveConfigMenuAction extends ChangeBuildConfigActionBase
|
|||
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
|
||||
*/
|
||||
public void init(IWorkbenchWindow window) {
|
||||
buildaction = new BuildAction(window, IncrementalProjectBuilder.INCREMENTAL_BUILD);
|
||||
buildaction = new BuildGroup.CDTBuildAction(window, IncrementalProjectBuilder.INCREMENTAL_BUILD);
|
||||
ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager();
|
||||
mngr.addCProjectDescriptionListener(this, CProjectDescriptionEvent.DATA_APPLIED);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue