mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-08 00:35:49 +02:00
1. Fix and test-case for the "Index" config selection mechanism for [Bug 172919] What to do about the index with multiple build configurations
2. The "Index" config setting is renamed to "DefaultSetting" config and exported to the public API
This commit is contained in:
parent
67538ff936
commit
835999aa31
24 changed files with 962 additions and 216 deletions
|
@ -25,6 +25,7 @@ public class CProjectDescriptionTests {
|
||||||
// each class being tested
|
// each class being tested
|
||||||
suite.addTest(CConfigurationDescriptionReferenceTests.suite());
|
suite.addTest(CConfigurationDescriptionReferenceTests.suite());
|
||||||
suite.addTest(ExternalSettingsProviderTests.suite());
|
suite.addTest(ExternalSettingsProviderTests.suite());
|
||||||
|
suite.addTest(CfgSettingsTests.suite());
|
||||||
return suite;
|
return suite;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -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.ICLanguageSettingEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener;
|
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.core.settings.model.WriteAccessException;
|
||||||
import org.eclipse.cdt.internal.core.model.APathEntry;
|
import org.eclipse.cdt.internal.core.model.APathEntry;
|
||||||
import org.eclipse.cdt.internal.core.model.BatchOperation;
|
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.ProjectEntry;
|
||||||
import org.eclipse.cdt.internal.core.model.SourceEntry;
|
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.CLanguageSettingCache;
|
||||||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescription;
|
|
||||||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IFolder;
|
import org.eclipse.core.resources.IFolder;
|
||||||
|
@ -1232,9 +1232,9 @@ public class CoreModel {
|
||||||
public static boolean isScannerInformationEmpty(IResource resource) {
|
public static boolean isScannerInformationEmpty(IResource resource) {
|
||||||
IProject project = resource.getProject();
|
IProject project = resource.getProject();
|
||||||
CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance();
|
CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance();
|
||||||
CProjectDescription des = (CProjectDescription)mngr.getProjectDescription(project, false);
|
ICProjectDescription des = mngr.getProjectDescription(project, false);
|
||||||
if(des != null){
|
if(des != null){
|
||||||
ICConfigurationDescription indexCfg = des.getIndexConfiguration();
|
ICConfigurationDescription indexCfg = des.getDefaultSettingConfiguration();
|
||||||
if(indexCfg != null){
|
if(indexCfg != null){
|
||||||
if(!mngr.isNewStyleCfg(indexCfg)){
|
if(!mngr.isNewStyleCfg(indexCfg)){
|
||||||
return oldIsScannerInformationEmpty(resource);
|
return oldIsScannerInformationEmpty(resource);
|
||||||
|
@ -1424,10 +1424,14 @@ public class CoreModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCProjectDescriptionListener(ICProjectDescriptionListener listener, int eventTypes){
|
public void addCProjectDescriptionListener(ICProjectDescriptionListener listener, int eventTypes){
|
||||||
descriptionManager.addListener(listener, eventTypes);
|
descriptionManager.addCProjectDescriptionListener(listener, eventTypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeCProjectDescriptionListener(ICProjectDescriptionListener listener){
|
public void removeCProjectDescriptionListener(ICProjectDescriptionListener listener){
|
||||||
descriptionManager.removeListener(listener);
|
descriptionManager.removeCProjectDescriptionListener(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ICProjectDescriptionManager getProjectDescriptionManager(){
|
||||||
|
return descriptionManager;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.settings.model;
|
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.CProjectDescriptionDelta;
|
||||||
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
import org.eclipse.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
||||||
import org.eclipse.cdt.internal.core.settings.model.ICDescriptionDelta;
|
import org.eclipse.cdt.internal.core.settings.model.ICDescriptionDelta;
|
||||||
|
@ -69,7 +68,7 @@ public final class CProjectDescriptionEvent {
|
||||||
return fActiveCfgDelta;
|
return fActiveCfgDelta;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICDescriptionDelta getIndexCfgDelta(){
|
public ICDescriptionDelta getDefaultSettingCfgDelta(){
|
||||||
if(fIndexCfgDelta == null){
|
if(fIndexCfgDelta == null){
|
||||||
fIndexCfgDelta = getDelta(false);
|
fIndexCfgDelta = getDelta(false);
|
||||||
}
|
}
|
||||||
|
@ -121,7 +120,7 @@ public final class CProjectDescriptionEvent {
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICConfigurationDescription getCfg(ICProjectDescription des, boolean active){
|
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){
|
private ICDescriptionDelta findCfgDelta(ICDescriptionDelta delta, String id){
|
||||||
|
|
|
@ -23,7 +23,11 @@ import org.eclipse.core.runtime.QualifiedName;
|
||||||
* @see CoreModel#getProjectDescription(IProject, boolean)
|
* @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
|
* returns an array of configurations available for this project
|
||||||
*
|
*
|
||||||
|
@ -140,4 +144,8 @@ public interface ICProjectDescription extends ICSettingContainer, ICSettingObje
|
||||||
* @param value
|
* @param value
|
||||||
*/
|
*/
|
||||||
void setSessionProperty(QualifiedName name, Object value);
|
void setSessionProperty(QualifiedName name, Object value);
|
||||||
|
|
||||||
|
ICConfigurationDescription getDefaultSettingConfiguration();
|
||||||
|
|
||||||
|
void setDefaultSettingConfiguration(ICConfigurationDescription cfg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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 <code>projects</code> argument is <code>null</code> 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);
|
||||||
|
}
|
|
@ -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();
|
||||||
|
}
|
|
@ -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 {
|
||||||
|
|
||||||
|
}
|
|
@ -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.ICSettingBase;
|
||||||
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.ICSourceEntry;
|
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.CBuildData;
|
||||||
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
|
import org.eclipse.cdt.core.settings.model.extension.CConfigurationData;
|
||||||
import org.eclipse.cdt.core.settings.model.extension.CFolderData;
|
import org.eclipse.cdt.core.settings.model.extension.CFolderData;
|
||||||
|
@ -766,5 +767,35 @@ public class CDataUtil {
|
||||||
}
|
}
|
||||||
return map;
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,8 @@ import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
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.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.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
@ -70,9 +70,9 @@ public class CContainerInfo extends OpenableInfo {
|
||||||
|
|
||||||
// IPathEntry[] entries = cproject.getResolvedPathEntries();
|
// IPathEntry[] entries = cproject.getResolvedPathEntries();
|
||||||
ICSourceEntry[] entries = null;
|
ICSourceEntry[] entries = null;
|
||||||
CProjectDescription des = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(cproject.getProject(), false);
|
ICProjectDescription des = CProjectDescriptionManager.getInstance().getProjectDescription(cproject.getProject(), false);
|
||||||
if(des != null){
|
if(des != null){
|
||||||
ICConfigurationDescription cfg = des.getIndexConfiguration();
|
ICConfigurationDescription cfg = des.getDefaultSettingConfiguration();
|
||||||
if(cfg != null){
|
if(cfg != null){
|
||||||
entries = cfg.getResolvedSourceEntries();
|
entries = cfg.getResolvedSourceEntries();
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,8 @@ import org.eclipse.cdt.core.model.ISourceEntry;
|
||||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
import org.eclipse.cdt.core.settings.model.CSourceEntry;
|
import org.eclipse.cdt.core.settings.model.CSourceEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
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.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.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
@ -603,9 +603,9 @@ public class CProject extends Openable implements ICProject {
|
||||||
protected List computeSourceRoots() throws CModelException {
|
protected List computeSourceRoots() throws CModelException {
|
||||||
//IPathEntry[] entries = getResolvedPathEntries();
|
//IPathEntry[] entries = getResolvedPathEntries();
|
||||||
ICSourceEntry[] entries = null;
|
ICSourceEntry[] entries = null;
|
||||||
CProjectDescription des = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(getProject(), false);
|
ICProjectDescription des = CProjectDescriptionManager.getInstance().getProjectDescription(getProject(), false);
|
||||||
if(des != null){
|
if(des != null){
|
||||||
ICConfigurationDescription cfg = des.getIndexConfiguration();
|
ICConfigurationDescription cfg = des.getDefaultSettingConfiguration();
|
||||||
if(cfg != null)
|
if(cfg != null)
|
||||||
entries = cfg.getResolvedSourceEntries();
|
entries = cfg.getResolvedSourceEntries();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,10 @@ import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.IIncludeReference;
|
import org.eclipse.cdt.core.model.IIncludeReference;
|
||||||
import org.eclipse.cdt.core.model.ILibraryReference;
|
import org.eclipse.cdt.core.model.ILibraryReference;
|
||||||
import org.eclipse.cdt.core.model.IOutputEntry;
|
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.model.ISourceRoot;
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
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.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.cdt.internal.core.settings.model.CProjectDescriptionManager;
|
||||||
import org.eclipse.core.resources.IContainer;
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
|
@ -88,9 +87,9 @@ class CProjectInfo extends OpenableInfo {
|
||||||
char[][] exclusionPatterns = null;
|
char[][] exclusionPatterns = null;
|
||||||
// try {
|
// try {
|
||||||
// entries = cproject.getResolvedPathEntries();
|
// entries = cproject.getResolvedPathEntries();
|
||||||
CProjectDescription des = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
|
ICProjectDescription des = CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
|
||||||
if(des != null){
|
if(des != null){
|
||||||
ICConfigurationDescription cfg = des.getIndexConfiguration();
|
ICConfigurationDescription cfg = des.getDefaultSettingConfiguration();
|
||||||
if(cfg != null){
|
if(cfg != null){
|
||||||
entries = cfg.getResolvedSourceEntries();
|
entries = cfg.getResolvedSourceEntries();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ public abstract class AbstractCExtensionProxy implements ICProjectDescriptionLis
|
||||||
public AbstractCExtensionProxy(IProject project, String extPointId) {
|
public AbstractCExtensionProxy(IProject project, String extPointId) {
|
||||||
fProject = project;
|
fProject = project;
|
||||||
fExtPointId = extPointId;
|
fExtPointId = extPointId;
|
||||||
CProjectDescriptionManager.getInstance().addListener(this, CProjectDescriptionEvent.LOADDED | CProjectDescriptionEvent.APPLIED);
|
CProjectDescriptionManager.getInstance().addCProjectDescriptionListener(this, CProjectDescriptionEvent.LOADDED | CProjectDescriptionEvent.APPLIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected final void providerRequested(){
|
protected final void providerRequested(){
|
||||||
|
@ -73,7 +73,7 @@ public abstract class AbstractCExtensionProxy implements ICProjectDescriptionLis
|
||||||
boolean newStile = true;
|
boolean newStile = true;
|
||||||
ICConfigurationDescription cfg = null;
|
ICConfigurationDescription cfg = null;
|
||||||
if(des != null){
|
if(des != null){
|
||||||
cfg = ((CProjectDescription)des).getIndexConfiguration();
|
cfg = des.getDefaultSettingConfiguration();
|
||||||
if(cfg != null){
|
if(cfg != null){
|
||||||
ref = getRef(cfg, false);
|
ref = getRef(cfg, false);
|
||||||
newStile = CProjectDescriptionManager.getInstance().isNewStyleCfg(cfg);
|
newStile = CProjectDescriptionManager.getInstance().isNewStyleCfg(cfg);
|
||||||
|
@ -140,7 +140,7 @@ public abstract class AbstractCExtensionProxy implements ICProjectDescriptionLis
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close(){
|
public void close(){
|
||||||
CProjectDescriptionManager.getInstance().removeListener(this);
|
CProjectDescriptionManager.getInstance().removeCProjectDescriptionListener(this);
|
||||||
if(fProvider != null){
|
if(fProvider != null){
|
||||||
deinitializeProvider(fProvider);
|
deinitializeProvider(fProvider);
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startup(){
|
public void startup(){
|
||||||
CProjectDescriptionManager.getInstance().addListener(this, CProjectDescriptionEvent.DATA_APPLIED
|
CProjectDescriptionManager.getInstance().addCProjectDescriptionListener(this, CProjectDescriptionEvent.DATA_APPLIED
|
||||||
| CProjectDescriptionEvent.LOADDED);
|
| CProjectDescriptionEvent.LOADDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
}
|
}
|
||||||
fFactoryMap.clear();
|
fFactoryMap.clear();
|
||||||
|
|
||||||
CProjectDescriptionManager.getInstance().removeListener(this);
|
CProjectDescriptionManager.getInstance().removeCProjectDescriptionListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,8 @@ import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
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.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.ICProjectDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICResourceDescription;
|
|
||||||
import org.eclipse.cdt.core.settings.model.ICSettingBase;
|
import org.eclipse.cdt.core.settings.model.ICSettingBase;
|
||||||
import org.eclipse.cdt.core.settings.model.ICSettingContainer;
|
import org.eclipse.cdt.core.settings.model.ICSettingContainer;
|
||||||
import org.eclipse.cdt.core.settings.model.ICSettingObject;
|
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.cdt.core.settings.model.util.CSettingEntryFactory;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
import org.eclipse.core.runtime.QualifiedName;
|
||||||
|
|
||||||
public class CProjectDescription implements ICProjectDescription, ICDataProxyContainer {
|
public class CProjectDescription implements ICProjectDescription, ICDataProxyContainer {
|
||||||
|
private static final String ACTIVE_CFG = "activeConfiguration"; //$NON-NLS-1$
|
||||||
private ICConfigurationDescription fActiveCfg;
|
private static final QualifiedName ACTIVE_CFG_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, ACTIVE_CFG);
|
||||||
private String fActiveCfgId;
|
private static final String SETTING_CFG = "settingConfiguration"; //$NON-NLS-1$
|
||||||
private ICConfigurationDescription fIndexCfg;
|
private static final QualifiedName SETTING_CFG_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, SETTING_CFG);
|
||||||
private String fIndexCfgId;
|
|
||||||
|
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 IProject fProject;
|
||||||
private ICSettingsStorage fStorage;
|
private ICSettingsStorage fStorage;
|
||||||
private ICStorageElement fRootStorageElement;
|
private ICStorageElement fRootStorageElement;
|
||||||
|
@ -47,27 +49,130 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
private boolean fIsReadOnly;
|
private boolean fIsReadOnly;
|
||||||
private boolean fIsModified;
|
private boolean fIsModified;
|
||||||
private HashMap fPropertiesMap;
|
private HashMap fPropertiesMap;
|
||||||
private boolean fNeedsActiveCfgIdPersistence;
|
// private boolean fNeedsActiveCfgIdPersistence;
|
||||||
private boolean fIsLoadding;
|
private boolean fIsLoadding;
|
||||||
private boolean fIsApplying;
|
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 {
|
CProjectDescription(IProject project, ICStorageElement element, boolean loadding) throws CoreException {
|
||||||
fProject = project;
|
fProject = project;
|
||||||
fRootStorageElement = element;
|
fRootStorageElement = element;
|
||||||
fIsReadOnly = loadding;
|
fIsReadOnly = loadding;
|
||||||
fIsLoadding = loadding;
|
fIsLoadding = loadding;
|
||||||
|
fActiveCfgInfo = new CfgIdPair(ACTIVE_CFG_PROPERTY);
|
||||||
|
fSettingCfgInfo = new CfgIdPair(SETTING_CFG_PROPERTY);
|
||||||
|
ICStorageElement el = null;
|
||||||
|
CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance();
|
||||||
if(loadding){
|
if(loadding){
|
||||||
CProjectDescriptionManager mngr = CProjectDescriptionManager.getInstance();
|
|
||||||
Map cfgStorMap = mngr.createCfgStorages(this);
|
Map cfgStorMap = mngr.createCfgStorages(this);
|
||||||
|
|
||||||
for(Iterator iter = cfgStorMap.values().iterator(); iter.hasNext();){
|
for(Iterator iter = cfgStorMap.values().iterator(); iter.hasNext();){
|
||||||
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache((ICStorageElement)iter.next(), this);
|
CConfigurationDescriptionCache cache = new CConfigurationDescriptionCache((ICStorageElement)iter.next(), this);
|
||||||
configurationCreated(cache);
|
configurationCreated(cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
el = getStorage(CProjectDescriptionManager.MODULE_ID, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fPrefs = new CProjectDescriptionPreferences(el,
|
||||||
|
(CProjectDescriptionPreferences)mngr.getProjectDescriptionWorkspacePreferences(false),
|
||||||
|
false);
|
||||||
|
|
||||||
fPropertiesMap = new HashMap();
|
fPropertiesMap = new HashMap();
|
||||||
// loadActiveCfgId();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateProject(IProject project){
|
void updateProject(IProject project){
|
||||||
|
@ -123,6 +228,9 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next();
|
CConfigurationDescriptionCache cache = (CConfigurationDescriptionCache)iter.next();
|
||||||
cache.doneInitialization();
|
cache.doneInitialization();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(fIsReadOnly)
|
||||||
|
fPrefs.setReadOnly(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLoadding(){
|
public boolean isLoadding(){
|
||||||
|
@ -133,19 +241,17 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
return fIsApplying;
|
return fIsApplying;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CProjectDescription(IProject project) throws CoreException {
|
|
||||||
this(project, CProjectDescriptionManager.getInstance().createStorage(project, true, false));
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
public CProjectDescription(CProjectDescription base, boolean saving, ICStorageElement el) {
|
public CProjectDescription(CProjectDescription base, boolean saving, ICStorageElement el) {
|
||||||
fActiveCfgId = base.fActiveCfgId;
|
fActiveCfgInfo = new CfgIdPair(base.fActiveCfgInfo);
|
||||||
fIndexCfgId = base.fIndexCfgId;
|
fSettingCfgInfo = new CfgIdPair(base.fSettingCfgInfo);
|
||||||
fProject = base.fProject;
|
fProject = base.fProject;
|
||||||
fRootStorageElement = el;
|
fRootStorageElement = el;
|
||||||
fIsReadOnly = saving;
|
fIsReadOnly = saving;
|
||||||
fIsLoadding = base.fIsLoadding;
|
fIsLoadding = base.fIsLoadding;
|
||||||
fIsApplying = saving || base.fIsApplying;
|
fIsApplying = saving || base.fIsApplying;
|
||||||
|
|
||||||
|
fPrefs = new CProjectDescriptionPreferences(base.fPrefs, (CProjectDescriptionPreferences)CProjectDescriptionManager.getInstance().getProjectDescriptionWorkspacePreferences(false), false);
|
||||||
|
|
||||||
for(Iterator iter = base.fCfgMap.values().iterator(); iter.hasNext();){
|
for(Iterator iter = base.fCfgMap.values().iterator(); iter.hasNext();){
|
||||||
try {
|
try {
|
||||||
IInternalCCfgInfo cfgDes = (IInternalCCfgInfo)iter.next();
|
IInternalCCfgInfo cfgDes = (IInternalCCfgInfo)iter.next();
|
||||||
|
@ -183,41 +289,9 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICConfigurationDescription getActiveConfiguration() {
|
public ICConfigurationDescription getActiveConfiguration() {
|
||||||
if(fActiveCfg == null){
|
return fActiveCfgInfo.getConfiguration();
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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(){
|
private String getFirstCfgId(){
|
||||||
if(!fCfgMap.isEmpty()){
|
if(!fCfgMap.isEmpty()){
|
||||||
return (String)fCfgMap.keySet().iterator().next();
|
return (String)fCfgMap.keySet().iterator().next();
|
||||||
|
@ -255,15 +329,11 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
}
|
}
|
||||||
|
|
||||||
void configurationRemoved(CConfigurationDescription des){
|
void configurationRemoved(CConfigurationDescription des){
|
||||||
boolean wasActive = des.isActive();
|
|
||||||
fCfgMap.remove(des.getId());
|
fCfgMap.remove(des.getId());
|
||||||
fIsModified = true;
|
fIsModified = true;
|
||||||
|
|
||||||
if(wasActive){
|
fActiveCfgInfo.configurationRemoved(des);
|
||||||
fActiveCfg = null;
|
fSettingCfgInfo.configurationRemoved(des);
|
||||||
// fActiveCfgId = null;
|
|
||||||
getActiveConfiguration();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeConfiguration(ICConfigurationDescription cfg) throws WriteAccessException {
|
public void removeConfiguration(ICConfigurationDescription cfg) throws WriteAccessException {
|
||||||
|
@ -280,14 +350,13 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
if(cfg == null)
|
if(cfg == null)
|
||||||
throw new NullPointerException();
|
throw new NullPointerException();
|
||||||
|
|
||||||
if(getActiveConfiguration() != cfg){
|
fActiveCfgInfo.setConfiguration(cfg);
|
||||||
fActiveCfgId = cfg.getId();
|
|
||||||
fActiveCfg = cfg;
|
if(getConfigurationReltations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
|
||||||
fIsModified = true;
|
fSettingCfgInfo.setConfiguration(cfg);
|
||||||
// storeActiveCfgId(fActiveCfgId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public IProject getProject() {
|
public IProject getProject() {
|
||||||
return fProject;
|
return fProject;
|
||||||
}
|
}
|
||||||
|
@ -382,6 +451,9 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
if(fIsModified)
|
if(fIsModified)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if(fPrefs.isModified())
|
||||||
|
return true;
|
||||||
|
|
||||||
if(fRootStorageElement != null
|
if(fRootStorageElement != null
|
||||||
&& ((InternalXmlStorageElement)fRootStorageElement).isDirty())
|
&& ((InternalXmlStorageElement)fRootStorageElement).isDirty())
|
||||||
return true;
|
return true;
|
||||||
|
@ -401,32 +473,23 @@ public class CProjectDescription implements ICProjectDescription, ICDataProxyCon
|
||||||
return getConfigurationById(id);
|
return getConfigurationById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICConfigurationDescription getIndexConfiguration(){
|
public ICConfigurationDescription getDefaultSettingConfiguration(){
|
||||||
if(fIndexCfg == null){
|
if(getConfigurationReltations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
|
||||||
String id = getIndexConfigurationId();
|
return getActiveConfiguration();
|
||||||
fIndexCfg = getConfigurationById(id);
|
|
||||||
if(fIndexCfg == null){
|
return fSettingCfgInfo.getConfiguration();
|
||||||
fIndexCfg = getActiveConfiguration();
|
|
||||||
if(fIndexCfg != null){
|
|
||||||
fIndexCfgId = fIndexCfg.getId();
|
|
||||||
} else {
|
|
||||||
fIndexCfgId = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return fIndexCfg;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getIndexConfigurationId(){
|
public void setDefaultSettingConfiguration(ICConfigurationDescription cfg) throws WriteAccessException {
|
||||||
if(fIndexCfgId == null){
|
if(fIsReadOnly)
|
||||||
fIndexCfgId = getActiveConfigurationId();
|
throw ExceptionFactory.createIsReadOnlyException();
|
||||||
}
|
if(cfg == null)
|
||||||
return fIndexCfgId;
|
throw new NullPointerException();
|
||||||
}
|
|
||||||
|
fSettingCfgInfo.setConfiguration(cfg);
|
||||||
void setIndexConfiguration(ICConfigurationDescription cfg){
|
|
||||||
fIndexCfg = cfg;
|
if(getConfigurationReltations() == CONFIGS_LINK_SETTINGS_AND_ACTIVE)
|
||||||
fIndexCfgId = cfg.getId();
|
fActiveCfgInfo.setConfiguration(cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object getSessionProperty(QualifiedName name) {
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.ICLanguageSettingEntry;
|
||||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICProjectDescriptionListener;
|
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.ICResourceDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICSettingBase;
|
import org.eclipse.cdt.core.settings.model.ICSettingBase;
|
||||||
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
import org.eclipse.cdt.core.settings.model.ICSettingEntry;
|
||||||
|
@ -117,16 +119,13 @@ import org.w3c.dom.NodeList;
|
||||||
import org.w3c.dom.ProcessingInstruction;
|
import org.w3c.dom.ProcessingInstruction;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
public class CProjectDescriptionManager {
|
public class CProjectDescriptionManager implements ICProjectDescriptionManager {
|
||||||
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 OLD_PROJECT_DESCRIPTION = "cdtproject"; //$NON-NLS-1$
|
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_CDTPROJECT_FILE_NAME = ".cdtproject"; //$NON-NLS-1$
|
||||||
private static final String OLD_PROJECT_OWNER_ID = "id"; //$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_NAME = "convertedConfig"; //$NON-NLS-1$
|
||||||
private static final String CONVERTED_CFG_ID_PREFIX = "converted.config"; //$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 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 QualifiedName PROJECT_DESCRCIPTION_PROPERTY = new QualifiedName(CCorePlugin.PLUGIN_ID, "projectDescription"); //$NON-NLS-1$
|
||||||
private static final String ROOT_ELEMENT_NAME = "cproject"; //$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 ICLanguageSetting[] EMPTY_LANGUAGE_SETTINGS_ARRAY = new ICLanguageSetting[0];
|
||||||
private static final String PREFERENCES_STORAGE = "preferences"; //$NON-NLS-1$
|
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 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 ID = "id"; //$NON-NLS-1$
|
||||||
private static final String PREFERENCE_CFG_ID_PREFIX = "preference."; //$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$
|
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 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 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 {
|
static class CompositeWorkspaceRunnable implements IWorkspaceRunnable {
|
||||||
private List fRunnables = new ArrayList();
|
private List fRunnables = new ArrayList();
|
||||||
private String fName;
|
private String fName;
|
||||||
|
@ -277,6 +250,7 @@ public class CProjectDescriptionManager {
|
||||||
private ThreadLocal fThreadInfo = new ThreadLocal();
|
private ThreadLocal fThreadInfo = new ThreadLocal();
|
||||||
private Map fDescriptionMap = new HashMap(); //calls to this map are "manually" synchronized with the CProjectDescriptionManager object lock;
|
private Map fDescriptionMap = new HashMap(); //calls to this map are "manually" synchronized with the CProjectDescriptionManager object lock;
|
||||||
private ResourceChangeHandler fRcChangeHandler;
|
private ResourceChangeHandler fRcChangeHandler;
|
||||||
|
private CProjectDescriptionWorkspacePreferences fPreferences;
|
||||||
|
|
||||||
// private CStorage fPrefCfgStorage;
|
// private CStorage fPrefCfgStorage;
|
||||||
private ICDataProxyContainer fPrefUpdater = new ICDataProxyContainer(){
|
private ICDataProxyContainer fPrefUpdater = new ICDataProxyContainer(){
|
||||||
|
@ -928,13 +902,14 @@ public class CProjectDescriptionManager {
|
||||||
return getProjectDescription(project, true);
|
return getProjectDescription(project, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void storeActiveCfgId(IProject project, String id){
|
// private void storeActiveCfgId(IProject project, String id){
|
||||||
try {
|
// try {
|
||||||
project.setPersistentProperty(ACTIVE_CFG_PROPERTY, id);
|
// project.setPersistentProperty(ACTIVE_CFG_PROPERTY, id);
|
||||||
} catch (CoreException e) {
|
// } catch (CoreException e) {
|
||||||
// Hitting this error just means the default config is not set
|
// // Hitting this error just means the default config is not set
|
||||||
}
|
// CCorePlugin.log(e);
|
||||||
}
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* returns true if the project description was modiofied false - otherwise
|
* returns true if the project description was modiofied false - otherwise
|
||||||
|
@ -948,7 +923,8 @@ public class CProjectDescriptionManager {
|
||||||
|
|
||||||
ICConfigurationDescription oldCfg = oldDes != null ? oldDes.getActiveConfiguration() : null;
|
ICConfigurationDescription oldCfg = oldDes != null ? oldDes.getActiveConfiguration() : null;
|
||||||
|
|
||||||
checkActiveCfgChange(newDes, newCfg, oldCfg);
|
checkActiveCfgChange(newDes, oldDes);
|
||||||
|
checkSettingCfgChange(newDes, oldDes);
|
||||||
|
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
|
|
||||||
|
@ -969,14 +945,14 @@ public class CProjectDescriptionManager {
|
||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
String loadActiveCfgId(ICProjectDescription des){
|
// String loadActiveCfgId(ICProjectDescription des){
|
||||||
try {
|
// try {
|
||||||
return des.getProject().getPersistentProperty(ACTIVE_CFG_PROPERTY);
|
// return des.getProject().getPersistentProperty(ACTIVE_CFG_PROPERTY);
|
||||||
} catch (CoreException e) {
|
// } catch (CoreException e) {
|
||||||
// Hitting this error just means the default config is not set
|
// CCorePlugin.log(e);
|
||||||
}
|
// }
|
||||||
return null;
|
// return null;
|
||||||
}
|
// }
|
||||||
|
|
||||||
private Set projSetFromProjNameSet(Set projNameSet){
|
private Set projSetFromProjNameSet(Set projNameSet){
|
||||||
if(projNameSet.size() == 0)
|
if(projNameSet.size() == 0)
|
||||||
|
@ -1022,18 +998,31 @@ public class CProjectDescriptionManager {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private boolean checkActiveCfgChange(CProjectDescription des,
|
private boolean checkActiveCfgChange(CProjectDescription des,
|
||||||
ICConfigurationDescription newCfg,
|
CProjectDescription oldDes
|
||||||
ICConfigurationDescription oldCfg){
|
// ICConfigurationDescription newCfg,
|
||||||
String newId = newCfg.getId();
|
// ICConfigurationDescription oldCfg
|
||||||
|
){
|
||||||
|
ICConfigurationDescription oldCfg = oldDes != null ? oldDes.getActiveConfiguration() : null;
|
||||||
|
// String newId = newCfg.getId();
|
||||||
String oldId = oldCfg != null ? oldCfg.getId() : null;
|
String oldId = oldCfg != null ? oldCfg.getId() : null;
|
||||||
|
|
||||||
if(des.needsActiveCfgIdPersistence() || !newId.equals(oldId)){
|
|
||||||
storeActiveCfgId(des.getProject(), newId);
|
return des.checkPersistActiveCfg(oldId, false);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return 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,
|
private boolean checkBuildSystemChange(IProjectDescription des,
|
||||||
ICConfigurationDescription newCfg,
|
ICConfigurationDescription newCfg,
|
||||||
ICConfigurationDescription oldCfg,
|
ICConfigurationDescription oldCfg,
|
||||||
|
@ -1908,8 +1897,8 @@ public class CProjectDescriptionManager {
|
||||||
newCfg = newDes.getActiveConfiguration();
|
newCfg = newDes.getActiveConfiguration();
|
||||||
oldCfg = oldDes.getActiveConfiguration();
|
oldCfg = oldDes.getActiveConfiguration();
|
||||||
} else {
|
} else {
|
||||||
newCfg = ((CProjectDescription)newDes).getIndexConfiguration();
|
newCfg = newDes.getDefaultSettingConfiguration();
|
||||||
oldCfg = ((CProjectDescription)oldDes).getIndexConfiguration();
|
oldCfg = oldDes.getDefaultSettingConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(newCfg == null){
|
if(newCfg == null){
|
||||||
|
@ -2486,19 +2475,19 @@ public class CProjectDescriptionManager {
|
||||||
int kind = projDesDelta.getDeltaKind();
|
int kind = projDesDelta.getDeltaKind();
|
||||||
switch(kind){
|
switch(kind){
|
||||||
case ICDescriptionDelta.CHANGED:
|
case ICDescriptionDelta.CHANGED:
|
||||||
CProjectDescription newDes = (CProjectDescription)projDesDelta.getNewSetting();
|
ICProjectDescription newDes = (ICProjectDescription)projDesDelta.getNewSetting();
|
||||||
CProjectDescription oldDes = (CProjectDescription)projDesDelta.getOldSetting();
|
ICProjectDescription oldDes = (ICProjectDescription)projDesDelta.getOldSetting();
|
||||||
// int flags = projDesDelta.getChangeFlags();
|
// int flags = projDesDelta.getChangeFlags();
|
||||||
ICConfigurationDescription activeCfg = newDes.getActiveConfiguration();
|
// ICConfigurationDescription activeCfg = newDes.getActiveConfiguration();
|
||||||
ICConfigurationDescription indexCfg = newDes.getIndexConfiguration();
|
ICConfigurationDescription indexCfg = newDes.getDefaultSettingConfiguration();
|
||||||
if(indexCfg != activeCfg){
|
// if(indexCfg != activeCfg){
|
||||||
ICDescriptionDelta delta = findDelta(activeCfg.getId(), projDesDelta);
|
// ICDescriptionDelta delta = findDelta(activeCfg.getId(), projDesDelta);
|
||||||
if(delta != null && delta.getDeltaKind() == ICDescriptionDelta.CHANGED){
|
// if(delta != null && delta.getDeltaKind() == ICDescriptionDelta.CHANGED){
|
||||||
indexCfg = activeCfg;
|
// indexCfg = activeCfg;
|
||||||
newDes.setIndexConfiguration(activeCfg);
|
// newDes.setIndexConfiguration(activeCfg);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
ICConfigurationDescription oldIndexCfg = oldDes.getIndexConfiguration();
|
ICConfigurationDescription oldIndexCfg = oldDes.getDefaultSettingConfiguration();
|
||||||
ICDescriptionDelta indexDelta;
|
ICDescriptionDelta indexDelta;
|
||||||
if(oldIndexCfg.getId().equals(indexCfg.getId())){
|
if(oldIndexCfg.getId().equals(indexCfg.getId())){
|
||||||
indexDelta = findDelta(indexCfg.getId(), projDesDelta);
|
indexDelta = findDelta(indexCfg.getId(), projDesDelta);
|
||||||
|
@ -2696,13 +2685,13 @@ public class CProjectDescriptionManager {
|
||||||
return kindsArray;
|
return kindsArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addListener(ICProjectDescriptionListener listener, int eventTypes){
|
public void addCProjectDescriptionListener(ICProjectDescriptionListener listener, int eventTypes){
|
||||||
synchronized(this){
|
synchronized(this){
|
||||||
fListeners.add(new ListenerDescriptor(listener, eventTypes));
|
fListeners.add(new ListenerDescriptor(listener, eventTypes));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeListener(ICProjectDescriptionListener listener){
|
public void removeCProjectDescriptionListener(ICProjectDescriptionListener listener){
|
||||||
synchronized(this){
|
synchronized(this){
|
||||||
int size = fListeners.size();
|
int size = fListeners.size();
|
||||||
ListenerDescriptor des;
|
ListenerDescriptor des;
|
||||||
|
@ -3084,7 +3073,7 @@ public class CProjectDescriptionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNewStyleIndexCfg(ICProjectDescription des){
|
public boolean isNewStyleIndexCfg(ICProjectDescription des){
|
||||||
ICConfigurationDescription cfgDes = ((CProjectDescription)des).getIndexConfiguration();
|
ICConfigurationDescription cfgDes = des.getDefaultSettingConfiguration();
|
||||||
if(cfgDes != null)
|
if(cfgDes != null)
|
||||||
return isNewStyleCfg(cfgDes);
|
return isNewStyleCfg(cfgDes);
|
||||||
return false;
|
return false;
|
||||||
|
@ -3317,4 +3306,94 @@ public class CProjectDescriptionManager {
|
||||||
return false;
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -49,13 +49,13 @@ public class CfgExportSettingContainerFactory extends
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startup(){
|
public void startup(){
|
||||||
CProjectDescriptionManager.getInstance().addListener(this,
|
CProjectDescriptionManager.getInstance().addCProjectDescriptionListener(this,
|
||||||
CProjectDescriptionEvent.APPLIED
|
CProjectDescriptionEvent.APPLIED
|
||||||
| CProjectDescriptionEvent.LOADDED);
|
| CProjectDescriptionEvent.LOADDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void shutdown(){
|
public void shutdown(){
|
||||||
CProjectDescriptionManager.getInstance().removeListener(this);
|
CProjectDescriptionManager.getInstance().removeCProjectDescriptionListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class CfgRefContainer extends CExternalSettingsContainer {
|
private class CfgRefContainer extends CExternalSettingsContainer {
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
|
||||||
fProject = project;
|
fProject = project;
|
||||||
fListeners = Collections.synchronizedList(new ArrayList());
|
fListeners = Collections.synchronizedList(new ArrayList());
|
||||||
|
|
||||||
CProjectDescriptionManager.getInstance().addListener(this, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADDED);
|
CProjectDescriptionManager.getInstance().addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -89,7 +89,7 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
|
||||||
for (int i = 0; i < observers.length; i++) {
|
for (int i = 0; i < observers.length; i++) {
|
||||||
observers[i].pathEntryStoreChanged(evt);
|
observers[i].pathEntryStoreChanged(evt);
|
||||||
}
|
}
|
||||||
CProjectDescriptionManager.getInstance().removeListener(this);
|
CProjectDescriptionManager.getInstance().removeCProjectDescriptionListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IProject getProject() {
|
public IProject getProject() {
|
||||||
|
@ -123,8 +123,8 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
|
||||||
// usrList.add(entries[i]);
|
// usrList.add(entries[i]);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
CProjectDescription des = (CProjectDescription)CoreModel.getDefault().getProjectDescription(fProject, true);
|
ICProjectDescription des = CoreModel.getDefault().getProjectDescription(fProject, true);
|
||||||
ICConfigurationDescription cfgDes = des.getIndexConfiguration();
|
ICConfigurationDescription cfgDes = des.getDefaultSettingConfiguration();
|
||||||
CConfigurationData data = cfgDes.getConfigurationData();
|
CConfigurationData data = cfgDes.getConfigurationData();
|
||||||
PathEntryTranslator tr = new PathEntryTranslator(fProject, data);
|
PathEntryTranslator tr = new PathEntryTranslator(fProject, data);
|
||||||
IPathEntry[] usrEntries = (IPathEntry[])usrList.toArray(new IPathEntry[usrList.size()]);
|
IPathEntry[] usrEntries = (IPathEntry[])usrList.toArray(new IPathEntry[usrList.size()]);
|
||||||
|
@ -160,11 +160,11 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
|
||||||
|
|
||||||
switch(event.getEventType()){
|
switch(event.getEventType()){
|
||||||
case CProjectDescriptionEvent.APPLIED:{
|
case CProjectDescriptionEvent.APPLIED:{
|
||||||
CProjectDescription des = (CProjectDescription)event.getNewCProjectDescription();
|
ICProjectDescription des = event.getNewCProjectDescription();
|
||||||
CProjectDescription oldDes = (CProjectDescription)event.getOldCProjectDescription();
|
ICProjectDescription oldDes = event.getOldCProjectDescription();
|
||||||
List oldCrEntries = null;
|
List oldCrEntries = null;
|
||||||
if(oldDes != null){
|
if(oldDes != null){
|
||||||
ICConfigurationDescription oldIndexCfg = oldDes.getIndexConfiguration();
|
ICConfigurationDescription oldIndexCfg = oldDes.getDefaultSettingConfiguration();
|
||||||
List[] oldEs = getCachedEntries(oldIndexCfg);
|
List[] oldEs = getCachedEntries(oldIndexCfg);
|
||||||
if(oldEs != null)
|
if(oldEs != null)
|
||||||
oldCrEntries = oldEs[1];
|
oldCrEntries = oldEs[1];
|
||||||
|
@ -176,7 +176,7 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
|
||||||
clearCachedEntries(des);
|
clearCachedEntries(des);
|
||||||
|
|
||||||
if(oldCrEntries != null){
|
if(oldCrEntries != null){
|
||||||
ICConfigurationDescription newIndexCfg = des.getIndexConfiguration();
|
ICConfigurationDescription newIndexCfg = des.getDefaultSettingConfiguration();
|
||||||
List[] newEs = getEntries(fProject, newIndexCfg);
|
List[] newEs = getEntries(fProject, newIndexCfg);
|
||||||
List newCrEntries = newEs[1];
|
List newCrEntries = newEs[1];
|
||||||
if(!Arrays.equals(oldCrEntries.toArray(), newCrEntries.toArray())){
|
if(!Arrays.equals(oldCrEntries.toArray(), newCrEntries.toArray())){
|
||||||
|
@ -253,8 +253,8 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private static ICConfigurationDescription getIndexCfg(IProject project){
|
private static ICConfigurationDescription getIndexCfg(IProject project){
|
||||||
CProjectDescription des = (CProjectDescription)CCorePlugin.getDefault().getProjectDescription(project, false);
|
ICProjectDescription des = CCorePlugin.getDefault().getProjectDescription(project, false);
|
||||||
return des.getIndexConfiguration();
|
return des.getDefaultSettingConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List getContainerEntries(IProject project){
|
private static List getContainerEntries(IProject project){
|
||||||
|
@ -265,7 +265,7 @@ public class ConfigBasedPathEntryStore implements IPathEntryStore, ICProjectDesc
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List getContainerEntries(ICProjectDescription des){
|
private static List getContainerEntries(ICProjectDescription des){
|
||||||
ICConfigurationDescription cfg = ((CProjectDescription)des).getIndexConfiguration();
|
ICConfigurationDescription cfg = des.getDefaultSettingConfiguration();
|
||||||
List es[] = getEntries(des.getProject(), cfg);
|
List es[] = getEntries(des.getProject(), cfg);
|
||||||
if(es != null)
|
if(es != null)
|
||||||
return es[1];
|
return es[1];
|
||||||
|
|
|
@ -53,14 +53,14 @@ public class DescriptionScannerInfoProvider implements IScannerInfoProvider, ICP
|
||||||
DescriptionScannerInfoProvider(IProject project){
|
DescriptionScannerInfoProvider(IProject project){
|
||||||
fProject = project;
|
fProject = project;
|
||||||
|
|
||||||
CProjectDescriptionManager.getInstance().addListener(this, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADDED);
|
CProjectDescriptionManager.getInstance().addCProjectDescriptionListener(this, CProjectDescriptionEvent.APPLIED | CProjectDescriptionEvent.LOADDED);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateProjCfgInfo(ICProjectDescription des){
|
private void updateProjCfgInfo(ICProjectDescription des){
|
||||||
fInited = true;
|
fInited = true;
|
||||||
fProjDes = des;
|
fProjDes = des;
|
||||||
if(fProjDes != null){
|
if(fProjDes != null){
|
||||||
fCfgDes = ((CProjectDescription)des).getIndexConfiguration();
|
fCfgDes = des.getDefaultSettingConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
fIdToLanguageSettingsMap.clear();
|
fIdToLanguageSettingsMap.clear();
|
||||||
|
@ -267,7 +267,7 @@ public class DescriptionScannerInfoProvider implements IScannerInfoProvider, ICP
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close(){
|
public void close(){
|
||||||
CProjectDescriptionManager.getInstance().removeListener(this);
|
CProjectDescriptionManager.getInstance().removeCProjectDescriptionListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleEvent(CProjectDescriptionEvent event) {
|
public void handleEvent(CProjectDescriptionEvent event) {
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class ScannerInfoProviderProxy extends AbstractCExtensionProxy implements
|
||||||
|
|
||||||
public ScannerInfoProviderProxy(IProject project) {
|
public ScannerInfoProviderProxy(IProject project) {
|
||||||
super(project, CCorePlugin.BUILD_SCANNER_INFO_UNIQ_ID);
|
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) {
|
public IScannerInfo getScannerInformation(IResource resource) {
|
||||||
|
|
|
@ -38,6 +38,7 @@ import org.eclipse.cdt.core.resources.IConsole;
|
||||||
import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
|
import org.eclipse.cdt.core.resources.IPathEntryVariableManager;
|
||||||
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
|
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.WriteAccessException;
|
||||||
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
import org.eclipse.cdt.core.settings.model.util.CDataUtil;
|
||||||
import org.eclipse.cdt.internal.core.CConfigBasedDescriptorManager;
|
import org.eclipse.cdt.internal.core.CConfigBasedDescriptorManager;
|
||||||
|
@ -1248,4 +1249,8 @@ public class CCorePlugin extends Plugin {
|
||||||
public boolean isNewStyleProject(ICProjectDescription des){
|
public boolean isNewStyleProject(ICProjectDescription des){
|
||||||
return fNewCProjectDescriptionManager.isNewStyleProject(des);
|
return fNewCProjectDescriptionManager.isNewStyleProject(des);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ICProjectDescriptionManager getProjectDescriptionManager(){
|
||||||
|
return fNewCProjectDescriptionManager;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -307,7 +307,7 @@ public class CConfigBasedDescriptorManager implements ICDescriptorManager {
|
||||||
if(des.isReadOnly())
|
if(des.isReadOnly())
|
||||||
des = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(des.getProject(), true);
|
des = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(des.getProject(), true);
|
||||||
|
|
||||||
ICConfigurationDescription cfgDes = des.getIndexConfiguration();
|
ICConfigurationDescription cfgDes = des.getDefaultSettingConfiguration();
|
||||||
|
|
||||||
|
|
||||||
if(cfgDes != null){
|
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(){
|
public void shutdown(){
|
||||||
if(fDescriptionListener != null){
|
if(fDescriptionListener != null){
|
||||||
CProjectDescriptionManager.getInstance().removeListener(fDescriptionListener);
|
CProjectDescriptionManager.getInstance().removeCProjectDescriptionListener(fDescriptionListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,7 +381,7 @@ public class CConfigBasedDescriptorManager implements ICDescriptorManager {
|
||||||
if(dr != null){
|
if(dr != null){
|
||||||
//the descriptor was requested while load process
|
//the descriptor was requested while load process
|
||||||
des = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(des.getProject(), true);
|
des = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(des.getProject(), true);
|
||||||
ICConfigurationDescription cfgDescription = des.getIndexConfiguration();
|
ICConfigurationDescription cfgDescription = des.getDefaultSettingConfiguration();
|
||||||
if(cfgDescription != null){
|
if(cfgDescription != null){
|
||||||
dr.updateConfiguration((CConfigurationDescription)cfgDescription);
|
dr.updateConfiguration((CConfigurationDescription)cfgDescription);
|
||||||
dr.setDirty(false);
|
dr.setDirty(false);
|
||||||
|
@ -419,7 +419,7 @@ public class CConfigBasedDescriptorManager implements ICDescriptorManager {
|
||||||
ICConfigurationDescription updatedCfg = null;
|
ICConfigurationDescription updatedCfg = null;
|
||||||
if(oldDes == null){
|
if(oldDes == null){
|
||||||
dr = findDescriptor(newDes);
|
dr = findDescriptor(newDes);
|
||||||
updatedCfg = newDes.getIndexConfiguration();
|
updatedCfg = newDes.getDefaultSettingConfiguration();
|
||||||
if(dr != null){
|
if(dr != null){
|
||||||
desEvent = new CDescriptorEvent(dr, CDescriptorEvent.CDTPROJECT_ADDED, 0);
|
desEvent = new CDescriptorEvent(dr, CDescriptorEvent.CDTPROJECT_ADDED, 0);
|
||||||
}
|
}
|
||||||
|
@ -430,10 +430,10 @@ public class CConfigBasedDescriptorManager implements ICDescriptorManager {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dr = findDescriptor(newDes);
|
dr = findDescriptor(newDes);
|
||||||
updatedCfg = newDes.getIndexConfiguration();
|
updatedCfg = newDes.getDefaultSettingConfiguration();
|
||||||
if(dr != null){
|
if(dr != null){
|
||||||
ICConfigurationDescription newCfg = newDes.getIndexConfiguration();
|
ICConfigurationDescription newCfg = newDes.getDefaultSettingConfiguration();
|
||||||
ICConfigurationDescription oldCfg = oldDes.getIndexConfiguration();
|
ICConfigurationDescription oldCfg = oldDes.getDefaultSettingConfiguration();
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
if(newCfg.getId().equals(oldCfg.getId())){
|
if(newCfg.getId().equals(oldCfg.getId())){
|
||||||
ICDescriptionDelta cfgDelta = findCfgDelta(event.getProjectDelta(), newCfg.getId());
|
ICDescriptionDelta cfgDelta = findCfgDelta(event.getProjectDelta(), newCfg.getId());
|
||||||
|
@ -453,7 +453,7 @@ public class CConfigBasedDescriptorManager implements ICDescriptorManager {
|
||||||
|
|
||||||
if(updatedCfg != null && dr != null){
|
if(updatedCfg != null && dr != null){
|
||||||
CProjectDescription writableDes = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(event.getProject(), true);
|
CProjectDescription writableDes = (CProjectDescription)CProjectDescriptionManager.getInstance().getProjectDescription(event.getProject(), true);
|
||||||
ICConfigurationDescription indexCfg = writableDes.getIndexConfiguration();
|
ICConfigurationDescription indexCfg = writableDes.getDefaultSettingConfiguration();
|
||||||
dr.updateConfiguration((CConfigurationDescription)indexCfg);
|
dr.updateConfiguration((CConfigurationDescription)indexCfg);
|
||||||
dr.setDirty(false);
|
dr.setDirty(false);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue