Search in sources :

Example 1 with ProjectLifecycleListener

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

the class StartupManagerImpl method scheduleInitialVfsRefresh.

public void scheduleInitialVfsRefresh() {
    GuiUtils.invokeLaterIfNeeded(() -> {
        if (myProject.isDisposed() || myInitialRefreshScheduled)
            return;
        myInitialRefreshScheduled = true;
        markContentRootsForRefresh();
        Application app = ApplicationManager.getApplication();
        if (!app.isCommandLine()) {
            final long sessionId = VirtualFileManager.getInstance().asyncRefresh(null);
            final MessageBusConnection connection = app.getMessageBus().connect();
            connection.subscribe(ProjectLifecycleListener.TOPIC, new ProjectLifecycleListener() {

                @Override
                public void afterProjectClosed(@NotNull Project project) {
                    if (project != myProject)
                        return;
                    RefreshQueue.getInstance().cancelSession(sessionId);
                    connection.disconnect();
                }
            });
        } else {
            VirtualFileManager.getInstance().syncRefresh();
        }
    }, ModalityState.defaultModalityState());
}
Also used : MessageBusConnection(com.intellij.util.messages.MessageBusConnection) ProjectLifecycleListener(com.intellij.openapi.project.impl.ProjectLifecycleListener)

Aggregations

ProjectLifecycleListener (com.intellij.openapi.project.impl.ProjectLifecycleListener)1 MessageBusConnection (com.intellij.util.messages.MessageBusConnection)1