From cc174bfe8c322c059aa2e9a4c97ad0d3898d5623 Mon Sep 17 00:00:00 2001 From: David Inglis Date: Fri, 22 Aug 2003 21:26:28 +0000 Subject: [PATCH] update --- .../eclipse/cdt/make/core/IMakeTarget.java | 4 +- .../cdt/make/core/IMakeTargetManager.java | 8 +- .../cdt/make/internal/core/MakeTarget.java | 38 +- .../make/internal/core/MakeTargetManager.java | 32 +- .../make/internal/core/ProjectTargets.java | 96 +++-- .../cview16/{make.gif => make_target.gif} | Bin .../icons/obj16/error_obj.gif | Bin 0 -> 159 bytes .../obj16/{target.gif => target_obj.gif} | Bin .../org.eclipse.cdt.make.ui/plugin.properties | 11 +- build/org.eclipse.cdt.make.ui/plugin.xml | 64 +++- .../make/internal/ui/MakeResources.properties | 7 + .../cdt/make/internal/ui/MakeUIImages.java | 6 +- .../cdt/make/internal/ui/MessageLine.java | 61 +++ ...uildAction.java => BuildTargetAction.java} | 7 +- .../make/ui/actions/CreateTargetAction.java | 59 +++ .../cdt/make/ui/actions/TargetBuild.java | 15 +- .../make/ui/dialogs/BuildTargetDialog.java | 154 +------- .../cdt/make/ui/dialogs/MakeTargetDialog.java | 348 ++++++++++++++++++ .../cdt/make/ui/views/AddTargetAction.java | 13 +- .../cdt/make/ui/views/BuildTargetAction.java | 4 +- .../cdt/make/ui/views/DeleteTargetAction.java | 23 +- .../cdt/make/ui/views/EditTargetAction.java | 16 +- 22 files changed, 736 insertions(+), 230 deletions(-) rename build/org.eclipse.cdt.make.ui/icons/cview16/{make.gif => make_target.gif} (100%) create mode 100644 build/org.eclipse.cdt.make.ui/icons/obj16/error_obj.gif rename build/org.eclipse.cdt.make.ui/icons/obj16/{target.gif => target_obj.gif} (100%) create mode 100644 build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MessageLine.java rename build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/{CreateBuildAction.java => BuildTargetAction.java} (92%) create mode 100644 build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/CreateTargetAction.java create mode 100644 build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTarget.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTarget.java index db4b7414a0b..46655d01551 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTarget.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTarget.java @@ -25,9 +25,11 @@ public interface IMakeTarget { boolean isDefaultBuildCmd(); void setUseDefaultBuildCmd(boolean useDefault); + void setBuildTarget(String target); + String getBuildTarget(); + IPath getBuildCommand(); void setBuildCommand(IPath command); - String getBuildArguments(); void setBuildArguments(String arguments); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTargetManager.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTargetManager.java index 9bdd4e3df1d..4bf9c7fa141 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTargetManager.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeTargetManager.java @@ -15,7 +15,8 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; public interface IMakeTargetManager { - IMakeTarget addTarget(IContainer container, String targetBuilderID, String targetName) throws CoreException; + IMakeTarget createTarget(String targetName, String targetID); + void addTarget(IContainer container, IMakeTarget target) throws CoreException; void removeTarget(IMakeTarget target) throws CoreException; void renameTarget(IMakeTarget target, String name) throws CoreException; @@ -23,8 +24,9 @@ public interface IMakeTargetManager { IMakeTarget findTarget(IContainer container, String name); IProject[] getTargetBuilderProjects() throws CoreException; - - String getBuilderID(String targetBuilderID); + + String getBuilderID(String targetID); + String[] getTargetBuilders(IProject project); void addListener(IMakeTargetListener listener); diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java index 823371035af..5e3ec6c65b9 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTarget.java @@ -19,9 +19,11 @@ import org.eclipse.core.resources.IncrementalProjectBuilder; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Path; public class MakeTarget implements IMakeTarget { + private String target; private String buildArguments; private IPath buildCommand; private boolean isDefaultBuildCmd; @@ -29,13 +31,18 @@ public class MakeTarget implements IMakeTarget { private String name; private String targetBuilderID; private IContainer container; - - MakeTarget(IContainer container, String targetBuilderID, String name) { - this.container = container; + private MakeTargetManager manager; + + MakeTarget(MakeTargetManager manager, String targetBuilderID, String name) { + this.manager = manager; this.targetBuilderID = targetBuilderID; this.name = name; } + void setContainer(IContainer container) { + this.container = container; + } + void setName(String name) { this.name = name; } @@ -65,7 +72,7 @@ public class MakeTarget implements IMakeTarget { } public IPath getBuildCommand() { - return buildCommand; + return buildCommand != null ? buildCommand: new Path(""); } public void setBuildCommand(IPath command) { @@ -73,7 +80,7 @@ public class MakeTarget implements IMakeTarget { } public String getBuildArguments() { - return buildArguments; + return buildArguments != null ? buildArguments : ""; } public void setBuildArguments(String arguments) { @@ -100,16 +107,29 @@ public class MakeTarget implements IMakeTarget { public void build(IProgressMonitor monitor) throws CoreException { IProject project = container.getProject(); - String builderID = MakeCorePlugin.getDefault().getTargetManager().getBuilderID(targetBuilderID); + String builderID = manager.getBuilderID(targetBuilderID); HashMap infoMap = new HashMap(); IMakeBuilderInfo info = MakeCorePlugin.createBuildInfo(infoMap, builderID); - info.setBuildArguments(buildArguments); - info.setBuildCommand(buildCommand); + if ( buildArguments != null) { + info.setBuildArguments(buildArguments); + } + if ( buildCommand != null ) { + info.setBuildCommand(buildCommand); + } info.setUseDefaultBuildCmd(isDefaultBuildCmd); info.setStopOnError(isStopOnError); info.setFullBuildEnable(true); - info.setFullBuildTarget(buildArguments); + info.setFullBuildTarget(target); info.setBuildLocation(container.getLocation()); project.build(IncrementalProjectBuilder.FULL_BUILD, builderID, infoMap, monitor); } + + public void setBuildTarget(String target) { + this.target = target; + + } + + public String getBuildTarget() { + return target; + } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTargetManager.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTargetManager.java index e654bcff06f..d6219f71905 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTargetManager.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/MakeTargetManager.java @@ -48,6 +48,8 @@ import org.eclipse.core.runtime.Status; public class MakeTargetManager implements IMakeTargetManager, IResourceChangeListener { private static String TARGET_BUILD_EXT = "MakeTargetBuilder"; //$NON-NLS-1$ + private static String TARGETS_EXT = "targets"; //$NON-NLS-1$ + private ListenerList listeners = new ListenerList(); private HashMap projectMap = new HashMap(); private HashMap builderMap; @@ -56,19 +58,23 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis public MakeTargetManager() { } - public IMakeTarget addTarget(IContainer container, String targetBuilderID, String targetName) throws CoreException { + public IMakeTarget createTarget(String name, String targetBuilderID) { + return new MakeTarget(this, targetBuilderID, name); + } + + public void addTarget(IContainer container, IMakeTarget target) throws CoreException { if (container instanceof IWorkspaceRoot) { throw new CoreException(new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, MakeCorePlugin.getResourceString("MakeTargetManager.add_to_workspace_root"), null)); //$NON-NLS-1$ } - ProjectTargets projectTargets = (ProjectTargets) projectMap.get(container.getProject()); + IProject project = container.getProject(); + ProjectTargets projectTargets = (ProjectTargets) projectMap.get(project); if (projectTargets == null) { - projectTargets = readTargets(container.getProject()); + projectTargets = readTargets(project); } - MakeTarget target = new MakeTarget(container, targetBuilderID, targetName); - projectTargets.add(target); + ((MakeTarget)target).setContainer(container); + projectTargets.add((MakeTarget)target); writeTargets(projectTargets); notifyListeners(new MakeTargetEvent(this, MakeTargetEvent.TARGET_ADD, target)); - return target; } public void removeTarget(IMakeTarget target) throws CoreException { @@ -231,7 +237,7 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis } protected void writeTargets(ProjectTargets projectTargets) throws CoreException { - IPath targetFilePath = MakeCorePlugin.getDefault().getStateLocation().append(projectTargets.getProject().getName()); + IPath targetFilePath = MakeCorePlugin.getDefault().getStateLocation().append(projectTargets.getProject().getName()).addFileExtension(TARGETS_EXT); File targetFile = targetFilePath.toFile(); try { FileOutputStream file = new FileOutputStream(targetFile); @@ -244,15 +250,21 @@ public class MakeTargetManager implements IMakeTargetManager, IResourceChangeLis } protected ProjectTargets readTargets(IProject project) { - IPath targetFilePath = MakeCorePlugin.getDefault().getStateLocation().append(project.getName()); + IPath targetFilePath = MakeCorePlugin.getDefault().getStateLocation().append(project.getName()).addFileExtension(TARGETS_EXT); File targetFile = targetFilePath.toFile(); + ProjectTargets projectTargets = null; if (targetFile.exists()) { try { - return new ProjectTargets(project, new FileInputStream(targetFile)); + projectTargets = new ProjectTargets(this, project, new FileInputStream(targetFile)); } catch (FileNotFoundException e) { } } - return new ProjectTargets(project); + if ( projectTargets == null) { + projectTargets = new ProjectTargets(this, project); + } + projectMap.put(project, projectTargets); + return projectTargets; + } protected void initializeBuilders() { diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java index db5047b7391..d4db46f72e9 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/internal/core/ProjectTargets.java @@ -7,6 +7,8 @@ import java.io.OutputStreamWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; +import java.util.Map; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -31,19 +33,31 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; public class ProjectTargets { - private static String BUILD_TARGET_ELEMENT = "buildTargets"; //$NON-NLS-1$ - private static String TARGET_ELEMENT = "target"; //$NON-NLS-1$ + private static final String BUILD_TARGET_ELEMENT = "buildTargets"; //$NON-NLS-1$ + private static final String TARGET_ELEMENT = "target"; //$NON-NLS-1$ + private static final String TARGET_ATTR_ID = "targetID"; //$NON-NLS-1$ + private static final String TARGET_ATTR_PATH = "path"; + private static final String TARGET_ATTR_NAME = "name"; + private static final String TARGET_STOP_ON_ERROR = "stopOnError"; + private static final String TARGET_USE_DEFAULT_CMD = "useDefaultCommand"; + private static final String TARGET_ARGUMENTS = "buildArguments"; + private static final String TARGET_COMMAND ="buildCommand"; + private static final String TARGET = "buidlTarget"; + private HashMap targetMap = new HashMap(); - private IProject project; - public ProjectTargets(IProject project) { + private IProject project; + private MakeTargetManager manager; + + public ProjectTargets(MakeTargetManager manager, IProject project) { this.project = project; + this.manager = manager; } - public ProjectTargets(IProject project, InputStream input) { - this(project); - + public ProjectTargets(MakeTargetManager manager, IProject project, InputStream input) { + this(manager, project); + Document document = null; try { DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder(); @@ -59,29 +73,34 @@ public class ProjectTargets { if (node.getNodeName().equals(TARGET_ELEMENT)) { IContainer container = null; NamedNodeMap attr = node.getAttributes(); - String path = attr.getNamedItem("targetID").getNodeValue(); - if (path != null) { + String path = attr.getNamedItem(TARGET_ATTR_PATH).getNodeValue(); + if (path != null && !path.equals("")) { container = project.getFolder(path); } else { container = project; } - MakeTarget target = new MakeTarget(container, attr.getNamedItem("targetID").getNodeValue(), attr.getNamedItem("name").getNodeValue()); //$NON-NLS-1$ //$NON-NLS-2$ - String option = getString(node, "stopOnError"); + MakeTarget target = new MakeTarget(manager, attr.getNamedItem(TARGET_ATTR_ID).getNodeValue(), attr.getNamedItem(TARGET_ATTR_NAME).getNodeValue()); + target.setContainer(container); + String option = getString(node, TARGET_STOP_ON_ERROR); if (option != null) { target.setStopOnError(Boolean.valueOf(option).booleanValue()); } - option = getString(node, "useDefaultCommand"); + option = getString(node, TARGET_USE_DEFAULT_CMD); if (option != null) { target.setUseDefaultBuildCmd(Boolean.valueOf(option).booleanValue()); } - option = getString(node, "buildCommand"); + option = getString(node, TARGET_COMMAND); if (option != null) { target.setBuildCommand(new Path(option)); } - option = getString(node, "buildArguments"); + option = getString(node, TARGET_ARGUMENTS); if (option != null) { target.setBuildArguments(option); } + option = getString(node, TARGET); + if (option != null) { + target.setBuildTarget(option); + } try { add(target); } catch (CoreException e) { @@ -113,17 +132,17 @@ public class ProjectTargets { } return new IMakeTarget[0]; } - + public IMakeTarget findTarget(IContainer container, String name) { ArrayList list = (ArrayList) targetMap.get(container); if (list != null) { Iterator targets = list.iterator(); - while( targets.hasNext()) { - IMakeTarget target = (IMakeTarget)targets.next(); - if ( target.getName().equals(name) ) { + while (targets.hasNext()) { + IMakeTarget target = (IMakeTarget) targets.next(); + if (target.getName().equals(name)) { return target; } - } + } } return null; } @@ -165,11 +184,46 @@ public class ProjectTargets { protected Document getAsXML() throws IOException { Document doc = new DocumentImpl(); - Element configRootElement = doc.createElement(BUILD_TARGET_ELEMENT); - doc.appendChild(configRootElement); + Element targetsRootElement = doc.createElement(BUILD_TARGET_ELEMENT); + doc.appendChild(targetsRootElement); + Iterator container = targetMap.entrySet().iterator(); + while (container.hasNext()) { + List targets = (List) ((Map.Entry)container.next()).getValue(); + for (int i = 0; i < targets.size(); i++) { + MakeTarget target = (MakeTarget) targets.get(i); + targetsRootElement.appendChild(createTargetElement(doc, target)); + } + } return doc; } + private Node createTargetElement(Document doc, MakeTarget target) { + Element targetElem = doc.createElement(TARGET_ELEMENT); + targetElem.setAttribute(TARGET_ATTR_NAME, target.getName()); + targetElem.setAttribute(TARGET_ATTR_ID, target.getTargetBuilderID()); + targetElem.setAttribute(TARGET_ATTR_PATH, target.getContainer().getProjectRelativePath().toString()); + Element elem = doc.createElement(TARGET_COMMAND); + targetElem.appendChild(elem); + elem.appendChild(doc.createTextNode(target.getBuildCommand().toString())); + + elem = doc.createElement(TARGET_ARGUMENTS); + elem.appendChild(doc.createTextNode(target.getBuildArguments())); + targetElem.appendChild(elem); + + elem = doc.createElement(TARGET); + elem.appendChild(doc.createTextNode(target.getBuildTarget())); + targetElem.appendChild(elem); + + elem = doc.createElement(TARGET_STOP_ON_ERROR); + elem.appendChild(doc.createTextNode(new Boolean(target.isStopOnError()).toString())); + targetElem.appendChild(elem); + + elem = doc.createElement(TARGET_USE_DEFAULT_CMD); + elem.appendChild(doc.createTextNode(new Boolean(target.isDefaultBuildCmd()).toString())); + targetElem.appendChild(elem); + return targetElem; + } + public void saveTargets(OutputStream output) throws IOException { Document doc = getAsXML(); OutputFormat format = new OutputFormat(); diff --git a/build/org.eclipse.cdt.make.ui/icons/cview16/make.gif b/build/org.eclipse.cdt.make.ui/icons/cview16/make_target.gif similarity index 100% rename from build/org.eclipse.cdt.make.ui/icons/cview16/make.gif rename to build/org.eclipse.cdt.make.ui/icons/cview16/make_target.gif diff --git a/build/org.eclipse.cdt.make.ui/icons/obj16/error_obj.gif b/build/org.eclipse.cdt.make.ui/icons/obj16/error_obj.gif new file mode 100644 index 0000000000000000000000000000000000000000..b04020bc723a345d97f68c485286138159294b51 GIT binary patch literal 159 zcmZ?wbhEHb6krfw*v!E2zux{wgvI}O`yUn-_wDWX+uP5uu&B4U|G$6#{QCO;V8DO` z6o0ZXGB9v6=zzpPW-ze$6rA*2z1QM-NY$mI3PP=oty~H$UYV-Q4I0f&6XZpi*4R!^ xyPL3d!C$U+FAW1@CT-3`IR?znG}u@ZyB#DZi90XElaV`uD)&M;ZHrxOJ literal 0 HcmV?d00001 diff --git a/build/org.eclipse.cdt.make.ui/icons/obj16/target.gif b/build/org.eclipse.cdt.make.ui/icons/obj16/target_obj.gif similarity index 100% rename from build/org.eclipse.cdt.make.ui/icons/obj16/target.gif rename to build/org.eclipse.cdt.make.ui/icons/obj16/target_obj.gif diff --git a/build/org.eclipse.cdt.make.ui/plugin.properties b/build/org.eclipse.cdt.make.ui/plugin.properties index 8d5960be605..efb747d0d07 100644 --- a/build/org.eclipse.cdt.make.ui/plugin.properties +++ b/build/org.eclipse.cdt.make.ui/plugin.properties @@ -12,12 +12,10 @@ WizardConvertMakeProject.description=Convert a C/C++ Project to use a simple mak MenuMakeNew.label=Make Builds -ActionMakeBuildCreate.label=Build/Create Make Target... -ActionMakeAll.label=Make all -ActionMakeClean.label=Make clean -ActionMakeRebuild.label=Make rebuild -ActionMakeUpdate.label=Update Old Make Project... +ActionMakeCreateTarget.label=Create Make Target... +ActionMakeBuildTarget.label=Build Make Target... +ActionMakeUpdate.label=Update Old Make Project... CommandMakeBuildCreate.name=Build/Create Make Target CommandMakeBuildCreate.description=Build or create a new make build target @@ -28,4 +26,5 @@ PropertyMakeProject.name= C/C++ Make Project ViewCatagoryMake.name=Make ViewMake.name=Make Targets -ActionSetMake.label=Make Action Set \ No newline at end of file +ActionSetMake.label=Make Actions +ActionSetUpdateMake.label=Update Make Projects diff --git a/build/org.eclipse.cdt.make.ui/plugin.xml b/build/org.eclipse.cdt.make.ui/plugin.xml index c95b1bdcb45..1c0ac1a4fe1 100644 --- a/build/org.eclipse.cdt.make.ui/plugin.xml +++ b/build/org.eclipse.cdt.make.ui/plugin.xml @@ -77,11 +77,18 @@ adaptable="false" id="org.eclipse.cdt.make.ui.popupMenu.CViewContribution"> + id="org.eclipse.cdt.make.ui.CViewCreateTargetAction"> + + + id="org.eclipse.cdt.make.ui.NavigatorBuildTargetAction"> @@ -187,7 +195,7 @@ @@ -196,12 +204,48 @@ + id="org.eclipse.cdt.make.ui.UpdateMakeAction" + icon="icons/ctool16/update_old.gif" + toolbarPath="Normal" + tooltip="%ActionMakeUpdate.tooltip"> + + + + + + + + + + + + + + + + + + + + + diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties index a465e0eb806..cd4f46d4fa5 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeResources.properties @@ -41,6 +41,13 @@ SettingsBlock.makeWorkbench.auto=Build on resource save (Auto Build) SettingsBlock.makeWorkbench.incremental=Build (Incremental Build) SettingsBlock.makeWorkbench.full=Rebuild (Full Build) +TargetBlock.target.group_label=Target +TargetBlock.target.label=Target Name: + +BuildTarget.target.group_label=Build Target +BuildTarget.target.label=Build Target: + + # String constants for the build include path and preprocessor symbols BuildPathInfoBlock.label=Paths and Symbols BuildPathInfoBlock.paths=Include paths: diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeUIImages.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeUIImages.java index 81389b98bda..51abce8d538 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeUIImages.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MakeUIImages.java @@ -39,9 +39,13 @@ public class MakeUIImages { public static final String OBJ = "obj16/"; //$NON-NLS-1$ // For the build image - public static final String IMG_OBJS_BUILD_TARGET = NAME_PREFIX + "target.gif"; //$NON-NLS-1$ + public static final String IMG_OBJS_BUILD_TARGET = NAME_PREFIX + "target_obj.gif"; //$NON-NLS-1$ public static final ImageDescriptor DESC_BUILD_TARGET = createManaged(OBJ, IMG_OBJS_BUILD_TARGET); + public static final String IMG_OBJS_ERROR = NAME_PREFIX + "error_obj.gif"; + public static final ImageDescriptor DESC_OBJ_ERROR = createManaged(OBJ, IMG_OBJS_ERROR); + + public static final String IMG_TOOLS_MAKE_TARGET_BUILD = NAME_PREFIX + "target_build.gif"; //$NON-NLS-1$ public static final String IMG_TOOLS_MAKE_TARGET_ADD = NAME_PREFIX + "target_add.gif"; //$NON-NLS-1$ public static final String IMG_TOOLS_MAKE_TARGET_DELETE = NAME_PREFIX + "target_delete.gif"; //$NON-NLS-1$ diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MessageLine.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MessageLine.java new file mode 100644 index 00000000000..f839a812cc1 --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/internal/ui/MessageLine.java @@ -0,0 +1,61 @@ +package org.eclipse.cdt.make.internal.ui; + +/* + * (c) Copyright IBM Corp. 2000, 2001. + * All Rights Reserved. + */ + +import org.eclipse.jface.resource.JFaceColors; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.CLabel; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.widgets.Composite; + +/** + * A message line. It distinguishs between "normal" messages and errors. + * Setting an error message hides a currently displayed message until + * clearErrorMessage is called. + */ +public class MessageLine extends CLabel { + + private String fMessage; + + private Color fNormalMsgAreaBackground; + + /** + * Creates a new message line as a child of the given parent. + */ + public MessageLine(Composite parent) { + this(parent, SWT.LEFT); + } + + /** + * Creates a new message line as a child of the parent and with the given SWT stylebits. + */ + public MessageLine(Composite parent, int style) { + super(parent, style); + fNormalMsgAreaBackground= getBackground(); + } + + + /** + * Display the given error message. A currently displayed message + * is saved and will be redisplayed when the error message is cleared. + */ + public void setErrorMessage(String message) { + if (message != null && message.length() > 0) { + setText(message); + setImage(MakeUIImages.getImage(MakeUIImages.IMG_OBJS_ERROR)); + setBackground(JFaceColors.getErrorBackground(getDisplay())); + return; + } + setText(fMessage); + setImage(null); + setBackground(fNormalMsgAreaBackground); + } + + public void setMessage(String message) { + fMessage = message; + setText(message); + } +} 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/BuildTargetAction.java similarity index 92% rename from build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/CreateBuildAction.java rename to build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/BuildTargetAction.java index e8bd55e91f3..72fd36bca1c 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/BuildTargetAction.java @@ -25,7 +25,7 @@ import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindowActionDelegate; import org.eclipse.ui.actions.ActionDelegate; -public class CreateBuildAction extends ActionDelegate implements IObjectActionDelegate, IWorkbenchWindowActionDelegate { +public class BuildTargetAction extends ActionDelegate implements IObjectActionDelegate, IWorkbenchWindowActionDelegate { IWorkbenchPart fPart; IContainer fContainer; @@ -33,16 +33,15 @@ public class CreateBuildAction extends ActionDelegate implements IObjectActionDe public void run(IAction action) { 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); + dialog.setTarget(target); } catch (CoreException e) { } dialog.open(); - IMakeTarget target = dialog.getSelectedTarget(); + IMakeTarget target = dialog.getTarget(); if ( target != null ) { try { fContainer.setSessionProperty(new QualifiedName(MakeUIPlugin.getUniqueIdentifier(), "lastTarget"), target.getName()); diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/CreateTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/CreateTargetAction.java new file mode 100644 index 00000000000..198fba27bcd --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/actions/CreateTargetAction.java @@ -0,0 +1,59 @@ +/* + * Created on 25-Jul-2003 + * + * Copyright (c) 2002,2003 QNX Software Systems Ltd. + * + * Contributors: + * QNX Software Systems - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.make.ui.actions; + +import org.eclipse.cdt.core.model.ICContainer; +import org.eclipse.cdt.make.ui.dialogs.MakeTargetDialog; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IObjectActionDelegate; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; +import org.eclipse.ui.actions.ActionDelegate; + +public class CreateTargetAction extends ActionDelegate implements IObjectActionDelegate, IWorkbenchWindowActionDelegate { + + IWorkbenchPart fPart; + IContainer fContainer; + + public void run(IAction action) { + if ( fContainer != null ) { + MakeTargetDialog dialog; + try { + dialog = new MakeTargetDialog(fPart.getSite().getShell(), fContainer); + dialog.open(); + } catch (CoreException e) { + } + } + } + + public void setActivePart(IAction action, IWorkbenchPart targetPart) { + fPart = targetPart; + } + + public void init(IWorkbenchWindow window) { + } + + public void selectionChanged(IAction action, ISelection selection) { + if ( selection instanceof IStructuredSelection ) { + 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; + } + } + } +} 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/actions/TargetBuild.java index af699009de2..85735673642 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/actions/TargetBuild.java @@ -17,8 +17,10 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.operation.IRunnableContext; import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorReference; @@ -67,7 +69,16 @@ public class TargetBuild { } } - static public void run(boolean fork, IRunnableContext context, final IMakeTarget[] targets) { + static public void runWithProgressDialog(Shell shell, IMakeTarget[] targets) { + ProgressMonitorDialog pd = new ProgressMonitorDialog(shell); + try { + TargetBuild.run(true, pd, targets); + } catch (InvocationTargetException e) { + MakeUIPlugin.errorDialog(shell, "Target Build Error", "Error Building Target", e); + } + } + + static public void run(boolean fork, IRunnableContext context, final IMakeTarget[] targets) throws InvocationTargetException { try { context.run(fork, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { @@ -91,8 +102,6 @@ public class TargetBuild { }); } catch (InterruptedException e) { return; - } catch (InvocationTargetException e) { - MakeUIPlugin.logException(e, "Build Error", "Error Building Projects"); } } } 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 ea917244c7d..3d96520a777 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 @@ -1,159 +1,21 @@ package org.eclipse.cdt.make.ui.dialogs; -import java.util.HashMap; - -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.MakeCorePlugin; -import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; -import org.eclipse.cdt.utils.ui.controls.ControlFactory; -import org.eclipse.cdt.utils.ui.controls.RadioButtonsArea; import org.eclipse.core.resources.IContainer; -import org.eclipse.jface.dialogs.TitleAreaDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Listener; +import org.eclipse.jface.dialogs.Dialog; import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -public class BuildTargetDialog extends TitleAreaDialog { - private IMakeTarget fSelection; - public static int OPEN_MODE_BUILD = 1; - public static int OPEN_MODE_CREATE_NEW = 2; - public static int OPEN_MODE_RENAME = 2; - - private int openMode; - - private static final String PREFIX = "SettingsBlock"; //$NON-NLS-1$ - - private static final String MAKE_SETTING_GROUP = PREFIX + ".makeSetting.group_label"; //$NON-NLS-1$ - private static final String MAKE_SETTING_KEEP_GOING = PREFIX + ".makeSetting.keepOnGoing"; //$NON-NLS-1$ - private static final String MAKE_SETTING_STOP_ERROR = PREFIX + ".makeSetting.stopOnError"; //$NON-NLS-1$ - - private static final String MAKE_CMD_GROUP = PREFIX + ".makeCmd.group_label"; //$NON-NLS-1$ - private static final String MAKE_CMD_USE_DEFAULT = PREFIX + ".makeCmd.use_default"; //$NON-NLS-1$ - private static final String MAKE_CMD_LABEL = PREFIX + ".makeCmd.label"; //$NON-NLS-1$ - - private static final String KEEP_ARG = "keep"; //$NON-NLS-1$ - private static final String STOP_ARG = "stop"; //$NON-NLS-1$ - - RadioButtonsArea stopRadioButtons; - Text buildCommand; - Button defButton; - - IMakeBuilderInfo fBuildInfo; - IMakeTargetManager fTargetManager; - - /** - * @param parentShell - */ - public BuildTargetDialog(Shell parentShell, IContainer container) { - super(parentShell); - fTargetManager = MakeCorePlugin.getDefault().getTargetManager(); - String[] id = fTargetManager.getTargetBuilders(container.getProject()); - if (id.length > 0) { - fBuildInfo = MakeCorePlugin.createBuildInfo(new HashMap(), id[0]); - } +public class BuildTargetDialog extends Dialog { + + public BuildTargetDialog(Shell shell, IContainer fContainer) { + super(shell); } - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - Control control = super.createDialogArea(parent); - - createSettingControls(parent); - createBuildCmdControls(parent); - - return control; + public void setTarget(IMakeTarget target) { + } - protected void createSettingControls(Composite parent) { - String[][] radios = new String[][] { { MakeUIPlugin.getResourceString(MAKE_SETTING_STOP_ERROR), STOP_ARG }, { - MakeUIPlugin.getResourceString(MAKE_SETTING_KEEP_GOING), KEEP_ARG } - }; - stopRadioButtons = new RadioButtonsArea(parent, MakeUIPlugin.getResourceString(MAKE_SETTING_GROUP), 1, radios); - GridLayout layout = new GridLayout(); - layout.marginHeight = 0; - layout.marginWidth = 0; - stopRadioButtons.setLayout(layout); - if (fBuildInfo.isStopOnError()) - stopRadioButtons.setSelectValue(STOP_ARG); - else - stopRadioButtons.setSelectValue(KEEP_ARG); - } - - protected void createBuildCmdControls(Composite parent) { - Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_CMD_GROUP), 1); - GridLayout layout = new GridLayout(); - layout.numColumns = 2; - layout.makeColumnsEqualWidth = false; - layout.horizontalSpacing = 0; - group.setLayout(layout); - group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - defButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_CMD_USE_DEFAULT)); - defButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - if (defButton.getSelection() == true) { - buildCommand.setEnabled(false); - stopRadioButtons.setEnabled(true); - } else { - buildCommand.setEnabled(true); - stopRadioButtons.setEnabled(false); - } - } - }); - GridData gd = new GridData(GridData.FILL_HORIZONTAL); - gd.horizontalSpan = 2; - defButton.setLayoutData(gd); - Label label = ControlFactory.createLabel(group, MakeUIPlugin.getResourceString(MAKE_CMD_LABEL)); - ((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING; - ((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false; - buildCommand = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER); - ((GridData) (buildCommand.getLayoutData())).horizontalAlignment = GridData.FILL; - ((GridData) (buildCommand.getLayoutData())).grabExcessHorizontalSpace = true; - buildCommand.addListener(SWT.Modify, new Listener() { - public void handleEvent(Event e) { - } - }); - if (fBuildInfo.getBuildCommand() != null) { - StringBuffer cmd = new StringBuffer(fBuildInfo.getBuildCommand().toOSString()); - if (!fBuildInfo.isDefaultBuildCmd()) { - String args = fBuildInfo.getBuildArguments(); - if (args != null && !args.equals("")) { //$NON-NLS-1$ - cmd.append(" "); //$NON-NLS-1$ - cmd.append(args); - } - } - buildCommand.setText(cmd.toString()); - } - if (fBuildInfo.isDefaultBuildCmd()) { - buildCommand.setEnabled(false); - } else { - stopRadioButtons.setEnabled(false); - } - defButton.setSelection(fBuildInfo.isDefaultBuildCmd()); - } - - public void setOpenMode(int mode) { - openMode = mode; - } - - public void setSelectedTarget(IMakeTarget target) { - fSelection = target; - } - - public IMakeTarget getSelectedTarget() { + public IMakeTarget getTarget() { return null; } 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 new file mode 100644 index 00000000000..a0938924028 --- /dev/null +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/dialogs/MakeTargetDialog.java @@ -0,0 +1,348 @@ +/* + * Created on 22-Aug-2003 + * + * Copyright (c) 2002,2003 QNX Software Systems Ltd. + * + * Contributors: + * QNX Software Systems - Initial API and implementation +***********************************************************************/ +package org.eclipse.cdt.make.ui.dialogs; + +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.MakeCorePlugin; +import org.eclipse.cdt.make.internal.ui.*; +import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; +import org.eclipse.cdt.utils.ui.controls.ControlFactory; +import org.eclipse.cdt.utils.ui.controls.RadioButtonsArea; +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Status; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +public class MakeTargetDialog extends Dialog { + + private MessageLine fStatusLine; + private static final String TARGET_PREFIX = "TargetBlock"; //$NON-NLS-1$ + private static final String TARGET_NAME_LABEL = TARGET_PREFIX + ".target.label"; + + private static final String BUILD_ARGUMENT_PREFIX = "BuildTarget"; //$NON-NLS-1$ + private static final String BUILD_ARGUMENT_GROUP = BUILD_ARGUMENT_PREFIX + ".target.group_label"; + private static final String BUILD_ARGUMENT_LABEL = BUILD_ARGUMENT_PREFIX + ".target.label"; + + private static final String SETTING_PREFIX = "SettingsBlock"; //$NON-NLS-1$ + + private static final String MAKE_SETTING_GROUP = SETTING_PREFIX + ".makeSetting.group_label"; //$NON-NLS-1$ + private static final String MAKE_SETTING_KEEP_GOING = SETTING_PREFIX + ".makeSetting.keepOnGoing"; //$NON-NLS-1$ + private static final String MAKE_SETTING_STOP_ERROR = SETTING_PREFIX + ".makeSetting.stopOnError"; //$NON-NLS-1$ + + private static final String MAKE_CMD_GROUP = SETTING_PREFIX + ".makeCmd.group_label"; //$NON-NLS-1$ + private static final String MAKE_CMD_USE_DEFAULT = SETTING_PREFIX + ".makeCmd.use_default"; //$NON-NLS-1$ + private static final String MAKE_CMD_LABEL = SETTING_PREFIX + ".makeCmd.label"; //$NON-NLS-1$ + + private static final String KEEP_ARG = "keep"; //$NON-NLS-1$ + private static final String STOP_ARG = "stop"; //$NON-NLS-1$ + + Text targetNameText; + RadioButtonsArea stopRadioButtons; + Text commandText; + Button defButton; + Text targetText; + + IMakeTargetManager fTargetManager; + IContainer fContainer; + + private IPath buildCommand; + private boolean isDefaultCommand; + private boolean isStopOnError; + private String buildArguments; + private String targetString; + private String targetName; + private String targetBuildID; + private IMakeTarget fTarget; + + /** + * @param parentShell + */ + public MakeTargetDialog(Shell parentShell, IMakeTarget target) throws CoreException { + this(parentShell, target.getContainer()); + fTarget = target; + isStopOnError = target.isStopOnError(); + isDefaultCommand = target.isDefaultBuildCmd(); + buildCommand = target.getBuildCommand(); + buildArguments = target.getBuildArguments(); + targetName = target.getName(); + targetString = target.getBuildTarget(); + targetBuildID = target.getTargetBuilderID(); + } + + /** + * @param parentShell + */ + public MakeTargetDialog(Shell parentShell, IContainer container) throws CoreException { + super(parentShell); + fContainer = container; + fTargetManager = MakeCorePlugin.getDefault().getTargetManager(); + String[] id = fTargetManager.getTargetBuilders(container.getProject()); + if (id.length == 0) { + throw new CoreException( + new Status(IStatus.ERROR, MakeUIPlugin.getUniqueIdentifier(), -1, "Not target builders on the project", null)); + } + targetBuildID = id[0]; + IMakeBuilderInfo buildInfo = + MakeCorePlugin.createBuildInfo(container.getProject(), fTargetManager.getBuilderID(targetBuildID)); + isStopOnError = buildInfo.isStopOnError(); + isDefaultCommand = buildInfo.isDefaultBuildCmd(); + buildCommand = buildInfo.getBuildCommand(); + buildArguments = buildInfo.getBuildArguments(); + targetString = buildInfo.getIncrementalBuildTarget(); + targetName = ""; + } + + protected void configureShell(Shell newShell) { + String title; + if (fTarget == null) { + title = "Create Make target."; + } else { + title = "Modify Make target,"; + } + newShell.setText(title); + super.configureShell(newShell); + } + + /* (non-Javadoc) + * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) + */ + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + initializeDialogUnits(composite); + + String title; + if (fTarget == null) { + title = "Create a new Make target."; + } else { + title = "Modify a Make target,"; + } + + fStatusLine = new MessageLine(composite); + fStatusLine.setAlignment(SWT.LEFT); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.widthHint = convertWidthInCharsToPixels(50); + fStatusLine.setLayoutData(gd); + fStatusLine.setMessage(title); + + createNameControl(composite); + createSettingControls(composite); + createBuildCmdControls(composite); + createTargetControl(composite); + + return composite; + } + + protected void createNameControl(Composite parent) { + Composite composite = ControlFactory.createComposite(parent, 2); + ((GridLayout) composite.getLayout()).makeColumnsEqualWidth = false; + composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + Label label = ControlFactory.createLabel(composite, MakeUIPlugin.getResourceString(TARGET_NAME_LABEL)); + ((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING; + ((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false; + targetNameText = ControlFactory.createTextField(composite, SWT.SINGLE | SWT.BORDER); + ((GridData) (targetNameText.getLayoutData())).horizontalAlignment = GridData.FILL; + ((GridData) (targetNameText.getLayoutData())).grabExcessHorizontalSpace = true; + targetNameText.setText(targetName); + targetNameText.addListener(SWT.Modify, new Listener() { + public void handleEvent(Event e) { + String newName = targetNameText.getText().trim(); + if (newName.equals("")) { + fStatusLine.setErrorMessage("Must specify a target name."); + getButton(IDialogConstants.OK_ID).setEnabled(false); + } else if (fTarget != null + && fTarget.getName().equals(newName) + || fTargetManager.findTarget(fContainer, newName) == null) { + fStatusLine.setErrorMessage(null); + getButton(IDialogConstants.OK_ID).setEnabled(true); + } else { + fStatusLine.setErrorMessage("Target with that name already exits"); + getButton(IDialogConstants.OK_ID).setEnabled(false); + } + } + + }); + } + + protected void createSettingControls(Composite parent) { + String[][] radios = new String[][] { { MakeUIPlugin.getResourceString(MAKE_SETTING_STOP_ERROR), STOP_ARG }, { + MakeUIPlugin.getResourceString(MAKE_SETTING_KEEP_GOING), KEEP_ARG } + }; + stopRadioButtons = new RadioButtonsArea(parent, MakeUIPlugin.getResourceString(MAKE_SETTING_GROUP), 1, radios); + if (isStopOnError) + stopRadioButtons.setSelectValue(STOP_ARG); + else + stopRadioButtons.setSelectValue(KEEP_ARG); + } + + protected void createBuildCmdControls(Composite parent) { + Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(MAKE_CMD_GROUP), 1); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + layout.makeColumnsEqualWidth = false; + group.setLayout(layout); + group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + defButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_CMD_USE_DEFAULT)); + defButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + if (defButton.getSelection() == true) { + commandText.setEnabled(false); + stopRadioButtons.setEnabled(true); + } else { + commandText.setEnabled(true); + stopRadioButtons.setEnabled(false); + } + } + }); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = 2; + defButton.setLayoutData(gd); + Label label = ControlFactory.createLabel(group, MakeUIPlugin.getResourceString(MAKE_CMD_LABEL)); + ((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING; + ((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false; + commandText = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER); + ((GridData) (commandText.getLayoutData())).horizontalAlignment = GridData.FILL; + ((GridData) (commandText.getLayoutData())).grabExcessHorizontalSpace = true; + commandText.addListener(SWT.Modify, new Listener() { + public void handleEvent(Event e) { + if (commandText.getText().equals("")) { + fStatusLine.setErrorMessage("Must specify a build command"); + } + } + }); + if (buildCommand != null) { + StringBuffer cmd = new StringBuffer(buildCommand.toOSString()); + if (!isDefaultCommand) { + String args = buildArguments; + if (args != null && !args.equals("")) { //$NON-NLS-1$ + cmd.append(" "); //$NON-NLS-1$ + cmd.append(args); + } + } + commandText.setText(cmd.toString()); + } + if (isDefaultCommand) { + commandText.setEnabled(false); + } else { + stopRadioButtons.setEnabled(false); + } + defButton.setSelection(isDefaultCommand); + } + + private void createTargetControl(Composite parent) { + Group group = ControlFactory.createGroup(parent, MakeUIPlugin.getResourceString(BUILD_ARGUMENT_GROUP), 1); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + layout.makeColumnsEqualWidth = false; + group.setLayout(layout); + group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + Label label = ControlFactory.createLabel(group, MakeUIPlugin.getResourceString(BUILD_ARGUMENT_LABEL)); + ((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING; + ((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false; + targetText = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER); + ((GridData) (targetText.getLayoutData())).horizontalAlignment = GridData.FILL; + ((GridData) (targetText.getLayoutData())).grabExcessHorizontalSpace = true; + targetText.setText(targetString); + } + + protected void createButtonsForButtonBar(Composite parent) { + if (fTarget != null) { + createButton(parent, IDialogConstants.OK_ID, "Update", true); + } else { + createButton(parent, IDialogConstants.OK_ID, "Create", true); + } + createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); + } + + private boolean isStopOnError() { + return stopRadioButtons.getSelectedValue().equals(STOP_ARG); + } + + private boolean useDefaultBuildCmd() { + return defButton.getSelection(); + } + + private String getBuildLine() { + if (commandText != null) { + String cmd = commandText.getText(); + if (cmd != null) + return cmd.trim(); + } + return null; + } + + protected void okPressed() { + IMakeTarget target = fTarget; + if (fTarget == null) { + target = fTargetManager.createTarget(targetNameText.getText().trim(), targetBuildID); + } + + target.setStopOnError(isStopOnError()); + target.setUseDefaultBuildCmd(useDefaultBuildCmd()); + if (!useDefaultBuildCmd()) { + String bldLine = getBuildLine(); + int start = 0; + int end = -1; + if (!bldLine.startsWith("\"")) { //$NON-NLS-1$ + end = bldLine.indexOf(' '); + } else { + start = 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); + } + target.setBuildTarget(targetText.getText().trim()); + + if (fTarget == null) { + try { + fTargetManager.addTarget(fContainer, target); + } catch (CoreException e) { + MakeUIPlugin.errorDialog(getShell(), "Make Target Error", "Error adding target", e); + } + } else { + if (!target.getName().equals(targetNameText.getText().trim())) { + try { + fTargetManager.renameTarget(target, targetNameText.getText().trim()); + } catch (CoreException e) { + } + } + } + super.okPressed(); + } +} diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/AddTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/AddTargetAction.java index db72b23bc80..a80a1fa95c1 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/AddTargetAction.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/AddTargetAction.java @@ -8,9 +8,11 @@ package org.eclipse.cdt.make.ui.views; import java.util.List; import org.eclipse.cdt.make.internal.ui.MakeUIImages; -import org.eclipse.cdt.make.ui.dialogs.BuildTargetDialog; +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.IResource; +import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.actions.SelectionListenerAction; @@ -30,9 +32,12 @@ public class AddTargetAction extends SelectionListenerAction { public void run() { if (canAdd()) { - BuildTargetDialog dialog = new BuildTargetDialog(shell, (IContainer) getStructuredSelection().getFirstElement()); - dialog.setOpenMode(BuildTargetDialog.OPEN_MODE_CREATE_NEW); - dialog.open(); + try { + MakeTargetDialog dialog = new MakeTargetDialog(shell, (IContainer) getStructuredSelection().getFirstElement()); + dialog.open(); + } catch (CoreException e) { + MakeUIPlugin.errorDialog(shell, "Internal Error", "", e); + } } } 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 e407057fd51..c0f7ed43607 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 @@ -12,7 +12,6 @@ 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.core.resources.IResource; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.actions.SelectionListenerAction; @@ -32,9 +31,8 @@ public class BuildTargetAction extends SelectionListenerAction { public void run() { if (canBuild()) { - ProgressMonitorDialog pd = new ProgressMonitorDialog(shell); IMakeTarget[] targets = (IMakeTarget[]) getSelectedElements().toArray(new IMakeTarget[0]); - TargetBuild.run(true, pd, targets); + TargetBuild.runWithProgressDialog(shell, targets); } } diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java index cd9de094fcd..99d1aeb6dd7 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/DeleteTargetAction.java @@ -10,8 +10,12 @@ import java.util.Iterator; import java.util.List; 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.MakeUIImages; +import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Shell; @@ -46,7 +50,10 @@ public class DeleteTargetAction extends SelectionListenerAction { msg = MessageFormat.format("Are you sure you want to delete ''{0}''?", new Object[] { target.getName()}); } else { title = "Confirm Multiple Target Deletion"; - msg = MessageFormat.format("Are you sure you want to delete these {0} targets?", new Object[] { new Integer(targets.size())}); + msg = + MessageFormat.format( + "Are you sure you want to delete these {0} targets?", + new Object[] { new Integer(targets.size())}); } return MessageDialog.openQuestion(shell, title, msg); } @@ -54,12 +61,22 @@ public class DeleteTargetAction extends SelectionListenerAction { public void run() { if (canDelete() && confirmDelete() == false) return; + List targets = getTargetsToDelete(); + IMakeTargetManager manager = MakeCorePlugin.getDefault().getTargetManager(); + Iterator iter = targets.iterator(); + try { + while (iter.hasNext()) { + manager.removeTarget((IMakeTarget) iter.next()); + } + } catch (CoreException e) { + MakeUIPlugin.errorDialog(shell, "Target Remove Error", "Error deleting build target", e); + } } protected boolean updateSelection(IStructuredSelection selection) { - return super.updateSelection(selection) && canDelete(); + return super.updateSelection(selection) && canDelete(); } - + /** * @return */ diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/EditTargetAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/EditTargetAction.java index 9695fc08e56..60ab60fca52 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/EditTargetAction.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/EditTargetAction.java @@ -9,9 +9,10 @@ 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.dialogs.BuildTargetDialog; -import org.eclipse.core.resources.IContainer; +import org.eclipse.cdt.make.internal.ui.MakeUIPlugin; +import org.eclipse.cdt.make.ui.dialogs.MakeTargetDialog; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.actions.SelectionListenerAction; @@ -31,10 +32,13 @@ public class EditTargetAction extends SelectionListenerAction { public void run() { if (canRename()) { - BuildTargetDialog dialog = new BuildTargetDialog(shell, (IContainer) getStructuredSelection().getFirstElement()); - dialog.setOpenMode(BuildTargetDialog.OPEN_MODE_CREATE_NEW); - dialog.setSelectedTarget((IMakeTarget) getStructuredSelection().getFirstElement()); - dialog.open(); + MakeTargetDialog dialog; + try { + dialog = new MakeTargetDialog(shell, (IMakeTarget) getStructuredSelection().getFirstElement()); + dialog.open(); + } catch (CoreException e) { + MakeUIPlugin.errorDialog(shell, "Internal Error", "", e); + } } }