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


Java VfsUtil.createDirectories方法代码示例

本文整理汇总了Java中com.intellij.openapi.vfs.VfsUtil.createDirectories方法的典型用法代码示例。如果您正苦于以下问题:Java VfsUtil.createDirectories方法的具体用法?Java VfsUtil.createDirectories怎么用?Java VfsUtil.createDirectories使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.vfs.VfsUtil的用法示例。


在下文中一共展示了VfsUtil.createDirectories方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configure

import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
public void configure(final Project project, final MavenId projectId, final String muleVersion, final VirtualFile root)
{
    try
    {
        //Create mule folders.
        final VirtualFile appDirectory = VfsUtil.createDirectories(root.getPath() + "/src/main/domain");
        final VirtualFile resources = VfsUtil.createDirectories(root.getPath() + "/src/main/resources");
        final VirtualFile muleConfigFile = createMuleConfigFile(project, projectId, appDirectory);
        createMuleDeployPropertiesFile(project, projectId, appDirectory);
        createPomFile(project, projectId, muleVersion, root);
        // execute when current dialog is closed (e.g. Project Structure)
        MavenUtil.invokeLater(project, ModalityState.NON_MODAL, () -> EditorHelper.openInEditor(getPsiFile(project, muleConfigFile)));

    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:20,代码来源:MuleDomainMavenProjectBuilderHelper.java

示例2: createDirectoryIfNotExists

import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
public static boolean createDirectoryIfNotExists(final String promptPrefix, String directoryPath, boolean promptUser) {
  File dir = new File(directoryPath);
  if (!dir.exists()) {
    if (promptUser) {
      final int answer = Messages.showOkCancelDialog(IdeBundle.message("promot.projectwizard.directory.does.not.exist", promptPrefix,
                                                                       dir.getPath(), ApplicationNamesInfo.getInstance().getFullProductName()),
                                                     IdeBundle.message("title.directory.does.not.exist"), Messages.getQuestionIcon());
      if (answer != Messages.OK) {
        return false;
      }
    }
    try {
      VfsUtil.createDirectories(dir.getPath());
    }
    catch (IOException e) {
      Messages.showErrorDialog(IdeBundle.message("error.failed.to.create.directory", dir.getPath()), CommonBundle.getErrorTitle());
      return false;
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ProjectWizardUtil.java

示例3: addFileToProject

import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
@Override
public PsiFile addFileToProject(@NotNull @NonNls String rootPath, @NotNull @NonNls final String relativePath, @NotNull @NonNls final String fileText) throws IOException {
  final VirtualFile dir = VfsUtil.createDirectories(rootPath + "/" + PathUtil.getParentPath(relativePath));

  final VirtualFile[] virtualFile = new VirtualFile[1];
  new WriteCommandAction.Simple(getProject()) {
    @Override
    protected void run() throws Throwable {
      virtualFile[0] = dir.createChildData(this, StringUtil.getShortName(relativePath, '/'));
      VfsUtil.saveText(virtualFile[0], fileText);
      PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
    }
  }.execute();
  return ApplicationManager.getApplication().runReadAction(new Computable<PsiFile>() {
          @Override
          public PsiFile compute() {
            return PsiManager.getInstance(getProject()).findFile(virtualFile[0]);
          }
        });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:HeavyIdeaTestFixtureImpl.java

示例4: makeSureParentPathExists

import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
@Nullable
private VirtualFile makeSureParentPathExists(final String[] pieces) throws IOException {
  VirtualFile child = myBaseDirectory;

  final int size = (pieces.length - 1);
  for (int i = 0; i < size; i++) {
    final String piece = pieces[i];
    if ("".equals(piece)) {
      continue;
    }
    if ("..".equals(piece)) {
      child = child.getParent();
      continue;
    }

    VirtualFile nextChild = child.findChild(piece);
    if (nextChild == null) {
      nextChild = VfsUtil.createDirectories(child.getPath() + '/' + piece);
      myCreatedDirectories.add(nextChild);
    }
    child = nextChild;
  }
  return child;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:PathsVerifier.java

示例5: outputXmlToRes

import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
public void outputXmlToRes(File targetResDir) {
  String currentFilePath = myContext.getImagePath();
  // At output step, we can ignore the errors since they have been exposed in the previous step.
  String xmlFileContent = generateVectorXml(new File(currentFilePath), null);

  String xmlFileName = myContext.getAssetName();
  // Here get the XML file content, and write into targetResDir / drawable / ***.xml
  File file = new File(targetResDir, SdkConstants.FD_RES_DRAWABLE + File.separator +
                                     xmlFileName + SdkConstants.DOT_XML);
  try {
    VirtualFile directory = VfsUtil.createDirectories(file.getParentFile().getAbsolutePath());
    VirtualFile xmlFile = directory.findChild(file.getName());
    if (xmlFile == null || !xmlFile.exists()) {
      xmlFile = directory.createChildData(this, file.getName());
    }

    VfsUtil.saveText(xmlFile, xmlFileContent);
  }
  catch (IOException e) {
    LOG.error(e);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:AssetStudioAssetGenerator.java

示例6: prepareProjectStructure

import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
private static void prepareProjectStructure(@NotNull ModifiableRootModel model, @NotNull VirtualFile root) {
  VirtualFile src = root.findChild("src");
  if (src == null || !src.isDirectory()) return;

  if (ArrayUtil.contains(src, model.getSourceRoots())) {
    try {
      VirtualFile java = VfsUtil.createDirectories(src.getPath() + "/main/java");
      if (java != null && java.isDirectory()) {
        for (VirtualFile child : src.getChildren()) {
          if (!child.getName().equals("main")) {
            child.move(null, java);
          }
        }
      }
    }
    catch (IOException e) {
      MavenLog.LOG.info(e);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:MavenFrameworkSupportProvider.java

示例7: setupRootModel

import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
@Override
public void setupRootModel(final ModifiableRootModel modifiableRootModel) throws ConfigurationException {
    super.setupRootModel(modifiableRootModel);

    String contentEntryPath = getContentEntryPath();
    if (StringUtil.isEmpty(contentEntryPath)) {
        throw new ConfigurationException("There is no valid content entry path associated with the module. Unable to generate template directory structure.");
    }

    LocalFileSystem fileSystem = getInstance();
    VirtualFile modelContentRootDir = fileSystem.refreshAndFindFileByIoFile(new File(contentEntryPath));

    if (modelContentRootDir == null) {
        throw new ConfigurationException("Model content root directory '" + contentEntryPath + "' could not be found. Unable to generate template directory structure.");
    }

    ContentEntry content = modifiableRootModel.addContentEntry(modelContentRootDir);

    try {
        VirtualFile sourceCodeDir = VfsUtil.createDirectories(modelContentRootDir.getPath() + "/src/main/java");
        VfsUtil.createDirectories(modelContentRootDir.getPath() + "/src/main/java/com/processing/sketch");

        VirtualFile resources = VfsUtil.createDirectories(modelContentRootDir.getPath() + "/src/main/resources");

        content.addSourceFolder(sourceCodeDir, false);
        content.addSourceFolder(resources, JavaResourceRootType.RESOURCE, JavaResourceRootType.RESOURCE.createDefaultProperties());
    } catch (IOException io) {
        logger.error("Unable to generate template directory structure:", io);
        throw new ConfigurationException("Unable to generate template directory structure.");
    }

    VirtualFile sketchPackagePointer = getInstance().refreshAndFindFileByPath(getContentEntryPath() + "/src/main/java/com/processing/sketch");

    if (generateTemplateSketchClass) {
        ApplicationManager.getApplication().runWriteAction(new CreateSketchTemplateFile(sketchPackagePointer));
    }
}
 
开发者ID:mistodev,项目名称:processing-idea,代码行数:38,代码来源:ProcessingModuleBuilder.java

示例8: configure

import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
public void configure(final Project project, final MavenId projectId, final String muleVersion, final VirtualFile root, @Nullable MavenId parentId)
{
    try
    {
        //Create mule folders.
        final VirtualFile appDirectory = VfsUtil.createDirectories(root.getPath() + "/src/main/app");
        final VirtualFile resources = VfsUtil.createDirectories(root.getPath() + "/src/main/resources");
        createLog4J(project, projectId, resources);
        final VirtualFile muleConfigFile = createMuleConfigFile(project, projectId, appDirectory);
        createMuleDeployPropertiesFile(project, projectId, appDirectory);
        createMuleAppPropertiesFiles(project, appDirectory);
        VfsUtil.createDirectories(root.getPath() + "/src/main/api");
        //MUnit support
        VfsUtil.createDirectories(root.getPath() + "/src/test/munit");
        final VirtualFile testResources = VfsUtil.createDirectories(root.getPath() + "/src/test/resources");
        createLog4JTest(project, projectId, testResources);

        if (parentId == null)
            createPomFile(project, projectId, muleVersion, root);
        else
            createModulePomFile(project, projectId, root, parentId);

        // execute when current dialog is closed (e.g. Project Structure)
        MavenUtil.invokeLater(project, ModalityState.NON_MODAL, () -> EditorHelper.openInEditor(getPsiFile(project, muleConfigFile)));

    }
    catch (IOException e)
    {
        e.printStackTrace();
    }
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:32,代码来源:MuleMavenProjectBuilderHelper.java

示例9: validate

import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
public boolean validate() throws ConfigurationException {
  if (!super.validate()) {
    return false;
  }

  if (CREATE_SOURCE_PANEL.equals(myCurrentMode) && myRbCreateSource.isSelected()) {
    final String sourceDirectoryPath = getSourceDirectoryPath();
    final String relativePath = myTfSourceDirectoryName.getText().trim();
    if (relativePath.length() == 0) {
      String text = IdeBundle.message("prompt.relative.path.to.sources.empty", FileUtil.toSystemDependentName(sourceDirectoryPath));
      final int answer = Messages.showYesNoCancelDialog(myTfSourceDirectoryName, text, IdeBundle.message("title.mark.source.directory"),
                                             IdeBundle.message("action.mark"), IdeBundle.message("action.do.not.mark"),
                                               CommonBundle.getCancelButtonText(), Messages.getQuestionIcon());
      if (answer == Messages.CANCEL) {
        return false; // cancel
      }
      if (answer == Messages.NO) { // don't mark
        myRbNoSource.doClick();
      }
    }
    if (sourceDirectoryPath != null) {
      final File rootDir = new File(getContentRootPath());
      final File srcDir = new File(sourceDirectoryPath);
      if (!FileUtil.isAncestor(rootDir, srcDir, false)) {
        Messages.showErrorDialog(myTfSourceDirectoryName,
                                 IdeBundle.message("error.source.directory.should.be.under.module.content.root.directory"),
                                 CommonBundle.getErrorTitle());
        return false;
      }
      try {
        VfsUtil.createDirectories(srcDir.getPath());
      }
      catch (IOException e) {
        throw new ConfigurationException(e.getMessage());
      }
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:SourcePathsStep.java

示例10: createDir

import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
private static boolean createDir(File ideaDir) {
  try {
    VfsUtil.createDirectories(ideaDir.getPath());
    return true;
  }
  catch (IOException e) {
    return false;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:SaveAsDirectoryBasedFormatAction.java

示例11: findFile

import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
@Override
public VirtualFile findFile(@NotNull RootType rootType, @NotNull String pathName, @NotNull Option option) throws IOException {
  ApplicationManager.getApplication().assertReadAccessAllowed();

  String fullPath = getRootPath(rootType) + "/" + pathName;
  if (option != Option.create_new_always) {
    VirtualFile file = LocalFileSystem.getInstance().findFileByPath(fullPath);
    if (file != null && !file.isDirectory()) return file;
    if (option == Option.existing_only) return null;
  }
  String ext = PathUtil.getFileExtension(pathName);
  String fileNameExt = PathUtil.getFileName(pathName);
  String fileName = StringUtil.trimEnd(fileNameExt, ext == null ? "" : "." + ext);
  AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(getClass());
  try {
    VirtualFile dir = VfsUtil.createDirectories(PathUtil.getParentPath(fullPath));
    if (option == Option.create_new_always) {
      return VfsUtil.createChildSequent(LocalFileSystem.getInstance(), dir, fileName, StringUtil.notNullize(ext));
    }
    else {
      return dir.createChildData(LocalFileSystem.getInstance(), fileNameExt);
    }
  }
  finally {
    token.finish();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:ScratchFileServiceImpl.java

示例12: createModulePom

import com.intellij.openapi.vfs.VfsUtil; //导入方法依赖的package包/类
private VirtualFile createModulePom() throws IOException {
  VirtualFile baseDir = myVirtualFile.getParent();
  String modulePath = PathUtil.getCanonicalPath(baseDir.getPath() + "/" + myText);
  VirtualFile moduleDir = VfsUtil.createDirectories(modulePath);
  return moduleDir.createChildData(this, MavenConstants.POM_XML);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:7,代码来源:MavenModulePsiReference.java


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