### Eclipse Workspace Patch 1.0 #P org.eclipse.cdt.make.ui Index: plugin.properties =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.make.ui/plugin.properties,v retrieving revision 1.34 diff -u -r1.34 plugin.properties --- plugin.properties 11 Sep 2009 02:09:37 -0000 1.34 +++ plugin.properties 26 Jan 2010 23:01:30 -0000 @@ -25,7 +25,6 @@ Make.Target.label=Make Target ActionMakeCreateTarget.label=Create... -ActionMakeBuildTarget.label=Build... ActionMakeUpdate.label=Update Old Make Project... ActionMakeUpdate.tooltip=Update Old Make Project @@ -34,6 +33,8 @@ CommandTargetBuild.description=Invoke a make target build for the selected container. CommandTargetCreate.name=Create Make Target CommandTargetCreate.description=Create a new make build target for the selected container. +LastTargetBuild.name=Rebuild Last Target +LastTargetBuild.description=Rebuild the last make target for the selected container or project. # Build Settings Preference page PreferenceBuildSettings.name=Build Settings @@ -48,7 +49,6 @@ PropertyMakeProject.name= C/C++ Make Project ViewCatagoryMake.name=Make -ViewMake.name=Make Targets ActionSetMake.label=Make Actions ActionSetUpdateMake.label=Update Make Projects Index: plugin.xml =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.make.ui/plugin.xml,v retrieving revision 1.80 diff -u -r1.80 plugin.xml --- plugin.xml 11 Sep 2009 02:09:37 -0000 1.80 +++ plugin.xml 26 Jan 2010 23:01:31 -0000 @@ -54,6 +54,14 @@ adaptable="true" id="org.eclipse.cdt.make.ui.popupMenu.NavigatorContribution"> + + + + @@ -144,6 +162,13 @@ id="org.eclipse.cdt.make.ui.targetBuildCommand"> + + - + + + + + + + + + + + + + + + + + + + Index: src/org/eclipse/cdt/make/internal/ui/MakeResources.properties =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties,v retrieving revision 1.56 diff -u -r1.56 MakeResources.properties --- src/org/eclipse/cdt/make/internal/ui/MakeResources.properties 30 Aug 2009 02:45:15 -0000 1.56 +++ src/org/eclipse/cdt/make/internal/ui/MakeResources.properties 26 Jan 2010 23:01:31 -0000 @@ -10,6 +10,7 @@ # Wind River Systems - fix for bugzilla 135150 and 194198 # Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136) # IBM Corporation +# Axel Mueller - [69922] Rebuild last target ############################################################################### MakeCWizard.title=C/Make Project @@ -184,6 +185,10 @@ BuildTargetAction.label=Build &Target BuildTargetAction.tooltip=Build Make Target +BuildLastTargetAction.label=Rebuild &Last Target +BuildLastTargetAction.tooltip=Rebuild the last make target for the selected container or project. + +ActionMakeBuildTarget.label=Build... EditTargetAction.label=&Edit... EditTargetAction.tooltip=Edit Make Target @@ -213,6 +218,9 @@ # Prefernece Page MakePreferencePage.description=Specify the settings used as defaults by the New Standard Make Project creation wizard. MakeTargetPreferencePage.buildTargetInBackground.label=Build Make target in the background. +MakeTargetPreferencePage.buildLastTarget.title=Rebuild Last Target +MakeTargetPreferencePage.buildLastTarget.resource=Rebuild last target of the selected &resource +MakeTargetPreferencePage.buildLastTarget.project=Rebuild last target in &project's root folder #Property Page MakeProjectPropertyPage.closedproject=Project Closed Index: src/org/eclipse/cdt/make/internal/ui/preferences/MakePreferencePage.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/preferences/MakePreferencePage.java,v retrieving revision 1.12 diff -u -r1.12 MakePreferencePage.java --- src/org/eclipse/cdt/make/internal/ui/preferences/MakePreferencePage.java 23 Jun 2006 17:25:51 -0000 1.12 +++ src/org/eclipse/cdt/make/internal/ui/preferences/MakePreferencePage.java 26 Jan 2010 23:01:32 -0000 @@ -7,6 +7,7 @@ * * Contributors: * QNX Software Systems - Initial API and implementation + * Axel Mueller - [69922] Rebuild last target *******************************************************************************/ package org.eclipse.cdt.make.internal.ui.preferences; @@ -14,6 +15,7 @@ import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.FieldEditorPreferencePage; import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.RadioGroupFieldEditor; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; @@ -22,6 +24,13 @@ private static final String PREF_BUILD_TARGET_IN_BACKGROUND = "MakeTargetPrefs.buildTargetInBackground"; //$NON-NLS-1$ private static final String TARGET_BUILDS_IN_BACKGROUND = "MakeTargetPreferencePage.buildTargetInBackground.label"; //$NON-NLS-1$ + + private static final String PREF_BUILD_LAST_TARGET = "MakeTargetPrefs.buildLastTarget"; //$NON-NLS-1$ + private static final String BUILD_LAST_TARGET = "MakeTargetPreferencePage.buildLastTarget.title"; //$NON-NLS-1$ + private static final String PREF_BUILD_LAST_RESOURCE = "MakeTargetPrefs.buildLastTarget.resource"; //$NON-NLS-1$ + private static final String BUILD_LAST_RESOURCE = "MakeTargetPreferencePage.buildLastTarget.resource"; //$NON-NLS-1$ + private static final String PREF_BUILD_LAST_PROJECT = "MakeTargetPrefs.buildLastTarget.project"; //$NON-NLS-1$ + private static final String BUILD_LAST_PROJECT = "MakeTargetPreferencePage.buildLastTarget.project"; //$NON-NLS-1$ public MakePreferencePage() { super(GRID); @@ -37,6 +46,17 @@ BooleanFieldEditor tagetBackgroundEditor = new BooleanFieldEditor(PREF_BUILD_TARGET_IN_BACKGROUND, MakeUIPlugin.getResourceString(TARGET_BUILDS_IN_BACKGROUND), parent); addField(tagetBackgroundEditor); + + // make last target + RadioGroupFieldEditor edit = new RadioGroupFieldEditor( + PREF_BUILD_LAST_TARGET, + MakeUIPlugin.getResourceString(BUILD_LAST_TARGET), 1, + new String[][] { + {MakeUIPlugin.getResourceString(BUILD_LAST_RESOURCE), PREF_BUILD_LAST_RESOURCE}, + {MakeUIPlugin.getResourceString(BUILD_LAST_PROJECT), PREF_BUILD_LAST_PROJECT} }, + parent, + true); + addField(edit); } public static boolean isBuildTargetInBackground() { @@ -47,11 +67,15 @@ MakeUIPlugin.getDefault().getPreferenceStore().setValue(PREF_BUILD_TARGET_IN_BACKGROUND, enable); } + public static boolean useProjectForLastMakeTarget() { + return MakeUIPlugin.getDefault().getPreferenceStore().getString(PREF_BUILD_LAST_TARGET).equals(PREF_BUILD_LAST_PROJECT); + } /** * Initializes the default values of this page in the preference bundle. */ public static void initDefaults(IPreferenceStore prefs) { prefs.setDefault(PREF_BUILD_TARGET_IN_BACKGROUND, true); + prefs.setDefault(PREF_BUILD_LAST_TARGET, PREF_BUILD_LAST_RESOURCE); } public void init(IWorkbench workbench) { Index: src/org/eclipse/cdt/make/ui/TargetListViewerPart.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/TargetListViewerPart.java,v retrieving revision 1.11 diff -u -r1.11 TargetListViewerPart.java --- src/org/eclipse/cdt/make/ui/TargetListViewerPart.java 5 Aug 2009 21:20:41 -0000 1.11 +++ src/org/eclipse/cdt/make/ui/TargetListViewerPart.java 26 Jan 2010 23:01:32 -0000 @@ -42,14 +42,16 @@ private final int REMOVE_TARGET = 1; private final int EDIT_TARGET = 2; private IContainer fContainer; + private boolean recursive; - public TargetListViewerPart(IContainer container) { + public TargetListViewerPart(IContainer container, boolean recursive) { super(new String[] { MakeUIPlugin.getResourceString("TargetListViewer.button.add"), //$NON-NLS-1$ MakeUIPlugin .getResourceString("TargetListViewer.button.remove"), //$NON-NLS-1$ MakeUIPlugin.getResourceString("TargetListViewer.button.edit")}); //$NON-NLS-1$ fContainer = container; + this.recursive = recursive; } @Override @@ -79,7 +81,7 @@ .getSelection()); } }); - tableViewer.setContentProvider(new MakeContentProvider(true)); + tableViewer.setContentProvider(new MakeContentProvider(recursive)); tableViewer.addFilter(new ViewerFilter() { @Override Index: src/org/eclipse/cdt/make/ui/actions/AbstractTargetAction.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/AbstractTargetAction.java,v retrieving revision 1.7 diff -u -r1.7 AbstractTargetAction.java --- src/org/eclipse/cdt/make/ui/actions/AbstractTargetAction.java 23 Jun 2006 17:52:06 -0000 1.7 +++ src/org/eclipse/cdt/make/ui/actions/AbstractTargetAction.java 26 Jan 2010 23:01:32 -0000 @@ -7,17 +7,21 @@ * * Contributors: * QNX Software Systems - Initial API and implementation + * Axel Mueller - [69922] Rebuild last target *******************************************************************************/ package org.eclipse.cdt.make.ui.actions; import org.eclipse.cdt.core.model.ICContainer; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.make.core.IMakeTarget; import org.eclipse.cdt.make.core.MakeCorePlugin; import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.jface.action.IAction; +import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Shell; @@ -26,13 +30,16 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.actions.ActionDelegate; +import org.eclipse.ui.editors.text.TextEditor; +import org.eclipse.ui.part.EditorPart; public abstract class AbstractTargetAction extends ActionDelegate implements IObjectActionDelegate, IWorkbenchWindowActionDelegate { private IWorkbenchPart fPart; private IWorkbenchWindow fWindow; - private IContainer fContainer; + private boolean isEnabled; + protected IContainer fContainer; protected Shell getShell() { if (fPart != null) { @@ -55,8 +62,9 @@ fWindow = window; } + @Override public void selectionChanged(IAction action, ISelection selection) { - boolean enabled = false; + isEnabled = false; if (selection instanceof IStructuredSelection) { IStructuredSelection sel = (IStructuredSelection) selection; Object obj = sel.getFirstElement(); @@ -75,14 +83,29 @@ } else { fContainer = ((IResource)obj).getParent(); } + } else if (obj instanceof IMakeTarget) { + fContainer = ((IMakeTarget)obj).getContainer(); } else { fContainer = null; } - if (fContainer != null && MakeCorePlugin.getDefault().getTargetManager().hasTargetBuilder(fContainer.getProject())) { - enabled = true; + } else if (selection instanceof ITextSelection) + { // key binding pressed inside active text editor + IWorkbenchPart part = fPart != null ? fPart : fWindow.getActivePage().getActivePart(); + if ( part instanceof TextEditor ) { + IFile file = org.eclipse.ui.ide.ResourceUtil.getFile(((EditorPart) part).getEditorInput()); + fContainer = file.getParent(); + } else { + fContainer = null; } } - action.setEnabled(enabled); + if (fContainer != null && MakeCorePlugin.getDefault().getTargetManager().hasTargetBuilder(fContainer.getProject())) { + isEnabled = true; + } + if ( action != null ) + action.setEnabled(isEnabled); } + public boolean isEnabled() { + return isEnabled; + } } Index: src/org/eclipse/cdt/make/ui/actions/BuildLastTargetAction.java =================================================================== RCS file: src/org/eclipse/cdt/make/ui/actions/BuildLastTargetAction.java diff -N src/org/eclipse/cdt/make/ui/actions/BuildLastTargetAction.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/cdt/make/ui/actions/BuildLastTargetAction.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,78 @@ +/******************************************************************************* + * Copyright (c) 2010 Axel Mueller 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: + * Axel Mueller - [69922] Initial implementation + *******************************************************************************/ +package org.eclipse.cdt.make.ui.actions; + +import org.eclipse.cdt.make.core.IMakeTarget; +import org.eclipse.cdt.make.core.MakeCorePlugin; +import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; +import org.eclipse.cdt.make.ui.TargetBuild; +import org.eclipse.cdt.make.ui.dialogs.BuildTargetDialog; +import org.eclipse.cdt.make.internal.ui.preferences.MakePreferencePage; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.window.Window; + +public class BuildLastTargetAction extends AbstractTargetAction { + + @Override + public void run(IAction action) { + IContainer container = getSelectedContainer(); + if (container != null) { + String name = null; + if (MakePreferencePage.useProjectForLastMakeTarget()) { + container = container.getProject(); + } + try { + name = (String)container.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget")); //$NON-NLS-1$ + } catch (CoreException e) { + } + try { + if (name != null) { + IPath path = new Path(name); + name = path.segment(path.segmentCount() - 1); + IContainer targetContainer; + if (path.segmentCount() > 1) { + path = path.removeLastSegments(1); + targetContainer = (IContainer)container.findMember(path); + } else { + targetContainer = container; + } + IMakeTarget target = MakeCorePlugin.getDefault().getTargetManager().findTarget(targetContainer, name); + TargetBuild.buildTargets(getShell(), new IMakeTarget[] { target }); + } + else { + BuildTargetDialog dialog = new BuildTargetDialog(getShell(), container, false/*Recursive*/); + if (dialog.open() == Window.OK) { + IMakeTarget target = dialog.getTarget(); + if (target != null) { + IPath path = + target.getContainer().getProjectRelativePath().removeFirstSegments( + container.getProjectRelativePath().segmentCount()); + path = path.append(target.getName()); + container.setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"), //$NON-NLS-1$ + path.toString()); + } + } + } + } catch (CoreException e) { + } + } + } + + @Override + public boolean isEnabled() { + return super.isEnabled(); + } +} Index: src/org/eclipse/cdt/make/ui/actions/BuildLastTargetHandler.java =================================================================== RCS file: src/org/eclipse/cdt/make/ui/actions/BuildLastTargetHandler.java diff -N src/org/eclipse/cdt/make/ui/actions/BuildLastTargetHandler.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/cdt/make/ui/actions/BuildLastTargetHandler.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2010 Axel Mueller 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: + * Axel Mueller - [69922] Initial implementation + *******************************************************************************/ +package org.eclipse.cdt.make.ui.actions; + +import org.eclipse.core.commands.AbstractHandler; +import org.eclipse.core.commands.ExecutionEvent; +import org.eclipse.core.commands.ExecutionException; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.handlers.HandlerUtil; + +public class BuildLastTargetHandler extends AbstractHandler { + + public Object execute(ExecutionEvent event) throws ExecutionException { + final BuildLastTargetAction buildAction= new BuildLastTargetAction(); + ISelection selection = HandlerUtil.getCurrentSelection( event ); + IWorkbenchPart part = HandlerUtil.getActivePart( event ); + buildAction.setActivePart(null, part); + buildAction.selectionChanged(null, selection); + + if (buildAction.isEnabled()) { + buildAction.run(null); + } + return null; + } + +} Index: src/org/eclipse/cdt/make/ui/actions/BuildTargetAction.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/BuildTargetAction.java,v retrieving revision 1.10 diff -u -r1.10 BuildTargetAction.java --- src/org/eclipse/cdt/make/ui/actions/BuildTargetAction.java 23 Jun 2006 17:52:06 -0000 1.10 +++ src/org/eclipse/cdt/make/ui/actions/BuildTargetAction.java 26 Jan 2010 23:01:34 -0000 @@ -7,6 +7,7 @@ * * Contributors: * QNX Software Systems - Initial API and implementation + * Axel Mueller - [69922] Rebuild last target *******************************************************************************/ package org.eclipse.cdt.make.ui.actions; @@ -20,14 +21,39 @@ import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.jface.action.IAction; +import org.eclipse.jface.bindings.BindingManagerEvent; +import org.eclipse.jface.bindings.IBindingManagerListener; import org.eclipse.jface.window.Window; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.keys.IBindingService; public class BuildTargetAction extends AbstractTargetAction { - + + private IBindingService bindingService; + private IAction InitAction; + + public BuildTargetAction(){ + bindingService = null; + InitAction = null; + } + + @Override + public void init(IAction action) { + bindingService = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class); + if (bindingService != null) { + bindingService.addBindingManagerListener(bindingManagerListener); + String keyBinding = bindingService.getBestActiveBindingFormattedFor("org.eclipse.cdt.make.ui.targetBuildCommand"); //$NON-NLS-1$ + if (keyBinding != null) + action.setText(MakeUIPlugin.getResourceString("ActionMakeBuildTarget.label")+"\t"+ keyBinding); //$NON-NLS-1$ //$NON-NLS-2$ + } + InitAction = action; + } + + @Override public void run(IAction action) { IContainer container = getSelectedContainer(); if (container != null) { - BuildTargetDialog dialog = new BuildTargetDialog(getShell(), container); + BuildTargetDialog dialog = new BuildTargetDialog(getShell(), container, true); String name = null; try { name = (String)container.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget")); //$NON-NLS-1$ @@ -63,5 +89,28 @@ } } } + + @Override + public void dispose() { + if (bindingService != null) { + bindingService.removeBindingManagerListener(bindingManagerListener); + bindingService = null; + } + + super.dispose(); + } + + private IBindingManagerListener bindingManagerListener = new IBindingManagerListener() { + + public void bindingManagerChanged(BindingManagerEvent event) { + + if (event.isActiveBindingsChanged()) { + String keyBinding = bindingService.getBestActiveBindingFormattedFor("org.eclipse.cdt.make.ui.targetBuildCommand"); //$NON-NLS-1$ + if (keyBinding != null) InitAction.setText( + MakeUIPlugin.getResourceString("ActionMakeBuildTarget.label")+"\t"+ keyBinding); //$NON-NLS-1$ //$NON-NLS-2$ + + } + } + }; } Index: src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java,v retrieving revision 1.19 diff -u -r1.19 BuildTargetDialog.java --- src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java 3 Feb 2009 14:56:01 -0000 1.19 +++ src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java 26 Jan 2010 23:01:34 -0000 @@ -34,11 +34,11 @@ private final TargetListViewerPart targetPart; private final IContainer fContainer; - public BuildTargetDialog(Shell parent, IContainer container) { + public BuildTargetDialog(Shell parent, IContainer container, boolean recursive) { super(parent); setShellStyle(getShellStyle() | SWT.RESIZE); fContainer = container; - targetPart = new TargetListViewerPart(fContainer); + targetPart = new TargetListViewerPart(fContainer, recursive); } public void setTarget(IMakeTarget target) { Index: src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java,v retrieving revision 1.27 diff -u -r1.27 MakeTargetDialog.java --- src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java 20 May 2009 13:59:57 -0000 1.27 +++ src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java 26 Jan 2010 23:01:35 -0000 @@ -22,6 +22,7 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.QualifiedName; import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; @@ -476,6 +477,20 @@ target = fTargetManager.createTarget(fContainer.getProject(), targetName, targetBuildID); } else { if (!target.getName().equals(targetName)) { + String lastTargetName = null; + IContainer container = target.getContainer(); + try { + lastTargetName = (String)container.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget")); //$NON-NLS-1$ + } catch (CoreException e) { + } + if (lastTargetName != null && lastTargetName.equals(target.getName())) { + IPath path = container.getProjectRelativePath().removeFirstSegments( + container.getProjectRelativePath().segmentCount()); + path = path.append(targetName); + container.setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"), //$NON-NLS-1$ + path.toString()); + } + fTargetManager.renameTarget(target, targetName); } } Index: src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java_lasttarget =================================================================== RCS file: src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java_lasttarget diff -N src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java_lasttarget --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java_lasttarget 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2000, 2009 QNX Software Systems 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: + * QNX Software Systems - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.make.ui.views; + + +import java.util.List; + +import org.eclipse.cdt.make.core.IMakeTarget; +import org.eclipse.cdt.make.internal.ui.MakeUIImages; +import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; +import org.eclipse.cdt.make.ui.TargetBuild; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.QualifiedName; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.actions.SelectionListenerAction; + +public class BuildTargetAction extends SelectionListenerAction { + private final Shell shell; + + public BuildTargetAction(Shell shell) { + super(MakeUIPlugin.getResourceString("BuildTargetAction.label")); //$NON-NLS-1$ + this.shell = shell; + + setToolTipText(MakeUIPlugin.getResourceString("BuildTargetAction.tooltip")); //$NON-NLS-1$ + MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_BUILD); //$NON-NLS-1$ + setEnabled(false); + } + + @Override + public void run() { + if (canBuild()) { + IMakeTarget[] targets = getSelectedElements().toArray(new IMakeTarget[0]); + TargetBuild.buildTargets(shell, targets); + if (targets.length == 1) { + IContainer container = targets[0].getContainer(); + IPath path = container.getProjectRelativePath().removeFirstSegments( + container.getProjectRelativePath().segmentCount()); + path = path.append(targets[0].getName()); + try { + container.setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(),"lastTarget"), //$NON-NLS-1$ + path.toString()); + } catch (CoreException e) { + } + } + } + } + + @Override + protected boolean updateSelection(IStructuredSelection selection) { + return super.updateSelection(selection) && canBuild(); + } + + private boolean canBuild() { + List elements = getSelectedElements(); + for (Object element : elements) { + if (! (element instanceof IMakeTarget)) { + return false; + } + } + return elements.size()>0; + } + + private List getSelectedElements() { + return getStructuredSelection().toList(); + } +} Index: src/org/eclipse/cdt/make/ui/views/MakeView.java =================================================================== RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/MakeView.java,v retrieving revision 1.22 diff -u -r1.22 MakeView.java --- src/org/eclipse/cdt/make/ui/views/MakeView.java 5 Nov 2009 13:26:18 -0000 1.22 +++ src/org/eclipse/cdt/make/ui/views/MakeView.java 26 Jan 2010 23:01:37 -0000 @@ -80,6 +80,7 @@ private Clipboard clipboard; private BuildTargetAction buildTargetAction; + private RebuildLastTargetAction buildLastTargetAction; private EditTargetAction editTargetAction; private DeleteTargetAction deleteTargetAction; private AddTargetAction newTargetAction; @@ -287,6 +288,7 @@ clipboard = new Clipboard(shell.getDisplay()); buildTargetAction = new BuildTargetAction(shell); + buildLastTargetAction = new RebuildLastTargetAction(); newTargetAction = new AddTargetAction(shell); copyTargetAction = new CopyTargetAction(shell, clipboard, pasteTargetAction); pasteTargetAction = new PasteTargetAction(shell, clipboard); @@ -345,6 +347,7 @@ manager.add(deleteTargetAction); manager.add(new Separator()); manager.add(buildTargetAction); + manager.add(buildLastTargetAction); // Other plug-ins can contribute there actions here // manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); @@ -362,6 +365,7 @@ void updateActions(IStructuredSelection sel) { newTargetAction.selectionChanged(sel); buildTargetAction.selectionChanged(sel); + buildLastTargetAction.selectionChanged(sel); deleteTargetAction.selectionChanged(sel); editTargetAction.selectionChanged(sel); copyTargetAction.selectionChanged(sel); @@ -406,6 +410,10 @@ keyBinding = bindingService.getBestActiveBindingFormattedFor(IWorkbenchCommandConstants.EDIT_DELETE); if (keyBinding != null) deleteTargetAction.setText( MakeUIPlugin.getResourceString("DeleteTargetAction.label")+"\t"+ keyBinding); //$NON-NLS-1$ //$NON-NLS-2$ + + keyBinding = bindingService.getBestActiveBindingFormattedFor("org.eclipse.cdt.make.ui.targetBuildLastCommand"); //$NON-NLS-1$ + if (keyBinding != null) buildLastTargetAction.setText( + MakeUIPlugin.getResourceString("BuildLastTargetAction.label")+"\t"+ keyBinding); //$NON-NLS-1$ //$NON-NLS-2$ } } }; Index: src/org/eclipse/cdt/make/ui/views/RebuildLastTargetAction.java =================================================================== RCS file: src/org/eclipse/cdt/make/ui/views/RebuildLastTargetAction.java diff -N src/org/eclipse/cdt/make/ui/views/RebuildLastTargetAction.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/cdt/make/ui/views/RebuildLastTargetAction.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2010 Axel Mueller. + * 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: + * Axel Mueller - [69922] Initial implementation + *******************************************************************************/ +package org.eclipse.cdt.make.ui.views; + + + +import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; +import org.eclipse.cdt.make.ui.actions.BuildLastTargetAction; +import org.eclipse.ui.actions.SelectionListenerAction; + +public class RebuildLastTargetAction extends SelectionListenerAction { + + public RebuildLastTargetAction() { + super(MakeUIPlugin.getResourceString("BuildLastTargetAction.label")); //$NON-NLS-1$ + + setToolTipText(MakeUIPlugin.getResourceString("BuildLastTargetAction.tooltip")); //$NON-NLS-1$ + setEnabled(false); + } + + @Override + public void run() { + final BuildLastTargetAction buildAction= new BuildLastTargetAction(); + buildAction.selectionChanged(null, this.getStructuredSelection()); + + if (buildAction.isEnabled()) { + buildAction.run(null); + } + } +}