mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
bug 271165, language mapping dialog combo boxes should be sorted
This commit is contained in:
parent
7cf6808597
commit
679552dc61
2 changed files with 19 additions and 4 deletions
|
@ -11,7 +11,9 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.ui.language;
|
package org.eclipse.cdt.internal.ui.language;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.jface.dialogs.Dialog;
|
import org.eclipse.jface.dialogs.Dialog;
|
||||||
import org.eclipse.jface.dialogs.IDialogConstants;
|
import org.eclipse.jface.dialogs.IDialogConstants;
|
||||||
|
@ -34,8 +36,8 @@ public abstract class ContentTypeMappingDialog extends Dialog {
|
||||||
String fSelectedLanguageID;
|
String fSelectedLanguageID;
|
||||||
String fSelectedConfigurationID;
|
String fSelectedConfigurationID;
|
||||||
String fSelectedConfigurationName;
|
String fSelectedConfigurationName;
|
||||||
HashMap<String, String> fContentTypeNamesToIDsMap;
|
Map<String, String> fContentTypeNamesToIDsMap;
|
||||||
HashMap<String, String> fLanguageNamesToIDsMap;
|
Map<String, String> fLanguageNamesToIDsMap;
|
||||||
|
|
||||||
public ContentTypeMappingDialog(Shell parentShell) {
|
public ContentTypeMappingDialog(Shell parentShell) {
|
||||||
super(parentShell);
|
super(parentShell);
|
||||||
|
@ -79,10 +81,12 @@ public abstract class ContentTypeMappingDialog extends Dialog {
|
||||||
ILanguage[] languages = LanguageManager.getInstance()
|
ILanguage[] languages = LanguageManager.getInstance()
|
||||||
.getRegisteredLanguages();
|
.getRegisteredLanguages();
|
||||||
String[] descriptions = new String[languages.length];
|
String[] descriptions = new String[languages.length];
|
||||||
|
|
||||||
for (int i = 0; i < descriptions.length; i++) {
|
for (int i = 0; i < descriptions.length; i++) {
|
||||||
descriptions[i] = languages[i].getName();
|
descriptions[i] = languages[i].getName();
|
||||||
fLanguageNamesToIDsMap.put(descriptions[i], languages[i].getId());
|
fLanguageNamesToIDsMap.put(descriptions[i], languages[i].getId());
|
||||||
}
|
}
|
||||||
|
Arrays.sort(descriptions);
|
||||||
return descriptions;
|
return descriptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,9 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.language;
|
package org.eclipse.cdt.internal.ui.language;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
@ -131,18 +134,26 @@ public class ProjectContentTypeMappingDialog extends ContentTypeMappingDialog {
|
||||||
private void configureContentTypes(Combo combo, ICConfigurationDescription configuration) {
|
private void configureContentTypes(Combo combo, ICConfigurationDescription configuration) {
|
||||||
combo.removeAll();
|
combo.removeAll();
|
||||||
IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
|
IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
|
||||||
|
List<String> names = new LinkedList<String>();
|
||||||
|
|
||||||
for (int i = 0; i < fContentTypesIDs.length; i++) {
|
for (int i = 0; i < fContentTypesIDs.length; i++) {
|
||||||
String contentTypeId = fContentTypesIDs[i];
|
String contentTypeId = fContentTypesIDs[i];
|
||||||
String name = contentTypeManager.getContentType(contentTypeId).getName();
|
String name = contentTypeManager.getContentType(contentTypeId).getName();
|
||||||
|
|
||||||
if (configuration != null) {
|
if (configuration != null) {
|
||||||
String key = ProjectLanguageMappingWidget.createFilterKey(configuration.getId(), contentTypeId);
|
String key = ProjectLanguageMappingWidget.createFilterKey(configuration.getId(), contentTypeId);
|
||||||
if (!fFilteredContentTypes.contains(key)) {
|
if (!fFilteredContentTypes.contains(key)) {
|
||||||
combo.add(name);
|
names.add(name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
combo.add(name);
|
names.add(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Collections.sort(names);
|
||||||
|
for(String name : names) {
|
||||||
|
combo.add(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Add table
Reference in a new issue