use of com.intellij.util.messages.MessageBusConnection in project android by JetBrains.
the class JavaFacet method initFacet.
@Override
public void initFacet() {
MessageBusConnection connection = getModule().getMessageBus().connect(this);
connection.subscribe(PROJECT_ROOTS, new ModuleRootListener() {
@Override
public void rootsChanged(ModuleRootEvent event) {
ApplicationManager.getApplication().invokeLater(() -> {
if (!isDisposed()) {
PsiDocumentManager.getInstance(getModule().getProject()).commitAllDocuments();
updateConfiguration();
}
});
}
});
updateConfiguration();
}
use of com.intellij.util.messages.MessageBusConnection in project android by JetBrains.
the class AndroidProjectComponent method projectOpened.
@Override
public void projectOpened() {
final CompilerManager manager = CompilerManager.getInstance(myProject);
manager.addBeforeTask(new AndroidPrecompileTask());
myDisposable = Disposer.newDisposable(getClass().getName());
if (!ApplicationManager.getApplication().isUnitTestMode() && !ApplicationManager.getApplication().isHeadlessEnvironment()) {
if (ProjectFacetManager.getInstance(myProject).hasFacets(AndroidFacet.ID)) {
createAndroidSpecificComponents();
} else {
final MessageBusConnection connection = myProject.getMessageBus().connect(myDisposable);
connection.subscribe(FacetManager.FACETS_TOPIC, new FacetManagerAdapter() {
@Override
public void facetAdded(@NotNull Facet facet) {
if (facet instanceof AndroidFacet) {
createAndroidSpecificComponents();
connection.disconnect();
}
}
});
}
}
}
use of com.intellij.util.messages.MessageBusConnection in project android by JetBrains.
the class DeveloperServices method initializeFor.
private static void initializeFor(@NotNull final Module module) {
if (ourServices.containsKey(module)) {
return;
}
for (DeveloperServiceCreators creators : DeveloperServiceCreators.EP_NAME.getExtensions()) {
try {
for (DeveloperServiceCreator creator : creators.getCreators()) {
DeveloperService service = creator.createService(module);
if (service != null) {
ourServices.put(module, service);
}
}
} catch (Exception e) {
LOG.warn("Caught exception while initializing services", e);
}
}
getBuildSystemOperations(module.getProject()).initializeServices(module, new Runnable() {
@Override
public void run() {
for (DeveloperService service : ourServices.get(module)) {
service.updateInstalledState();
}
}
});
MessageBusConnection connection = module.getMessageBus().connect(module);
connection.subscribe(ProjectTopics.MODULES, new ModuleListener() {
@Override
public void moduleRemoved(@NotNull Project project, @NotNull Module moduleRemoved) {
if (module == moduleRemoved) {
ourServices.removeAll(module);
}
}
});
}
use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.
the class CloudGitChooseAccountStepImpl method updateDataModel.
@Override
public void updateDataModel() {
super.updateDataModel();
final MultiMap<CloudGitProjectRoot, DetectedSourceRoot> project2sourceRoots = new MultiMap<>();
new RootIterator() {
CloudGitProjectRoot lastProjectRoot = null;
@Override
protected void processProjectRoot(CloudGitProjectRoot root) {
lastProjectRoot = root;
project2sourceRoots.put(lastProjectRoot, new ArrayList<>());
}
@Override
protected void processJavaSourceRoot(DetectedSourceRoot root) {
project2sourceRoots.putValue(lastProjectRoot, root);
}
}.iterate();
List<ModuleDescriptor> modules = new ArrayList<>(myProjectDescriptor.getModules());
for (Map.Entry<CloudGitProjectRoot, Collection<DetectedSourceRoot>> project2sourceRootsEntry : project2sourceRoots.entrySet()) {
final CloudGitProjectRoot projectRoot = project2sourceRootsEntry.getKey();
final File directory = projectRoot.getDirectory();
ModuleDescriptor moduleDescriptor = new ModuleDescriptor(directory, StdModuleTypes.JAVA, project2sourceRootsEntry.getValue());
final String applicationName = projectRoot.getApplicationName();
moduleDescriptor.addConfigurationUpdater(new ModuleBuilder.ModuleConfigurationUpdater() {
@Override
public void update(@NotNull final Module module, @NotNull ModifiableRootModel rootModel) {
final MessageBusConnection connection = module.getProject().getMessageBus().connect();
connection.subscribe(ProjectTopics.MODULES, new ModuleListener() {
@Override
public void moduleAdded(@NotNull Project project, @NotNull Module addedModule) {
if (addedModule == module) {
StartupManager.getInstance(project).runWhenProjectIsInitialized(() -> onModuleAdded(module));
connection.disconnect();
}
}
});
}
private void onModuleAdded(Module module) {
createRunConfiguration(module, applicationName);
GitInit.refreshAndConfigureVcsMappings(module.getProject(), projectRoot.getRepositoryRoot(), directory.getAbsolutePath());
}
});
modules.add(moduleDescriptor);
}
myProjectDescriptor.setModules(modules);
}
use of com.intellij.util.messages.MessageBusConnection in project intellij-community by JetBrains.
the class GitUntrackedFilesHolder method setupVfsListener.
void setupVfsListener(@NotNull Project project) {
if (!project.isDisposed()) {
MessageBusConnection connection = project.getMessageBus().connect(this);
connection.subscribe(VirtualFileManager.VFS_CHANGES, this);
}
}
Aggregations