Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/CreateBuildAction.java')
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/CreateBuildAction.java38
1 files changed, 34 insertions, 4 deletions
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/CreateBuildAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/CreateBuildAction.java
index d05faa5c2f5..e8bd55e91f3 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/CreateBuildAction.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/CreateBuildAction.java
@@ -8,7 +8,14 @@
***********************************************************************/
package org.eclipse.cdt.make.ui.actions;
+import org.eclipse.cdt.core.model.ICContainer;
+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.dialogs.BuildTargetDialog;
import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -24,8 +31,25 @@ public class CreateBuildAction extends ActionDelegate implements IObjectActionDe
IContainer fContainer;
public void run(IAction action) {
- BuildTargetDialog dialog = new BuildTargetDialog(fPart.getSite().getShell(), fContainer);
- dialog.open();
+ if ( fContainer != null ) {
+ BuildTargetDialog dialog = new BuildTargetDialog(fPart.getSite().getShell(), fContainer);
+ dialog.setOpenMode(BuildTargetDialog.OPEN_MODE_BUILD);
+ String name;
+ try {
+ name = (String) fContainer.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"));
+ IMakeTarget target = MakeCorePlugin.getDefault().getTargetManager().findTarget(fContainer, name);
+ dialog.setSelectedTarget(target);
+ } catch (CoreException e) {
+ }
+ dialog.open();
+ IMakeTarget target = dialog.getSelectedTarget();
+ if ( target != null ) {
+ try {
+ fContainer.setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"), target.getName());
+ } catch (CoreException e1) {
+ }
+ }
+ }
}
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
@@ -37,8 +61,14 @@ public class CreateBuildAction extends ActionDelegate implements IObjectActionDe
public void selectionChanged(IAction action, ISelection selection) {
if ( selection instanceof IStructuredSelection ) {
- fContainer = (IContainer)((IStructuredSelection)selection).getFirstElement();
+ IStructuredSelection sel = (IStructuredSelection)selection;
+ if ( sel.getFirstElement() instanceof ICContainer ) {
+ fContainer = (IContainer) ((ICContainer)sel.getFirstElement()).getUnderlyingResource();
+ } else if (sel.getFirstElement() instanceof IContainer ) {
+ fContainer = (IContainer)sel.getFirstElement();
+ } else {
+ fContainer = null;
+ }
}
}
-
}

Back to the top