Search in sources :

Example 6 with ProjectManager

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

the class NotificationsManagerImpl method notifyByBalloon.

@Nullable
private static Balloon notifyByBalloon(@NotNull final Notification notification, @NotNull final NotificationDisplayType displayType, @Nullable final Project project) {
    if (isDummyEnvironment())
        return null;
    Window window = findWindowForBalloon(project);
    if (window instanceof IdeFrame) {
        BalloonLayout layout = ((IdeFrame) window).getBalloonLayout();
        if (layout == null)
            return null;
        final ProjectManager projectManager = ProjectManager.getInstance();
        final boolean noProjects = projectManager.getOpenProjects().length == 0;
        final boolean sticky = NotificationDisplayType.STICKY_BALLOON == displayType || noProjects;
        Ref<BalloonLayoutData> layoutDataRef = new Ref<>();
        if (project == null || project.isDefault()) {
            BalloonLayoutData layoutData = new BalloonLayoutData();
            layoutData.groupId = "";
            layoutData.welcomeScreen = layout instanceof WelcomeBalloonLayoutImpl;
            layoutData.type = notification.getType();
            layoutDataRef.set(layoutData);
        } else {
            BalloonLayoutData.MergeInfo mergeData = ((BalloonLayoutImpl) layout).preMerge(notification);
            if (mergeData != null) {
                BalloonLayoutData layoutData = new BalloonLayoutData();
                layoutData.mergeData = mergeData;
                layoutDataRef.set(layoutData);
            }
        }
        final Balloon balloon = createBalloon((IdeFrame) window, notification, false, false, layoutDataRef, project != null ? project : ApplicationManager.getApplication());
        if (notification.isExpired()) {
            return null;
        }
        layout.add(balloon, layoutDataRef.get());
        if (balloon.isDisposed()) {
            return null;
        }
        if (layoutDataRef.get() != null) {
            layoutDataRef.get().project = project;
        }
        ((BalloonImpl) balloon).startFadeoutTimer(0);
        if (NotificationDisplayType.BALLOON == displayType) {
            FrameStateManager.getInstance().getApplicationActive().doWhenDone(() -> {
                if (!sticky && !balloon.isDisposed()) {
                    ((BalloonImpl) balloon).startSmartFadeoutTimer(10000);
                }
            });
        }
        return balloon;
    }
    return null;
}
Also used : IdeFrame(com.intellij.openapi.wm.IdeFrame) WelcomeBalloonLayoutImpl(com.intellij.openapi.wm.impl.welcomeScreen.WelcomeBalloonLayoutImpl) ProjectManager(com.intellij.openapi.project.ProjectManager) Ref(com.intellij.openapi.util.Ref) WelcomeBalloonLayoutImpl(com.intellij.openapi.wm.impl.welcomeScreen.WelcomeBalloonLayoutImpl) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with ProjectManager

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

the class DefaultProjectLocator method guessProjectForFile.

@Nullable
public Project guessProjectForFile(final VirtualFile file) {
    ProjectManager projectManager = ProjectManager.getInstance();
    if (projectManager == null)
        return null;
    final Project[] projects = projectManager.getOpenProjects();
    if (projects.length == 1) {
        return !projects[0].isDisposed() ? projects[0] : null;
    } else {
        return null;
    }
}
Also used : Project(com.intellij.openapi.project.Project) ProjectManager(com.intellij.openapi.project.ProjectManager) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with ProjectManager

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

the class PlatformTestCase method cleanupApplicationCaches.

public static void cleanupApplicationCaches(Project project) {
    if (project != null && !project.isDisposed()) {
        UndoManagerImpl globalInstance = (UndoManagerImpl) UndoManager.getGlobalInstance();
        if (globalInstance != null) {
            globalInstance.dropHistoryInTests();
        }
        ((UndoManagerImpl) UndoManager.getInstance(project)).dropHistoryInTests();
        ((DocumentReferenceManagerImpl) DocumentReferenceManager.getInstance()).cleanupForNextTest();
        ((PsiManagerImpl) PsiManager.getInstance(project)).cleanupForNextTest();
    }
    final ProjectManager projectManager = ProjectManager.getInstance();
    assert projectManager != null : "The ProjectManager is not initialized yet";
    ProjectManagerImpl projectManagerImpl = (ProjectManagerImpl) projectManager;
    if (projectManagerImpl.isDefaultProjectInitialized()) {
        Project defaultProject = projectManager.getDefaultProject();
        ((PsiManagerImpl) PsiManager.getInstance(defaultProject)).cleanupForNextTest();
    }
    AsyncHighlighterUpdater.completeAsyncTasks();
    ((FileBasedIndexImpl) FileBasedIndex.getInstance()).cleanupForNextTest();
    LocalFileSystemImpl localFileSystem = (LocalFileSystemImpl) LocalFileSystem.getInstance();
    if (localFileSystem != null) {
        localFileSystem.cleanupForNextTest();
    }
}
Also used : UndoManagerImpl(com.intellij.openapi.command.impl.UndoManagerImpl) Project(com.intellij.openapi.project.Project) DocumentReferenceManagerImpl(com.intellij.openapi.command.impl.DocumentReferenceManagerImpl) PsiManagerImpl(com.intellij.psi.impl.PsiManagerImpl) FileBasedIndexImpl(com.intellij.util.indexing.FileBasedIndexImpl) LocalFileSystemImpl(com.intellij.openapi.vfs.impl.local.LocalFileSystemImpl) ProjectManager(com.intellij.openapi.project.ProjectManager) ProjectManagerImpl(com.intellij.openapi.project.impl.ProjectManagerImpl)

Example 9 with ProjectManager

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

the class IdeSdks method afterAndroidSdkPathUpdate.

private static void afterAndroidSdkPathUpdate(@NotNull File androidSdkPath) {
    ProjectManager projectManager = ApplicationManager.getApplication().getComponent(ProjectManager.class);
    Project[] openProjects = projectManager.getOpenProjects();
    if (openProjects.length == 0) {
        return;
    }
    AndroidSdkEventListener[] eventListeners = AndroidSdkEventListener.EP_NAME.getExtensions();
    for (Project project : openProjects) {
        if (!AndroidProjectInfo.getInstance(project).requiresAndroidModel()) {
            continue;
        }
        for (AndroidSdkEventListener listener : eventListeners) {
            listener.afterSdkPathChange(androidSdkPath, project);
        }
    }
}
Also used : NewProjectUtil.applyJdkToProject(com.intellij.ide.impl.NewProjectUtil.applyJdkToProject) Project(com.intellij.openapi.project.Project) ProjectManager(com.intellij.openapi.project.ProjectManager)

Example 10 with ProjectManager

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

the class NewProjectSetup method createProject.

@NotNull
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 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