Search in sources :

Example 16 with ProjectManagerEx

use of com.intellij.openapi.project.ex.ProjectManagerEx in project android by JetBrains.

the class NewProjectSetup method openProject.

@NotNull
Project openProject(@NotNull String projectPath) throws IOException {
    ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
    Project newProject = projectManager.loadProject(projectPath);
    if (newProject == null) {
        throw new NullPointerException("Failed to open project at '" + projectPath + "'");
    }
    return newProject;
}
Also used : Project(com.intellij.openapi.project.Project) ProjectManagerEx(com.intellij.openapi.project.ex.ProjectManagerEx) NotNull(org.jetbrains.annotations.NotNull)

Example 17 with ProjectManagerEx

use of com.intellij.openapi.project.ex.ProjectManagerEx in project android by JetBrains.

the class AndroidGradleTestCase method tearDown.

@Override
protected void tearDown() throws Exception {
    myModules = null;
    try {
        Messages.setTestDialog(TestDialog.DEFAULT);
        if (myFixture != null) {
            try {
                Project project = myFixture.getProject();
                // that here, otherwise the testsuite will leak
                if (AndroidProjectInfo.getInstance(project).requiresAndroidModel()) {
                    AndroidGradleProjectComponent projectComponent = AndroidGradleProjectComponent.getInstance(project);
                    projectComponent.projectClosed();
                }
            } finally {
                try {
                    myFixture.tearDown();
                } catch (Exception e) {
                    LOG.warn("Failed to tear down " + myFixture.getClass().getSimpleName(), e);
                }
                myFixture = null;
            }
        }
        GradleProjectImporter.ourSkipSetupFromTest = false;
        ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
        Project[] openProjects = projectManager.getOpenProjects();
        if (openProjects.length > 0) {
            PlatformTestCase.closeAndDisposeProjectAndCheckThatNoOpenProjects(openProjects[0]);
        }
    } finally {
        try {
            assertEquals(0, ProjectManager.getInstance().getOpenProjects().length);
        } finally {
            //noinspection ThrowFromFinallyBlock
            super.tearDown();
        }
    }
}
Also used : AndroidGradleProjectComponent(com.android.tools.idea.gradle.project.AndroidGradleProjectComponent) Projects.isLegacyIdeaAndroidProject(com.android.tools.idea.gradle.util.Projects.isLegacyIdeaAndroidProject) Project(com.intellij.openapi.project.Project) ProjectManagerEx(com.intellij.openapi.project.ex.ProjectManagerEx) ConfigurationException(com.intellij.openapi.options.ConfigurationException) IOException(java.io.IOException)

Example 18 with ProjectManagerEx

use of com.intellij.openapi.project.ex.ProjectManagerEx in project android by JetBrains.

the class GradleModuleImportTest method tearDown.

/**
   * {@link ProjectManagerEx}
   */
@Override
protected void tearDown() throws Exception {
    try {
        if (myFixture != null) {
            myFixture.tearDown();
            myFixture = null;
        }
        ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
        Project[] openProjects = projectManager.getOpenProjects();
        if (openProjects.length > 0) {
            final Project project = openProjects[0];
            ApplicationManager.getApplication().runWriteAction(new Runnable() {

                @Override
                public void run() {
                    Disposer.dispose(project);
                    ProjectManagerEx projectManager = ProjectManagerEx.getInstanceEx();
                    if (projectManager instanceof ProjectManagerImpl) {
                        Collection<Project> projectsStillOpen = projectManager.closeTestProject(project);
                        if (!projectsStillOpen.isEmpty()) {
                            Project project = projectsStillOpen.iterator().next();
                            projectsStillOpen.clear();
                            throw new AssertionError("Test project is not disposed: " + project + ";\n created in: " + PlatformTestCase.getCreationPlace(project));
                        }
                    }
                }
            });
        }
        if (dir != null && dir.isDirectory()) {
            ApplicationManager.getApplication().runWriteAction(new ThrowableComputable<Boolean, IOException>() {

                @Override
                public Boolean compute() throws IOException {
                    VirtualFile vfile = findFileByIoFile(dir, true);
                    if (vfile != null) {
                        vfile.delete(GradleModuleImportTest.this);
                    }
                    return true;
                }
            });
        }
    } finally {
        super.tearDown();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) IOException(java.io.IOException) ProjectManagerEx(com.intellij.openapi.project.ex.ProjectManagerEx) ProjectManagerImpl(com.intellij.openapi.project.impl.ProjectManagerImpl)

Aggregations

ProjectManagerEx (com.intellij.openapi.project.ex.ProjectManagerEx)18 Project (com.intellij.openapi.project.Project)17 File (java.io.File)9 VirtualFile (com.intellij.openapi.vfs.VirtualFile)8 IOException (java.io.IOException)6 ProjectManagerImpl (com.intellij.openapi.project.impl.ProjectManagerImpl)3 ProjectBuilder (com.intellij.ide.util.projectWizard.ProjectBuilder)2 Module (com.intellij.openapi.module.Module)2 NotNull (org.jetbrains.annotations.NotNull)2 Nullable (org.jetbrains.annotations.Nullable)2 GradleBuildFile (com.android.tools.idea.gradle.parser.GradleBuildFile)1 AndroidGradleProjectComponent (com.android.tools.idea.gradle.project.AndroidGradleProjectComponent)1 GradleUtil.getGradleBuildFile (com.android.tools.idea.gradle.util.GradleUtil.getGradleBuildFile)1 Projects.canImportAsGradleProject (com.android.tools.idea.gradle.util.Projects.canImportAsGradleProject)1 Projects.isLegacyIdeaAndroidProject (com.android.tools.idea.gradle.util.Projects.isLegacyIdeaAndroidProject)1 Document (com.intellij.openapi.editor.Document)1 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)1 FileDocumentManagerImpl (com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl)1 FileTypeManagerImpl (com.intellij.openapi.fileTypes.impl.FileTypeManagerImpl)1 ConfigurationException (com.intellij.openapi.options.ConfigurationException)1