1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-24 01:15:29 +02:00

bug 69922: [Help Wanted] Introduce a "run last make target" key binding

Patch from Axel Mueller
This commit is contained in:
Andrew Gvozdev 2010-02-02 14:04:18 +00:00
parent 142fa69aa4
commit 480a3b86d7
15 changed files with 418 additions and 31 deletions

View file

@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2003, 2009 QNX Software Systems and others.
# Copyright (c) 2003, 2010 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
@ -25,7 +25,6 @@ WizardConvertMakeProject.description=Convert to a C/C++ Project
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.name=Make Target Build
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 @@ PreferenceMakefileSettings.name= Settings
PropertyMakeProject.name= C/C++ Make Project
ViewCatagoryMake.name=Make
ViewMake.name=Make Targets
ActionSetMake.label=Make Actions
ActionSetUpdateMake.label=Update Make Projects

View file

@ -53,6 +53,14 @@
objectClass="org.eclipse.core.resources.IResource"
adaptable="true"
id="org.eclipse.cdt.make.ui.popupMenu.NavigatorContribution">
<action
label="%LastTargetBuild.name"
class="org.eclipse.cdt.make.ui.actions.BuildLastTargetAction"
menubarPath="org.eclipse.cdt.make.ui.menu/gm1"
id="org.eclipse.cdt.make.ui.NavigatorBuildLastTargetAction"
enablesFor="1"
definitionId="org.eclipse.cdt.make.ui.targetBuildLastCommand">
</action>
<action
label="%ActionMakeBuildTarget.label"
class="org.eclipse.cdt.make.ui.actions.BuildTargetAction"
@ -134,6 +142,16 @@
contextId="org.eclipse.cdt.make.ui.makefileEditorScope"
commandId="org.eclipse.cdt.make.ui.edit.text.makefile.uncomment"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
<key
sequence="Shift+F9"
contextId="org.eclipse.ui.contexts.window"
commandId="org.eclipse.cdt.make.ui.targetBuildCommand"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
<key
sequence="F9"
contextId="org.eclipse.ui.contexts.window"
commandId="org.eclipse.cdt.make.ui.targetBuildLastCommand"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
</extension>
<extension
point="org.eclipse.ui.commands">
@ -143,6 +161,13 @@
categoryId="org.eclipse.ui.category.project"
id="org.eclipse.cdt.make.ui.targetBuildCommand">
</command>
<command
categoryId="org.eclipse.ui.category.project"
defaultHandler="org.eclipse.cdt.make.ui.actions.BuildLastTargetHandler"
description="%LastTargetBuild.description"
id="org.eclipse.cdt.make.ui.targetBuildLastCommand"
name="%LastTargetBuild.name">
</command>
<command
name="%CommandTargetCreate.name"
description="%CommandTargetCreate.description"
@ -281,7 +306,7 @@
id="org.eclipse.cdt.make.ui">
</category>
<view
name="%ViewMake.name"
name="%Make.Target.label"
icon="icons/view16/make_target.gif"
category="org.eclipse.cdt.make.ui"
class="org.eclipse.cdt.make.ui.views.MakeView"
@ -326,7 +351,31 @@
<groupMarker
name="gm1">
</groupMarker>
</menu>
</menu>
<action
definitionId="org.eclipse.cdt.make.ui.targetBuildLastCommand"
label="%LastTargetBuild.name"
class="org.eclipse.cdt.make.ui.actions.BuildLastTargetAction"
menubarPath="project/org.eclipse.cdt.make.ui.prjmenu/gm1"
enablesFor="1"
id="org.eclipse.cdt.make.ui.actions.buildLastTargetAction">
<enablement>
<or>
<objectClass
name="org.eclipse.core.resources.IContainer">
</objectClass>
<objectClass
name="org.eclipse.core.resources.IFile">
</objectClass>
<objectClass
name="org.eclipse.cdt.core.model.ICContainer">
</objectClass>
<objectClass
name="org.eclipse.cdt.core.model.ICProject">
</objectClass>
</or>
</enablement>
</action>
<action
definitionId="org.eclipse.cdt.make.ui.targetBuildCommand"
label="%ActionMakeBuildTarget.label"
@ -339,12 +388,18 @@
<objectClass
name="org.eclipse.core.resources.IContainer">
</objectClass>
<objectClass
name="org.eclipse.core.resources.IFile">
</objectClass>
<objectClass
name="org.eclipse.cdt.core.model.ICContainer">
</objectClass>
<objectClass
name="org.eclipse.cdt.core.model.ICProject">
</objectClass>
<objectClass
name="org.eclipse.cdt.MakeTarget">
</objectClass>
</or>
</enablement>
</action>

View file

@ -1,5 +1,5 @@
###############################################################################
# Copyright (c) 2003, 2009 QNX Software Systems and others.
# Copyright (c) 2003, 2010 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
@ -184,6 +184,10 @@ DeleteTargetAction.exception.errorDeletingBuildTarget=Error deleting Make target
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 +217,9 @@ MakeUIPlugin.update_project_message=Older \'make\' projects have been detected i
# 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=From selected &folder
MakeTargetPreferencePage.buildLastTarget.project=From &project root
#Property Page
MakeProjectPropertyPage.closedproject=Project Closed

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2004, 2006 IBM Corporation and others.
* Copyright (c) 2004, 2010 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:
* QNX Software Systems - Initial API and implementation
* Axel Mueller - Rebuild last target
*******************************************************************************/
package org.eclipse.cdt.make.internal.ui.preferences;
@ -14,6 +15,7 @@ import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
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 @@ public class MakePreferencePage extends FieldEditorPreferencePage implements IWo
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);
@ -31,12 +40,24 @@ public class MakePreferencePage extends FieldEditorPreferencePage implements IWo
/**
* @see FieldEditorPreferencePage#createControl(Composite)
*/
@Override
protected void createFieldEditors() {
Composite parent = getFieldEditorParent();
BooleanFieldEditor tagetBackgroundEditor = new BooleanFieldEditor(PREF_BUILD_TARGET_IN_BACKGROUND,
MakeUIPlugin.getResourceString(TARGET_BUILDS_IN_BACKGROUND), parent);
addField(tagetBackgroundEditor);
// make last target for selected resource or project
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 +68,20 @@ public class MakePreferencePage extends FieldEditorPreferencePage implements IWo
MakeUIPlugin.getDefault().getPreferenceStore().setValue(PREF_BUILD_TARGET_IN_BACKGROUND, enable);
}
/**
* preference to rebuild last target
*
* @return {@code true} if from selected project else from selected resource
*/
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) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2006 QNX Software Systems and others.
* Copyright (c) 2000, 2010 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
@ -42,14 +42,19 @@ public class TargetListViewerPart extends StructuredViewerPart {
private final int REMOVE_TARGET = 1;
private final int EDIT_TARGET = 2;
private IContainer fContainer;
public TargetListViewerPart(IContainer container) {
private boolean recursive;
/**
* @param container
* @param recursive {@code true} if to search recursively for target
*/
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.remove"), //$NON-NLS-1$
MakeUIPlugin.getResourceString("TargetListViewer.button.edit")}); //$NON-NLS-1$
fContainer = container;
this.fContainer = container;
this.recursive = recursive;
}
@Override
@ -79,7 +84,7 @@ public class TargetListViewerPart extends StructuredViewerPart {
.getSelection());
}
});
tableViewer.setContentProvider(new MakeContentProvider(true));
tableViewer.setContentProvider(new MakeContentProvider(recursive));
tableViewer.addFilter(new ViewerFilter() {
@Override

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2006 QNX Software Systems and others.
* Copyright (c) 2000, 2010 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
@ -7,17 +7,21 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
* Axel Mueller - 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.IWorkbenchPart;
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 @@ public abstract class AbstractTargetAction
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 @@ public abstract class AbstractTargetAction
} 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;
}
}

View file

@ -0,0 +1,83 @@
/*******************************************************************************
* 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 - Initial API and 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;
/**
* Rebuild last target of selected resource or project.
* Search is done non-recursively.
* If no valid last target is found, show the build target dialog.
*/
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 {
boolean showDialog = true;
if (name != null) {
IPath path = new Path(name);
if (path.segmentCount() <= 1) {// do not look recursively for last target
IMakeTarget target = MakeCorePlugin.getDefault().getTargetManager().findTarget(container, name);
if (target != null) {
TargetBuild.buildTargets(getShell(), new IMakeTarget[] { target });
showDialog = false;
}
}
}
// no last target found, let the user decide
if (showDialog) {
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();
}
}

View file

@ -0,0 +1,38 @@
/*******************************************************************************
* 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 - Initial API and 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;
/**
* Handler for {@link org.eclipse.cdt.make.ui.actions.BuildLastTargetAction}
*/
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;
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2006 QNX Software Systems and others.
* Copyright (c) 2000, 2010 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
@ -7,6 +7,7 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
* Axel Mueller - Rebuild last target
*******************************************************************************/
package org.eclipse.cdt.make.ui.actions;
@ -20,14 +21,40 @@ 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.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 static final String TARGET_BUILD_COMMAND = "org.eclipse.cdt.make.ui.targetBuildCommand"; //$NON-NLS-1$
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(TARGET_BUILD_COMMAND);
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 +90,28 @@ public class BuildTargetAction extends AbstractTargetAction {
}
}
}
@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(TARGET_BUILD_COMMAND);
if (keyBinding != null) InitAction.setText(
MakeUIPlugin.getResourceString("ActionMakeBuildTarget.label")+"\t"+ keyBinding); //$NON-NLS-1$ //$NON-NLS-2$
}
}
};
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2009 QNX Software Systems and others.
* Copyright (c) 2000, 2010 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
@ -34,11 +34,11 @@ public class BuildTargetDialog extends Dialog {
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) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2009 QNX Software Systems and others.
* Copyright (c) 2000, 2010 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
@ -22,6 +22,7 @@ import org.eclipse.core.runtime.CoreException;
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,21 @@ public class MakeTargetDialog extends Dialog {
target = fTargetManager.createTarget(fContainer.getProject(), targetName, targetBuildID);
} else {
if (!target.getName().equals(targetName)) {
// if necessary rename last target property, too
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);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2009 QNX Software Systems and others.
* Copyright (c) 2000, 2010 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
@ -17,6 +17,10 @@ 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;
@ -38,6 +42,16 @@ public class BuildTargetAction extends SelectionListenerAction {
if (canBuild()) {
IMakeTarget[] targets = getSelectedElements().toArray(new IMakeTarget[0]);
TargetBuild.buildTargets(shell, targets);
// set last target property for last element
IContainer container = targets[targets.length-1].getContainer();
IPath path = container.getProjectRelativePath().removeFirstSegments(
container.getProjectRelativePath().segmentCount());
path = path.append(targets[targets.length-1].getName());
try {
container.setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(),"lastTarget"), //$NON-NLS-1$
path.toString());
} catch (CoreException e) {
}
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2009 QNX Software Systems and others.
* Copyright (c) 2000, 2010 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
@ -17,7 +17,9 @@ import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.core.IMakeTargetManager;
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.runtime.CoreException;
import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell;
@ -73,7 +75,21 @@ public class DeleteTargetAction extends SelectionListenerAction {
try {
for (Object target : getSelectedElements()) {
if (target instanceof IMakeTarget) {
manager.removeTarget((IMakeTarget) target);
manager.removeTarget((IMakeTarget) target);
// if necessary remove last target property
String lastTargetName = null;
IContainer container = ((IMakeTarget) target).getContainer();
try {
lastTargetName = (String)container.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget")); //$NON-NLS-1$
} catch (CoreException e) {
}
if (lastTargetName != null && lastTargetName.equals(((IMakeTarget) target).getName())) {
try {
container.setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(),
"lastTarget"), null); //$NON-NLS-1$
} catch (CoreException e) {
}
}
}
}
} catch (CoreException e) {

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2007 QNX Software Systems and others.
* Copyright (c) 2000, 2010 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
@ -77,9 +77,12 @@ import org.eclipse.ui.part.ViewPart;
public class MakeView extends ViewPart {
private static final String TARGET_BUILD_LAST_COMMAND = "org.eclipse.cdt.make.ui.targetBuildLastCommand"; //$NON-NLS-1$
private Clipboard clipboard;
private BuildTargetAction buildTargetAction;
private RebuildLastTargetAction buildLastTargetAction;
private EditTargetAction editTargetAction;
private DeleteTargetAction deleteTargetAction;
private AddTargetAction newTargetAction;
@ -287,6 +290,7 @@ public class MakeView extends ViewPart {
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 +349,7 @@ public class MakeView extends ViewPart {
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 +367,7 @@ public class MakeView extends ViewPart {
void updateActions(IStructuredSelection sel) {
newTargetAction.selectionChanged(sel);
buildTargetAction.selectionChanged(sel);
buildLastTargetAction.selectionChanged(sel);
deleteTargetAction.selectionChanged(sel);
editTargetAction.selectionChanged(sel);
copyTargetAction.selectionChanged(sel);
@ -406,6 +412,10 @@ public class MakeView extends ViewPart {
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(TARGET_BUILD_LAST_COMMAND);
if (keyBinding != null) buildLastTargetAction.setText(
MakeUIPlugin.getResourceString("BuildLastTargetAction.label")+"\t"+ keyBinding); //$NON-NLS-1$ //$NON-NLS-2$
}
}
};

View file

@ -0,0 +1,40 @@
/*******************************************************************************
* 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 - Initial API and 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;
/**
* Rebuild last target of selected resource or project.
*/
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);
}
}
}