Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlain Magloire2005-07-08 17:31:57 -0400
committerAlain Magloire2005-07-08 17:31:57 -0400
commitf4e8db793069aad46431ca3c6b9342d85a261a31 (patch)
tree2a457bb90246090c391b553764dcf96424ad56df
parent44f7f93af97d16f60fd548de1096afba51bbdeca (diff)
downloadorg.eclipse.cdt-f4e8db793069aad46431ca3c6b9342d85a261a31.tar.gz
org.eclipse.cdt-f4e8db793069aad46431ca3c6b9342d85a261a31.tar.xz
org.eclipse.cdt-f4e8db793069aad46431ca3c6b9342d85a261a31.zip
2005-07-08 Alain Magloire
Fix for the CFileType UI * src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java * src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java
-rw-r--r--core/org.eclipse.cdt.ui/ChangeLog5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java1
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java73
3 files changed, 32 insertions, 47 deletions
diff --git a/core/org.eclipse.cdt.ui/ChangeLog b/core/org.eclipse.cdt.ui/ChangeLog
index 6470dd5be7..7858e991a3 100644
--- a/core/org.eclipse.cdt.ui/ChangeLog
+++ b/core/org.eclipse.cdt.ui/ChangeLog
@@ -1,3 +1,8 @@
+2005-07-08 Alain Magloire
+ Fix for the CFileType UI
+ * src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java
+ * src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java
+
2005-07-06 Vladimir Hirsl
Disabled Add Folder/File button in CPathIncludeSymbolEntryPerFilePage.
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 4244662e50..ee57f8534a 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
@@ -320,6 +320,7 @@ public class CFileTypesPreferenceBlock {
CFileTypeAssociation[] add = (CFileTypeAssociation[]) fAddAssoc.toArray(new CFileTypeAssociation[fAddAssoc.size()]);
CFileTypeAssociation[] rem = (CFileTypeAssociation[]) fRemoveAssoc.toArray(new CFileTypeAssociation[fRemoveAssoc.size()]);
+ changed = add.length > 0 || rem.length > 0;
adjustAssociations(add, rem);
fAddAssoc.clear();
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 f626e15269..d1c4e3b9d6 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
@@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.ui.preferences;
import java.util.ArrayList;
+import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.internal.core.model.CModelManager;
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.core.resources.IProject;
@@ -148,14 +149,14 @@ public class CFileTypesPropertyPage extends PropertyPage {
if (! isProjectSpecificContentType(project.getName())) {
// enable project-specific settings for this project
contentTypePrefs.putBoolean(PREF_LOCAL_CONTENT_TYPE_SETTINGS, true);
+ try {
+ contentTypePrefs.flush();
+ } catch (BackingStoreException e) {
+ // ignore ??
+ }
+ computeEvents(project);
}
fPrefsBlock.performOk();
- computeEvents(project);
- try {
- contentTypePrefs.flush();
- } catch (BackingStoreException e) {
- // ignore ??
- }
} else if (fUseWorkspace.getSelection()) {
IProject project = getProject();
if (isProjectSpecificContentType(project.getName())) {
@@ -163,12 +164,12 @@ public class CFileTypesPropertyPage extends PropertyPage {
Preferences contentTypePrefs = projectScope.getNode(FULLPATH_CONTENT_TYPE_PREF_NODE);
// enable project-specific settings for this project
contentTypePrefs.putBoolean(PREF_LOCAL_CONTENT_TYPE_SETTINGS, false);
+ computeEvents(project);
try {
contentTypePrefs.flush();
} catch (BackingStoreException e) {
// ignore ??
}
- computeEvents(project);
}
}
return super.performOk();
@@ -208,6 +209,16 @@ public class CFileTypesPropertyPage extends PropertyPage {
return false;
}
+ public IContentType[] getRegistedContentTypes() {
+ String [] ids = CoreModel.getRegistedContentTypeIds();
+ IContentTypeManager manager = Platform.getContentTypeManager();
+ IContentType [] ctypes = new IContentType[ids.length];
+ for (int i = 0; i < ids.length; i++) {
+ ctypes[i] = manager.getContentType(ids[i]);
+ }
+ return ctypes;
+ }
+
/**
* We are looking at the association from the project, if we have any
* we should generate an event.
@@ -215,7 +226,7 @@ public class CFileTypesPropertyPage extends PropertyPage {
*/
void computeEvents(IProject project) {
IScopeContext projectScope = new ProjectScope(project);
- IContentType[] ctypes = fPrefsBlock.getRegistedContentTypes();
+ IContentType[] ctypes = getRegistedContentTypes();
ArrayList list = new ArrayList(ctypes.length);
for (int i = 0; i < ctypes.length; i++) {
IContentType ctype = ctypes[i];
@@ -236,48 +247,16 @@ public class CFileTypesPropertyPage extends PropertyPage {
}
// 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);
+ if (list.size() > 0) {
+ IContentTypeManager.ContentTypeChangeEvent[] events = new IContentTypeManager.ContentTypeChangeEvent[list.size()];
+ for (int i = 0; i < list.size(); ++i) {
+ IContentType source = (IContentType)list.get(i);
+ events[i] = new IContentTypeManager.ContentTypeChangeEvent(source, projectScope);
+ }
+ CModelManager.getDefault().contentTypeChanged(events);
}
}
-// 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;

Back to the top