mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-20 23:45:23 +02:00
Bug 312575 tidy patch
This commit is contained in:
parent
24f6fec914
commit
e4d218aa70
5 changed files with 134 additions and 326 deletions
|
@ -10,23 +10,17 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.settings.model;
|
package org.eclipse.cdt.internal.core.settings.model;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
/**
|
||||||
import java.util.Arrays;
|
* External setting change event
|
||||||
import java.util.List;
|
*/
|
||||||
|
|
||||||
class CExternalSettingChangeEvent {
|
class CExternalSettingChangeEvent {
|
||||||
private List<CExternalSettingsContainerChangeInfo> fChangeInfoList = new ArrayList<CExternalSettingsContainerChangeInfo>();
|
private final CExternalSettingsContainerChangeInfo[] fChangeInfos;
|
||||||
|
|
||||||
CExternalSettingChangeEvent(CExternalSettingsContainerChangeInfo[] infos){
|
CExternalSettingChangeEvent(CExternalSettingsContainerChangeInfo[] infos){
|
||||||
fChangeInfoList.addAll(Arrays.asList(infos));
|
fChangeInfos = infos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// void add(CExternalSettingsContainerChangeInfo info){
|
|
||||||
// fChangeInfoList.add(info);
|
|
||||||
// }
|
|
||||||
|
|
||||||
public CExternalSettingsContainerChangeInfo[] getChangeInfos(){
|
public CExternalSettingsContainerChangeInfo[] getChangeInfos(){
|
||||||
return fChangeInfoList.toArray(
|
return fChangeInfos;
|
||||||
new CExternalSettingsContainerChangeInfo[fChangeInfoList.size()]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,10 +71,6 @@ public class CExternalSettingsHolder extends CExternalSettingsContainer {
|
||||||
return EMPTY_EXT_SETTINGS_ARRAY;
|
return EMPTY_EXT_SETTINGS_ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setExternallSettings(CExternalSetting[] settings){
|
|
||||||
setExternalSettings(settings, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setExternalSettings(CExternalSetting[] settings, boolean add){
|
void setExternalSettings(CExternalSetting[] settings, boolean add){
|
||||||
if(!add)
|
if(!add)
|
||||||
removeExternalSettings();
|
removeExternalSettings();
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Intel Corporation - Initial API and implementation
|
* Intel Corporation - Initial API and implementation
|
||||||
|
* James Blackburn (Broadcom Corp.)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.settings.model;
|
package org.eclipse.cdt.internal.core.settings.model;
|
||||||
|
|
||||||
|
@ -46,23 +47,6 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
private Map<String, FactoryDescriptor> fFactoryMap = new HashMap<String, FactoryDescriptor>();
|
private Map<String, FactoryDescriptor> fFactoryMap = new HashMap<String, FactoryDescriptor>();
|
||||||
private static CExternalSettingsManager fInstance;
|
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(){
|
private CExternalSettingsManager(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,9 +121,6 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
}
|
}
|
||||||
private static class ContainerDescriptor {
|
private static class ContainerDescriptor {
|
||||||
private FactoryDescriptor fFactoryDr;
|
private FactoryDescriptor fFactoryDr;
|
||||||
// private String fContainerId;
|
|
||||||
// private String fProjectName;
|
|
||||||
// private String fCfgId;
|
|
||||||
private CExternalSettingsHolder fHolder;
|
private CExternalSettingsHolder fHolder;
|
||||||
|
|
||||||
private CExternalSettingsContainer fContainer;
|
private CExternalSettingsContainer fContainer;
|
||||||
|
@ -150,9 +131,6 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
ICConfigurationDescription cfgDes,
|
ICConfigurationDescription cfgDes,
|
||||||
CExternalSetting[] previousSettings){
|
CExternalSetting[] previousSettings){
|
||||||
fFactoryDr = factoryDr;
|
fFactoryDr = factoryDr;
|
||||||
// fContainerId = containerId;
|
|
||||||
// fProjectName = project.getName();
|
|
||||||
// fCfgId = cfgDes.getId();
|
|
||||||
try {
|
try {
|
||||||
fContainer = fFactoryDr.getFactory().createContainer(containerId, project, cfgDes, previousSettings);
|
fContainer = fFactoryDr.getFactory().createContainer(containerId, project, cfgDes, previousSettings);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -165,24 +143,11 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
public CExternalSetting[] getExternalSettings(){
|
public CExternalSetting[] getExternalSettings(){
|
||||||
if(fHolder == null){
|
if(fHolder == null){
|
||||||
fHolder = new CExternalSettingsHolder();
|
fHolder = new CExternalSettingsHolder();
|
||||||
fHolder.setExternallSettings(fContainer.getExternalSettings());
|
fHolder.setExternalSettings(fContainer.getExternalSettings(), false);
|
||||||
}
|
}
|
||||||
return fHolder.getExternalSettings();
|
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 class FactoryDescriptor {
|
||||||
private CExternalSettingContainerFactory fFactory;
|
private CExternalSettingContainerFactory fFactory;
|
||||||
private String fId;
|
private String fId;
|
||||||
// private Map fContainerMap;
|
|
||||||
|
|
||||||
private FactoryDescriptor(String id){
|
private FactoryDescriptor(String id){
|
||||||
fId = id;
|
fId = id;
|
||||||
|
@ -233,10 +197,6 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
return NullFactory.INSTANCE;
|
return NullFactory.INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public String getId(){
|
|
||||||
// return fId;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public void shutdown(){
|
public void shutdown(){
|
||||||
if(fFactory != null){
|
if(fFactory != null){
|
||||||
fFactory.removeListener(CExternalSettingsManager.this);
|
fFactory.removeListener(CExternalSettingsManager.this);
|
||||||
|
@ -248,8 +208,6 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
|
|
||||||
private interface ICfgContainer {
|
private interface ICfgContainer {
|
||||||
ICConfigurationDescription getConfguration(boolean write);
|
ICConfigurationDescription getConfguration(boolean write);
|
||||||
|
|
||||||
// boolean isWritable();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class CfgContainer implements ICfgContainer {
|
private static class CfgContainer implements ICfgContainer {
|
||||||
|
@ -265,11 +223,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private interface ICRefInfoContainer {
|
private class CfgContainerRefInfoContainer {
|
||||||
CSettingsRefInfo getRefInfo(boolean write);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class CfgContainerRefInfoContainer implements ICRefInfoContainer{
|
|
||||||
private ICfgContainer fCfgContainer;
|
private ICfgContainer fCfgContainer;
|
||||||
private CSettingsRefInfo fRefInfo;
|
private CSettingsRefInfo fRefInfo;
|
||||||
private boolean fWriteWasRequested;
|
private boolean fWriteWasRequested;
|
||||||
|
@ -289,33 +243,13 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private class CfgRefInfoContainer implements ICRefInfoContainer{
|
private static class HolderContainer {
|
||||||
// private CSettingsRefInfo fRefInfo;
|
private CfgContainerRefInfoContainer fRIContainer;
|
||||||
// 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 CRefSettingsHolder fHolder;
|
private CRefSettingsHolder fHolder;
|
||||||
private boolean fWriteWasRequested;
|
private boolean fWriteWasRequested;
|
||||||
private CContainerRef fCRef;
|
private CContainerRef fCRef;
|
||||||
|
|
||||||
HolderContainer(ICRefInfoContainer cr, CContainerRef cref){
|
HolderContainer(CfgContainerRefInfoContainer cr, CContainerRef cref){
|
||||||
fRIContainer = cr;
|
fRIContainer = cr;
|
||||||
fCRef = cref;
|
fCRef = cref;
|
||||||
}
|
}
|
||||||
|
@ -344,10 +278,10 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class CfgListCfgContainer implements ICfgContainer{
|
private static class CfgListCfgContainer implements ICfgContainer{
|
||||||
private ICfgList fList;
|
private ProjDesCfgList fList;
|
||||||
private int fNum;
|
private int fNum;
|
||||||
|
|
||||||
CfgListCfgContainer(ICfgList list, int num){
|
CfgListCfgContainer(ProjDesCfgList list, int num){
|
||||||
fList = list;
|
fList = list;
|
||||||
fNum = num;
|
fNum = num;
|
||||||
}
|
}
|
||||||
|
@ -355,19 +289,13 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
public ICConfigurationDescription getConfguration(boolean write) {
|
public ICConfigurationDescription getConfguration(boolean write) {
|
||||||
return fList.get(fNum, write);
|
return fList.get(fNum, write);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public boolean isWritable() {
|
|
||||||
// return !getConfguration(false).isReadOnly();
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private interface ICfgList {
|
/**
|
||||||
ICConfigurationDescription get(int num, boolean write);
|
* A simple container type that contains a Project Description & and associated list
|
||||||
|
* of configuration descriptions.
|
||||||
int size();
|
*/
|
||||||
}
|
private static class ProjDesCfgList {
|
||||||
|
|
||||||
private static class ProjDesCfgList implements ICfgList{
|
|
||||||
private ICProjectDescription fProjDes;
|
private ICProjectDescription fProjDes;
|
||||||
private List<ICConfigurationDescription> fCfgList = new ArrayList<ICConfigurationDescription>();
|
private List<ICConfigurationDescription> fCfgList = new ArrayList<ICConfigurationDescription>();
|
||||||
|
|
||||||
|
@ -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() {
|
public int size() {
|
||||||
return fCfgList.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){
|
private FactoryDescriptor getFactoryDescriptor(String id){
|
||||||
FactoryDescriptor dr = fFactoryMap.get(id);
|
FactoryDescriptor dr = fFactoryMap.get(id);
|
||||||
if(dr == null){
|
if(dr == null){
|
||||||
|
@ -453,39 +351,30 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
return dr.getFactory();
|
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,
|
public void settingsChanged(IProject project, String cfgId,
|
||||||
CExternalSettingChangeEvent event) {
|
CExternalSettingChangeEvent event) {
|
||||||
ProjDesCfgList[] lists = null;
|
ProjDesCfgList[] lists = null;
|
||||||
CExternalSettingsContainerChangeInfo[] infos = event.getChangeInfos();
|
CExternalSettingsContainerChangeInfo[] infos = event.getChangeInfos();
|
||||||
for(int i = 0; i < infos.length; i++){
|
for (CExternalSettingsContainerChangeInfo info : infos) {
|
||||||
CExternalSettingsContainerChangeInfo info = infos[i];
|
|
||||||
switch(info.getEventType()){
|
switch(info.getEventType()){
|
||||||
case CExternalSettingsContainerChangeInfo.CHANGED:
|
case CExternalSettingsContainerChangeInfo.CHANGED:
|
||||||
int flags = info.getChangeFlags();
|
int flags = info.getChangeFlags();
|
||||||
if((flags & CExternalSettingsContainerChangeInfo.CONTAINER_CONTENTS) != 0){
|
if((flags & CExternalSettingsContainerChangeInfo.CONTAINER_CONTENTS) != 0){
|
||||||
if(lists == null)
|
if(lists == null)
|
||||||
lists = createCfgListsForEvent(project, cfgId);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(lists != null)
|
// TODO modifying the project description in an asynchronous runnable is likely bad...
|
||||||
applyLists(lists);
|
if(lists != null) {
|
||||||
}
|
|
||||||
|
|
||||||
private void applyLists(ProjDesCfgList[] lists){
|
|
||||||
final List<ICProjectDescription> list = getModifiedProjDesList(lists);
|
final List<ICProjectDescription> list = getModifiedProjDesList(lists);
|
||||||
if(list.size() != 0){
|
if(list.size() != 0){
|
||||||
IWorkspaceRunnable r = new IWorkspaceRunnable(){
|
IWorkspaceRunnable r = new IWorkspaceRunnable(){
|
||||||
|
@ -496,12 +385,11 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
CProjectDescriptionManager.getInstance().setProjectDescription(des.getProject(), des, false, monitor);
|
CProjectDescriptionManager.getInstance().setProjectDescription(des.getProject(), des, false, monitor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
CProjectDescriptionManager.runWspModification(r, new NullProgressMonitor());
|
CProjectDescriptionManager.runWspModification(r, new NullProgressMonitor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private List<ICProjectDescription> getModifiedProjDesList(ProjDesCfgList[] lists){
|
private List<ICProjectDescription> getModifiedProjDesList(ProjDesCfgList[] lists){
|
||||||
List<ICProjectDescription> list = new ArrayList<ICProjectDescription>();
|
List<ICProjectDescription> list = new ArrayList<ICProjectDescription>();
|
||||||
|
@ -512,47 +400,37 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void containerContentsChanged(ProjDesCfgList[] lists, CContainerRef ref, DeltaInfo deltaInfo){
|
/**
|
||||||
for(int i = 0; i < lists.length; i++){
|
* Returns an array of ProjDescCfgList corresponding to the passed in project + cfgId
|
||||||
containerContentsChanged(lists[i], null, ref, deltaInfo);
|
* @param project project, or null
|
||||||
}
|
* @param cfgId configuration ID, or null
|
||||||
}
|
* @return ProjDescCfgList[]
|
||||||
|
*/
|
||||||
private ProjDesCfgList[] createCfgListsForEvent(IProject project, String cfgId){
|
private ProjDesCfgList[] createCfgListsForEvent(IProject project, String cfgId){
|
||||||
ProjDesCfgList lists[];
|
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];
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
lists = createCfgLists();
|
|
||||||
}
|
|
||||||
return lists;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ProjDesCfgList[] createCfgLists(){
|
|
||||||
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
|
|
||||||
List<ProjDesCfgList> list = new ArrayList<ProjDesCfgList>();
|
|
||||||
for(int i = 0; i < projects.length; i++){
|
|
||||||
ProjDesCfgList l = createCfgList(projects[i], (Set<String>)null);
|
|
||||||
if(l != null)
|
|
||||||
list.add(l);
|
|
||||||
}
|
|
||||||
return list.toArray(new ProjDesCfgList[list.size()]);
|
|
||||||
}
|
|
||||||
|
|
||||||
private ProjDesCfgList createCfgList(IProject project, String cfgId){
|
|
||||||
Set<String> set = null;
|
Set<String> set = null;
|
||||||
|
if(project != null) {
|
||||||
if(cfgId != null){
|
if(cfgId != null){
|
||||||
set = new HashSet<String>();
|
set = new HashSet<String>();
|
||||||
set.add(cfgId);
|
set.add(cfgId);
|
||||||
}
|
}
|
||||||
|
ProjDesCfgList l = createCfgList(project, set);
|
||||||
return createCfgList(project, set);
|
if(l != null)
|
||||||
|
lists = new ProjDesCfgList[] { l };
|
||||||
|
else
|
||||||
|
lists = new ProjDesCfgList[0];
|
||||||
|
} else {
|
||||||
|
// Project is null -- add all CDT projects & configs in the workspace
|
||||||
|
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
|
||||||
|
List<ProjDesCfgList> list = new ArrayList<ProjDesCfgList>();
|
||||||
|
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 createCfgList(IProject project, Set<String> cfgIdSet){
|
private ProjDesCfgList createCfgList(IProject project, Set<String> cfgIdSet){
|
||||||
|
@ -563,54 +441,19 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
return new ProjDesCfgList(des, cfgIdSet);
|
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,
|
private boolean processContainerChange(int op,
|
||||||
ICfgContainer cr,
|
ICfgContainer cr,
|
||||||
CContainerRef crInfo,
|
CfgContainerRefInfoContainer riContainer,
|
||||||
DeltaInfo deltaInfo){
|
CContainerRef crInfo){
|
||||||
return processContainerChange(op, cr, new CfgContainerRefInfoContainer(cr), crInfo, deltaInfo);
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean processContainerChange(int op,
|
|
||||||
ICfgContainer cr,
|
|
||||||
ICRefInfoContainer riContainer,
|
|
||||||
CContainerRef crInfo,
|
|
||||||
DeltaInfo deltaInfo){
|
|
||||||
|
|
||||||
ICConfigurationDescription cfg = cr.getConfguration(false);
|
ICConfigurationDescription cfg = cr.getConfguration(false);
|
||||||
|
|
||||||
ExtSettingsDelta[] deltas = checkExternalSettingsChange(op,
|
ExtSettingsDelta[] deltas = checkExternalSettingsChange(op,
|
||||||
cfg.getProjectDescription().getProject(), cfg, riContainer, crInfo);
|
cfg.getProjectDescription().getProject(), cfg, riContainer, crInfo);
|
||||||
|
|
||||||
if(deltas != null){
|
if(deltas != null)
|
||||||
return applyDeltas(cr, deltas);
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean applyDeltas(ICfgContainer cr, ExtSettingsDelta[] deltas){
|
|
||||||
return CExternalSettingsDeltaProcessor.applyDelta(cr.getConfguration(true), deltas);
|
return CExternalSettingsDeltaProcessor.applyDelta(cr.getConfguration(true), deltas);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class RefInfoContainer{
|
private static class RefInfoContainer{
|
||||||
|
@ -666,17 +509,41 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
|
|
||||||
public void handleEvent(CProjectDescriptionEvent event) {
|
public void handleEvent(CProjectDescriptionEvent event) {
|
||||||
switch(event.getEventType()){
|
switch(event.getEventType()){
|
||||||
case CProjectDescriptionEvent.DATA_APPLIED:
|
case CProjectDescriptionEvent.DATA_APPLIED: {
|
||||||
checkStore(event.getNewCProjectDescription());
|
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;
|
break;
|
||||||
|
}
|
||||||
case CProjectDescriptionEvent.LOADED:
|
case CProjectDescriptionEvent.LOADED:
|
||||||
final SettingsUpdateStatus status = update(event.getNewCProjectDescription());
|
ProjDesCfgList list = new ProjDesCfgList(event.getNewCProjectDescription(), null);
|
||||||
if(status.isChanged()){
|
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(){
|
IWorkspaceRunnable r = new IWorkspaceRunnable(){
|
||||||
|
|
||||||
public void run(IProgressMonitor monitor) throws CoreException {
|
public void run(IProgressMonitor monitor) throws CoreException {
|
||||||
ICProjectDescription des = status.getCProjectDescription();
|
CProjectDescriptionManager.getInstance().setProjectDescription(prjDesc.getProject(), prjDesc);
|
||||||
CProjectDescriptionManager.getInstance().setProjectDescription(des.getProject(), des);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -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){
|
private void store(ICConfigurationDescription cfg, CSettingsRefInfo ri){
|
||||||
try {
|
try {
|
||||||
ICStorageElement el = cfg.getStorage(EXTERNAL_SETTING_STORAGE_ID, true);
|
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){
|
public void containerContentsChanged(ICConfigurationDescription cfg, CContainerRef cr){
|
||||||
CfgContainer ccr = new CfgContainer(cfg);
|
CfgContainer ccr = new CfgContainer(cfg);
|
||||||
containerContentsChanged(ccr, cr, null);
|
processContainerChange(OP_CHANGED, ccr, new CfgContainerRefInfoContainer(ccr), cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addContainer(ICConfigurationDescription cfg, CContainerRef cr){
|
public void addContainer(ICConfigurationDescription cfg, CContainerRef cr){
|
||||||
CfgContainer ccr = new CfgContainer(cfg);
|
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){
|
public void removeContainer(ICConfigurationDescription cfg, CContainerRef cr){
|
||||||
CfgContainer ccr = new CfgContainer(cfg);
|
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){
|
public CContainerRef[] getReferences(ICConfigurationDescription cfg, String factoryId){
|
||||||
|
@ -733,25 +583,10 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
return info.getReferences(factoryId);
|
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,
|
private ExtSettingsDelta[] checkExternalSettingsChange(int op,
|
||||||
IProject proj,
|
IProject proj,
|
||||||
ICConfigurationDescription cfgDes,
|
ICConfigurationDescription cfgDes,
|
||||||
ICRefInfoContainer riContainer,
|
CfgContainerRefInfoContainer riContainer,
|
||||||
CContainerRef cr){
|
CContainerRef cr){
|
||||||
HolderContainer hCr = new HolderContainer(riContainer, cr);
|
HolderContainer hCr = new HolderContainer(riContainer, cr);
|
||||||
CRefSettingsHolder holder = hCr.getHolder(false);
|
CRefSettingsHolder holder = hCr.getHolder(false);
|
||||||
|
@ -763,41 +598,31 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
if(holder == null)
|
if(holder == null)
|
||||||
return 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)
|
if(op == OP_REMOVED)
|
||||||
hCr.removeHolder();
|
hCr.removeHolder();
|
||||||
return deltas;
|
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){
|
public void restoreSourceEntryDefaults(ICConfigurationDescription cfg){
|
||||||
CfgContainer cr = new CfgContainer(cfg);
|
CfgContainer cr = new CfgContainer(cfg);
|
||||||
CfgContainerRefInfoContainer ric = new CfgContainerRefInfoContainer(cr);
|
CfgContainerRefInfoContainer ric = new CfgContainerRefInfoContainer(cr);
|
||||||
CExternalSetting[] settings = ric.getRefInfo(false).createExternalSettings();
|
CExternalSetting[] settings = ric.getRefInfo(false).createExternalSettings();
|
||||||
ExtSettingsDelta[] deltas = getDeltaCalculator().getSettingChange(settings, null);
|
ExtSettingsDelta[] deltas = CExternalSettinsDeltaCalculator.getInstance().getSettingChange(settings, null);
|
||||||
if(deltas != null){
|
if(deltas != null){
|
||||||
CExternalSettingsDeltaProcessor.applySourceEntriesChange(cfg, deltas);
|
CExternalSettingsDeltaProcessor.applySourceEntriesChange(cfg, deltas);
|
||||||
}
|
}
|
||||||
|
@ -807,7 +632,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
CfgContainer cr = new CfgContainer(cfg);
|
CfgContainer cr = new CfgContainer(cfg);
|
||||||
CfgContainerRefInfoContainer ric = new CfgContainerRefInfoContainer(cr);
|
CfgContainerRefInfoContainer ric = new CfgContainerRefInfoContainer(cr);
|
||||||
CExternalSetting[] settings = ric.getRefInfo(false).createExternalSettings();
|
CExternalSetting[] settings = ric.getRefInfo(false).createExternalSettings();
|
||||||
ExtSettingsDelta[] deltas = getDeltaCalculator().getSettingChange(settings, null);
|
ExtSettingsDelta[] deltas = CExternalSettinsDeltaCalculator.getInstance().getSettingChange(settings, null);
|
||||||
if(deltas != null){
|
if(deltas != null){
|
||||||
CExternalSettingsDeltaProcessor.applyOutputEntriesChange(cfg, deltas);
|
CExternalSettingsDeltaProcessor.applyOutputEntriesChange(cfg, deltas);
|
||||||
}
|
}
|
||||||
|
@ -818,7 +643,7 @@ public class CExternalSettingsManager implements ICExternalSettingsListener, ICP
|
||||||
CfgContainer cr = new CfgContainer(cfg);
|
CfgContainer cr = new CfgContainer(cfg);
|
||||||
CfgContainerRefInfoContainer ric = new CfgContainerRefInfoContainer(cr);
|
CfgContainerRefInfoContainer ric = new CfgContainerRefInfoContainer(cr);
|
||||||
CExternalSetting[] settings = ric.getRefInfo(false).createExternalSettings();
|
CExternalSetting[] settings = ric.getRefInfo(false).createExternalSettings();
|
||||||
ExtSettingsDelta[] deltas = getDeltaCalculator().getSettingChange(settings, null);
|
ExtSettingsDelta[] deltas = CExternalSettinsDeltaCalculator.getInstance().getSettingChange(settings, null);
|
||||||
if(deltas != null){
|
if(deltas != null){
|
||||||
CExternalSettingsDeltaProcessor.applyDelta(ls, deltas, entryKinds);
|
CExternalSettingsDeltaProcessor.applyDelta(ls, deltas, entryKinds);
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
* 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
|
||||||
|
@ -54,21 +54,6 @@ class CSettingsRefInfo {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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){
|
CContainerRef[] getReferences(String factoryId){
|
||||||
List<CContainerRef> list = new ArrayList<CContainerRef>();
|
List<CContainerRef> list = new ArrayList<CContainerRef>();
|
||||||
for (CContainerRef r : fESHolderMap.keySet()) {
|
for (CContainerRef r : fESHolderMap.keySet()) {
|
||||||
|
|
|
@ -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
|
* 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
|
||||||
|
@ -16,5 +16,13 @@ import org.eclipse.core.resources.IProject;
|
||||||
* Listener for external settings changes
|
* Listener for external settings changes
|
||||||
*/
|
*/
|
||||||
public interface ICExternalSettingsListener {
|
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);
|
void settingsChanged(IProject project, String cfgId, CExternalSettingChangeEvent event);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue