當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。