View | Details | Raw Unified | Return to bug 69922 | Differences between
and this patch

Collapse All | Expand All

(-)plugin.properties (-2 / +2 lines)
Lines 25-31 Link Here
25
25
26
Make.Target.label=Make Target
26
Make.Target.label=Make Target
27
ActionMakeCreateTarget.label=Create...
27
ActionMakeCreateTarget.label=Create...
28
ActionMakeBuildTarget.label=Build...
29
28
30
ActionMakeUpdate.label=Update Old Make Project...
29
ActionMakeUpdate.label=Update Old Make Project...
31
ActionMakeUpdate.tooltip=Update Old Make Project
30
ActionMakeUpdate.tooltip=Update Old Make Project
Lines 34-39 Link Here
34
CommandTargetBuild.description=Invoke a make target build for the selected container.
33
CommandTargetBuild.description=Invoke a make target build for the selected container.
35
CommandTargetCreate.name=Create Make Target
34
CommandTargetCreate.name=Create Make Target
36
CommandTargetCreate.description=Create a new make build target for the selected container.
35
CommandTargetCreate.description=Create a new make build target for the selected container.
36
LastTargetBuild.name=Rebuild Last Target
37
LastTargetBuild.description=Rebuild the last make target for the selected container or project.
37
38
38
# Build Settings Preference page
39
# Build Settings Preference page
39
PreferenceBuildSettings.name=Build Settings
40
PreferenceBuildSettings.name=Build Settings
Lines 48-54 Link Here
48
PropertyMakeProject.name= C/C++ Make Project
49
PropertyMakeProject.name= C/C++ Make Project
49
50
50
ViewCatagoryMake.name=Make
51
ViewCatagoryMake.name=Make
51
ViewMake.name=Make Targets
52
52
53
ActionSetMake.label=Make Actions
53
ActionSetMake.label=Make Actions
54
ActionSetUpdateMake.label=Update Make Projects
54
ActionSetUpdateMake.label=Update Make Projects
(-)plugin.xml (-2 / +57 lines)
Lines 54-59 Link Here
54
            adaptable="true"
54
            adaptable="true"
55
            id="org.eclipse.cdt.make.ui.popupMenu.NavigatorContribution">
55
            id="org.eclipse.cdt.make.ui.popupMenu.NavigatorContribution">
56
         <action
56
         <action
57
               label="%LastTargetBuild.name"
58
               class="org.eclipse.cdt.make.ui.actions.BuildLastTargetAction"
59
               menubarPath="org.eclipse.cdt.make.ui.menu/gm1"
60
               id="org.eclipse.cdt.make.ui.NavigatorBuildLastTargetAction"
61
               enablesFor="1"
62
               definitionId="org.eclipse.cdt.make.ui.targetBuildLastCommand">
63
         </action>   
64
         <action
57
               label="%ActionMakeBuildTarget.label"
65
               label="%ActionMakeBuildTarget.label"
58
               class="org.eclipse.cdt.make.ui.actions.BuildTargetAction"
66
               class="org.eclipse.cdt.make.ui.actions.BuildTargetAction"
59
               menubarPath="org.eclipse.cdt.make.ui.menu/gm1"
67
               menubarPath="org.eclipse.cdt.make.ui.menu/gm1"
Lines 134-139 Link Here
134
            contextId="org.eclipse.cdt.make.ui.makefileEditorScope"
142
            contextId="org.eclipse.cdt.make.ui.makefileEditorScope"
135
            commandId="org.eclipse.cdt.make.ui.edit.text.makefile.uncomment"
143
            commandId="org.eclipse.cdt.make.ui.edit.text.makefile.uncomment"
136
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
144
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
145
      <key
146
            sequence="Shift+F9"
147
            contextId="org.eclipse.ui.contexts.window"
148
            commandId="org.eclipse.cdt.make.ui.targetBuildCommand"
149
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>             
150
      <key
151
            sequence="F9"
152
            contextId="org.eclipse.ui.contexts.window"
153
            commandId="org.eclipse.cdt.make.ui.targetBuildLastCommand"
154
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>             
137
   </extension>
155
   </extension>
138
   <extension
156
   <extension
139
      point="org.eclipse.ui.commands">
157
      point="org.eclipse.ui.commands">
Lines 144-149 Link Here
144
            id="org.eclipse.cdt.make.ui.targetBuildCommand">
162
            id="org.eclipse.cdt.make.ui.targetBuildCommand">
145
      </command>
163
      </command>
146
      <command
164
      <command
165
            categoryId="org.eclipse.ui.category.project"
166
            defaultHandler="org.eclipse.cdt.make.ui.actions.BuildLastTargetHandler"
167
            description="%LastTargetBuild.description"
168
            id="org.eclipse.cdt.make.ui.targetBuildLastCommand"
169
            name="%LastTargetBuild.name">
170
      </command>  
171
      <command
147
            name="%CommandTargetCreate.name"
172
            name="%CommandTargetCreate.name"
148
            description="%CommandTargetCreate.description"
173
            description="%CommandTargetCreate.description"
149
            categoryId="org.eclipse.ui.category.project"
174
            categoryId="org.eclipse.ui.category.project"
Lines 281-287 Link Here
281
            id="org.eclipse.cdt.make.ui">
306
            id="org.eclipse.cdt.make.ui">
282
      </category>
307
      </category>
283
      <view
308
      <view
284
            name="%ViewMake.name"
309
            name="%Make.Target.label"
285
            icon="icons/view16/make_target.gif"
310
            icon="icons/view16/make_target.gif"
286
            category="org.eclipse.cdt.make.ui"
311
            category="org.eclipse.cdt.make.ui"
287
            class="org.eclipse.cdt.make.ui.views.MakeView"
312
            class="org.eclipse.cdt.make.ui.views.MakeView"
Lines 326-332 Link Here
326
               <groupMarker
351
               <groupMarker
327
                  name="gm1">
352
                  name="gm1">
328
               </groupMarker>
353
               </groupMarker>
329
            </menu>         
354
            </menu>   
355
            <action
356
               definitionId="org.eclipse.cdt.make.ui.targetBuildLastCommand"
357
               label="%LastTargetBuild.name"
358
               class="org.eclipse.cdt.make.ui.actions.BuildLastTargetAction"               
359
               menubarPath="project/org.eclipse.cdt.make.ui.prjmenu/gm1"
360
               enablesFor="1"
361
               id="org.eclipse.cdt.make.ui.actions.buildLastTargetAction">
362
               <enablement>
363
               <or>
364
                  <objectClass
365
                        name="org.eclipse.core.resources.IContainer">
366
                  </objectClass>
367
                  <objectClass
368
                        name="org.eclipse.core.resources.IFile">
369
                  </objectClass>
370
                  <objectClass
371
                        name="org.eclipse.cdt.core.model.ICContainer">
372
                  </objectClass>
373
                  <objectClass
374
                        name="org.eclipse.cdt.core.model.ICProject">
375
                  </objectClass>
376
               </or>
377
            </enablement>
378
         </action>  
330
            <action
379
            <action
331
               definitionId="org.eclipse.cdt.make.ui.targetBuildCommand"
380
               definitionId="org.eclipse.cdt.make.ui.targetBuildCommand"
332
               label="%ActionMakeBuildTarget.label"
381
               label="%ActionMakeBuildTarget.label"
Lines 340-350 Link Here
340
                        name="org.eclipse.core.resources.IContainer">
389
                        name="org.eclipse.core.resources.IContainer">
341
                  </objectClass>
390
                  </objectClass>
342
                  <objectClass
391
                  <objectClass
392
                        name="org.eclipse.core.resources.IFile">
393
                  </objectClass>
394
                  <objectClass
343
                        name="org.eclipse.cdt.core.model.ICContainer">
395
                        name="org.eclipse.cdt.core.model.ICContainer">
344
                  </objectClass>
396
                  </objectClass>
345
                  <objectClass
397
                  <objectClass
346
                        name="org.eclipse.cdt.core.model.ICProject">
398
                        name="org.eclipse.cdt.core.model.ICProject">
347
                  </objectClass>
399
                  </objectClass>
400
                  <objectClass
401
                        name="org.eclipse.cdt.MakeTarget">
402
                  </objectClass>
348
               </or>
403
               </or>
349
            </enablement>
404
            </enablement>
350
         </action>
405
         </action>
(-)src/org/eclipse/cdt/make/internal/ui/MakeResources.properties (+8 lines)
Lines 10-15 Link Here
10
#     Wind River Systems - fix for bugzilla 135150 and 194198
10
#     Wind River Systems - fix for bugzilla 135150 and 194198
11
#     Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
11
#     Tianchao Li (tianchao.li@gmail.com) - arbitrary build directory (bug #136136)
12
#     IBM Corporation 
12
#     IBM Corporation 
13
#     Axel Mueller - [69922] Rebuild last target
13
###############################################################################
14
###############################################################################
14
15
15
MakeCWizard.title=C/Make Project
16
MakeCWizard.title=C/Make Project
Lines 184-189 Link Here
184
185
185
BuildTargetAction.label=Build &Target
186
BuildTargetAction.label=Build &Target
186
BuildTargetAction.tooltip=Build Make Target
187
BuildTargetAction.tooltip=Build Make Target
188
BuildLastTargetAction.label=Rebuild &Last Target
189
BuildLastTargetAction.tooltip=Rebuild the last make target for the selected container or project.
190
191
ActionMakeBuildTarget.label=Build...
187
192
188
EditTargetAction.label=&Edit...
193
EditTargetAction.label=&Edit...
189
EditTargetAction.tooltip=Edit Make Target
194
EditTargetAction.tooltip=Edit Make Target
Lines 213-218 Link Here
213
# Prefernece Page
218
# Prefernece Page
214
MakePreferencePage.description=Specify the settings used as defaults by the New Standard Make Project creation wizard.
219
MakePreferencePage.description=Specify the settings used as defaults by the New Standard Make Project creation wizard.
215
MakeTargetPreferencePage.buildTargetInBackground.label=Build Make target in the background.
220
MakeTargetPreferencePage.buildTargetInBackground.label=Build Make target in the background.
221
MakeTargetPreferencePage.buildLastTarget.title=Rebuild Last Target
222
MakeTargetPreferencePage.buildLastTarget.resource=Rebuild last target of the selected &resource
223
MakeTargetPreferencePage.buildLastTarget.project=Rebuild last target in &project's root folder
216
224
217
#Property Page
225
#Property Page
218
MakeProjectPropertyPage.closedproject=Project Closed
226
MakeProjectPropertyPage.closedproject=Project Closed
(-)src/org/eclipse/cdt/make/internal/ui/preferences/MakePreferencePage.java (+24 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     QNX Software Systems - Initial API and implementation
9
 *     QNX Software Systems - Initial API and implementation
10
 *     Axel Mueller - [69922] Rebuild last target
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.make.internal.ui.preferences;
12
package org.eclipse.cdt.make.internal.ui.preferences;
12
13
Lines 14-19 Link Here
14
import org.eclipse.jface.preference.BooleanFieldEditor;
15
import org.eclipse.jface.preference.BooleanFieldEditor;
15
import org.eclipse.jface.preference.FieldEditorPreferencePage;
16
import org.eclipse.jface.preference.FieldEditorPreferencePage;
16
import org.eclipse.jface.preference.IPreferenceStore;
17
import org.eclipse.jface.preference.IPreferenceStore;
18
import org.eclipse.jface.preference.RadioGroupFieldEditor;
17
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.swt.widgets.Composite;
18
import org.eclipse.ui.IWorkbench;
20
import org.eclipse.ui.IWorkbench;
19
import org.eclipse.ui.IWorkbenchPreferencePage;
21
import org.eclipse.ui.IWorkbenchPreferencePage;
Lines 22-27 Link Here
22
24
23
	private static final String PREF_BUILD_TARGET_IN_BACKGROUND = "MakeTargetPrefs.buildTargetInBackground"; //$NON-NLS-1$
25
	private static final String PREF_BUILD_TARGET_IN_BACKGROUND = "MakeTargetPrefs.buildTargetInBackground"; //$NON-NLS-1$
24
	private static final String TARGET_BUILDS_IN_BACKGROUND = "MakeTargetPreferencePage.buildTargetInBackground.label"; //$NON-NLS-1$
26
	private static final String TARGET_BUILDS_IN_BACKGROUND = "MakeTargetPreferencePage.buildTargetInBackground.label"; //$NON-NLS-1$
27
	
28
	private static final String PREF_BUILD_LAST_TARGET = "MakeTargetPrefs.buildLastTarget"; //$NON-NLS-1$
29
	private static final String BUILD_LAST_TARGET = "MakeTargetPreferencePage.buildLastTarget.title"; //$NON-NLS-1$
30
	private static final String PREF_BUILD_LAST_RESOURCE = "MakeTargetPrefs.buildLastTarget.resource"; //$NON-NLS-1$
31
	private static final String BUILD_LAST_RESOURCE = "MakeTargetPreferencePage.buildLastTarget.resource"; //$NON-NLS-1$
32
	private static final String PREF_BUILD_LAST_PROJECT = "MakeTargetPrefs.buildLastTarget.project"; //$NON-NLS-1$
33
	private static final String BUILD_LAST_PROJECT = "MakeTargetPreferencePage.buildLastTarget.project"; //$NON-NLS-1$
25
34
26
	public MakePreferencePage() {
35
	public MakePreferencePage() {
27
		super(GRID);
36
		super(GRID);
Lines 37-42 Link Here
37
		BooleanFieldEditor tagetBackgroundEditor = new BooleanFieldEditor(PREF_BUILD_TARGET_IN_BACKGROUND,
46
		BooleanFieldEditor tagetBackgroundEditor = new BooleanFieldEditor(PREF_BUILD_TARGET_IN_BACKGROUND,
38
				MakeUIPlugin.getResourceString(TARGET_BUILDS_IN_BACKGROUND), parent);
47
				MakeUIPlugin.getResourceString(TARGET_BUILDS_IN_BACKGROUND), parent);
39
		addField(tagetBackgroundEditor);
48
		addField(tagetBackgroundEditor);
49
		
50
		// make last target
51
		RadioGroupFieldEditor edit = new RadioGroupFieldEditor(
52
				PREF_BUILD_LAST_TARGET,
53
				MakeUIPlugin.getResourceString(BUILD_LAST_TARGET), 1, 
54
				new String[][] {
55
						{MakeUIPlugin.getResourceString(BUILD_LAST_RESOURCE), PREF_BUILD_LAST_RESOURCE}, 
56
						{MakeUIPlugin.getResourceString(BUILD_LAST_PROJECT), PREF_BUILD_LAST_PROJECT} }, 
57
				parent,
58
				true);
59
		addField(edit);
40
	}
60
	}
41
61
42
	public static boolean isBuildTargetInBackground() {
62
	public static boolean isBuildTargetInBackground() {
Lines 47-57 Link Here
47
		MakeUIPlugin.getDefault().getPreferenceStore().setValue(PREF_BUILD_TARGET_IN_BACKGROUND, enable);
67
		MakeUIPlugin.getDefault().getPreferenceStore().setValue(PREF_BUILD_TARGET_IN_BACKGROUND, enable);
48
	}
68
	}
49
69
70
	public static boolean useProjectForLastMakeTarget() {
71
		return MakeUIPlugin.getDefault().getPreferenceStore().getString(PREF_BUILD_LAST_TARGET).equals(PREF_BUILD_LAST_PROJECT);
72
	}
50
	/**
73
	/**
51
	 * Initializes the default values of this page in the preference bundle.
74
	 * Initializes the default values of this page in the preference bundle.
52
	 */
75
	 */
53
	public static void initDefaults(IPreferenceStore prefs) {
76
	public static void initDefaults(IPreferenceStore prefs) {
54
		prefs.setDefault(PREF_BUILD_TARGET_IN_BACKGROUND, true);
77
		prefs.setDefault(PREF_BUILD_TARGET_IN_BACKGROUND, true);
78
		prefs.setDefault(PREF_BUILD_LAST_TARGET, PREF_BUILD_LAST_RESOURCE);
55
	}
79
	}
56
80
57
	public void init(IWorkbench workbench) {
81
	public void init(IWorkbench workbench) {
(-)src/org/eclipse/cdt/make/ui/TargetListViewerPart.java (-2 / +4 lines)
Lines 42-55 Link Here
42
    private final int REMOVE_TARGET = 1;
42
    private final int REMOVE_TARGET = 1;
43
    private final int EDIT_TARGET = 2;
43
    private final int EDIT_TARGET = 2;
44
    private IContainer fContainer;
44
    private IContainer fContainer;
45
    private boolean recursive;
45
46
46
    public TargetListViewerPart(IContainer container) {
47
    public TargetListViewerPart(IContainer container, boolean recursive) {
47
        super(new String[] {
48
        super(new String[] {
48
                MakeUIPlugin.getResourceString("TargetListViewer.button.add"), //$NON-NLS-1$
49
                MakeUIPlugin.getResourceString("TargetListViewer.button.add"), //$NON-NLS-1$
49
                MakeUIPlugin
50
                MakeUIPlugin
50
                        .getResourceString("TargetListViewer.button.remove"), //$NON-NLS-1$
51
                        .getResourceString("TargetListViewer.button.remove"), //$NON-NLS-1$
51
                MakeUIPlugin.getResourceString("TargetListViewer.button.edit")}); //$NON-NLS-1$
52
                MakeUIPlugin.getResourceString("TargetListViewer.button.edit")}); //$NON-NLS-1$
52
        fContainer = container;
53
        fContainer = container;
54
        this.recursive = recursive;
53
    }
55
    }
54
56
55
    @Override
57
    @Override
Lines 79-85 Link Here
79
                                        .getSelection());
81
                                        .getSelection());
80
                    }
82
                    }
81
                });
83
                });
82
        tableViewer.setContentProvider(new MakeContentProvider(true));
84
        tableViewer.setContentProvider(new MakeContentProvider(recursive));
83
        tableViewer.addFilter(new ViewerFilter() {
85
        tableViewer.addFilter(new ViewerFilter() {
84
86
85
            @Override
87
            @Override
(-)src/org/eclipse/cdt/make/ui/actions/AbstractTargetAction.java (-5 / +28 lines)
Lines 7-23 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     QNX Software Systems - Initial API and implementation
9
 *     QNX Software Systems - Initial API and implementation
10
 *     Axel Mueller - [69922] Rebuild last target
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.make.ui.actions;
12
package org.eclipse.cdt.make.ui.actions;
12
13
13
import org.eclipse.cdt.core.model.ICContainer;
14
import org.eclipse.cdt.core.model.ICContainer;
14
import org.eclipse.cdt.core.model.ICElement;
15
import org.eclipse.cdt.core.model.ICElement;
15
import org.eclipse.cdt.core.model.ICProject;
16
import org.eclipse.cdt.core.model.ICProject;
17
import org.eclipse.cdt.make.core.IMakeTarget;
16
import org.eclipse.cdt.make.core.MakeCorePlugin;
18
import org.eclipse.cdt.make.core.MakeCorePlugin;
17
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
19
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
18
import org.eclipse.core.resources.IContainer;
20
import org.eclipse.core.resources.IContainer;
21
import org.eclipse.core.resources.IFile;
19
import org.eclipse.core.resources.IResource;
22
import org.eclipse.core.resources.IResource;
20
import org.eclipse.jface.action.IAction;
23
import org.eclipse.jface.action.IAction;
24
import org.eclipse.jface.text.ITextSelection;
21
import org.eclipse.jface.viewers.ISelection;
25
import org.eclipse.jface.viewers.ISelection;
22
import org.eclipse.jface.viewers.IStructuredSelection;
26
import org.eclipse.jface.viewers.IStructuredSelection;
23
import org.eclipse.swt.widgets.Shell;
27
import org.eclipse.swt.widgets.Shell;
Lines 26-38 Link Here
26
import org.eclipse.ui.IWorkbenchWindow;
30
import org.eclipse.ui.IWorkbenchWindow;
27
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
31
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
28
import org.eclipse.ui.actions.ActionDelegate;
32
import org.eclipse.ui.actions.ActionDelegate;
33
import org.eclipse.ui.editors.text.TextEditor;
34
import org.eclipse.ui.part.EditorPart;
29
35
30
public abstract class AbstractTargetAction
36
public abstract class AbstractTargetAction
31
	extends ActionDelegate
37
	extends ActionDelegate
32
	implements IObjectActionDelegate, IWorkbenchWindowActionDelegate {
38
	implements IObjectActionDelegate, IWorkbenchWindowActionDelegate {
33
	private IWorkbenchPart fPart;
39
	private IWorkbenchPart fPart;
34
	private IWorkbenchWindow fWindow;
40
	private IWorkbenchWindow fWindow;
35
	private IContainer fContainer;
41
	private boolean isEnabled;
42
	protected IContainer fContainer;
36
43
37
	protected Shell getShell() {
44
	protected Shell getShell() {
38
		if (fPart != null) {
45
		if (fPart != null) {
Lines 55-62 Link Here
55
		fWindow = window;
62
		fWindow = window;
56
	}
63
	}
57
64
65
	@Override
58
	public void selectionChanged(IAction action, ISelection selection) {
66
	public void selectionChanged(IAction action, ISelection selection) {
59
		boolean enabled = false;
67
		isEnabled = false;
60
		if (selection instanceof IStructuredSelection) {
68
		if (selection instanceof IStructuredSelection) {
61
			IStructuredSelection sel = (IStructuredSelection) selection;
69
			IStructuredSelection sel = (IStructuredSelection) selection;
62
			Object obj = sel.getFirstElement();
70
			Object obj = sel.getFirstElement();
Lines 75-88 Link Here
75
				} else {
83
				} else {
76
					fContainer = ((IResource)obj).getParent();
84
					fContainer = ((IResource)obj).getParent();
77
				}
85
				}
86
			} else if (obj instanceof IMakeTarget) {
87
				fContainer = ((IMakeTarget)obj).getContainer();
78
			} else {
88
			} else {
79
				fContainer = null;
89
				fContainer = null;
80
			}
90
			}
81
			if (fContainer != null && MakeCorePlugin.getDefault().getTargetManager().hasTargetBuilder(fContainer.getProject())) {
91
		} else if (selection instanceof ITextSelection)
82
				enabled = true;
92
		{	// key binding pressed inside active text editor
93
			IWorkbenchPart part = fPart != null ? fPart : fWindow.getActivePage().getActivePart();
94
			if ( part instanceof TextEditor ) {
95
				IFile file = org.eclipse.ui.ide.ResourceUtil.getFile(((EditorPart) part).getEditorInput());
96
				fContainer = file.getParent();
97
			} else {
98
				fContainer = null;
83
			}
99
			}
84
		}
100
		}
85
		action.setEnabled(enabled);
101
		if (fContainer != null && MakeCorePlugin.getDefault().getTargetManager().hasTargetBuilder(fContainer.getProject())) {
102
			isEnabled = true;
103
		}
104
		if ( action != null )
105
			action.setEnabled(isEnabled);
86
	}
106
	}
87
107
108
	public boolean isEnabled() {
109
		return isEnabled;
110
	}
88
}
111
}
(-)src/org/eclipse/cdt/make/ui/actions/BuildLastTargetAction.java (+78 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Axel Mueller and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Axel Mueller - [69922] Initial implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.make.ui.actions;
12
13
import org.eclipse.cdt.make.core.IMakeTarget;
14
import org.eclipse.cdt.make.core.MakeCorePlugin;
15
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
16
import org.eclipse.cdt.make.ui.TargetBuild;
17
import org.eclipse.cdt.make.ui.dialogs.BuildTargetDialog;
18
import org.eclipse.cdt.make.internal.ui.preferences.MakePreferencePage;
19
import org.eclipse.core.resources.IContainer;
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.IPath;
22
import org.eclipse.core.runtime.Path;
23
import org.eclipse.core.runtime.QualifiedName;
24
import org.eclipse.jface.action.IAction;
25
import org.eclipse.jface.window.Window;
26
27
public class BuildLastTargetAction extends AbstractTargetAction {
28
	
29
	@Override
30
	public void run(IAction action) {
31
		IContainer container = getSelectedContainer();
32
		if (container != null) {
33
			String name = null;
34
			if (MakePreferencePage.useProjectForLastMakeTarget()) {
35
				container = container.getProject();
36
			}
37
			try {
38
				name = (String)container.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget")); //$NON-NLS-1$
39
			} catch (CoreException e) {
40
			}
41
			try {
42
				if (name != null) {
43
					IPath path = new Path(name);
44
					name = path.segment(path.segmentCount() - 1);
45
					IContainer targetContainer;
46
					if (path.segmentCount() > 1) {
47
						path = path.removeLastSegments(1);
48
						targetContainer = (IContainer)container.findMember(path);
49
					} else {
50
						targetContainer = container;
51
					}
52
					IMakeTarget target = MakeCorePlugin.getDefault().getTargetManager().findTarget(targetContainer, name);
53
					TargetBuild.buildTargets(getShell(), new IMakeTarget[] { target });
54
				}
55
				else {
56
					BuildTargetDialog dialog = new BuildTargetDialog(getShell(), container, false/*Recursive*/);
57
					if (dialog.open() == Window.OK) {
58
						IMakeTarget target = dialog.getTarget();
59
						if (target != null) {
60
							IPath path =
61
								target.getContainer().getProjectRelativePath().removeFirstSegments(
62
										container.getProjectRelativePath().segmentCount());
63
							path = path.append(target.getName());
64
							container.setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"), //$NON-NLS-1$
65
									path.toString());
66
						}
67
					}
68
				}
69
			} catch (CoreException e) {
70
			}
71
		}
72
	}
73
74
	@Override
75
	public boolean isEnabled() {
76
		return super.isEnabled();
77
	}
78
}
(-)src/org/eclipse/cdt/make/ui/actions/BuildLastTargetHandler.java (+35 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Axel Mueller and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Axel Mueller - [69922] Initial implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.make.ui.actions;
12
13
import org.eclipse.core.commands.AbstractHandler;
14
import org.eclipse.core.commands.ExecutionEvent;
15
import org.eclipse.core.commands.ExecutionException;
16
import org.eclipse.jface.viewers.ISelection;
17
import org.eclipse.ui.IWorkbenchPart;
18
import org.eclipse.ui.handlers.HandlerUtil;
19
20
public class BuildLastTargetHandler extends AbstractHandler {
21
	
22
	public Object execute(ExecutionEvent event) throws ExecutionException {
23
		final BuildLastTargetAction buildAction= new BuildLastTargetAction();
24
		ISelection selection = HandlerUtil.getCurrentSelection( event );
25
		IWorkbenchPart part = HandlerUtil.getActivePart( event );
26
		buildAction.setActivePart(null, part);
27
		buildAction.selectionChanged(null, selection);
28
29
		if (buildAction.isEnabled()) {
30
			buildAction.run(null);
31
		}
32
		return null;
33
	}
34
35
}
(-)src/org/eclipse/cdt/make/ui/actions/BuildTargetAction.java (-2 / +51 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     QNX Software Systems - Initial API and implementation
9
 *     QNX Software Systems - Initial API and implementation
10
 *     Axel Mueller - [69922] Rebuild last target
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.cdt.make.ui.actions;
12
package org.eclipse.cdt.make.ui.actions;
12
13
Lines 20-33 Link Here
20
import org.eclipse.core.runtime.Path;
21
import org.eclipse.core.runtime.Path;
21
import org.eclipse.core.runtime.QualifiedName;
22
import org.eclipse.core.runtime.QualifiedName;
22
import org.eclipse.jface.action.IAction;
23
import org.eclipse.jface.action.IAction;
24
import org.eclipse.jface.bindings.BindingManagerEvent;
25
import org.eclipse.jface.bindings.IBindingManagerListener;
23
import org.eclipse.jface.window.Window;
26
import org.eclipse.jface.window.Window;
27
import org.eclipse.ui.PlatformUI;
28
import org.eclipse.ui.keys.IBindingService;
24
29
25
public class BuildTargetAction extends AbstractTargetAction {
30
public class BuildTargetAction extends AbstractTargetAction {
26
31
	
32
	private IBindingService bindingService;
33
	private IAction InitAction;
34
	
35
	public BuildTargetAction(){
36
		bindingService = null;
37
		InitAction = null;
38
	}
39
	
40
	@Override
41
	public void init(IAction action) {
42
		bindingService = (IBindingService) PlatformUI.getWorkbench().getService(IBindingService.class);
43
		if (bindingService != null) {
44
			bindingService.addBindingManagerListener(bindingManagerListener);
45
			String keyBinding = bindingService.getBestActiveBindingFormattedFor("org.eclipse.cdt.make.ui.targetBuildCommand"); //$NON-NLS-1$
46
			if (keyBinding != null) 
47
				action.setText(MakeUIPlugin.getResourceString("ActionMakeBuildTarget.label")+"\t"+ keyBinding); //$NON-NLS-1$ //$NON-NLS-2$
48
		}
49
		InitAction = action;
50
    }
51
	
52
	@Override
27
	public void run(IAction action) {
53
	public void run(IAction action) {
28
		IContainer container = getSelectedContainer();
54
		IContainer container = getSelectedContainer();
29
		if (container != null) {
55
		if (container != null) {
30
			BuildTargetDialog dialog = new BuildTargetDialog(getShell(), container);
56
			BuildTargetDialog dialog = new BuildTargetDialog(getShell(), container, true);
31
			String name = null;
57
			String name = null;
32
			try {
58
			try {
33
				name = (String)container.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget")); //$NON-NLS-1$
59
				name = (String)container.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget")); //$NON-NLS-1$
Lines 63-67 Link Here
63
			}
89
			}
64
		}
90
		}
65
	}
91
	}
92
	
93
	@Override
94
	public void dispose() {
95
		if (bindingService != null) {
96
			bindingService.removeBindingManagerListener(bindingManagerListener);
97
			bindingService = null;
98
		}
99
		
100
		super.dispose();
101
	}
102
103
	private IBindingManagerListener bindingManagerListener = new IBindingManagerListener() {
104
105
		public void bindingManagerChanged(BindingManagerEvent event) {
106
			
107
			if (event.isActiveBindingsChanged()) {
108
				String keyBinding = bindingService.getBestActiveBindingFormattedFor("org.eclipse.cdt.make.ui.targetBuildCommand"); //$NON-NLS-1$
109
				if (keyBinding != null) InitAction.setText(
110
						MakeUIPlugin.getResourceString("ActionMakeBuildTarget.label")+"\t"+ keyBinding); //$NON-NLS-1$ //$NON-NLS-2$
111
				
112
			}
113
		}
114
	};
66
115
67
}
116
}
(-)src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java (-2 / +2 lines)
Lines 34-44 Link Here
34
	private final TargetListViewerPart targetPart;
34
	private final TargetListViewerPart targetPart;
35
	private final IContainer fContainer;
35
	private final IContainer fContainer;
36
36
37
	public BuildTargetDialog(Shell parent, IContainer container) {
37
	public BuildTargetDialog(Shell parent, IContainer container, boolean recursive) {
38
		super(parent);
38
		super(parent);
39
		setShellStyle(getShellStyle() | SWT.RESIZE);
39
		setShellStyle(getShellStyle() | SWT.RESIZE);
40
		fContainer = container;
40
		fContainer = container;
41
		targetPart = new TargetListViewerPart(fContainer);
41
		targetPart = new TargetListViewerPart(fContainer, recursive);
42
	}
42
	}
43
43
44
	public void setTarget(IMakeTarget target) {
44
	public void setTarget(IMakeTarget target) {
(-)src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java (+15 lines)
Lines 22-27 Link Here
22
import org.eclipse.core.runtime.IPath;
22
import org.eclipse.core.runtime.IPath;
23
import org.eclipse.core.runtime.IStatus;
23
import org.eclipse.core.runtime.IStatus;
24
import org.eclipse.core.runtime.Path;
24
import org.eclipse.core.runtime.Path;
25
import org.eclipse.core.runtime.QualifiedName;
25
import org.eclipse.core.runtime.Status;
26
import org.eclipse.core.runtime.Status;
26
import org.eclipse.jface.dialogs.Dialog;
27
import org.eclipse.jface.dialogs.Dialog;
27
import org.eclipse.jface.dialogs.IDialogConstants;
28
import org.eclipse.jface.dialogs.IDialogConstants;
Lines 476-481 Link Here
476
				target = fTargetManager.createTarget(fContainer.getProject(), targetName, targetBuildID);
477
				target = fTargetManager.createTarget(fContainer.getProject(), targetName, targetBuildID);
477
			} else {
478
			} else {
478
				if (!target.getName().equals(targetName)) {
479
				if (!target.getName().equals(targetName)) {
480
					String lastTargetName = null;
481
					IContainer container = target.getContainer();
482
					try {
483
						lastTargetName = (String)container.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget")); //$NON-NLS-1$
484
					} catch (CoreException e) {
485
					}
486
					if (lastTargetName != null && lastTargetName.equals(target.getName())) {
487
						IPath path = container.getProjectRelativePath().removeFirstSegments(
488
								container.getProjectRelativePath().segmentCount());
489
						path = path.append(targetName);
490
						container.setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"), //$NON-NLS-1$
491
								path.toString());
492
					}
493
					
479
					fTargetManager.renameTarget(target, targetName);
494
					fTargetManager.renameTarget(target, targetName);
480
				}
495
				}
481
			}
496
			}
(-)src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java_lasttarget (+77 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2000, 2009 QNX Software Systems and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     QNX Software Systems - Initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.make.ui.views;
12
13
14
import java.util.List;
15
16
import org.eclipse.cdt.make.core.IMakeTarget;
17
import org.eclipse.cdt.make.internal.ui.MakeUIImages;
18
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
19
import org.eclipse.cdt.make.ui.TargetBuild;
20
import org.eclipse.core.resources.IContainer;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IPath;
23
import org.eclipse.core.runtime.QualifiedName;
24
import org.eclipse.jface.viewers.IStructuredSelection;
25
import org.eclipse.swt.widgets.Shell;
26
import org.eclipse.ui.actions.SelectionListenerAction;
27
28
public class BuildTargetAction extends SelectionListenerAction {
29
	private final Shell shell;
30
31
	public BuildTargetAction(Shell shell) {
32
		super(MakeUIPlugin.getResourceString("BuildTargetAction.label")); //$NON-NLS-1$
33
		this.shell = shell;
34
35
		setToolTipText(MakeUIPlugin.getResourceString("BuildTargetAction.tooltip")); //$NON-NLS-1$
36
		MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_BUILD); //$NON-NLS-1$
37
		setEnabled(false);
38
	}
39
40
	@Override
41
	public void run() {
42
		if (canBuild()) {
43
			IMakeTarget[] targets = getSelectedElements().toArray(new IMakeTarget[0]);
44
			TargetBuild.buildTargets(shell, targets);
45
			if (targets.length == 1) {
46
				IContainer container = targets[0].getContainer();
47
				IPath path = container.getProjectRelativePath().removeFirstSegments(
48
						container.getProjectRelativePath().segmentCount());
49
				path = path.append(targets[0].getName());
50
				try {
51
					container.setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(),"lastTarget"), //$NON-NLS-1$
52
							path.toString());
53
				} catch (CoreException e) {
54
				}
55
			}
56
		}
57
	}
58
59
	@Override
60
	protected boolean updateSelection(IStructuredSelection selection) {
61
		return super.updateSelection(selection) && canBuild();
62
	}
63
64
	private boolean canBuild() {
65
		List<?> elements = getSelectedElements();
66
		for (Object element : elements) {
67
			if (! (element instanceof IMakeTarget)) {
68
				return false;
69
			}
70
		}
71
		return elements.size()>0;
72
	}
73
74
	private List<?> getSelectedElements() {
75
		return getStructuredSelection().toList();
76
	}
77
}
(-)src/org/eclipse/cdt/make/ui/views/MakeView.java (+8 lines)
Lines 80-85 Link Here
80
	private Clipboard clipboard;
80
	private Clipboard clipboard;
81
81
82
	private BuildTargetAction buildTargetAction;
82
	private BuildTargetAction buildTargetAction;
83
	private RebuildLastTargetAction buildLastTargetAction;
83
	private EditTargetAction editTargetAction;
84
	private EditTargetAction editTargetAction;
84
	private DeleteTargetAction deleteTargetAction;
85
	private DeleteTargetAction deleteTargetAction;
85
	private AddTargetAction newTargetAction;
86
	private AddTargetAction newTargetAction;
Lines 287-292 Link Here
287
		clipboard = new Clipboard(shell.getDisplay());
288
		clipboard = new Clipboard(shell.getDisplay());
288
289
289
		buildTargetAction = new BuildTargetAction(shell);
290
		buildTargetAction = new BuildTargetAction(shell);
291
		buildLastTargetAction = new RebuildLastTargetAction();
290
		newTargetAction = new AddTargetAction(shell);
292
		newTargetAction = new AddTargetAction(shell);
291
		copyTargetAction = new CopyTargetAction(shell, clipboard, pasteTargetAction);
293
		copyTargetAction = new CopyTargetAction(shell, clipboard, pasteTargetAction);
292
		pasteTargetAction = new PasteTargetAction(shell, clipboard);
294
		pasteTargetAction = new PasteTargetAction(shell, clipboard);
Lines 345-350 Link Here
345
		manager.add(deleteTargetAction);
347
		manager.add(deleteTargetAction);
346
		manager.add(new Separator());
348
		manager.add(new Separator());
347
		manager.add(buildTargetAction);
349
		manager.add(buildTargetAction);
350
		manager.add(buildLastTargetAction);
348
351
349
		// Other plug-ins can contribute there actions here
352
		// Other plug-ins can contribute there actions here
350
		// manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
353
		// manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
Lines 362-367 Link Here
362
	void updateActions(IStructuredSelection sel) {
365
	void updateActions(IStructuredSelection sel) {
363
		newTargetAction.selectionChanged(sel);
366
		newTargetAction.selectionChanged(sel);
364
		buildTargetAction.selectionChanged(sel);
367
		buildTargetAction.selectionChanged(sel);
368
		buildLastTargetAction.selectionChanged(sel);
365
		deleteTargetAction.selectionChanged(sel);
369
		deleteTargetAction.selectionChanged(sel);
366
		editTargetAction.selectionChanged(sel);
370
		editTargetAction.selectionChanged(sel);
367
		copyTargetAction.selectionChanged(sel);
371
		copyTargetAction.selectionChanged(sel);
Lines 406-411 Link Here
406
				keyBinding = bindingService.getBestActiveBindingFormattedFor(IWorkbenchCommandConstants.EDIT_DELETE);
410
				keyBinding = bindingService.getBestActiveBindingFormattedFor(IWorkbenchCommandConstants.EDIT_DELETE);
407
				if (keyBinding != null) deleteTargetAction.setText(
411
				if (keyBinding != null) deleteTargetAction.setText(
408
						MakeUIPlugin.getResourceString("DeleteTargetAction.label")+"\t"+ keyBinding); //$NON-NLS-1$ //$NON-NLS-2$
412
						MakeUIPlugin.getResourceString("DeleteTargetAction.label")+"\t"+ keyBinding); //$NON-NLS-1$ //$NON-NLS-2$
413
				
414
				keyBinding = bindingService.getBestActiveBindingFormattedFor("org.eclipse.cdt.make.ui.targetBuildLastCommand"); //$NON-NLS-1$
415
				if (keyBinding != null) buildLastTargetAction.setText(
416
						MakeUIPlugin.getResourceString("BuildLastTargetAction.label")+"\t"+ keyBinding); //$NON-NLS-1$ //$NON-NLS-2$
409
			}
417
			}
410
		}
418
		}
411
	};
419
	};
(-)src/org/eclipse/cdt/make/ui/views/RebuildLastTargetAction.java (+37 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 Axel Mueller.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     Axel Mueller - [69922] Initial implementation
10
 *******************************************************************************/
11
package org.eclipse.cdt.make.ui.views;
12
13
14
15
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
16
import org.eclipse.cdt.make.ui.actions.BuildLastTargetAction;
17
import org.eclipse.ui.actions.SelectionListenerAction;
18
19
public class RebuildLastTargetAction extends SelectionListenerAction {
20
	
21
	public RebuildLastTargetAction() {
22
		super(MakeUIPlugin.getResourceString("BuildLastTargetAction.label")); //$NON-NLS-1$
23
		
24
		setToolTipText(MakeUIPlugin.getResourceString("BuildLastTargetAction.tooltip")); //$NON-NLS-1$		
25
		setEnabled(false);
26
	}
27
	
28
	@Override
29
	public void run() {
30
		final BuildLastTargetAction buildAction= new BuildLastTargetAction();
31
		buildAction.selectionChanged(null, this.getStructuredSelection());
32
33
		if (buildAction.isEnabled()) {
34
			buildAction.run(null);
35
		}
36
	}
37
}

Return to bug 69922