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;
}
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;
}
}
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();
}
}
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);
}
}
}
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;
}
Aggregations