本文整理汇总了Java中com.intellij.ide.fileTemplates.FileTemplateUtil.canCreateFromTemplate方法的典型用法代码示例。如果您正苦于以下问题:Java FileTemplateUtil.canCreateFromTemplate方法的具体用法?Java FileTemplateUtil.canCreateFromTemplate怎么用?Java FileTemplateUtil.canCreateFromTemplate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.ide.fileTemplates.FileTemplateUtil
的用法示例。
在下文中一共展示了FileTemplateUtil.canCreateFromTemplate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canCreateFromTemplate
import com.intellij.ide.fileTemplates.FileTemplateUtil; //导入方法依赖的package包/类
static boolean canCreateFromTemplate(AnActionEvent e, FileTemplate template){
if (e == null) return false;
DataContext dataContext = e.getDataContext();
IdeView view = LangDataKeys.IDE_VIEW.getData(dataContext);
if (view == null) return false;
PsiDirectory[] dirs = view.getDirectories();
if (dirs.length == 0) return false;
return FileTemplateUtil.canCreateFromTemplate(dirs, template);
}
示例2: canCreateFromTemplate
import com.intellij.ide.fileTemplates.FileTemplateUtil; //导入方法依赖的package包/类
static boolean canCreateFromTemplate(AnActionEvent e, FileTemplate template) {
if (e == null) return false;
DataContext dataContext = e.getDataContext();
IdeView view = dataContext.getData(LangDataKeys.IDE_VIEW);
if (view == null) return false;
PsiDirectory[] dirs = view.getDirectories();
if (dirs.length == 0) return false;
return FileTemplateUtil.canCreateFromTemplate(dirs, template);
}
示例3: generateFromTemplate
import com.intellij.ide.fileTemplates.FileTemplateUtil; //导入方法依赖的package包/类
@Nullable
private PsiElement generateFromTemplate(
String templateName,
String outputFileName,
Path outputFolderPath,
Properties templateProperties,
Module module) {
FileTemplate configTemplate =
FileTemplateManager.getDefaultInstance().getInternalTemplate(templateName);
File outputFolder = outputFolderPath.toFile();
if (!outputFolder.exists() && !outputFolder.mkdirs()) {
logger.warn("Failed to create " + outputFileName + " directory: " + outputFolder.toString());
return null;
}
VirtualFile virtualOutputFolder =
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(outputFolder);
if (virtualOutputFolder == null) {
logger.warn("Failed to locate " + outputFolder.toString() + "directory");
return null;
}
PsiDirectory outputPsiDirectory =
PsiManager.getInstance(module.getProject()).findDirectory(virtualOutputFolder);
if (outputPsiDirectory != null
&& FileTemplateUtil.canCreateFromTemplate(
new PsiDirectory[] {outputPsiDirectory}, configTemplate)) {
try {
return FileTemplateUtil.createFromTemplate(
configTemplate, outputFileName, templateProperties, outputPsiDirectory);
} catch (Exception e) {
// If the file already exists, this exception will be thrown by createFromTemplate
// We want to silently skip the generation in this case.
logger.debug("Failed to create app.yaml from template. " + e.getMessage());
}
} else {
logger.error("Failed to create app.yaml from template");
}
return null;
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:42,代码来源:DefaultAppEngineProjectService.java