com.intellij.openapi.project.Project.getMessageBus()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(9.5k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中com.intellij.openapi.project.Project.getMessageBus()方法的一些代码示例,展示了Project.getMessageBus()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Project.getMessageBus()方法的具体详情如下:
包路径:com.intellij.openapi.project.Project
类名称:Project
方法名:getMessageBus

Project.getMessageBus介绍

暂无

代码示例

代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin

public GoIdeaSdkService(@NotNull Project project) {
 super(project);
 myProject.getMessageBus().connect(project).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
  @Override
  public void rootsChanged(ModuleRootEvent event) {
   incModificationCount();
  }
 });
}

代码示例来源:origin: JetBrains/ideavim

public void addFileEditorManagerListener(@NotNull Project project, @NotNull FileEditorManagerListener listener) {
 final MessageBusConnection connection = project.getMessageBus().connect();
 connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, listener);
}

代码示例来源:origin: ballerina-platform/ballerina-lang

public BallerinaIdeaSdkService(@NotNull Project project) {
  super(project);
  myProject.getMessageBus().connect(project).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
    @Override
    public void rootsChanged(ModuleRootEvent event) {
      incModificationCount();
    }
  });
}

代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin

public WrongSdkConfigurationNotificationProvider(@NotNull Project project, @NotNull EditorNotifications notifications) {
 myProject = project;
 MessageBusConnection connection = myProject.getMessageBus().connect(project);
 connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
  @Override
  public void rootsChanged(ModuleRootEvent event) {
   notifications.updateAllNotifications();
  }
 });
 connection.subscribe(GoLibrariesService.LIBRARIES_TOPIC, newRootUrls -> notifications.updateAllNotifications());
}

代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin

public GoFileIgnoredByBuildToolNotificationProvider(@NotNull Project project,
                          @NotNull EditorNotifications notifications,
                          @NotNull FileEditorManager fileEditorManager) {
 myProject = project;
 MessageBusConnection connection = myProject.getMessageBus().connect(myProject);
 connection.subscribe(GoModuleSettings.TOPIC, module -> notifications.updateAllNotifications());
 connection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener.Adapter() {
  @Override
  public void after(@NotNull List<? extends VFileEvent> events) {
   if (!myProject.isDisposed()) {
    Set<VirtualFile> openFiles = ContainerUtil.newHashSet(fileEditorManager.getSelectedFiles());
    for (VFileEvent event : events) {
     VirtualFile file = event.getFile();
     if (file != null && openFiles.contains(file)) {
      notifications.updateNotifications(file);
     }
    }
   }
  }
 });
}

代码示例来源:origin: ballerina-platform/ballerina-lang

public WrongSdkConfigurationNotificationProvider(@NotNull Project project,
                         @NotNull EditorNotifications notifications) {
  myProject = project;
  MessageBusConnection connection = myProject.getMessageBus().connect(project);
  connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
    @Override
    public void rootsChanged(ModuleRootEvent event) {
      notifications.updateAllNotifications();
    }
  });
  connection.subscribe(BallerinaLibrariesService.LIBRARIES_TOPIC,
      newRootUrls -> notifications.updateAllNotifications());
}

代码示例来源:origin: hsz/idea-gitignore

/** Initializes component. */
@Override
public void initComponent() {
  messageBus = myProject.getMessageBus().connect();
  messageBus.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new IgnoreEditorManagerListener(myProject));
}

代码示例来源:origin: hsz/idea-gitignore

/** Component initialization method. */
@Override
public void initComponent() {
  settings = IgnoreSettings.getInstance();
  messageBus = myProject.getMessageBus().connect();
  messageBus.subscribe(IgnoreManager.TrackedIgnoredListener.TRACKED_IGNORED, this);
}

代码示例来源:origin: hsz/idea-gitignore

/**
 * This method is invoked by default implementation of "OK" action. It just closes dialog with
 * <code>OK_EXIT_CODE</code>. This is convenient place to override functionality of "OK" action.
 * Note that the method does nothing if "OK" action isn't enabled.
 */
@Override
protected void doOKAction() {
  super.doOKAction();
  HashMap<VcsRoot, ArrayList<VirtualFile>> checked = getCheckedFiles();
  for (Map.Entry<VcsRoot, ArrayList<VirtualFile>> entry : checked.entrySet()) {
    for (VirtualFile file : entry.getValue()) {
      ExternalExec.removeFileFromTracking(file, entry.getKey());
    }
  }
  project.getMessageBus().syncPublisher(TRACKED_IGNORED_REFRESH).refresh();
}

代码示例来源:origin: hsz/idea-gitignore

/**
 * Constructor.
 *
 * @param project        current project
 * @param projectManager project manager instance
 * @param index          index instance
 */
public IgnoreFileBasedIndexProjectHandler(@NotNull final Project project, @NotNull ProjectManager projectManager,
                     @NotNull final FileBasedIndex index) {
  super(project);
  this.projectManager = projectManager;
  this.index = index;
  StartupManager.getInstance(myProject).registerPreStartupActivity(() -> {
    index.registerIndexableSet(IgnoreFileBasedIndexProjectHandler.this, project);
    myProject.getMessageBus().syncPublisher(REFRESH_STATUSES).refresh();
  });
}

代码示例来源:origin: KronicDeth/intellij-elixir

private void updateSdkLevels(@NotNull Project project, @NotNull Set<Sdk> sdkSet) {
  final DumbService dumbService = DumbService.getInstance(project);
  final DumbModeTask task = new DumbModeTask() {
    @Override
    public void performInDumbMode(@NotNull ProgressIndicator indicator) {
      if (!project.isDisposed()) {
        final PerformanceWatcher.Snapshot snapshot = PerformanceWatcher.takeSnapshot();
        final List<Runnable> tasks = ReadAction.compute(() -> rootUpdateTaskList(project, sdkSet));
        PushedFilePropertiesUpdaterImpl.invokeConcurrentlyIfPossible(tasks);
        if (!ApplicationManager.getApplication().isUnitTestMode()) {
          snapshot.logResponsivenessSinceCreation(
              "Pushing Elixir language level to " + tasks.size() + " roots in " +
                  sdkSet.size() + " SDKs");
        }
      }
    }
  };
  project.getMessageBus().connect(task).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
    @Override
    public void rootsChanged(ModuleRootEvent event) {
      DumbService.getInstance(project).cancelTask(task);
    }
  });
  dumbService.queueTask(task);
}

代码示例来源:origin: go-lang-plugin-org/go-lang-idea-plugin

public void setBuildTargetSettings(@NotNull GoBuildTargetSettings buildTargetSettings) {
 if (!buildTargetSettings.equals(myState.buildTargetSettings)) {
  XmlSerializerUtil.copyBean(buildTargetSettings, myState.buildTargetSettings);
  if (!myModule.isDisposed()) {
   myModule.getProject().getMessageBus().syncPublisher(TOPIC).changed(myModule);
  }
  cleanResolveCaches();
  myState.buildTargetSettings.incModificationCount();
 }
}

代码示例来源:origin: hsz/idea-gitignore

messageBus = project.getMessageBus().connect();
messageBus.subscribe(UISettingsListener.TOPIC, uiSettings -> updateTabbedPanelPolicy());
updateTabbedPanelPolicy();

代码示例来源:origin: hsz/idea-gitignore

myProject.getMessageBus().syncPublisher(TRACKED_IGNORED).handleFiles(result);

代码示例来源:origin: hsz/idea-gitignore

/** Enable manager. */
private void enable() {
  if (working) {
    return;
  }
  refreshTrackedIgnoredFeature.run();
  virtualFileManager.addVirtualFileListener(virtualFileListener);
  settings.addListener(settingsListener);
  messageBus = myProject.getMessageBus().connect();
  messageBus.subscribe(TRACKED_IGNORED_REFRESH, () -> debouncedRefreshTrackedIgnores.run(true));
  messageBus.subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, () -> {
    ExternalIndexableSetContributor.invalidateCache(myProject);
    vcsRoots.clear();
    vcsRoots.addAll(ContainerUtil.newArrayList(projectLevelVcsManager.getAllVcsRoots()));
  });
  messageBus.subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
    @Override
    public void enteredDumbMode() {
    }
    @Override
    public void exitDumbMode() {
      debouncedExitDumbMode.run();
    }
  });
  messageBus.subscribe(ProjectTopics.PROJECT_ROOTS, commonRunnableListeners);
  messageBus.subscribe(RefreshStatusesListener.REFRESH_STATUSES, commonRunnableListeners);
  messageBus.subscribe(ProjectTopics.MODULES, commonRunnableListeners);
  working = true;
}

代码示例来源:origin: SonarSource/sonarlint-intellij

public IssueManager(SonarLintAppUtils appUtils, Project project, LiveIssueCache cache, IssuePersistence store) {
 super(project);
 this.appUtils = appUtils;
 this.cache = cache;
 this.messageBus = project.getMessageBus();
 this.store = store;
}

代码示例来源:origin: misakuo/svgtoandroid

public static void showTopic(Project project, String title, String content, NotificationType type) {
  project.getMessageBus().syncPublisher(Notifications.TOPIC).notify(
      new Notification(Notifications.SYSTEM_MESSAGES_GROUP_ID,
          title,
          content,
          type));
}

代码示例来源:origin: SonarSource/sonarlint-intellij

public SonarQubeEventNotifications(Project project, ProjectBindingManager bindingManager, SonarLintProjectState projectState,
 SonarLintProjectSettings projectSettings) {
 super(project);
 this.bindingManager = bindingManager;
 this.projectState = projectState;
 this.projectSettings = projectSettings;
 this.eventListener = new EventListener();
 this.notificationTime = new ProjectNotificationTime();
 this.busConnection = project.getMessageBus().connect(myProject);
}

代码示例来源:origin: SonarSource/sonarlint-intellij

private Project createProject() {
 Project project = mock(Project.class);
 when(project.getMessageBus()).thenReturn(new MessageBusImpl.RootBus(this));
 when(project.isDisposed()).thenReturn(false);
 return project;
}

代码示例来源:origin: SonarSource/sonarlint-intellij

@Test
public void testCallListenerOnError() {
 TaskListener listener = mock(TaskListener.class);
 getProject().getMessageBus().connect(getProject()).subscribe(TaskListener.SONARLINT_TASK_TOPIC, listener);
 doThrow(new IllegalStateException("error")).when(sonarLintAnalyzer).analyzeModule(eq(module), eq(files), any(IssueListener.class), any(ProgressMonitor.class));
 task.run(progress);
 // never called because of error
 verifyZeroInteractions(processor);
 // still called
 verify(listener).ended(job);
 verifyNoMoreInteractions(listener);
}

相关文章