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

The following examples show how to use com.intellij.codeInsight.template.postfix.templates.PostfixTemplate. 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: AndroidPostfixTemplateProvider.java    From android-postfix-plugin with Apache License 2.0 6 votes vote down vote up
public AndroidPostfixTemplateProvider() {
    templates = ContainerUtil.<PostfixTemplate>newHashSet(
            new ToastTemplate(),
            new LogTemplate(),
            new LogDTemplate(),
            new TextUtilsIsEmptyTemplate(),
            new VisibleGoneTemplate(),
            new FindViewByIdTemplate(),
            new FindViewByIdVariableTemplate(),
            new FindViewByIdFieldTemplate(),
            new VisibleTemplate(),
            new InvisibleTemplate(),
            new GoneTemplate(),
            new SnackbarTemplate(),
            new SnackbarTemplate(true)
    );
}
 
Example #2
Source File: PostfixTemplatesChildConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void focusTemplate(PostfixTemplate template) {
  int itemIndex = myCheckBoxList.getItemIndex(template);
  if(itemIndex == -1) {
    return;
  }
  myCheckBoxList.setSelectedIndex(itemIndex);
}
 
Example #3
Source File: SandPostfixTemplateProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public Set<PostfixTemplate> getTemplates() {
  return new HashSet<PostfixTemplate>() {
    {
      add(new TestTemplate());
      add(new DDTemplate());
    }
  };
}
 
Example #4
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 #5
Source File: FluidPostfixTemplateProvider.java    From idea-php-typo3-plugin with MIT License 5 votes vote down vote up
@NotNull
@Override
public Set<PostfixTemplate> getTemplates() {
    return ContainerUtil.set(
        new AliasPostfixTemplate(),
        new ForEachPostfixTemplate(),
        new DebugInlinePostfixTemplate()
    );
}
 
Example #6
Source File: PostfixTemplatesChildConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void reset() {
  int size = myCheckBoxList.getItemsCount();

  for (int i = 0; i < size; i++) {
    PostfixTemplate itemAt = myCheckBoxList.getItemAt(i);

    myCheckBoxList.setItemSelected(itemAt, myTemplatesSettings.isTemplateEnabled(itemAt, myExtensionPoint.getInstance()));
  }
}
 
Example #7
Source File: PostfixTemplatesChildConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void apply() throws ConfigurationException {
  int size = myCheckBoxList.getItemsCount();
  for (int i = 0; i < size; i++) {
    PostfixTemplate itemAt = myCheckBoxList.getItemAt(i);

    if (myCheckBoxList.isItemSelected(i)) {
      myTemplatesSettings.enableTemplate(itemAt, myExtensionPoint.getInstance());
    }
    else {
      myTemplatesSettings.disableTemplate(itemAt, myExtensionPoint.getInstance());
    }
  }
}
 
Example #8
Source File: PostfixTemplatesChildConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public boolean isModified() {
  int size = myCheckBoxList.getItemsCount();
  for (int i = 0; i < size; i++) {
    PostfixTemplate itemAt = myCheckBoxList.getItemAt(i);

    if (myTemplatesSettings.isTemplateEnabled(itemAt, myExtensionPoint.getInstance()) != myCheckBoxList.isItemSelected(i)) {
      return true;
    }
  }
  return false;
}
 
Example #9
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 #10
Source File: HakunaMatataPostfixTemplateProvider.java    From HakunaMatataIntelliJPlugin with Apache License 2.0 5 votes vote down vote up
public HakunaMatataPostfixTemplateProvider() {
        templates = ContainerUtil.<PostfixTemplate>newHashSet(
                new AssignNewExpressionTemplate(),
                new EmptyStringTemplate(),
                new NewExpressionTemplate(),
                new IfElseStatementPostfixTemplate(),
//                new IfElseIfStatementPostfixTemplate(),
                new AssertBasePostfixTemplate(AssertMethod.EQUALS),
                new AssertBasePostfixTemplate(AssertMethod.NOT_EQUALS),
                new AssertBasePostfixTemplate(AssertMethod.SAME),
                new AssertBasePostfixTemplate(AssertMethod.NOT_SAME),
                new AssertBasePostfixTemplate(AssertMethod.THAT),
                new AssertBasePostfixTemplate(AssertMethod.TRUE),
                new AssertBasePostfixTemplate(AssertMethod.FALSE),
                new MockitoBasePostfixTemplate(MockitoMethod.WHEN_THEN),
                new MockitoBasePostfixTemplate(MockitoMethod.WHEN_THENCALLREALMETHOD),
                new MockitoBasePostfixTemplate(MockitoMethod.WHEN_THENANSWER),
                new MockitoBasePostfixTemplate(MockitoMethod.WHEN_THENRETURN),
                new MockitoBasePostfixTemplate(MockitoMethod.WHEN_THENTHROW),
                new MockitoBasePostfixTemplate(MockitoMethod.DO_NOTHING_WHEN),
                new MockitoBasePostfixTemplate(MockitoMethod.DO_RETURN_WHEN),
                new MockitoBasePostfixTemplate(MockitoMethod.DO_THROW_WHEN),
                new MockitoBasePostfixTemplate(MockitoMethod.MOCK),
                new MockitoBasePostfixTemplate(MockitoMethod.SPY),
                new MockitoBasePostfixTemplate(MockitoMethod.VERIFY),
                new MockitoBasePostfixTemplate(MockitoMethod.VERIFY_NO_MORE_INTERACTIONS),
                new MockitoBasePostfixTemplate(MockitoMethod.VERIFY_ZERO_INTERACTIONS)
        );
    }
 
Example #11
Source File: LombokPostfixTemplateProvider.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@NotNull
@Override
public Set<PostfixTemplate> getTemplates() {
  return lombokTemplates;
}
 
Example #12
Source File: CSharpPostfixTemplateProvider.java    From consulo-csharp with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public Set<PostfixTemplate> getTemplates()
{
	return myTemplates;
}
 
Example #13
Source File: AndroidPostfixTemplateProvider.java    From android-postfix-plugin with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
public Set<PostfixTemplate> getTemplates() {
    return templates;
}
 
Example #14
Source File: HakunaMatataPostfixTemplateProvider.java    From HakunaMatataIntelliJPlugin with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
public Set<PostfixTemplate> getTemplates() {
    return templates;
}
 
Example #15
Source File: PostfixTemplateLookupElement.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public PostfixTemplate getPostfixTemplate() {
  return myTemplate;
}
 
Example #16
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 #17
Source File: PostfixTemplatesSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
public boolean isTemplateEnabled(PostfixTemplate template, @Nonnull String strictLangForProvider) {
  Set<String> result = myLangToDisabledTemplates.get(strictLangForProvider);
  return result == null || !result.contains(template.getKey());
}
 
Example #18
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 #19
Source File: PostfixTemplatesSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void disableTemplate(PostfixTemplate template, String langForProvider) {
  Set<String> state = ContainerUtil.getOrCreate(myLangToDisabledTemplates, langForProvider, (Factory<Set<String>>)ContainerUtil::newHashSet);
  state.add(template.getKey());
}
 
Example #20
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);
}
 
Example #21
Source File: PostfixTemplatesSettings.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void enableTemplate(PostfixTemplate template, String langForProvider) {
  Set<String> state = ContainerUtil.getOrCreate(myLangToDisabledTemplates, langForProvider, (Factory<Set<String>>)ContainerUtil::newHashSet);
  state.remove(template.getKey());
}
 
Example #22
Source File: PostfixTemplateMetaData.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static PostfixTemplateMetaData createMetaData(@Nullable PostfixTemplate template) {
  if (template == null) return EMPTY_METADATA;

  return new PostfixTemplateMetaData(template);
}
 
Example #23
Source File: PostfixTemplateMetaData.java    From consulo with Apache License 2.0 4 votes vote down vote up
public PostfixTemplateMetaData(PostfixTemplate template) {
  super(template.getClass().getClassLoader(), template.getClass().getSimpleName());
  myTemplate = template;
}