use of com.intellij.openapi.project.DumbAwareRunnable in project intellij-community by JetBrains.
the class MavenProjectsNavigator method doInit.
private void doInit() {
listenForProjectsChanges();
if (isUnitTestMode())
return;
MavenUtil.runWhenInitialized(myProject, new DumbAwareRunnable() {
@Override
public void run() {
if (myProject.isDisposed())
return;
initToolWindow();
}
});
}
use of com.intellij.openapi.project.DumbAwareRunnable in project intellij-community by JetBrains.
the class MvcModuleStructureSynchronizer method queue.
public void queue(SyncAction action, Object on) {
ApplicationManager.getApplication().assertIsDispatchThread();
if (myProject.isDisposed())
return;
boolean shouldSchedule;
synchronized (myOrders) {
shouldSchedule = myOrders.isEmpty();
myOrders.add(Pair.create(on, action));
}
if (shouldSchedule) {
StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new DumbAwareRunnable() {
@Override
public void run() {
scheduleRunActions();
}
});
}
}
use of com.intellij.openapi.project.DumbAwareRunnable in project intellij-community by JetBrains.
the class RepositoryLibrarySynchronizer method runActivity.
@Override
public void runActivity(@NotNull final Project project) {
StartupManager.getInstance(project).registerPostStartupActivity(new DumbAwareRunnable() {
@Override
public void run() {
ApplicationManager.getApplication().invokeLater(new DumbAwareRunnable() {
@Override
public void run() {
final Collection<Library> libraries = collectLibraries(project, new Predicate<Library>() {
@Override
public boolean apply(Library library) {
if (!(library instanceof LibraryEx)) {
return false;
}
LibraryEx libraryEx = (LibraryEx) library;
return libraryEx.getKind() == RepositoryLibraryType.REPOSITORY_LIBRARY_KIND && libraryEx.getProperties() instanceof RepositoryLibraryProperties && isLibraryNeedToBeReloaded(libraryEx, (RepositoryLibraryProperties) libraryEx.getProperties());
}
});
for (Library library : libraries) {
final LibraryEx libraryEx = (LibraryEx) library;
RepositoryUtils.reloadDependencies(project, libraryEx);
}
}
}, project.getDisposed());
}
});
}
use of com.intellij.openapi.project.DumbAwareRunnable in project intellij-community by JetBrains.
the class PyStudyShowTutorial method projectOpened.
@Override
public void projectOpened() {
ApplicationManager.getApplication().invokeLater(new DumbAwareRunnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new DumbAwareRunnable() {
@Override
public void run() {
if (PropertiesComponent.getInstance().getBoolean(ourShowPopup, true)) {
final String content = "<html>If you'd like to learn more about PyCharm Edu, " + "click <a href=\"https://www.jetbrains.com/pycharm-edu/quickstart/\">here</a> to watch a tutorial</html>";
final Notification notification = new Notification("Watch Tutorials!", "", content, NotificationType.INFORMATION, new NotificationListener.UrlOpeningListener(true));
Notifications.Bus.notify(notification);
Balloon balloon = notification.getBalloon();
if (balloon != null) {
balloon.addListener(new JBPopupAdapter() {
@Override
public void onClosed(LightweightWindowEvent event) {
notification.expire();
}
});
}
notification.whenExpired(() -> PropertiesComponent.getInstance().setValue(ourShowPopup, false, true));
}
}
});
}
});
}
use of com.intellij.openapi.project.DumbAwareRunnable in project intellij-community by JetBrains.
the class BraceHighlightingHandler method lookForInjectedAndMatchBracesInOtherThread.
static void lookForInjectedAndMatchBracesInOtherThread(@NotNull final Editor editor, @NotNull final Alarm alarm, @NotNull final Processor<BraceHighlightingHandler> processor) {
ApplicationManagerEx.getApplicationEx().assertIsDispatchThread();
if (!isValidEditor(editor))
return;
if (!PROCESSED_EDITORS.add(editor)) {
// Assuming to be in EDT here.
return;
}
final int offset = editor.getCaretModel().getOffset();
final Project project = editor.getProject();
final PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(editor, project);
if (!isValidFile(psiFile))
return;
ApplicationManager.getApplication().executeOnPooledThread(() -> {
if (!ApplicationManagerEx.getApplicationEx().tryRunReadAction(() -> {
final PsiFile injected;
try {
if (psiFile instanceof PsiBinaryFile || !isValidEditor(editor) || !isValidFile(psiFile)) {
injected = null;
} else {
injected = getInjectedFileIfAny(editor, project, offset, psiFile, alarm);
}
} catch (RuntimeException e) {
// Reset processing flag in case of unexpected exception.
ApplicationManager.getApplication().invokeLater(new DumbAwareRunnable() {
@Override
public void run() {
PROCESSED_EDITORS.remove(editor);
}
});
throw e;
}
ApplicationManager.getApplication().invokeLater(new DumbAwareRunnable() {
@Override
public void run() {
try {
if (isValidEditor(editor) && isValidFile(injected)) {
Editor newEditor = InjectedLanguageUtil.getInjectedEditorForInjectedFile(editor, injected);
BraceHighlightingHandler handler = new BraceHighlightingHandler(project, newEditor, alarm, injected);
processor.process(handler);
}
} finally {
PROCESSED_EDITORS.remove(editor);
}
}
}, ModalityState.stateForComponent(editor.getComponent()));
})) {
// write action is queued in AWT. restart after it's finished
ApplicationManager.getApplication().invokeLater(() -> {
PROCESSED_EDITORS.remove(editor);
lookForInjectedAndMatchBracesInOtherThread(editor, alarm, processor);
}, ModalityState.stateForComponent(editor.getComponent()));
}
});
}
Aggregations