diff --git a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml index fb64d78ff7e..063efe8fda2 100644 --- a/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.core.tests/plugin.xml @@ -355,6 +355,7 @@ + + + + The configuration that this configuration was cloned from. + + + diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedProject.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedProject.java index 1beb1aa3754..acaf5b57d38 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedProject.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/IManagedProject.java @@ -130,6 +130,21 @@ public interface IManagedProject extends IBuildObject { */ public void setDirty(boolean isDirty); + /** + * Returns true if this project is valid + * else false. + * + * @return boolean + */ + public boolean isValid(); + + /** + * Sets the element's "Valid" flag. + * + * @param isValid + */ + public void setValid(boolean isValid); + /** * Persist the managed project to the project file (.cdtbuild). * diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java index ab6c6ed8830..5f4bde0faeb 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/core/ManagedBuildManager.java @@ -1135,6 +1135,10 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI // This is a 1.2 manifest and we are compatible for now return true; } else { + // isCompatibleWith will return FALSE, if: + // o The major versions are not equal + // o The major versions are equal, but the remainder of the manifest version # is + // greater than the MBS version # return(buildInfoVersion.isCompatibleWith(version)); } } @@ -1184,8 +1188,12 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI // Make sure that the version is compatible with the manager fileVersion = rootElement.getNodeValue(); PluginVersionIdentifier version = new PluginVersionIdentifier(fileVersion); + // isCompatibleWith will return FALSE, if: + // o The major versions are not equal + // o The major versions are equal, but the remainder of the .cdtbuild version # is + // greater than the MBS version # if (!buildInfoVersion.isCompatibleWith(version)) { - throw new BuildException(ManagedMakeMessages.getResourceString(PROJECT_VERSION_ERROR)); + throw new BuildException(ManagedMakeMessages.getFormattedString(PROJECT_VERSION_ERROR, project.getName())); } if (buildInfoVersion.isGreaterThan(version)) { // TODO Upgrade the project @@ -1207,6 +1215,11 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI throw e; } } + if (buildInfo.getManagedProject() == null || + (!buildInfo.getManagedProject().isValid())) { + // The load failed + throw new Exception(ManagedMakeMessages.getFormattedString("ManagedBuildManager.error.id.nomatch", project.getName())); + } project.setSessionProperty(buildInfoProperty, buildInfo); } } catch (Exception e) { @@ -1245,18 +1258,34 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI IExtension extension = extensions[i]; // Can we read this manifest if (!isVersionCompatible(extension)) { - //The version of the Plug-in is greater than what the manager thinks it understands - throw new BuildException(ManagedMakeMessages.getResourceString(MANIFEST_VERSION_ERROR)); - } - // Get the "configuraton elements" defined in the plugin.xml file. - // Note that these "configuration elements" are not related to the - // managed build system "configurations". - // From the PDE Guide: - // A configuration element, with its attributes and children, directly - // reflects the content and structure of the extension section within the - // declaring plug-in's manifest (plugin.xml) file. - IConfigurationElement[] elements = extension.getConfigurationElements(); - loadConfigElements(DefaultManagedConfigElement.convertArray(elements)); + // The version of the Plug-in is greater than what the manager thinks it understands + // Display error message + IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if(window == null){ + IWorkbenchWindow windows[] = PlatformUI.getWorkbench().getWorkbenchWindows(); + window = windows[0]; + } + + final Shell shell = window.getShell(); + final String errMsg = ManagedMakeMessages.getFormattedString(MANIFEST_VERSION_ERROR, extension.getUniqueIdentifier()); + shell.getDisplay().syncExec( new Runnable() { + public void run() { + MessageDialog.openError(shell, + ManagedMakeMessages.getResourceString("ManagedBuildManager.error.manifest_load_failed_title"), //$NON-NLS-1$ + errMsg); + } + } ); + } else { + // Get the "configuraton elements" defined in the plugin.xml file. + // Note that these "configuration elements" are not related to the + // managed build system "configurations". + // From the PDE Guide: + // A configuration element, with its attributes and children, directly + // reflects the content and structure of the extension section within the + // declaring plug-in's manifest (plugin.xml) file. + IConfigurationElement[] elements = extension.getConfigurationElements(); + loadConfigElements(DefaultManagedConfigElement.convertArray(elements)); + } } // Then call resolve. // @@ -1834,5 +1863,4 @@ public class ManagedBuildManager extends AbstractCExtension implements IScannerI public static IManagedConfigElement getConfigElement(IBuildObject buildObj) { return (IManagedConfigElement)getConfigElementMap().get(buildObj); } - } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java index fff0585bb80..7d8cad48465 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/Configuration.java @@ -111,7 +111,7 @@ public class Configuration extends BuildObject implements IConfiguration { * Create a new extension configuration based on one already defined. * * @param projectType The ProjectType the configuration will be added to. - * @param parentConfig The IConfiguration to copy the settings from. + * @param parentConfig The IConfiguration that is the parent configuration of this configuration * @param id A unique ID for the new configuration. */ public Configuration(ProjectType projectType, IConfiguration parentConfig, String id) { @@ -144,6 +144,7 @@ public class Configuration extends BuildObject implements IConfiguration { * Create a new extension configuration and fill in the attributes and childen later. * * @param projectType The ProjectType the configuration will be added to. + * @param parentConfig The IConfiguration that is the parent configuration of this configuration * @param id A unique ID for the new configuration. * @param name A name for the new configuration. */ @@ -196,8 +197,9 @@ public class Configuration extends BuildObject implements IConfiguration { * Create a new project, non-extension, configuration based on one already defined. * * @param managedProject The ManagedProject the configuration will be added to. - * @param parentConfig The IConfiguration to copy the settings from. + * @param cloneConfig The IConfiguration to copy the settings from. * @param id A unique ID for the new configuration. + * @param cloneTools If true, the configuration's tools are cloned */ public Configuration(ManagedProject managedProject, Configuration cloneConfig, String id, boolean cloneTools) { setId(id); diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java index db5d41ea72e..a81f8249b63 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedBuildInfo.java @@ -123,7 +123,8 @@ public class ManagedBuildInfo implements IManagedBuildInfo, IScannerInfo { // TODO: There should only be 1? for (int projIndex = projNodes.getLength() - 1; projIndex >= 0; --projIndex) { ManagedProject proj = new ManagedProject(this, (Element)projNodes.item(projIndex)); - proj.resolveReferences(); + if (!proj.resolveReferences()) + proj.setValid(false); } // Switch the rebuild off since this is an existing project diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java index affe5d53582..b7c52a5001a 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/ManagedProject.java @@ -47,6 +47,7 @@ public class ManagedProject extends BuildObject implements IManagedProject { private Map configMap; // Miscellaneous private boolean isDirty = false; + private boolean isValid = true; private boolean resolved = true; /* @@ -95,15 +96,17 @@ public class ManagedProject extends BuildObject implements IManagedProject { this(buildInfo.getOwner()); // Initialize from the XML attributes - loadFromProject(element); - - // Load children - NodeList configElements = element.getChildNodes(); - for (int i = 0; i < configElements.getLength(); ++i) { - Node configElement = configElements.item(i); - if (configElement.getNodeName().equals(IConfiguration.CONFIGURATION_ELEMENT_NAME)) { - Configuration config = new Configuration(this, (Element)configElement); + if (loadFromProject(element)) { + // Load children + NodeList configElements = element.getChildNodes(); + for (int i = 0; i < configElements.getLength(); ++i) { + Node configElement = configElements.item(i); + if (configElement.getNodeName().equals(IConfiguration.CONFIGURATION_ELEMENT_NAME)) { + Configuration config = new Configuration(this, (Element)configElement); + } } + } else { + setValid(false); } // hook me up @@ -120,7 +123,7 @@ public class ManagedProject extends BuildObject implements IManagedProject { * * @param element An XML element containing the project information */ - protected void loadFromProject(Element element) { + protected boolean loadFromProject(Element element) { // id setId(element.getAttribute(IBuildObject.ID)); @@ -135,9 +138,10 @@ public class ManagedProject extends BuildObject implements IManagedProject { if (projectTypeId != null && projectTypeId.length() > 0) { projectType = ManagedBuildManager.getExtensionProjectType(projectTypeId); if (projectType == null) { - // TODO: Report error + return false; } } + return true; } /* (non-Javadoc) @@ -348,14 +352,14 @@ public class ManagedProject extends BuildObject implements IManagedProject { /* (non-Javadoc) * Resolve the element IDs to interface references */ - public void resolveReferences() { + public boolean resolveReferences() { if (!resolved) { resolved = true; // Resolve project-type if (projectTypeId != null && projectTypeId.length() > 0) { projectType = ManagedBuildManager.getExtensionProjectType(projectTypeId); if (projectType == null) { - // TODO: Report error + return false; } } @@ -366,6 +370,7 @@ public class ManagedProject extends BuildObject implements IManagedProject { current.resolveReferences(); } } + return true; } /* (non-Javadoc) @@ -400,4 +405,20 @@ public class ManagedProject extends BuildObject implements IManagedProject { } } + /* (non-Javadoc) + * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#isValid() + */ + public boolean isValid() { + // TODO: In the future, children could also have a "valid" state that should be checked + return isValid; + } + + /* (non-Javadoc) + * @see org.eclipse.cdt.managedbuilder.core.IManagedProject#setValid(boolean) + */ + public void setValid(boolean isValid) { + // TODO: In the future, children could also have a "valid" state... + this.isValid = isValid; + } + } diff --git a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties index 67a1eef678d..ac320e2eb7e 100644 --- a/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties +++ b/build/org.eclipse.cdt.managedbuilder.core/src/org/eclipse/cdt/managedbuilder/internal/core/PluginResources.properties @@ -37,10 +37,12 @@ Option.error.bad_value_type=Bad value for type ManagedBuildManager.error.owner_not_null=addTarget: owner not null ManagedBuildManager.error.null_owner=addTarget: null owner ManagedBuildManager.error.owner_not_project=addTarget: owner not project -ManagedBuildManager.error.manifest.version.error=The version of plugin file is higher than version of the build system -ManagedBuildManager.error.project.version.error=The version of the project is higher than the build system +ManagedBuildManager.error.manifest_load_failed_title=Managed Build System Version Error +ManagedBuildManager.error.manifest.version.error=The version number defined in the plugin manifest file\n{0}\nis greater than the version of the Managed Build System.\nThe definitions in the manifest file will not be loaded. ManagedBuildManager.error.open_failed_title=Managed Make Project File Error ManagedBuildManager.error.open_failed=The Managed Make project file could not be read because of the following error.\n\n{0}\n\nManaged Make functionality will not be available for this project. +ManagedBuildManager.error.project.version.error=The version number of the project {0} is greater than the Managed Build System version number. +ManagedBuildManager.error.id.nomatch=Error loading Managed Make project information for project {0}. The tool definitions used to create the project are not available. # Makefile Generator Messages MakefileGenerator.message.start.file=Building file: diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties index 015a75e92c4..3ad314a1d76 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/internal/ui/PluginResources.properties @@ -54,7 +54,7 @@ BuildPropertyPage.tip.addconf=Add configurations for the platform BuildPropertyPage.tip.remconf=Remove configurations for the platform BuildPropertyPage.manage.title=Manage BuildPropertyPage.error.Unknown_tree_element=Unknown type of element in tree of type {0} -BuildPropertyPage.error.version_low=The project settings are stored in an earlier format.\nYou must upgrade the project before the settings can be displayed. +BuildPropertyPage.error.version_low=The Managed Make project settings for this project are not available. BuildPropertyPage.defaults.title=Reset Configuration Tools BuildPropertyPage.defaults.message=This action will reset all of the tools in the selected configuration to their default settings.\n\nDo you want to proceed? BuildPropertyPage.changes.save.title=Apply Configuration Changes @@ -72,7 +72,7 @@ ToolsSettingsBlock.label.ToolOptions=Options # ----------- Build Settings Block ----------- BuildSettingsBlock.label.Settings=Build Settings -BuildSettingsBlock.label.makecmdgroup=Make command +BuildSettingsBlock.label.makecmdgroup=Build command BuildSettingsBlock.label.makecmddef=Use default command BuildSettingsBlock.label.output.group=Build output BuildSettingsBlock.label.output.name=Artifact name: @@ -87,7 +87,7 @@ ResourceBuildPropertyPage.selection.configuration.all=All configurations ResourceBuildPropertyPage.label.ToolTree=Tools ResourceBuildPropertyPage.label.ToolOptions=Options ResourceBuildPropertyPage.label.NotMBSFile=The project is closed or the file is not contained within a Managed Make project. -ResourceBuildPropertyPage.error.version_low=The project settings are stored in an earlier format.\nYou must upgrade the project before the settings can be displayed. +ResourceBuildPropertyPage.error.version_low=The Managed Make project settings for this project are not available. # ----------- Entry Dialog ----------- BrowseEntryDialog.error.Folder_name_invalid = Folder name invalid