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

bug 299858: Project Explorer is not notified when FolderDescription is created for an existing folder

This commit is contained in:
Andrew Gvozdev 2010-01-18 02:53:40 +00:00
parent f9be7ba9d5
commit 2c098ef25a
2 changed files with 39 additions and 37 deletions

View file

@ -1975,7 +1975,12 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
return list;
}
private List<CElementDelta> generateCElementDeltasFromResourceDelta(ICProject cProject, ICDescriptionDelta delta, List<CElementDelta> list){
/**
* The method maps {@link ICDescriptionDelta} to {@link CElementDelta} which are added to the {@code list}.
* The delta will indicate modification of CElement for a given resource plus language settings
* if they changed (relative to parent resource description if the resource has no its own).
*/
private void generateCElementDeltasFromResourceDelta(ICProject cProject, ICDescriptionDelta delta, List<CElementDelta> list){
int kind = delta.getDeltaKind();
ICDescriptionDelta parentDelta = delta.getParent();
@ -1991,21 +1996,17 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
case ICDescriptionDelta.ADDED:
newRcDes = (ICResourceDescription)delta.getNewSetting();
path = newRcDes.getPath();
oldRcDes = null;
oldRcDes = ((ICConfigurationDescription)parentDelta.getOldSetting()).getResourceDescription(path, false);
break;
case ICDescriptionDelta.CHANGED:
// if((delta.getChangeFlags() & ICProjectDescriptionDelta.PATH) == 0){
newRcDes = (ICResourceDescription)delta.getNewSetting();
path = newRcDes.getPath();
oldRcDes = (ICResourceDescription)delta.getOldSetting();
break;
// }
// //if path changed treat as default
default:
newRcDes = (ICResourceDescription)delta.getNewSetting();
path = newRcDes.getPath();
oldRcDes = ((ICConfigurationDescription)parentDelta.getOldSetting()).getResourceDescription(path, false);
break;
// Not possible
CCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, SettingsModelMessages.getString("CProjectDescriptionManager.illegalDeltaKind")+kind)); //$NON-NLS-1$
return;
}
path = path.makeRelative();
@ -2013,11 +2014,15 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
try {
el = cProject.findElement(path);
} catch (CModelException e) {
return list;
return;
}
IResource rc = el.getResource();
if(rc != null){
CElementDelta ceRcDelta = new CElementDelta(el.getCModel());
ceRcDelta.changed(el, ICElementDelta.F_MODIFIERS);
list.add(ceRcDelta);
if(rc.getType() == IResource.FILE){
String fileName = path.lastSegment();
ICLanguageSetting newLS = getLanguageSetting(newRcDes, fileName);
@ -2025,34 +2030,29 @@ public class CProjectDescriptionManager implements ICProjectDescriptionManager {
ICDescriptionDelta ld = createDelta(newLS, oldLS);
generateCElementDeltasFromLanguageDelta(el, ld, list);
} else {
if(newRcDes.getType() == ICSettingBase.SETTING_FOLDER){
ICFolderDescription oldFoDes = null;
if (oldRcDes != null) {
if (oldRcDes.getType() == ICSettingBase.SETTING_FOLDER)
oldFoDes = (ICFolderDescription)oldRcDes;
if(newRcDes.getType() != ICSettingBase.SETTING_FOLDER){
CCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, SettingsModelMessages.getString("CProjectDescriptionManager.wrongTypeOfResourceDescription")+newRcDes)); //$NON-NLS-1$
return;
}
ICDescriptionDelta folderDelta = createDelta((ICFolderDescription)newRcDes, oldFoDes);
if(folderDelta != null){
CElementDelta cElDelta = new CElementDelta(el.getCModel());
cElDelta.changed(el, ICElementDelta.F_MODIFIERS);
list.add(cElDelta);
ICFolderDescription newFoDes = (ICFolderDescription)newRcDes;
ICDescriptionDelta children[] = folderDelta.getChildren();
ICDescriptionDelta child;
for(int i = 0; i < children.length; i++){
child = children[i];
if(oldRcDes.getType() != ICSettingBase.SETTING_FOLDER){
CCorePlugin.log(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, SettingsModelMessages.getString("CProjectDescriptionManager.wrongTypeOfResourceDescription")+oldRcDes)); //$NON-NLS-1$
return;
}
ICFolderDescription oldFoDes = (ICFolderDescription)oldRcDes;
ICDescriptionDelta folderDelta = createDelta(newFoDes, oldFoDes);
if (folderDelta != null) {
for (ICDescriptionDelta child : folderDelta.getChildren()) {
if(child.getSettingType() == ICSettingBase.SETTING_LANGUAGE){
generateCElementDeltasFromLanguageDelta(el, child, list);
}
}
}
} else {
//ERROR?
}
}
}
return list;
}
private ICLanguageSetting getLanguageSetting(ICResourceDescription rcDes, String fileName){

View file

@ -38,6 +38,8 @@ CProjectDescriptionManager.15=Preference Configuration
CProjectDescriptionManager.16=attempt to set description for the non-openned project
CProjectDescriptionManager.17=unable to apply the invalid project description for project
CProjectDescriptionManager.cfgIDAlreadyExists=Configuration with ID: {0} already exists in passed in settings storage
CProjectDescriptionManager.illegalDeltaKind=Illegal delta kind
CProjectDescriptionManager.wrongTypeOfResourceDescription=Wrong type of resource description:
CFolderDescription.0=data was not created
CFolderDescription.1=expected proxy of type ICLanguageSetting, but was
CFolderDescription.2=data was not created