Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Montojo2007-09-19 15:04:44 -0400
committerJason Montojo2007-09-19 15:04:44 -0400
commitfe8aede0d0086dbc9f1593439112216c32d53785 (patch)
tree1314dbd65249a32188d69617591edbda2150f758
parent5ddaf70aef5167bf74831bd3d39be359d3ac5037 (diff)
downloadorg.eclipse.cdt-fe8aede0d0086dbc9f1593439112216c32d53785.tar.gz
org.eclipse.cdt-fe8aede0d0086dbc9f1593439112216c32d53785.tar.xz
org.eclipse.cdt-fe8aede0d0086dbc9f1593439112216c32d53785.zip
Bug 203881 - Language mapping dialog always fires indexer
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java7
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingWidget.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingPropertyPage.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidget.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingPreferencePage.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWidget.java5
6 files changed, 37 insertions, 0 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java
index fa893343dcd..459d6bd97c0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/FileLanguageMappingPropertyPage.java
@@ -72,6 +72,7 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
private Table fTable;
private ILanguage[] fLanguages;
private Map fLanguageIds;
+ private boolean fHasChanges;
public FileLanguageMappingPropertyPage() {
super();
@@ -178,6 +179,7 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
String selectedLanguage = ((String[]) combo.getData())[index];
LanguageTableData data = (LanguageTableData) item.getData();
data.languageId = selectedLanguage;
+ fHasChanges = true;
try {
refreshMappings();
@@ -307,6 +309,10 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
public boolean performOk() {
try {
+ if (!fHasChanges) {
+ return true;
+ }
+
IFile file = getFile();
IProject project = file.getProject();
LanguageManager manager = LanguageManager.getInstance();
@@ -330,6 +336,7 @@ public class FileLanguageMappingPropertyPage extends PropertyPage {
}
config.setFileMappings(file, mappings);
manager.storeLanguageMappingConfiguration(file);
+ fHasChanges = false;
return true;
} catch (CoreException e) {
CCorePlugin.log(e);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingWidget.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingWidget.java
index e9cd419f6a2..0c810983dd9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingWidget.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/LanguageMappingWidget.java
@@ -44,6 +44,8 @@ public abstract class LanguageMappingWidget {
protected Set fOverriddenContentTypes;
+ private boolean fIsChanged;
+
public LanguageMappingWidget() {
fOverriddenFont = JFaceResources.getFontRegistry().getItalic(JFaceResources.DIALOG_FONT);
fOverriddenContentTypes = Collections.EMPTY_SET;
@@ -91,6 +93,14 @@ public abstract class LanguageMappingWidget {
fChild = child;
}
+ public boolean isChanged() {
+ return fIsChanged;
+ }
+
+ public void setChanged(boolean changed) {
+ fIsChanged = changed;
+ }
+
protected void createHeader(Composite parent, String description) {
Link link = new Link(fContents, SWT.NONE);
link.setText(description);
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 b5aaee55a26..86e1ee96ddc 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
@@ -161,9 +161,14 @@ public class ProjectLanguageMappingPropertyPage extends PropertyPage {
public boolean performOk() {
try {
+ if (!fMappingWidget.isChanged()) {
+ return true;
+ }
+
fMappings.setContentTypeMappings(fMappingWidget.getContentTypeMappings());
IContentType[] affectedContentTypes = fMappingWidget.getAffectedContentTypes();
LanguageManager.getInstance().storeLanguageMappingConfiguration(getProject(), affectedContentTypes);
+ fMappingWidget.setChanged(false);
return true;
} catch (CoreException e) {
CCorePlugin.log(e);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidget.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidget.java
index 49c0c460758..3c624d3f3f9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidget.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/ProjectLanguageMappingWidget.java
@@ -133,6 +133,7 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget {
fConfigurationContentTypeMappings.put(configuration, contentTypeMappings);
}
contentTypeMappings.put(contentType, language);
+ setChanged(true);
IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
fAffectedContentTypes.add(contentTypeManager.getContentType(contentType));
@@ -168,6 +169,10 @@ public class ProjectLanguageMappingWidget extends LanguageMappingWidget {
IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
fAffectedContentTypes.add(contentTypeManager.getContentType(contentType));
}
+
+ if (selection.length > 0) {
+ setChanged(true);
+ }
refreshMappings();
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingPreferencePage.java
index 8670c0bfb16..10d7a0791c9 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingPreferencePage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingPreferencePage.java
@@ -69,11 +69,16 @@ public class WorkspaceLanguageMappingPreferencePage extends PreferencePage imple
public boolean performOk() {
try {
+ if (!fMappingWidget.isChanged()) {
+ return true;
+ }
+
IContentType[] affectedContentTypes = fMappingWidget.getAffectedContentTypes();
LanguageManager manager = LanguageManager.getInstance();
WorkspaceLanguageConfiguration config = manager.getWorkspaceLanguageConfiguration();
config.setWorkspaceMappings(fMappingWidget.getContentTypeMappings());
manager.storeWorkspaceLanguageConfiguration(affectedContentTypes);
+ fMappingWidget.setChanged(false);
return true;
} catch (CoreException e) {
CCorePlugin.log(e);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWidget.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWidget.java
index bd6eb4511a9..e898b98f938 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWidget.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/WorkspaceLanguageMappingWidget.java
@@ -100,6 +100,7 @@ public class WorkspaceLanguageMappingWidget extends LanguageMappingWidget {
String contentType = dialog.getContentTypeID();
String language = dialog.getLanguageID();
fContentTypeMappings.put(contentType, language);
+ setChanged(true);
IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
fAffectedContentTypes.add(contentTypeManager.getContentType(contentType));
refreshMappings();
@@ -123,6 +124,10 @@ public class WorkspaceLanguageMappingWidget extends LanguageMappingWidget {
IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
fAffectedContentTypes.add(contentTypeManager.getContentType(contentType));
}
+
+ if (selection.length > 0) {
+ setChanged(true);
+ }
refreshMappings();
}

Back to the top