use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.
the class MessageBusImpl method connect.
@Override
@NotNull
public MessageBusConnection connect(@NotNull Disposable parentDisposable) {
checkNotDisposed();
final MessageBusConnection connection = new MessageBusConnectionImpl(this);
Disposer.register(parentDisposable, connection);
return connection;
}
use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.
the class MessageListenerList method add.
public void add(@NotNull final T listener, @NotNull Disposable parentDisposable) {
Disposer.register(parentDisposable, new Disposable() {
@Override
public void dispose() {
myListenerToConnectionMap.remove(listener);
}
});
final MessageBusConnection connection = myMessageBus.connect(parentDisposable);
connection.subscribe(myTopic, listener);
myListenerToConnectionMap.put(listener, connection);
}
use of com.intellij.util.messages.MessageBusConnection 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());
}
use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.
the class EditorUtil method runBatchFoldingOperationOutsideOfBulkUpdate.
public static void runBatchFoldingOperationOutsideOfBulkUpdate(@NotNull Editor editor, @NotNull Runnable operation) {
DocumentEx document = ObjectUtils.tryCast(editor.getDocument(), DocumentEx.class);
if (document != null && document.isInBulkUpdate()) {
MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect();
disposeWithEditor(editor, connection);
connection.subscribe(DocumentBulkUpdateListener.TOPIC, new DocumentBulkUpdateListener.Adapter() {
@Override
public void updateFinished(@NotNull Document doc) {
if (doc == editor.getDocument()) {
editor.getFoldingModel().runBatchFoldingOperation(operation);
connection.disconnect();
}
}
});
} else {
editor.getFoldingModel().runBatchFoldingOperation(operation);
}
}
use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.
the class DumbServiceImpl method runWhenPowerSaveModeChanges.
private void runWhenPowerSaveModeChanges(Runnable r) {
MessageBusConnection connection = myProject.getMessageBus().connect();
connection.subscribe(PowerSaveMode.TOPIC, () -> {
r.run();
connection.disconnect();
});
}
Aggregations