Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Inglis2005-07-04 14:06:27 +0000
committerDavid Inglis2005-07-04 14:06:27 +0000
commitbcf69885a2954f37381ed63c03100b1f89da3310 (patch)
treecf4142d2815f83d3fda620a7c659ac03b87fa9b9 /build/org.eclipse.cdt.make.ui
parentd4b824ca8c15064867bc5ad517440948583631db (diff)
downloadorg.eclipse.cdt-bcf69885a2954f37381ed63c03100b1f89da3310.tar.gz
org.eclipse.cdt-bcf69885a2954f37381ed63c03100b1f89da3310.tar.xz
org.eclipse.cdt-bcf69885a2954f37381ed63c03100b1f89da3310.zip
fixed for bug#94831
Diffstat (limited to 'build/org.eclipse.cdt.make.ui')
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/AddBuildTargetAction.java32
-rw-r--r--build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java20
2 files changed, 32 insertions, 20 deletions
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/AddBuildTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/AddBuildTargetAction.java
index 421d685805a..2d4f0b36072 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/AddBuildTargetAction.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/editor/AddBuildTargetAction.java
@@ -19,6 +19,7 @@ import org.eclipse.cdt.make.core.MakeCorePlugin;
import org.eclipse.cdt.make.core.makefile.ITargetRule;
import org.eclipse.cdt.make.internal.ui.MakeUIPlugin;
import org.eclipse.cdt.make.ui.dialogs.MakeTargetDialog;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.Action;
@@ -68,18 +69,15 @@ public class AddBuildTargetAction extends Action {
sbMakefileTarget.append(' ').append(name);
}
}
- String buildName = sbBuildName.toString();
+ String buildName = generateUniqueName(file.getParent(), sbBuildName.toString());
String makefileTarget = sbMakefileTarget.toString();
- IMakeTarget target;
+ IMakeTarget target = null;
try {
- target = manager.findTarget(file.getParent(), buildName);
- if (target == null) {
- String[] ids = manager.getTargetBuilders(file.getProject());
- if (ids.length > 0) {
- target = manager.createTarget(file.getProject(), buildName, ids[0]);
- target.setBuildTarget(makefileTarget);
- manager.addTarget(file.getParent(), target);
- }
+ String[] ids = manager.getTargetBuilders(file.getProject());
+ if (ids.length > 0) {
+ target = manager.createTarget(file.getProject(), buildName, ids[0]);
+ target.setBuildAttribute(IMakeTarget.BUILD_TARGET, makefileTarget);
+ target.setContainer(file.getParent());
}
} catch (CoreException e) {
MakeUIPlugin.errorDialog(shell, MakeUIPlugin.getResourceString("AddBuildTargetAction.exception.internal"), e.toString(), e); //$NON-NLS-1$
@@ -99,6 +97,20 @@ public class AddBuildTargetAction extends Action {
}
}
+ private String generateUniqueName(IContainer container, String targetString) {
+ String newName = targetString;
+ int i = 0;
+ IMakeTargetManager manager = MakeCorePlugin.getDefault().getTargetManager();
+ try {
+ while (manager.findTarget(container, newName) != null) {
+ i++;
+ newName = targetString + " (" + Integer.toString(i) + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ } catch (CoreException e) {
+ }
+ return newName;
+ }
+
public boolean canActionBeAdded(ISelection selection) {
ITargetRule[] rules = getTargetRules(selection);
for (int i = 0; i < rules.length; i++) {
diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java
index 07b0e3b468f..079554f5362 100644
--- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java
+++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java
@@ -91,7 +91,7 @@ public class MakeTargetDialog extends Dialog {
buildCommand = target.getBuildCommand();
buildArguments = target.getBuildArguments();
targetName = target.getName();
- targetString = target.getBuildTarget();
+ targetString = target.getBuildAttribute(IMakeTarget.BUILD_TARGET, "all");
targetBuildID = target.getTargetBuilderID();
runAllBuilders = target.runAllBuilders();
}
@@ -125,7 +125,7 @@ public class MakeTargetDialog extends Dialog {
private String getTitle() {
String title;
- if (fTarget == null) {
+ if (fTarget == null || !MakeCorePlugin.getDefault().getTargetManager().targetExists(fTarget)) {
title = MakeUIPlugin.getResourceString("MakeTargetDialog.title.createMakeTarget"); //$NON-NLS-1$
} else {
title = MakeUIPlugin.getResourceString("MakeTargetDialog.title.modifyMakeTarget"); //$NON-NLS-1$
@@ -298,10 +298,10 @@ public class MakeTargetDialog extends Dialog {
}
protected void createButtonsForButtonBar(Composite parent) {
- if (fTarget != null) {
- createButton(parent, IDialogConstants.OK_ID, MakeUIPlugin.getResourceString("MakeTargetDialog.button.update"), true); //$NON-NLS-1$
- } else {
+ if (fTarget == null || !MakeCorePlugin.getDefault().getTargetManager().targetExists(fTarget)) {
createButton(parent, IDialogConstants.OK_ID, MakeUIPlugin.getResourceString("MakeTargetDialog.button.create"), true); //$NON-NLS-1$
+ } else {
+ createButton(parent, IDialogConstants.OK_ID, MakeUIPlugin.getResourceString("MakeTargetDialog.button.update"), true); //$NON-NLS-1$
}
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
//do this here because setting the text will set enablement on the ok
@@ -333,7 +333,7 @@ public class MakeTargetDialog extends Dialog {
}
protected boolean targetHasChanged() {
- if (initializing || fTarget == null)
+ if (initializing || fTarget == null || !MakeCorePlugin.getDefault().getTargetManager().targetExists(fTarget))
return true;
if (isStopOnError != isStopOnError())
return true;
@@ -421,16 +421,16 @@ public class MakeTargetDialog extends Dialog {
} else {
path = new Path(bldLine.substring(start, end));
}
- target.setBuildCommand(path);
+ target.setBuildAttribute(IMakeTarget.BUILD_COMMAND, path.toString());
String args = ""; //$NON-NLS-1$
if (end != -1) {
args = bldLine.substring(end + 1);
}
- target.setBuildArguments(args);
+ target.setBuildAttribute(IMakeTarget.BUILD_ARGUMENTS, args);
}
- target.setBuildTarget(getTarget());
+ target.setBuildAttribute(IMakeTarget.BUILD_TARGET, getTarget());
- if (fTarget == null) {
+ if (fTarget == null || !MakeCorePlugin.getDefault().getTargetManager().targetExists(fTarget)) {
fTargetManager.addTarget(fContainer, target);
} else {
if (!target.getName().equals(getTargetName())) {

Back to the top