Search in sources :

Example 1 with ProjectManager

use of com.intellij.openapi.project.ProjectManager in project intellij-code-outline by sitano.

the class CodeOutlinePlugin method addProjectListener.

private void addProjectListener() {
    ProjectManager pm = ProjectManager.getInstance();
    pm.addProjectManagerListener(new ProjectManagerAdapter() {

        public void projectOpened(Project project) {
            regForProject(project);
        }

        public void projectClosed(Project project) {
            unregForProject(project);
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) ProjectManagerAdapter(com.intellij.openapi.project.ProjectManagerAdapter) ProjectManager(com.intellij.openapi.project.ProjectManager)

Example 2 with ProjectManager

use of com.intellij.openapi.project.ProjectManager in project intellij-code-outline by sitano.

the class CodeOutlinePlugin method createForOpenProjects.

private void createForOpenProjects() {
    ProjectManager pm = ProjectManager.getInstance();
    Project[] projects = pm.getOpenProjects();
    for (Project project : projects) {
        regForProject(project);
    }
}
Also used : Project(com.intellij.openapi.project.Project) ProjectManager(com.intellij.openapi.project.ProjectManager)

Example 3 with ProjectManager

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

the class CompilerTask method run.

@Override
public void run(@NotNull final ProgressIndicator indicator) {
    myIndicator = indicator;
    final ProjectManager projectManager = ProjectManager.getInstance();
    projectManager.addProjectManagerListener(myProject, myCloseListener = new CloseListener());
    final Semaphore semaphore = ((CompilerManagerImpl) CompilerManager.getInstance(myProject)).getCompilationSemaphore();
    boolean acquired = false;
    try {
        try {
            while (!acquired) {
                acquired = semaphore.tryAcquire(300, TimeUnit.MILLISECONDS);
                if (!acquired && !myWaitForPreviousSession) {
                    return;
                }
                if (indicator.isCanceled()) {
                    // let compile work begin in order to stop gracefuly on cancel event
                    break;
                }
            }
        } catch (InterruptedException ignored) {
        }
        if (!isHeadless()) {
            addIndicatorDelegate();
        }
        myCompileWork.run();
    } catch (ProcessCanceledException ignored) {
    } finally {
        try {
            indicator.stop();
            projectManager.removeProjectManagerListener(myProject, myCloseListener);
        } finally {
            if (acquired) {
                semaphore.release();
            }
        }
    }
}
Also used : CompilerManagerImpl(com.intellij.compiler.CompilerManagerImpl) Semaphore(java.util.concurrent.Semaphore) ProjectManager(com.intellij.openapi.project.ProjectManager) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 4 with ProjectManager

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

the class ModuleLoadingStressTest method testContentEntryExchange.

public void testContentEntryExchange() throws Exception {
    String path = myProject.getBasePath();
    int count = 100;
    for (int i = 0; i < count; i++) {
        String name = "module" + i;
        File folder = new File(path, name);
        createModule(name, folder, path);
        String inner = "inner" + i;
        createModule(inner, new File(folder, inner), path);
    }
    ApplicationManagerEx.getApplicationEx().doNotSave(false);
    myProject.save();
    String projectFilePath = myProject.getProjectFilePath();
    String moduleName = myModule.getName();
    ProjectManager manager = ProjectManager.getInstance();
    manager.closeProject(myProject);
    ApplicationManager.getApplication().runWriteAction(() -> Disposer.dispose(myProject));
    myProject = manager.loadAndOpenProject(projectFilePath);
    Module[] modules = ModuleManager.getInstance(myProject).getModules();
    assertEquals(count * 2 + 1, modules.length);
    for (Module module : modules) {
        if (moduleName.equals(module.getName()))
            continue;
        VirtualFile root = ModuleRootManager.getInstance(module).getContentRoots()[0];
        assertEquals(module.getName(), root.getName());
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Module(com.intellij.openapi.module.Module) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) ProjectManager(com.intellij.openapi.project.ProjectManager)

Example 5 with ProjectManager

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

the class ApplicationImpl method saveAll.

@Override
public void saveAll() {
    if (myDoNotSave)
        return;
    FileDocumentManager.getInstance().saveAllDocuments();
    ProjectManager projectManager = ProjectManager.getInstance();
    if (projectManager instanceof ProjectManagerEx) {
        ((ProjectManagerEx) projectManager).flushChangedProjectFileAlarm();
    }
    Project[] openProjects = projectManager.getOpenProjects();
    for (Project openProject : openProjects) {
        openProject.save();
    }
    saveSettings();
}
Also used : Project(com.intellij.openapi.project.Project) ProjectManagerEx(com.intellij.openapi.project.ex.ProjectManagerEx) ProjectManager(com.intellij.openapi.project.ProjectManager)

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