summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTom Hochstein2013-07-11 14:46:35 (EDT)
committerAndrew Gvozdev2013-07-12 14:43:31 (EDT)
commit783ae5a2d45f2e259ed675af879f8cf9b331cd38 (patch)
treebd77d14829c50765cda0be12ac35740a8433951a
parent8134c7e1cda8b91227020c71549b58466a1c552c (diff)
downloadorg.eclipse.cdt-783ae5a2d45f2e259ed675af879f8cf9b331cd38.zip
org.eclipse.cdt-783ae5a2d45f2e259ed675af879f8cf9b331cd38.tar.gz
org.eclipse.cdt-783ae5a2d45f2e259ed675af879f8cf9b331cd38.tar.bz2
Bug 412601 - Preprocessor Entries properties tab should list languagesrefs/changes/17/14417/7
alphabetically by name, not id Change-Id: I575ca197c464287f7894d83abe7bd7ddb2e8f2d0 Signed-off-by: Tom Hochstein <tom.hochstein@freescale.com> Reviewed-on: https://git.eclipse.org/r/14417 Reviewed-by: Andrew Gvozdev <angvoz.dev@gmail.com> IP-Clean: Andrew Gvozdev <angvoz.dev@gmail.com> Tested-by: Andrew Gvozdev <angvoz.dev@gmail.com>
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java48
1 files changed, 35 insertions, 13 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java
index aa900f5..87b8285 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/language/settings/providers/LanguageSettingsEntriesTab.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Andrew Gvozdev - Initial API and implementation
+ * Tom Hochstein (Freescale) - Bug 412601 - Preprocessor Entries properties tab should list languages
*******************************************************************************/
package org.eclipse.cdt.internal.ui.language.settings.providers;
@@ -17,6 +18,7 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.TreeMap;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
@@ -940,31 +942,51 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
if (languageIds.size() > 1) {
// remove null language when some real ones are defined
languageIds.remove(null);
- Collections.sort(languageIds);
} else if (languageIds.isEmpty()) {
// if no languages are defined keep null language as "Unspecified language"
languageIds.add(null);
}
+
+ // Use a TreeMap to sort the languages by name.
+ // For each name we keep a list of ids in case of name overlap.
+ Map<String, List<String>> map = new TreeMap<String, List<String>>();
for (String langId : languageIds) {
ILanguage language = LanguageManager.getInstance().getLanguage(langId);
String langName = language != null ? language.getName() : Messages.LanguageSettingsEntriesTab_UnspecifiedLanguage;
if (langName == null || langName.length() == 0)
continue;
-
- TreeItem t = new TreeItem(treeLanguages, SWT.NONE);
- t.setText(0, langName);
- t.setData(langId);
- if (currentLanguageIdGlobal != null && currentLanguageIdGlobal.equals(langId)) {
- currentLanguageId = currentLanguageIdGlobal;
- treeLanguages.setSelection(t);
- } else if (currentLanguageId == null) {
- // this selects first language on first round
- // do not select the tree item and global language selection here, only on actual click
- currentLanguageId = langId;
+ List<String> langIds = map.get(langName);
+ if (langIds == null) {
+ langIds = new ArrayList<String>();
+ map.put(langName, langIds);
+ }
+ langIds.add(langId);
+ }
+
+ for (String langName : map.keySet()) {
+ List<String> langIds = map.get(langName);
+ for (String langId : langIds) {
+ TreeItem t = new TreeItem(treeLanguages, SWT.NONE);
+ if (langIds.size() == 1) {
+ t.setText(0, langName);
+ } else {
+ StringBuilder uniqueLangName = new StringBuilder();
+ uniqueLangName.append(langName).append(" [id=") //$NON-NLS-1$
+ .append(langId).append("]"); //$NON-NLS-1$
+ t.setText(0, uniqueLangName.toString());
+ }
+ t.setData(langId);
+ if (currentLanguageIdGlobal != null && currentLanguageIdGlobal.equals(langId)) {
+ currentLanguageId = currentLanguageIdGlobal;
+ treeLanguages.setSelection(t);
+ } else if (currentLanguageId == null) {
+ // this selects first language on first round
+ // do not select the tree item and global language selection here, only on actual click
+ currentLanguageId = langId;
+ }
}
}
-
}
/**