当前位置: 首页>>代码示例>>Java>>正文


Java TemplateContextType类代码示例

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


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


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