Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 157680 Details for
Bug 69922
[Help Wanted] Introduce a "run last make target" key binding
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Bind Build Target dialog to a key and introduce a true key binding for the last target
BuildLastTarget_69922_patch5.txt (text/plain), 35.00 KB, created by
Axel Mueller
on 2010-01-29 17:30:59 EST
(
hide
)
Description:
Bind Build Target dialog to a key and introduce a true key binding for the last target
Filename:
MIME Type:
Creator:
Axel Mueller
Created:
2010-01-29 17:30:59 EST
Size:
35.00 KB
patch
obsolete
>### 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 29 Jan 2010 22:20:15 -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 29 Jan 2010 22:20:16 -0000 >@@ -54,6 +54,14 @@ > 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" > menubarPath="org.eclipse.cdt.make.ui.menu/gm1" >@@ -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"> >@@ -144,6 +162,13 @@ > 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" > categoryId="org.eclipse.ui.category.project" >@@ -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" >@@ -340,11 +389,17 @@ > 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> >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 29 Jan 2010 22:20:16 -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 29 Jan 2010 22:20:16 -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 29 Jan 2010 22:20:17 -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 29 Jan 2010 22:20:17 -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,79 @@ >+/******************************************************************************* >+ * 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 { >+ boolean showDialog = false; >+ 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 }); >+ } else >+ showDialog = true; >+ } >+ } else >+ showDialog = true; >+ >+ // 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(); >+ } >+} >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 29 Jan 2010 22:20:19 -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 29 Jan 2010 22:20:19 -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 29 Jan 2010 22:20:20 -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 >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java,v >retrieving revision 1.12 >diff -u -r1.12 BuildTargetAction.java >--- src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java 12 Mar 2009 18:21:05 -0000 1.12 >+++ src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java 29 Jan 2010 22:20:20 -0000 >@@ -17,6 +17,10 @@ > 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 @@ > 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) { >+ } > } > } > >Index: src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.cdt/all/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java,v >retrieving revision 1.13 >diff -u -r1.13 DeleteTargetAction.java >--- src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java 20 May 2009 13:59:57 -0000 1.13 >+++ src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java 29 Jan 2010 22:20:20 -0000 >@@ -17,7 +17,10 @@ > 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.IPath; >+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 +76,21 @@ > try { > for (Object target : getSelectedElements()) { > if (target instanceof IMakeTarget) { >- manager.removeTarget((IMakeTarget) target); >+ manager.removeTarget((IMakeTarget) target); >+ // remove last target property if necessary >+ 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) { >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 29 Jan 2010 22:20:20 -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); >+ } >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 69922
:
152531
|
155335
|
155641
|
157353
|
157680
|
157846