Search in sources :

Example 1 with AppLifecycleListener

use of com.intellij.ide.AppLifecycleListener in project android by JetBrains.

the class GradleSpecificInitializer method checkInstallPath.

/**
   * Gradle has an issue when the studio path contains ! (http://b.android.com/184588)
   */
private static void checkInstallPath() {
    if (PathManager.getHomePath().contains("!")) {
        final Application app = ApplicationManager.getApplication();
        app.getMessageBus().connect(app).subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {

            @Override
            public void appStarting(Project project) {
                app.invokeLater(() -> {
                    String message = String.format("%1$s must not be installed in a path containing '!' or Gradle sync will fail!", ApplicationNamesInfo.getInstance().getProductName());
                    Notification notification = getNotificationGroup().createNotification(message, NotificationType.ERROR);
                    notification.setImportant(true);
                    Notifications.Bus.notify(notification);
                });
            }
        });
    }
}
Also used : Project(com.intellij.openapi.project.Project) AppLifecycleListener(com.intellij.ide.AppLifecycleListener) Application(com.intellij.openapi.application.Application)

Example 2 with AppLifecycleListener

use of com.intellij.ide.AppLifecycleListener in project android by JetBrains.

the class GradleSpecificInitializer method addStartupWarning.

private static void addStartupWarning(@NotNull final String message, @Nullable final NotificationListener listener) {
    final Application app = ApplicationManager.getApplication();
    app.getMessageBus().connect(app).subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {

        @Override
        public void appStarting(Project project) {
            app.invokeLater(() -> {
                Notification notification = getNotificationGroup().createNotification("SDK Validation", message, NotificationType.WARNING, listener);
                notification.setImportant(true);
                Notifications.Bus.notify(notification);
            });
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) AppLifecycleListener(com.intellij.ide.AppLifecycleListener) Application(com.intellij.openapi.application.Application)

Example 3 with AppLifecycleListener

use of com.intellij.ide.AppLifecycleListener in project android by JetBrains.

the class GradleSpecificInitializer method registerAppClosing.

// Registers a callback that gets notified when the IDE is closing.
private static void registerAppClosing() {
    Application app = ApplicationManager.getApplication();
    MessageBusConnection connection = app.getMessageBus().connect(app);
    connection.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {

        @Override
        public void appClosing() {
            try {
                DefaultGradleConnector.close();
            } catch (RuntimeException e) {
                LOG.info("Failed to stop Gradle daemons during IDE shutdown", e);
            }
        }
    });
}
Also used : MessageBusConnection(com.intellij.util.messages.MessageBusConnection) AppLifecycleListener(com.intellij.ide.AppLifecycleListener) Application(com.intellij.openapi.application.Application)

Example 4 with AppLifecycleListener

use of com.intellij.ide.AppLifecycleListener in project intellij-community by JetBrains.

the class ApplicationStatisticsPersistenceComponent method initComponent.

@Override
public void initComponent() {
    ApplicationManager.getApplication().getMessageBus().connect().subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {

        @Override
        public void appClosing() {
            persistOpenedProjects();
            persistOnClosing = false;
        }
    });
    ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() {

        @Override
        public void projectClosing(Project project) {
            if (persistOnClosing && project != null) {
                UsagesCollector.doPersistProjectUsages(project);
            }
        }
    });
    persistPeriodically();
}
Also used : Project(com.intellij.openapi.project.Project) ProjectManagerAdapter(com.intellij.openapi.project.ProjectManagerAdapter) AppLifecycleListener(com.intellij.ide.AppLifecycleListener)

Aggregations

AppLifecycleListener (com.intellij.ide.AppLifecycleListener)4 Application (com.intellij.openapi.application.Application)3 Project (com.intellij.openapi.project.Project)3 ProjectManagerAdapter (com.intellij.openapi.project.ProjectManagerAdapter)1 MessageBusConnection (com.intellij.util.messages.MessageBusConnection)1