diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java index 989077a59fc..4244662e509 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java @@ -396,7 +396,7 @@ public class CFileTypesPreferenceBlock { } } - private IContentType[] getRegistedContentTypes() { + public IContentType[] getRegistedContentTypes() { if (fContentTypes == null) { String [] ids = CoreModel.getRegistedContentTypeIds(); IContentTypeManager manager = Platform.getContentTypeManager(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java index 3cc94430470..f626e152695 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java @@ -208,25 +208,25 @@ public class CFileTypesPropertyPage extends PropertyPage { return false; } + /** + * We are looking at the association from the project, if we have any + * we should generate an event. + * @param project + */ void computeEvents(IProject project) { IScopeContext projectScope = new ProjectScope(project); - - // Calculate the events to tell the clients of changes - IContentTypeManager manager = Platform.getContentTypeManager(); - IContentType[] ctypes = manager.getAllContentTypes(); + IContentType[] ctypes = fPrefsBlock.getRegistedContentTypes(); ArrayList list = new ArrayList(ctypes.length); for (int i = 0; i < ctypes.length; i++) { IContentType ctype = ctypes[i]; try { IContentTypeSettings projectSettings = ctype.getSettings(projectScope); - String[] globalSpecs = ctypes[i].getFileSpecs(IContentType.FILE_EXTENSION_SPEC); String[] projectSpecs = projectSettings.getFileSpecs(IContentType.FILE_EXTENSION_SPEC); - if (isSpecsChanged(globalSpecs, projectSpecs)) { + if (projectSpecs!= null && projectSpecs.length > 0) { list.add(ctype); } else { - globalSpecs = ctypes[i].getFileSpecs(IContentType.FILE_NAME_SPEC); projectSpecs = projectSettings.getFileSpecs(IContentType.FILE_NAME_SPEC); - if (isSpecsChanged(globalSpecs, projectSpecs)) { + if (projectSpecs != null && projectSpecs.length > 0) { list.add(ctype); } } @@ -234,6 +234,7 @@ public class CFileTypesPropertyPage extends PropertyPage { // ignore ? } } + // fire the events for (int i = 0; i < list.size(); ++i) { IContentType source = (IContentType)list.get(i); @@ -242,6 +243,41 @@ public class CFileTypesPropertyPage extends PropertyPage { } } +// void computeEvents(IProject project) { +// IScopeContext projectScope = new ProjectScope(project); +// +// // Calculate the events to tell the clients of changes +// //IContentTypeManager manager = Platform.getContentTypeManager(); +// //IContentType[] ctypes = manager.getAllContentTypes(); +// IContentType[] ctypes = fPrefsBlock.getRegistedContentTypes(); +// ArrayList list = new ArrayList(ctypes.length); +// for (int i = 0; i < ctypes.length; i++) { +// IContentType ctype = ctypes[i]; +// try { +// IContentTypeSettings projectSettings = ctype.getSettings(projectScope); +// String[] globalSpecs = ctypes[i].getFileSpecs(IContentType.FILE_EXTENSION_SPEC); +// String[] projectSpecs = projectSettings.getFileSpecs(IContentType.FILE_EXTENSION_SPEC); +// if (isSpecsChanged(globalSpecs, projectSpecs)) { +// list.add(ctype); +// } else { +// globalSpecs = ctypes[i].getFileSpecs(IContentType.FILE_NAME_SPEC); +// projectSpecs = projectSettings.getFileSpecs(IContentType.FILE_NAME_SPEC); +// if (isSpecsChanged(globalSpecs, projectSpecs)) { +// list.add(ctype); +// } +// } +// } catch (CoreException e) { +// // ignore ? +// } +// } +// // fire the events +// for (int i = 0; i < list.size(); ++i) { +// IContentType source = (IContentType)list.get(i); +// IContentTypeManager.ContentTypeChangeEvent event = new IContentTypeManager.ContentTypeChangeEvent(source, projectScope); +// CModelManager.getDefault().contentTypeChanged(event); +// } +// } + boolean isSpecsChanged(String[] newSpecs, String[] oldSpecs) { if (newSpecs.length != oldSpecs.length) { return true;