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);
}
}
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);
}
}
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);
}
});
}
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);
}
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();
}
}
Aggregations