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


Java AllFileTemplatesConfigurable类代码示例

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


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

示例1: actionPerformed

import com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e){
  Project project = e.getData(PlatformDataKeys.PROJECT);
  String fileText = e.getData(PlatformDataKeys.FILE_TEXT);
  VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE);
  String extension = file.getExtension();
  String nameWithoutExtension = file.getNameWithoutExtension();
  AllFileTemplatesConfigurable fileTemplateOptions = new AllFileTemplatesConfigurable();
  ConfigureTemplatesDialog dialog = new ConfigureTemplatesDialog(project, fileTemplateOptions);
  PsiFile psiFile = e.getData(LangDataKeys.PSI_FILE);
  for(SaveFileAsTemplateHandler handler: Extensions.getExtensions(SaveFileAsTemplateHandler.EP_NAME)) {
    String textFromHandler = handler.getTemplateText(psiFile, fileText, nameWithoutExtension);
    if (textFromHandler != null) {
      fileText = textFromHandler;
      break;
    }
  }
  fileTemplateOptions.createNewTemplate(nameWithoutExtension, extension, fileText);
  dialog.show();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:SaveFileAsTemplateAction.java

示例2: actionPerformed

import com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable; //导入依赖的package包/类
@RequiredDispatchThread
@Override
public void actionPerformed(@Nonnull AnActionEvent e){
  Project project = e.getRequiredData(CommonDataKeys.PROJECT);
  String fileText = e.getData(PlatformDataKeys.FILE_TEXT);
  VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE);
  String extension = file.getExtension();
  String nameWithoutExtension = file.getNameWithoutExtension();
  AllFileTemplatesConfigurable fileTemplateOptions = new AllFileTemplatesConfigurable(project);
  ConfigureTemplatesDialog dialog = new ConfigureTemplatesDialog(project, fileTemplateOptions);
  PsiFile psiFile = e.getData(LangDataKeys.PSI_FILE);
  for(SaveFileAsTemplateHandler handler: Extensions.getExtensions(SaveFileAsTemplateHandler.EP_NAME)) {
    String textFromHandler = handler.getTemplateText(psiFile, fileText, nameWithoutExtension);
    if (textFromHandler != null) {
      fileText = textFromHandler;
      break;
    }
  }
  fileTemplateOptions.createNewTemplate(nameWithoutExtension, extension, fileText);
  dialog.show();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:22,代码来源:SaveFileAsTemplateAction.java

示例3: createEditTemplateAction

import com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable; //导入依赖的package包/类
@Nullable
@Override
public AnAction createEditTemplateAction(DataContext dataContext) {
  final Project project = CommonDataKeys.PROJECT.getData(dataContext);
  final Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
  final PsiFile file = CommonDataKeys.PSI_FILE.getData(dataContext);
  final PsiClass targetClass = editor == null || file == null ? null : getTargetClass(editor, file);
  if (targetClass != null) {
    final List<TestFramework> frameworks = TestIntegrationUtils.findSuitableFrameworks(targetClass);
    final TestIntegrationUtils.MethodKind methodKind = ((MyHandler)getHandler()).myMethodKind;
    if (!frameworks.isEmpty()) {
      return new AnAction("Edit Template") {
        @Override
        public void actionPerformed(AnActionEvent e) {
          chooseAndPerform(editor, frameworks, new Consumer<TestFramework>() {
            @Override
            public void consume(TestFramework framework) {
              final FileTemplateDescriptor descriptor = methodKind.getFileTemplateDescriptor(framework);
              if (descriptor != null) {
                final String fileName = descriptor.getFileName();
                AllFileTemplatesConfigurable.editCodeTemplate(FileUtil.getNameWithoutExtension(fileName), project);
              } else {
                HintManager.getInstance().showErrorHint(editor, "No template found for " + framework.getName() + ":" + BaseGenerateTestSupportMethodAction.this.getTemplatePresentation().getText());
              }
            }
          });
        }
      };
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:BaseGenerateTestSupportMethodAction.java

示例4: testFindCodeTemplates

import com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable; //导入依赖的package包/类
public void testFindCodeTemplates() {
  ConfigurableGroup[] groups = {new ProjectConfigurablesGroup(getProject())};
  ConfigurableHit configurables = SearchableOptionsRegistrar.getInstance().getConfigurables(groups, DocumentEvent.EventType.INSERT, null, "method", getProject());
  Set<Configurable> configurableSet = configurables.getAll();
  for (Configurable configurable : configurableSet) {
    if (configurable.getDisplayName().equals(new AllFileTemplatesConfigurable(getProject()).getDisplayName())) {
      return;
    }
  }
  fail("File Templates are not found");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:SearchableOptionsTest.java

示例5: testFindCodeTemplates

import com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable; //导入依赖的package包/类
public void testFindCodeTemplates() throws Exception {
  final ConfigurableHit configurables =
    SearchableOptionsRegistrar.getInstance().getConfigurables(new ConfigurableGroup[]{new IdeConfigurablesGroup()}, DocumentEvent.EventType.INSERT, null, "method", getProject());
  final Set<Configurable> configurableSet = configurables.getAll();
  for (Configurable configurable : configurableSet) {
    if (configurable.getDisplayName().equals(new AllFileTemplatesConfigurable().getDisplayName())) {
      return;
    }
  }
  fail("File Templates are not found");
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:12,代码来源:SearchableOptionsTest.java

示例6: ConfigureTemplatesDialog

import com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable; //导入依赖的package包/类
public ConfigureTemplatesDialog(Project project){
  this(project, new AllFileTemplatesConfigurable(project));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:ConfigureTemplatesDialog.java

示例7: ConfigureTemplatesDialog

import com.intellij.ide.fileTemplates.impl.AllFileTemplatesConfigurable; //导入依赖的package包/类
public ConfigureTemplatesDialog(Project project){
  this(project, new AllFileTemplatesConfigurable());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:4,代码来源:ConfigureTemplatesDialog.java


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