mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
update
This commit is contained in:
parent
d3c32bb369
commit
cc174bfe8c
22 changed files with 736 additions and 230 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -24,7 +25,8 @@ public interface IMakeTargetManager {
|
|||
|
||||
IProject[] getTargetBuilderProjects() throws CoreException;
|
||||
|
||||
String getBuilderID(String targetBuilderID);
|
||||
String getBuilderID(String targetID);
|
||||
|
||||
String[] getTargetBuilders(IProject project);
|
||||
|
||||
void addListener(IMakeTargetListener listener);
|
||||
|
|
|
@ -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;
|
||||
private MakeTargetManager manager;
|
||||
|
||||
MakeTarget(IContainer container, String targetBuilderID, String name) {
|
||||
this.container = container;
|
||||
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);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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,18 +33,30 @@ 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 {
|
||||
|
@ -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) {
|
||||
|
@ -118,9 +137,9 @@ public class ProjectTargets {
|
|||
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;
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
|
Before Width: | Height: | Size: 161 B After Width: | Height: | Size: 161 B |
BIN
build/org.eclipse.cdt.make.ui/icons/obj16/error_obj.gif
Normal file
BIN
build/org.eclipse.cdt.make.ui/icons/obj16/error_obj.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 159 B |
Before Width: | Height: | Size: 161 B After Width: | Height: | Size: 161 B |
|
@ -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
|
||||
ActionSetMake.label=Make Actions
|
||||
ActionSetUpdateMake.label=Update Make Projects
|
||||
|
|
|
@ -77,11 +77,18 @@
|
|||
adaptable="false"
|
||||
id="org.eclipse.cdt.make.ui.popupMenu.CViewContribution">
|
||||
<action
|
||||
label="%ActionMakeBuildCreate.label"
|
||||
class="org.eclipse.cdt.make.ui.actions.CreateBuildAction"
|
||||
label="%ActionMakeCreateTarget.label"
|
||||
class="org.eclipse.cdt.make.ui.actions.CreateTargetAction"
|
||||
menubarPath="buildGroup"
|
||||
enablesFor="1"
|
||||
id="org.eclipse.cdt.make.ui.CViewCreateBuildAction">
|
||||
id="org.eclipse.cdt.make.ui.CViewCreateTargetAction">
|
||||
</action>
|
||||
<action
|
||||
label="%ActionMakeBuildTarget.label"
|
||||
class="org.eclipse.cdt.make.ui.actions.BuildTargetAction"
|
||||
menubarPath="buildGroup"
|
||||
enablesFor="1"
|
||||
id="org.eclipse.cdt.make.ui.CViewBuildTargetAction">
|
||||
</action>
|
||||
<filter
|
||||
name="projectNature"
|
||||
|
@ -93,11 +100,11 @@
|
|||
adaptable="false"
|
||||
id="org.eclipse.cdt.make.ui.popupMenu.NavigatorContribution">
|
||||
<action
|
||||
label="%ActionMakeBuildCreate.label"
|
||||
class="org.eclipse.cdt.make.ui.actions.CreateBuildAction"
|
||||
label="%ActionMakeBuildTarget.label"
|
||||
class="org.eclipse.cdt.make.ui.actions.BuildTargetAction"
|
||||
menubarPath="additions"
|
||||
enablesFor="1"
|
||||
id="org.eclipse.cdt.make.ui.NavigatorCreateBuildAction">
|
||||
id="org.eclipse.cdt.make.ui.NavigatorBuildTargetAction">
|
||||
</action>
|
||||
<filter
|
||||
name="projectNature"
|
||||
|
@ -144,6 +151,7 @@
|
|||
label="%ActionMakeUpdate.label"
|
||||
class="org.eclipse.cdt.make.ui.actions.UpdateMakeProjectAction"
|
||||
enablesFor="+"
|
||||
icon="icons/ctool16/update_old.gif"
|
||||
id="org.eclipse.cdt.make.ui.UpdateProjectMakeAction">
|
||||
</action>
|
||||
</objectContribution>
|
||||
|
@ -187,7 +195,7 @@
|
|||
</category>
|
||||
<view
|
||||
name="%ViewMake.name"
|
||||
icon="icons/cview16/make.gif"
|
||||
icon="icons/cview16/make_target.gif"
|
||||
category="org.eclipse.cdt.make.ui"
|
||||
class="org.eclipse.cdt.make.ui.views.MakeView"
|
||||
id="org.eclipse.cdt.make.ui.views.MakeView">
|
||||
|
@ -196,12 +204,48 @@
|
|||
<extension
|
||||
point="org.eclipse.ui.actionSets">
|
||||
<actionSet
|
||||
label="%ActionUpdateActionSet.label"
|
||||
label="%ActionSetUpdateMake.label"
|
||||
id="org.eclipse.cdt.make.ui.updateActionSet">
|
||||
<action
|
||||
label="org.eclipse.cdt.make.ui.action1"
|
||||
label="%ActionMakeUpdate.label"
|
||||
class="org.eclipse.cdt.make.ui.actions.UpdateMakeProjectAction"
|
||||
id="org.eclipse.cdt.make.ui.action1">
|
||||
id="org.eclipse.cdt.make.ui.UpdateMakeAction"
|
||||
icon="icons/ctool16/update_old.gif"
|
||||
toolbarPath="Normal"
|
||||
tooltip="%ActionMakeUpdate.tooltip">
|
||||
<enablement>
|
||||
<and>
|
||||
<not>
|
||||
<objectState
|
||||
name="nature"
|
||||
value="org.eclipse.cdt.make.core.makeNature">
|
||||
</objectState>
|
||||
</not>
|
||||
<objectState
|
||||
name="nature"
|
||||
value="org.eclipse.cdt.core.cnature">
|
||||
</objectState>
|
||||
<or>
|
||||
<objectState
|
||||
name="projectPersistentProperty"
|
||||
value="org.eclipse.cdt.core.buildLocation">
|
||||
</objectState>
|
||||
<objectState
|
||||
name="projectPersistentProperty"
|
||||
value="org.eclipse.cdt.core.buildFullArguments">
|
||||
</objectState>
|
||||
<objectState
|
||||
name="projectPersistentProperty"
|
||||
value="org.eclipse.cdt.core.buildIncrementalArguments">
|
||||
</objectState>
|
||||
<objectState
|
||||
name="projectPersistentProperty"
|
||||
value="org.eclipse.cdt.make.goals">
|
||||
</objectState>
|
||||
</or>
|
||||
</and>
|
||||
</enablement>
|
||||
|
||||
</action>
|
||||
</actionSet>
|
||||
</extension>
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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$
|
||||
|
|
|
@ -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
|
||||
* <code>clearErrorMessage</code> 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);
|
||||
}
|
||||
}
|
|
@ -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());
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
public class BuildTargetDialog extends Dialog {
|
||||
|
||||
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 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);
|
||||
public void setTarget(IMakeTarget target) {
|
||||
|
||||
createSettingControls(parent);
|
||||
createBuildCmdControls(parent);
|
||||
|
||||
return control;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -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);
|
||||
try {
|
||||
MakeTargetDialog dialog = new MakeTargetDialog(shell, (IContainer) getStructuredSelection().getFirstElement());
|
||||
dialog.open();
|
||||
} catch (CoreException e) {
|
||||
MakeUIPlugin.errorDialog(shell, "Internal Error", "", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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,6 +61,16 @@ 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) {
|
||||
|
|
|
@ -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());
|
||||
MakeTargetDialog dialog;
|
||||
try {
|
||||
dialog = new MakeTargetDialog(shell, (IMakeTarget) getStructuredSelection().getFirstElement());
|
||||
dialog.open();
|
||||
} catch (CoreException e) {
|
||||
MakeUIPlugin.errorDialog(shell, "Internal Error", "", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue