use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.
the class LocalFileSystemTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
MessageBusConnection connection = ApplicationManager.getApplication().getMessageBus().connect(getTestRootDisposable());
connection.subscribe(VirtualFileManager.VFS_CHANGES, new BulkFileListener() {
@Override
public void before(@NotNull List<? extends VFileEvent> events) {
checkFiles(events, true);
}
@Override
public void after(@NotNull List<? extends VFileEvent> events) {
checkFiles(events, false);
}
private void checkFiles(List<? extends VFileEvent> events, boolean before) {
for (VFileEvent event : events) {
VirtualFile file = event.getFile();
if (file != null) {
boolean shouldBeInvalid = event instanceof VFileCreateEvent && before && !((VFileCreateEvent) event).isReCreation() || event instanceof VFileDeleteEvent && !before;
assertEquals(event.toString(), !shouldBeInvalid, file.isValid());
}
}
}
});
myFS = LocalFileSystem.getInstance();
}
use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.
the class NavBarListener method unsubscribeFrom.
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);
WolfTheProblemSolver.getInstance(project).removeProblemListener(listener);
ActionManager.getInstance().removeAnActionListener(listener);
final MessageBusConnection connection = (MessageBusConnection) panel.getClientProperty(BUS);
panel.putClientProperty(BUS, null);
if (connection != null) {
connection.disconnect();
}
LafManager.getInstance().removeLafManagerListener(listener);
}
}
use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.
the class Alarm method addRequest.
public void addRequest(@NotNull 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.Adapter() {
@Override
public void applicationActivated(IdeFrame ideFrame) {
connection.disconnect();
addRequest(request, delay);
}
});
} else {
addRequest(request, delay);
}
}
use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.
the class MessageListenerList method add.
public void add(@NotNull T listener) {
final MessageBusConnection connection = myMessageBus.connect();
connection.subscribe(myTopic, listener);
myListenerToConnectionMap.put(listener, connection);
}
use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.
the class GitLogProvider method subscribeToRootRefreshEvents.
@NotNull
@Override
public Disposable subscribeToRootRefreshEvents(@NotNull final Collection<VirtualFile> roots, @NotNull final VcsLogRefresher refresher) {
MessageBusConnection connection = myProject.getMessageBus().connect(myProject);
connection.subscribe(GitRepository.GIT_REPO_CHANGE, repository -> {
VirtualFile root = repository.getRoot();
if (roots.contains(root)) {
refresher.refresh(root);
}
});
return connection;
}
Aggregations