public FileTypePatternDialog(@Nullable String initialPatterns, FileType fileType, Language templateDataLanguage) { myPatternField.setText(initialPatterns); if (fileType instanceof TemplateLanguageFileType) { final DefaultComboBoxModel model = (DefaultComboBoxModel) myLanguageCombo.getModel(); model.addElement(null); final List<Language> languages = TemplateDataLanguageMappings.getTemplateableLanguages(); Collections.sort(languages, new Comparator<Language>() { @Override public int compare(final Language o1, final Language o2) { return o1.getID().compareTo(o2.getID()); } }); for (Language language : languages) { model.addElement(language); } myLanguageCombo.setRenderer(new ListCellRendererWrapper() { @Override public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) { setText(value == null ? "" : ((Language) value).getDisplayName()); if (value != null) { final FileType type = ((Language)value).getAssociatedFileType(); if (type != null) { setIcon(type.getIcon()); } } } }); myLanguageCombo.setSelectedItem(templateDataLanguage); } else { myLanguageCombo.setVisible(false); myTemplateDataLanguageButton.setVisible(false); } }