mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-31 04:45:38 +02:00
Bug 412601 - Preprocessor Entries properties tab should list languages
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>
This commit is contained in:
parent
8134c7e1cd
commit
783ae5a2d4
1 changed files with 35 additions and 13 deletions
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Gvozdev - Initial API and implementation
|
* 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;
|
package org.eclipse.cdt.internal.ui.language.settings.providers;
|
||||||
|
|
||||||
|
@ -17,6 +18,7 @@ import java.util.Iterator;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -940,31 +942,51 @@ public class LanguageSettingsEntriesTab extends AbstractCPropertyTab {
|
||||||
if (languageIds.size() > 1) {
|
if (languageIds.size() > 1) {
|
||||||
// remove null language when some real ones are defined
|
// remove null language when some real ones are defined
|
||||||
languageIds.remove(null);
|
languageIds.remove(null);
|
||||||
Collections.sort(languageIds);
|
|
||||||
} else if (languageIds.isEmpty()) {
|
} else if (languageIds.isEmpty()) {
|
||||||
// if no languages are defined keep null language as "Unspecified language"
|
// if no languages are defined keep null language as "Unspecified language"
|
||||||
languageIds.add(null);
|
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) {
|
for (String langId : languageIds) {
|
||||||
ILanguage language = LanguageManager.getInstance().getLanguage(langId);
|
ILanguage language = LanguageManager.getInstance().getLanguage(langId);
|
||||||
|
|
||||||
String langName = language != null ? language.getName() : Messages.LanguageSettingsEntriesTab_UnspecifiedLanguage;
|
String langName = language != null ? language.getName() : Messages.LanguageSettingsEntriesTab_UnspecifiedLanguage;
|
||||||
if (langName == null || langName.length() == 0)
|
if (langName == null || langName.length() == 0)
|
||||||
continue;
|
continue;
|
||||||
|
List<String> langIds = map.get(langName);
|
||||||
TreeItem t = new TreeItem(treeLanguages, SWT.NONE);
|
if (langIds == null) {
|
||||||
t.setText(0, langName);
|
langIds = new ArrayList<String>();
|
||||||
t.setData(langId);
|
map.put(langName, langIds);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue