Package com.intellij.openapi.roots

Examples of com.intellij.openapi.roots.ProjectRootManager


    public void setJdk(final String pPomUrl, final ProjectJdk pJdk) {
        if (!isRegistered(pPomUrl))
            return;

        final ProjectRootManager rootMgr = ProjectRootManager.getInstance(project);
        final ProjectJdk defJdk = rootMgr.getProjectJdk();

        final ProjectJdk oldJdk = getJdk(pPomUrl);
        if (pJdk == null || pJdk.equals(defJdk))
            put(KEY, pPomUrl, null);
        else
View Full Code Here


        VirtualFile[] contentRoots = rootManager.getContentRoots();
        return lookupFilesForName(contentRoots, name);
    }

    public static VirtualFile[] lookupFilesForName(Module module, String name) {
        ProjectRootManager rootManager = ProjectRootManager.getInstance(module.getProject());
        VirtualFile[] contentRoots = rootManager.getContentRoots();
        return lookupFilesForName(contentRoots, name);
    }
View Full Code Here

  }


  public static VirtualFile[] getModulesSourceRoots(@NotNull final DataContext dataContext) {
    final Project project = getProject(dataContext);
    final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(project);

    return projectRootManager.getContentSourceRoots();
  }
View Full Code Here

  }*/


  @Nullable
  public static Module getModuleForFile(@NotNull final VirtualFile virtualFile, final Project project) {
    final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(project);
    final ProjectFileIndex projectFileIndex = projectRootManager.getFileIndex();

    return projectFileIndex.getModuleForFile(virtualFile);
  }
View Full Code Here

  }


  @Nullable
  public static String getFirstProjectRootPath(final Project project) {
    final ProjectRootManager projectManager = ProjectRootManager.getInstance(project);
    final VirtualFile rootFiles[] = projectManager.getContentRoots();
    if (rootFiles.length == 0) {
      return null;
    }
    return rootFiles[0].getPath();
  }
View Full Code Here

        if (!currentFileExtension.equals("awl") && !currentFileExtension.equals("htm")) {
            return;
        }

        Editor editor = (Editor)event.getDataContext().getData(DataConstants.EDITOR);
        ProjectRootManager rootManager = ProjectRootManager.getInstance(project);
        Document document = editor.getDocument();
        CaretModel caret = editor.getCaretModel();

        String componentName = findComponentName(document, caret.getOffset());
        if (componentName == null) {
            showError("cannot figure out component name", project);
        }
        else {
            String javaFileName = componentName + ".java";
            String awlFileName = componentName + ".awl";

            // find components
            Vector components = new Vector();
            VirtualFile[] rootDirectories = rootManager.
                                            getRootFiles(ProjectRootType.SOURCE);
            for (int index = 0; index < rootDirectories.length; index ++) {
                findJavaFileWithName(javaFileName, awlFileName,
                                    rootDirectories[index], components);
            }
View Full Code Here

            e.printStackTrace();
        }
    }

    public static VirtualFile[] lookupFilesForName(Project project, String name) {
        ProjectRootManager rootManager = ProjectRootManager.getInstance(project);
        VirtualFile[] contentRoots = rootManager.getContentRoots();
        return lookupFilesForName(contentRoots, name);
    }
View Full Code Here

                                                  @NotNull VirtualFile sourceFile,
                                                  @Nullable String targetFile,
                                                  @Nullable String targetPackage,
                                                  boolean returnRoot) {
    boolean hasPackage = StringUtil.isNotEmpty(targetPackage);
    ProjectRootManager rootManager = ProjectRootManager.getInstance(project);
    ProjectFileIndex fileIndex = ProjectFileIndex.SERVICE.getInstance(project);
    Collection<VirtualFile> files = targetFile == null ? Collections.<VirtualFile>emptyList() :
                                    FilenameIndex.getVirtualFilesByName(project, targetFile,
                                                                        ProjectScope.getAllScope(project));

    VirtualFile existingFile = null;
    for (VirtualFile file : files) {
      String existingFilePackage = fileIndex.getPackageNameByDirectory(file.getParent());
      if (!hasPackage || existingFilePackage == null || targetPackage.equals(existingFilePackage)) {
        existingFile = file;
        break;
      }
    }

    VirtualFile existingFileRoot =
      existingFile == null ? null :
      fileIndex.isInSourceContent(existingFile) ? fileIndex.getSourceRootForFile(existingFile) :
      fileIndex.isInContent(existingFile) ? fileIndex.getContentRootForFile(existingFile) : null;

    VirtualFile[] sourceRoots = rootManager.getContentSourceRoots();
    VirtualFile[] contentRoots = rootManager.getContentRoots();
    final VirtualFile virtualRoot = existingFileRoot != null ? existingFileRoot :
                                    hasPackage && fileIndex.isInSource(sourceFile) ? fileIndex.getSourceRootForFile(sourceFile) :
                                    fileIndex.isInContent(sourceFile) ? fileIndex.getContentRootForFile(sourceFile) :
                                    getFirstElement(hasPackage && sourceRoots.length > 0? sourceRoots : contentRoots);
    if (virtualRoot == null) {
View Full Code Here

        {
            return null;
        }

        Project project = psiElement.getProject();
        ProjectRootManager projectRootManager = ProjectRootManager.getInstance( project );
        boolean includeTestClasses = projectRootManager.getFileIndex().isInTestSourceContent( classVirtualFile );
        return module.getModuleWithDependenciesAndLibrariesScope( includeTestClasses );
    }
View Full Code Here

          throw new RuntimeException(e);
        }
      }
    });

    ProjectRootManager rootManager = ProjectRootManager.getInstance(getProject());
    myContentRoot = rootManager.getContentRoots()[0];
    mySourceRoot = rootManager.getContentSourceRoots()[0];

    VFSUtil._setProject(getProject());
  }
View Full Code Here

TOP

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

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.