• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java TemplateContextType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.codeInsight.template.TemplateContextType的典型用法代码示例。如果您正苦于以下问题:Java TemplateContextType类的具体用法?Java TemplateContextType怎么用?Java TemplateContextType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



TemplateContextType类属于com.intellij.codeInsight.template包,在下文中一共展示了TemplateContextType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: addContextNode

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
private static void addContextNode(MultiMap<TemplateContextType, TemplateContextType> hierarchy,
                                   CheckedTreeNode parent,
                                   TemplateContextType type, TemplateContext context) {
  final Collection<TemplateContextType> children = hierarchy.get(type);
  final String name = UIUtil.removeMnemonic(type.getPresentableName());
  final CheckedTreeNode node = new CheckedTreeNode(Pair.create(children.isEmpty() ? type : null, name));
  parent.add(node);

  if (children.isEmpty()) {
    node.setChecked(context.isExplicitlyEnabled(type));
  }
  else {
    for (TemplateContextType child : children) {
      addContextNode(hierarchy, node, child, context);
    }
    final CheckedTreeNode other = new CheckedTreeNode(Pair.create(type, "Other"));
    other.setChecked(context.isExplicitlyEnabled(type));
    node.add(other);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:LiveTemplateSettingsEditor.java


示例2: getDifference

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
Map<TemplateContextType, Boolean> getDifference(@Nullable TemplateContext defaultContext) {
  Map<TemplateContextType, Boolean> result = ContainerUtil.newLinkedHashMap();
  synchronized (myContextStates) {
    //noinspection NestedSynchronizedStatement
    synchronized (defaultContext == null ? myContextStates : defaultContext.myContextStates) {
      for (TemplateContextType contextType : TemplateManagerImpl.getAllContextTypes()) {
        Boolean ownValue = getOwnValue(contextType);
        if (ownValue != null) {
          if (defaultContext == null || isEnabled(contextType) != defaultContext.isEnabled(contextType)) {
            result.put(contextType, ownValue);
          }
        }
      }
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:TemplateContext.java


示例3: performCopy

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
@Override
public void performCopy(@NotNull DataContext dataContext) {
  final Set<TemplateImpl> templates = myConfigurable.getSelectedTemplates().keySet();


  CopyPasteManager.getInstance().setContents(new StringSelection(StringUtil.join(templates, new Function<TemplateImpl, String>() {
    @Override
    public String fun(TemplateImpl template) {
      TemplateContext zeroContext = new TemplateContext();
      for (TemplateContextType type : TemplateContextType.EP_NAME.getExtensions()) {
        zeroContext.setEnabled(type, false);
      }
      return JDOMUtil.writeElement(TemplateSettings.serializeTemplate(template, zeroContext));
    }
  }, SystemProperties.getLineSeparator())));
  
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:LiveTemplateTree.java


示例4: addContextNode

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
private void addContextNode(MultiMap<TemplateContextType, TemplateContextType> hierarchy,
                            CheckedTreeNode parent,
                            TemplateContextType type) {
  final Collection<TemplateContextType> children = hierarchy.get(type);
  final String name = UIUtil.removeMnemonic(type.getPresentableName());
  final CheckedTreeNode node = new CheckedTreeNode(Pair.create(children.isEmpty() ? type : null, name));
  parent.add(node);

  if (children.isEmpty()) {
    node.setChecked(myContext.get(type));
  }
  else {
    for (TemplateContextType child : children) {
      addContextNode(hierarchy, node, child);
    }
    final CheckedTreeNode other = new CheckedTreeNode(Pair.create(type, "Other"));
    other.setChecked(myContext.get(type));
    node.add(other);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:LiveTemplateSettingsEditor.java


示例5: createTemplateEditor

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
private void createTemplateEditor(final TemplateImpl template,
                                  String shortcut,
                                  Map<TemplateOptionalProcessor, Boolean> options,
                                  Map<TemplateContextType, Boolean> context) {
  myCurrentTemplateEditor = new LiveTemplateSettingsEditor(template, shortcut, options, context, new Runnable() {
    @Override
    public void run() {
      DefaultMutableTreeNode node = getNode(getSingleSelectedIndex());
      if (node != null) {
        ((DefaultTreeModel)myTree.getModel()).nodeChanged(node);
        TemplateSettings.getInstance().setLastSelectedTemplate(template.getGroupName(), template.getKey());
      }
    }
  }, TemplateSettings.getInstance().getTemplate(template.getKey(), template.getGroupName()) != null);
  for (Component component : myDetailsPanel.getComponents()) {
    if (component instanceof LiveTemplateSettingsEditor) {
      myDetailsPanel.remove(component);
    }
  }

  myDetailsPanel.add(myCurrentTemplateEditor, TEMPLATE_SETTINGS);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:TemplateListPanel.java


示例6: getDifference

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
Map<TemplateContextType, Boolean> getDifference(@Nullable TemplateContext defaultContext) {
  Map<TemplateContextType, Boolean> result = ContainerUtil.newLinkedHashMap();
  synchronized (myContextStates) {
    //noinspection NestedSynchronizedStatement
    synchronized (defaultContext == null ? myContextStates : defaultContext.myContextStates) {
      for (TemplateContextType contextType : TemplateManagerImpl.getAllContextTypes()) {
        String context = contextType.getContextId();
        Boolean myStateInContext = myContextStates.get(context);
        if (myStateInContext != null && differsFromDefault(defaultContext, context, myStateInContext)) {
          result.put(contextType, myStateInContext);
        }
      }
    }
  }
  return result;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:TemplateContext.java


示例7: getDifference

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
Map<TemplateContextType, Boolean> getDifference(@Nullable TemplateContext defaultContext) {
  Map<TemplateContextType, Boolean> result = ContainerUtil.newLinkedHashMap();
  synchronized (myContextStates) {
    //noinspection NestedSynchronizedStatement
    synchronized (defaultContext == null ? myContextStates : defaultContext.myContextStates) {
      for (TemplateContextType contextType : TemplateContextType.EP_NAME.getExtensions()) {
        String context = contextType.getContextId();
        Boolean myStateInContext = myContextStates.get(context);
        if (myStateInContext != null && differsFromDefault(defaultContext, context, myStateInContext)) {
          result.put(contextType, myStateInContext);
        }
      }
    }
  }
  return result;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:TemplateContext.java


示例8: testLiveTemplate

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
public void testLiveTemplate() throws Throwable {
  final Template template = TemplateManager.getInstance(getProject()).createTemplate("foo", "zzz");
  template.addTextSegment("FooFactory.createFoo()");
  final SmartCompletionContextType completionContextType =
    ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), SmartCompletionContextType.class);
  ((TemplateImpl)template).getTemplateContext().setEnabled(completionContextType, true);
  CodeInsightTestUtil.addTemplate(template, myTestRootDisposable);
  doTest();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:SmartTypeCompletionTest.java


示例9: getApplicableContexts

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
private List<TemplateContextType> getApplicableContexts() {
  ArrayList<TemplateContextType> result = new ArrayList<TemplateContextType>();
  for (TemplateContextType type : TemplateManagerImpl.getAllContextTypes()) {
    if (myContext.isExplicitlyEnabled(type)) {
      result.add(type);
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:LiveTemplateSettingsEditor.java


示例10: isExpandableFromEditor

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
private boolean isExpandableFromEditor() {
  boolean hasNonExpandable = false;
  for (TemplateContextType type : getApplicableContexts()) {
    if (type.isExpandableFromEditor()) {
      return true;
    }
    hasNonExpandable = true;
  }
  
  return !hasNonExpandable;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:LiveTemplateSettingsEditor.java


示例11: isEnabled

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
public boolean isEnabled(TemplateContextType contextType) {
  synchronized (myContextStates) {
    Boolean storedValue = getOwnValue(contextType);
    if (storedValue == null) {
      TemplateContextType baseContextType = contextType.getBaseContextType();
      if (baseContextType != null && !(baseContextType instanceof EverywhereContextType)) {
        return isEnabled(baseContextType);
      }
      return false;
    }
    return storedValue.booleanValue();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:TemplateContext.java


示例12: writeTemplateContext

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
void writeTemplateContext(Element element, @Nullable TemplateContext defaultContext) throws WriteExternalException {
  Map<TemplateContextType, Boolean> diff = getDifference(defaultContext);
  for (TemplateContextType type : diff.keySet()) {
    Element optionElement = new Element("option");
    optionElement.setAttribute("name", type.getContextId());
    optionElement.setAttribute("value", diff.get(type).toString());
    element.addContent(optionElement);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:TemplateContext.java


示例13: createDocument

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
private static Document createDocument(CharSequence text, @Nullable TemplateContext context, Project project) {
  if (context != null) {
    for (TemplateContextType type : TemplateManagerImpl.getAllContextTypes()) {
      if (context.isExplicitlyEnabled(type)) {
        return type.createDocument(text, project);
      }
    }
  }

  return EditorFactory.getInstance().createDocument(text);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:TemplateEditorUtil.java


示例14: setHighlighter

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
public static void setHighlighter(Editor editor, @Nullable TemplateContext templateContext) {
  SyntaxHighlighter highlighter = null;
  if (templateContext != null) {
    for(TemplateContextType type: TemplateManagerImpl.getAllContextTypes()) {
      if (templateContext.isEnabled(type)) {
        highlighter = type.createHighlighter();
        if (highlighter != null) break;
      }
    }
  }
  setHighlighter((EditorEx)editor, highlighter);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:TemplateEditorUtil.java


示例15: EditVariableDialog

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
public EditVariableDialog(Editor editor, Component parent, ArrayList<Variable> variables, List<TemplateContextType> contextTypes) {
  super(parent, true);
  myContextTypes = contextTypes;
  setButtonsMargin(null);
  myVariables = variables;
  myEditor = editor;
  init();
  setTitle(CodeInsightBundle.message("templates.dialog.edit.variables.title"));
  setOKButtonText(CommonBundle.getOkButtonText());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:EditVariableDialog.java


示例16: createJsonTemplate

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
@NotNull
private Template createJsonTemplate(@NotNull String name, @NotNull String group, @NotNull String text) {
  final TemplateManager templateManager = TemplateManager.getInstance(getProject());
  final Template template = templateManager.createTemplate(name, group, text);

  final TemplateContextType context = ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), JsonContextType.class);
  assertNotNull(context);
  ((TemplateImpl)template).getTemplateContext().setEnabled(context, true);

  CodeInsightTestUtil.addTemplate(template, myTestRootDisposable);
  return template;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:JsonLiveTemplateTest.java


示例17: testLiveTemplate

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
public void testLiveTemplate() throws Throwable {
  final Template template = TemplateManager.getInstance(getProject()).createTemplate("foo", "zzz");
  template.addTextSegment("FooFactory.createFoo()");
  final SmartCompletionContextType completionContextType =
    ContainerUtil.findInstance(TemplateContextType.EP_NAME.getExtensions(), SmartCompletionContextType.class);
  ((TemplateImpl)template).getTemplateContext().setEnabled(completionContextType, true);
  TemplateSettings.getInstance().addTemplate(template);
  try {
    doTest();
  }
  finally {
    TemplateSettings.getInstance().removeTemplate(template);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:SmartTypeCompletionTest.java


示例18: getApplicableContexts

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
private List<TemplateContextType> getApplicableContexts() {
  ArrayList<TemplateContextType> result = new ArrayList<TemplateContextType>();
  for (TemplateContextType type : myContext.keySet()) {
    if (myContext.get(type).booleanValue()) {
      result.add(type);
    }
  }
  return result;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:LiveTemplateSettingsEditor.java


示例19: updateHighlighter

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
private void updateHighlighter() {
  List<TemplateContextType> applicableContexts = getApplicableContexts();
  if (!applicableContexts.isEmpty()) {
    TemplateContext contextByType = new TemplateContext();
    contextByType.setEnabled(applicableContexts.get(0), true);
    TemplateEditorUtil.setHighlighter(myTemplateEditor, contextByType);
    return;
  }
  ((EditorEx) myTemplateEditor).repaint(0, myTemplateEditor.getDocument().getTextLength());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:11,代码来源:LiveTemplateSettingsEditor.java


示例20: areContextsEqual

import com.intellij.codeInsight.template.TemplateContextType; //导入依赖的package包/类
private boolean areContextsEqual(final TemplateImpl newTemplate, final TemplateImpl originalTemplate) {
  Map<TemplateContextType, Boolean> templateContext = getTemplateContext(newTemplate);
  for (TemplateContextType processor : templateContext.keySet()) {
    if (originalTemplate.getTemplateContext().isEnabled(processor) != templateContext.get(processor).booleanValue())
      return false;
  }
  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:9,代码来源:TemplateListPanel.java



注:本文中的com.intellij.codeInsight.template.TemplateContextType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java NetworkLayer类代码示例发布时间:2022-05-21
下一篇:
Java License类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap