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:
parent
1a924925c5
commit
7e403feb06
5 changed files with 47 additions and 17 deletions
|
@ -6,7 +6,8 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* 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;
|
package org.eclipse.cdt.core.settings.model.extension;
|
||||||
|
|
||||||
|
@ -27,4 +28,20 @@ public abstract class CExternalSettingProvider {
|
||||||
* @return CExternalSetting[] or contributed external settings
|
* @return CExternalSetting[] or contributed external settings
|
||||||
*/
|
*/
|
||||||
public abstract CExternalSetting[] getSettings(IProject project, ICConfigurationDescription cfg);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -10,16 +10,28 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.settings.model;
|
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.cdt.core.settings.model.ICConfigurationDescription;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
public abstract class CExternalSettingContainerFactory {
|
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(
|
public abstract CExternalSettingsContainer createContainer(
|
||||||
String id,
|
String id,
|
||||||
IProject project,
|
IProject project,
|
||||||
ICConfigurationDescription cfgDes) throws CoreException;
|
ICConfigurationDescription cfgDes, CExternalSetting[] previousSettings) throws CoreException;
|
||||||
|
|
||||||
public void addListener(ICExternalSettingsListener listener){
|
public void addListener(ICExternalSettingsListener listener){
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,13 +147,14 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
private ContainerDescriptor(FactoryDescriptor factoryDr,
|
private ContainerDescriptor(FactoryDescriptor factoryDr,
|
||||||
String containerId,
|
String containerId,
|
||||||
IProject project,
|
IProject project,
|
||||||
ICConfigurationDescription cfgDes){
|
ICConfigurationDescription cfgDes,
|
||||||
|
CExternalSetting[] previousSettings){
|
||||||
fFactoryDr = factoryDr;
|
fFactoryDr = factoryDr;
|
||||||
// fContainerId = containerId;
|
// fContainerId = containerId;
|
||||||
// fProjectName = project.getName();
|
// fProjectName = project.getName();
|
||||||
// fCfgId = cfgDes.getId();
|
// fCfgId = cfgDes.getId();
|
||||||
try {
|
try {
|
||||||
fContainer = fFactoryDr.getFactory().createContainer(containerId, project, cfgDes);
|
fContainer = fFactoryDr.getFactory().createContainer(containerId, project, cfgDes, previousSettings);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
}
|
}
|
||||||
if(fContainer == null)
|
if(fContainer == null)
|
||||||
|
@ -201,7 +202,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CExternalSettingsContainer createContainer(String id,
|
public CExternalSettingsContainer createContainer(String id,
|
||||||
IProject project, ICConfigurationDescription cfgDes) throws CoreException {
|
IProject project, ICConfigurationDescription cfgDes, CExternalSetting[] previousSettings) throws CoreException {
|
||||||
return NullContainer.INSTANCE;
|
return NullContainer.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -471,10 +472,10 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
private ContainerDescriptor createDescriptor(String factoryId,
|
private ContainerDescriptor createDescriptor(String factoryId,
|
||||||
String containerId,
|
String containerId,
|
||||||
IProject project,
|
IProject project,
|
||||||
ICConfigurationDescription cfgDes
|
ICConfigurationDescription cfgDes,
|
||||||
) {
|
CExternalSetting[] previousSettings) {
|
||||||
FactoryDescriptor dr = getFactoryDescriptor(factoryId);
|
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,
|
public void settingsChanged(IProject project, String cfgId,
|
||||||
|
@ -791,7 +792,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
CExternalSetting[] newSettings = null;
|
CExternalSetting[] newSettings = null;
|
||||||
CExternalSetting[] oldSettings = hCr.getHolder(false).getExternalSettings();
|
CExternalSetting[] oldSettings = hCr.getHolder(false).getExternalSettings();
|
||||||
if(add){
|
if(add){
|
||||||
ContainerDescriptor cdr = createDescriptor(cr.getFactoryId(), cr.getContainerId(), proj, cfgDes);
|
ContainerDescriptor cdr = createDescriptor(cr.getFactoryId(), cr.getContainerId(), proj, cfgDes, oldSettings);
|
||||||
newSettings = cdr.getExternalSettings();
|
newSettings = cdr.getExternalSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class CfgExportSettingContainerFactory extends
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CExternalSettingsContainer createContainer(String id,
|
public CExternalSettingsContainer createContainer(String id,
|
||||||
IProject project, ICConfigurationDescription cfgDes) {
|
IProject project, ICConfigurationDescription cfgDes, CExternalSetting[] previousSettings) {
|
||||||
try {
|
try {
|
||||||
String[] r = parseId(id);
|
String[] r = parseId(id);
|
||||||
return new CfgRefContainer(r[0], r[1]);
|
return new CfgRefContainer(r[0], r[1]);
|
||||||
|
|
|
@ -102,8 +102,8 @@ public class ExtensionContainerFactory extends CExternalSettingContainerFactoryW
|
||||||
return fProvider;
|
return fProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
CExternalSettingsContainer getContainer(IProject project, ICConfigurationDescription cfg){
|
CExternalSettingsContainer getContainer(IProject project, ICConfigurationDescription cfg, CExternalSetting[] previousSettings){
|
||||||
return new CESContainer(getProvider().getSettings(project, cfg));
|
return new CESContainer(getProvider().getSettings(project, cfg, previousSettings));
|
||||||
}
|
}
|
||||||
|
|
||||||
CExternalSettingProvider createProvider() throws CoreException{
|
CExternalSettingProvider createProvider() throws CoreException{
|
||||||
|
@ -175,10 +175,10 @@ public class ExtensionContainerFactory extends CExternalSettingContainerFactoryW
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CExternalSettingsContainer createContainer(String id,
|
public CExternalSettingsContainer createContainer(String id,
|
||||||
IProject project, ICConfigurationDescription cfgDes) throws CoreException {
|
IProject project, ICConfigurationDescription cfgDes, CExternalSetting[] previousSettings) throws CoreException {
|
||||||
CExtensionSettingProviderDescriptor dr = getProviderDescriptorMap().get(id);
|
CExtensionSettingProviderDescriptor dr = getProviderDescriptorMap().get(id);
|
||||||
if(dr != null)
|
if(dr != null)
|
||||||
return dr.getContainer(project, cfgDes);
|
return dr.getContainer(project, cfgDes, previousSettings);
|
||||||
return CExternalSettingsManager.NullContainer.INSTANCE;
|
return CExternalSettingsManager.NullContainer.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue