mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
finish up project convertion to convert old make target to new targets
finish up build target dialog - add/remove/delete now working - displayed as a table
This commit is contained in:
parent
428e119084
commit
ad843c5751
7 changed files with 316 additions and 158 deletions
|
@ -1,35 +0,0 @@
|
||||||
package org.eclipse.cdt.make.internal.ui.part;
|
|
||||||
|
|
||||||
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
|
||||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
||||||
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
|
||||||
import org.eclipse.jface.viewers.StructuredViewer;
|
|
||||||
import org.eclipse.jface.viewers.TableViewer;
|
|
||||||
import org.eclipse.swt.SWT;
|
|
||||||
import org.eclipse.swt.widgets.Button;
|
|
||||||
import org.eclipse.swt.widgets.Composite;
|
|
||||||
|
|
||||||
public class ListViewerPart extends StructuredViewerPart {
|
|
||||||
|
|
||||||
public ListViewerPart(String[] buttonLabels) {
|
|
||||||
super(buttonLabels);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected StructuredViewer createStructuredViewer(Composite parent, int style) {
|
|
||||||
TableViewer tableViewer = new TableViewer(parent, SWT.SINGLE | SWT.BORDER);
|
|
||||||
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
|
||||||
public void selectionChanged(SelectionChangedEvent e) {
|
|
||||||
ListViewerPart.this.selectionChanged((IStructuredSelection) e.getSelection());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return tableViewer;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void buttonSelected(Button button, int index) {
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void selectionChanged(IStructuredSelection selection) {
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
|
@ -80,10 +80,10 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] getElements(Object obj) {
|
public Object[] getElements(Object obj) {
|
||||||
if ( bFlatten ) {
|
if (bFlatten) {
|
||||||
List list = new ArrayList();
|
List list = new ArrayList();
|
||||||
Object[] children = getChildren(obj);
|
Object[] children = getChildren(obj);
|
||||||
for( int i = 0; i < children.length; i++ ) {
|
for (int i = 0; i < children.length; i++) {
|
||||||
list.add(children[i]);
|
list.add(children[i]);
|
||||||
list.addAll(Arrays.asList(getElements(children[i])));
|
list.addAll(Arrays.asList(getElements(children[i])));
|
||||||
}
|
}
|
||||||
|
@ -145,7 +145,11 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis
|
||||||
ctrl.getDisplay().syncExec(new Runnable() {
|
ctrl.getDisplay().syncExec(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
if (ctrl != null && !ctrl.isDisposed()) {
|
if (ctrl != null && !ctrl.isDisposed()) {
|
||||||
viewer.refresh(event.getTarget().getContainer());
|
if (bFlatten) {
|
||||||
|
viewer.refresh();
|
||||||
|
} else {
|
||||||
|
viewer.refresh(event.getTarget().getContainer());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,11 +9,12 @@ 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.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.jface.viewers.ITableLabelProvider;
|
||||||
import org.eclipse.jface.viewers.LabelProvider;
|
import org.eclipse.jface.viewers.LabelProvider;
|
||||||
import org.eclipse.swt.graphics.Image;
|
import org.eclipse.swt.graphics.Image;
|
||||||
import org.eclipse.ui.model.WorkbenchLabelProvider;
|
import org.eclipse.ui.model.WorkbenchLabelProvider;
|
||||||
|
|
||||||
public class MakeLabelProvider extends LabelProvider {
|
public class MakeLabelProvider extends LabelProvider implements ITableLabelProvider {
|
||||||
private IPath pathPrefix;
|
private IPath pathPrefix;
|
||||||
|
|
||||||
WorkbenchLabelProvider fLableProvider = new WorkbenchLabelProvider();
|
WorkbenchLabelProvider fLableProvider = new WorkbenchLabelProvider();
|
||||||
|
@ -42,32 +43,12 @@ public class MakeLabelProvider extends LabelProvider {
|
||||||
* @see ILabelProvider#getText(Object)
|
* @see ILabelProvider#getText(Object)
|
||||||
*/
|
*/
|
||||||
public String getText(Object obj) {
|
public String getText(Object obj) {
|
||||||
StringBuffer str = new StringBuffer();
|
|
||||||
if (obj instanceof IMakeTarget) {
|
if (obj instanceof IMakeTarget) {
|
||||||
if ( pathPrefix != null) {
|
return ((IMakeTarget) obj).getName();
|
||||||
IPath targetPath = ((IMakeTarget)obj).getContainer().getProjectRelativePath();
|
|
||||||
if ( pathPrefix.isPrefixOf(targetPath) ) {
|
|
||||||
targetPath = targetPath.removeFirstSegments(pathPrefix.segmentCount());
|
|
||||||
}
|
|
||||||
str.append(targetPath.toString());
|
|
||||||
if (targetPath.segmentCount() > 0) {
|
|
||||||
str.append("/");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
str.append(((IMakeTarget)obj).getName());
|
|
||||||
} else if (obj instanceof IContainer) {
|
} else if (obj instanceof IContainer) {
|
||||||
if ( pathPrefix != null ) {
|
return fLableProvider.getText(obj);
|
||||||
IPath targetPath = ((IContainer)obj).getProjectRelativePath();
|
|
||||||
if ( pathPrefix.isPrefixOf(targetPath) ) {
|
|
||||||
targetPath = targetPath.removeFirstSegments(pathPrefix.segmentCount());
|
|
||||||
}
|
|
||||||
str.append(targetPath.toString());
|
|
||||||
str.append("/");
|
|
||||||
} else {
|
|
||||||
return fLableProvider.getText(obj);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return str.toString();
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
@ -75,4 +56,27 @@ public class MakeLabelProvider extends LabelProvider {
|
||||||
fLableProvider.dispose();
|
fLableProvider.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Image getColumnImage(Object obj, int columnIndex) {
|
||||||
|
return columnIndex == 0 ? getImage(obj) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getColumnText(Object obj, int columnIndex) {
|
||||||
|
switch (columnIndex) {
|
||||||
|
case 0 :
|
||||||
|
return getText(obj);
|
||||||
|
case 1 :
|
||||||
|
if (obj instanceof IMakeTarget) {
|
||||||
|
if (pathPrefix != null) {
|
||||||
|
IPath targetPath = ((IMakeTarget) obj).getContainer().getProjectRelativePath();
|
||||||
|
if (pathPrefix.isPrefixOf(targetPath)) {
|
||||||
|
targetPath = targetPath.removeFirstSegments(pathPrefix.segmentCount());
|
||||||
|
}
|
||||||
|
if (targetPath.segmentCount() > 0) {
|
||||||
|
return targetPath.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,137 @@
|
||||||
|
package org.eclipse.cdt.make.ui;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.make.core.IMakeTarget;
|
||||||
|
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.cdt.make.internal.ui.part.StructuredViewerPart;
|
||||||
|
import org.eclipse.cdt.make.ui.dialogs.MakeTargetDialog;
|
||||||
|
import org.eclipse.core.resources.IContainer;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.jface.viewers.ColumnWeightData;
|
||||||
|
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
|
import org.eclipse.jface.viewers.SelectionChangedEvent;
|
||||||
|
import org.eclipse.jface.viewers.StructuredSelection;
|
||||||
|
import org.eclipse.jface.viewers.StructuredViewer;
|
||||||
|
import org.eclipse.jface.viewers.TableLayout;
|
||||||
|
import org.eclipse.jface.viewers.TableViewer;
|
||||||
|
import org.eclipse.jface.viewers.Viewer;
|
||||||
|
import org.eclipse.jface.viewers.ViewerFilter;
|
||||||
|
import org.eclipse.swt.SWT;
|
||||||
|
import org.eclipse.swt.widgets.Button;
|
||||||
|
import org.eclipse.swt.widgets.Composite;
|
||||||
|
import org.eclipse.swt.widgets.Table;
|
||||||
|
import org.eclipse.swt.widgets.TableColumn;
|
||||||
|
|
||||||
|
public class TargetListViewerPart extends StructuredViewerPart {
|
||||||
|
|
||||||
|
private TableViewer tableViewer;
|
||||||
|
private IMakeTarget fSelectedTarget;
|
||||||
|
private final int ADD_TARGET = 0;
|
||||||
|
private final int REMOVE_TARGET = 1;
|
||||||
|
private final int EDIT_TARGET = 2;
|
||||||
|
private IContainer fContainer;
|
||||||
|
|
||||||
|
public TargetListViewerPart(IContainer container) {
|
||||||
|
super(new String[] { "Add Target...", "Remove Target", "Edit Target..." });
|
||||||
|
fContainer = container;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected StructuredViewer createStructuredViewer(Composite parent, int style) {
|
||||||
|
tableViewer = new TableViewer(parent, SWT.SINGLE | SWT.BORDER);
|
||||||
|
Table table = (Table) tableViewer.getControl();
|
||||||
|
TableLayout layout = new TableLayout();
|
||||||
|
table.setLayout(layout);
|
||||||
|
table.setHeaderVisible(true);
|
||||||
|
|
||||||
|
layout.addColumnData(new ColumnWeightData(50));
|
||||||
|
TableColumn tc = new TableColumn(table, SWT.NONE);
|
||||||
|
tc.setText("Targets");
|
||||||
|
layout.addColumnData(new ColumnWeightData(50));
|
||||||
|
tc = new TableColumn(table, SWT.NONE);
|
||||||
|
tc.setText("Location");
|
||||||
|
|
||||||
|
tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
|
||||||
|
public void selectionChanged(SelectionChangedEvent e) {
|
||||||
|
TargetListViewerPart.this.selectionChanged((IStructuredSelection) e.getSelection());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tableViewer.setContentProvider(new MakeContentProvider(true));
|
||||||
|
tableViewer.addFilter(new ViewerFilter() {
|
||||||
|
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
||||||
|
return (element instanceof IMakeTarget);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
tableViewer.setLabelProvider(new MakeLabelProvider(fContainer.getProjectRelativePath()));
|
||||||
|
tableViewer.setInput(fContainer);
|
||||||
|
|
||||||
|
if (fSelectedTarget != null) {
|
||||||
|
tableViewer.setSelection(new StructuredSelection(fSelectedTarget), true);
|
||||||
|
}
|
||||||
|
return tableViewer;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void buttonSelected(Button button, int index) {
|
||||||
|
try {
|
||||||
|
switch (index) {
|
||||||
|
case ADD_TARGET :
|
||||||
|
{
|
||||||
|
MakeTargetDialog dialog = new MakeTargetDialog(getControl().getShell(), fContainer);
|
||||||
|
dialog.open();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case REMOVE_TARGET :
|
||||||
|
IMakeTargetManager manager = MakeCorePlugin.getDefault().getTargetManager();
|
||||||
|
manager.removeTarget((IMakeTarget) ((IStructuredSelection) getViewer().getSelection()).getFirstElement());
|
||||||
|
break;
|
||||||
|
case EDIT_TARGET :
|
||||||
|
{
|
||||||
|
MakeTargetDialog dialog =
|
||||||
|
new MakeTargetDialog(
|
||||||
|
getControl().getShell(),
|
||||||
|
(IMakeTarget) ((IStructuredSelection) getViewer().getSelection()).getFirstElement());
|
||||||
|
dialog.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
MakeUIPlugin.errorDialog(getControl().getShell(), "Error", "Error", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void selectionChanged(IStructuredSelection selection) {
|
||||||
|
fSelectedTarget = (IMakeTarget) selection.getFirstElement();
|
||||||
|
updateEnabledState();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSelectedTarget(IMakeTarget target) {
|
||||||
|
if (tableViewer != null) {
|
||||||
|
tableViewer.setSelection(new StructuredSelection(fSelectedTarget), true);
|
||||||
|
} else {
|
||||||
|
fSelectedTarget = target;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IMakeTarget getSelectedTarget() {
|
||||||
|
return fSelectedTarget;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.internal.ui.part.SharedPart#updateEnabledState()
|
||||||
|
*/
|
||||||
|
protected void updateEnabledState() {
|
||||||
|
super.updateEnabledState();
|
||||||
|
setButtonEnabled(REMOVE_TARGET, fSelectedTarget != null && isEnabled());
|
||||||
|
setButtonEnabled(EDIT_TARGET, fSelectedTarget != null && isEnabled());
|
||||||
|
}
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.make.internal.ui.part.SharedPart#createControl(org.eclipse.swt.widgets.Composite, int, int)
|
||||||
|
*/
|
||||||
|
public void createControl(Composite parent, int style, int span) {
|
||||||
|
super.createControl(parent, style, span);
|
||||||
|
updateEnabledState();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -14,13 +14,19 @@ import java.util.ArrayList;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.make.core.IMakeBuilderInfo;
|
import org.eclipse.cdt.make.core.IMakeBuilderInfo;
|
||||||
|
import org.eclipse.cdt.make.core.IMakeTarget;
|
||||||
|
import org.eclipse.cdt.make.core.IMakeTargetManager;
|
||||||
import org.eclipse.cdt.make.core.MakeBuilder;
|
import org.eclipse.cdt.make.core.MakeBuilder;
|
||||||
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
import org.eclipse.cdt.make.core.MakeCorePlugin;
|
||||||
import org.eclipse.cdt.make.core.MakeProjectNature;
|
import org.eclipse.cdt.make.core.MakeProjectNature;
|
||||||
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
|
||||||
import org.eclipse.cdt.make.ui.wizards.UpdateMakeProjectWizard;
|
import org.eclipse.cdt.make.ui.wizards.UpdateMakeProjectWizard;
|
||||||
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
import org.eclipse.core.resources.IResource;
|
||||||
|
import org.eclipse.core.resources.IResourceProxy;
|
||||||
|
import org.eclipse.core.resources.IResourceProxyVisitor;
|
||||||
import org.eclipse.core.resources.IWorkspaceRunnable;
|
import org.eclipse.core.resources.IWorkspaceRunnable;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -103,6 +109,57 @@ public class UpdateMakeProjectAction implements IWorkbenchWindowActionDelegate {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class TargetConvertVisitor implements IResourceProxyVisitor {
|
||||||
|
private final int TOTAL_WORK = 100;
|
||||||
|
private int halfWay = TOTAL_WORK / 2;
|
||||||
|
private int currentIncrement = 4;
|
||||||
|
private int nextProgress = currentIncrement;
|
||||||
|
private int worked = 0;
|
||||||
|
IProgressMonitor monitor;
|
||||||
|
|
||||||
|
public TargetConvertVisitor(IProgressMonitor monitor) {
|
||||||
|
this.monitor = monitor;
|
||||||
|
monitor.beginTask("Converting Make Targets...", TOTAL_WORK);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean visit(IResourceProxy proxy) throws CoreException {
|
||||||
|
try {
|
||||||
|
if (proxy.getType() != IResource.FOLDER && proxy.getType() != IResource.PROJECT) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
IContainer container = (IContainer) proxy.requestResource();
|
||||||
|
monitor.subTask(container.getProjectRelativePath().toString());
|
||||||
|
QualifiedName qName = new QualifiedName("org.eclipse.cdt.make", "goals");
|
||||||
|
String goal = container.getPersistentProperty(qName);
|
||||||
|
if (goal != null) {
|
||||||
|
goal = goal.trim();
|
||||||
|
IMakeTargetManager manager = MakeCorePlugin.getDefault().getTargetManager();
|
||||||
|
String[] builder = manager.getTargetBuilders(container.getProject());
|
||||||
|
IMakeTarget target = manager.createTarget(container.getProject(), goal, builder[0]);
|
||||||
|
target.setBuildTarget(goal);
|
||||||
|
manager.addTarget(container, target);
|
||||||
|
container.setPersistentProperty(qName, null);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
} finally {
|
||||||
|
if (--nextProgress <= 0) {
|
||||||
|
//we have exhausted the current increment, so report progress
|
||||||
|
monitor.worked(1);
|
||||||
|
worked++;
|
||||||
|
if (worked >= halfWay) {
|
||||||
|
//we have passed the current halfway point, so double the
|
||||||
|
//increment and reset the halfway point.
|
||||||
|
currentIncrement *= 2;
|
||||||
|
halfWay += (TOTAL_WORK - halfWay) / 2;
|
||||||
|
}
|
||||||
|
//reset the progress counter to another full increment
|
||||||
|
nextProgress = currentIncrement;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected static void doProjectUpdate(IProgressMonitor monitor, IProject[] project) throws CoreException {
|
protected static void doProjectUpdate(IProgressMonitor monitor, IProject[] project) throws CoreException {
|
||||||
monitor.beginTask("Updating make Projects...", project.length * 3);
|
monitor.beginTask("Updating make Projects...", project.length * 3);
|
||||||
try {
|
try {
|
||||||
|
@ -120,21 +177,36 @@ public class UpdateMakeProjectAction implements IWorkbenchWindowActionDelegate {
|
||||||
|
|
||||||
// move existing build properties to new
|
// move existing build properties to new
|
||||||
IMakeBuilderInfo newInfo = MakeCorePlugin.createBuildInfo(project[i], MakeBuilder.BUILDER_ID);
|
IMakeBuilderInfo newInfo = MakeCorePlugin.createBuildInfo(project[i], MakeBuilder.BUILDER_ID);
|
||||||
QualifiedName qlocation = new QualifiedName(CCorePlugin.PLUGIN_ID, "buildLocation");
|
final int LOCATION = 0, FULL_ARGS = 1, INC_ARGS = 2, STOP_ERORR = 3, USE_DEFAULT = 4;
|
||||||
String location = project[i].getPersistentProperty(qlocation);
|
QualifiedName[] qName = new QualifiedName[USE_DEFAULT + 1];
|
||||||
if ( location != null) {
|
qName[LOCATION] = new QualifiedName(CCorePlugin.PLUGIN_ID, "buildLocation");
|
||||||
newInfo.setBuildCommand(new Path(location));
|
qName[FULL_ARGS] = new QualifiedName(CCorePlugin.PLUGIN_ID, "buildFullArguments");
|
||||||
}
|
qName[INC_ARGS] = new QualifiedName(CCorePlugin.PLUGIN_ID, "buildIncrementalArguments");
|
||||||
|
qName[STOP_ERORR] = new QualifiedName(CCorePlugin.PLUGIN_ID, "stopOnError");
|
||||||
|
qName[USE_DEFAULT] = new QualifiedName(CCorePlugin.PLUGIN_ID, "useDefaultBuildCmd");
|
||||||
|
|
||||||
//remove old properties
|
String property = project[i].getPersistentProperty(qName[LOCATION]);
|
||||||
QualifiedName[] qName =
|
if (property != null) {
|
||||||
{
|
newInfo.setBuildCommand(new Path(property));
|
||||||
new QualifiedName(CCorePlugin.PLUGIN_ID, "buildFullArguments"),
|
}
|
||||||
new QualifiedName(CCorePlugin.PLUGIN_ID, "buildIncrementalArguments"),
|
property = project[i].getPersistentProperty(qName[FULL_ARGS]);
|
||||||
new QualifiedName("org.eclipse.cdt", "make.goals")};
|
if (property != null) {
|
||||||
|
newInfo.setBuildArguments(property);
|
||||||
|
}
|
||||||
|
property = project[i].getPersistentProperty(qName[STOP_ERORR]);
|
||||||
|
if (property != null) {
|
||||||
|
newInfo.setStopOnError(Boolean.valueOf(property).booleanValue());
|
||||||
|
}
|
||||||
|
property = project[i].getPersistentProperty(qName[USE_DEFAULT]);
|
||||||
|
if (property != null) {
|
||||||
|
newInfo.setUseDefaultBuildCmd(Boolean.valueOf(property).booleanValue());
|
||||||
|
}
|
||||||
for (int j = 0; j < qName.length; j++) {
|
for (int j = 0; j < qName.length; j++) {
|
||||||
project[i].setPersistentProperty(qName[j], null);
|
project[i].setPersistentProperty(qName[j], null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IProgressMonitor subMon = new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
|
||||||
|
project[i].accept(new TargetConvertVisitor(subMon), 0);
|
||||||
monitor.worked(1);
|
monitor.worked(1);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -145,5 +217,4 @@ public class UpdateMakeProjectAction implements IWorkbenchWindowActionDelegate {
|
||||||
public void selectionChanged(IAction action, ISelection selection) {
|
public void selectionChanged(IAction action, ISelection selection) {
|
||||||
fSelection = selection;
|
fSelection = selection;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,13 @@
|
||||||
package org.eclipse.cdt.make.ui.dialogs;
|
package org.eclipse.cdt.make.ui.dialogs;
|
||||||
|
|
||||||
import org.eclipse.cdt.make.core.IMakeTarget;
|
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.cdt.make.ui.TargetBuild;
|
||||||
|
import org.eclipse.cdt.make.ui.TargetListViewerPart;
|
||||||
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.StructuredViewer;
|
|
||||||
import org.eclipse.jface.viewers.Viewer;
|
|
||||||
import org.eclipse.jface.viewers.ViewerFilter;
|
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
import org.eclipse.swt.layout.GridLayout;
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
|
@ -24,22 +17,21 @@ import org.eclipse.swt.widgets.Label;
|
||||||
import org.eclipse.swt.widgets.Shell;
|
import org.eclipse.swt.widgets.Shell;
|
||||||
|
|
||||||
public class BuildTargetDialog extends Dialog {
|
public class BuildTargetDialog extends Dialog {
|
||||||
|
private TargetListViewerPart targetPart;
|
||||||
private IMakeTarget fSelected;
|
|
||||||
private StructuredViewer listViewer;
|
|
||||||
private IContainer fContainer;
|
private IContainer fContainer;
|
||||||
|
|
||||||
public BuildTargetDialog(Shell shell, IContainer container) {
|
public BuildTargetDialog(Shell shell, IContainer container) {
|
||||||
super(shell);
|
super(shell);
|
||||||
fContainer = container;
|
fContainer = container;
|
||||||
|
targetPart = new TargetListViewerPart(fContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTarget(IMakeTarget targets) {
|
public void setTarget(IMakeTarget target) {
|
||||||
fSelected = targets;
|
targetPart.setSelectedTarget(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IMakeTarget getTarget() {
|
public IMakeTarget getTarget() {
|
||||||
return fSelected;
|
return targetPart.getSelectedTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void configureShell(Shell newShell) {
|
protected void configureShell(Shell newShell) {
|
||||||
|
@ -61,38 +53,25 @@ public class BuildTargetDialog extends Dialog {
|
||||||
gd.horizontalSpan = 2;
|
gd.horizontalSpan = 2;
|
||||||
title.setLayoutData(gd);
|
title.setLayoutData(gd);
|
||||||
title.setText("Make Targets for: " + fContainer.getFullPath().toString().substring(1));
|
title.setText("Make Targets for: " + fContainer.getFullPath().toString().substring(1));
|
||||||
ListViewerPart part = new ListViewerPart(new String[] { "Add Target...", "Remove Target", "Edit Target..." });
|
targetPart.createControl(composite, SWT.NULL, 2);
|
||||||
part.createControl(composite, SWT.NULL, 2);
|
|
||||||
listViewer = part.getViewer();
|
gd = (GridData) targetPart.getControl().getLayoutData();
|
||||||
listViewer.setContentProvider(new MakeContentProvider(true));
|
gd.heightHint = convertHeightInCharsToPixels(15);
|
||||||
listViewer.addFilter(new ViewerFilter() {
|
gd.widthHint = convertWidthInCharsToPixels(50);
|
||||||
public boolean select(Viewer viewer, Object parentElement, Object element) {
|
targetPart.getControl().setLayoutData(gd);
|
||||||
return (element instanceof IMakeTarget);
|
targetPart.getViewer().addDoubleClickListener(new IDoubleClickListener() {
|
||||||
}
|
|
||||||
});
|
|
||||||
listViewer.setLabelProvider(new MakeLabelProvider(fContainer.getProjectRelativePath()));
|
|
||||||
listViewer.addDoubleClickListener(new IDoubleClickListener() {
|
|
||||||
public void doubleClick(DoubleClickEvent event) {
|
public void doubleClick(DoubleClickEvent event) {
|
||||||
okPressed();
|
okPressed();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
gd = (GridData) part.getControl().getLayoutData();
|
|
||||||
gd.heightHint = convertHeightInCharsToPixels(15);
|
|
||||||
gd.widthHint = convertWidthInCharsToPixels(50);
|
|
||||||
part.getControl().setLayoutData(gd);
|
|
||||||
|
|
||||||
listViewer.setInput(fContainer);
|
|
||||||
if (fSelected != null)
|
|
||||||
listViewer.setSelection(new StructuredSelection(fSelected), true);
|
|
||||||
|
|
||||||
return composite;
|
return composite;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void okPressed() {
|
protected void okPressed() {
|
||||||
fSelected = (IMakeTarget) ((IStructuredSelection) listViewer.getSelection()).getFirstElement();
|
IMakeTarget selected = targetPart.getSelectedTarget();
|
||||||
if (fSelected != null) {
|
if (selected != null) {
|
||||||
TargetBuild.runWithProgressDialog(getShell(), new IMakeTarget[] { fSelected });
|
TargetBuild.runWithProgressDialog(getShell(), new IMakeTarget[] { selected });
|
||||||
}
|
}
|
||||||
super.okPressed();
|
super.okPressed();
|
||||||
}
|
}
|
||||||
|
|
|
@ -175,9 +175,10 @@ public class MakeTargetDialog extends Dialog {
|
||||||
if (newName.equals("")) {
|
if (newName.equals("")) {
|
||||||
fStatusLine.setErrorMessage("Must specify a target name.");
|
fStatusLine.setErrorMessage("Must specify a target name.");
|
||||||
getButton(IDialogConstants.OK_ID).setEnabled(false);
|
getButton(IDialogConstants.OK_ID).setEnabled(false);
|
||||||
} else if (fTarget != null
|
} else if (
|
||||||
&& fTarget.getName().equals(newName)
|
fTarget != null
|
||||||
|| fTargetManager.findTarget(fContainer, newName) == null) {
|
&& fTarget.getName().equals(newName)
|
||||||
|
|| fTargetManager.findTarget(fContainer, newName) == null) {
|
||||||
fStatusLine.setErrorMessage(null);
|
fStatusLine.setErrorMessage(null);
|
||||||
getButton(IDialogConstants.OK_ID).setEnabled(true);
|
getButton(IDialogConstants.OK_ID).setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
|
@ -298,50 +299,47 @@ public class MakeTargetDialog extends Dialog {
|
||||||
|
|
||||||
protected void okPressed() {
|
protected void okPressed() {
|
||||||
IMakeTarget target = fTarget;
|
IMakeTarget target = fTarget;
|
||||||
if (fTarget == null) {
|
try {
|
||||||
target = fTargetManager.createTarget(targetNameText.getText().trim(), targetBuildID);
|
if (fTarget == null) {
|
||||||
}
|
target = fTargetManager.createTarget(fContainer.getProject(), targetNameText.getText().trim(), targetBuildID);
|
||||||
|
}
|
||||||
|
|
||||||
target.setStopOnError(isStopOnError());
|
target.setStopOnError(isStopOnError());
|
||||||
target.setUseDefaultBuildCmd(useDefaultBuildCmd());
|
target.setUseDefaultBuildCmd(useDefaultBuildCmd());
|
||||||
if (!useDefaultBuildCmd()) {
|
if (!useDefaultBuildCmd()) {
|
||||||
String bldLine = getBuildLine();
|
String bldLine = getBuildLine();
|
||||||
int start = 0;
|
int start = 0;
|
||||||
int end = -1;
|
int end = -1;
|
||||||
if (!bldLine.startsWith("\"")) { //$NON-NLS-1$
|
if (!bldLine.startsWith("\"")) { //$NON-NLS-1$
|
||||||
end = bldLine.indexOf(' ');
|
end = bldLine.indexOf(' ');
|
||||||
} else {
|
} else {
|
||||||
start = 1;
|
start = 1;
|
||||||
end = bldLine.indexOf('"', 1);
|
end = bldLine.indexOf('"', 1);
|
||||||
|
}
|
||||||
|
IPath path;
|
||||||
|
if (end == -1) {
|
||||||
|
path = new Path(bldLine);
|
||||||
|
} else {
|
||||||
|
path = new Path(bldLine.substring(start, end));
|
||||||
|
}
|
||||||
|
target.setBuildCommand(path);
|
||||||
|
String args = ""; //$NON-NLS-1$
|
||||||
|
if (end != -1) {
|
||||||
|
args = bldLine.substring(end + 1);
|
||||||
|
}
|
||||||
|
target.setBuildArguments(args);
|
||||||
}
|
}
|
||||||
IPath path;
|
target.setBuildTarget(targetText.getText().trim());
|
||||||
if (end == -1) {
|
|
||||||
path = new Path(bldLine);
|
|
||||||
} else {
|
|
||||||
path = new Path(bldLine.substring(start, end));
|
|
||||||
}
|
|
||||||
target.setBuildCommand(path);
|
|
||||||
String args = ""; //$NON-NLS-1$
|
|
||||||
if (end != -1) {
|
|
||||||
args = bldLine.substring(end + 1);
|
|
||||||
}
|
|
||||||
target.setBuildArguments(args);
|
|
||||||
}
|
|
||||||
target.setBuildTarget(targetText.getText().trim());
|
|
||||||
|
|
||||||
if (fTarget == null) {
|
if (fTarget == null) {
|
||||||
try {
|
|
||||||
fTargetManager.addTarget(fContainer, target);
|
fTargetManager.addTarget(fContainer, target);
|
||||||
} catch (CoreException e) {
|
} else {
|
||||||
MakeUIPlugin.errorDialog(getShell(), "Make Target Error", "Error adding target", e);
|
if (!target.getName().equals(targetNameText.getText().trim())) {
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!target.getName().equals(targetNameText.getText().trim())) {
|
|
||||||
try {
|
|
||||||
fTargetManager.renameTarget(target, targetNameText.getText().trim());
|
fTargetManager.renameTarget(target, targetNameText.getText().trim());
|
||||||
} catch (CoreException e) {
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
MakeUIPlugin.errorDialog(getShell(), "Make Target Error", "Error adding target", e);
|
||||||
}
|
}
|
||||||
super.okPressed();
|
super.okPressed();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue