com.intellij.codeInsight.template.postfix.templates.PostfixTemplateProvider Java Examples

The following examples show how to use com.intellij.codeInsight.template.postfix.templates.PostfixTemplateProvider. 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: PostfixTemplatesChildConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Nullable
@Override
public JComponent createComponent() {
  PostfixTemplateProvider postfixTemplateProvider = myExtensionPoint.getInstance();
  if (postfixTemplateProvider == null) {
    return null;
  }

  OnePixelSplitter splitter = new OnePixelSplitter();
  splitter.setSplitterProportionKey("PostfixTemplatesChildConfigurable.splitter");

  myCheckBoxList = new CheckBoxList<>();

  splitter.setFirstComponent(ScrollPaneFactory.createScrollPane(myCheckBoxList, true));

  myPostfixDescriptionPanel = new PostfixDescriptionPanel();
  JPanel component = myPostfixDescriptionPanel.getComponent();
  component.setBorder(JBUI.Borders.empty(0, 8, 0, 0));
  splitter.setSecondComponent(component);

  myCheckBoxList.setItems(new ArrayList<>(postfixTemplateProvider.getTemplates()), PostfixTemplate::getPresentableName, postfixTemplate -> Boolean.TRUE);

  myCheckBoxList.addListSelectionListener(new ListSelectionListener() {
    @Override
    public void valueChanged(ListSelectionEvent e) {
      PostfixTemplate itemAt = myCheckBoxList.getItemAt(myCheckBoxList.getSelectedIndex());

      myPostfixDescriptionPanel.reset(PostfixTemplateMetaData.createMetaData(itemAt));
    }
  });
  return splitter;
}
 
Example #2
Source File: PostfixTemplateLookupElement.java    From consulo with Apache License 2.0 5 votes vote down vote up
public PostfixTemplateLookupElement(@Nonnull PostfixLiveTemplate liveTemplate,
                                    @Nonnull PostfixTemplate postfixTemplate,
                                    @Nonnull String templateKey,
                                    @Nonnull PostfixTemplateProvider provider,
                                    boolean sudden) {
  super(liveTemplate, templateKey, StringUtil.trimStart(templateKey, "."), postfixTemplate.getDescription(), sudden, true);
  myTemplate = postfixTemplate;
  myProvider = provider;
}
 
Example #3
Source File: PostfixTemplatesConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
public PostfixTemplatesChildConfigurable findConfigurable(PostfixTemplateProvider postfixTemplateProvider) {
  for (Configurable configurable : getConfigurables()) {
    PostfixTemplatesChildConfigurable childConfigurable = (PostfixTemplatesChildConfigurable)configurable;

    if (childConfigurable.getPostfixTemplateProvider() == postfixTemplateProvider) {
      return childConfigurable;
    }
  }
  return null;
}
 
Example #4
Source File: PostfixTemplatesChildConfigurable.java    From consulo with Apache License 2.0 4 votes vote down vote up
public PostfixTemplateProvider getPostfixTemplateProvider() {
  return myExtensionPoint.getInstance();
}
 
Example #5
Source File: PostfixTemplateLookupElement.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public PostfixTemplateProvider getProvider() {
  return myProvider;
}
 
Example #6
Source File: PostfixTemplatesSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
public boolean isTemplateEnabled(@Nonnull PostfixTemplate template, @Nonnull PostfixTemplateProvider provider) {
  String langForProvider = PostfixTemplatesUtils.getLangForProvider(provider);
  return isTemplateEnabled(template, langForProvider);
}
 
Example #7
Source File: PostfixTemplatesSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void disableTemplate(@Nonnull PostfixTemplate template, @Nonnull PostfixTemplateProvider provider) {
  String langForProvider = PostfixTemplatesUtils.getLangForProvider(provider);
  disableTemplate(template, langForProvider);
}
 
Example #8
Source File: PostfixTemplatesSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void enableTemplate(@Nonnull PostfixTemplate template, @Nonnull PostfixTemplateProvider provider) {
  String langForProvider = PostfixTemplatesUtils.getLangForProvider(provider);
  enableTemplate(template, langForProvider);
}