1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-01 20:53:12 +02:00

target build dialog

This commit is contained in:
David Inglis 2003-09-04 20:26:48 +00:00
parent ad31833096
commit 0b3616d668
4 changed files with 38 additions and 17 deletions

View file

@ -1,4 +1,4 @@
package org.eclipse.cdt.make.ui.actions; package org.eclipse.cdt.make.ui;
/* /*
* (c) Copyright QNX Software Systems Ltd. 2002. * (c) Copyright QNX Software Systems Ltd. 2002.

View file

@ -15,6 +15,8 @@ import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.ui.dialogs.BuildTargetDialog; import org.eclipse.cdt.make.ui.dialogs.BuildTargetDialog;
import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IContainer;
import org.eclipse.core.runtime.CoreException; 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.core.runtime.QualifiedName;
import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
@ -34,21 +36,34 @@ public class BuildTargetAction extends ActionDelegate implements IObjectActionDe
public void run(IAction action) { public void run(IAction action) {
if (fContainer != null) { if (fContainer != null) {
BuildTargetDialog dialog = new BuildTargetDialog(fPart.getSite().getShell(), fContainer); BuildTargetDialog dialog = new BuildTargetDialog(fPart.getSite().getShell(), fContainer);
String name; String name = null;
try { try {
name = (String) fContainer.getSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget")); 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) { } 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) { if (dialog.open() == Window.OK) {
IMakeTarget target = dialog.getTarget(); IMakeTarget target = dialog.getTarget();
if (target != null) { if (target != null) {
try { try {
IPath path = target.getContainer().getProjectRelativePath().removeFirstSegments(fContainer.getProjectRelativePath().segmentCount());
path = path.append(target.getName());
fContainer.setSessionProperty( fContainer.setSessionProperty(
new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"), new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"),
target.getName()); path.toString());
} catch (CoreException e1) { } catch (CoreException e1) {
} }
} }

View file

@ -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.internal.ui.part.ListViewerPart;
import org.eclipse.cdt.make.ui.MakeContentProvider; import org.eclipse.cdt.make.ui.MakeContentProvider;
import org.eclipse.cdt.make.ui.MakeLabelProvider; import org.eclipse.cdt.make.ui.MakeLabelProvider;
import org.eclipse.cdt.make.ui.TargetBuild;
import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IContainer;
import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener; import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
@ -23,7 +25,7 @@ import org.eclipse.swt.widgets.Shell;
public class BuildTargetDialog extends Dialog { public class BuildTargetDialog extends Dialog {
private IMakeTarget[] selected; private IMakeTarget fSelected;
private StructuredViewer listViewer; private StructuredViewer listViewer;
private IContainer fContainer; private IContainer fContainer;
@ -32,12 +34,12 @@ public class BuildTargetDialog extends Dialog {
fContainer = container; fContainer = container;
} }
public void setTarget(IMakeTarget[] targets) { public void setTarget(IMakeTarget targets) {
selected = targets; fSelected = targets;
} }
public IMakeTarget getTarget() { public IMakeTarget getTarget() {
return null; return fSelected;
} }
protected void configureShell(Shell newShell) { protected void configureShell(Shell newShell) {
@ -53,7 +55,7 @@ public class BuildTargetDialog extends Dialog {
protected Control createDialogArea(Composite parent) { protected Control createDialogArea(Composite parent) {
Composite composite = (Composite) super.createDialogArea(parent); Composite composite = (Composite) super.createDialogArea(parent);
((GridLayout)composite.getLayout()).numColumns = 2; ((GridLayout) composite.getLayout()).numColumns = 2;
Label title = new Label(composite, SWT.NONE); Label title = new Label(composite, SWT.NONE);
GridData gd = new GridData(); GridData gd = new GridData();
gd.horizontalSpan = 2; gd.horizontalSpan = 2;
@ -73,21 +75,25 @@ public class BuildTargetDialog extends Dialog {
public void doubleClick(DoubleClickEvent event) { public void doubleClick(DoubleClickEvent event) {
okPressed(); okPressed();
} }
}); });
gd = (GridData) part.getControl().getLayoutData(); gd = (GridData) part.getControl().getLayoutData();
gd.heightHint = convertHeightInCharsToPixels(15); gd.heightHint = convertHeightInCharsToPixels(15);
gd.widthHint = convertWidthInCharsToPixels(50); gd.widthHint = convertWidthInCharsToPixels(50);
part.getControl().setLayoutData(gd); part.getControl().setLayoutData(gd);
listViewer.setInput(fContainer); listViewer.setInput(fContainer);
if (selected != null) if (fSelected != null)
listViewer.setSelection(new StructuredSelection(selected), true); listViewer.setSelection(new StructuredSelection(fSelected), true);
return composite; return composite;
} }
protected void okPressed() { protected void okPressed() {
fSelected = (IMakeTarget) ((IStructuredSelection) listViewer.getSelection()).getFirstElement();
if (fSelected != null) {
TargetBuild.runWithProgressDialog(getShell(), new IMakeTarget[] { fSelected });
}
super.okPressed(); super.okPressed();
} }

View file

@ -10,7 +10,7 @@ import java.util.List;
import org.eclipse.cdt.make.core.IMakeTarget; import org.eclipse.cdt.make.core.IMakeTarget;
import org.eclipse.cdt.make.internal.ui.MakeUIImages; 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.core.resources.IResource;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;