mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
2005-07-09 Alain Magloire
Fix PR 102324: Fire event in the property page for change contentType * src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java * src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java
This commit is contained in:
parent
d2aff435e1
commit
d896048b89
3 changed files with 62 additions and 8 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2005-07-09 Alain Magloire
|
||||||
|
Fix PR 102324: Fire event in the property page for change contentType
|
||||||
|
* src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java
|
||||||
|
* src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java
|
||||||
|
|
||||||
2005-07-09 Alain Magloire
|
2005-07-09 Alain Magloire
|
||||||
Fix PR 97963
|
Fix PR 97963
|
||||||
* src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferncePage.java
|
* src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferncePage.java
|
||||||
|
|
|
@ -344,7 +344,7 @@ public class CFileTypesPreferenceBlock {
|
||||||
return assocs;
|
return assocs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void adjustAssociations(CFileTypeAssociation[] add, CFileTypeAssociation[] rem) {
|
protected void adjustAssociations(CFileTypeAssociation[] add, CFileTypeAssociation[] rem) {
|
||||||
IScopeContext context = null;
|
IScopeContext context = null;
|
||||||
if (fInput != null) {
|
if (fInput != null) {
|
||||||
context = new ProjectScope(fInput);
|
context = new ProjectScope(fInput);
|
||||||
|
@ -353,7 +353,7 @@ public class CFileTypesPreferenceBlock {
|
||||||
removeAssociations(rem, context);
|
removeAssociations(rem, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addAssociations(CFileTypeAssociation[] add, IScopeContext context) {
|
protected void addAssociations(CFileTypeAssociation[] add, IScopeContext context) {
|
||||||
for (int i = 0; i < add.length; ++i) {
|
for (int i = 0; i < add.length; ++i) {
|
||||||
CFileTypeAssociation assoc = add[i];
|
CFileTypeAssociation assoc = add[i];
|
||||||
String spec = assoc.getSpec();
|
String spec = assoc.getSpec();
|
||||||
|
@ -375,7 +375,7 @@ public class CFileTypesPreferenceBlock {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeAssociations(CFileTypeAssociation[] rem, IScopeContext context) {
|
protected void removeAssociations(CFileTypeAssociation[] rem, IScopeContext context) {
|
||||||
for (int i = 0; i < rem.length; ++i) {
|
for (int i = 0; i < rem.length; ++i) {
|
||||||
CFileTypeAssociation assoc = rem[i];
|
CFileTypeAssociation assoc = rem[i];
|
||||||
IContentType contentType = assoc.getContentType();
|
IContentType contentType = assoc.getContentType();
|
||||||
|
|
|
@ -45,6 +45,54 @@ import org.osgi.service.prefs.Preferences;
|
||||||
*/
|
*/
|
||||||
public class CFileTypesPropertyPage extends PropertyPage {
|
public class CFileTypesPropertyPage extends PropertyPage {
|
||||||
|
|
||||||
|
class FixCFileTypesPreferenceBlock extends CFileTypesPreferenceBlock {
|
||||||
|
ArrayList list = new ArrayList();
|
||||||
|
|
||||||
|
public FixCFileTypesPreferenceBlock() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FixCFileTypesPreferenceBlock(IProject input) {
|
||||||
|
super(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IContentTypeManager.ContentTypeChangeEvent newContentTypeChangeEvent(IContentType source, IScopeContext context) {
|
||||||
|
return new IContentTypeManager.ContentTypeChangeEvent(source, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean performOk() {
|
||||||
|
boolean changed = super.performOk();
|
||||||
|
if (changed) {
|
||||||
|
int size = list.size();
|
||||||
|
if (size > 0) {
|
||||||
|
IContentTypeManager.ContentTypeChangeEvent[] events = new IContentTypeManager.ContentTypeChangeEvent[size];
|
||||||
|
list.toArray(events);
|
||||||
|
CModelManager.getDefault().contentTypeChanged(events);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.ui.preferences.CFileTypesPreferenceBlock#addAssociation(org.eclipse.core.runtime.preferences.IScopeContext, org.eclipse.core.runtime.content.IContentType, java.lang.String, int)
|
||||||
|
*/
|
||||||
|
protected void addAssociation(IScopeContext context, IContentType contentType, String spec, int type) {
|
||||||
|
super.addAssociation(context, contentType, spec, type);
|
||||||
|
// accumulate the events
|
||||||
|
list.add(newContentTypeChangeEvent(contentType, context));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.internal.ui.preferences.CFileTypesPreferenceBlock#removeAssociation(org.eclipse.core.runtime.preferences.IScopeContext, org.eclipse.core.runtime.content.IContentType, java.lang.String, int)
|
||||||
|
*/
|
||||||
|
protected void removeAssociation(IScopeContext context, IContentType contentType, String spec, int type) {
|
||||||
|
super.removeAssociation(context, contentType, spec, type);
|
||||||
|
// accumulate the events
|
||||||
|
list.add(newContentTypeChangeEvent(contentType, context));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private static final String CONTENT_TYPE_PREF_NODE = "content-types"; //$NON-NLS-1$
|
private static final String CONTENT_TYPE_PREF_NODE = "content-types"; //$NON-NLS-1$
|
||||||
private static final String FULLPATH_CONTENT_TYPE_PREF_NODE = Platform.PI_RUNTIME + IPath.SEPARATOR + CONTENT_TYPE_PREF_NODE;
|
private static final String FULLPATH_CONTENT_TYPE_PREF_NODE = Platform.PI_RUNTIME + IPath.SEPARATOR + CONTENT_TYPE_PREF_NODE;
|
||||||
private static final String PREF_LOCAL_CONTENT_TYPE_SETTINGS = "enabled"; //$NON-NLS-1$
|
private static final String PREF_LOCAL_CONTENT_TYPE_SETTINGS = "enabled"; //$NON-NLS-1$
|
||||||
|
@ -57,7 +105,7 @@ public class CFileTypesPropertyPage extends PropertyPage {
|
||||||
|
|
||||||
protected Button fUseWorkspace;
|
protected Button fUseWorkspace;
|
||||||
protected Button fUseProject;
|
protected Button fUseProject;
|
||||||
protected CFileTypesPreferenceBlock fPrefsBlock;
|
protected FixCFileTypesPreferenceBlock fPrefsBlock;
|
||||||
|
|
||||||
public CFileTypesPropertyPage(){
|
public CFileTypesPropertyPage(){
|
||||||
super();
|
super();
|
||||||
|
@ -111,9 +159,9 @@ public class CFileTypesPropertyPage extends PropertyPage {
|
||||||
blockPane.setLayoutData(new GridData(GridData.FILL_BOTH));
|
blockPane.setLayoutData(new GridData(GridData.FILL_BOTH));
|
||||||
|
|
||||||
if (custom) {
|
if (custom) {
|
||||||
fPrefsBlock = new CFileTypesPreferenceBlock(project);
|
fPrefsBlock = new FixCFileTypesPreferenceBlock(project);
|
||||||
} else {
|
} else {
|
||||||
fPrefsBlock = new CFileTypesPreferenceBlock();
|
fPrefsBlock = new FixCFileTypesPreferenceBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
fPrefsBlock.createControl(blockPane);
|
fPrefsBlock.createControl(blockPane);
|
||||||
|
@ -162,7 +210,7 @@ public class CFileTypesPropertyPage extends PropertyPage {
|
||||||
if (isProjectSpecificContentType(project.getName())) {
|
if (isProjectSpecificContentType(project.getName())) {
|
||||||
ProjectScope projectScope = new ProjectScope(project);
|
ProjectScope projectScope = new ProjectScope(project);
|
||||||
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
|
// disable project-specific settings for this project
|
||||||
contentTypePrefs.putBoolean(PREF_LOCAL_CONTENT_TYPE_SETTINGS, false);
|
contentTypePrefs.putBoolean(PREF_LOCAL_CONTENT_TYPE_SETTINGS, false);
|
||||||
computeEvents(project);
|
computeEvents(project);
|
||||||
try {
|
try {
|
||||||
|
@ -170,6 +218,7 @@ public class CFileTypesPropertyPage extends PropertyPage {
|
||||||
} catch (BackingStoreException e) {
|
} catch (BackingStoreException e) {
|
||||||
// ignore ??
|
// ignore ??
|
||||||
}
|
}
|
||||||
|
computeEvents(project);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return super.performOk();
|
return super.performOk();
|
||||||
|
|
Loading…
Add table
Reference in a new issue