Search in sources :

Example 11 with ProjectRootManager

use of com.intellij.openapi.roots.ProjectRootManager in project intellij-plugins by JetBrains.

the class VFSUtilTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    final File dir = createTempDirectory();
    updateRoots(new Updater() {

        @Override
        public void update(ModifiableRootModel modifiableModel) {
            myContentRoot = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(dir);
            try {
                VirtualFile src = myContentRoot.createChildDirectory(this, "src");
                myContentEntry = modifiableModel.addContentEntry(myContentRoot);
                myContentEntry.addSourceFolder(src, false);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    });
    ProjectRootManager rootManager = ProjectRootManager.getInstance(getProject());
    myContentRoot = rootManager.getContentRoots()[0];
    mySourceRoot = rootManager.getContentSourceRoots()[0];
    VFSUtil._setProject(getProject());
}
Also used : ModifiableRootModel(com.intellij.openapi.roots.ModifiableRootModel) VirtualFile(com.intellij.openapi.vfs.VirtualFile) IOException(java.io.IOException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) VFile(jetbrains.communicator.core.vfs.VFile) ProjectRootManager(com.intellij.openapi.roots.ProjectRootManager)

Example 12 with ProjectRootManager

use of com.intellij.openapi.roots.ProjectRootManager in project intellij-plugins by JetBrains.

the class FlexProjectConverter method preProcessingFinished.

@Override
public void preProcessingFinished() throws CannotConvertException {
    ComponentManagerSettings projectRootManagerSettings = myContext.getProjectRootManagerSettings();
    if (projectRootManagerSettings == null)
        return;
    Element projectRootManager = projectRootManagerSettings.getComponentElement(ProjectRootManager.class.getSimpleName());
    if (projectRootManager == null)
        return;
    getParams().projectSdkName = projectRootManager.getAttributeValue(ProjectRootManagerImpl.PROJECT_JDK_NAME_ATTR);
    ConversionParams.convertFlexSdks();
}
Also used : Element(org.jdom.Element) ProjectRootManager(com.intellij.openapi.roots.ProjectRootManager)

Example 13 with ProjectRootManager

use of com.intellij.openapi.roots.ProjectRootManager in project checkstyle-idea by jshiell.

the class ScanProject method actionPerformed.

@Override
public void actionPerformed(final AnActionEvent event) {
    try {
        final Project project = DataKeys.PROJECT.getData(event.getDataContext());
        if (project == null) {
            return;
        }
        final CheckStylePlugin checkStylePlugin = project.getComponent(CheckStylePlugin.class);
        if (checkStylePlugin == null) {
            throw new IllegalStateException("Couldn't get checkstyle plugin");
        }
        final ScanScope scope = checkStylePlugin.configurationManager().getCurrent().getScanScope();
        final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(CheckStyleToolWindowPanel.ID_TOOLWINDOW);
        toolWindow.activate(() -> {
            try {
                setProgressText(toolWindow, "plugin.status.in-progress.project");
                Runnable scanAction = null;
                if (scope == ScanScope.Everything) {
                    scanAction = new ScanEverythingAction(project, getSelectedOverride(toolWindow));
                } else {
                    final ProjectRootManager projectRootManager = ProjectRootManager.getInstance(project);
                    final VirtualFile[] sourceRoots = projectRootManager.getContentSourceRoots();
                    if (sourceRoots.length > 0) {
                        scanAction = new ScanSourceRootsAction(project, sourceRoots, getSelectedOverride(toolWindow));
                    }
                }
                if (scanAction != null) {
                    ApplicationManager.getApplication().runReadAction(scanAction);
                }
            } catch (Throwable e) {
                CheckStylePlugin.processErrorAndLog("Project scan", e);
            }
        });
    } catch (Throwable e) {
        CheckStylePlugin.processErrorAndLog("Project scan", e);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) ScanScope(org.infernus.idea.checkstyle.model.ScanScope) ToolWindow(com.intellij.openapi.wm.ToolWindow) ProjectRootManager(com.intellij.openapi.roots.ProjectRootManager) CheckStylePlugin(org.infernus.idea.checkstyle.CheckStylePlugin)

Example 14 with ProjectRootManager

use of com.intellij.openapi.roots.ProjectRootManager in project ideavim by JetBrains.

the class FileGroup method findFile.

@Nullable
public VirtualFile findFile(@NotNull String filename, @NotNull Project proj) {
    VirtualFile found = null;
    if (filename.length() > 2 && filename.charAt(0) == '~' && filename.charAt(1) == File.separatorChar) {
        String homefile = filename.substring(2);
        String dir = System.getProperty("user.home");
        if (logger.isDebugEnabled()) {
            logger.debug("home dir file");
            logger.debug("looking for " + homefile + " in " + dir);
        }
        found = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(dir, homefile));
    } else {
        if (proj == null) {
            return null;
        }
        ProjectRootManager prm = ProjectRootManager.getInstance(proj);
        VirtualFile[] roots = prm.getContentRoots();
        for (int i = 0; i < roots.length; i++) {
            if (logger.isDebugEnabled()) {
                logger.debug("root[" + i + "] = " + roots[i].getPath());
            }
            found = findFile(roots[i], filename);
            if (found != null) {
                break;
            }
        }
        if (found == null) {
            found = LocalFileSystem.getInstance().findFileByIoFile(new File(filename));
        }
    }
    return found;
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) ProjectRootManager(com.intellij.openapi.roots.ProjectRootManager) Nullable(org.jetbrains.annotations.Nullable)

Example 15 with ProjectRootManager

use of com.intellij.openapi.roots.ProjectRootManager in project intellij-community by JetBrains.

the class ThumbnailViewUI method findFiles.

private Set<VirtualFile> findFiles(VirtualFile file) {
    Set<VirtualFile> files = new HashSet<>(0);
    Project project = thumbnailView.getProject();
    if (!project.isDisposed()) {
        ProjectRootManager rootManager = ProjectRootManager.getInstance(project);
        boolean projectIgnored = rootManager.getFileIndex().isExcluded(file);
        if (!projectIgnored && !FileTypeManager.getInstance().isFileIgnored(file)) {
            ImageFileTypeManager typeManager = ImageFileTypeManager.getInstance();
            if (file.isDirectory()) {
                if (thumbnailView.isRecursive()) {
                    files.addAll(findFiles(file.getChildren()));
                } else if (isImagesInDirectory(file)) {
                    files.add(file);
                }
            } else if (typeManager.isImage(file)) {
                files.add(file);
            }
        }
    }
    return files;
}
Also used : Project(com.intellij.openapi.project.Project) ImageFileTypeManager(org.intellij.images.fileTypes.ImageFileTypeManager) ProjectRootManager(com.intellij.openapi.roots.ProjectRootManager) HashSet(java.util.HashSet)

Aggregations

ProjectRootManager (com.intellij.openapi.roots.ProjectRootManager)29 VirtualFile (com.intellij.openapi.vfs.VirtualFile)22 Project (com.intellij.openapi.project.Project)8 Module (com.intellij.openapi.module.Module)7 Sdk (com.intellij.openapi.projectRoots.Sdk)6 NotNull (org.jetbrains.annotations.NotNull)6 Nullable (org.jetbrains.annotations.Nullable)6 ModuleRootManager (com.intellij.openapi.roots.ModuleRootManager)4 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)4 File (java.io.File)4 IncorrectOperationException (com.intellij.util.IncorrectOperationException)3 ModifiableRootModel (com.intellij.openapi.roots.ModifiableRootModel)2 NullableComputable (com.intellij.openapi.util.NullableComputable)2 PsiDirectory (com.intellij.psi.PsiDirectory)2 PsiManager (com.intellij.psi.PsiManager)2 PackageWrapper (com.intellij.refactoring.PackageWrapper)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 CheckStylePlugin (org.infernus.idea.checkstyle.CheckStylePlugin)2 ScanScope (org.infernus.idea.checkstyle.model.ScanScope)2