diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingStore.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingStore.java index f59c7b54ec8..fb3b7f9d19f 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingStore.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/language/LanguageMappingStore.java @@ -163,7 +163,6 @@ public class LanguageMappingStore { Iterator entries = contentTypeMappings.entrySet().iterator(); while (entries.hasNext()) { Entry entry = (Entry) entries.next(); - Element mapping = document.createElement(CONTENT_TYPE_MAPPING); String configuration = (String) entry.getKey(); Iterator contentTypeEntries = ((Map) entry.getValue()).entrySet().iterator(); @@ -172,6 +171,7 @@ public class LanguageMappingStore { String contentType = (String) configurationEntry.getKey(); String language = (String) configurationEntry.getValue(); + Element mapping = document.createElement(CONTENT_TYPE_MAPPING); mapping.setAttribute(ATTRIBUTE_CONTENT_TYPE, contentType); mapping.setAttribute(ATTRIBUTE_CONFIGURATION, configuration); mapping.setAttribute(ATTRIBUTE_LANGUAGE, language); @@ -194,7 +194,7 @@ public class LanguageMappingStore { serializer.transform(source, result); String encodedMappings = buffer.getBuffer().toString(); - Preferences node = CCorePlugin.getDefault().getPluginPreferences();; + Preferences node = CCorePlugin.getDefault().getPluginPreferences(); node.setValue(CCorePreferenceConstants.WORKSPACE_LANGUAGE_MAPPINGS, encodedMappings); CCorePlugin.getDefault().savePluginPreferences(); } catch (ParserConfigurationException e) { @@ -205,7 +205,7 @@ public class LanguageMappingStore { } public WorkspaceLanguageConfiguration decodeWorkspaceMappings() throws CoreException { - Preferences node = CCorePlugin.getDefault().getPluginPreferences();; + Preferences node = CCorePlugin.getDefault().getPluginPreferences(); String encodedMappings = node.getString(CCorePreferenceConstants.WORKSPACE_LANGUAGE_MAPPINGS); WorkspaceLanguageConfiguration config = new WorkspaceLanguageConfiguration(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPropertyPage.java index 95c8d31b24d..5abc293076c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPropertyPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPropertyPage.java @@ -20,6 +20,7 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Group; import org.eclipse.ui.dialogs.PropertyPage; @@ -70,10 +71,30 @@ public class ProjectLanguageMappingPropertyPage extends PropertyPage { fetchWorkspaceMappings(); fInheritedMappingWidget.createContents(group, null); fInheritedMappingsChangeListener = new ILanguageMappingChangeListener() { - public void handleLanguageMappingChangeEvent(ILanguageMappingChangeEvent event) { + public void handleLanguageMappingChangeEvent(final ILanguageMappingChangeEvent event) { if (event.getType() == ILanguageMappingChangeEvent.TYPE_WORKSPACE) { - fetchWorkspaceMappings(); - fInheritedMappingWidget.refreshMappings(); + if (ProjectLanguageMappingPropertyPage.this.isControlCreated()) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + if (!ProjectLanguageMappingPropertyPage.this.getControl().isDisposed()) { + fetchWorkspaceMappings(); + fInheritedMappingWidget.refreshMappings(); + } + } + }); + } + } + else if (event.getType() == ILanguageMappingChangeEvent.TYPE_PROJECT) { + if (ProjectLanguageMappingPropertyPage.this.isControlCreated()) { + Display.getDefault().asyncExec(new Runnable() { + public void run() { + if (!ProjectLanguageMappingPropertyPage.this.getControl().isDisposed()) { + fetchMappings(event.getProject()); + fMappingWidget.refreshMappings(); + } + } + }); + } } } };