mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup — AppLifecycleListener — default method implementation
This commit is contained in:
@@ -162,7 +162,7 @@ public class DaemonListeners implements Disposable {
|
||||
if (project.isDefault()) return;
|
||||
MessageBusConnection connection = messageBus.connect(this);
|
||||
|
||||
connection.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
|
||||
connection.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
|
||||
@Override
|
||||
public void appClosing() {
|
||||
stopDaemon(false, "App closing");
|
||||
|
||||
@@ -29,49 +29,49 @@ import org.jetbrains.annotations.Nullable;
|
||||
public interface AppLifecycleListener {
|
||||
Topic<AppLifecycleListener> TOPIC = Topic.create("Application lifecycle notifications", AppLifecycleListener.class);
|
||||
|
||||
void appFrameCreated(final String[] commandLineArgs, @NotNull Ref<Boolean> willOpenProject);
|
||||
default void appFrameCreated(final String[] commandLineArgs, @NotNull Ref<Boolean> willOpenProject) {
|
||||
}
|
||||
|
||||
void appStarting(@Nullable Project projectFromCommandLine);
|
||||
default void appStarting(@Nullable Project projectFromCommandLine) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a project frame is closed.
|
||||
*/
|
||||
void projectFrameClosed();
|
||||
default void projectFrameClosed() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called if the project opening was cancelled or failed because of an error.
|
||||
*/
|
||||
void projectOpenFailed();
|
||||
default void projectOpenFailed() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the welcome screen is displayed.
|
||||
*/
|
||||
void welcomeScreenDisplayed();
|
||||
default void welcomeScreenDisplayed() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Fired before saving settings and before final 'can exit?' check. App may end up not closing if some of the
|
||||
* {@link com.intellij.openapi.application.ApplicationListener} listeners return false from their {@code canExitApplication}
|
||||
* method.
|
||||
*/
|
||||
void appClosing();
|
||||
default void appClosing() {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fired after saving settings and after final 'can exit?' check.
|
||||
*/
|
||||
default void appWillBeClosed() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Please use {@link AppLifecycleListener} directly.
|
||||
*/
|
||||
@Deprecated
|
||||
abstract class Adapter implements AppLifecycleListener {
|
||||
@Override
|
||||
public void appFrameCreated(String[] commandLineArgs, @NotNull Ref<Boolean> willOpenProject) { }
|
||||
|
||||
@Override
|
||||
public void appStarting(Project projectFromCommandLine) { }
|
||||
|
||||
@Override
|
||||
public void projectFrameClosed() { }
|
||||
|
||||
@Override
|
||||
public void projectOpenFailed() { }
|
||||
|
||||
@Override
|
||||
public void welcomeScreenDisplayed() { }
|
||||
|
||||
@Override
|
||||
public void appClosing() { }
|
||||
}
|
||||
}
|
||||
@@ -635,7 +635,7 @@ public abstract class RecentProjectsManagerBase extends RecentProjectsManager im
|
||||
myState.groups.remove(group);
|
||||
}
|
||||
|
||||
private class MyAppLifecycleListener extends AppLifecycleListener.Adapter {
|
||||
private class MyAppLifecycleListener implements AppLifecycleListener {
|
||||
@Override
|
||||
public void appFrameCreated(final String[] commandLineArgs, @NotNull final Ref<Boolean> willOpenProject) {
|
||||
if (willReopenProjectOnStart()) {
|
||||
|
||||
@@ -107,7 +107,7 @@ public class SystemHealthMonitor extends ApplicationComponent.Adapter {
|
||||
final String message = IdeBundle.message(key) + IdeBundle.message("sys.health.acknowledge.link");
|
||||
|
||||
final Application app = ApplicationManager.getApplication();
|
||||
app.getMessageBus().connect(app).subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
|
||||
app.getMessageBus().connect(app).subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
|
||||
@Override
|
||||
public void appFrameCreated(String[] commandLineArgs, @NotNull Ref<Boolean> willOpenProject) {
|
||||
app.invokeLater(() -> {
|
||||
|
||||
+1
-1
@@ -165,7 +165,7 @@ public class ApplicationStatisticsPersistenceComponent extends ApplicationStatis
|
||||
|
||||
@Override
|
||||
public void initComponent() {
|
||||
ApplicationManager.getApplication().getMessageBus().connect().subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
|
||||
ApplicationManager.getApplication().getMessageBus().connect().subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
|
||||
@Override
|
||||
public void appClosing() {
|
||||
persistOpenedProjects();
|
||||
|
||||
+9
-8
@@ -46,8 +46,8 @@ import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.progress.*;
|
||||
import com.intellij.openapi.progress.impl.CoreProgressManager;
|
||||
import com.intellij.openapi.progress.util.ProgressWindow;
|
||||
import com.intellij.openapi.progress.util.PotemkinProgress;
|
||||
import com.intellij.openapi.progress.util.ProgressWindow;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.project.ProjectManager;
|
||||
import com.intellij.openapi.project.ex.ProjectManagerEx;
|
||||
@@ -790,7 +790,8 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
|
||||
return;
|
||||
}
|
||||
|
||||
getMessageBus().syncPublisher(AppLifecycleListener.TOPIC).appClosing();
|
||||
AppLifecycleListener lifecycleListener = getMessageBus().syncPublisher(AppLifecycleListener.TOPIC);
|
||||
lifecycleListener.appClosing();
|
||||
|
||||
myDisposeInProgress = true;
|
||||
|
||||
@@ -799,15 +800,15 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App
|
||||
}
|
||||
|
||||
saveSettings();
|
||||
|
||||
lifecycleListener.appWillBeClosed();
|
||||
|
||||
boolean success = disposeSelf(!force);
|
||||
if (!success || isUnitTestMode() || Boolean.getBoolean("idea.test.guimode")) {
|
||||
if (Boolean.getBoolean("idea.test.guimode")) {
|
||||
IdeaApplication.getInstance().shutdown();
|
||||
if (!success || isUnitTestMode() || Boolean.getBoolean("idea.test.guimode")) {
|
||||
if (Boolean.getBoolean("idea.test.guimode")) {
|
||||
IdeaApplication.getInstance().shutdown();
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
int exitCode = 0;
|
||||
if (restart && Restarter.isSupported()) {
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ public class UpdateCheckerComponent implements ApplicationComponent {
|
||||
return;
|
||||
}
|
||||
|
||||
app.getMessageBus().connect(app).subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
|
||||
app.getMessageBus().connect(app).subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
|
||||
@Override
|
||||
public void appFrameCreated(String[] commandLineArgs, @NotNull Ref<Boolean> willOpenProject) {
|
||||
BuildNumber currentBuild = ApplicationInfo.getInstance().getBuild();
|
||||
|
||||
@@ -155,7 +155,7 @@ public final class WindowManagerImpl extends WindowManagerEx implements NamedCom
|
||||
}
|
||||
};
|
||||
|
||||
bus.connect().subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
|
||||
bus.connect().subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
|
||||
@Override
|
||||
public void appClosing() {
|
||||
// save full screen window states
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class PlatformProjectStarter implements ApplicationComponent {
|
||||
public PlatformProjectStarter(MessageBus bus) {
|
||||
bus.connect().subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
|
||||
bus.connect().subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
|
||||
public void appFrameCreated(final String[] commandLineArgs, @NotNull final Ref<Boolean> willOpenProject) {
|
||||
for (String arg : commandLineArgs) {
|
||||
if (!arg.equals(StartupUtil.NO_SPLASH)) {
|
||||
|
||||
@@ -63,7 +63,7 @@ class LibNotifyWrapper implements SystemNotificationsImpl.Notifier {
|
||||
myIcon = icon != null ? icon : "dialog-information";
|
||||
|
||||
MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect();
|
||||
connection.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
|
||||
connection.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
|
||||
@Override
|
||||
public void appClosing() {
|
||||
synchronized (myLock) {
|
||||
|
||||
@@ -49,7 +49,7 @@ class MountainLionNotifications implements SystemNotificationsImpl.Notifier {
|
||||
cleanupDeliveredNotifications();
|
||||
}
|
||||
});
|
||||
connection.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
|
||||
connection.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
|
||||
@Override
|
||||
public void appClosing() {
|
||||
cleanupDeliveredNotifications();
|
||||
|
||||
@@ -71,7 +71,6 @@ import com.intellij.util.text.DateFormatUtil;
|
||||
import org.jdom.Attribute;
|
||||
import org.jdom.DataConversionException;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.CalledInAwt;
|
||||
import org.jetbrains.annotations.*;
|
||||
|
||||
import javax.swing.*;
|
||||
@@ -151,7 +150,7 @@ public class ProjectLevelVcsManagerImpl extends ProjectLevelVcsManagerEx impleme
|
||||
if (project.isDefault()) {
|
||||
// default project is disposed in write action, so treat it differently
|
||||
MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect();
|
||||
connection.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
|
||||
connection.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
|
||||
@Override
|
||||
public void appClosing() {
|
||||
Disposer.dispose(myInitialization);
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ public class EduStepicUpdater {
|
||||
if (!checkNeeded()) {
|
||||
return;
|
||||
}
|
||||
application.getMessageBus().connect(application).subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
|
||||
application.getMessageBus().connect(application).subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
|
||||
@Override
|
||||
public void appFrameCreated(String[] commandLineArgs, @NotNull Ref<Boolean> willOpenProject) {
|
||||
|
||||
|
||||
+1
-1
@@ -187,7 +187,7 @@ public class PyCharmEduInitialConfigurator {
|
||||
|
||||
if (!propertiesComponent.isValueSet(DISPLAYED_PROPERTY)) {
|
||||
|
||||
bus.connect().subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
|
||||
bus.connect().subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
|
||||
@Override
|
||||
public void welcomeScreenDisplayed() {
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ public class PyCharmInitialConfigurator {
|
||||
}
|
||||
|
||||
if (!propertiesComponent.isValueSet(DISPLAYED_PROPERTY)) {
|
||||
bus.connect().subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
|
||||
bus.connect().subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
|
||||
@Override
|
||||
public void welcomeScreenDisplayed() {
|
||||
ApplicationManager.getApplication().invokeLater(() -> {
|
||||
|
||||
Reference in New Issue
Block a user