Package com.intellij.openapi.roots

Examples of com.intellij.openapi.roots.ModuleRootManager


    final PsiClass activatorClass = PsiTreeUtil.getChildOfType(activatorClassFile, PsiClass.class);
    CommandProcessor.getInstance().executeCommand(myFixture.getProject(), new Runnable() {
      public void run() {
        ApplicationManager.getApplication().runWriteAction(new Runnable() {
          public void run() {
            ModuleRootManager rootManager = TestUtil.getModuleRootManager(myFixture.getProject(), "t1");
            JavaRefactoringFactory factory = JavaRefactoringFactory.getInstance(myFixture.getProject());
            MoveDestination moveDestination = factory.createSourceRootMoveDestination("tx", rootManager.getSourceRoots()[0]);
            factory.createMoveClassesOrPackages(new PsiElement[]{activatorClass}, moveDestination).run();
          }
        });
      }
    }, "test", "testid");
View Full Code Here


          libraryMappings.disassociateWithProject(libraryModel.getName());
        }
      }
      else {
        for (Module module : myModuleSelector.getSelectedModules()) {
          ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
          VirtualFile[] roots = moduleRootManager.getContentRoots();
          for (VirtualFile root : roots) {
            libraryMappings.associate(root, libraryModel.getName(), false);
            LOG.info("Library '" + libraryModel.getName() + "' has been associated with " + root);
          }
        }
View Full Code Here

    return result;
  }


  private static void findFileInModule(final Set<VirtualFile> found, Module module, VFile file) {
    ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
    findInRoots(found, rootManager.getSourceRoots(), file.getSourcePath());
    findInRoots(found, rootManager.getContentRoots(), file.getContentPath());
  }
View Full Code Here

      }
    });
  }

  public static PsiFile loadPsiFile(Project project, String moduleName, String filePathInSource) {
    final ModuleRootManager rootManager = getModuleRootManager(project, moduleName);
    final VirtualFile root = rootManager.getSourceRoots()[0];
    VirtualFile file = root.findFileByRelativePath(filePathInSource);
    assertNotNull(file);
    PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
    assertNotNull(psiFile);
    return psiFile;
View Full Code Here

    assertNotNull(psiFile);
    return psiFile;
  }

  public static PsiFile loadPsiFileUnderContent(Project project, String moduleName, String filePathInContent) {
    final ModuleRootManager rootManager = getModuleRootManager(project, moduleName);
    VirtualFile root = rootManager.getContentRoots()[0];
    VirtualFile file = root.findFileByRelativePath(filePathInContent);
    assertNotNull(file);
    PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
    assertNotNull(psiFile);
    return psiFile;
View Full Code Here

    public String[] getModuleSrc(String name) {
        Project project = getActiveProject();
        if (project != null) {
            Module module = ModuleManager.getInstance(project).findModuleByName(name);
            ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
            VirtualFile virtualFiles[] = moduleRootManager.getSourceRoots();
            String src[] = new String[virtualFiles.length];
            for (int count = 0; count < src.length; count++) {
                src[count] = virtualFiles[count].getPresentableUrl();
            }
            return src;
View Full Code Here

    protected void removeContentRoots() {
        new WriteCommandAction.Simple(myModule.getProject()) {
            @Override
            protected void run() throws Throwable {
                ModuleRootManager instance =
                    ModuleRootManager.getInstance(myModule);

                ModifiableRootModel modifiableModel = instance.getModifiableModel();

                ContentEntry[] entries = instance.getContentEntries();
                for (ContentEntry entry : entries) {
                    modifiableModel.removeContentEntry(entry);
                }
                modifiableModel.commit();
            }
View Full Code Here

    }

    @Override
    public void moduleCreated(@NotNull final Module module) {

        ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
        final VirtualFile sourceRoots[] = moduleRootManager.getSourceRoots();
        final String projectName = module.getProject().getName();
        GoProjectSettings.getInstance(module.getProject()).loadState(settings);

        try {
            Sdk sdk = GoSdkUtil.getGoogleGoSdkForProject(module.getProject());
View Full Code Here

  protected void addLibraryToRoots(final VirtualFile jarFile, OrderRootType rootType) {
    addLibraryToRoots(myModule, jarFile, rootType);
  }

  protected static void addLibraryToRoots(final Module module, final VirtualFile jarFile, final OrderRootType rootType) {
    final ModuleRootManager manager = ModuleRootManager.getInstance(module);
    final ModifiableRootModel rootModel = manager.getModifiableModel();
    final Library jarLibrary = rootModel.getModuleLibraryTable().createLibrary();
    final Library.ModifiableModel libraryModel = jarLibrary.getModifiableModel();
    libraryModel.addRoot(jarFile, rootType);
    libraryModel.commit();
    rootModel.commit();
View Full Code Here

    //final ProjectJdkEx jdk = ProjectJdkUtil.getDefaultJdk("java 1.4");
    final ProjectJdk jdk = getTestProjectJdk();
//    ProjectJdkImpl jdk = ProjectJdkTable.getInstance().addJdk(defaultJdk);
    Module[] modules = ModuleManager.getInstance(myProject).getModules();
    for (Module module : modules) {
      final ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
      ApplicationManager.getApplication().runWriteAction(new Runnable() {
        public void run() {
          final ModifiableRootModel rootModel = rootManager.getModifiableModel();
          rootModel.setJdk(jdk);
          rootModel.commit();
        }
      });
    }
View Full Code Here

TOP

Related Classes of com.intellij.openapi.roots.ModuleRootManager

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.