Search in sources :

Example 66 with MessageBusConnection

use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.

the class ProjectWideFacetListenersRegistryImpl method onModuleRemoved.

private void onModuleRemoved(final Module module) {
    final MessageBusConnection connection = myModule2Connection.remove(module);
    if (connection != null) {
        connection.disconnect();
    }
    final FacetManager facetManager = FacetManager.getInstance(module);
    final Facet[] facets = facetManager.getAllFacets();
    for (Facet facet : facets) {
        onFacetRemoved(facet, false);
    }
}
Also used : MessageBusConnection(com.intellij.util.messages.MessageBusConnection)

Example 67 with MessageBusConnection

use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.

the class FacetPointersManagerImpl method initComponent.

@Override
public void initComponent() {
    MessageBusConnection connection = myProject.getMessageBus().connect();
    connection.subscribe(ProjectTopics.MODULES, new ModuleListener() {

        @Override
        public void moduleAdded(@NotNull Project project, @NotNull Module module) {
            refreshPointers(module);
        }

        @Override
        public void modulesRenamed(@NotNull Project project, @NotNull List<Module> modules, @NotNull Function<Module, String> oldNameProvider) {
            for (Module module : modules) {
                refreshPointers(module);
            }
        }
    });
    connection.subscribe(FacetManager.FACETS_TOPIC, new FacetManagerAdapter() {

        @Override
        public void facetAdded(@NotNull Facet facet) {
            refreshPointers(facet.getModule());
        }

        @Override
        public void beforeFacetRenamed(@NotNull Facet facet) {
            final FacetPointerImpl pointer = myPointers.get(constructId(facet));
            if (pointer != null) {
                pointer.refresh();
            }
        }

        @Override
        public void facetRenamed(@NotNull final Facet facet, @NotNull final String oldName) {
            refreshPointers(facet.getModule());
        }
    });
    for (Module module : ModuleManager.getInstance(myProject).getModules()) {
        refreshPointers(module);
    }
}
Also used : Project(com.intellij.openapi.project.Project) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) ModuleListener(com.intellij.openapi.project.ModuleListener) Module(com.intellij.openapi.module.Module) FacetManagerAdapter(com.intellij.facet.FacetManagerAdapter) Facet(com.intellij.facet.Facet)

Example 68 with MessageBusConnection

use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.

the class RunDashboardManagerImpl method initToolWindowListeners.

private void initToolWindowListeners() {
    RunManagerEx.getInstanceEx(myProject).addRunManagerListener(new RunManagerListener() {

        @Override
        public void runConfigurationAdded(@NotNull RunnerAndConfigurationSettings settings) {
            updateDashboardIfNeeded(settings);
        }

        @Override
        public void runConfigurationRemoved(@NotNull RunnerAndConfigurationSettings settings) {
            updateDashboardIfNeeded(settings);
        }

        @Override
        public void runConfigurationChanged(@NotNull RunnerAndConfigurationSettings settings) {
            updateDashboardIfNeeded(settings);
        }
    });
    MessageBusConnection connection = myProject.getMessageBus().connect(myProject);
    connection.subscribe(ExecutionManager.EXECUTION_TOPIC, new ExecutionListener() {

        @Override
        public void processStarted(@NotNull String executorId, @NotNull ExecutionEnvironment env, @NotNull final ProcessHandler handler) {
            updateDashboardIfNeeded(env.getRunnerAndConfigurationSettings());
        }

        @Override
        public void processTerminated(@NotNull String executorId, @NotNull ExecutionEnvironment env, @NotNull ProcessHandler handler, int exitCode) {
            updateDashboardIfNeeded(env.getRunnerAndConfigurationSettings());
        }
    });
    connection.subscribe(RunDashboardManager.DASHBOARD_TOPIC, new DashboardListener() {

        @Override
        public void contentChanged(boolean withStructure) {
            updateDashboard(withStructure);
        }
    });
    connection.subscribe(DumbService.DUMB_MODE, new DumbService.DumbModeListener() {

        @Override
        public void enteredDumbMode() {
        }

        @Override
        public void exitDumbMode() {
            updateDashboard(false);
        }
    });
}
Also used : MessageBusConnection(com.intellij.util.messages.MessageBusConnection) ExecutionEnvironment(com.intellij.execution.runners.ExecutionEnvironment) DumbService(com.intellij.openapi.project.DumbService) ProcessHandler(com.intellij.execution.process.ProcessHandler)

Example 69 with MessageBusConnection

use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.

the class ProjectLevelVcsManagerImpl method addVcsListener.

@Override
public void addVcsListener(VcsListener listener) {
    MessageBusConnection connection = myProject.getMessageBus().connect();
    connection.subscribe(VCS_CONFIGURATION_CHANGED, listener);
    myAdapters.put(listener, connection);
}
Also used : MessageBusConnection(com.intellij.util.messages.MessageBusConnection)

Example 70 with MessageBusConnection

use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.

the class LocalFileSystemTest method doTestPartialRefresh.

public static void doTestPartialRefresh(@NotNull File top) throws IOException {
    File sub = IoTestUtil.createTestDir(top, "sub");
    File file1 = IoTestUtil.createTestFile(top, "file1.txt", ".");
    File file2 = IoTestUtil.createTestFile(sub, "file2.txt", ".");
    LocalFileSystem lfs = LocalFileSystem.getInstance();
    VirtualFile topDir = lfs.refreshAndFindFileByIoFile(top);
    assertNotNull(topDir);
    VirtualFile subDir = lfs.refreshAndFindFileByIoFile(sub);
    assertNotNull(subDir);
    VirtualFile vFile1 = lfs.refreshAndFindFileByIoFile(file1);
    assertNotNull(vFile1);
    VirtualFile vFile2 = lfs.refreshAndFindFileByIoFile(file2);
    assertNotNull(vFile2);
    topDir.refresh(false, true);
    Set<VirtualFile> processed = ContainerUtil.newHashSet();
    MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect();
    connection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() {

        @Override
        public void after(@NotNull List<? extends VFileEvent> events) {
            events.forEach(e -> processed.add(e.getFile()));
        }
    });
    try {
        IoTestUtil.updateFile(file1, "++");
        IoTestUtil.updateFile(file2, "++");
        ((NewVirtualFile) topDir).markDirtyRecursively();
        topDir.refresh(false, false);
        // vFile2 should stay unvisited after non-recursive refresh
        assertThat(processed).containsExactly(vFile1);
        processed.clear();
        topDir.refresh(false, true);
        // vFile2 changes should be picked up by a next recursive refresh
        assertThat(processed).containsExactly(vFile2);
    } finally {
        connection.disconnect();
    }
}
Also used : VfsRootAccess(com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess) java.util(java.util) WriteAction(com.intellij.openapi.application.WriteAction) ArrayUtil(com.intellij.util.ArrayUtil) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) FileAttributes(com.intellij.openapi.util.io.FileAttributes) ContainerUtil(com.intellij.util.containers.ContainerUtil) FileSystemUtil(com.intellij.openapi.util.io.FileSystemUtil) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) com.intellij.openapi.vfs.newvfs(com.intellij.openapi.vfs.newvfs) PersistentFSImpl(com.intellij.openapi.vfs.newvfs.persistent.PersistentFSImpl) VFileCreateEvent(com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent) FileUtil(com.intellij.openapi.util.io.FileUtil) VFileDeleteEvent(com.intellij.openapi.vfs.newvfs.events.VFileDeleteEvent) Path(java.nio.file.Path) VFileEvent(com.intellij.openapi.vfs.newvfs.events.VFileEvent) SimpleFileVisitor(java.nio.file.SimpleFileVisitor) RefreshWorker(com.intellij.openapi.vfs.newvfs.persistent.RefreshWorker) PlatformTestUtil(com.intellij.testFramework.PlatformTestUtil) Files(java.nio.file.Files) StringUtil(com.intellij.openapi.util.text.StringUtil) PlatformTestCase(com.intellij.testFramework.PlatformTestCase) PersistentFS(com.intellij.openapi.vfs.newvfs.persistent.PersistentFS) IOException(java.io.IOException) VirtualDirectoryImpl(com.intellij.openapi.vfs.newvfs.impl.VirtualDirectoryImpl) VFileContentChangeEvent(com.intellij.openapi.vfs.newvfs.events.VFileContentChangeEvent) SystemInfo(com.intellij.openapi.util.SystemInfo) File(java.io.File) FileVisitResult(java.nio.file.FileVisitResult) ApplicationManager(com.intellij.openapi.application.ApplicationManager) IoTestUtil(com.intellij.openapi.util.io.IoTestUtil) com.intellij.openapi.vfs(com.intellij.openapi.vfs) GeneralSettings(com.intellij.ide.GeneralSettings) VirtualFileSystemEntry(com.intellij.openapi.vfs.newvfs.impl.VirtualFileSystemEntry) ObjectUtils(com.intellij.util.ObjectUtils) NotNull(org.jetbrains.annotations.NotNull) MessageBusConnection(com.intellij.util.messages.MessageBusConnection) File(java.io.File)

Aggregations

MessageBusConnection (com.intellij.util.messages.MessageBusConnection)81 Project (com.intellij.openapi.project.Project)16 NotNull (org.jetbrains.annotations.NotNull)15 Module (com.intellij.openapi.module.Module)11 ModuleRootEvent (com.intellij.openapi.roots.ModuleRootEvent)10 ModuleListener (com.intellij.openapi.project.ModuleListener)8 ModuleRootListener (com.intellij.openapi.roots.ModuleRootListener)8 VirtualFile (com.intellij.openapi.vfs.VirtualFile)7 Disposable (com.intellij.openapi.Disposable)6 Document (com.intellij.openapi.editor.Document)6 VFileEvent (com.intellij.openapi.vfs.newvfs.events.VFileEvent)5 Update (com.intellij.util.ui.update.Update)5 ApplicationManager (com.intellij.openapi.application.ApplicationManager)4 StringUtil (com.intellij.openapi.util.text.StringUtil)4 ProcessHandler (com.intellij.execution.process.ProcessHandler)3 Application (com.intellij.openapi.application.Application)3 FileDocumentManagerAdapter (com.intellij.openapi.fileEditor.FileDocumentManagerAdapter)3 ModuleRootAdapter (com.intellij.openapi.roots.ModuleRootAdapter)3 VFileCreateEvent (com.intellij.openapi.vfs.newvfs.events.VFileCreateEvent)3 File (java.io.File)3