1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 295620 External Settings providers need some way of knowing what settings they provided previously

This commit is contained in:
James Blackburn 2009-11-19 17:08:09 +00:00
parent 1a924925c5
commit 7e403feb06
5 changed files with 47 additions and 17 deletions

View file

@ -6,7 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Intel Corporation - Initial API and implementation
* Intel Corporation - Initial API and implementation
* James Blackburn (Broadcom Corp.)
*******************************************************************************/
package org.eclipse.cdt.core.settings.model.extension;
@ -14,7 +15,7 @@ import org.eclipse.cdt.core.settings.model.CExternalSetting;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.core.resources.IProject;
/**
/**
* Abstract base class for the External Settings Provider extension point. Contributed
* external settings are added to the Project's build configuration.
*/
@ -27,4 +28,20 @@ public abstract class CExternalSettingProvider {
* @return CExternalSetting[] or contributed external settings
*/
public abstract CExternalSetting[] getSettings(IProject project, ICConfigurationDescription cfg);
/**
* Hook for fetching external settings from the contributed external settings provider.
* This call-back provides the previous version of the settings as cached by cdt.core
*
* @param project IProject
* @param cfg ICConfigurationDescription for which to fetch contributed external settings
* @param previousSettings external settings as cached by cdt.core for this {@link CExternalSettingProvider}
* or an empty array
* @return CExternalSetting[] of contributed external settings
* @since 5.2
*/
public CExternalSetting[] getSettings(IProject project, ICConfigurationDescription cfg,
CExternalSetting[] previousSettings) {
return getSettings(project, cfg);
}
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2007 Intel Corporation and others.
* Copyright (c) 2007, 2009 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
@ -10,16 +10,28 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.settings.model;
import org.eclipse.cdt.core.settings.model.CExternalSetting;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
public abstract class CExternalSettingContainerFactory {
/**
* Create a settings container for fetching External Settings from the External
* Settings provider with the given id on the specified project and configuration
*
* @param id of the external settings provider
* @param project project to fetch settings for
* @param cfgDes configuration to fetch settings for
* @param previousSettings settings as previously cached by cdt.core
* @return {@link CExternalSettingsContainer}
* @throws CoreException
*/
public abstract CExternalSettingsContainer createContainer(
String id,
IProject project,
ICConfigurationDescription cfgDes) throws CoreException;
ICConfigurationDescription cfgDes, CExternalSetting[] previousSettings) throws CoreException;
public void addListener(ICExternalSettingsListener listener){
}

View file

@ -147,13 +147,14 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
private ContainerDescriptor(FactoryDescriptor factoryDr,
String containerId,
IProject project,
ICConfigurationDescription cfgDes){
ICConfigurationDescription cfgDes,
CExternalSetting[] previousSettings){
fFactoryDr = factoryDr;
// fContainerId = containerId;
// fProjectName = project.getName();
// fCfgId = cfgDes.getId();
try {
fContainer = fFactoryDr.getFactory().createContainer(containerId, project, cfgDes);
fContainer = fFactoryDr.getFactory().createContainer(containerId, project, cfgDes, previousSettings);
} catch (CoreException e) {
}
if(fContainer == null)
@ -201,7 +202,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
@Override
public CExternalSettingsContainer createContainer(String id,
IProject project, ICConfigurationDescription cfgDes) throws CoreException {
IProject project, ICConfigurationDescription cfgDes, CExternalSetting[] previousSettings) throws CoreException {
return NullContainer.INSTANCE;
}
@ -471,10 +472,10 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
private ContainerDescriptor createDescriptor(String factoryId,
String containerId,
IProject project,
ICConfigurationDescription cfgDes
) {
ICConfigurationDescription cfgDes,
CExternalSetting[] previousSettings) {
FactoryDescriptor dr = getFactoryDescriptor(factoryId);
return new ContainerDescriptor(dr, containerId, project, cfgDes);
return new ContainerDescriptor(dr, containerId, project, cfgDes, previousSettings);
}
public void settingsChanged(IProject project, String cfgId,
@ -791,7 +792,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
CExternalSetting[] newSettings = null;
CExternalSetting[] oldSettings = hCr.getHolder(false).getExternalSettings();
if(add){
ContainerDescriptor cdr = createDescriptor(cr.getFactoryId(), cr.getContainerId(), proj, cfgDes);
ContainerDescriptor cdr = createDescriptor(cr.getFactoryId(), cr.getContainerId(), proj, cfgDes, oldSettings);
newSettings = cdr.getExternalSettings();
}

View file

@ -101,7 +101,7 @@ public class CfgExportSettingContainerFactory extends
@Override
public CExternalSettingsContainer createContainer(String id,
IProject project, ICConfigurationDescription cfgDes) {
IProject project, ICConfigurationDescription cfgDes, CExternalSetting[] previousSettings) {
try {
String[] r = parseId(id);
return new CfgRefContainer(r[0], r[1]);

View file

@ -102,8 +102,8 @@ public class ExtensionContainerFactory extends CExternalSettingContainerFactoryW
return fProvider;
}
CExternalSettingsContainer getContainer(IProject project, ICConfigurationDescription cfg){
return new CESContainer(getProvider().getSettings(project, cfg));
CExternalSettingsContainer getContainer(IProject project, ICConfigurationDescription cfg, CExternalSetting[] previousSettings){
return new CESContainer(getProvider().getSettings(project, cfg, previousSettings));
}
CExternalSettingProvider createProvider() throws CoreException{
@ -175,10 +175,10 @@ public class ExtensionContainerFactory extends CExternalSettingContainerFactoryW
@Override
public CExternalSettingsContainer createContainer(String id,
IProject project, ICConfigurationDescription cfgDes) throws CoreException {
IProject project, ICConfigurationDescription cfgDes, CExternalSetting[] previousSettings) throws CoreException {
CExtensionSettingProviderDescriptor dr = getProviderDescriptorMap().get(id);
if(dr != null)
return dr.getContainer(project, cfgDes);
return dr.getContainer(project, cfgDes, previousSettings);
return CExternalSettingsManager.NullContainer.INSTANCE;
}