com.intellij.util.messages.MessageBusConnection Java Examples

The following examples show how to use com.intellij.util.messages.MessageBusConnection. 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: PantsSystemProjectResolver.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
private void doViewSwitch(@NotNull ExternalSystemTaskId id, @NotNull String projectPath) {
  Project ideProject = id.findProject();
  if (ideProject == null) {
    return;
  }
  // Disable zooming on subsequent project resolves/refreshes,
  // i.e. a project that already has existing modules, because it may zoom at a module
  // that is going to be replaced by the current resolve.
  if (ModuleManager.getInstance(ideProject).getModules().length > 0) {
    return;
  }

  MessageBusConnection messageBusConnection = ideProject.getMessageBus().connect();
  messageBusConnection.subscribe(
    ProjectTopics.PROJECT_ROOTS,
    new ModuleRootListener() {
      @Override
      public void rootsChanged(ModuleRootEvent event) {
        // Initiate view switch only when project modules have been created.
        new ViewSwitchProcessor(ideProject, projectPath).asyncViewSwitch();
      }
    }
  );
}
 
Example #2
Source File: SnapshotsRunListener.java    From tmc-intellij with MIT License 6 votes vote down vote up
private void connectToMessageBus(Project project) {
    logger.info("Connecting to message bus.");
    MessageBusConnection bus = project.getMessageBus().connect();
    bus.setDefaultHandler(
            (method, objects) -> {
                logger.info("Method call observed in message bus.");
                for (Object object : objects) {
                    if (method.toString().toLowerCase().contains("contentselected")) {
                        if (object.toString().toLowerCase().contains("debug")) {
                            new ButtonInputListener().receiveDebugRunAction();
                        } else if (object.toString().contains("DefaultRunExecutor")) {
                            new ButtonInputListener().receiveRunAction();
                        }
                    }
                }
            });
    logger.info("Subscribing to RunContentManager topic.");
    bus.subscribe(RunContentManager.TOPIC);
}
 
Example #3
Source File: FlutterSaveActionsManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private FlutterSaveActionsManager(@NotNull Project project) {
  this.myProject = project;

  final MessageBus bus = project.getMessageBus();
  final MessageBusConnection connection = bus.connect();
  connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerListener() {
    @Override
    public void beforeDocumentSaving(@NotNull Document document) {
      // Don't try and format read only docs.
      if (!document.isWritable()) {
        return;
      }

      handleBeforeDocumentSaving(document);
    }
  });
}
 
Example #4
Source File: UnindexedFilesUpdater.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void scheduleInitialVfsRefresh() {
  ProjectRootManagerEx.getInstanceEx(myProject).markRootsForRefresh();

  Application app = ApplicationManager.getApplication();
  if (!app.isCommandLine()) {
    long sessionId = VirtualFileManager.getInstance().asyncRefresh(null);
    MessageBusConnection connection = app.getMessageBus().connect();
    connection.subscribe(ProjectManager.TOPIC, new ProjectManagerListener() {
      @Override
      public void projectClosed(@Nonnull Project project, @Nonnull UIAccess uiAccess) {
        if (project == myProject) {
          RefreshQueue.getInstance().cancelSession(sessionId);
          connection.disconnect();
        }
      }
    });
  }
  else {
    VirtualFileManager.getInstance().syncRefresh();
  }
}
 
Example #5
Source File: FlutterSaveActionsManager.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private FlutterSaveActionsManager(@NotNull Project project) {
  this.myProject = project;

  final MessageBus bus = project.getMessageBus();
  final MessageBusConnection connection = bus.connect();
  connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerListener() {
    @Override
    public void beforeDocumentSaving(@NotNull Document document) {
      // Don't try and format read only docs.
      if (!document.isWritable()) {
        return;
      }

      handleBeforeDocumentSaving(document);
    }
  });
}
 
Example #6
Source File: VcsEventWatcher.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void projectOpened() {
  MessageBusConnection connection = myProject.getMessageBus().connect(myProject);
  connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
    @Override
    public void rootsChanged(ModuleRootEvent event) {
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          if (myProject.isDisposed()) return;
          VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
        }
      }, ModalityState.NON_MODAL);
    }
  });
  connection.subscribe(ProblemListener.TOPIC, new MyProblemListener());
}
 
Example #7
Source File: BreadcrumbsInitializingActivity.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void runActivity(@Nonnull Project project) {
  if (project.isDefault() || ApplicationManager.getApplication().isUnitTestMode() || project.isDisposed()) {
    return;
  }

  MessageBusConnection connection = project.getMessageBus().connect();
  connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new MyFileEditorManagerListener());
  connection.subscribe(FileTypeManager.TOPIC, new FileTypeListener() {
    @Override
    public void fileTypesChanged(@Nonnull FileTypeEvent event) {
      reinitBreadcrumbsInAllEditors(project);
    }
  });

  VirtualFileManager.getInstance().addVirtualFileListener(new MyVirtualFileListener(project), project);
  connection.subscribe(UISettingsListener.TOPIC, uiSettings -> reinitBreadcrumbsInAllEditors(project));

  UIUtil.invokeLaterIfNeeded(() -> reinitBreadcrumbsInAllEditors(project));
}
 
Example #8
Source File: IncomingChangesIndicator.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Inject
public IncomingChangesIndicator(Application application, Project project, CommittedChangesCache cache) {
  myProject = project;
  myCache = cache;

  if(project.isDefault()) {
    return;
  }

  final MessageBusConnection connection = project.getMessageBus().connect();
  connection.subscribe(CommittedChangesCache.COMMITTED_TOPIC, new CommittedChangesAdapter() {
    @Override
    public void incomingChangesUpdated(@Nullable final List<CommittedChangeList> receivedChanges) {
      application.invokeLater(() -> refreshIndicator());
    }
  });
  final VcsListener listener = () -> UIUtil.invokeLaterIfNeeded(this::updateIndicatorVisibility);
  connection.subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, listener);
  connection.subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED_IN_PLUGIN, listener);
}
 
Example #9
Source File: OutdatedVersionNotifier.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Inject
public OutdatedVersionNotifier(Provider<FileEditorManager> fileEditorManager,
                               CommittedChangesCache cache,
                               Project project) {
  myFileEditorManager = fileEditorManager;
  myCache = cache;
  myProject = project;
  MessageBusConnection busConnection = project.getMessageBus().connect();
  busConnection.subscribe(CommittedChangesCache.COMMITTED_TOPIC, new CommittedChangesAdapter() {
    @Override
    public void incomingChangesUpdated(@Nullable final List<CommittedChangeList> receivedChanges) {
      if (myCache.getCachedIncomingChanges() == null) {
        requestLoadIncomingChanges();
      }
      else {
        updateAllEditorsLater();
      }
    }

    @Override
    public void changesCleared() {
      updateAllEditorsLater();
    }
  });
  busConnection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new MyFileEditorManagerListener());
}
 
Example #10
Source File: LibNotifyWrapper.java    From consulo with Apache License 2.0 6 votes vote down vote up
private LibNotifyWrapper() {
  myLibNotify = (LibNotify)Native.loadLibrary("libnotify.so.4", LibNotify.class);

  String appName = ApplicationNamesInfo.getInstance().getProductName();
  if (myLibNotify.notify_init(appName) == 0) {
    throw new IllegalStateException("notify_init failed");
  }

  String icon = AppUIUtil.findIcon(ContainerPathManager.get().getAppHomeDirectory().getPath());
  myIcon = icon != null ? icon : "dialog-information";

  MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect();
  connection.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
    @Override
    public void appClosing() {
      synchronized (myLock) {
        myDisposed = true;
        myLibNotify.notify_uninit();
      }
    }
  });
}
 
Example #11
Source File: AutoScrollFromSourceHandler.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void install() {
  final MessageBusConnection connection = myProject.getMessageBus().connect(myProject);
  connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerAdapter() {
    @Override
    public void selectionChanged(@Nonnull FileEditorManagerEvent event) {
      final FileEditor editor = event.getNewEditor();
      if (editor != null && myComponent.isShowing() && isAutoScrollEnabled()) {
        myAlarm.cancelAllRequests();
        myAlarm.addRequest(new Runnable() {
          @Override
          public void run() {
            selectElementFromEditor(editor);
          }
        }, getAlarmDelay(), getModalityState());
      }
    }
  });
}
 
Example #12
Source File: Alarm.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void addRequest(@Nonnull final Runnable request, final int delay, boolean runWithActiveFrameOnly) {
  if (runWithActiveFrameOnly && !ApplicationManager.getApplication().isActive()) {
    final MessageBus bus = ApplicationManager.getApplication().getMessageBus();
    final MessageBusConnection connection = bus.connect(this);
    connection.subscribe(ApplicationActivationListener.TOPIC, new ApplicationActivationListener() {
      @Override
      public void applicationActivated(@Nonnull IdeFrame ideFrame) {
        connection.disconnect();
        addRequest(request, delay);
      }
    });
  }
  else {
    addRequest(request, delay);
  }
}
 
Example #13
Source File: VcsLogContentProvider.java    From consulo with Apache License 2.0 6 votes vote down vote up
public VcsLogContentProvider(@Nonnull Project project, @Nonnull VcsProjectLog projectLog) {
  myProject = project;
  myProjectLog = projectLog;

  MessageBusConnection connection = project.getMessageBus().connect(project);
  connection.subscribe(VcsProjectLog.VCS_PROJECT_LOG_CHANGED, new VcsProjectLog.ProjectLogListener() {
    @Override
    public void logCreated() {
      addLogUi();
    }

    @Override
    public void logDisposed() {
      myContainer.removeAll();
      closeLogTabs();
    }
  });

  if (myProjectLog.getLogManager() != null) {
    addLogUi();
  }
}
 
Example #14
Source File: EditorFactoryImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Inject
public EditorFactoryImpl(Application application) {
  MessageBusConnection busConnection = application.getMessageBus().connect();
  busConnection.subscribe(ProjectManager.TOPIC, new ProjectManagerListener() {
    @Override
    public void projectClosed(@Nonnull Project project, @Nonnull UIAccess uiAccess) {
      // validate all editors are disposed after fireProjectClosed() was called, because it's the place where editor should be released
      Disposer.register(project, () -> {
        Project[] openProjects = ProjectManager.getInstance().getOpenProjects();
        boolean isLastProjectClosed = openProjects.length == 0;
        // EditorTextField.releaseEditorLater defer releasing its editor; invokeLater to avoid false positives about such editors.
        ApplicationManager.getApplication().invokeLater(() -> validateEditorsAreReleased(project, isLastProjectClosed));
      });
    }
  });
  busConnection.subscribe(EditorColorsManager.TOPIC, scheme -> refreshAllEditors());

  LaterInvocator.addModalityStateListener(new ModalityStateListener() {
    @Override
    public void beforeModalityStateChanged(boolean entering) {
      for (Editor editor : myEditors) {
        ((DesktopEditorImpl)editor).beforeModalityStateChanged();
      }
    }
  }, ApplicationManager.getApplication());
}
 
Example #15
Source File: EditorUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void runBatchFoldingOperationOutsideOfBulkUpdate(@Nonnull Editor editor, @Nonnull Runnable operation) {
  DocumentEx document = ObjectUtils.tryCast(editor.getDocument(), DocumentEx.class);
  if (document != null && document.isInBulkUpdate()) {
    MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect();
    disposeWithEditor(editor, connection::disconnect);
    connection.subscribe(DocumentBulkUpdateListener.TOPIC, new DocumentBulkUpdateListener.Adapter() {
      @Override
      public void updateFinished(@Nonnull Document doc) {
        if (doc == editor.getDocument()) {
          editor.getFoldingModel().runBatchFoldingOperation(operation);
          connection.disconnect();
        }
      }
    });
  }
  else {
    editor.getFoldingModel().runBatchFoldingOperation(operation);
  }
}
 
Example #16
Source File: TextEditorComponent.java    From consulo with Apache License 2.0 6 votes vote down vote up
public TextEditorComponent(@Nonnull final Project project, @Nonnull final VirtualFile file, @Nonnull final DesktopTextEditorImpl textEditor) {
  super(new BorderLayout(), textEditor);

  myProject = project;
  myFile = file;
  myTextEditor = textEditor;

  myDocument = FileDocumentManager.getInstance().getDocument(myFile);
  LOG.assertTrue(myDocument != null);
  myDocument.addDocumentListener(new MyDocumentListener(), this);

  myEditor = createEditor();
  add(myEditor.getComponent(), BorderLayout.CENTER);
  myModified = isModifiedImpl();
  myValid = isEditorValidImpl();
  LOG.assertTrue(myValid);

  MyVirtualFileListener myVirtualFileListener = new MyVirtualFileListener();
  myFile.getFileSystem().addVirtualFileListener(myVirtualFileListener);
  Disposer.register(this, () -> myFile.getFileSystem().removeVirtualFileListener(myVirtualFileListener));
  MessageBusConnection myConnection = project.getMessageBus().connect(this);
  myConnection.subscribe(FileTypeManager.TOPIC, new MyFileTypeListener());

  myEditorHighlighterUpdater = new EditorHighlighterUpdater(myProject, this, (EditorEx)myEditor, myFile);
}
 
Example #17
Source File: EditorHighlighterUpdater.java    From consulo with Apache License 2.0 6 votes vote down vote up
public EditorHighlighterUpdater(@Nonnull Project project, @Nonnull Disposable parentDisposable, @Nonnull EditorEx editor, @Nullable VirtualFile file) {
  myProject = project;
  myEditor = editor;
  myFile = file;
  MessageBusConnection connection = project.getMessageBus().connect(parentDisposable);
  connection.subscribe(FileTypeManager.TOPIC, new MyFileTypeListener());
  connection.subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
    @Override
    public void enteredDumbMode() {
      updateHighlighters();
    }

    @Override
    public void exitDumbMode() {
      updateHighlighters();
    }
  });
}
 
Example #18
Source File: EditorHistoryManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Inject
EditorHistoryManager(@Nonnull Project project) {
  myProject = project;

  MessageBusConnection connection = project.getMessageBus().connect();

  connection.subscribe(UISettingsListener.TOPIC, new UISettingsListener() {
    @Override
    public void uiSettingsChanged(UISettings uiSettings) {
      trimToSize();
    }
  });

  connection.subscribe(FileEditorManagerListener.Before.FILE_EDITOR_MANAGER, new FileEditorManagerListener.Before.Adapter() {
    @Override
    public void beforeFileClosed(@Nonnull FileEditorManager source, @Nonnull VirtualFile file) {
      updateHistoryEntry(file, false);
    }
  });
  connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new MyEditorManagerListener());
}
 
Example #19
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 #20
Source File: LogicalRootsManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Inject
public LogicalRootsManagerImpl(final ModuleManager moduleManager, final Project project) {
  myModuleManager = moduleManager;
  myProject = project;

  final MessageBusConnection connection = project.getMessageBus().connect();
  connection.subscribe(LOGICAL_ROOTS, new LogicalRootListener() {
    @Override
    public void logicalRootsChanged() {
      clear();
      //updateCache(moduleManager);
    }
  });
  connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
    @Override
    public void rootsChanged(ModuleRootEvent event) {
      project.getMessageBus().syncPublisher(LOGICAL_ROOTS).logicalRootsChanged();
    }
  });
  registerLogicalRootProvider(LogicalRootType.SOURCE_ROOT, new NotNullFunction<Module, List<VirtualFileLogicalRoot>>() {
    @Override
    @Nonnull
    public List<VirtualFileLogicalRoot> fun(final Module module) {
      return ContainerUtil.map2List(ModuleRootManager.getInstance(module).getContentFolderFiles(ContentFolderScopes.productionAndTest()), new Function<VirtualFile, VirtualFileLogicalRoot>() {
        @Override
        public VirtualFileLogicalRoot fun(final VirtualFile s) {
          return new VirtualFileLogicalRoot(s);
        }
      });
    }
  });
}
 
Example #21
Source File: PsiAwareFileEditorManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected void projectOpened(@Nonnull MessageBusConnection connection) {
  super.projectOpened(connection);

  myPsiManager.addPsiTreeChangeListener(myPsiTreeChangeListener);
  connection.subscribe(ProblemListener.TOPIC, myProblemListener);
}
 
Example #22
Source File: NavBarListener.java    From consulo with Apache License 2.0 5 votes vote down vote up
static void subscribeTo(NavBarPanel panel) {
  if (panel.getClientProperty(LISTENER) != null) {
    unsubscribeFrom(panel);
  }

  final NavBarListener listener = new NavBarListener(panel);
  final Project project = panel.getProject();
  panel.putClientProperty(LISTENER, listener);
  KeyboardFocusManager.getCurrentKeyboardFocusManager().addPropertyChangeListener(listener);
  FileStatusManager.getInstance(project).addFileStatusListener(listener);
  PsiManager.getInstance(project).addPsiTreeChangeListener(listener);

  final MessageBusConnection connection = project.getMessageBus().connect();
  connection.subscribe(AnActionListener.TOPIC, listener);
  connection.subscribe(ProblemListener.TOPIC, listener);
  connection.subscribe(ProjectTopics.PROJECT_ROOTS, listener);
  connection.subscribe(NavBarModelListener.NAV_BAR, listener);
  connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, listener);
  panel.putClientProperty(BUS, connection);
  panel.addKeyListener(listener);

  if (panel.isInFloatingMode()) {
    final Window window = SwingUtilities.windowForComponent(panel);
    if (window != null) {
      window.addWindowFocusListener(listener);
    }
  }
}
 
Example #23
Source File: EditorNotificationsImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Inject
public EditorNotificationsImpl(Project project) {
  myProject = project;
  myUpdateMerger = new MergingUpdateQueue("EditorNotifications update merger", 100, true, null, project);
  MessageBusConnection connection = project.getMessageBus().connect(project);
  connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new FileEditorManagerListener() {
    @Override
    public void fileOpened(@Nonnull FileEditorManager source, @Nonnull VirtualFile file) {
      updateNotifications(file);
    }
  });
  connection.subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {
    @Override
    public void enteredDumbMode() {
      updateAllNotifications();
    }

    @Override
    public void exitDumbMode() {
      updateAllNotifications();
    }
  });
  connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
    @Override
    public void rootsChanged(ModuleRootEvent event) {
      updateAllNotifications();
    }
  });
}
 
Example #24
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 #25
Source File: MountainLionNotifications.java    From consulo with Apache License 2.0 5 votes vote down vote up
private MountainLionNotifications() {
  final MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect();
  connection.subscribe(ApplicationActivationListener.TOPIC, new ApplicationActivationListener.Adapter() {
    @Override
    public void applicationActivated(IdeFrame ideFrame) {
      cleanupDeliveredNotifications();
    }
  });
  connection.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
    @Override
    public void appClosing() {
      cleanupDeliveredNotifications();
    }
  });
}
 
Example #26
Source File: ProjectTreeBuilder.java    From consulo with Apache License 2.0 5 votes vote down vote up
public ProjectTreeBuilder(@Nonnull Project project,
                          @Nonnull JTree tree,
                          @Nonnull DefaultTreeModel treeModel,
                          @Nullable Comparator<NodeDescriptor> comparator,
                          @Nonnull ProjectAbstractTreeStructureBase treeStructure) {
  super(project, tree, treeModel, treeStructure, comparator);

  final MessageBusConnection connection = project.getMessageBus().connect(this);

  connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
    @Override
    public void rootsChanged(ModuleRootEvent event) {
      queueUpdate();
    }
  });

  connection.subscribe(BookmarksListener.TOPIC, new MyBookmarksListener());

  PsiManager.getInstance(project).addPsiTreeChangeListener(createPsiTreeChangeListener(project), this);
  FileStatusManager.getInstance(project).addFileStatusListener(new MyFileStatusListener(), this);
  CopyPasteManager.getInstance().addContentChangedListener(new CopyPasteUtil.DefaultCopyPasteListener(getUpdater()), this);

  connection.subscribe(ProblemListener.TOPIC, new MyProblemListener());

  setCanYieldUpdate(true);

  initRootNode();
}
 
Example #27
Source File: ScopeTreeViewPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void initListeners() {
  final MessageBusConnection connection = myProject.getMessageBus().connect(this);
  connection.subscribe(ProjectTopics.PROJECT_ROOTS, new MyModuleRootListener());
  connection.subscribe(ProblemListener.TOPIC, myProblemListener);
  PsiManager.getInstance(myProject).addPsiTreeChangeListener(myPsiTreeChangeAdapter);
  ChangeListManager.getInstance(myProject).addChangeListListener(myChangesListListener);
  FileStatusManager.getInstance(myProject).addFileStatusListener(myFileStatusListener, myProject);
}
 
Example #28
Source File: RecentProjectPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
FilePathChecker(Runnable callback, Collection<String> paths) {
  myCallback = callback;
  myPaths = paths;
  MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect(this);
  connection.subscribe(ApplicationActivationListener.TOPIC, this);
  connection.subscribe(PowerSaveMode.TOPIC, this);
  onAppStateChanged();
}
 
Example #29
Source File: DesktopIconDeferrerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Inject
public DesktopIconDeferrerImpl(Application application) {
  final MessageBusConnection connection = application.getMessageBus().connect();
  connection.subscribe(PsiModificationTracker.TOPIC, this::clear);
  connection.subscribe(ProjectManager.TOPIC, new ProjectManagerListener() {
    @Override
    public void projectClosed(@Nonnull Project project, @Nonnull UIAccess uiAccess) {
      clear();
    }
  });
  LowMemoryWatcher.register(this::clear, this);
}
 
Example #30
Source File: RecentProjectsManagerBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
protected RecentProjectsManagerBase(@Nonnull Application application) {
  MessageBusConnection connection = application.getMessageBus().connect();
  connection.subscribe(AppLifecycleListener.TOPIC, new MyAppLifecycleListener());
  if (!application.isHeadlessEnvironment()) {
    connection.subscribe(ProjectManager.TOPIC, new MyProjectListener());
  }
}