From 36fd016fbb9e85c31db77aad2bd2192e948e1777 Mon Sep 17 00:00:00 2001 From: David Inglis Date: Thu, 14 Aug 2003 02:11:07 +0000 Subject: [PATCH] update new make plugin --- .../cdt/make/core/BuildInfoFactory.java | 136 ++++++++-------- .../cdt/make/core/IMakeBuilderInfo.java | 24 +-- .../cdt/make/core/MakeBuildManager.java | 20 +-- .../eclipse/cdt/make/core/MakeCorePlugin.java | 18 ++- .../cdt/make/core/MakeProjectNature.java | 37 +++-- .../cdt/make/ui/BuildPathInfoBlock.java | 3 +- .../eclipse/cdt/make/ui/SettingsBlock.java | 151 ++++++++++++------ 7 files changed, 217 insertions(+), 172 deletions(-) diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/BuildInfoFactory.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/BuildInfoFactory.java index 6e4a03db559..f1a16272405 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/BuildInfoFactory.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/BuildInfoFactory.java @@ -25,32 +25,34 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Preferences; +import org.eclipse.core.runtime.Status; public class BuildInfoFactory { - public static final String PREFIX = MakeCorePlugin.getUniqueIdentifier(); + private static final String PREFIX = MakeCorePlugin.getUniqueIdentifier(); - public static final String BUILD_COMMAND = PREFIX + ".buildCommand"; - public static final String BUILD_LOCATION = PREFIX + ".buildLocation"; - public static final String STOP_ON_ERROR = PREFIX + ".stopOnError"; - public static final String USE_DEFAULT_BUILD_CMD = PREFIX + ".useDefaultBuildCmd"; - public static final String BUILD_TARGET_AUTO = PREFIX + ".autoBuildTarget"; - public static final String BUILD_TARGET_INCREMENTAL = PREFIX + ".incrementalBuildTarget"; - public static final String BUILD_TARGET_FULL = PREFIX + ".fullBuildTarget"; - public static final String BUILD_FULL_ENABLED = PREFIX + ".enableFullBuild"; - public static final String BUILD_INCREMENTAL_ENABLED = PREFIX + ".enabledIncrementalBuild"; - public static final String BUILD_AUTO_ENABLED = PREFIX + ".enableAutoBuild"; - public static final String BUILD_ARGUMENTS = PREFIX + ".buildArguments"; + private static final String BUILD_COMMAND = PREFIX + ".buildCommand"; + private static final String BUILD_LOCATION = PREFIX + ".buildLocation"; + private static final String STOP_ON_ERROR = PREFIX + ".stopOnError"; + private static final String USE_DEFAULT_BUILD_CMD = PREFIX + ".useDefaultBuildCmd"; + private static final String BUILD_TARGET_AUTO = PREFIX + ".autoBuildTarget"; + private static final String BUILD_TARGET_INCREMENTAL = PREFIX + ".incrementalBuildTarget"; + private static final String BUILD_TARGET_FULL = PREFIX + ".fullBuildTarget"; + private static final String BUILD_FULL_ENABLED = PREFIX + ".enableFullBuild"; + private static final String BUILD_INCREMENTAL_ENABLED = PREFIX + ".enabledIncrementalBuild"; + private static final String BUILD_AUTO_ENABLED = PREFIX + ".enableAutoBuild"; + private static final String BUILD_ARGUMENTS = PREFIX + ".buildArguments"; - public abstract static class Store implements IMakeBuilderInfo, IScannerInfo { + private abstract static class Store implements IMakeBuilderInfo, IScannerInfo { // List of include paths protected List pathList; protected List symbolList; - public void setUseDefaultBuildCmd(boolean on) { + public void setUseDefaultBuildCmd(boolean on) throws CoreException { putValue(USE_DEFAULT_BUILD_CMD, new Boolean(on).toString()); } @@ -61,7 +63,7 @@ public class BuildInfoFactory { return getBoolean(USE_DEFAULT_BUILD_CMD); } - public void setBuildCommand(IPath location) { + public void setBuildCommand(IPath location) throws CoreException { putValue(BUILD_COMMAND, location.toString()); } @@ -100,7 +102,7 @@ public class BuildInfoFactory { protected abstract String getBuilderID(); - public void setBuildLocation(IPath location) { + public void setBuildLocation(IPath location) throws CoreException { putValue(BUILD_LOCATION, location.toString()); } @@ -109,7 +111,7 @@ public class BuildInfoFactory { return new Path(location == null ? "" : location); } - public void setStopOnError(boolean enabled) { + public void setStopOnError(boolean enabled) throws CoreException { putValue(STOP_ON_ERROR, new Boolean(enabled).toString()); } @@ -117,7 +119,7 @@ public class BuildInfoFactory { return getBoolean(STOP_ON_ERROR); } - public void setAutoBuildTarget(String target) { + public void setAutoBuildTarget(String target) throws CoreException { putValue(BUILD_TARGET_AUTO, target); } @@ -125,7 +127,7 @@ public class BuildInfoFactory { return getString(BUILD_TARGET_AUTO); } - public void setIncrementalBuildTarget(String target) { + public void setIncrementalBuildTarget(String target) throws CoreException { putValue(BUILD_TARGET_INCREMENTAL, target); } @@ -133,7 +135,7 @@ public class BuildInfoFactory { return getString(BUILD_TARGET_INCREMENTAL); } - public void setFullBuildTarget(String target) { + public void setFullBuildTarget(String target) throws CoreException { putValue(BUILD_TARGET_FULL, target); } @@ -157,7 +159,7 @@ public class BuildInfoFactory { * @see org.eclipse.cdt.core.build.managed.IScannerInfo#getIncludePaths() */ public String[] getIncludePaths() { - return (String[]) getPathList().toArray(new String[getPathList().size()]); + return (String[])getPathList().toArray(new String[getPathList().size()]); } /* (non-Javadoc) @@ -194,7 +196,7 @@ public class BuildInfoFactory { } public String[] getPreprocessorSymbols() { - return (String[]) getSymbolList().toArray(new String[getSymbolList().size()]); + return (String[])getSymbolList().toArray(new String[getSymbolList().size()]); } protected List getSymbolList() { @@ -208,10 +210,10 @@ public class BuildInfoFactory { return Boolean.valueOf(getString(property)).booleanValue(); } - public abstract void putValue(String name, String value); + public abstract void putValue(String name, String value) throws CoreException; public abstract String getString(String property); - public void setAutoBuildEnable(boolean enabled) { + public void setAutoBuildEnable(boolean enabled) throws CoreException { putValue(BUILD_AUTO_ENABLED, new Boolean(enabled).toString()); } @@ -219,7 +221,7 @@ public class BuildInfoFactory { return getBoolean(BUILD_AUTO_ENABLED); } - public void setIncrementalBuildEnable(boolean enabled) { + public void setIncrementalBuildEnable(boolean enabled) throws CoreException { putValue(BUILD_INCREMENTAL_ENABLED, new Boolean(enabled).toString()); } @@ -227,7 +229,7 @@ public class BuildInfoFactory { return getBoolean(BUILD_INCREMENTAL_ENABLED); } - public void setFullBuildEnable(boolean enabled) { + public void setFullBuildEnable(boolean enabled) throws CoreException { putValue(BUILD_FULL_ENABLED, new Boolean(enabled).toString()); } @@ -239,65 +241,69 @@ public class BuildInfoFactory { return getString(BUILD_ARGUMENTS); } - public void setBuildArguments(String args) { + public void setBuildArguments(String args) throws CoreException { putValue(BUILD_ARGUMENTS, args); } } - public static class Preference extends Store { + private static class Preference extends Store { private Preferences prefs; private String builderID; + private boolean useDefaults; - public Preference(Preferences prefs, String builderID) { + public Preference(Preferences prefs, String builderID, boolean useDefaults) { this.prefs = prefs; this.builderID = builderID; + this.useDefaults = useDefaults; } public void putValue(String name, String value) { - prefs.setValue(name, value); + if (useDefaults) { + prefs.setDefault(name, value); + } else { + prefs.setValue(name, value); + } } public String getString(String property) { + if (useDefaults) { + return prefs.getDefaultString(property); + } return prefs.getString(property); } - public void setDefault(String name, String value) { - prefs.setDefault(name, value); - } - protected String getBuilderID() { return builderID; } } - public static class BuildProperty extends Store { + private static class BuildProperty extends Store { private IProject project; private String builderID; - - public BuildProperty(IProject project, String builderID) { + private Map args; + + public BuildProperty(IProject project, String builderID) throws CoreException { this.project = project; this.builderID = builderID; + ICommand builder; + builder = MakeProjectNature.getBuildSpec(project, builderID); + if (builder == null) { + throw new CoreException( + new Status(IStatus.ERROR, MakeCorePlugin.getUniqueIdentifier(), -1, "Missing Builder: " + builderID, null)); + } + args = builder.getArguments(); } - public void putValue(String name, String value) { - try { - ICommand builder = MakeProjectNature.getBuildSpec(project); - Map args = builder.getArguments(); - args.put(name, value); - builder.setArguments(args); - } catch (CoreException e) { - } + public void putValue(String name, String value) throws CoreException { + ICommand builder = MakeProjectNature.getBuildSpec(project, builderID); + args.put(name, value); + builder.setArguments(args); + project.setDescription(project.getDescription(), null); } public String getString(String name) { - ICommand builder; - try { - builder = MakeProjectNature.getBuildSpec(project); - Map args = builder.getArguments(); - return (String) args.get(name); - } catch (CoreException e) { - } - return null; + String value = (String)args.get(name); + return value == null ? "" : value; } public String getBuilderID() { @@ -305,7 +311,7 @@ public class BuildInfoFactory { } } - public static class BuildArguments extends Store { + private static class BuildArguments extends Store { private Map args; private String builderID; @@ -315,10 +321,11 @@ public class BuildInfoFactory { } public void putValue(String name, String value) { + args.put(name, value); } public String getString(String name) { - return (String) args.get(name); + return (String)args.get(name); } public String getBuilderID() { @@ -326,28 +333,15 @@ public class BuildInfoFactory { } } - public static IMakeBuilderInfo create(Preferences prefs, String builderID) { - return new BuildInfoFactory.Preference(prefs, builderID); + public static IMakeBuilderInfo create(Preferences prefs, String builderID, boolean useDefaults) { + return new BuildInfoFactory.Preference(prefs, builderID, useDefaults); } - public static IMakeBuilderInfo create(IProject project, String builderID) { + public static IMakeBuilderInfo create(IProject project, String builderID) throws CoreException { return new BuildInfoFactory.BuildProperty(project, builderID); } public static IMakeBuilderInfo create(Map args, String builderID) { return new BuildInfoFactory.BuildArguments(args, builderID); } - - public static void initializeDefaultPreferences(Preferences prefs) { - prefs.setDefault(BUILD_COMMAND, "make"); - prefs.setDefault(BUILD_LOCATION, ""); - prefs.setDefault(STOP_ON_ERROR, new Boolean(false).toString()); - prefs.setDefault(USE_DEFAULT_BUILD_CMD, new Boolean(true).toString()); - prefs.setDefault(BUILD_AUTO_ENABLED, new Boolean(false).toString()); - prefs.setDefault(BUILD_FULL_ENABLED, new Boolean(true).toString()); - prefs.setDefault(BUILD_INCREMENTAL_ENABLED, new Boolean(true).toString()); - prefs.setDefault(BUILD_TARGET_AUTO, "all"); - prefs.setDefault(BUILD_TARGET_INCREMENTAL, "all"); - prefs.setDefault(BUILD_TARGET_FULL, "clean all"); - } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeBuilderInfo.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeBuilderInfo.java index 2e8b0c55cb9..9da7225c182 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeBuilderInfo.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/IMakeBuilderInfo.java @@ -11,6 +11,7 @@ package org.eclipse.cdt.make.core; * IBM Rational Software - Initial API and implementation ***********************************************************************/ +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; public interface IMakeBuilderInfo { @@ -30,21 +31,20 @@ public interface IMakeBuilderInfo { public String[] getPreprocessorSymbols(); public String[] getIncludePaths(); - void setBuildLocation(IPath location); - void setStopOnError(boolean on); - void setUseDefaultBuildCmd(boolean on); - void setBuildCommand(IPath command); - void setBuildArguments(String args); + void setBuildLocation(IPath location) throws CoreException; + void setStopOnError(boolean on) throws CoreException; + void setUseDefaultBuildCmd(boolean on) throws CoreException; + void setBuildCommand(IPath command) throws CoreException; + void setBuildArguments(String args) throws CoreException; - void setAutoBuildEnable(boolean enabled); - void setAutoBuildTarget(String target); - void setIncrementalBuildEnable(boolean enabled); - void setIncrementalBuildTarget(String target); - void setFullBuildEnable(boolean enabled); - void setFullBuildTarget(String target); + void setAutoBuildEnable(boolean enabled) throws CoreException; + void setAutoBuildTarget(String target) throws CoreException; + void setIncrementalBuildEnable(boolean enabled) throws CoreException; + void setIncrementalBuildTarget(String target) throws CoreException; + void setFullBuildEnable(boolean enabled) throws CoreException; + void setFullBuildTarget(String target) throws CoreException; public void setPreprocessorSymbols(String[] symbols); public void setIncludePaths(String[] paths); - } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuildManager.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuildManager.java index a2b71d12567..6bd15bff3c4 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuildManager.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeBuildManager.java @@ -58,28 +58,17 @@ public class MakeBuildManager extends AbstractCExtension implements IScannerInfo private static IMakeBuilderInfo findBuildInfo(IResource resource, boolean create) throws CoreException { IMakeBuilderInfo buildInfo = null; // See if there's already one associated with the resource for this session - try { - buildInfo = (IMakeBuilderInfo)resource.getSessionProperty(buildInfoProperty); - } catch (CoreException e) { - } + buildInfo = (IMakeBuilderInfo)resource.getSessionProperty(buildInfoProperty); // Try to load one for the project if (buildInfo == null && resource instanceof IProject) { - try { - buildInfo = loadBuildInfo((IProject)resource); - } catch (CoreException e) { - } + buildInfo = loadBuildInfo((IProject)resource); } // There is nothing persisted for the session, or saved in a file so // create a build info object - if (buildInfo == null && create) { - buildInfo = BuildInfoFactory.create((IProject)resource, MakeBuilder.BUILDER_ID); - try { - ((IProject)resource).setSessionProperty(buildInfoProperty, buildInfo); - } catch (CoreException e) { - buildInfo = null; - } + if (buildInfo != null) { + ((IProject)resource).setSessionProperty(buildInfoProperty, buildInfo); } return buildInfo; } @@ -185,7 +174,6 @@ public class MakeBuildManager extends AbstractCExtension implements IScannerInfo } buildInfo.setIncludePaths((String[]) includes.toArray(new String[includes.size()])); buildInfo.setPreprocessorSymbols((String[]) symbols.toArray(new String[symbols.size()])); - project.setSessionProperty(buildInfoProperty, buildInfo); return buildInfo; } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeCorePlugin.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeCorePlugin.java index 4cf435fe31d..f9ca3f97734 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeCorePlugin.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeCorePlugin.java @@ -16,7 +16,9 @@ import java.util.MissingResourceException; import java.util.ResourceBundle; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPluginDescriptor; +import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Plugin; /** @@ -81,8 +83,22 @@ public class MakeCorePlugin extends Plugin { } return getDefault().getDescriptor().getUniqueIdentifier(); } + protected void initializeDefaultPluginPreferences() { - BuildInfoFactory.initializeDefaultPreferences(getPluginPreferences()); + IMakeBuilderInfo info = BuildInfoFactory.create(getPluginPreferences(), MakeBuilder.BUILDER_ID, true); + try { + info.setBuildCommand(new Path("make")); + info.setBuildLocation(new Path("")); + info.setStopOnError(false); + info.setUseDefaultBuildCmd(true); + info.setAutoBuildEnable(false); + info.setAutoBuildTarget("all"); + info.setIncrementalBuildEnable(true); + info.setIncrementalBuildTarget("all"); + info.setFullBuildEnable(true); + info.setFullBuildTarget("clean all"); + } catch (CoreException e) { + } getPluginPreferences().setDefault(CCorePlugin.PREF_BINARY_PARSER, CCorePlugin.PLUGIN_ID + ".ELF"); } } diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeProjectNature.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeProjectNature.java index 30414f428cc..9894389ecbb 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeProjectNature.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeProjectNature.java @@ -39,21 +39,17 @@ public class MakeProjectNature implements IProjectNature { project.setDescription(description, monitor); } - public static ICommand getBuildSpec(IProject project) throws CoreException { + public static ICommand getBuildSpec(IProject project, String builderID) throws CoreException { IProjectDescription description = project.getDescription(); ICommand[] commands = description.getBuildSpec(); for (int i = 0; i < commands.length; ++i) { - if (commands[i].getBuilderName().equals(MakeBuilder.BUILDER_ID)) { + if (commands[i].getBuilderName().equals(builderID)) { return commands[i]; } } return null; } - public void addToBuildSpec(String builderID, IProgressMonitor mon) throws CoreException { - addToBuildSpec(getProject(), builderID, mon); - } - /** * Adds a builder to the build spec for the given project. */ @@ -79,15 +75,11 @@ public class MakeProjectNature implements IProjectNature { } } - public void removeBuildSpec(IProgressMonitor mon) throws CoreException { - removeFromBuildSpec(MakeBuilder.BUILDER_ID, mon); - } - /** * Removes the given builder from the build spec for the given project. */ - public void removeFromBuildSpec(String builderID, IProgressMonitor mon) throws CoreException { - IProjectDescription description = getProject().getDescription(); + public static void removeFromBuildSpec(IProject project, String builderID, IProgressMonitor mon) throws CoreException { + IProjectDescription description = project.getDescription(); ICommand[] commands = description.getBuildSpec(); for (int i = 0; i < commands.length; ++i) { if (commands[i].getBuilderName().equals(builderID)) { @@ -98,15 +90,19 @@ public class MakeProjectNature implements IProjectNature { break; } } - getProject().setDescription(description, mon); + project.setDescription(description, mon); + } + + public void addBuildSpec() throws CoreException { + addToBuildSpec(getProject(), MakeBuilder.BUILDER_ID, null); } /** * @see IProjectNature#configure */ public void configure() throws CoreException { - addToBuildSpec(MakeBuilder.BUILDER_ID, null); - IMakeBuilderInfo info = BuildInfoFactory.create(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID); + addBuildSpec(); + IMakeBuilderInfo info = BuildInfoFactory.create(MakeCorePlugin.getDefault().getPluginPreferences(), MakeBuilder.BUILDER_ID, false); fBuildInfo.setBuildLocation(info.getBuildLocation()); @@ -124,11 +120,15 @@ public class MakeProjectNature implements IProjectNature { fBuildInfo.setFullBuildTarget(info.getFullBuildTarget()); } + public void removeBuildSpec() throws CoreException { + removeFromBuildSpec(getProject(), MakeBuilder.BUILDER_ID, null); + } + /** - * @see IProjectNature#deconfigure - */ + * @see IProjectNature#deconfigure + */ public void deconfigure() throws CoreException { - removeFromBuildSpec(MakeBuilder.BUILDER_ID, null); + removeBuildSpec(); } /** @@ -148,5 +148,4 @@ public class MakeProjectNature implements IProjectNature { } catch (CoreException e) { } } - } diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/BuildPathInfoBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/BuildPathInfoBlock.java index df5822f3f0e..bb7fd9c7572 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/BuildPathInfoBlock.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/BuildPathInfoBlock.java @@ -268,6 +268,7 @@ public class BuildPathInfoBlock extends AbstractCOptionPage { if (getContainer().getProject() != null) { // dinglis-TODO: set list to preference settings } + getContainer().updateContainer(); } /* @@ -363,8 +364,6 @@ public class BuildPathInfoBlock extends AbstractCOptionPage { * @see org.eclipse.cdt.ui.wizards.IWizardTab#getControl(org.eclipse.swt.widgets.Composite) */ public void createControl(Composite parent) { - this.shell = parent.getShell(); - // Create the composite control for the tab int tabColumns = 3; Font font = parent.getFont(); diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/SettingsBlock.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/SettingsBlock.java index 610a2c376d5..7eb06475004 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/SettingsBlock.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/SettingsBlock.java @@ -21,7 +21,6 @@ import org.eclipse.core.runtime.Preferences; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -31,6 +30,7 @@ import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.ContainerSelectionDialog; public class SettingsBlock extends AbstractCOptionPage { @@ -60,22 +60,22 @@ public class SettingsBlock extends AbstractCOptionPage { private static final String KEEP_ARG = "keep"; //$NON-NLS-1$ private static final String STOP_ARG = "stop"; //$NON-NLS-1$ - protected RadioButtonsArea stopRadioButtons; - protected Button defButton; - protected Text cmdText; - protected Text makeDirText; + private RadioButtonsArea stopRadioButtons; + private Button defButton; + private Text buildCommand; + private Text buildLocation; private Text targetFull; private Text targetIncr; private Text targetAuto; - private Button fFullButton; - private Button fIncrButton; - private Button fAutoButton; + private Button fullButton; + private Button incrButton; + private Button autoButton; private IMakeBuilderInfo fBuildInfo; private Preferences fPrefs; private String fBuilderID; - + public SettingsBlock(Preferences prefs, String builderID) { super(MakeUIPlugin.getResourceString(MAKE_LABEL)); setDescription(MakeUIPlugin.getResourceString(MAKE_MESSAGE)); @@ -110,11 +110,11 @@ public class SettingsBlock extends AbstractCOptionPage { defButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { if (defButton.getSelection() == true) { - cmdText.setEnabled(false); + buildCommand.setEnabled(false); stopRadioButtons.setEnabled(true); getContainer().updateContainer(); } else { - cmdText.setEnabled(true); + buildCommand.setEnabled(true); stopRadioButtons.setEnabled(false); getContainer().updateContainer(); } @@ -126,25 +126,27 @@ public class SettingsBlock extends AbstractCOptionPage { Label label = ControlFactory.createLabel(group, MakeUIPlugin.getResourceString(MAKE_CMD_LABEL)); ((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING; ((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false; - cmdText = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER); - ((GridData) (cmdText.getLayoutData())).horizontalAlignment = GridData.FILL; - ((GridData) (cmdText.getLayoutData())).grabExcessHorizontalSpace = true; - cmdText.addListener(SWT.Modify, new Listener() { + 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) { getContainer().updateContainer(); } }); if (fBuildInfo.getBuildCommand() != null) { StringBuffer cmd = new StringBuffer(fBuildInfo.getBuildCommand().toOSString()); - String args = fBuildInfo.getBuildArguments(); - if ( args != null && !args.equals("")) { - cmd.append(" "); - cmd.append(args); + if (!fBuildInfo.isDefaultBuildCmd()) { + String args = fBuildInfo.getBuildArguments(); + if (args != null && !args.equals("")) { + cmd.append(" "); + cmd.append(args); + } } - cmdText.setText(cmd.toString()); + buildCommand.setText(cmd.toString()); } if (fBuildInfo.isDefaultBuildCmd()) { - cmdText.setEnabled(false); + buildCommand.setEnabled(false); } else { stopRadioButtons.setEnabled(false); } @@ -154,9 +156,9 @@ public class SettingsBlock extends AbstractCOptionPage { protected void createWorkBenchBuildControls(Composite parent) { SelectionAdapter selectionAdapter = new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { - targetAuto.setEnabled(fAutoButton.getSelection()); - targetFull.setEnabled(fFullButton.getSelection()); - targetIncr.setEnabled(fIncrButton.getSelection()); + targetAuto.setEnabled(autoButton.getSelection()); + targetFull.setEnabled(fullButton.getSelection()); + targetIncr.setEnabled(incrButton.getSelection()); getContainer().updateContainer(); } @@ -171,23 +173,23 @@ public class SettingsBlock extends AbstractCOptionPage { label.setText(MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_TYPE)); label = new Label(group, SWT.NONE); label.setText(MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_TARGET)); - fAutoButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_AUTO)); - fAutoButton.addSelectionListener(selectionAdapter); - fAutoButton.setSelection(fBuildInfo.isAutoBuildEnable()); + autoButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_AUTO)); + autoButton.addSelectionListener(selectionAdapter); + autoButton.setSelection(fBuildInfo.isAutoBuildEnable()); targetAuto = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER); targetAuto.setText(fBuildInfo.getAutoBuildTarget()); ((GridData) (targetAuto.getLayoutData())).horizontalAlignment = GridData.FILL; ((GridData) (targetAuto.getLayoutData())).grabExcessHorizontalSpace = true; - fIncrButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_INCR)); - fIncrButton.addSelectionListener(selectionAdapter); - fIncrButton.setSelection(fBuildInfo.isIncrementalBuildEnabled()); + incrButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_INCR)); + incrButton.addSelectionListener(selectionAdapter); + incrButton.setSelection(fBuildInfo.isIncrementalBuildEnabled()); targetIncr = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER); targetIncr.setText(fBuildInfo.getIncrementalBuildTarget()); ((GridData) (targetIncr.getLayoutData())).horizontalAlignment = GridData.FILL; ((GridData) (targetIncr.getLayoutData())).grabExcessHorizontalSpace = true; - fFullButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_FULL)); - fFullButton.addSelectionListener(selectionAdapter); - fFullButton.setSelection(fBuildInfo.isFullBuildEnabled()); + fullButton = ControlFactory.createCheckBox(group, MakeUIPlugin.getResourceString(MAKE_WORKBENCH_BUILD_FULL)); + fullButton.addSelectionListener(selectionAdapter); + fullButton.setSelection(fBuildInfo.isFullBuildEnabled()); targetFull = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER); targetFull.setText(fBuildInfo.getFullBuildTarget()); ((GridData) (targetFull.getLayoutData())).horizontalAlignment = GridData.FILL; @@ -205,28 +207,38 @@ public class SettingsBlock extends AbstractCOptionPage { Label label = ControlFactory.createLabel(group, MakeUIPlugin.getResourceString(MAKE_BUILD_DIR_LABEL)); ((GridData) (label.getLayoutData())).horizontalAlignment = GridData.BEGINNING; ((GridData) (label.getLayoutData())).grabExcessHorizontalSpace = false; - makeDirText = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER); - ((GridData) (makeDirText.getLayoutData())).horizontalAlignment = GridData.FILL; - ((GridData) (makeDirText.getLayoutData())).grabExcessHorizontalSpace = true; - makeDirText.addListener(SWT.Modify, new Listener() { + buildLocation = ControlFactory.createTextField(group, SWT.SINGLE | SWT.BORDER); + ((GridData) (buildLocation.getLayoutData())).horizontalAlignment = GridData.FILL; + ((GridData) (buildLocation.getLayoutData())).grabExcessHorizontalSpace = true; + buildLocation.addListener(SWT.Modify, new Listener() { public void handleEvent(Event e) { getContainer().updateContainer(); } }); Button browse = new Button(group, SWT.NONE); browse.setText(MakeUIPlugin.getResourceString(MAKE_BUILD_DIR_BROWSE)); - browse.addSelectionListener(new SelectionListener() { - public void widgetDefaultSelected(SelectionEvent e) { - } + browse.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { + ContainerSelectionDialog dialog = + new ContainerSelectionDialog(getShell(), getContainer().getProject(), false, null); + dialog.open(); + Object[] result = dialog.getResult(); + } }); - makeDirText.setText(fBuildInfo.getBuildLocation().toOSString()); + buildLocation.setText(fBuildInfo.getBuildLocation().toOSString()); } public void createControl(Composite parent) { Composite composite = ControlFactory.createComposite(parent, 1); + setControl(composite); + if (fBuildInfo == null) { + ControlFactory.createEmptySpace(composite); + ControlFactory.createLabel(composite, "Missing builder information on project."); + return; + } + createSettingControls(composite); createBuildCmdControls(composite); createWorkBenchBuildControls(composite); @@ -234,12 +246,10 @@ public class SettingsBlock extends AbstractCOptionPage { if (getContainer().getProject() != null) { createBuilderWorkingDirControls(composite); } - - setControl(composite); } public boolean isValid() { - if (defButton.getSelection() != true) { + if (defButton != null && defButton.getSelection() != true) { String cmd = getBuildLine(); if (cmd == null || cmd.length() == 0) { return false; @@ -257,7 +267,7 @@ public class SettingsBlock extends AbstractCOptionPage { if (getContainer().getProject() != null) { info = BuildInfoFactory.create(getContainer().getProject(), fBuilderID); } else { - info = BuildInfoFactory.create(fPrefs, fBuilderID); + info = BuildInfoFactory.create(fPrefs, fBuilderID, false); } info.setStopOnError(isStopOnError()); info.setUseDefaultBuildCmd(useDefaultBuildCmd()); @@ -284,13 +294,49 @@ public class SettingsBlock extends AbstractCOptionPage { } info.setBuildArguments(args); } + info.setAutoBuildEnable(autoButton.getSelection()); + info.setAutoBuildTarget(targetAuto.getText().trim()); + info.setIncrementalBuildEnable(incrButton.getSelection()); + info.setIncrementalBuildTarget(targetIncr.getText().trim()); + info.setFullBuildEnable(fullButton.getSelection()); + info.setFullBuildTarget(targetFull.getText().trim()); + info.setBuildLocation(new Path(buildLocation.getText().trim())); } public void performDefaults() { + IMakeBuilderInfo info; if (getContainer().getProject() != null) { + info = BuildInfoFactory.create(fPrefs, fBuilderID, false); } else { - + info = BuildInfoFactory.create(fPrefs, fBuilderID, true); } + if (info.isStopOnError()) + stopRadioButtons.setSelectValue(STOP_ARG); + else + stopRadioButtons.setSelectValue(KEEP_ARG); + if (info.getBuildCommand() != null) { + StringBuffer cmd = new StringBuffer(info.getBuildCommand().toOSString()); + if (!info.isDefaultBuildCmd()) { + String args = info.getBuildArguments(); + if (args != null && !args.equals("")) { + cmd.append(" "); + cmd.append(args); + } + } + buildCommand.setText(cmd.toString()); + } + if (info.isDefaultBuildCmd()) { + buildCommand.setEnabled(false); + } else { + stopRadioButtons.setEnabled(false); + } + defButton.setSelection(info.isDefaultBuildCmd()); + autoButton.setSelection(info.isAutoBuildEnable()); + targetAuto.setText(info.getAutoBuildTarget()); + incrButton.setSelection(info.isIncrementalBuildEnabled()); + targetIncr.setText(info.getIncrementalBuildTarget()); + fullButton.setSelection(info.isFullBuildEnabled()); + targetFull.setText(info.getFullBuildTarget()); } private boolean isStopOnError() { @@ -302,8 +348,8 @@ public class SettingsBlock extends AbstractCOptionPage { } private String getBuildLine() { - if (cmdText != null) { - String cmd = cmdText.getText(); + if (buildCommand != null) { + String cmd = buildCommand.getText(); if (cmd != null) return cmd.trim(); } @@ -313,14 +359,17 @@ public class SettingsBlock extends AbstractCOptionPage { public void setContainer(ICOptionContainer container) { super.setContainer(container); if (getContainer().getProject() != null) { - fBuildInfo = BuildInfoFactory.create(getContainer().getProject(), fBuilderID); + try { + fBuildInfo = BuildInfoFactory.create(getContainer().getProject(), fBuilderID); + } catch (CoreException e) { + } } else { - fBuildInfo = BuildInfoFactory.create(fPrefs, fBuilderID); + fBuildInfo = BuildInfoFactory.create(fPrefs, fBuilderID, false); } } public String getErrorMessage() { - if (defButton.getSelection() != true) { + if (!useDefaultBuildCmd()) { String cmd = getBuildLine(); if (cmd == null || cmd.length() == 0) { return "Must enter a build command";