1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

1. Fix NPE in the New Project Wizard

2. Fix to [Bug 189125] [New project model] Stroage modules don't get copied
3. Fix to build path settings
This commit is contained in:
Mikhail Sennikovsky 2007-06-08 16:00:45 +00:00
parent 6653aa0f0d
commit a032fbd206
9 changed files with 87 additions and 23 deletions

View file

@ -1693,41 +1693,65 @@ public class Builder extends BuildObject implements IBuilder, IMatchKeyProvider
}
public String getBuildPathAttribute(){
return getBuildPathAttribute(true);
}
public String getBuildPathAttribute(boolean querySuperClass){
if(buildPath == null){
if(superClass != null){
return ((Builder)superClass).getBuildPathAttribute();
if(querySuperClass && superClass != null){
return ((Builder)superClass).getBuildPathAttribute(true);
}
}
return buildPath;
}
public void setBuildPath(String path){
setBuildPathAttribute(path);
}
public void setBuildPathAttribute(String path){
buildPath = path;
setDirty(true);
}
public String getBuildPath(){
if(isManagedBuildOn())
return getDefaultBuildPath();
String path = getBuildPathAttribute();
if(path == null){
boolean initBuildPathVar = false;
Configuration cfg = (Configuration)getConfguration();
if(cfg != null && !cfg.isPreference()){
path = getDefaultBuildPath();
// if(isManagedBuildOn() && !isExtensionElement()) {
// buildPath = path;
// }
}
return path;
}
public String getDefaultBuildPath(){
Configuration cfg = (Configuration)getConfguration();
String path = null;
if(cfg != null){
if(isManagedBuildOn()){
path = cfg.getName();
}
if(!isExtensionElement() && !cfg.isPreference()){
IProject project = cfg.getOwner().getProject();
IPath projPath = project.getFullPath();
if(isManagedBuildOn()){
path = projPath.append(cfg.getName()).toString();
initBuildPathVar = !isExtensionBuilder;
} else {
path = projPath.toString();
}
IPath buildPath = project.getFullPath();
IStringVariableManager mngr = VariablesPlugin.getDefault().getStringVariableManager();
if(path != null)
buildPath = buildPath.append(path);
path = buildPath.toString();
path = mngr.generateVariableExpression("workspace_loc", path); //$NON-NLS-1$
if(initBuildPathVar)
buildPath = path;
} else {
path = ""; //$NON-NLS-1$
}
}
if(path == null){
path = ""; //$NON-NLS-1$
}
return path;
}

View file

@ -41,6 +41,7 @@ import org.eclipse.cdt.managedbuilder.core.ITool;
import org.eclipse.cdt.managedbuilder.core.IToolChain;
import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager;
import org.eclipse.cdt.managedbuilder.core.ManagedBuilderCorePlugin;
import org.eclipse.cdt.managedbuilder.internal.core.Builder;
import org.eclipse.cdt.managedbuilder.internal.core.BuilderFactory;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.managedbuilder.internal.core.ISettingsChangeListener;
@ -106,6 +107,11 @@ public class ConfigurationDataProvider extends CConfigurationDataProvider implem
rootElement.setAttribute(VERSION_ATTRIBUTE, ManagedBuildManager.getVersion().toString());
ICStorageElement cfgElemen = rootElement.createChild(IConfiguration.CONFIGURATION_ELEMENT_NAME);
Configuration cfg = (Configuration)appliedCfg.getConfiguration();
Builder b = (Builder)cfg.getEditableBuilder();
if(b != null && b.isManagedBuildOn() && b.getBuildPathAttribute(false) == null){
String bPath = b.getDefaultBuildPath();
b.setBuildPathAttribute(bPath);
}
// cfg.setConfigurationDescription(des);
// ManagedBuildManager.performValueHandlerEvent(cfg, IManagedOptionValueHandler.EVENT_APPLY);
cfg.serialize(cfgElemen);

View file

@ -14,6 +14,7 @@ package org.eclipse.cdt.managedbuilder.ui.properties;
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
import org.eclipse.cdt.managedbuilder.core.IBuilder;
import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.internal.core.Builder;
import org.eclipse.cdt.managedbuilder.internal.core.Configuration;
import org.eclipse.cdt.ui.newui.AbstractCPropertyTab;
import org.eclipse.cdt.ui.newui.TriButton;
@ -296,7 +297,7 @@ public class BuilderSettingsTab extends AbstractCBuildPropertyTab {
b2.setParallelizationNum(b1.getParallelizationNum());
if (b2.canKeepEnvironmentVariablesInBuildfile())
b2.setKeepEnvironmentVariablesInBuildfile(b1.keepEnvironmentVariablesInBuildfile());
b2.setBuildPath(null);
((Builder)b2).setBuildPath(((Builder)b1).getBuildPathAttribute());
b2.setAutoBuildEnable((b1.isAutoBuildEnable()));
b2.setBuildAttribute(IBuilder.BUILD_TARGET_AUTO, (b1.getBuildAttribute(IBuilder.BUILD_TARGET_AUTO, EMPTY_STR)));

View file

@ -95,7 +95,7 @@ public class MBSWizardHandler extends CWizardHandler {
private IWizardPage startingPage;
// private EntryDescriptor entryDescriptor = null;
private EntryInfo entryInfo;
private CfgHolder[] cfgs = null;
protected CfgHolder[] cfgs = null;
protected static final class EntryInfo {
private SortedMap tcs;

View file

@ -55,7 +55,7 @@ public class STDWizardHandler extends MBSWizardHandler {
ManagedProject mProj = new ManagedProject(des);
info.setManagedProject(mProj);
CfgHolder[] cfgs = fConfigPage.getCfgItems(defaults);
cfgs = fConfigPage.getCfgItems(defaults);
for (int i=0; i<cfgs.length; i++) {
String s = (cfgs[i].getToolChain() == null) ? "0" : ((ToolChain)(cfgs[i].getToolChain())).getId(); //$NON-NLS-1$

View file

@ -87,8 +87,8 @@ public class CProjectDescriptionBasicTests extends BaseTestCase{
ICStorageElement child = el.createChild(EL_NAME);
child.setAttribute(ATTR2, ATTR2_VALUE);
final String newCfgId1 = CDataUtil.genId(null);
final String newCfgId2 = CDataUtil.genId(null);
final String newCfgId1 = "cfg1.id";//CDataUtil.genId(null);
// final String newCfgId2 = CDataUtil.genId(null);
ICConfigurationDescription cfg1 = des.createConfiguration(newCfgId1, newCfgId1 + ".name", baseCfg);
assertEquals(newCfgId1, cfg1.getId());
@ -102,6 +102,26 @@ public class CProjectDescriptionBasicTests extends BaseTestCase{
mngr.setProjectDescription(p3, des);
des = mngr.getProjectDescription(p3, false);
cfg1 = des.getConfigurationById(newCfgId1);
el = cfg1.getStorage(STORAGE_ID, false);
assertNotNull(el);
assertEquals(ATTR_VALUE, el.getAttribute(ATTR));
assertEquals(1, el.getChildren().length);
child = el.getChildren()[0];
assertEquals(EL_NAME, child.getName());
assertEquals(ATTR2_VALUE, child.getAttribute(ATTR2));
des = mngr.getProjectDescription(p3, true);
cfg1 = des.getConfigurationById(newCfgId1);
el = cfg1.getStorage(STORAGE_ID, false);
assertNotNull(el);
assertEquals(ATTR_VALUE, el.getAttribute(ATTR));
assertEquals(1, el.getChildren().length);
child = el.getChildren()[0];
assertEquals(EL_NAME, child.getName());
assertEquals(ATTR2_VALUE, child.getAttribute(ATTR2));
}
public void remove_prefix_testSetInvalidCreatingDescription() throws Exception {

View file

@ -93,13 +93,14 @@ public class CConfigurationDescription extends CDataProxyContainer implements IC
CConfigurationSpecSettings baseSettings = ((CConfigurationDescription)base).getSpecSettings();
InternalXmlStorageElement baseRootEl = (InternalXmlStorageElement)baseSettings.getRootStorageElement();
InternalXmlStorageElement newRootEl = CProjectDescriptionManager.getInstance().copyElement(baseRootEl, false);
InternalXmlStorageElement newRootEl = CProjectDescriptionManager.getInstance().copyConfigurationElement(baseRootEl, id, false);
ICStorageElement parentEl = baseRootEl.getParent();
parentEl.importChild(newRootEl);
newRootEl = (InternalXmlStorageElement)parentEl.importChild(newRootEl);
fCfgSpecSettings = new CConfigurationSpecSettings(this, baseSettings, newRootEl);
fCfgSpecSettings.setId(id);
fCfgSpecSettings.setName(name);
fCfgSpecSettings.serializeId();
CConfigurationData baseData = ((IInternalCCfgInfo)base).getConfigurationData(false);
if(baseData instanceof CConfigurationDescriptionCache){
baseData = ((CConfigurationDescriptionCache)baseData).getConfigurationData();

View file

@ -329,6 +329,12 @@ public class CConfigurationSpecSettings implements ICSettingsStorage{
fIsModified = true;
}
}
void serializeId() throws CoreException {
fId = fCfg.getId();
ICStorageElement settings = getSettingsStorageElement();
settings.setAttribute(ID, fId);
}
void serialize() throws CoreException {
fId = fCfg.getId();

View file

@ -2807,6 +2807,12 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
}
InternalXmlStorageElement copyConfigurationElement(InternalXmlStorageElement el, String newId, boolean readOnly) throws CoreException {
el = copyElement(el, readOnly);
el.setAttribute(CConfigurationSpecSettings.ID, newId);
return el;
}
InternalXmlStorageElement copyElement(InternalXmlStorageElement el, boolean readOnly) throws CoreException {
// try {
// DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();