diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionTests.java index 376db9c0a05..a741b8661d6 100644 --- a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionTests.java +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionTests.java @@ -25,6 +25,7 @@ public class CProjectDescriptionTests { // each class being tested suite.addTest(CConfigurationDescriptionReferenceTests.suite()); suite.addTest(ExternalSettingsProviderTests.suite()); + suite.addTest(CfgSettingsTests.suite()); return suite; } diff --git a/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CfgSettingsTests.java b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CfgSettingsTests.java new file mode 100644 index 00000000000..de8afd6737b --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/model/org/eclipse/cdt/core/settings/model/CfgSettingsTests.java @@ -0,0 +1,159 @@ +/******************************************************************************* + * Copyright (c) 2007 Intel Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.settings.model; + +import junit.framework.TestSuite; + +import org.eclipse.cdt.core.dom.IPDOMManager; +import org.eclipse.cdt.core.model.CoreModel; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.testplugin.CProjectHelper; +import org.eclipse.cdt.core.testplugin.util.BaseTestCase; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; + +public class CfgSettingsTests extends BaseTestCase { + private static final String PROJ_NAME_PREFIX = "sfgst_"; + ICProject p1; + + public static TestSuite suite() { + return suite(CfgSettingsTests.class, "_"); + } + + protected void setUp() throws Exception { + } + + public void testDefaultSettingConfig() throws Exception { + ICProjectDescriptionManager mngr = CoreModel.getDefault().getProjectDescriptionManager(); + + ICProjectDescriptionWorkspacePreferences prefs = mngr.getProjectDescriptionWorkspacePreferences(true); + + int wspRel = prefs.getConfigurationReltations(); + CoreModel model = CoreModel.getDefault(); + p1 = CProjectHelper.createNewStileCProject(PROJ_NAME_PREFIX + "a", IPDOMManager.ID_NO_INDEXER); + IProject project = p1.getProject(); + ICProjectDescription des = model.getProjectDescription(project, false); + assertEquals(wspRel, des.getConfigurationReltations()); + assertTrue(des.isDefaultConfigurationRelations()); + prefs.setConfigurationRelations(ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT); + assertEquals(wspRel, des.getConfigurationReltations()); + assertEquals(wspRel, mngr.getProjectDescriptionWorkspacePreferences(true).getConfigurationReltations()); + prefs.setConfigurationRelations(ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE); + assertEquals(wspRel, des.getConfigurationReltations()); + assertEquals(wspRel, mngr.getProjectDescriptionWorkspacePreferences(true).getConfigurationReltations()); + assertTrue(des.isDefaultConfigurationRelations()); + wspRel = getChangedConfigRelStatus(wspRel); + + prefs.setConfigurationRelations(wspRel); + + mngr.setProjectDescriptionWorkspacePreferences(prefs, true, null); + des = model.getProjectDescription(project, false); + prefs = mngr.getProjectDescriptionWorkspacePreferences(true); + assertEquals(wspRel, des.getConfigurationReltations()); + assertEquals(wspRel, prefs.getConfigurationReltations()); + assertTrue(des.isDefaultConfigurationRelations()); + + des = mngr.getProjectDescription(project); + assertTrue(des.isDefaultConfigurationRelations()); + wspRel = prefs.getConfigurationReltations(); + assertEquals(wspRel, des.getConfigurationReltations()); + wspRel = getChangedConfigRelStatus(wspRel); + prefs.setConfigurationRelations(wspRel); + assertTrue(wspRel != des.getConfigurationReltations()); + mngr.setProjectDescriptionWorkspacePreferences(prefs, false, null); + assertEquals(wspRel, des.getConfigurationReltations()); + mngr.setProjectDescription(des.getProject(), des); + des = mngr.getProjectDescription(project, false); + assertEquals(wspRel, des.getConfigurationReltations()); + + des = mngr.getProjectDescription(project); + prefs = mngr.getProjectDescriptionWorkspacePreferences(false); + assertEquals(des.getConfigurationReltations(), prefs.getConfigurationReltations()); + assertTrue(des.isDefaultConfigurationRelations()); + wspRel = prefs.getConfigurationReltations(); + int projRel = getChangedConfigRelStatus(wspRel); + des.setConfigurationRelations(projRel); + assertFalse(des.isDefaultConfigurationRelations()); + assertEquals(projRel, des.getConfigurationReltations()); + mngr.setProjectDescription(project, des); + + des = mngr.getProjectDescription(project, false); + assertFalse(des.isDefaultConfigurationRelations()); + assertEquals(projRel, des.getConfigurationReltations()); + + des = mngr.getProjectDescription(project, true); + assertFalse(des.isDefaultConfigurationRelations()); + assertEquals(projRel, des.getConfigurationReltations()); + + ICConfigurationDescription aCfg = des.getActiveConfiguration(); + ICConfigurationDescription sCfg = des.getDefaultSettingConfiguration(); + assertEquals(aCfg, sCfg); + + des.createConfiguration("qq.2", "test2", des.getConfigurations()[0]); + + assertEquals(aCfg, des.getActiveConfiguration()); + assertEquals(sCfg, des.getActiveConfiguration()); + + projRel = getChangedConfigRelStatus(projRel); + des.setConfigurationRelations(projRel); + assertEquals(aCfg, des.getActiveConfiguration()); + assertEquals(sCfg, des.getActiveConfiguration()); + assertFalse(des.isDefaultConfigurationRelations()); + + projRel = ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE; + des.setConfigurationRelations(projRel); + ICConfigurationDescription cfg2 = des.getConfigurationById("qq.2"); + assertNotNull(cfg2); + des.setActiveConfiguration(cfg2); + assertEquals(cfg2, des.getActiveConfiguration()); + assertEquals(cfg2, des.getDefaultSettingConfiguration()); + + projRel = ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT; + des.setConfigurationRelations(projRel); + des.setActiveConfiguration(aCfg); + assertEquals(aCfg, des.getActiveConfiguration()); + assertEquals(cfg2, des.getDefaultSettingConfiguration()); + + des.setDefaultSettingConfiguration(aCfg); + assertEquals(aCfg, des.getActiveConfiguration()); + assertEquals(aCfg, des.getDefaultSettingConfiguration()); + + des.setDefaultSettingConfiguration(cfg2); + assertEquals(aCfg, des.getActiveConfiguration()); + assertEquals(cfg2, des.getDefaultSettingConfiguration()); + + mngr.setProjectDescription(project, des); + + des = mngr.getProjectDescription(project, false); + assertEquals(aCfg.getId(), des.getActiveConfiguration().getId()); + assertEquals(cfg2.getId(), des.getDefaultSettingConfiguration().getId()); + + des = mngr.getProjectDescription(project, true); + assertEquals(aCfg.getId(), des.getActiveConfiguration().getId()); + assertEquals(cfg2.getId(), des.getDefaultSettingConfiguration().getId()); + } + + private int getChangedConfigRelStatus(int status){ + if(status == ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT) + return ICProjectDescriptionPreferences.CONFIGS_LINK_SETTINGS_AND_ACTIVE; + return ICProjectDescriptionPreferences.CONFIGS_INDEPENDENT; + } + + protected void tearDown() throws Exception { + try { + if(p1 != null){ + p1.getProject().delete(true, null); + p1 = null; + } + } catch (CoreException e){ + } + } +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java index 3aedfc592cd..8e1889fbdfd 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/CoreModel.java @@ -21,6 +21,7 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSetting; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener; +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.settings.model.WriteAccessException; import org.eclipse.cdt.internal.core.model.APathEntry; import org.eclipse.cdt.internal.core.model.BatchOperation; @@ -37,7 +38,6 @@ import org.eclipse.cdt.internal.core.model.PathEntryManager; import org.eclipse.cdt.internal.core.model.ProjectEntry; import org.eclipse.cdt.internal.core.model.SourceEntry; import org.eclipse.cdt.internal.core.settings.model.CLanguageSettingCache; -import org.eclipse.cdt.internal.core.settings.model.CProjectDescription; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFolder; @@ -1232,9 +1232,9 @@ public class CoreModel { public static boolean isScannerInformationEmpty(IResource resource) { IProject project = resource.getProject(); CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance(); - CProjectDescription des = (CProjectDescription)mngr.getProjectDescription(project, false); + ICProjectDescription des = mngr.getProjectDescription(project, false); if(des != null){ - ICConfigurationDescription indexCfg = des.getIndexConfiguration(); + ICConfigurationDescription indexCfg = des.getDefaultSettingConfiguration(); if(indexCfg != null){ if(!mngr.isNewStyleCfg(indexCfg)){ return oldIsScannerInformationEmpty(resource); @@ -1424,10 +1424,14 @@ public class CoreModel { } public void addCProjectDescriptionListener(ICProjectDescriptionListener listener, int eventTypes){ - descriptionManager.addListener(listener, eventTypes); + descriptionManager.addCProjectDescriptionListener(listener, eventTypes); } public void removeCProjectDescriptionListener(ICProjectDescriptionListener listener){ - descriptionManager.removeListener(listener); + descriptionManager.removeCProjectDescriptionListener(listener); + } + + public ICProjectDescriptionManager getProjectDescriptionManager(){ + return descriptionManager; } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionEvent.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionEvent.java index 62424a25d8e..537233ada1f 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionEvent.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/CProjectDescriptionEvent.java @@ -10,7 +10,6 @@ *******************************************************************************/ package org.eclipse.cdt.core.settings.model; -import org.eclipse.cdt.internal.core.settings.model.CProjectDescription; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionDelta; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.cdt.internal.core.settings.model.ICDescriptionDelta; @@ -69,7 +68,7 @@ public final class CProjectDescriptionEvent { return fActiveCfgDelta; } - public ICDescriptionDelta getIndexCfgDelta(){ + public ICDescriptionDelta getDefaultSettingCfgDelta(){ if(fIndexCfgDelta == null){ fIndexCfgDelta = getDelta(false); } @@ -121,7 +120,7 @@ public final class CProjectDescriptionEvent { } private ICConfigurationDescription getCfg(ICProjectDescription des, boolean active){ - return active ? des.getActiveConfiguration() : ((CProjectDescription)des).getIndexConfiguration(); + return active ? des.getActiveConfiguration() : des.getDefaultSettingConfiguration(); } private ICDescriptionDelta findCfgDelta(ICDescriptionDelta delta, String id){ diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescription.java index cc2a27c5681..8f6a30f865c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescription.java @@ -23,7 +23,11 @@ import org.eclipse.core.runtime.QualifiedName; * @see CoreModel#getProjectDescription(IProject, boolean) * */ -public interface ICProjectDescription extends ICSettingContainer, ICSettingObject, ICSettingsStorage{ +public interface ICProjectDescription extends ICSettingContainer, + ICSettingObject, + ICSettingsStorage, + ICProjectDescriptionPreferences { + /** * returns an array of configurations available for this project * @@ -140,4 +144,8 @@ public interface ICProjectDescription extends ICSettingContainer, ICSettingObje * @param value */ void setSessionProperty(QualifiedName name, Object value); + + ICConfigurationDescription getDefaultSettingConfiguration(); + + void setDefaultSettingConfiguration(ICConfigurationDescription cfg); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionManager.java new file mode 100644 index 00000000000..762027405c4 --- /dev/null +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionManager.java @@ -0,0 +1,120 @@ +/******************************************************************************* + * Copyright (c) 2007 Intel Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.settings.model; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; + +public interface ICProjectDescriptionManager { + /** + * the method creates and returns a writable project description + * + * @param project project for which the project description is requested + * @param loadIfExists if true the method first tries to load and return the project description + * from the settings file (.cproject) + * if false, the stored settings are ignored and the new (empty) project description is created + * NOTE: changes made to the returned project description will not be applied untill the {@link #setProjectDescription(IProject, ICProjectDescription)} is called + * @return {@link ICProjectDescription} + * @throws CoreException + */ + ICProjectDescription createProjectDescription(IProject project, boolean loadIfExists) throws CoreException; + + /** + * returns the project description associated with this project + * this is a convenience method fully equivalent to getProjectDescription(project, true) + * see {@link #getProjectDescription(IProject, boolean)} for more detail + * @param project + * @return a writable copy of the ICProjectDescription or null if the project does not contain the + * CDT data associated with it. + * Note: changes to the project description will not be reflected/used by the core + * untill the {@link #setProjectDescription(IProject, ICProjectDescription)} is called + * + * @see #getProjectDescription(IProject, boolean) + */ + ICProjectDescription getProjectDescription(IProject project); + + /** + * this method is called to save/apply the project description + * the method should be called to apply changes made to the project description + * returned by the {@link #getProjectDescription(IProject, boolean)} or {@link #createProjectDescription(IProject, boolean)} + * + * @param project + * @param des + * @throws CoreException + * + * @see {@link #getProjectDescription(IProject, boolean)} + * @see #createProjectDescription(IProject, boolean) + */ + void setProjectDescription(IProject project, ICProjectDescription des) throws CoreException; + + void setProjectDescription(IProject project, ICProjectDescription des, boolean force, IProgressMonitor monitor) throws CoreException; + + /** + * returns the project description associated with this project + * + * @param project project for which the description is requested + * @param write if true, the writable description copy is returned. + * If false the cached read-only description is returned. + * + * CDT core maintains the cached project description settings. If only read access is needed to description, + * then the read-only project description should be obtained. + * This description always operates with cached data and thus it is better to use it for performance reasons + * All set* calls to the read-only description result in the {@link WriteAccessException} + * + * When the writable description is requested, the description copy is created. + * Changes to this description will not be reflected/used by the core and Build System untill the + * {@link #setProjectDescription(IProject, ICProjectDescription)} is called + * + * Each getProjectDescription(project, true) returns a new copy of the project description + * + * The writable description uses the cached data untill the first set call + * after that the description communicates directly to the Build System + * i.e. the implementer of the org.eclipse.cdt.core.CConfigurationDataProvider extension + * This ensures the Core<->Build System settings integrity + * + * @return {@link ICProjectDescription} + */ + ICProjectDescription getProjectDescription(IProject project, boolean write); + + /** + * forces the cached data of the specified projects to be re-calculated. + * if the projects argument is null al projects + * within the workspace are updated + * + * @param projects + * @param monitor + * @throws CoreException + */ + void updateProjectDescriptions(IProject projects[], IProgressMonitor monitor) throws CoreException; + + /** + * aswers whether the given project is a new-style project, i.e. CConfigurationDataProvider-driven + * @param project + * @return + */ + boolean isNewStyleProject(IProject project); + + /** + * aswers whether the given project is a new-style project, i.e. CConfigurationDataProvider-driven + * @param des + * @return + */ + boolean isNewStyleProject(ICProjectDescription des); + + void addCProjectDescriptionListener(ICProjectDescriptionListener listener, int eventTypes); + + void removeCProjectDescriptionListener(ICProjectDescriptionListener listener); + + ICProjectDescriptionWorkspacePreferences getProjectDescriptionWorkspacePreferences(boolean write); + + boolean setProjectDescriptionWorkspacePreferences(ICProjectDescriptionWorkspacePreferences prefs, boolean updateProjects, IProgressMonitor monitor); +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionPreferences.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionPreferences.java new file mode 100644 index 00000000000..02893291497 --- /dev/null +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionPreferences.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2007 Intel Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.settings.model; + +public interface ICProjectDescriptionPreferences { + /** + * Configuration relation status specifying that the Settings and Build configurations are + * independent of each other, i.e. changing the active configuration will NOT change the settings + * configuration used by the core and vie a versa + * + * @see #getConfigurationReltations() + * @see #setConfigurationRelations(Integer) + */ + public static final int CONFIGS_INDEPENDENT = 1; + + /** + * Configuration relation status specifying that the Settings and Build configurations are + * settings are linked with each other, i.e. changing the active configuration will change the settings + * configuration used by the core and vie a versa + * + * @see #getConfigurationReltations() + * @see #setConfigurationRelations(Integer) + */ + public static final int CONFIGS_LINK_SETTINGS_AND_ACTIVE = 2; + + /** + * returns the CONFIG_xxx status for this project description + * + * @see #CONFIGS_INDEPENDENT + * @see #CONFIGS_LINK_SETTINGS_AND_ACTIVE + * + * @return int + */ + int getConfigurationReltations(); + + /** + * sets the configuration relation status. can be an integer value containing the + * CONFIG_xxx status + * + * @see #CONFIGS_INDEPENDENT + * @see #CONFIGS_LINK_SETTINGS_AND_ACTIVE + * + * @param status + */ + void setConfigurationRelations(int status); + + /** + * specifies that the default configuration relations should be used + * When called for the project description, specifies that the workspace preferences settings + * should be used + * When called for the workspace preferences sets the default relation value + * which is CONFIGS_INDEPENDENT + */ + void useDefaultConfigurationRelations(); + + /** + * specifies whether default configuration relations are used + */ + boolean isDefaultConfigurationRelations(); +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionWorkspacePreferences.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionWorkspacePreferences.java new file mode 100644 index 00000000000..c2ac2a520dd --- /dev/null +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/ICProjectDescriptionWorkspacePreferences.java @@ -0,0 +1,16 @@ +/******************************************************************************* + * Copyright (c) 2007 Intel Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.core.settings.model; + +public interface ICProjectDescriptionWorkspacePreferences extends + ICProjectDescriptionPreferences { + +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java index 6bf83b881f4..0fc48e59ca6 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java @@ -45,6 +45,7 @@ import org.eclipse.cdt.core.settings.model.ICOutputEntry; import org.eclipse.cdt.core.settings.model.ICSettingBase; import org.eclipse.cdt.core.settings.model.ICSettingEntry; import org.eclipse.cdt.core.settings.model.ICSourceEntry; +import org.eclipse.cdt.core.settings.model.ICStorageElement; import org.eclipse.cdt.core.settings.model.extension.CBuildData; import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; import org.eclipse.cdt.core.settings.model.extension.CFolderData; @@ -766,5 +767,35 @@ public class CDataUtil { } return map; } + + public static boolean getBoolean(ICStorageElement el, String attr, boolean defaultValue){ + if(el != null){ + String tmp = el.getAttribute(attr); + if(tmp != null){ + return Boolean.valueOf(tmp).booleanValue(); + } + } + return defaultValue; + } + public static void setBoolean(ICStorageElement el, String attr, boolean value){ + el.setAttribute(attr, Boolean.valueOf(value).toString()); + } + + public static int getInteger(ICStorageElement el, String attr, int defaultValue){ + if(el != null){ + String tmp = el.getAttribute(attr); + if(tmp != null){ + try { + return Integer.parseInt(tmp); + } catch (NumberFormatException e) { + } + } + } + return defaultValue; + } + + public static void setInteger(ICStorageElement el, String attr, int value){ + el.setAttribute(attr, new Integer(value).toString()); + } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CContainerInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CContainerInfo.java index d779b5bbc3c..2dbfef1535a 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CContainerInfo.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CContainerInfo.java @@ -17,8 +17,8 @@ import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ISourceRoot; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICSourceEntry; -import org.eclipse.cdt.internal.core.settings.model.CProjectDescription; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; @@ -70,9 +70,9 @@ public class CContainerInfo extends OpenableInfo { // IPathEntry[] entries = cproject.getResolvedPathEntries(); ICSourceEntry[] entries = null; - CProjectDescription des = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(cproject.getProject(), false); + ICProjectDescription des = CProjectDescriptionManager.getInstance().getProjectDescription(cproject.getProject(), false); if(des != null){ - ICConfigurationDescription cfg = des.getIndexConfiguration(); + ICConfigurationDescription cfg = des.getDefaultSettingConfiguration(); if(cfg != null){ entries = cfg.getResolvedSourceEntries(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java index c9580a63a4b..a16c4fb28bd 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProject.java @@ -44,8 +44,8 @@ import org.eclipse.cdt.core.model.ISourceEntry; import org.eclipse.cdt.core.model.ISourceRoot; import org.eclipse.cdt.core.settings.model.CSourceEntry; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICSourceEntry; -import org.eclipse.cdt.internal.core.settings.model.CProjectDescription; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; @@ -603,9 +603,9 @@ public class CProject extends Openable implements ICProject { protected List computeSourceRoots() throws CModelException { //IPathEntry[] entries = getResolvedPathEntries(); ICSourceEntry[] entries = null; - CProjectDescription des = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(getProject(), false); + ICProjectDescription des = CProjectDescriptionManager.getInstance().getProjectDescription(getProject(), false); if(des != null){ - ICConfigurationDescription cfg = des.getIndexConfiguration(); + ICConfigurationDescription cfg = des.getDefaultSettingConfiguration(); if(cfg != null) entries = cfg.getResolvedSourceEntries(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProjectInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProjectInfo.java index b865e27e330..ae9f9d08ea9 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProjectInfo.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CProjectInfo.java @@ -22,11 +22,10 @@ import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.IIncludeReference; import org.eclipse.cdt.core.model.ILibraryReference; import org.eclipse.cdt.core.model.IOutputEntry; -import org.eclipse.cdt.core.model.ISourceEntry; import org.eclipse.cdt.core.model.ISourceRoot; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICSourceEntry; -import org.eclipse.cdt.internal.core.settings.model.CProjectDescription; import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; @@ -88,9 +87,9 @@ class CProjectInfo extends OpenableInfo { char[][] exclusionPatterns = null; // try { // entries = cproject.getResolvedPathEntries(); - CProjectDescription des = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(project, false); + ICProjectDescription des = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); if(des != null){ - ICConfigurationDescription cfg = des.getIndexConfiguration(); + ICConfigurationDescription cfg = des.getDefaultSettingConfiguration(); if(cfg != null){ entries = cfg.getResolvedSourceEntries(); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCExtensionProxy.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCExtensionProxy.java index 904a590e31a..0fcde978f3d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCExtensionProxy.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/AbstractCExtensionProxy.java @@ -30,7 +30,7 @@ public abstract class AbstractCExtensionProxy implements ICProjectDescriptionLis public AbstractCExtensionProxy(IProject project, String extPointId) { fProject = project; fExtPointId = extPointId; - CProjectDescriptionManager.getInstance().addListener(this, CProjectDescriptionEvent.LOADDED | CProjectDescriptionEvent.APPLIED); + CProjectDescriptionManager.getInstance().addCProjectDescriptionListener(this, CProjectDescriptionEvent.LOADDED | CProjectDescriptionEvent.APPLIED); } protected final void providerRequested(){ @@ -73,7 +73,7 @@ public abstract class AbstractCExtensionProxy implements ICProjectDescriptionLis boolean newStile = true; ICConfigurationDescription cfg = null; if(des != null){ - cfg = ((CProjectDescription)des).getIndexConfiguration(); + cfg = des.getDefaultSettingConfiguration(); if(cfg != null){ ref = getRef(cfg, false); newStile = CProjectDescriptionManager.getInstance().isNewStyleCfg(cfg); @@ -140,7 +140,7 @@ public abstract class AbstractCExtensionProxy implements ICProjectDescriptionLis } public void close(){ - CProjectDescriptionManager.getInstance().removeListener(this); + CProjectDescriptionManager.getInstance().removeCProjectDescriptionListener(this); if(fProvider != null){ deinitializeProvider(fProvider); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsManager.java index 2acfe09dc60..de9b54aa62d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsManager.java @@ -67,7 +67,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP } public void startup(){ - CProjectDescriptionManager.getInstance().addListener(this, CProjectDescriptionEvent.DATA_APPLIED + CProjectDescriptionManager.getInstance().addCProjectDescriptionListener(this, CProjectDescriptionEvent.DATA_APPLIED | CProjectDescriptionEvent.LOADDED); } @@ -78,7 +78,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP } fFactoryMap.clear(); - CProjectDescriptionManager.getInstance().removeListener(this); + CProjectDescriptionManager.getInstance().removeCProjectDescriptionListener(this); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java index 65937f04c19..1a8cdef02b8 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescription.java @@ -15,12 +15,8 @@ import java.util.Iterator; import java.util.Map; import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.settings.model.ICBuildSetting; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; -import org.eclipse.cdt.core.settings.model.ICFolderDescription; -import org.eclipse.cdt.core.settings.model.ICLanguageSetting; import org.eclipse.cdt.core.settings.model.ICProjectDescription; -import org.eclipse.cdt.core.settings.model.ICResourceDescription; import org.eclipse.cdt.core.settings.model.ICSettingBase; import org.eclipse.cdt.core.settings.model.ICSettingContainer; import org.eclipse.cdt.core.settings.model.ICSettingObject; @@ -31,15 +27,21 @@ import org.eclipse.cdt.core.settings.model.extension.CConfigurationData; import org.eclipse.cdt.core.settings.model.util.CSettingEntryFactory; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.QualifiedName; public class CProjectDescription implements ICProjectDescription, ICDataProxyContainer { - - private ICConfigurationDescription fActiveCfg; - private String fActiveCfgId; - private ICConfigurationDescription fIndexCfg; - private String fIndexCfgId; + private static final String ACTIVE_CFG = "activeConfiguration"; //$NON-NLS-1$ + private static final QualifiedName ACTIVE_CFG_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, ACTIVE_CFG); + private static final String SETTING_CFG = "settingConfiguration"; //$NON-NLS-1$ + private static final QualifiedName SETTING_CFG_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, SETTING_CFG); + + private CfgIdPair fActiveCfgInfo; + private CfgIdPair fSettingCfgInfo; + private CProjectDescriptionPreferences fPrefs; +// private ICConfigurationDescription fActiveCfg; +// private String fActiveCfgId; +// private ICConfigurationDescription fIndexCfg; +// private String fIndexCfgId; private IProject fProject; private ICSettingsStorage fStorage; private ICStorageElement fRootStorageElement; @@ -47,27 +49,130 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon private boolean fIsReadOnly; private boolean fIsModified; private HashMap fPropertiesMap; - private boolean fNeedsActiveCfgIdPersistence; +// private boolean fNeedsActiveCfgIdPersistence; private boolean fIsLoadding; private boolean fIsApplying; + private class CfgIdPair { + private String fId; + private ICConfigurationDescription fCfg; + private QualifiedName fPersistanceName; + private boolean fNeedsPersistance; + private boolean fIsModified; + + CfgIdPair(CfgIdPair base){ + fId = base.fId; + fPersistanceName = base.fPersistanceName; + } + + CfgIdPair(QualifiedName persistanceName){ + fPersistanceName = persistanceName; + } + + public String getId(){ + if(fId == null){ + fId = load(); + if(fId == null){ + fId = getFirstCfgId(); + if(fId != null){ + fNeedsPersistance = true; + } + } + } + return fId; + } + + public ICConfigurationDescription getConfiguration() { + if(fCfg == null){ + String id = getId(); + if(id != null){ + fCfg = getConfigurationById(id); + if(fCfg == null){ + fId = getFirstCfgId(); + if(fId != null){ + fCfg = getConfigurationById(fId); + fNeedsPersistance = true; + } + } + } + } + return fCfg; + } + + public void setConfiguration(ICConfigurationDescription cfg){ + if(cfg.getProjectDescription() != CProjectDescription.this) + throw new IllegalArgumentException(); + + if(cfg.getId().equals(getId())) + return; + + fCfg = cfg; + fId = cfg.getId(); + fIsModified = true; + fNeedsPersistance = true; + } + + public void configurationRemoved(ICConfigurationDescription cfg){ + if(cfg.getProjectDescription() != CProjectDescription.this) + throw new IllegalArgumentException(); + + if(!fCfg.getId().equals(getId())) + return; + + fIsModified = true; + fCfg = null; + getConfiguration(); + } + + private String load(){ + try { + return getProject().getPersistentProperty(fPersistanceName); + } catch (CoreException e) { + CCorePlugin.log(e); + } + return null; + } + + private boolean store(String oldId, boolean force){ + if(force || fIsModified || fNeedsPersistance || oldId == null || !oldId.equals(fId)){ + try { + getProject().setPersistentProperty(fPersistanceName, fId); + fIsModified = false; + fNeedsPersistance = false; + return true; + } catch (CoreException e) { + CCorePlugin.log(e); + } + } + return false; + } + + } CProjectDescription(IProject project, ICStorageElement element, boolean loadding) throws CoreException { fProject = project; fRootStorageElement = element; fIsReadOnly = loadding; fIsLoadding = loadding; - + fActiveCfgInfo = new CfgIdPair(ACTIVE_CFG_PROPERTY); + fSettingCfgInfo = new CfgIdPair(SETTING_CFG_PROPERTY); + ICStorageElement el = null; + CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance(); if(loadding){ - CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance(); Map cfgStorMap = mngr.createCfgStorages(this); for(Iterator iter = cfgStorMap.values().iterator(); iter.hasNext();){ CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache((ICStorageElement)iter.next(), this); configurationCreated(cache); } + + el = getStorage(CProjectDescriptionManager.MODULE_ID, false); } + + fPrefs = new CProjectDescriptionPreferences(el, + (CProjectDescriptionPreferences)mngr.getProjectDescriptionWorkspacePreferences(false), + false); + fPropertiesMap = new HashMap(); -// loadActiveCfgId(); } void updateProject(IProject project){ @@ -123,6 +228,9 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next(); cache.doneInitialization(); } + + if(fIsReadOnly) + fPrefs.setReadOnly(true); } public boolean isLoadding(){ @@ -133,19 +241,17 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon return fIsApplying; } -/* CProjectDescription(IProject project) throws CoreException { - this(project, CProjectDescriptionManager.getInstance().createStorage(project, true, false)); - } -*/ public CProjectDescription(CProjectDescription base, boolean saving, ICStorageElement el) { - fActiveCfgId = base.fActiveCfgId; - fIndexCfgId = base.fIndexCfgId; + fActiveCfgInfo = new CfgIdPair(base.fActiveCfgInfo); + fSettingCfgInfo = new CfgIdPair(base.fSettingCfgInfo); fProject = base.fProject; fRootStorageElement = el; fIsReadOnly = saving; fIsLoadding = base.fIsLoadding; fIsApplying = saving || base.fIsApplying; + fPrefs = new CProjectDescriptionPreferences(base.fPrefs, (CProjectDescriptionPreferences)CProjectDescriptionManager.getInstance().getProjectDescriptionWorkspacePreferences(false), false); + for(Iterator iter = base.fCfgMap.values().iterator(); iter.hasNext();){ try { IInternalCCfgInfo cfgDes = (IInternalCCfgInfo)iter.next(); @@ -183,41 +289,9 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon } public ICConfigurationDescription getActiveConfiguration() { - if(fActiveCfg == null){ - String id = getActiveConfigurationId(); - if(id != null){ - fActiveCfg = getConfigurationById(id); - if(fActiveCfg == null){ - fActiveCfgId = getFirstCfgId(); - if(fActiveCfgId != null){ - fActiveCfg = getConfigurationById(fActiveCfgId); - fNeedsActiveCfgIdPersistence = true; -// storeActiveCfgId(fActiveCfgId); - } - } - } - } - return fActiveCfg; + return fActiveCfgInfo.getConfiguration(); } - private String getActiveConfigurationId(){ - if(fActiveCfgId == null){ - fActiveCfgId = CProjectDescriptionManager.getInstance().loadActiveCfgId(this); - if(fActiveCfgId == null){ - fActiveCfgId = getFirstCfgId(); - if(fActiveCfgId != null){ - fNeedsActiveCfgIdPersistence = true; -// storeActiveCfgId(fActiveCfgId); - } - } - } - return fActiveCfgId; - } - - boolean needsActiveCfgIdPersistence(){ - return fNeedsActiveCfgIdPersistence; - } - private String getFirstCfgId(){ if(!fCfgMap.isEmpty()){ return (String)fCfgMap.keySet().iterator().next(); @@ -255,15 +329,11 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon } void configurationRemoved(CConfigurationDescription des){ - boolean wasActive = des.isActive(); fCfgMap.remove(des.getId()); fIsModified = true; - - if(wasActive){ - fActiveCfg = null; -// fActiveCfgId = null; - getActiveConfiguration(); - } + + fActiveCfgInfo.configurationRemoved(des); + fSettingCfgInfo.configurationRemoved(des); } public void removeConfiguration(ICConfigurationDescription cfg) throws WriteAccessException { @@ -280,14 +350,13 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon if(cfg == null) throw new NullPointerException(); - if(getActiveConfiguration() != cfg){ - fActiveCfgId = cfg.getId(); - fActiveCfg = cfg; - fIsModified = true; -// storeActiveCfgId(fActiveCfgId); - } - } + fActiveCfgInfo.setConfiguration(cfg); + + if(getConfigurationReltations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE) + fSettingCfgInfo.setConfiguration(cfg); + } + public IProject getProject() { return fProject; } @@ -382,6 +451,9 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon if(fIsModified) return true; + if(fPrefs.isModified()) + return true; + if(fRootStorageElement != null && ((InternalXmlStorageElement)fRootStorageElement).isDirty()) return true; @@ -401,32 +473,23 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon return getConfigurationById(id); } - public ICConfigurationDescription getIndexConfiguration(){ - if(fIndexCfg == null){ - String id = getIndexConfigurationId(); - fIndexCfg = getConfigurationById(id); - if(fIndexCfg == null){ - fIndexCfg = getActiveConfiguration(); - if(fIndexCfg != null){ - fIndexCfgId = fIndexCfg.getId(); - } else { - fIndexCfgId = null; - } - } - } - return fIndexCfg; + public ICConfigurationDescription getDefaultSettingConfiguration(){ + if(getConfigurationReltations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE) + return getActiveConfiguration(); + + return fSettingCfgInfo.getConfiguration(); } - - private String getIndexConfigurationId(){ - if(fIndexCfgId == null){ - fIndexCfgId = getActiveConfigurationId(); - } - return fIndexCfgId; - } - - void setIndexConfiguration(ICConfigurationDescription cfg){ - fIndexCfg = cfg; - fIndexCfgId = cfg.getId(); + + public void setDefaultSettingConfiguration(ICConfigurationDescription cfg) throws WriteAccessException { + if(fIsReadOnly) + throw ExceptionFactory.createIsReadOnlyException(); + if(cfg == null) + throw new NullPointerException(); + + fSettingCfgInfo.setConfiguration(cfg); + + if(getConfigurationReltations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE) + fActiveCfgInfo.setConfiguration(cfg); } public Object getSessionProperty(QualifiedName name) { @@ -458,4 +521,49 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon } } } + +// boolean checkPersistCfgChanges(boolean force){ +// boolean stored = false; +// stored |= checkPersistActiveCfg(force); +// stored |= checkPersistSettingCfg(force); +// return stored; +// } + + boolean checkPersistActiveCfg(String oldId, boolean force){ + return fActiveCfgInfo.store(oldId, force); + } + + boolean checkPersistSettingCfg(String oldId, boolean force){ + return fSettingCfgInfo.store(oldId, force); + } + + boolean needsActiveCfgPersistence(){ + return fActiveCfgInfo.fIsModified; + } + + boolean needsSettingCfgPersistence(){ + return fSettingCfgInfo.fIsModified; + } + + CProjectDescriptionPreferences getPreferences(){ + return fPrefs; + } + + public int getConfigurationReltations() { + return fPrefs.getConfigurationReltations(); + } + + public boolean isDefaultConfigurationRelations() { + return fPrefs.isDefaultConfigurationRelations(); + } + + public void setConfigurationRelations(int status) { + fPrefs.setConfigurationRelations(status); + } + + public void useDefaultConfigurationRelations() { + fPrefs.useDefaultConfigurationRelations(); + } + + } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java index cc46ef27d92..8bbac9193a6 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionManager.java @@ -54,6 +54,8 @@ import org.eclipse.cdt.core.settings.model.ICLanguageSetting; import org.eclipse.cdt.core.settings.model.ICLanguageSettingEntry; import org.eclipse.cdt.core.settings.model.ICProjectDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener; +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionWorkspacePreferences; import org.eclipse.cdt.core.settings.model.ICResourceDescription; import org.eclipse.cdt.core.settings.model.ICSettingBase; import org.eclipse.cdt.core.settings.model.ICSettingEntry; @@ -117,16 +119,13 @@ import org.w3c.dom.NodeList; import org.w3c.dom.ProcessingInstruction; import org.xml.sax.SAXException; -public class CProjectDescriptionManager { - private static final String ACTIVE_CFG = "activeConfiguration"; //$NON-NLS-1$ - private static final QualifiedName ACTIVE_CFG_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, ACTIVE_CFG); - +public class CProjectDescriptionManager implements ICProjectDescriptionManager { private static final String OLD_PROJECT_DESCRIPTION = "cdtproject"; //$NON-NLS-1$ private static final String OLD_CDTPROJECT_FILE_NAME = ".cdtproject"; //$NON-NLS-1$ private static final String OLD_PROJECT_OWNER_ID = "id"; //$NON-NLS-1$ private static final String CONVERTED_CFG_NAME = "convertedConfig"; //$NON-NLS-1$ private static final String CONVERTED_CFG_ID_PREFIX = "converted.config"; //$NON-NLS-1$ - + private static final String STORAGE_FILE_NAME = ".cproject"; //$NON-NLS-1$ // private static final QualifiedName PROJECT_DESCRCIPTION_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, "projectDescription"); //$NON-NLS-1$ private static final String ROOT_ELEMENT_NAME = "cproject"; //$NON-NLS-1$ @@ -139,6 +138,7 @@ public class CProjectDescriptionManager { private static final ICLanguageSetting[] EMPTY_LANGUAGE_SETTINGS_ARRAY = new ICLanguageSetting[0]; private static final String PREFERENCES_STORAGE = "preferences"; //$NON-NLS-1$ private static final String PREFERENCE_BUILD_SYSTEM_ELEMENT = "buildSystem"; //$NON-NLS-1$ + private static final String PREFERENCES_ELEMENT = "preferences"; //$NON-NLS-1$ private static final String ID = "id"; //$NON-NLS-1$ private static final String PREFERENCE_CFG_ID_PREFIX = "preference."; //$NON-NLS-1$ private static final String PREFERENCE_CFG_NAME = "Preference Configuration"; //$NON-NLS-1$ @@ -149,33 +149,6 @@ public class CProjectDescriptionManager { private static final QualifiedName SCANNER_INFO_PROVIDER_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, "scannerInfoProvider"); //$NON-NLS-1$ private static final QualifiedName LOAD_FLAG = new QualifiedName(CCorePlugin.PLUGIN_ID, "descriptionLoadded"); //$NON-NLS-1$ -// private class CompositeSafeRunnable implements ISafeRunnable { -// private List fRunnables = new ArrayList(); -// private boolean fStopOnErr; -// -// public void add(ISafeRunnable runnable){ -// fRunnables.add(runnable); -// } -// -// public void handleException(Throwable exception) { -// } -// -// public void run() throws Exception { -// for(Iterator iter = fRunnables.iterator(); iter.hasNext();){ -// ISafeRunnable r = (ISafeRunnable)iter.next(); -// try { -// r.run(); -// } catch (Exception e){ -// r.handleException(e); -// if(fStopOnErr) -// throw e; -// else -// r.handleException(e); -// } -// } -// } -// } - static class CompositeWorkspaceRunnable implements IWorkspaceRunnable { private List fRunnables = new ArrayList(); private String fName; @@ -277,6 +250,7 @@ public class CProjectDescriptionManager { private ThreadLocal fThreadInfo = new ThreadLocal(); private Map fDescriptionMap = new HashMap(); //calls to this map are "manually" synchronized with the CProjectDescriptionManager object lock; private ResourceChangeHandler fRcChangeHandler; + private CProjectDescriptionWorkspacePreferences fPreferences; // private CStorage fPrefCfgStorage; private ICDataProxyContainer fPrefUpdater = new ICDataProxyContainer(){ @@ -928,13 +902,14 @@ public class CProjectDescriptionManager { return getProjectDescription(project, true); } - private void storeActiveCfgId(IProject project, String id){ - try { - project.setPersistentProperty(ACTIVE_CFG_PROPERTY, id); - } catch (CoreException e) { - // Hitting this error just means the default config is not set - } - } +// private void storeActiveCfgId(IProject project, String id){ +// try { +// project.setPersistentProperty(ACTIVE_CFG_PROPERTY, id); +// } catch (CoreException e) { +// // Hitting this error just means the default config is not set +// CCorePlugin.log(e); +// } +// } /* * returns true if the project description was modiofied false - otherwise @@ -948,7 +923,8 @@ public class CProjectDescriptionManager { ICConfigurationDescription oldCfg = oldDes != null ? oldDes.getActiveConfiguration() : null; - checkActiveCfgChange(newDes, newCfg, oldCfg); + checkActiveCfgChange(newDes, oldDes); + checkSettingCfgChange(newDes, oldDes); boolean modified = false; @@ -969,14 +945,14 @@ public class CProjectDescriptionManager { return modified; } - String loadActiveCfgId(ICProjectDescription des){ - try { - return des.getProject().getPersistentProperty(ACTIVE_CFG_PROPERTY); - } catch (CoreException e) { - // Hitting this error just means the default config is not set - } - return null; - } +// String loadActiveCfgId(ICProjectDescription des){ +// try { +// return des.getProject().getPersistentProperty(ACTIVE_CFG_PROPERTY); +// } catch (CoreException e) { +// CCorePlugin.log(e); +// } +// return null; +// } private Set projSetFromProjNameSet(Set projNameSet){ if(projNameSet.size() == 0) @@ -1022,18 +998,31 @@ public class CProjectDescriptionManager { // } private boolean checkActiveCfgChange(CProjectDescription des, - ICConfigurationDescription newCfg, - ICConfigurationDescription oldCfg){ - String newId = newCfg.getId(); + CProjectDescription oldDes +// ICConfigurationDescription newCfg, +// ICConfigurationDescription oldCfg + ){ + ICConfigurationDescription oldCfg = oldDes != null ? oldDes.getActiveConfiguration() : null; +// String newId = newCfg.getId(); String oldId = oldCfg != null ? oldCfg.getId() : null; - if(des.needsActiveCfgIdPersistence() || !newId.equals(oldId)){ - storeActiveCfgId(des.getProject(), newId); - return true; - } - return false; + + return des.checkPersistActiveCfg(oldId, false); } - + + private boolean checkSettingCfgChange(CProjectDescription des, + CProjectDescription oldDes +// ICConfigurationDescription newCfg, +// ICConfigurationDescription oldCfg + ){ + ICConfigurationDescription oldCfg = oldDes != null ? oldDes.getDefaultSettingConfiguration() : null; +// String newId = newCfg.getId(); + String oldId = oldCfg != null ? oldCfg.getId() : null; + + + return des.checkPersistSettingCfg(oldId, false); + } + private boolean checkBuildSystemChange(IProjectDescription des, ICConfigurationDescription newCfg, ICConfigurationDescription oldCfg, @@ -1908,8 +1897,8 @@ public class CProjectDescriptionManager { newCfg = newDes.getActiveConfiguration(); oldCfg = oldDes.getActiveConfiguration(); } else { - newCfg = ((CProjectDescription)newDes).getIndexConfiguration(); - oldCfg = ((CProjectDescription)oldDes).getIndexConfiguration(); + newCfg = newDes.getDefaultSettingConfiguration(); + oldCfg = oldDes.getDefaultSettingConfiguration(); } if(newCfg == null){ @@ -2486,19 +2475,19 @@ public class CProjectDescriptionManager { int kind = projDesDelta.getDeltaKind(); switch(kind){ case ICDescriptionDelta.CHANGED: - CProjectDescription newDes = (CProjectDescription)projDesDelta.getNewSetting(); - CProjectDescription oldDes = (CProjectDescription)projDesDelta.getOldSetting(); + ICProjectDescription newDes = (ICProjectDescription)projDesDelta.getNewSetting(); + ICProjectDescription oldDes = (ICProjectDescription)projDesDelta.getOldSetting(); // int flags = projDesDelta.getChangeFlags(); - ICConfigurationDescription activeCfg = newDes.getActiveConfiguration(); - ICConfigurationDescription indexCfg = newDes.getIndexConfiguration(); - if(indexCfg != activeCfg){ - ICDescriptionDelta delta = findDelta(activeCfg.getId(), projDesDelta); - if(delta != null && delta.getDeltaKind() == ICDescriptionDelta.CHANGED){ - indexCfg = activeCfg; - newDes.setIndexConfiguration(activeCfg); - } - } - ICConfigurationDescription oldIndexCfg = oldDes.getIndexConfiguration(); +// ICConfigurationDescription activeCfg = newDes.getActiveConfiguration(); + ICConfigurationDescription indexCfg = newDes.getDefaultSettingConfiguration(); +// if(indexCfg != activeCfg){ +// ICDescriptionDelta delta = findDelta(activeCfg.getId(), projDesDelta); +// if(delta != null && delta.getDeltaKind() == ICDescriptionDelta.CHANGED){ +// indexCfg = activeCfg; +// newDes.setIndexConfiguration(activeCfg); +// } +// } + ICConfigurationDescription oldIndexCfg = oldDes.getDefaultSettingConfiguration(); ICDescriptionDelta indexDelta; if(oldIndexCfg.getId().equals(indexCfg.getId())){ indexDelta = findDelta(indexCfg.getId(), projDesDelta); @@ -2696,13 +2685,13 @@ public class CProjectDescriptionManager { return kindsArray; } - public void addListener(ICProjectDescriptionListener listener, int eventTypes){ + public void addCProjectDescriptionListener(ICProjectDescriptionListener listener, int eventTypes){ synchronized(this){ fListeners.add(new ListenerDescriptor(listener, eventTypes)); } } - public void removeListener(ICProjectDescriptionListener listener){ + public void removeCProjectDescriptionListener(ICProjectDescriptionListener listener){ synchronized(this){ int size = fListeners.size(); ListenerDescriptor des; @@ -3084,7 +3073,7 @@ public class CProjectDescriptionManager { } public boolean isNewStyleIndexCfg(ICProjectDescription des){ - ICConfigurationDescription cfgDes = ((CProjectDescription)des).getIndexConfiguration(); + ICConfigurationDescription cfgDes = des.getDefaultSettingConfiguration(); if(cfgDes != null) return isNewStyleCfg(cfgDes); return false; @@ -3317,4 +3306,94 @@ public class CProjectDescriptionManager { return false; } + + public ICProjectDescriptionWorkspacePreferences getProjectDescriptionWorkspacePreferences( + boolean write) { + if(fPreferences == null){ + try { + fPreferences = loadPreferences(); + } catch (CoreException e) { + } + if(fPreferences == null) + fPreferences = new CProjectDescriptionWorkspacePreferences((ICStorageElement)null, null, true); + } + + CProjectDescriptionWorkspacePreferences prefs = fPreferences; + + if(write) + prefs = new CProjectDescriptionWorkspacePreferences(prefs, false); + + return prefs; + } + + public boolean setProjectDescriptionWorkspacePreferences(ICProjectDescriptionWorkspacePreferences prefs, + boolean updateProjects, + IProgressMonitor monitor) { + if(monitor == null) + monitor = new NullProgressMonitor(); + boolean changed = false; + ICProjectDescriptionWorkspacePreferences oldPrefs = getProjectDescriptionWorkspacePreferences(false); + try { + do { + if(oldPrefs != prefs){ + if(prefs.getConfigurationReltations() != oldPrefs.getConfigurationReltations()){ + changed = true; + break; + } + } + } while(false); + + if(changed){ + CProjectDescriptionWorkspacePreferences basePrefs; + if(prefs instanceof CProjectDescriptionWorkspacePreferences) + basePrefs = (CProjectDescriptionWorkspacePreferences)prefs; + else + throw new IllegalArgumentException(); + + fPreferences = new CProjectDescriptionWorkspacePreferences(basePrefs, null, true); + + storePreferences(fPreferences); + + if(updateProjects) + updateProjectDescriptions(null, monitor); + } + } catch (CoreException e) { + CCorePlugin.log(e); + } finally { + monitor.done(); + } + + return changed; + } + + private void storePreferences(CProjectDescriptionWorkspacePreferences prefs) throws CoreException { + ICStorageElement el = getCProjectDescriptionPreferencesElement(true, false); + prefs.serialize(el); + saveCProjectDescriptionPreferencesElement(el); + } + + private void saveCProjectDescriptionPreferencesElement(ICStorageElement el) throws CoreException{ + ICStorageElement cur = getCProjectDescriptionPreferencesElement(true, false); + ICStorageElement parent = cur.getParent(); + parent.removeChild(cur); + parent.importChild(el); + savePreferenceStorage(PREFERENCES_STORAGE, MODULE_ID, parent); + } + + private CProjectDescriptionWorkspacePreferences loadPreferences() throws CoreException{ + ICStorageElement el = getCProjectDescriptionPreferencesElement(false, true); + return new CProjectDescriptionWorkspacePreferences(el, null, true); + } + + private ICStorageElement getCProjectDescriptionPreferencesElement(boolean createIfNotFound, boolean readOnly) throws CoreException{ + ICStorageElement el = getPreferenceStorage(PREFERENCES_STORAGE, MODULE_ID, createIfNotFound, readOnly); + ICStorageElement[] children = el.getChildren(); + for(int i = 0; i < children.length; i++){ + if(PREFERENCES_ELEMENT.equals(children[i].getName())) + return children[i]; + } + if(createIfNotFound) + return el.createChild(PREFERENCES_ELEMENT); + throw ExceptionFactory.createCoreException("workspace info element does not exist"); + } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionPreferences.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionPreferences.java new file mode 100644 index 00000000000..de33cd528a5 --- /dev/null +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionPreferences.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * Copyright (c) 2007 Intel Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.settings.model; + +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionPreferences; +import org.eclipse.cdt.core.settings.model.ICStorageElement; +import org.eclipse.cdt.core.settings.model.util.CDataUtil; + +public class CProjectDescriptionPreferences implements ICProjectDescriptionPreferences { + private static final String ATTR_CONFIG_RELATIONS = "configRelations"; //$NON-NLS-1$ + + private static final int DEFAULT_RELATIONS = CONFIGS_INDEPENDENT; + private boolean fIsReadOnly; + private boolean fIsModified; + + private Integer fConfigRelations; + private CProjectDescriptionPreferences fSuperPreference; + + CProjectDescriptionPreferences(CProjectDescriptionPreferences base, boolean isReadOnly){ + this(base, base.fSuperPreference, isReadOnly); + } + + CProjectDescriptionPreferences(CProjectDescriptionPreferences base, CProjectDescriptionPreferences superPreference, boolean isReadOnly){ + fConfigRelations = base.fConfigRelations; + fSuperPreference = superPreference; + fIsReadOnly = isReadOnly; + } + + CProjectDescriptionPreferences(ICStorageElement el, CProjectDescriptionPreferences superPreference, boolean isReadOnly){ + fIsReadOnly = isReadOnly; + if(el != null){ + if(el.getAttribute(ATTR_CONFIG_RELATIONS) != null) + fConfigRelations = new Integer(CDataUtil.getInteger(el, ATTR_CONFIG_RELATIONS, DEFAULT_RELATIONS)); + } + + this.fSuperPreference = superPreference; + } + + protected CProjectDescriptionPreferences getSuperPreferences(){ + if(isReadOnly()) + return fSuperPreference; + return (CProjectDescriptionPreferences)CProjectDescriptionManager.getInstance().getProjectDescriptionWorkspacePreferences(false); + } + + void serialize(ICStorageElement el){ + if(fConfigRelations != null) + CDataUtil.setInteger(el, ATTR_CONFIG_RELATIONS, fConfigRelations.intValue()); + } + + public int getConfigurationReltations() { + if(fConfigRelations != null) + return fConfigRelations.intValue(); + CProjectDescriptionPreferences superPrefs = getSuperPreferences(); + if(superPrefs != null) + return superPrefs.getConfigurationReltations(); + return DEFAULT_RELATIONS; + } + + public boolean isDefaultConfigurationRelations() { + return fConfigRelations == null; + } + + public void setConfigurationRelations(int status) { + if(fIsReadOnly) + throw ExceptionFactory.createIsReadOnlyException(); + if(fConfigRelations != null && fConfigRelations.intValue() == status) + return; + + fConfigRelations = new Integer(status); + fIsModified = true; + } + + public void useDefaultConfigurationRelations() { + if(fIsReadOnly) + throw ExceptionFactory.createIsReadOnlyException(); + + if(fConfigRelations == null) + return; + + fConfigRelations = null; + fIsModified = true; + } + + public boolean isModified(){ + return fIsModified + || (fSuperPreference != null + && !fSuperPreference.settingsEqual((CProjectDescriptionPreferences)CProjectDescriptionManager.getInstance().getProjectDescriptionWorkspacePreferences(false))); + } + + public boolean isReadOnly(){ + return fIsReadOnly; + } + + void setReadOnly(boolean readOnly){ + fIsReadOnly = readOnly; + } + + public boolean settingsEqual(CProjectDescriptionPreferences other){ + if(isDefaultConfigurationRelations() != other.isDefaultConfigurationRelations()) + return false; + + if(getConfigurationReltations() != other.getConfigurationReltations()) + return false; + + return true; + } +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionWorkspacePreferences.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionWorkspacePreferences.java new file mode 100644 index 00000000000..43de5854da7 --- /dev/null +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CProjectDescriptionWorkspacePreferences.java @@ -0,0 +1,34 @@ +/******************************************************************************* + * Copyright (c) 2007 Intel Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Intel Corporation - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.settings.model; + +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionWorkspacePreferences; +import org.eclipse.cdt.core.settings.model.ICStorageElement; + +public class CProjectDescriptionWorkspacePreferences extends + CProjectDescriptionPreferences implements ICProjectDescriptionWorkspacePreferences{ + + public CProjectDescriptionWorkspacePreferences( + CProjectDescriptionPreferences base, boolean isReadOnly) { + super(base, isReadOnly); + } + + public CProjectDescriptionWorkspacePreferences( + CProjectDescriptionPreferences base, + CProjectDescriptionPreferences superPreference, boolean isReadOnly) { + super(base, superPreference, isReadOnly); + } + + public CProjectDescriptionWorkspacePreferences(ICStorageElement el, + CProjectDescriptionPreferences superPreference, boolean isReadOnly) { + super(el, superPreference, isReadOnly); + } +} diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgExportSettingContainerFactory.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgExportSettingContainerFactory.java index 95b35fc1f83..d903be62fc3 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgExportSettingContainerFactory.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CfgExportSettingContainerFactory.java @@ -49,13 +49,13 @@ public class CfgExportSettingContainerFactory extends } public void startup(){ - CProjectDescriptionManager.getInstance().addListener(this, + CProjectDescriptionManager.getInstance().addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADDED); } public void shutdown(){ - CProjectDescriptionManager.getInstance().removeListener(this); + CProjectDescriptionManager.getInstance().removeCProjectDescriptionListener(this); } private class CfgRefContainer extends CExternalSettingsContainer { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java index 2a4abbf3fd8..a21ee00eb01 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ConfigBasedPathEntryStore.java @@ -53,7 +53,7 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc fProject = project; fListeners = Collections.synchronizedList(new ArrayList()); - CProjectDescriptionManager.getInstance().addListener(this, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADDED); + CProjectDescriptionManager.getInstance().addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADDED); } /* (non-Javadoc) @@ -89,7 +89,7 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc for (int i = 0; i < observers.length; i++) { observers[i].pathEntryStoreChanged(evt); } - CProjectDescriptionManager.getInstance().removeListener(this); + CProjectDescriptionManager.getInstance().removeCProjectDescriptionListener(this); } public IProject getProject() { @@ -123,8 +123,8 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc // usrList.add(entries[i]); // } - CProjectDescription des = (CProjectDescription)CoreModel.getDefault().getProjectDescription(fProject, true); - ICConfigurationDescription cfgDes = des.getIndexConfiguration(); + ICProjectDescription des = CoreModel.getDefault().getProjectDescription(fProject, true); + ICConfigurationDescription cfgDes = des.getDefaultSettingConfiguration(); CConfigurationData data = cfgDes.getConfigurationData(); PathEntryTranslator tr = new PathEntryTranslator(fProject, data); IPathEntry[] usrEntries = (IPathEntry[])usrList.toArray(new IPathEntry[usrList.size()]); @@ -160,11 +160,11 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc switch(event.getEventType()){ case CProjectDescriptionEvent.APPLIED:{ - CProjectDescription des = (CProjectDescription)event.getNewCProjectDescription(); - CProjectDescription oldDes = (CProjectDescription)event.getOldCProjectDescription(); + ICProjectDescription des = event.getNewCProjectDescription(); + ICProjectDescription oldDes = event.getOldCProjectDescription(); List oldCrEntries = null; if(oldDes != null){ - ICConfigurationDescription oldIndexCfg = oldDes.getIndexConfiguration(); + ICConfigurationDescription oldIndexCfg = oldDes.getDefaultSettingConfiguration(); List[] oldEs = getCachedEntries(oldIndexCfg); if(oldEs != null) oldCrEntries = oldEs[1]; @@ -176,7 +176,7 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc clearCachedEntries(des); if(oldCrEntries != null){ - ICConfigurationDescription newIndexCfg = des.getIndexConfiguration(); + ICConfigurationDescription newIndexCfg = des.getDefaultSettingConfiguration(); List[] newEs = getEntries(fProject, newIndexCfg); List newCrEntries = newEs[1]; if(!Arrays.equals(oldCrEntries.toArray(), newCrEntries.toArray())){ @@ -253,8 +253,8 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc // } private static ICConfigurationDescription getIndexCfg(IProject project){ - CProjectDescription des = (CProjectDescription)CCorePlugin.getDefault().getProjectDescription(project, false); - return des.getIndexConfiguration(); + ICProjectDescription des = CCorePlugin.getDefault().getProjectDescription(project, false); + return des.getDefaultSettingConfiguration(); } private static List getContainerEntries(IProject project){ @@ -265,7 +265,7 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc } private static List getContainerEntries(ICProjectDescription des){ - ICConfigurationDescription cfg = ((CProjectDescription)des).getIndexConfiguration(); + ICConfigurationDescription cfg = des.getDefaultSettingConfiguration(); List es[] = getEntries(des.getProject(), cfg); if(es != null) return es[1]; diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java index b2cd874d6cd..02dc568d47d 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/DescriptionScannerInfoProvider.java @@ -53,14 +53,14 @@ public class DescriptionScannerInfoProvider implements IScannerInfoProvider, ICP DescriptionScannerInfoProvider(IProject project){ fProject = project; - CProjectDescriptionManager.getInstance().addListener(this, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADDED); + CProjectDescriptionManager.getInstance().addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADDED); } private void updateProjCfgInfo(ICProjectDescription des){ fInited = true; fProjDes = des; if(fProjDes != null){ - fCfgDes = ((CProjectDescription)des).getIndexConfiguration(); + fCfgDes = des.getDefaultSettingConfiguration(); } fIdToLanguageSettingsMap.clear(); @@ -267,7 +267,7 @@ public class DescriptionScannerInfoProvider implements IScannerInfoProvider, ICP } public void close(){ - CProjectDescriptionManager.getInstance().removeListener(this); + CProjectDescriptionManager.getInstance().removeCProjectDescriptionListener(this); } public void handleEvent(CProjectDescriptionEvent event) { diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ScannerInfoProviderProxy.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ScannerInfoProviderProxy.java index 5a9cba03edc..2c985e9411c 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ScannerInfoProviderProxy.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ScannerInfoProviderProxy.java @@ -32,7 +32,7 @@ public class ScannerInfoProviderProxy extends AbstractCExtensionProxy implements public ScannerInfoProviderProxy(IProject project) { super(project, CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID); - CProjectDescriptionManager.getInstance().addListener(this, CProjectDescriptionEvent.LOADDED | CProjectDescriptionEvent.APPLIED); + CProjectDescriptionManager.getInstance().addCProjectDescriptionListener(this, CProjectDescriptionEvent.LOADDED | CProjectDescriptionEvent.APPLIED); } public IScannerInfo getScannerInformation(IResource resource) { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java index 36e6d9a2c13..fa60279a3fb 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/CCorePlugin.java @@ -38,6 +38,7 @@ import org.eclipse.cdt.core.resources.IConsole; import org.eclipse.cdt.core.resources.IPathEntryVariableManager; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICProjectDescription; +import org.eclipse.cdt.core.settings.model.ICProjectDescriptionManager; import org.eclipse.cdt.core.settings.model.WriteAccessException; import org.eclipse.cdt.core.settings.model.util.CDataUtil; import org.eclipse.cdt.internal.core.CConfigBasedDescriptorManager; @@ -1248,4 +1249,8 @@ public class CCorePlugin extends Plugin { public boolean isNewStyleProject(ICProjectDescription des){ return fNewCProjectDescriptionManager.isNewStyleProject(des); } + + public ICProjectDescriptionManager getProjectDescriptionManager(){ + return fNewCProjectDescriptionManager; + } } \ No newline at end of file diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptorManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptorManager.java index 933b7c1a9aa..9365c85a1ab 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptorManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/core/CConfigBasedDescriptorManager.java @@ -307,7 +307,7 @@ public class CConfigBasedDescriptorManager implements ICDescriptorManager { if(des.isReadOnly()) des = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(des.getProject(), true); - ICConfigurationDescription cfgDes = des.getIndexConfiguration(); + ICConfigurationDescription cfgDes = des.getDefaultSettingConfiguration(); if(cfgDes != null){ @@ -362,13 +362,13 @@ public class CConfigBasedDescriptorManager implements ICDescriptorManager { } }; - CProjectDescriptionManager.getInstance().addListener(fDescriptionListener, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADDED | CProjectDescriptionEvent.DATA_APPLIED | CProjectDescriptionEvent.ABOUT_TO_APPLY); + CProjectDescriptionManager.getInstance().addCProjectDescriptionListener(fDescriptionListener, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADDED | CProjectDescriptionEvent.DATA_APPLIED | CProjectDescriptionEvent.ABOUT_TO_APPLY); } } public void shutdown(){ if(fDescriptionListener != null){ - CProjectDescriptionManager.getInstance().removeListener(fDescriptionListener); + CProjectDescriptionManager.getInstance().removeCProjectDescriptionListener(fDescriptionListener); } } @@ -381,7 +381,7 @@ public class CConfigBasedDescriptorManager implements ICDescriptorManager { if(dr != null){ //the descriptor was requested while load process des = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(des.getProject(), true); - ICConfigurationDescription cfgDescription = des.getIndexConfiguration(); + ICConfigurationDescription cfgDescription = des.getDefaultSettingConfiguration(); if(cfgDescription != null){ dr.updateConfiguration((CConfigurationDescription)cfgDescription); dr.setDirty(false); @@ -419,7 +419,7 @@ public class CConfigBasedDescriptorManager implements ICDescriptorManager { ICConfigurationDescription updatedCfg = null; if(oldDes == null){ dr = findDescriptor(newDes); - updatedCfg = newDes.getIndexConfiguration(); + updatedCfg = newDes.getDefaultSettingConfiguration(); if(dr != null){ desEvent = new CDescriptorEvent(dr, CDescriptorEvent.CDTPROJECT_ADDED, 0); } @@ -430,10 +430,10 @@ public class CConfigBasedDescriptorManager implements ICDescriptorManager { } } else { dr = findDescriptor(newDes); - updatedCfg = newDes.getIndexConfiguration(); + updatedCfg = newDes.getDefaultSettingConfiguration(); if(dr != null){ - ICConfigurationDescription newCfg = newDes.getIndexConfiguration(); - ICConfigurationDescription oldCfg = oldDes.getIndexConfiguration(); + ICConfigurationDescription newCfg = newDes.getDefaultSettingConfiguration(); + ICConfigurationDescription oldCfg = oldDes.getDefaultSettingConfiguration(); int flags = 0; if(newCfg.getId().equals(oldCfg.getId())){ ICDescriptionDelta cfgDelta = findCfgDelta(event.getProjectDelta(), newCfg.getId()); @@ -453,7 +453,7 @@ public class CConfigBasedDescriptorManager implements ICDescriptorManager { if(updatedCfg != null && dr != null){ CProjectDescription writableDes = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(event.getProject(), true); - ICConfigurationDescription indexCfg = writableDes.getIndexConfiguration(); + ICConfigurationDescription indexCfg = writableDes.getDefaultSettingConfiguration(); dr.updateConfiguration((CConfigurationDescription)indexCfg); dr.setDirty(false); }