com.intellij.ProjectTopics Java Examples
The following examples show how to use
com.intellij.ProjectTopics.
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: ProjectRootManagerComponent.java From consulo with Apache License 2.0 | 6 votes |
@Override public void beforeValidityChanged(@Nonnull VirtualFilePointer[] pointers) { if (!myProject.isDisposed()) { if (myInsideRefresh == 0) { if (affectsRoots(pointers)) { beforeRootsChange(false); if (myDoLogCachesUpdate) LOG.debug(new Throwable(pointers.length > 0 ? pointers[0].getPresentableUrl() : "")); } } else if (!myPointerChangesDetected) { //this is the first pointer changing validity if (affectsRoots(pointers)) { myPointerChangesDetected = true; myProject.getMessageBus().syncPublisher(ProjectTopics.PROJECT_ROOTS).beforeRootsChange(new ModuleRootEventImpl(myProject, false)); if (myDoLogCachesUpdate) LOG.debug(new Throwable(pointers.length > 0 ? pointers[0].getPresentableUrl() : "")); } } } }
Example #2
Source File: VcsEventWatcher.java From consulo with Apache License 2.0 | 6 votes |
@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 #3
Source File: ModuleVcsDetector.java From consulo with Apache License 2.0 | 6 votes |
@Override public void projectOpened() { if (ApplicationManager.getApplication().isUnitTestMode()) return; final StartupManager manager = StartupManager.getInstance(myProject); manager.registerStartupActivity(new Runnable() { @Override public void run() { if (myVcsManager.needAutodetectMappings()) { autoDetectVcsMappings(true); } myVcsManager.updateActiveVcss(); } }); manager.registerPostStartupActivity(new Runnable() { @Override public void run() { myConnection = myMessageBus.connect(); final MyModulesListener listener = new MyModulesListener(); myConnection.subscribe(ProjectTopics.MODULES, listener); myConnection.subscribe(ProjectTopics.PROJECT_ROOTS, listener); } }); }
Example #4
Source File: ModulesDependenciesPanel.java From consulo with Apache License 2.0 | 6 votes |
public ModulesDependenciesPanel(final Project project, final Module[] modules) { super(new BorderLayout()); myProject = project; myModules = modules; //noinspection HardCodedStringLiteral myRightTreeModel = new DefaultTreeModel(new DefaultMutableTreeNode("Root")); myRightTree = new Tree(myRightTreeModel); initTree(myRightTree, true); initLeftTree(); mySplitter = new Splitter(); mySplitter.setFirstComponent(new MyTreePanel(myLeftTree, myProject)); mySplitter.setSecondComponent(new MyTreePanel(myRightTree, myProject)); setSplitterProportion(); add(mySplitter, BorderLayout.CENTER); add(createNorthPanel(), BorderLayout.NORTH); project.getMessageBus().connect(this).subscribe(ProjectTopics.PROJECT_ROOTS, this); }
Example #5
Source File: AnalyzeDependenciesComponent.java From consulo with Apache License 2.0 | 6 votes |
/** * The constructor * * @param module the module to analyze */ public AnalyzeDependenciesComponent(Module module) { myModule = module; mySettings = AnalyzeDependenciesSettings.getInstance(myModule.getProject()); initTree(); init(); getSplitter().setProportion(0.3f); myMessageBusConnection = myModule.getProject().getMessageBus().connect(); myMessageBusConnection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() { @Override public void rootsChanged(ModuleRootEvent event) { myClasspaths.clear(); updateTree(); } }); }
Example #6
Source File: PushedFilePropertiesUpdaterImpl.java From consulo with Apache License 2.0 | 6 votes |
public PushedFilePropertiesUpdaterImpl(@Nonnull Project project) { myProject = project; if (project.isDefault()) { return; } project.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { @Override public void rootsChanged(@Nonnull ModuleRootEvent event) { if (LOG.isTraceEnabled()) { LOG.trace(new Throwable("Processing roots changed event (caused by file type change: " + event.isCausedByFileTypesChange() + ")")); } for (FilePropertyPusher<?> pusher : FilePropertyPusher.EP_NAME.getExtensionList()) { pusher.afterRootsChanged(project); } } }); }
Example #7
Source File: PushedFilePropertiesUpdaterImpl.java From consulo with Apache License 2.0 | 6 votes |
private void queueTasks(@Nonnull List<? extends Runnable> actions) { actions.forEach(myTasks::offer); DumbModeTask task = new DumbModeTask(this) { @Override public void performInDumbMode(@Nonnull ProgressIndicator indicator) { performPushTasks(); } }; myProject.getMessageBus().connect(task).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { @Override public void rootsChanged(@Nonnull ModuleRootEvent event) { DumbService.getInstance(myProject).cancelTask(task); } }); DumbService.getInstance(myProject).queueTask(task); }
Example #8
Source File: BaseCompilerTestCase.java From consulo with Apache License 2.0 | 6 votes |
@Override protected void setUp() throws Exception { super.setUp(); if (useExternalCompiler()) { myProject.getMessageBus().connect(myTestRootDisposable).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() { @Override public void rootsChanged(ModuleRootEvent event) { //todo[nik] projectOpened isn't called in tests so we need to add this listener manually forceFSRescan(); } }); // CompilerTestUtil.enableExternalCompiler(myProject); } else { // CompilerTestUtil.disableExternalCompiler(myProject); } }
Example #9
Source File: ProjectRootManagerComponent.java From consulo with Apache License 2.0 | 6 votes |
@Override public void beforeValidityChanged(@Nonnull VirtualFilePointer[] pointers) { if (myProject.isDisposed()) { return; } if (myInsideRefresh == 0) { beforeRootsChange(false); if (LOG_CACHES_UPDATE || LOG.isDebugEnabled()) { LOG.debug(new Throwable(pointers.length > 0 ? pointers[0].getPresentableUrl() : "")); } } else if (!myPointerChangesDetected) { //this is the first pointer changing validity myPointerChangesDetected = true; myProject.getMessageBus().syncPublisher(ProjectTopics.PROJECT_ROOTS).beforeRootsChange(new ModuleRootEventImpl(myProject, false)); if (LOG_CACHES_UPDATE || LOG.isDebugEnabled()) { LOG.debug(new Throwable(pointers.length > 0 ? pointers[0].getPresentableUrl() : "")); } } }
Example #10
Source File: RunManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Inject public RunManagerImpl(@Nonnull Project project, @Nonnull ProjectPropertiesComponent propertiesComponent) { myConfig = new RunManagerConfig(propertiesComponent); myProject = project; initializeConfigurationTypes(ConfigurationType.CONFIGURATION_TYPE_EP.getExtensions()); myProject.getMessageBus().connect(myProject).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() { @Override public void rootsChanged(ModuleRootEvent event) { RunnerAndConfigurationSettings configuration = getSelectedConfiguration(); if (configuration != null) { myIconCheckTimes.remove(configuration.getUniqueID());//cache will be expired } } }); }
Example #11
Source File: CSharpPartialElementManager.java From consulo-csharp with Apache License 2.0 | 6 votes |
@Inject public CSharpPartialElementManager(@Nonnull Project project) { myProject = project; project.getMessageBus().connect().subscribe(PsiManagerImpl.ANY_PSI_CHANGE_TOPIC, new AnyPsiChangeListener.Adapter() { @Override public void beforePsiChanged(boolean isPhysical) { myCache.clear(); } }); project.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() { @Override public void rootsChanged(ModuleRootEvent event) { myCache.clear(); } }); }
Example #12
Source File: PantsSystemProjectResolver.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
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 #13
Source File: ScopeTreeViewPanel.java From consulo with Apache License 2.0 | 5 votes |
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 #14
Source File: ProjectRootManagerComponent.java From consulo with Apache License 2.0 | 5 votes |
@Override public void writeActionFinished(@Nonnull Object action) { if (--myInsideRefresh == 0) { if (myPointerChangesDetected) { myPointerChangesDetected = false; myProject.getMessageBus().syncPublisher(ProjectTopics.PROJECT_ROOTS).rootsChanged(new ModuleRootEventImpl(myProject, false)); doSynchronizeRoots(); addRootsToWatch(); } } }
Example #15
Source File: ProjectRootManagerComponent.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void fireRootsChangedEvent(boolean fileTypes) { isFiringEvent = true; try { myProject.getMessageBus().syncPublisher(ProjectTopics.PROJECT_ROOTS).rootsChanged(new ModuleRootEventImpl(myProject, fileTypes)); } finally { isFiringEvent = false; } }
Example #16
Source File: ProjectRootManagerComponent.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void fireBeforeRootsChangeEvent(boolean fileTypes) { isFiringEvent = true; try { myProject.getMessageBus().syncPublisher(ProjectTopics.PROJECT_ROOTS).beforeRootsChange(new ModuleRootEventImpl(myProject, fileTypes)); } finally { isFiringEvent = false; } }
Example #17
Source File: PsiVFSListener.java From consulo with Apache License 2.0 | 5 votes |
@Inject public PsiVFSListener(@Nonnull Project project, Provider<ProjectFileIndex> fileIndex) { installGlobalListener(); myProject = project; myFileTypeManager = FileTypeManager.getInstance(); myFileIndex = fileIndex; myManager = (PsiManagerImpl)PsiManager.getInstance(project); myFileManager = (FileManagerImpl)myManager.getFileManager(); if (project.isDefault()) { return; } // events must handled only after pre-startup (https://upsource.jetbrains.com/intellij/review/IDEA-CR-47395) StartupManager.getInstance(project).registerPreStartupActivity(() -> { MessageBusConnection connection = project.getMessageBus().connect(); connection.subscribe(ProjectTopics.PROJECT_ROOTS, new MyModuleRootListener()); connection.subscribe(FileTypeManager.TOPIC, new FileTypeListener() { @Override public void fileTypesChanged(@Nonnull FileTypeEvent e) { myFileManager.processFileTypesChanged(e.getRemovedFileType() != null); } }); connection.subscribe(AppTopics.FILE_DOCUMENT_SYNC, new MyFileDocumentManagerAdapter()); }); }
Example #18
Source File: UnindexedFilesUpdater.java From consulo with Apache License 2.0 | 5 votes |
public UnindexedFilesUpdater(final Project project) { myProject = project; myPusher = PushedFilePropertiesUpdater.getInstance(myProject); project.getMessageBus().connect(this).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { @Override public void rootsChanged(@Nonnull ModuleRootEvent event) { DumbService.getInstance(project).cancelTask(UnindexedFilesUpdater.this); } }); }
Example #19
Source File: LogicalRootsManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@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 #20
Source File: ClasspathEditor.java From consulo with Apache License 2.0 | 5 votes |
public ClasspathEditor(final ModuleConfigurationState state) { super(state); final Disposable disposable = Disposable.newDisposable(); state.getProject().getMessageBus().connect(disposable).subscribe(ProjectTopics.PROJECT_ROOTS, this); registerDisposable(disposable); }
Example #21
Source File: NavBarListener.java From consulo with Apache License 2.0 | 5 votes |
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 #22
Source File: ProjectTreeBuilder.java From consulo with Apache License 2.0 | 5 votes |
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 #23
Source File: BitrixFramework.java From bxfs with MIT License | 5 votes |
@Override public void projectOpened() { // projectSourceRoots = ProjectRootManager.getInstance(project).getContentSourceRoots(); // for (VirtualFile resourceRoot : WebResourcesPathsConfiguration.getInstance(project).getResourceDirectories()) { // projectResourceRoots = Arrays.copyOf(projectResourceRoots, projectResourceRoots.length + 1); // projectResourceRoots[projectResourceRoots.length - 1] = resourceRoot; // } project.getMessageBus().connect(project).subscribe(ProjectTopics.PROJECT_ROOTS, this); /* Шаблоны страниц */ FileTemplateManager templateManager = FileTemplateManager.getInstance(project); for (String templateName : templates.keySet()) { if (null == templateManager.findInternalTemplate(templateName)) { Optional<String> content = getResourceFileContent( "fileTemplates/" + templates.get(templateName) + ".php.ft"); if (content.isPresent()) { FileTemplate template = templateManager.addTemplate(templateName, "php"); template.setText(content.get()); template.setReformatCode(true); } } } }
Example #24
Source File: VcsRootScanner.java From consulo with Apache License 2.0 | 5 votes |
private VcsRootScanner(@Nonnull Project project, @Nonnull List<VcsRootChecker> checkers) { myRootProblemNotifier = VcsRootProblemNotifier.getInstance(project); myCheckers = checkers; 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); }
Example #25
Source File: KnowledgeViewTreeBuilder.java From netbeans-mmd-plugin with Apache License 2.0 | 5 votes |
public KnowledgeViewTreeBuilder(@Nonnull Project project, @Nonnull JTree tree, @Nonnull DefaultTreeModel treeModel, @Nullable Comparator<NodeDescriptor> comparator, @Nonnull KnowledgeViewPanelTreeStructure treeStructure) { super(project, tree, treeModel, treeStructure, comparator); final MessageBusConnection connection = project.getMessageBus().connect(this); connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() { @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); WolfTheProblemSolver.getInstance(project).addProblemListener(new MyProblemListener(), this); setCanYieldUpdate(true); initRootNode(); }
Example #26
Source File: PantsProjectCache.java From intellij-pants-plugin with Apache License 2.0 | 5 votes |
private void listenForRootsChange() { if (myProject.isDefault() || !PantsUtil.isPantsProject(myProject)) { return; } final MessageBusConnection connection = myProject.getMessageBus().connect(this); connection.subscribe( ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { @Override public void rootsChanged(@NotNull ModuleRootEvent event) { myProjectRoots = null; } } ); }
Example #27
Source File: Unity3dProjectService.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@Inject Unity3dProjectService(Project project) { myProject = project; project.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { @Override public void rootsChanged(ModuleRootEvent event) { myValue.drop(); } }); }
Example #28
Source File: SetupUnitySDKProvider.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@Inject public SetupUnitySDKProvider(Project project, final EditorNotifications notifications) { myProject = project; myProject.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { @Override public void rootsChanged(ModuleRootEvent event) { notifications.updateAllNotifications(); } }); myProject.getMessageBus().connect().subscribe(ModuleExtension.CHANGE_TOPIC, (oldExtension, newExtension) -> notifications.updateAllNotifications()); }
Example #29
Source File: FileIsNotAttachedProvider.java From consulo-unity3d with Apache License 2.0 | 5 votes |
@Inject public FileIsNotAttachedProvider(Project project, final EditorNotifications notifications) { myProject = project; myProject.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() { @Override public void rootsChanged(ModuleRootEvent event) { notifications.updateAllNotifications(); } }); myProject.getMessageBus().connect().subscribe(ModuleExtension.CHANGE_TOPIC, (oldExtension, newExtension) -> notifications.updateAllNotifications()); }
Example #30
Source File: IgnoreManager.java From idea-gitignore with MIT License | 5 votes |
/** Enable manager. */ private void enable() { if (working) { return; } refreshTrackedIgnoredFeature.run(); virtualFileManager.addVirtualFileListener(virtualFileListener); settings.addListener(settingsListener); messageBus = project.getMessageBus().connect(); messageBus.subscribe(TRACKED_IGNORED_REFRESH, () -> debouncedRefreshTrackedIgnores.run(true)); messageBus.subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, () -> { ExternalIndexableSetContributor.invalidateCache(project); 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; }