use of com.intellij.codeInsight.lookup.LookupElementAction in project intellij-community by JetBrains.
the class EmmetLookupActionProvider method fillActions.
@Override
public void fillActions(LookupElement element, final Lookup lookup, Consumer<LookupElementAction> consumer) {
if (element instanceof CustomLiveTemplateLookupElement && ((CustomLiveTemplateLookupElement) element).getCustomLiveTemplate() instanceof ZenCodingTemplate) {
final PsiElement context = lookup.getPsiElement();
final ZenCodingGenerator generator = context != null ? ZenCodingTemplate.findApplicableDefaultGenerator(context, false) : null;
if (generator != null) {
consumer.consume(new LookupElementAction(PlatformIcons.EDIT, "Edit Emmet settings") {
@Override
public Result performLookupAction() {
final Project project = lookup.getProject();
ApplicationManager.getApplication().invokeLater(() -> {
if (project.isDisposed())
return;
final Configurable generatorSpecificConfigurable = generator.createConfigurable();
Configurable configurable = generatorSpecificConfigurable != null ? generatorSpecificConfigurable : new XmlEmmetConfigurable();
ShowSettingsUtil.getInstance().editConfigurable(project, new EmmetCompositeConfigurable(configurable));
});
return Result.HIDE_LOOKUP;
}
});
consumer.consume(new LookupElementAction(AllIcons.Actions.Delete, "Disable Emmet") {
@Override
public Result performLookupAction() {
ApplicationManager.getApplication().invokeLater(generator::disableEmmet);
return Result.HIDE_LOOKUP;
}
});
}
}
}
use of com.intellij.codeInsight.lookup.LookupElementAction in project intellij-community by JetBrains.
the class LiveTemplateLookupActionProvider method fillActions.
@Override
public void fillActions(LookupElement element, final Lookup lookup, Consumer<LookupElementAction> consumer) {
if (element instanceof LiveTemplateLookupElementImpl) {
final TemplateImpl template = ((LiveTemplateLookupElementImpl) element).getTemplate();
final TemplateImpl templateFromSettings = TemplateSettings.getInstance().getTemplate(template.getKey(), template.getGroupName());
if (templateFromSettings != null) {
consumer.consume(new LookupElementAction(PlatformIcons.EDIT, "Edit live template settings") {
@Override
public Result performLookupAction() {
final Project project = lookup.getProject();
ApplicationManager.getApplication().invokeLater(() -> {
if (project.isDisposed())
return;
final LiveTemplatesConfigurable configurable = new LiveTemplatesConfigurable();
ShowSettingsUtil.getInstance().editConfigurable(project, configurable, () -> configurable.getTemplateListPanel().editTemplate(template));
});
return Result.HIDE_LOOKUP;
}
});
consumer.consume(new LookupElementAction(AllIcons.Actions.Delete, String.format("Disable '%s' template", template.getKey())) {
@Override
public Result performLookupAction() {
ApplicationManager.getApplication().invokeLater(() -> templateFromSettings.setDeactivated(true));
return Result.HIDE_LOOKUP;
}
});
}
}
}
use of com.intellij.codeInsight.lookup.LookupElementAction in project intellij-community by JetBrains.
the class ImportStaticLookupActionProvider method fillActions.
@Override
public void fillActions(final LookupElement element, Lookup lookup, Consumer<LookupElementAction> consumer) {
final StaticallyImportable item = element.as(StaticallyImportable.CLASS_CONDITION_KEY);
if (item == null || !item.canBeImported()) {
return;
}
final Icon checkIcon = PlatformIcons.CHECK_ICON;
final Icon icon = item.willBeImported() ? checkIcon : EmptyIcon.create(checkIcon);
consumer.consume(new LookupElementAction(icon, "Import statically") {
@Override
public Result performLookupAction() {
item.setShouldBeImported(!item.willBeImported());
return new Result.ChooseItem(element);
}
});
}
use of com.intellij.codeInsight.lookup.LookupElementAction 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