From 1ef05c7de25197e82b5adea1c4a486bdef5b1496 Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Wed, 11 Jan 2017 10:44:14 +0100 Subject: [PATCH] sort case-insensitively and cleanup --- .../inject/config/ui/LanguagePanel.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java index e9929bbd662a..f8074c2a32c4 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/config/ui/LanguagePanel.java @@ -25,7 +25,7 @@ import com.intellij.openapi.fileTypes.SyntaxHighlighterFactory; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.ComboBox; import com.intellij.ui.AncestorListenerAdapter; -import com.intellij.ui.ColoredListCellRendererWrapper; +import com.intellij.ui.ColoredListCellRenderer; import com.intellij.ui.EditorTextField; import com.intellij.ui.SimpleTextAttributes; import org.intellij.plugins.intelliLang.inject.InjectedLanguage; @@ -42,7 +42,7 @@ import java.util.Set; public class LanguagePanel extends AbstractInjectionPanel { private JPanel myRoot; - private ComboBox myLanguage; + private ComboBox myLanguage; private EditorTextField myPrefix; private EditorTextField mySuffix; @@ -51,14 +51,14 @@ public class LanguagePanel extends AbstractInjectionPanel { $$$setupUI$$$(); final String[] languageIDs = InjectedLanguage.getAvailableLanguageIDs(); - Arrays.sort(languageIDs); + Arrays.sort(languageIDs, String::compareToIgnoreCase); - myLanguage.setModel(new DefaultComboBoxModel(languageIDs)); - myLanguage.setRenderer(new ColoredListCellRendererWrapper() { + myLanguage.setModel(new DefaultComboBoxModel<>(languageIDs)); + myLanguage.setRenderer(new ColoredListCellRenderer() { final Set IDs = new HashSet<>(Arrays.asList(languageIDs)); @Override - protected void doCustomize(JList list, String s, int index, boolean selected, boolean hasFocus) { + protected void customizeCellRenderer(JList list, String s, int index, boolean selected, boolean hasFocus) { final SimpleTextAttributes attributes = IDs.contains(s) ? SimpleTextAttributes.REGULAR_ATTRIBUTES : SimpleTextAttributes.ERROR_ATTRIBUTES; append(s, attributes); @@ -91,7 +91,7 @@ public class LanguagePanel extends AbstractInjectionPanel { }); } - private void updateHighlighters() { + void updateHighlighters() { final EditorImpl editor = ((EditorImpl)myPrefix.getEditor()); if (editor == null) return; @@ -117,7 +117,7 @@ public class LanguagePanel extends AbstractInjectionPanel { } public void setLanguage(String id) { - final DefaultComboBoxModel model = (DefaultComboBoxModel)myLanguage.getModel(); + final DefaultComboBoxModel model = (DefaultComboBoxModel)myLanguage.getModel(); if (model.getIndexOf(id) == -1 && id.length() > 0) { model.insertElementAt(id, 0); }