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


Java VfsUtil类代码示例

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


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

示例1: getAlreadyOpenedModules

import com.intellij.openapi.vfs.VfsUtil; //导入依赖的package包/类
@NotNull
protected Set<HybrisModuleDescriptor> getAlreadyOpenedModules(@NotNull final Project project) {
    Validate.notNull(project);

    final HybrisModuleDescriptorFactory hybrisModuleDescriptorFactory = ServiceManager.getService(
        HybrisModuleDescriptorFactory.class
    );

    final Set<HybrisModuleDescriptor> existingModules = new THashSet<HybrisModuleDescriptor>();

    for (Module module : ModuleManager.getInstance(project).getModules()) {
        try {
            final VirtualFile[] contentRoots = ModuleRootManager.getInstance(module).getContentRoots();

            if (!ArrayUtils.isEmpty(contentRoots)) {
                existingModules.add(hybrisModuleDescriptorFactory.createDescriptor(
                    VfsUtil.virtualToIoFile(contentRoots[0]), this
                ));
            }
        } catch (HybrisConfigurationException e) {
            LOG.error(e);
        }
    }

    return existingModules;
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:27,代码来源:DefaultHybrisProjectDescriptor.java

示例2: createGlobalLibrary

import com.intellij.openapi.vfs.VfsUtil; //导入依赖的package包/类
public void createGlobalLibrary(
    @NotNull final IdeModifiableModelsProvider modifiableModelsProvider,
    @NotNull final File libraryDirRoot,
    @NotNull final String libraryName
) {
    final LibraryTable.ModifiableModel libraryTableModifiableModel = modifiableModelsProvider
        .getModifiableProjectLibrariesModel();

    Library library = libraryTableModifiableModel.getLibraryByName(libraryName);
    if (null == library) {
        library = libraryTableModifiableModel.createLibrary(libraryName);
    }

    if (libraryTableModifiableModel instanceof LibrariesModifiableModel) {
        final ExistingLibraryEditor existingLibraryEditor = ((LibrariesModifiableModel) libraryTableModifiableModel)
            .getLibraryEditor(library);
        existingLibraryEditor.addJarDirectory(
            VfsUtil.getUrlForLibraryRoot(libraryDirRoot), true, OrderRootType.CLASSES
        );
    } else {
        final Library.ModifiableModel libraryModifiableModel = modifiableModelsProvider
            .getModifiableLibraryModel(library);
        libraryModifiableModel.addJarDirectory(VfsUtil.getUrlForLibraryRoot(libraryDirRoot), true);
    }
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:26,代码来源:OotbHybrisModuleDescriptor.java

示例3: findBuildFile

import com.intellij.openapi.vfs.VfsUtil; //导入依赖的package包/类
private AntBuildFileBase findBuildFile(final File dir) {
    final File buildxml = new File(dir, HybrisConstants.ANT_BUILD_XML);
    if (!buildxml.exists()) {
        return null;
    }

    final VirtualFile buildFile = VfsUtil.findFileByIoFile(buildxml, true);
    if (buildFile == null) {
        return null;
    }

    final AntBuildFile antBuildFile;
    try {
        antBuildFile = antConfiguration.addBuildFile(buildFile);
    } catch (AntNoFileException e) {
        return null;
    }

    if (antBuildFile instanceof AntBuildFileBase) {
        return (AntBuildFileBase) antBuildFile;
    }
    return null;
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:24,代码来源:DefaultAntConfigurator.java

示例4: getSourceCodeRoot

import com.intellij.openapi.vfs.VfsUtil; //导入依赖的package包/类
@Nullable
private VirtualFile getSourceCodeRoot(final @NotNull HybrisModuleDescriptor moduleDescriptor) {
    final VirtualFile sourceCodeRoot;
    final File sourceCodeFile = moduleDescriptor.getRootProjectDescriptor().getSourceCodeFile();

    if (null != sourceCodeFile) {
        final VirtualFile sourceVFile = VfsUtil.findFileByIoFile(sourceCodeFile, true);
        if (null == sourceVFile) {
            sourceCodeRoot = null;
        } else if (sourceVFile.isDirectory()) {
            sourceCodeRoot = sourceVFile;
        } else {
            sourceCodeRoot = JarFileSystem.getInstance().getJarRootForLocalFile(sourceVFile);
        }
    } else {
        sourceCodeRoot = null;
    }

    return sourceCodeRoot;
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:21,代码来源:DefaultLibRootsConfigurator.java

示例5: configureBackOfficeRoots

import com.intellij.openapi.vfs.VfsUtil; //导入依赖的package包/类
protected void configureBackOfficeRoots(
    @NotNull final HybrisModuleDescriptor moduleDescriptor,
    @NotNull final ContentEntry contentEntry
) {
    Validate.notNull(moduleDescriptor);
    Validate.notNull(contentEntry);

    final File backOfficeModuleDirectory = new File(
        moduleDescriptor.getRootDirectory(), BACK_OFFICE_MODULE_DIRECTORY
    );

    final File backOfficeSrcDirectory = new File(backOfficeModuleDirectory, SRC_DIRECTORY);
    contentEntry.addSourceFolder(
        VfsUtil.pathToUrl(backOfficeSrcDirectory.getAbsolutePath()),
        JavaSourceRootType.SOURCE
    );

    addTestSourceRoots(contentEntry, backOfficeModuleDirectory);

    final File hmcResourcesDirectory = new File(backOfficeModuleDirectory, RESOURCES_DIRECTORY);
    contentEntry.addSourceFolder(
        VfsUtil.pathToUrl(hmcResourcesDirectory.getAbsolutePath()),
        JavaResourceRootType.RESOURCE
    );
    excludeDirectory(contentEntry, new File(backOfficeModuleDirectory, CLASSES_DIRECTORY));
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:27,代码来源:RegularContentRootConfigurator.java

示例6: configurePlatformRoots

import com.intellij.openapi.vfs.VfsUtil; //导入依赖的package包/类
protected void configurePlatformRoots(
    @NotNull final HybrisModuleDescriptor moduleDescriptor,
    @NotNull final ContentEntry contentEntry
) {
    Validate.notNull(moduleDescriptor);
    Validate.notNull(contentEntry);

    if (!HybrisConstants.PLATFORM_EXTENSION_NAME.equalsIgnoreCase(moduleDescriptor.getName())) {
        return;
    }
    final File rootDirectory = moduleDescriptor.getRootDirectory();
    final File platformBootstrapDirectory = new File(rootDirectory, PLATFORM_BOOTSTRAP_DIRECTORY);

    if (!moduleDescriptor.getRootProjectDescriptor().isImportOotbModulesInReadOnlyMode()) {

        final File platformBootstrapResourcesDirectory = new File(platformBootstrapDirectory, RESOURCES_DIRECTORY);
        contentEntry.addSourceFolder(
            VfsUtil.pathToUrl(platformBootstrapResourcesDirectory.getAbsolutePath()),
            JavaResourceRootType.RESOURCE
        );
    }

    excludeDirectory(contentEntry, new File(platformBootstrapDirectory, PLATFORM_MODEL_CLASSES_DIRECTORY));
    excludeDirectory(contentEntry, new File(rootDirectory, PLATFORM_TOMCAT_DIRECTORY));
    contentEntry.addExcludePattern("apache-ant-*");
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:27,代码来源:RegularContentRootConfigurator.java

示例7: configureAdditionalRoots

import com.intellij.openapi.vfs.VfsUtil; //导入依赖的package包/类
protected void configureAdditionalRoots(
    @NotNull final HybrisModuleDescriptor moduleDescriptor,
    @NotNull final String directoryName,
    @NotNull final ContentEntry contentEntry,
    @NotNull final File parentDirectory
) {
    Validate.notNull(moduleDescriptor);
    Validate.notNull(directoryName);
    Validate.notNull(contentEntry);
    Validate.notNull(parentDirectory);

    final File additionalModuleDirectory = new File(parentDirectory, directoryName);
    if (!additionalModuleDirectory.exists() || additionalModuleDirectory.isFile()) {
        return;
    }

    final File additionalClassesDirectory = new File(additionalModuleDirectory, CLASSES_DIRECTORY);
    contentEntry.addExcludeFolder(
        VfsUtil.pathToUrl(additionalClassesDirectory.getAbsolutePath())
    );
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:22,代码来源:ReadOnlyContentRootConfigurator.java

示例8: configureBackOfficeRoots

import com.intellij.openapi.vfs.VfsUtil; //导入依赖的package包/类
protected void configureBackOfficeRoots(
    @NotNull final HybrisModuleDescriptor moduleDescriptor,
    @NotNull final ContentEntry contentEntry
) {
    Validate.notNull(moduleDescriptor);
    Validate.notNull(contentEntry);

    final File backOfficeModuleDirectory = new File(
        moduleDescriptor.getRootDirectory(), BACK_OFFICE_MODULE_DIRECTORY
    );

    final File hmcClassesDirectory = new File(backOfficeModuleDirectory, CLASSES_DIRECTORY);
    contentEntry.addExcludeFolder(
        VfsUtil.pathToUrl(hmcClassesDirectory.getAbsolutePath())
    );
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:17,代码来源:ReadOnlyContentRootConfigurator.java

示例9: configureWebModuleRoots

import com.intellij.openapi.vfs.VfsUtil; //导入依赖的package包/类
protected void configureWebModuleRoots(
    @NotNull final HybrisModuleDescriptor moduleDescriptor,
    final @NotNull ContentEntry contentEntry,
    final File webModuleDirectory
) {
    Validate.notNull(moduleDescriptor);

    final File webAddonSrcDirectory = new File(webModuleDirectory, ADDON_SRC_DIRECTORY);
    contentEntry.addExcludeFolder(
        VfsUtil.pathToUrl(webAddonSrcDirectory.getAbsolutePath())
    );

    final File webTestClassesDirectory = new File(webModuleDirectory, TEST_CLASSES_DIRECTORY);
    contentEntry.addExcludeFolder(
        VfsUtil.pathToUrl(webTestClassesDirectory.getAbsolutePath())
    );

    final File commonWebSrcDirectory = new File(webModuleDirectory, COMMON_WEB_SRC_DIRECTORY);
    contentEntry.addExcludeFolder(
        VfsUtil.pathToUrl(commonWebSrcDirectory.getAbsolutePath())
    );
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:23,代码来源:ReadOnlyContentRootConfigurator.java

示例10: doQuickImport

import com.intellij.openapi.vfs.VfsUtil; //导入依赖的package包/类
@Override
public boolean doQuickImport(final VirtualFile file, final WizardContext wizardContext) {
    this.getBuilder().cleanup();
    this.getBuilder().setRootProjectDirectory(VfsUtil.virtualToIoFile(file.getParent()));

    final List<HybrisModuleDescriptor> projects = this.getBuilder().getList();
    if (null == projects || 1 != projects.size()) {
        return false;
    }

    try {
        this.getBuilder().setList(projects);
    } catch (ConfigurationException e) {
        LOG.error(e);
    }

    wizardContext.setProjectName(projects.get(0).getName());

    return true;
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:21,代码来源:HybrisProjectOpenProcessor.java

示例11: createModule

import com.intellij.openapi.vfs.VfsUtil; //导入依赖的package包/类
@NotNull
@Override
public Module createModule(@NotNull ModifiableModuleModel moduleModel) throws InvalidDataException, IOException, ModuleWithNameAlreadyExists, JDOMException, ConfigurationException {
  Module module = super.createModule(moduleModel);
  Course course = myTask.getLesson().getCourse();
  String directory = getModuleFileDirectory();
  if (directory == null) {
    return module;
  }
  VirtualFile moduleDir = VfsUtil.findFileByIoFile(new File(directory), true);
  if (moduleDir == null) {
    return module;
  }
  VirtualFile src = moduleDir.findChild(EduNames.SRC);
  if (src == null) {
    return module;
  }
  createTask(module.getProject(), course, src);
  ModuleRootModificationUtil.addDependency(module, myUtilModule);
  EduIntellijUtils.addJUnit(module);
  return module;
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:23,代码来源:EduTaskModuleBuilder.java

示例12: createChildFile

import com.intellij.openapi.vfs.VfsUtil; //导入依赖的package包/类
public static void createChildFile(@NotNull VirtualFile taskDir, @NotNull String name, @NotNull String text) throws IOException {
  String newDirectories = null;
  String fileName = name;
  VirtualFile dir = taskDir;
  if (name.contains("/")) {
    int pos = name.lastIndexOf("/");
    fileName = name.substring(pos + 1);
    newDirectories = name.substring(0, pos);
  }
  if (newDirectories != null) {
    dir = VfsUtil.createDirectoryIfMissing(taskDir, newDirectories);
  }
  if (dir != null) {
    VirtualFile virtualTaskFile = dir.findChild(fileName);
    if (virtualTaskFile == null) {
      virtualTaskFile = dir.createChildData(taskDir, fileName);
    }
    if (EduUtils.isImage(name)) {
      virtualTaskFile.setBinaryContent(Base64.decodeBase64(text));
    }
    else {
      VfsUtil.saveText(virtualTaskFile, text);
    }
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:26,代码来源:StudyGenerator.java

示例13: getTestsFile

import com.intellij.openapi.vfs.VfsUtil; //导入依赖的package包/类
@Nullable
@Override
protected VirtualFile getTestsFile() {
  VirtualFile taskDir = myTask.getTaskDir(myProject);
  if (taskDir == null) {
    return null;
  }
  for (String testFileName : myTask.getTestsText().keySet()) {
    VirtualFile testFile = VfsUtil.findRelativeFile(taskDir, testFileName);
    if (testFile != null) {
      return testFile;
    }
  }
  VirtualFile testsFile = taskDir.findChild(EduKotlinPluginConfigurator.LEGACY_TESTS_KT);
  if (testsFile != null) {
    return testsFile;
  }
  return taskDir.findChild(EduKotlinPluginConfigurator.TESTS_KT);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:20,代码来源:EduKotlinPyCharmTaskChecker.java

示例14: testAddingNewlyCreatedModuleToTheAggregator

import com.intellij.openapi.vfs.VfsUtil; //导入依赖的package包/类
public void testAddingNewlyCreatedModuleToTheAggregator() throws Exception {
  if (!hasMavenInstallation()) return;

  importProject("<groupId>test</groupId>" +
                "<artifactId>project</artifactId>" +
                "<version>1</version>");

  setModuleNameAndRoot("module", getProjectPath() + "/module");
  setAggregatorProject(myProjectPom);
  createNewModule(new MavenId("org.foo", "module", "1.0"));

  assertEquals(createPomXml("<groupId>test</groupId>" +
                            "<artifactId>project</artifactId>\n" +
                            "    <packaging>pom</packaging>\n" +
                            "    <version>1</version>\n" +
                            "    <modules>\n" +
                            "        <module>module</module>\n" +
                            "    </modules>\n"),
               StringUtil.convertLineSeparators(VfsUtil.loadText(myProjectPom)));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:MavenModuleBuilderTest.java

示例15: createContext

import com.intellij.openapi.vfs.VfsUtil; //导入依赖的package包/类
private static CvsContextAdapter createContext(final Collection<VirtualFile> createdCvsIgnoreFiles, final CvsContext context) {
  return new CvsContextAdapter() {
    @NotNull
    public VirtualFile[] getSelectedFiles() {
      return VfsUtil.toVirtualFileArray(createdCvsIgnoreFiles);
    }

    public Refreshable getRefreshableDialog() {
      return context.getRefreshableDialog();
    }

    public Project getProject() {
      return context.getProject();
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:IgnoreFileAction.java


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