use of com.intellij.codeInsight.template.postfix.templates.PostfixTemplate in project intellij-community by JetBrains.
the class PostfixTemplatesCheckboxTree method initTree.
public void initTree(@NotNull MultiMap<String, PostfixTemplate> langToTemplates) {
myRoot.removeAllChildren();
for (Map.Entry<String, Collection<PostfixTemplate>> entry : langToTemplates.entrySet()) {
String id = entry.getKey();
Language language = Language.findLanguageByID(id);
String langName = language != null ? language.getDisplayName() : id;
CheckedTreeNode langNode = new CheckedTreeNode(langName);
myRoot.add(langNode);
for (PostfixTemplate template : entry.getValue()) {
CheckedTreeNode templateNode = new PostfixTemplateCheckedTreeNode(template, langName);
langNode.add(templateNode);
}
}
myModel.nodeStructureChanged(myRoot);
TreeUtil.expandAll(this);
setSelectionRow(0);
}
use of com.intellij.codeInsight.template.postfix.templates.PostfixTemplate in project intellij-community by JetBrains.
the class PostfixTemplateLookupActionProvider method fillActions.
@Override
public void fillActions(LookupElement element, final Lookup lookup, Consumer<LookupElementAction> consumer) {
if (element instanceof PostfixTemplateLookupElement) {
final PostfixTemplateLookupElement templateLookupElement = (PostfixTemplateLookupElement) element;
final PostfixTemplate template = templateLookupElement.getPostfixTemplate();
consumer.consume(new LookupElementAction(PlatformIcons.EDIT, "Edit postfix templates settings") {
@Override
public Result performLookupAction() {
final Project project = lookup.getProject();
ApplicationManager.getApplication().invokeLater(() -> {
if (project.isDisposed())
return;
final PostfixTemplatesConfigurable configurable = new PostfixTemplatesConfigurable();
ShowSettingsUtil.getInstance().editConfigurable(project, configurable, () -> {
PostfixTemplatesCheckboxTree templatesTree = configurable.getTemplatesTree();
if (templatesTree != null) {
templatesTree.selectTemplate(template, PostfixTemplatesUtils.getLangForProvider(templateLookupElement.getProvider()));
}
});
});
return Result.HIDE_LOOKUP;
}
});
final PostfixTemplatesSettings settings = PostfixTemplatesSettings.getInstance();
if (settings != null && settings.isTemplateEnabled(template, templateLookupElement.getProvider())) {
consumer.consume(new LookupElementAction(AllIcons.Actions.Delete, String.format("Disable '%s' template", template.getKey())) {
@Override
public Result performLookupAction() {
ApplicationManager.getApplication().invokeLater(() -> settings.disableTemplate(template, templateLookupElement.getProvider()));
return Result.HIDE_LOOKUP;
}
});
}
}
}
Aggregations