diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/TargetBuild.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/TargetBuild.java similarity index 98% rename from build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/TargetBuild.java rename to build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/TargetBuild.java index 85735673642..e5162d2b891 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/TargetBuild.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/TargetBuild.java @@ -1,4 +1,4 @@ -package org.eclipse.cdt.make.ui.actions; +package org.eclipse.cdt.make.ui; /* * (c) Copyright QNX Software Systems Ltd. 2002. diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/BuildTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/BuildTargetAction.java index 1e070eb4937..017069ed6f4 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/BuildTargetAction.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/BuildTargetAction.java @@ -15,6 +15,8 @@ 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.IPath; +import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; @@ -34,21 +36,34 @@ public class BuildTargetAction extends ActionDelegate implements IObjectActionDe public void run(IAction action) { if (fContainer != null) { BuildTargetDialog dialog = new BuildTargetDialog(fPart.getSite().getShell(), fContainer); - String name; + String name = null; try { name = (String) fContainer.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget")); - IMakeTarget target = MakeCorePlugin.getDefault().getTargetManager().findTarget(fContainer, name); - if (target != null) - dialog.setTarget(new IMakeTarget[] { target }); } catch (CoreException e) { } + if ( name != null) { + IPath path = new Path(name); + name = path.segment(path.segmentCount() - 1); + IContainer container; + if ( path.segmentCount() > 1) { + path = path.removeLastSegments(1); + container = (IContainer) fContainer.findMember(path); + } else { + container = fContainer; + } + IMakeTarget target = MakeCorePlugin.getDefault().getTargetManager().findTarget(container, name); + if (target != null) + dialog.setTarget(target); + } if (dialog.open() == Window.OK) { IMakeTarget target = dialog.getTarget(); if (target != null) { try { + IPath path = target.getContainer().getProjectRelativePath().removeFirstSegments(fContainer.getProjectRelativePath().segmentCount()); + path = path.append(target.getName()); fContainer.setSessionProperty( new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"), - target.getName()); + path.toString()); } catch (CoreException e1) { } } diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java index 82507775986..7fb06a32130 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/BuildTargetDialog.java @@ -4,11 +4,13 @@ import org.eclipse.cdt.make.core.IMakeTarget; import org.eclipse.cdt.make.internal.ui.part.ListViewerPart; import org.eclipse.cdt.make.ui.MakeContentProvider; import org.eclipse.cdt.make.ui.MakeLabelProvider; +import org.eclipse.cdt.make.ui.TargetBuild; import org.eclipse.core.resources.IContainer; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.jface.viewers.Viewer; @@ -23,7 +25,7 @@ import org.eclipse.swt.widgets.Shell; public class BuildTargetDialog extends Dialog { - private IMakeTarget[] selected; + private IMakeTarget fSelected; private StructuredViewer listViewer; private IContainer fContainer; @@ -32,12 +34,12 @@ public class BuildTargetDialog extends Dialog { fContainer = container; } - public void setTarget(IMakeTarget[] targets) { - selected = targets; + public void setTarget(IMakeTarget targets) { + fSelected = targets; } public IMakeTarget getTarget() { - return null; + return fSelected; } protected void configureShell(Shell newShell) { @@ -53,7 +55,7 @@ public class BuildTargetDialog extends Dialog { protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); - ((GridLayout)composite.getLayout()).numColumns = 2; + ((GridLayout) composite.getLayout()).numColumns = 2; Label title = new Label(composite, SWT.NONE); GridData gd = new GridData(); gd.horizontalSpan = 2; @@ -73,21 +75,25 @@ public class BuildTargetDialog extends Dialog { public void doubleClick(DoubleClickEvent event) { okPressed(); } - }); + }); gd = (GridData) part.getControl().getLayoutData(); gd.heightHint = convertHeightInCharsToPixels(15); gd.widthHint = convertWidthInCharsToPixels(50); part.getControl().setLayoutData(gd); - + listViewer.setInput(fContainer); - if (selected != null) - listViewer.setSelection(new StructuredSelection(selected), true); + if (fSelected != null) + listViewer.setSelection(new StructuredSelection(fSelected), true); return composite; } - + protected void okPressed() { + fSelected = (IMakeTarget) ((IStructuredSelection) listViewer.getSelection()).getFirstElement(); + if (fSelected != null) { + TargetBuild.runWithProgressDialog(getShell(), new IMakeTarget[] { fSelected }); + } super.okPressed(); } diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java index c0f7ed43607..54b2538acfa 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/BuildTargetAction.java @@ -10,7 +10,7 @@ import java.util.List; import org.eclipse.cdt.make.core.IMakeTarget; import org.eclipse.cdt.make.internal.ui.MakeUIImages; -import org.eclipse.cdt.make.ui.actions.TargetBuild; +import org.eclipse.cdt.make.ui.TargetBuild; import org.eclipse.core.resources.IResource; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Shell;