Search in sources :

Example 11 with ProjectManager

use of com.intellij.openapi.project.ProjectManager in project ideavim by JetBrains.

the class VimPlugin method showMessage.

public static void showMessage(@Nullable String msg) {
    ProjectManager pm = ProjectManager.getInstance();
    Project[] projects = pm.getOpenProjects();
    for (Project project : projects) {
        StatusBar bar = WindowManager.getInstance().getStatusBar(project);
        if (bar != null) {
            if (msg == null || msg.length() == 0) {
                bar.setInfo("");
            } else {
                bar.setInfo("VIM - " + msg);
            }
        }
    }
}
Also used : Project(com.intellij.openapi.project.Project) StatusBar(com.intellij.openapi.wm.StatusBar) ProjectManager(com.intellij.openapi.project.ProjectManager)

Example 12 with ProjectManager

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

the class DefaultProjectLocator method getProjectsForFile.

@NotNull
@Override
public Collection<Project> getProjectsForFile(VirtualFile file) {
    final ProjectManager projectManager = ProjectManager.getInstance();
    if (projectManager == null || file == null) {
        return new HashSet<>();
    }
    final Project[] openProjects = projectManager.getOpenProjects();
    return Arrays.asList(openProjects);
}
Also used : Project(com.intellij.openapi.project.Project) ProjectManager(com.intellij.openapi.project.ProjectManager) HashSet(com.intellij.util.containers.HashSet) NotNull(org.jetbrains.annotations.NotNull)

Example 13 with ProjectManager

use of com.intellij.openapi.project.ProjectManager in project android by JetBrains.

the class IdeSdks method setJdkPath.

// Must run inside a WriteAction
public void setJdkPath(@NotNull File path) {
    if (checkForJdk(path)) {
        ApplicationManager.getApplication().assertWriteAccessAllowed();
        File canonicalPath = resolvePath(path);
        Sdk chosenJdk = null;
        if (myIdeInfo.isAndroidStudio()) {
            // Delete all JDKs in Android Studio. We want to have only one.
            List<Sdk> jdks = ProjectJdkTable.getInstance().getSdksOfType(JavaSdk.getInstance());
            for (final Sdk jdk : jdks) {
                ProjectJdkTable.getInstance().removeJdk(jdk);
            }
        } else {
            for (Sdk jdk : ProjectJdkTable.getInstance().getSdksOfType(JavaSdk.getInstance())) {
                if (pathsEqual(jdk.getHomePath(), canonicalPath.getPath())) {
                    chosenJdk = jdk;
                    break;
                }
            }
        }
        if (chosenJdk == null) {
            if (canonicalPath.isDirectory()) {
                chosenJdk = createJdk(canonicalPath);
                if (chosenJdk == null) {
                    // Unlikely to happen
                    throw new IllegalStateException("Failed to create IDEA JDK from '" + path.getPath() + "'");
                }
                updateAndroidSdks(chosenJdk);
                ProjectManager projectManager = ApplicationManager.getApplication().getComponent(ProjectManager.class);
                Project[] openProjects = projectManager.getOpenProjects();
                for (Project project : openProjects) {
                    applyJdkToProject(project, chosenJdk);
                }
            } else {
                throw new IllegalStateException("The resolved path '" + canonicalPath.getPath() + "' was not found");
            }
        }
    }
}
Also used : NewProjectUtil.applyJdkToProject(com.intellij.ide.impl.NewProjectUtil.applyJdkToProject) Project(com.intellij.openapi.project.Project) SdkPaths.validateAndroidSdk(com.android.tools.idea.sdk.SdkPaths.validateAndroidSdk) File(java.io.File) ProjectManager(com.intellij.openapi.project.ProjectManager)

Example 14 with ProjectManager

use of com.intellij.openapi.project.ProjectManager in project android by JetBrains.

the class NewProjects method createProject.

@NotNull
public static Project createProject(@NotNull String projectName, @NotNull String projectPath) throws ConfigurationException {
    ProjectManager projectManager = ProjectManager.getInstance();
    Project newProject = projectManager.createProject(projectName, projectPath);
    if (newProject == null) {
        throw new NullPointerException("Failed to create a new IDEA project");
    }
    return newProject;
}
Also used : Project(com.intellij.openapi.project.Project) ProjectManager(com.intellij.openapi.project.ProjectManager) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

ProjectManager (com.intellij.openapi.project.ProjectManager)14 Project (com.intellij.openapi.project.Project)11 NotNull (org.jetbrains.annotations.NotNull)3 NewProjectUtil.applyJdkToProject (com.intellij.ide.impl.NewProjectUtil.applyJdkToProject)2 File (java.io.File)2 Nullable (org.jetbrains.annotations.Nullable)2 SdkPaths.validateAndroidSdk (com.android.tools.idea.sdk.SdkPaths.validateAndroidSdk)1 CompilerManagerImpl (com.intellij.compiler.CompilerManagerImpl)1 DocumentReferenceManagerImpl (com.intellij.openapi.command.impl.DocumentReferenceManagerImpl)1 UndoManagerImpl (com.intellij.openapi.command.impl.UndoManagerImpl)1 Module (com.intellij.openapi.module.Module)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 ProjectManagerAdapter (com.intellij.openapi.project.ProjectManagerAdapter)1 ProjectManagerEx (com.intellij.openapi.project.ex.ProjectManagerEx)1 ProjectManagerImpl (com.intellij.openapi.project.impl.ProjectManagerImpl)1 Ref (com.intellij.openapi.util.Ref)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 LocalFileSystemImpl (com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl)1 IdeFrame (com.intellij.openapi.wm.IdeFrame)1 StatusBar (com.intellij.openapi.wm.StatusBar)1