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