use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.
the class ExecutorRegistryImpl method initComponent.
@Override
public void initComponent() {
ProjectManager.getInstance().addProjectManagerListener(new ProjectManagerAdapter() {
@Override
public void projectOpened(final Project project) {
final MessageBusConnection connect = project.getMessageBus().connect(project);
connect.subscribe(ExecutionManager.EXECUTION_TOPIC, new ExecutionListener() {
@Override
public void processStartScheduled(@NotNull String executorId, @NotNull ExecutionEnvironment environment) {
myInProgress.add(createExecutionId(executorId, environment));
}
@Override
public void processNotStarted(@NotNull String executorId, @NotNull ExecutionEnvironment environment) {
myInProgress.remove(createExecutionId(executorId, environment));
}
@Override
public void processStarted(@NotNull String executorId, @NotNull ExecutionEnvironment environment, @NotNull ProcessHandler handler) {
myInProgress.remove(createExecutionId(executorId, environment));
}
});
}
@Override
public void projectClosed(final Project project) {
// perform cleanup
synchronized (myInProgress) {
for (Iterator<Trinity<Project, String, String>> it = myInProgress.iterator(); it.hasNext(); ) {
final Trinity<Project, String, String> trinity = it.next();
if (project.equals(trinity.first)) {
it.remove();
}
}
}
}
});
final Executor[] executors = Extensions.getExtensions(Executor.EXECUTOR_EXTENSION_NAME);
for (Executor executor : executors) {
initExecutor(executor);
}
}
use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.
the class NavBarListener method subscribeTo.
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);
WolfTheProblemSolver.getInstance(project).addProblemListener(listener);
ActionManager.getInstance().addAnActionListener(listener);
final MessageBusConnection connection = project.getMessageBus().connect();
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);
}
} else {
LafManager.getInstance().addLafManagerListener(listener);
}
}
use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.
the class JarDirectoryWatcherImpl method cleanup.
private void cleanup() {
if (!myWatchRequests.isEmpty()) {
LocalFileSystem.getInstance().removeWatchedRoots(myWatchRequests);
myWatchRequests = Collections.emptySet();
}
final MessageBusConnection connection = myBusConnection;
if (connection != null) {
myBusConnection = null;
connection.disconnect();
}
}
use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.
the class RootsChangedTest method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
MessageBusConnection connection = myProject.getMessageBus().connect(getTestRootDisposable());
myModuleRootListener = new MyModuleRootListener();
connection.subscribe(ProjectTopics.PROJECT_ROOTS, myModuleRootListener);
}
use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.
the class MultiModuleEditingTest method testAddTwoModules.
public void testAddTwoModules() throws Exception {
final MessageBusConnection connection = myProject.getMessageBus().connect();
final MyModuleListener moduleListener = new MyModuleListener();
connection.subscribe(ProjectTopics.MODULES, moduleListener);
final ModuleManager moduleManager = ModuleManager.getInstance(myProject);
final Module moduleA;
final Module moduleB;
{
final ModifiableModuleModel modifiableModel = moduleManager.getModifiableModel();
moduleA = modifiableModel.newModule("a.iml", StdModuleTypes.JAVA.getId());
moduleB = modifiableModel.newModule("b.iml", StdModuleTypes.JAVA.getId());
assertEquals("Changes are not applied until commit", 0, moduleManager.getModules().length);
//noinspection SSBasedInspection
moduleListener.assertCorrectEvents(new String[0][]);
ApplicationManager.getApplication().runWriteAction(modifiableModel::commit);
}
assertEquals(2, moduleManager.getModules().length);
assertTrue(moduleManager.findModuleByName("a").equals(moduleA));
assertTrue(moduleManager.findModuleByName("b").equals(moduleB));
moduleListener.assertCorrectEvents(new String[][] { { "+a", "+b" } });
{
final ModifiableModuleModel modifiableModel = moduleManager.getModifiableModel();
modifiableModel.disposeModule(moduleA);
modifiableModel.disposeModule(moduleB);
assertEquals("Changes are not applied until commit", 2, moduleManager.getModules().length);
moduleListener.assertCorrectEvents(new String[][] { { "+a", "+b" } });
ApplicationManager.getApplication().runWriteAction(modifiableModel::commit);
}
assertEquals(0, moduleManager.getModules().length);
moduleListener.assertCorrectEvents(new String[][] { { "+a", "+b" }, { "-a", "-b" } });
connection.disconnect();
}
Aggregations