From e4d218aa70978524a1b38fd9ca33782b68bed217 Mon Sep 17 00:00:00 2001 From: James Blackburn Date: Fri, 14 May 2010 12:16:23 +0000 Subject: [PATCH] Bug 312575 tidy patch --- .../model/CExternalSettingChangeEvent.java | 20 +- .../model/CExternalSettingsHolder.java | 4 - .../model/CExternalSettingsManager.java | 409 +++++------------- .../core/settings/model/CSettingsRefInfo.java | 17 +- .../model/ICExternalSettingsListener.java | 10 +- 5 files changed, 134 insertions(+), 326 deletions(-) diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingChangeEvent.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingChangeEvent.java index 01e23317e93..8d145e800f2 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingChangeEvent.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingChangeEvent.java @@ -10,23 +10,17 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.settings.model; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - +/** + * External setting change event + */ class CExternalSettingChangeEvent { - private List fChangeInfoList = new ArrayList(); + private final CExternalSettingsContainerChangeInfo[] fChangeInfos; CExternalSettingChangeEvent(CExternalSettingsContainerChangeInfo[] infos){ - fChangeInfoList.addAll(Arrays.asList(infos)); + fChangeInfos = infos; } - -// void add(CExternalSettingsContainerChangeInfo info){ -// fChangeInfoList.add(info); -// } - + public CExternalSettingsContainerChangeInfo[] getChangeInfos(){ - return fChangeInfoList.toArray( - new CExternalSettingsContainerChangeInfo[fChangeInfoList.size()]); + return fChangeInfos; } } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsHolder.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsHolder.java index 43f79fb5cb2..7eaeabf44c0 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsHolder.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsHolder.java @@ -71,10 +71,6 @@ public class CExternalSettingsHolder extends CExternalSettingsContainer { return EMPTY_EXT_SETTINGS_ARRAY; } - void setExternallSettings(CExternalSetting[] settings){ - setExternalSettings(settings, false); - } - void setExternalSettings(CExternalSetting[] settings, boolean add){ if(!add) removeExternalSettings(); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsManager.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsManager.java index 4cfe5dcb376..51c138d8205 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsManager.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CExternalSettingsManager.java @@ -7,6 +7,7 @@ * * Contributors: * Intel Corporation - Initial API and implementation + * James Blackburn (Broadcom Corp.) *******************************************************************************/ package org.eclipse.cdt.internal.core.settings.model; @@ -46,23 +47,6 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP private Map fFactoryMap = new HashMap(); private static CExternalSettingsManager fInstance; - public static class SettingsUpdateStatus { - ICProjectDescription fDes; - boolean fIsChanged; - - SettingsUpdateStatus(ICProjectDescription des, boolean isChanged){ - fDes = des; - fIsChanged = isChanged; - } - - public ICProjectDescription getCProjectDescription(){ - return fDes; - } - - public boolean isChanged(){ - return fIsChanged; - } - } private CExternalSettingsManager(){ } @@ -137,9 +121,6 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP } private static class ContainerDescriptor { private FactoryDescriptor fFactoryDr; -// private String fContainerId; -// private String fProjectName; -// private String fCfgId; private CExternalSettingsHolder fHolder; private CExternalSettingsContainer fContainer; @@ -150,9 +131,6 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP ICConfigurationDescription cfgDes, CExternalSetting[] previousSettings){ fFactoryDr = factoryDr; -// fContainerId = containerId; -// fProjectName = project.getName(); -// fCfgId = cfgDes.getId(); try { fContainer = fFactoryDr.getFactory().createContainer(containerId, project, cfgDes, previousSettings); } catch (CoreException e) { @@ -165,24 +143,11 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP public CExternalSetting[] getExternalSettings(){ if(fHolder == null){ fHolder = new CExternalSettingsHolder(); - fHolder.setExternallSettings(fContainer.getExternalSettings()); + fHolder.setExternalSettings(fContainer.getExternalSettings(), false); } return fHolder.getExternalSettings(); } -// public CExternalSettingsContainer getContainer(){ -// if(fContainer == null){ -// IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(fProjectName); -// try { -// fContainer = fFactoryDr.getFactory().createContainer(fContainerId, project, fCfgId); -// } catch (CoreException e) { -// CCorePlugin.log(e); -// } -// if(fContainer == null) -// fContainer = NullContainer.INSTANCE; -// } -// return fContainer; -// } } /** @@ -210,7 +175,6 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP private class FactoryDescriptor { private CExternalSettingContainerFactory fFactory; private String fId; -// private Map fContainerMap; private FactoryDescriptor(String id){ fId = id; @@ -233,10 +197,6 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP return NullFactory.INSTANCE; } -// public String getId(){ -// return fId; -// } - public void shutdown(){ if(fFactory != null){ fFactory.removeListener(CExternalSettingsManager.this); @@ -248,8 +208,6 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP private interface ICfgContainer { ICConfigurationDescription getConfguration(boolean write); - -// boolean isWritable(); } private static class CfgContainer implements ICfgContainer { @@ -265,11 +223,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP } - private interface ICRefInfoContainer { - CSettingsRefInfo getRefInfo(boolean write); - } - - private class CfgContainerRefInfoContainer implements ICRefInfoContainer{ + private class CfgContainerRefInfoContainer { private ICfgContainer fCfgContainer; private CSettingsRefInfo fRefInfo; private boolean fWriteWasRequested; @@ -289,33 +243,13 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP } } -// private class CfgRefInfoContainer implements ICRefInfoContainer{ -// private CSettingsRefInfo fRefInfo; -// private ICConfigurationDescription fCfgDes; -// private boolean fWriteWasRequested; -// -// CfgRefInfoContainer(ICConfigurationDescription cfg){ -// fCfgDes = cfg; -// } -// -// public CSettingsRefInfo getRefInfo(boolean write) { -// if(fRefInfo == null -// || (write && !fWriteWasRequested)){ -// ICConfigurationDescription cfg = fCfgDes; -// fRefInfo = CExternalSettingsManager.this.getRefInfo(cfg, write); -// fWriteWasRequested |= write; -// } -// return fRefInfo; -// } -// } - - private class HolderContainer { - private ICRefInfoContainer fRIContainer; + private static class HolderContainer { + private CfgContainerRefInfoContainer fRIContainer; private CRefSettingsHolder fHolder; private boolean fWriteWasRequested; private CContainerRef fCRef; - HolderContainer(ICRefInfoContainer cr, CContainerRef cref){ + HolderContainer(CfgContainerRefInfoContainer cr, CContainerRef cref){ fRIContainer = cr; fCRef = cref; } @@ -344,10 +278,10 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP } private static class CfgListCfgContainer implements ICfgContainer{ - private ICfgList fList; + private ProjDesCfgList fList; private int fNum; - CfgListCfgContainer(ICfgList list, int num){ + CfgListCfgContainer(ProjDesCfgList list, int num){ fList = list; fNum = num; } @@ -355,19 +289,13 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP public ICConfigurationDescription getConfguration(boolean write) { return fList.get(fNum, write); } - -// public boolean isWritable() { -// return !getConfguration(false).isReadOnly(); -// } } - private interface ICfgList { - ICConfigurationDescription get(int num, boolean write); - - int size(); - } - - private static class ProjDesCfgList implements ICfgList{ + /** + * A simple container type that contains a Project Description & and associated list + * of configuration descriptions. + */ + private static class ProjDesCfgList { private ICProjectDescription fProjDes; private List fCfgList = new ArrayList(); @@ -404,41 +332,11 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP } } - public int getNumForId(String id){ - for(int i = 0; i < fCfgList.size(); i++){ - ICConfigurationDescription cfg = fCfgList.get(i); - if(id.equals(cfg.getId())) - return i; - } - return -1; - } - -// public ICConfigurationDescription getConfigurationById(String id, boolean write){ -// ICConfigurationDescription cfg = fProjDes.getConfigurationById(id); -// if(cfg == null) -// return null; -// if(write && fProjDes.isReadOnly()){ -// makeWritable(); -// cfg = fProjDes.getConfigurationById(id); -// } -// return cfg; -// } - public int size() { return fCfgList.size(); } } - private static class DeltaInfo{ -// private boolean fCalculated; -// private ExtSettingsDelta[] fDeltas; - -// void setDelta(ExtSettingsDelta[] deltas){ -// fDeltas = deltas; -//// fCalculated = true; -// } - } - private FactoryDescriptor getFactoryDescriptor(String id){ FactoryDescriptor dr = fFactoryMap.get(id); if(dr == null){ @@ -453,53 +351,43 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP return dr.getFactory(); } - private ContainerDescriptor createDescriptor(String factoryId, - String containerId, - IProject project, - ICConfigurationDescription cfgDes, - CExternalSetting[] previousSettings) { - FactoryDescriptor dr = getFactoryDescriptor(factoryId); - return new ContainerDescriptor(dr, containerId, project, cfgDes, previousSettings); - } - public void settingsChanged(IProject project, String cfgId, CExternalSettingChangeEvent event) { ProjDesCfgList[] lists = null; CExternalSettingsContainerChangeInfo[] infos = event.getChangeInfos(); - for(int i = 0; i < infos.length; i++){ - CExternalSettingsContainerChangeInfo info = infos[i]; + for (CExternalSettingsContainerChangeInfo info : infos) { switch(info.getEventType()){ case CExternalSettingsContainerChangeInfo.CHANGED: int flags = info.getChangeFlags(); if((flags & CExternalSettingsContainerChangeInfo.CONTAINER_CONTENTS) != 0){ if(lists == null) lists = createCfgListsForEvent(project, cfgId); - containerContentsChanged(lists, info.getContainerInfo(), null); + for (ProjDesCfgList list : lists) { + for(int i = 0; i < list.size(); i++){ + CfgListCfgContainer cr = new CfgListCfgContainer(list, i); + processContainerChange(OP_CHANGED, cr, new CfgContainerRefInfoContainer(cr), info.getContainerInfo()); + } + } } break; } - } - if(lists != null) - applyLists(lists); - } - - private void applyLists(ProjDesCfgList[] lists){ - final List list = getModifiedProjDesList(lists); - if(list.size() != 0){ - IWorkspaceRunnable r = new IWorkspaceRunnable(){ - - public void run(IProgressMonitor monitor) throws CoreException { - for(int i = 0; i < list.size(); i++){ - ICProjectDescription des = list.get(i); - CProjectDescriptionManager.getInstance().setProjectDescription(des.getProject(), des, false, monitor); + // TODO modifying the project description in an asynchronous runnable is likely bad... + if(lists != null) { + final List list = getModifiedProjDesList(lists); + if(list.size() != 0){ + IWorkspaceRunnable r = new IWorkspaceRunnable(){ + + public void run(IProgressMonitor monitor) throws CoreException { + for(int i = 0; i < list.size(); i++){ + ICProjectDescription des = list.get(i); + CProjectDescriptionManager.getInstance().setProjectDescription(des.getProject(), des, false, monitor); + } } - } - - }; - - CProjectDescriptionManager.runWspModification(r, new NullProgressMonitor()); + }; + CProjectDescriptionManager.runWspModification(r, new NullProgressMonitor()); + } } } @@ -511,50 +399,40 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP } return list; } - - private void containerContentsChanged(ProjDesCfgList[] lists, CContainerRef ref, DeltaInfo deltaInfo){ - for(int i = 0; i < lists.length; i++){ - containerContentsChanged(lists[i], null, ref, deltaInfo); - } - } + /** + * Returns an array of ProjDescCfgList corresponding to the passed in project + cfgId + * @param project project, or null + * @param cfgId configuration ID, or null + * @return ProjDescCfgList[] + */ private ProjDesCfgList[] createCfgListsForEvent(IProject project, String cfgId){ ProjDesCfgList lists[]; - if(project != null){ - ProjDesCfgList l = createCfgList(project, cfgId); - if(l != null){ - lists = new ProjDesCfgList[1]; - lists[0] = l; - } else { - lists = new ProjDesCfgList[0]; + Set set = null; + if(project != null) { + if(cfgId != null){ + set = new HashSet(); + set.add(cfgId); } + ProjDesCfgList l = createCfgList(project, set); + if(l != null) + lists = new ProjDesCfgList[] { l }; + else + lists = new ProjDesCfgList[0]; } else { - lists = createCfgLists(); + // Project is null -- add all CDT projects & configs in the workspace + IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); + List list = new ArrayList(); + for (IProject p : projects){ + ProjDesCfgList l = createCfgList(p, set); + if(l != null) + list.add(l); + } + lists = list.toArray(new ProjDesCfgList[list.size()]); } return lists; } - private ProjDesCfgList[] createCfgLists(){ - IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - List list = new ArrayList(); - for(int i = 0; i < projects.length; i++){ - ProjDesCfgList l = createCfgList(projects[i], (Set)null); - if(l != null) - list.add(l); - } - return list.toArray(new ProjDesCfgList[list.size()]); - } - - private ProjDesCfgList createCfgList(IProject project, String cfgId){ - Set set = null; - if(cfgId != null){ - set = new HashSet(); - set.add(cfgId); - } - - return createCfgList(project, set); - } - private ProjDesCfgList createCfgList(IProject project, Set cfgIdSet){ ICProjectDescription des = CProjectDescriptionManager.getInstance().getProjectDescription(project, false); if(des == null) @@ -563,56 +441,21 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP return new ProjDesCfgList(des, cfgIdSet); } - private void containerContentsChanged(ProjDesCfgList list, String[]cfgIds, CContainerRef ref, DeltaInfo deltaInfo){ - if(cfgIds != null && cfgIds.length != 0){ - for(int i = 0; i < cfgIds.length; i++){ - int num = list.getNumForId(cfgIds[i]); - if(num >= 0){ - CfgListCfgContainer cr = new CfgListCfgContainer(list, num); - containerContentsChanged(cr, ref, deltaInfo); - } - } - } else { - for(int i = 0; i < list.size(); i++){ - CfgListCfgContainer cr = new CfgListCfgContainer(list, i); - containerContentsChanged(cr, ref, deltaInfo); - } - } - } - - - private boolean containerContentsChanged(ICfgContainer cr, CContainerRef ref, DeltaInfo deltaInfo){ - return processContainerChange(OP_CHANGED, cr, ref, deltaInfo); - } - - private boolean processContainerChange(int op, - ICfgContainer cr, - CContainerRef crInfo, - DeltaInfo deltaInfo){ - return processContainerChange(op, cr, new CfgContainerRefInfoContainer(cr), crInfo, deltaInfo); - } - private boolean processContainerChange(int op, ICfgContainer cr, - ICRefInfoContainer riContainer, - CContainerRef crInfo, - DeltaInfo deltaInfo){ + CfgContainerRefInfoContainer riContainer, + CContainerRef crInfo){ ICConfigurationDescription cfg = cr.getConfguration(false); ExtSettingsDelta[] deltas = checkExternalSettingsChange(op, cfg.getProjectDescription().getProject(), cfg, riContainer, crInfo); - if(deltas != null){ - return applyDeltas(cr, deltas); - } + if(deltas != null) + return CExternalSettingsDeltaProcessor.applyDelta(cr.getConfguration(true), deltas); return false; } - private boolean applyDeltas(ICfgContainer cr, ExtSettingsDelta[] deltas){ - return CExternalSettingsDeltaProcessor.applyDelta(cr.getConfguration(true), deltas); - } - private static class RefInfoContainer{ CSettingsRefInfo fRefInfo; int fInstanceId; @@ -666,17 +509,41 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP public void handleEvent(CProjectDescriptionEvent event) { switch(event.getEventType()){ - case CProjectDescriptionEvent.DATA_APPLIED: - checkStore(event.getNewCProjectDescription()); + case CProjectDescriptionEvent.DATA_APPLIED: { + ICProjectDescription des = event.getNewCProjectDescription(); + if(des == null) + return; + + ICConfigurationDescription[] cfgs = des.getConfigurations(); + for(int i = 0; i < cfgs.length; i++){ + ICConfigurationDescription cfg = cfgs[i]; + RefInfoContainer cr = (RefInfoContainer)cfg.getSessionProperty(EXTERNAL_SETTING_PROPERTY); + if(cr != null/* && cr.fInstanceId != cfg.hashCode()*/){ + store(cfg, cr.fRefInfo); + } + } + break; + } case CProjectDescriptionEvent.LOADED: - final SettingsUpdateStatus status = update(event.getNewCProjectDescription()); - if(status.isChanged()){ + ProjDesCfgList list = new ProjDesCfgList(event.getNewCProjectDescription(), null); + boolean changed = false; + for(int i = 0; i < list.size(); i++){ + CfgListCfgContainer cfgCr = new CfgListCfgContainer(list, i); + CfgContainerRefInfoContainer ric = new CfgContainerRefInfoContainer(cfgCr); + CContainerRef[] refs = ric.getRefInfo(false).getReferences(); + for(int k = 0; k < refs.length; k++) { + if(processContainerChange(OP_CHANGED, cfgCr, new CfgContainerRefInfoContainer(cfgCr), refs[k])) + changed = true; + } + } + // TODO firing an asynchronous setProjectDescription here is likely to lead to trouble... + final ICProjectDescription prjDesc = list.fProjDes; + if(changed){ IWorkspaceRunnable r = new IWorkspaceRunnable(){ public void run(IProgressMonitor monitor) throws CoreException { - ICProjectDescription des = status.getCProjectDescription(); - CProjectDescriptionManager.getInstance().setProjectDescription(des.getProject(), des); + CProjectDescriptionManager.getInstance().setProjectDescription(prjDesc.getProject(), prjDesc); } }; @@ -686,23 +553,6 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP } } - private void checkStore(ICProjectDescription des){ - if(des == null) - return; - - ICConfigurationDescription[] cfgs = des.getConfigurations(); - for(int i = 0; i < cfgs.length; i++){ - checkStore(cfgs[i]); - } - } - - private void checkStore(ICConfigurationDescription cfg){ - RefInfoContainer cr = (RefInfoContainer)cfg.getSessionProperty(EXTERNAL_SETTING_PROPERTY); - if(cr != null/* && cr.fInstanceId != cfg.hashCode()*/){ - store(cfg, cr.fRefInfo); - } - } - private void store(ICConfigurationDescription cfg, CSettingsRefInfo ri){ try { ICStorageElement el = cfg.getStorage(EXTERNAL_SETTING_STORAGE_ID, true); @@ -715,17 +565,17 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP public void containerContentsChanged(ICConfigurationDescription cfg, CContainerRef cr){ CfgContainer ccr = new CfgContainer(cfg); - containerContentsChanged(ccr, cr, null); + processContainerChange(OP_CHANGED, ccr, new CfgContainerRefInfoContainer(ccr), cr); } public void addContainer(ICConfigurationDescription cfg, CContainerRef cr){ CfgContainer ccr = new CfgContainer(cfg); - processContainerChange(OP_ADDED, ccr, cr, null); + processContainerChange(OP_ADDED, ccr, new CfgContainerRefInfoContainer(ccr), cr); } public void removeContainer(ICConfigurationDescription cfg, CContainerRef cr){ CfgContainer ccr = new CfgContainer(cfg); - processContainerChange(OP_REMOVED, ccr, cr, null); + processContainerChange(OP_REMOVED, ccr, new CfgContainerRefInfoContainer(ccr), cr); } public CContainerRef[] getReferences(ICConfigurationDescription cfg, String factoryId){ @@ -733,25 +583,10 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP return info.getReferences(factoryId); } - public SettingsUpdateStatus update(ICProjectDescription des){ - ProjDesCfgList list = new ProjDesCfgList(des, null); - boolean changed = false; - for(int i = 0; i < list.size(); i++){ - CfgListCfgContainer cfgCr = new CfgListCfgContainer(list, i); - CfgContainerRefInfoContainer ric = new CfgContainerRefInfoContainer(cfgCr); - CContainerRef[] refs = ric.getRefInfo(false).getReferences(); - for(int k = 0; k < refs.length; k++) { - if(containerContentsChanged(cfgCr, refs[k], null)) - changed = true; - } - } - return new SettingsUpdateStatus(list.fProjDes, changed); - } - private ExtSettingsDelta[] checkExternalSettingsChange(int op, IProject proj, ICConfigurationDescription cfgDes, - ICRefInfoContainer riContainer, + CfgContainerRefInfoContainer riContainer, CContainerRef cr){ HolderContainer hCr = new HolderContainer(riContainer, cr); CRefSettingsHolder holder = hCr.getHolder(false); @@ -759,45 +594,35 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP holder = new CRefSettingsHolder(cr); hCr.setHolder(holder); } - + if(holder == null) return null; - - ExtSettingsDelta[] deltas = reconsile(proj, cfgDes, op != OP_REMOVED, hCr, cr); - + + CExternalSetting[] newSettings = null; + CExternalSetting[] oldSettings = hCr.getHolder(false).getExternalSettings(); + if (op != OP_REMOVED) { + FactoryDescriptor dr = getFactoryDescriptor(cr.getFactoryId()); + ContainerDescriptor cdr = new ContainerDescriptor(dr, cr.getContainerId(), proj, cfgDes, oldSettings); + newSettings = cdr.getExternalSettings(); + } + + ExtSettingsDelta[] deltas = CExternalSettinsDeltaCalculator.getInstance().getSettingChange(newSettings, oldSettings); + if(deltas != null) { + CRefSettingsHolder holder1 = hCr.getHolder(true); + holder1.setExternalSettings(newSettings, false); + holder1.setReconsiled(true); + } + if(op == OP_REMOVED) hCr.removeHolder(); return deltas; } - private ExtSettingsDelta[] reconsile(IProject proj, ICConfigurationDescription cfgDes, boolean addOrChange, HolderContainer hCr, CContainerRef cr){ -// if(holder.isReconsiled()) -// return; - CExternalSetting[] newSettings = null; - CExternalSetting[] oldSettings = hCr.getHolder(false).getExternalSettings(); - if (addOrChange) { - ContainerDescriptor cdr = createDescriptor(cr.getFactoryId(), cr.getContainerId(), proj, cfgDes, oldSettings); - newSettings = cdr.getExternalSettings(); - } - - ExtSettingsDelta[] deltas = getDeltaCalculator().getSettingChange(newSettings, oldSettings); - if(deltas != null){ - CRefSettingsHolder holder = hCr.getHolder(true); - holder.setExternallSettings(newSettings); - holder.setReconsiled(true); - } - return deltas; - } - - private CExternalSettinsDeltaCalculator getDeltaCalculator(){ - return CExternalSettinsDeltaCalculator.getInstance(); - } - public void restoreSourceEntryDefaults(ICConfigurationDescription cfg){ CfgContainer cr = new CfgContainer(cfg); CfgContainerRefInfoContainer ric = new CfgContainerRefInfoContainer(cr); CExternalSetting[] settings = ric.getRefInfo(false).createExternalSettings(); - ExtSettingsDelta[] deltas = getDeltaCalculator().getSettingChange(settings, null); + ExtSettingsDelta[] deltas = CExternalSettinsDeltaCalculator.getInstance().getSettingChange(settings, null); if(deltas != null){ CExternalSettingsDeltaProcessor.applySourceEntriesChange(cfg, deltas); } @@ -807,7 +632,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP CfgContainer cr = new CfgContainer(cfg); CfgContainerRefInfoContainer ric = new CfgContainerRefInfoContainer(cr); CExternalSetting[] settings = ric.getRefInfo(false).createExternalSettings(); - ExtSettingsDelta[] deltas = getDeltaCalculator().getSettingChange(settings, null); + ExtSettingsDelta[] deltas = CExternalSettinsDeltaCalculator.getInstance().getSettingChange(settings, null); if(deltas != null){ CExternalSettingsDeltaProcessor.applyOutputEntriesChange(cfg, deltas); } @@ -818,7 +643,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP CfgContainer cr = new CfgContainer(cfg); CfgContainerRefInfoContainer ric = new CfgContainerRefInfoContainer(cr); CExternalSetting[] settings = ric.getRefInfo(false).createExternalSettings(); - ExtSettingsDelta[] deltas = getDeltaCalculator().getSettingChange(settings, null); + ExtSettingsDelta[] deltas = CExternalSettinsDeltaCalculator.getInstance().getSettingChange(settings, null); if(deltas != null){ CExternalSettingsDeltaProcessor.applyDelta(ls, deltas, entryKinds); } diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CSettingsRefInfo.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CSettingsRefInfo.java index abb2fb356f0..99a0df77ef7 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CSettingsRefInfo.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/CSettingsRefInfo.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Intel Corporation and others. + * Copyright (c) 2007, 2010 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 @@ -53,21 +53,6 @@ class CSettingsRefInfo { e.setValue(h); } } - -// Map getContainerMapForFactory(String id){ -// Map map = new HashMap(); -// for(Iterator iter = fESHolderMap.entrySet().iterator(); iter.hasNext();){ -// Map.Entry entry = (Map.Entry)iter.next(); -// CContainerRef r = (CContainerRef)entry.getKey(); -// if(r.getFactoryId().equals(id)) -// map.put(r.getContainerId(), r); -// } -// return map; -// } - -// Map getContainerMapCopy(){ -// return new HashMap(fESHolderMap); -// } CContainerRef[] getReferences(String factoryId){ List list = new ArrayList(); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICExternalSettingsListener.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICExternalSettingsListener.java index 722b2b00912..010762f812f 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICExternalSettingsListener.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/settings/model/ICExternalSettingsListener.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Intel Corporation and others. + * Copyright (c) 2007, 2010 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 @@ -16,5 +16,13 @@ import org.eclipse.core.resources.IProject; * Listener for external settings changes */ public interface ICExternalSettingsListener { + + /** + * Notifies the listener that the configuration with id cfgId has changed in the project + * project. + * @param project or null indicating all projects should be considered + * @param cfgId or null indicating all configurations should be considered + * @param event CExternalSettingsChangeEvent + */ void settingsChanged(IProject project, String cfgId, CExternalSettingChangeEvent event); }