mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-05 23:35:48 +02:00
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
This commit is contained in:
parent
44f7f93af9
commit
f4e8db7930
3 changed files with 32 additions and 47 deletions
|
@ -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
|
2005-07-06 Vladimir Hirsl
|
||||||
Disabled Add Folder/File button in CPathIncludeSymbolEntryPerFilePage.
|
Disabled Add Folder/File button in CPathIncludeSymbolEntryPerFilePage.
|
||||||
|
|
||||||
|
|
|
@ -320,6 +320,7 @@ public class CFileTypesPreferenceBlock {
|
||||||
CFileTypeAssociation[] add = (CFileTypeAssociation[]) fAddAssoc.toArray(new CFileTypeAssociation[fAddAssoc.size()]);
|
CFileTypeAssociation[] add = (CFileTypeAssociation[]) fAddAssoc.toArray(new CFileTypeAssociation[fAddAssoc.size()]);
|
||||||
CFileTypeAssociation[] rem = (CFileTypeAssociation[]) fRemoveAssoc.toArray(new CFileTypeAssociation[fRemoveAssoc.size()]);
|
CFileTypeAssociation[] rem = (CFileTypeAssociation[]) fRemoveAssoc.toArray(new CFileTypeAssociation[fRemoveAssoc.size()]);
|
||||||
|
|
||||||
|
changed = add.length > 0 || rem.length > 0;
|
||||||
adjustAssociations(add, rem);
|
adjustAssociations(add, rem);
|
||||||
|
|
||||||
fAddAssoc.clear();
|
fAddAssoc.clear();
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.ui.preferences;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.internal.core.model.CModelManager;
|
import org.eclipse.cdt.internal.core.model.CModelManager;
|
||||||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -148,14 +149,14 @@ public class CFileTypesPropertyPage extends PropertyPage {
|
||||||
if (! isProjectSpecificContentType(project.getName())) {
|
if (! isProjectSpecificContentType(project.getName())) {
|
||||||
// enable project-specific settings for this project
|
// enable project-specific settings for this project
|
||||||
contentTypePrefs.putBoolean(PREF_LOCAL_CONTENT_TYPE_SETTINGS, true);
|
contentTypePrefs.putBoolean(PREF_LOCAL_CONTENT_TYPE_SETTINGS, true);
|
||||||
|
try {
|
||||||
|
contentTypePrefs.flush();
|
||||||
|
} catch (BackingStoreException e) {
|
||||||
|
// ignore ??
|
||||||
|
}
|
||||||
|
computeEvents(project);
|
||||||
}
|
}
|
||||||
fPrefsBlock.performOk();
|
fPrefsBlock.performOk();
|
||||||
computeEvents(project);
|
|
||||||
try {
|
|
||||||
contentTypePrefs.flush();
|
|
||||||
} catch (BackingStoreException e) {
|
|
||||||
// ignore ??
|
|
||||||
}
|
|
||||||
} else if (fUseWorkspace.getSelection()) {
|
} else if (fUseWorkspace.getSelection()) {
|
||||||
IProject project = getProject();
|
IProject project = getProject();
|
||||||
if (isProjectSpecificContentType(project.getName())) {
|
if (isProjectSpecificContentType(project.getName())) {
|
||||||
|
@ -163,12 +164,12 @@ public class CFileTypesPropertyPage extends PropertyPage {
|
||||||
Preferences contentTypePrefs = projectScope.getNode(FULLPATH_CONTENT_TYPE_PREF_NODE);
|
Preferences contentTypePrefs = projectScope.getNode(FULLPATH_CONTENT_TYPE_PREF_NODE);
|
||||||
// enable project-specific settings for this project
|
// enable project-specific settings for this project
|
||||||
contentTypePrefs.putBoolean(PREF_LOCAL_CONTENT_TYPE_SETTINGS, false);
|
contentTypePrefs.putBoolean(PREF_LOCAL_CONTENT_TYPE_SETTINGS, false);
|
||||||
|
computeEvents(project);
|
||||||
try {
|
try {
|
||||||
contentTypePrefs.flush();
|
contentTypePrefs.flush();
|
||||||
} catch (BackingStoreException e) {
|
} catch (BackingStoreException e) {
|
||||||
// ignore ??
|
// ignore ??
|
||||||
}
|
}
|
||||||
computeEvents(project);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.performOk();
|
return super.performOk();
|
||||||
|
@ -208,6 +209,16 @@ public class CFileTypesPropertyPage extends PropertyPage {
|
||||||
return false;
|
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 are looking at the association from the project, if we have any
|
||||||
* we should generate an event.
|
* we should generate an event.
|
||||||
|
@ -215,7 +226,7 @@ public class CFileTypesPropertyPage extends PropertyPage {
|
||||||
*/
|
*/
|
||||||
void computeEvents(IProject project) {
|
void computeEvents(IProject project) {
|
||||||
IScopeContext projectScope = new ProjectScope(project);
|
IScopeContext projectScope = new ProjectScope(project);
|
||||||
IContentType[] ctypes = fPrefsBlock.getRegistedContentTypes();
|
IContentType[] ctypes = getRegistedContentTypes();
|
||||||
ArrayList list = new ArrayList(ctypes.length);
|
ArrayList list = new ArrayList(ctypes.length);
|
||||||
for (int i = 0; i < ctypes.length; i++) {
|
for (int i = 0; i < ctypes.length; i++) {
|
||||||
IContentType ctype = ctypes[i];
|
IContentType ctype = ctypes[i];
|
||||||
|
@ -236,48 +247,16 @@ public class CFileTypesPropertyPage extends PropertyPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
// fire the events
|
// fire the events
|
||||||
for (int i = 0; i < list.size(); ++i) {
|
if (list.size() > 0) {
|
||||||
IContentType source = (IContentType)list.get(i);
|
IContentTypeManager.ContentTypeChangeEvent[] events = new IContentTypeManager.ContentTypeChangeEvent[list.size()];
|
||||||
IContentTypeManager.ContentTypeChangeEvent event = new IContentTypeManager.ContentTypeChangeEvent(source, projectScope);
|
for (int i = 0; i < list.size(); ++i) {
|
||||||
CModelManager.getDefault().contentTypeChanged(event);
|
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) {
|
boolean isSpecsChanged(String[] newSpecs, String[] oldSpecs) {
|
||||||
if (newSpecs.length != oldSpecs.length) {
|
if (newSpecs.length != oldSpecs.length) {
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Add table
Reference in a new issue