com.intellij.openapi.fileTypes.TemplateLanguageFileType Java Examples
The following examples show how to use
com.intellij.openapi.fileTypes.TemplateLanguageFileType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FileTypePatternDialog.java From consulo with Apache License 2.0 | 5 votes |
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(TargetAWT.to(type.getIcon())); } } } }); myLanguageCombo.setSelectedItem(templateDataLanguage); } else { myLanguageCombo.setVisible(false); myTemplateDataLanguageButton.setVisible(false); } }