use of com.intellij.openapi.roots.ModuleRootListener in project intellij-community by JetBrains.
the class MavenMergingUpdateQueue method makeUserAware.
public void makeUserAware(final Project project) {
AccessToken accessToken = ReadAction.start();
try {
EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster();
multicaster.addCaretListener(new CaretAdapter() {
@Override
public void caretPositionChanged(CaretEvent e) {
MavenMergingUpdateQueue.this.restartTimer();
}
}, this);
multicaster.addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent event) {
MavenMergingUpdateQueue.this.restartTimer();
}
}, this);
project.getMessageBus().connect(this).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
int beforeCalled;
@Override
public void beforeRootsChange(ModuleRootEvent event) {
if (beforeCalled++ == 0) {
suspend();
}
}
@Override
public void rootsChanged(ModuleRootEvent event) {
if (beforeCalled == 0)
// This may occur if listener has been added between beforeRootsChange() and rootsChanged() calls.
return;
if (--beforeCalled == 0) {
resume();
MavenMergingUpdateQueue.this.restartTimer();
}
}
});
} finally {
accessToken.finish();
}
}
use of com.intellij.openapi.roots.ModuleRootListener in project intellij-community by JetBrains.
the class ExternalSystemProjectsWatcher method makeUserAware.
private static void makeUserAware(final MergingUpdateQueue mergingUpdateQueue, final Project project) {
AccessToken accessToken = ReadAction.start();
try {
EditorEventMulticaster multicaster = EditorFactory.getInstance().getEventMulticaster();
multicaster.addCaretListener(new CaretAdapter() {
@Override
public void caretPositionChanged(CaretEvent e) {
mergingUpdateQueue.restartTimer();
}
}, mergingUpdateQueue);
multicaster.addDocumentListener(new DocumentAdapter() {
@Override
public void documentChanged(DocumentEvent event) {
mergingUpdateQueue.restartTimer();
}
}, mergingUpdateQueue);
project.getMessageBus().connect(mergingUpdateQueue).subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
int beforeCalled;
@Override
public void beforeRootsChange(ModuleRootEvent event) {
if (beforeCalled++ == 0) {
mergingUpdateQueue.suspend();
}
}
@Override
public void rootsChanged(ModuleRootEvent event) {
if (beforeCalled == 0) {
// This may occur if listener has been added between beforeRootsChange() and rootsChanged() calls.
return;
}
if (--beforeCalled == 0) {
mergingUpdateQueue.resume();
mergingUpdateQueue.restartTimer();
}
}
});
} finally {
accessToken.finish();
}
}
use of com.intellij.openapi.roots.ModuleRootListener in project intellij-community by JetBrains.
the class LibraryDependentToolWindowManager method projectOpened.
@Override
public void projectOpened() {
final ModuleRootListener rootListener = new ModuleRootListener() {
@Override
public void rootsChanged(ModuleRootEvent event) {
if (!myProject.isDisposed()) {
checkToolWindowStatuses(myProject);
}
}
};
StartupManager.getInstance(myProject).runWhenProjectIsInitialized(() -> {
if (!myProject.isDisposed()) {
checkToolWindowStatuses(myProject);
final MessageBusConnection connection = myProject.getMessageBus().connect(myProject);
connection.subscribe(ProjectTopics.PROJECT_ROOTS, rootListener);
}
});
}
use of com.intellij.openapi.roots.ModuleRootListener in project intellij-plugins by JetBrains.
the class DartServerRootsHandler method ensureProjectServed.
public void ensureProjectServed() {
assert (myIncludedRoots.isEmpty());
assert (myExcludedRoots.isEmpty());
ProgressManager.getInstance().executeNonCancelableSection(() -> {
updateRoots();
final DartAnalysisServerService das = DartAnalysisServerService.getInstance(myProject);
das.updateCurrentFile();
das.updateVisibleFiles();
});
myProject.getMessageBus().connect().subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootListener() {
@Override
public void rootsChanged(final ModuleRootEvent event) {
updateRoots();
}
});
}
use of com.intellij.openapi.roots.ModuleRootListener 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();
}
Aggregations