use of com.intellij.codeInsight.template.postfix.settings.PostfixTemplatesCheckboxTree 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