@Override public void createToolWindowContent(@NotNull Project project, @NotNull ToolWindow toolWindow) { ContentFactory contentFactory = ContentFactory.SERVICE.getInstance(); Set<SelectedExchangeCurrencyPair> selectedExchangeCurrencyPairs = IdeaCurrencyConfig.getInstance().getSelectedExchangeCurrencyPairs(); if (IdeaCurrencyConfig.getInstance().getActive()) { List<TickerDto> data = IdeaCurrencyApp.getInstance().getTickers(selectedExchangeCurrencyPairs); fillData(data); } Content content = contentFactory.createContent(contentPane, "", false); toolWindow.getContentManager().addContent(content); MessageBus messageBus = project.getMessageBus(); messageBusConnection = messageBus.connect(); messageBusConnection.subscribe(ConfigChangeNotifier.CONFIG_TOPIC, active -> { if (active) { scheduleNextTask(); } }); }
@Override public void initComponent() { MessageBus bus = ApplicationManager.getApplication().getMessageBus(); connection = bus.connect(); ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerListener() { @Override public void projectOpened(Project project) { Config config = Config.getInstance(project); if(config == null) { return; } if(!config.isConfigFilled()) { Notifications.Bus.notify( new Notification("Settings Error", "Gherkin TS Runner", "Settings have to be filled.", NotificationType.WARNING) ); return; } connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new GherkinFileEditorManagerListener(project)); } }); }
@Override public void actionPerformed(AnActionEvent e) { if (e.getProject() != null) { ScanManager scanManager = ScanManagerFactory.getScanManager(e.getProject()); if (scanManager == null) { // Check if the project is supported now ScanManagerFactory scanManagerFactory = ServiceManager.getService(e.getProject(), ScanManagerFactory.class); scanManagerFactory.initScanManager(e.getProject()); scanManager = ScanManagerFactory.getScanManager(e.getProject()); if (scanManager == null) { return; } MessageBus messageBus = ApplicationManager.getApplication().getMessageBus(); messageBus.syncPublisher(Events.ON_IDEA_FRAMEWORK_CHANGE).update(); } scanManager.asyncScanAndUpdateResults(false); } }
/** * This function is called after change in the build.gradle file or refresh gradle dependencies call. * @param toImport the project dependencies * @param projectData the project data * @param project the current project * @param modelsProvider contains the project modules */ @Override public void importData(@NotNull Collection<DataNode<LibraryDependencyData>> toImport, @Nullable ProjectData projectData, @NotNull Project project, @NotNull IdeModifiableModelsProvider modelsProvider) { if (projectData == null || !projectData.getOwner().equals(GradleConstants.SYSTEM_ID)) { return; } ScanManager scanManager = ScanManagerFactory.getScanManager(project); if (scanManager == null) { ScanManagerFactory scanManagerFactory = ServiceManager.getService(project, ScanManagerFactory.class); scanManagerFactory.initScanManager(project); scanManager = ScanManagerFactory.getScanManager(project); if (scanManager == null) { return; } MessageBus messageBus = ApplicationManager.getApplication().getMessageBus(); messageBus.syncPublisher(Events.ON_IDEA_FRAMEWORK_CHANGE).update(); } if (GlobalSettings.getInstance().isCredentialsSet()) { scanManager.asyncScanAndUpdateResults(true, toImport); } }
public static void _do(@NotNull final ConfigurationError error, @NotNull final Project project, @NotNull final PairProcessor<ConfigurationErrors, ConfigurationError> fun) { if (!project.isInitialized()) { StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() { @Override public void run() { fun.process(project.getMessageBus().syncPublisher(TOPIC), error); } }); return; } final MessageBus bus = project.getMessageBus(); if (EventQueue.isDispatchThread()) fun.process(bus.syncPublisher(TOPIC), error); else { //noinspection SSBasedInspection SwingUtilities.invokeLater(new Runnable() { @Override public void run() { fun.process(bus.syncPublisher(TOPIC), error); } }); } }
public static void set(@Nullable final String text, @Nullable final Project project, @Nullable final String requestor) { if (project != null) { if (project.isDisposed()) return; if (!project.isInitialized()) { StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() { public void run() { project.getMessageBus().syncPublisher(TOPIC).setInfo(text, requestor); } }); return; } } final MessageBus bus = project == null ? ApplicationManager.getApplication().getMessageBus() : project.getMessageBus(); bus.syncPublisher(TOPIC).setInfo(text, requestor); }
public PsiModificationTrackerImpl(Project project) { final MessageBus bus = project.getMessageBus(); myPublisher = bus.syncPublisher(TOPIC); bus.connect().subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() { private void doIncCounter() { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { incCounter(); } }); } @Override public void enteredDumbMode() { doIncCounter(); } @Override public void exitDumbMode() { doIncCounter(); } }); }
public IncomingChangesViewProvider(final Project project, final MessageBus bus) { myProject = project; myBus = bus; myListConsumer = new Consumer<List<CommittedChangeList>>() { @Override public void consume(final List<CommittedChangeList> lists) { UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { myBrowser.getEmptyText().setText(VcsBundle.message("incoming.changes.empty.message")); myBrowser.setItems(lists, CommittedChangesBrowserUseCase.INCOMING); } }); } }; }
public OutdatedVersionNotifier(FileEditorManager fileEditorManager, CommittedChangesCache cache, MessageBus messageBus, Project project) { myFileEditorManager = fileEditorManager; myCache = cache; myProject = project; messageBus.connect().subscribe(CommittedChangesCache.COMMITTED_TOPIC, new CommittedChangesAdapter() { public void incomingChangesUpdated(@Nullable final List<CommittedChangeList> receivedChanges) { if (myCache.getCachedIncomingChanges() == null) { requestLoadIncomingChanges(); } else { updateAllEditorsLater(); } } @Override public void changesCleared() { updateAllEditorsLater(); } }); }
public PsiAwareFileEditorManagerImpl(final Project project, final PsiManager psiManager, final WolfTheProblemSolver problemSolver, DockManager dockManager, MessageBus messageBus, EditorHistoryManager editorHistoryManager) { super(project, dockManager, editorHistoryManager); myPsiManager = psiManager; myProblemSolver = problemSolver; myPsiTreeChangeListener = new MyPsiTreeChangeListener(); myProblemListener = new MyProblemListener(); registerExtraEditorDataProvider(new TextEditorPsiDataProvider(), null); // reinit syntax highlighter for Groovy. In power save mode keywords are highlighted by GroovySyntaxHighlighter insteadof // GrKeywordAndDeclarationHighlighter. So we need to drop caches for token types attributes in LayeredLexerEditorHighlighter messageBus.connect().subscribe(PowerSaveMode.TOPIC, new PowerSaveMode.Listener() { @Override public void powerSaveStateChanged() { for (Editor editor : EditorFactory.getInstance().getAllEditors()) { ((EditorEx)editor).reinitSettings(); } } }); }
protected ScratchFileServiceImpl(MessageBus messageBus) { myIndex = new LightDirectoryIndex<RootType>(messageBus.connect(), NULL_TYPE) { @Override protected void collectRoots(@NotNull PairConsumer<VirtualFile, RootType> consumer) { LocalFileSystem fileSystem = LocalFileSystem.getInstance(); for (RootType r : RootType.getAllRootIds()) { String root = getRootPath(r); VirtualFile rootFile = fileSystem.findFileByPath(root); if (rootFile != null) { consumer.consume(rootFile, r); } } } }; initFileOpenedListener(messageBus); }
public PyModuleListener(MessageBus messageBus) { messageBus.connect().subscribe(ProjectTopics.MODULES, new ModuleAdapter() { @Override public void beforeModuleRemoved(@NotNull Project project, @NotNull Module module) { final RunManagerEx runManager = RunManagerEx.getInstanceEx(project); final Collection<RunnerAndConfigurationSettings> configurations = new ArrayList<RunnerAndConfigurationSettings>(runManager.getSortedConfigurations()); for (RunnerAndConfigurationSettings configuration : configurations) { if (configuration.getConfiguration() instanceof AbstractPythonRunConfiguration) { final Module configModule = ((AbstractPythonRunConfiguration)configuration.getConfiguration()).getModule(); if (configModule == module) { runManager.removeConfiguration(configuration); } } } } }); }
@Override protected void executeChunked(@NotNull List<List<String>> chunkedCommits) throws HgCommandException, VcsException { if (chunkedCommits.isEmpty()) { executeQNew(ContainerUtil.<String>emptyList()); } else { int size = chunkedCommits.size(); int i = 0; if (!myAmend) { executeQNew(chunkedCommits.get(0)); i = 1; } for (; i < size; i++) { executeQRefresh(chunkedCommits.get(i)); } } myRepository.update(); final MessageBus messageBus = myProject.getMessageBus(); messageBus.syncPublisher(HgVcs.REMOTE_TOPIC).update(myProject, null); }
public void execute() throws HgCommandException, VcsException { if (StringUtil.isEmptyOrSpaces(myMessage)) { throw new HgCommandException(HgVcsMessages.message("hg4idea.commit.error.messageEmpty")); } if (myFiles.isEmpty()) { executeChunked(Collections.<List<String>>emptyList()); } else { List<String> relativePaths = ContainerUtil.map2List(myFiles, new Function<HgFile, String>() { @Override public String fun(HgFile file) { return file.getRelativePath(); } }); List<List<String>> chunkedCommits = VcsFileUtil.chunkRelativePaths(relativePaths); executeChunked(chunkedCommits); } myRepository.update(); final MessageBus messageBus = myProject.getMessageBus(); messageBus.syncPublisher(HgVcs.REMOTE_TOPIC).update(myProject, null); }
private void upgradeIfNeeded(final MessageBus bus) { final MessageBusConnection connection = bus.connect(); connection.subscribe(ChangeListManagerImpl.LISTS_LOADED, new LocalChangeListsLoadedListener() { @Override public void processLoadedLists(final List<LocalChangeList> lists) { if (lists.isEmpty()) return; try { ChangeListManager.getInstance(myProject).setReadOnly(SvnChangeProvider.ourDefaultListName, true); if (!myConfiguration.changeListsSynchronized()) { processChangeLists(lists); } } catch (ProcessCanceledException e) { // } finally { myConfiguration.upgrade(); } connection.disconnect(); } }); }
/** Constructor. */ public IntelliJListener(TrackingEventManager trackingEventManager, Project project) { this.trackingEventManager = trackingEventManager; this.project = project; parent = new Disposable() { @Override public void dispose() { // intentionally left empty } }; editorWindowListener = new EditorWindowListener(project.getName()); final MessageBus messageBus = ApplicationManager.getApplication().getMessageBus(); connection = messageBus.connect(); }
@Override public void beforeEach(ExtensionContext context) { IdeaMocksImpl ideaMocks = new IdeaMocksImpl(); Project project = mock(Project.class); MessageBus messageBus = mock(MessageBus.class); when(project.getMessageBus()).thenReturn(messageBus); when(messageBus.syncPublisher(any(Topic.class))).thenAnswer(invocation -> { Topic topic = invocation.getArgument(0); Class<?> listenerClass = topic.getListenerClass(); if (ideaMocks.hasMockListener(listenerClass)) { return ideaMocks.getMockListener(listenerClass); } else { return ideaMocks.mockListener(listenerClass); } }); Store store = context.getStore(NS); store.put(Project.class, project); store.put(MessageBus.class, messageBus); store.put(IdeaMocks.class, ideaMocks); }
public JavaFileManagerImpl(final PsiManagerEx manager, final ProjectRootManager projectRootManager, MessageBus bus, final StartupManager startupManager) { super(manager, projectRootManager, bus); myConnection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() { @Override public void fileWithNoDocumentChanged(@NotNull final VirtualFile file) { clearNonRepositoryMaps(); } }); startupManager.registerStartupActivity( new Runnable() { @Override public void run() { initialize(); } } ); }
public PsiModificationTrackerImpl(Project project) { final MessageBus bus = project.getMessageBus(); myPublisher = bus.syncPublisher(TOPIC); bus.connect().subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() { @Override public void enteredDumbMode() { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { incCounter(); } }); } @Override public void exitDumbMode() { enteredDumbMode(); } }); }
public ClasspathStorage(Module module) { myConverter = getProvider(ClassPathStorageUtil.getStorageType(module)).createConverter(module); final MessageBus messageBus = module.getMessageBus(); final VirtualFileTracker virtualFileTracker = (VirtualFileTracker)module.getPicoContainer().getComponentInstanceOfType(VirtualFileTracker.class); if (virtualFileTracker != null && messageBus != null) { final ArrayList<VirtualFile> files = new ArrayList<VirtualFile>(); try { myConverter.getFileSet().listFiles(files); for (VirtualFile file : files) { final Listener listener = messageBus.syncPublisher(STORAGE_TOPIC); virtualFileTracker.addTracker(file.getUrl(), new VirtualFileAdapter() { @Override public void contentsChanged(final VirtualFileEvent event) { listener.storageFileChanged(event, ClasspathStorage.this); } }, true, module); } } catch (UnsupportedOperationException e) { //UnsupportedStorageProvider doesn't mean any files } } }
private GitRootScanner(@NotNull Project project) { myRootProblemNotifier = GitRootProblemNotifier.getInstance(project); StartupManager.getInstance(project).runWhenProjectIsInitialized(new DumbAwareRunnable() { @Override public void run() { myProjectIsInitialized = true; scanIfReady(); } }); final MessageBus messageBus = project.getMessageBus(); messageBus.connect().subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, this); messageBus.connect().subscribe(VirtualFileManager.VFS_CHANGES, this); messageBus.connect().subscribe(ProjectTopics.PROJECT_ROOTS, this); myAlarm = new Alarm(Alarm.ThreadToUse.POOLED_THREAD, project); }
private void setupEventListeners() { ApplicationManager.getApplication().invokeLater(new Runnable(){ public void run() { // save file MessageBus bus = ApplicationManager.getApplication().getMessageBus(); connection = bus.connect(); connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new CustomSaveListener()); // edit document EditorFactory.getInstance().getEventMulticaster().addDocumentListener(new CustomDocumentListener()); // mouse press EditorFactory.getInstance().getEventMulticaster().addEditorMouseListener(new CustomEditorMouseListener()); // scroll document EditorFactory.getInstance().getEventMulticaster().addVisibleAreaListener(new CustomVisibleAreaListener()); } }); }
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(IdeFrame ideFrame) { connection.disconnect(); addRequest(request, delay); } }); } else { addRequest(request, delay); } }
public EditorFactoryImpl(EditorActionManager editorActionManager) { Application application = ApplicationManager.getApplication(); MessageBus bus = application.getMessageBus(); MessageBusConnection connect = bus.connect(); connect.subscribe(ProjectLifecycleListener.TOPIC, new ProjectLifecycleListener() { @Override public void beforeProjectLoaded(@Nonnull final Project project) { // validate all editors are disposed after fireProjectClosed() was called, because it's the place where editor should be released Disposer.register(project, () -> { final Project[] openProjects = ProjectManager.getInstance().getOpenProjects(); final boolean isLastProjectClosed = openProjects.length == 0; validateEditorsAreReleased(project, isLastProjectClosed); }); } }); ApplicationManager.getApplication().getMessageBus().connect().subscribe(EditorColorsManager.TOPIC, new EditorColorsListener() { @Override public void globalSchemeChange(EditorColorsScheme scheme) { refreshAllEditors(); } }); TypedAction typedAction = editorActionManager.getTypedAction(); TypedActionHandler originalHandler = typedAction.getRawHandler(); typedAction.setupRawHandler(new MyTypedHandler(originalHandler)); }
public void reinitComponents(@Nonnull Set<String> componentNames, @Nonnull Collection<String> notReloadableComponents, @Nonnull Collection<? extends StateStorage> changedStorages) { MessageBus messageBus = getMessageBus(); messageBus.syncPublisher(BatchUpdateListener.TOPIC).onBatchUpdateStarted(); try { for (String componentName : componentNames) { if (!notReloadableComponents.contains(componentName)) { reinitComponent(componentName, changedStorages); } } } finally { messageBus.syncPublisher(BatchUpdateListener.TOPIC).onBatchUpdateFinished(); } }
public PsiManagerImpl(Project project, FileDocumentManager fileDocumentManager, PsiBuilderFactory psiBuilderFactory, FileIndexFacade fileIndex, MessageBus messageBus, PsiModificationTracker modificationTracker) { myProject = project; myFileIndex = fileIndex; myMessageBus = messageBus; myModificationTracker = modificationTracker; //We need to initialize PsiBuilderFactory service so it won't initialize under PsiLock from ChameleonTransform @SuppressWarnings({"UnusedDeclaration", "UnnecessaryLocalVariable"}) Object used = psiBuilderFactory; myFileManager = new FileManagerImpl(this, fileDocumentManager, fileIndex); myTreeChangePreprocessors.add((PsiTreeChangePreprocessor)modificationTracker); Disposer.register(project, () -> myIsDisposed = true); }
public PsiModificationTrackerImpl(Project project) { MessageBus bus = project.getMessageBus(); myPublisher = bus.syncPublisher(TOPIC); bus.connect().subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() { private void doIncCounter() { ApplicationManager.getApplication().runWriteAction(() -> incCounter()); } @Override public void enteredDumbMode() { doIncCounter(); } @Override public void exitDumbMode() { doIncCounter(); } }); }
public static void _do(@Nonnull final ConfigurationError error, @Nonnull final Project project, @Nonnull final PairProcessor<ConfigurationErrors, ConfigurationError> fun) { if (!project.isInitialized()) { StartupManager.getInstance(project).runWhenProjectIsInitialized(new Runnable() { @Override public void run() { fun.process(project.getMessageBus().syncPublisher(TOPIC), error); } }); return; } final MessageBus bus = project.getMessageBus(); if (EventQueue.isDispatchThread()) fun.process(bus.syncPublisher(TOPIC), error); else { //noinspection SSBasedInspection SwingUtilities.invokeLater(new Runnable() { @Override public void run() { fun.process(bus.syncPublisher(TOPIC), error); } }); } }
public PsiDocumentManagerImpl(@Nonnull final Project project, @Nonnull PsiManager psiManager, @Nonnull EditorFactory editorFactory, @Nonnull MessageBus bus, @NonNls @Nonnull final DocumentCommitProcessor documentCommitThread) { super(project, psiManager, bus, documentCommitThread); myDocumentCommitThread = documentCommitThread; editorFactory.getEventMulticaster().addDocumentListener(this, project); MessageBusConnection connection = bus.connect(); connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new FileDocumentManagerAdapter() { @Override public void fileContentLoaded(@Nonnull final VirtualFile virtualFile, @Nonnull Document document) { PsiFile psiFile = ReadAction.compute(() -> myProject.isDisposed() || !virtualFile.isValid() ? null : getCachedPsiFile(virtualFile)); fireDocumentCreated(document, psiFile); } }); connection.subscribe(DocumentBulkUpdateListener.TOPIC, new DocumentBulkUpdateListener.Adapter() { @Override public void updateFinished(@Nonnull Document doc) { documentCommitThread.commitAsynchronously(project, doc, "Bulk update finished", TransactionGuard.getInstance().getContextTransaction()); } }); Disposer.register(project, () -> ((DocumentCommitThread)myDocumentCommitThread).cancelTasksOnProjectDispose(project)); }
public FindManagerImpl(Project project, FindSettings findSettings, UsageViewManager anotherManager, MessageBus bus) { myProject = project; myBus = bus; findSettings.initModelBySetings(myFindInProjectModel); myFindInFileModel.setCaseSensitive(findSettings.isLocalCaseSensitive()); myFindInFileModel.setWholeWordsOnly(findSettings.isLocalWholeWordsOnly()); myFindInFileModel.setRegularExpressions(findSettings.isLocalRegularExpressions()); myFindUsagesManager = new FindUsagesManager(myProject, anotherManager); myFindInProjectModel.setMultipleFiles(true); NotificationsConfigurationImpl.remove("FindInPath"); Disposer.register(project, new Disposable() { @Override public void dispose() { if (myHelper != null) { Disposer.dispose(myHelper); } } }); }
private void triggerConfigChange() { DataContext dataContext = DataManager.getInstance().getDataContextFromFocus().getResult(); Project project = DataKeys.PROJECT.getData(dataContext); if (project != null) { MessageBus messageBus = project.getMessageBus(); messageBus.connect(); ConfigChangeNotifier configChangeNotifier = messageBus.syncPublisher(ConfigChangeNotifier.CONFIG_TOPIC); configChangeNotifier.configChanged(activeCheckBox.isSelected()); } }
@Override public void initComponent() { logger.debug("Initializing component"); MessageBus bus = ApplicationManager.getApplication().getMessageBus(); connection = bus.connect(); connection.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, new TabHighlighterFileEditorListener()); }
private ExternalProjectRefreshCallback getRefreshDependenciesCbk(boolean quickScan, ProgressIndicator indicator) { return new ExternalProjectRefreshCallback() { @Override public void onSuccess(@Nullable DataNode<ProjectData> externalProject) { try { Components components = collectComponentsToScan(externalProject); scanAndCacheArtifacts(components, quickScan, indicator); scanResults = updateResultsTree(scanResults); setUiLicenses(); MessageBus messageBus = project.getMessageBus(); messageBus.syncPublisher(Events.ON_SCAN_COMPONENTS_CHANGE).update(); } catch (Exception e) { Utils.notify(logger, "JFrog Xray scan failed", e, NotificationType.ERROR); } } @Override public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) { String details; String title = "JFrog Xray scan failed"; if (errorDetails != null) { details = errorDetails; title += ": " + errorMessage; } else { details = errorMessage; } Utils.notify(logger, title, details, NotificationType.ERROR); } }; }