diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectLanguageAction.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectLanguageAction.java index 3ab993cd5de0..fa2f66b129f8 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectLanguageAction.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/inject/InjectLanguageAction.java @@ -36,7 +36,8 @@ import com.intellij.psi.PsiLanguageInjectionHost; import com.intellij.psi.PsiManager; import com.intellij.psi.impl.PsiModificationTrackerImpl; import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.ui.ListCellRendererWrapper; +import com.intellij.ui.ColoredListCellRendererWrapper; +import com.intellij.ui.SimpleTextAttributes; import com.intellij.ui.components.JBList; import com.intellij.util.FileContentUtil; import com.intellij.util.Function; @@ -135,11 +136,15 @@ public class InjectLanguageAction implements IntentionAction { final List injectables = Injectable.getAllInjectables(); final JList list = new JBList(injectables); - list.setCellRenderer(new ListCellRendererWrapper() { + list.setCellRenderer(new ColoredListCellRendererWrapper() { @Override - public void customize(JList list, Injectable language, int index, boolean selected, boolean hasFocus) { + protected void doCustomize(JList list, Injectable language, int index, boolean selected, boolean hasFocus) { setIcon(language.getIcon()); - setText(language.getDisplayName()); + append(language.getDisplayName()); + String description = language.getAdditionalDescription(); + if (description != null) { + append(description, SimpleTextAttributes.GRAYED_ATTRIBUTES); + } } }); new PopupChooserBuilder(list).setItemChoosenCallback(new Runnable() { diff --git a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/references/Injectable.java b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/references/Injectable.java index bdb4cef4e7fc..9aecfbae69c6 100644 --- a/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/references/Injectable.java +++ b/plugins/IntelliLang/src/org/intellij/plugins/intelliLang/references/Injectable.java @@ -41,6 +41,11 @@ public abstract class Injectable implements Comparable { @NotNull public abstract String getDisplayName(); + @Nullable + public String getAdditionalDescription() { + return null; + } + @NotNull public Icon getIcon() { return EmptyIcon.ICON_16; @@ -69,7 +74,12 @@ public abstract class Injectable implements Comparable { } public Language toLanguage() { - return getLanguage() == null ? new Language(getId(), false) {} : getLanguage(); + return getLanguage() == null ? new Language(getId(), false) { + @Override + public String getDisplayName() { + return Injectable.this.getDisplayName(); + } + } : getLanguage(); } public static Injectable fromLanguage(final Language language) { @@ -83,8 +93,14 @@ public abstract class Injectable implements Comparable { @NotNull @Override public String getDisplayName() { + return language.getDisplayName(); + } + + @Nullable + @Override + public String getAdditionalDescription() { final FileType ft = language.getAssociatedFileType(); - return language.getDisplayName() + (ft != null ? " (" + ft.getDescription() + ")" : ""); + return ft != null ? " (" + ft.getDescription() + ")" : null; } @NotNull