mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
compute the events from ContentType changes.
This commit is contained in:
parent
02c0ca6a3c
commit
4762d82ac6
2 changed files with 45 additions and 9 deletions
|
@ -396,7 +396,7 @@ public class CFileTypesPreferenceBlock {
|
|||
}
|
||||
}
|
||||
|
||||
private IContentType[] getRegistedContentTypes() {
|
||||
public IContentType[] getRegistedContentTypes() {
|
||||
if (fContentTypes == null) {
|
||||
String [] ids = CoreModel.getRegistedContentTypeIds();
|
||||
IContentTypeManager manager = Platform.getContentTypeManager();
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue