1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-01 06:05:24 +02:00

RESOLVED - bug 185465: LanguageMapping issues

https://bugs.eclipse.org/bugs/show_bug.cgi?id=185465

Patch from Gerhard Schaber
This commit is contained in:
Chris Recoskie 2007-05-04 14:52:30 +00:00
parent 437d474f59
commit 8e63fb5452
2 changed files with 27 additions and 6 deletions

View file

@ -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();

View file

@ -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();
}
}
});
}
}
}
};