Java Code Examples for com.intellij.util.messages.MessageBusConnection#disconnect()

The following examples show how to use com.intellij.util.messages.MessageBusConnection#disconnect() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ANTLRv4PluginController.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void uninstallListeners() {
	VirtualFileManager.getInstance().removeVirtualFileListener(myVirtualFileAdapter);

	if ( !project.isDisposed() ) {
		MessageBusConnection msgBus = project.getMessageBus().connect(project);
		msgBus.disconnect();
	}
}
 
Example 2
Source File: FileTypeManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void removeFileTypeListener(@Nonnull FileTypeListener listener) {
  final MessageBusConnection connection = myAdapters.remove(listener);
  if (connection != null) {
    connection.disconnect();
  }
}
 
Example 3
Source File: ProjectLevelVcsManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void removeVcsListener(VcsListener listener) {
  final MessageBusConnection connection = myAdapters.remove(listener);
  if (connection != null) {
    connection.disconnect();
  }
}
 
Example 4
Source File: NavBarListener.java    From consulo with Apache License 2.0 5 votes vote down vote up
static void unsubscribeFrom(NavBarPanel panel) {
  final NavBarListener listener = (NavBarListener)panel.getClientProperty(LISTENER);
  panel.putClientProperty(LISTENER, null);
  if (listener != null) {
    final Project project = panel.getProject();
    KeyboardFocusManager.getCurrentKeyboardFocusManager().removePropertyChangeListener(listener);
    FileStatusManager.getInstance(project).removeFileStatusListener(listener);
    PsiManager.getInstance(project).removePsiTreeChangeListener(listener);
    final MessageBusConnection connection = (MessageBusConnection)panel.getClientProperty(BUS);
    panel.putClientProperty(BUS, null);
    if (connection != null) {
      connection.disconnect();
    }
  }
}
 
Example 5
Source File: BlazeProjectSystemSyncManager.java    From intellij with Apache License 2.0 4 votes vote down vote up
public ListenableFuture<SyncResult> syncProject(ProjectSystemSyncManager.SyncReason reason) {
  SettableFuture<ProjectSystemSyncManager.SyncResult> syncResult = SettableFuture.create();

  if (BlazeSyncStatus.getInstance(project).syncInProgress()) {
    syncResult.setException(
        new RuntimeException(
            "A sync was requested while one is already in progress."
                + " Use ProjectSystemSyncManager.isSyncInProgress to detect this scenario."));
  } else {
    BlazeSyncParams syncParams =
        BlazeSyncParams.builder()
            .setTitle("Sync")
            .setSyncMode(SyncMode.INCREMENTAL)
            .setSyncOrigin("ProjectSystemSyncManager")
            .setBlazeBuildParams(BlazeBuildParams.fromProject(project))
            .setAddProjectViewTargets(true)
            .setAddWorkingSet(BlazeUserSettings.getInstance().getExpandSyncToWorkingSet())
            .setBackgroundSync(true)
            .build();

    MessageBusConnection connection = project.getMessageBus().connect(project);
    connection.subscribe(
        PROJECT_SYSTEM_SYNC_TOPIC,
        new SyncResultListener() {
          @Override
          public void syncEnded(@NotNull SyncResult result) {
            connection.disconnect();
            syncResult.set(result);
          }
        });

    try {
      BlazeSyncManager.getInstance(project).requestProjectSync(syncParams);
    } catch (Throwable t) {
      if (!Disposer.isDisposed(connection)) {
        connection.disconnect();
      }

      syncResult.setException(t);
    }
  }

  return syncResult;
}
 
Example 6
Source File: MessageListenerList.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void remove(@Nonnull T listener) {
  final MessageBusConnection connection = myListenerToConnectionMap.remove(listener);
  if (connection != null) {
    connection.disconnect();
  }
}