use of com.intellij.openapi.project.DumbAwareRunnable in project intellij-community by JetBrains.
the class FileStatusManagerImpl method fileStatusChanged.
@Override
public void fileStatusChanged(final VirtualFile file) {
final Application application = ApplicationManager.getApplication();
if (!application.isDispatchThread() && !application.isUnitTestMode()) {
ApplicationManager.getApplication().invokeLater(new DumbAwareRunnable() {
@Override
public void run() {
fileStatusChanged(file);
}
});
return;
}
if (file == null || !file.isValid())
return;
FileStatus cachedStatus = getCachedStatus(file);
if (cachedStatus == FileStatusNull.INSTANCE) {
return;
}
if (cachedStatus == null) {
cacheChangedFileStatus(file, FileStatusNull.INSTANCE);
return;
}
FileStatus newStatus = calcStatus(file);
if (cachedStatus == newStatus)
return;
cacheChangedFileStatus(file, newStatus);
for (FileStatusListener listener : myListeners) {
listener.fileStatusChanged(file);
}
}
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()));
}
});
}
use of com.intellij.openapi.project.DumbAwareRunnable in project intellij-community by JetBrains.
the class ExternalDependenciesManagerImpl method loadState.
@Override
public void loadState(ExternalDependenciesState state) {
ArrayList<ProjectExternalDependency> oldDependencies = new ArrayList<>(myDependencies);
myDependencies.clear();
for (DependencyOnPluginState dependency : state.myDependencies) {
myDependencies.add(new DependencyOnPlugin(dependency.myId, dependency.myMinVersion, dependency.myMaxVersion, dependency.myChannel));
}
if (!oldDependencies.equals(myDependencies) && !myDependencies.isEmpty()) {
StartupManager.getInstance(myProject).runWhenProjectIsInitialized(new DumbAwareRunnable() {
@Override
public void run() {
CheckRequiredPluginsActivity.runCheck(myProject);
}
});
}
}
use of com.intellij.openapi.project.DumbAwareRunnable in project intellij-community by JetBrains.
the class PlatformProjectViewOpener method configureProject.
@Override
public void configureProject(final Project project, @NotNull final VirtualFile baseDir, Ref<Module> moduleRef) {
ToolWindowManagerEx manager = (ToolWindowManagerEx) ToolWindowManager.getInstance(project);
ToolWindow toolWindow = manager.getToolWindow(ToolWindowId.PROJECT_VIEW);
if (toolWindow == null) {
manager.addToolWindowManagerListener(new MyListener(manager, project));
} else {
StartupManager.getInstance(project).runWhenProjectIsInitialized(new DumbAwareRunnable() {
@Override
public void run() {
activateProjectToolWindow(project, toolWindow);
}
});
}
}
use of com.intellij.openapi.project.DumbAwareRunnable in project intellij-community by JetBrains.
the class NotificationsManagerImpl method doNotify.
private static void doNotify(@NotNull final Notification notification, @Nullable NotificationDisplayType displayType, @Nullable final Project project) {
final NotificationsConfigurationImpl configuration = NotificationsConfigurationImpl.getInstanceImpl();
if (!configuration.isRegistered(notification.getGroupId())) {
configuration.register(notification.getGroupId(), displayType == null ? NotificationDisplayType.BALLOON : displayType);
}
final NotificationSettings settings = NotificationsConfigurationImpl.getSettings(notification.getGroupId());
boolean shouldLog = settings.isShouldLog();
boolean displayable = settings.getDisplayType() != NotificationDisplayType.NONE;
boolean willBeShown = displayable && NotificationsConfigurationImpl.getInstanceImpl().SHOW_BALLOONS;
if (!shouldLog && !willBeShown) {
notification.expire();
}
if (NotificationsConfigurationImpl.getInstanceImpl().SHOW_BALLOONS) {
final Runnable runnable = new DumbAwareRunnable() {
@Override
public void run() {
showNotification(notification, project);
}
};
if (project == null) {
UIUtil.invokeLaterIfNeeded(runnable);
} else if (!project.isDisposed()) {
StartupManager.getInstance(project).runWhenProjectIsInitialized(runnable);
}
}
}
Aggregations