use of com.intellij.openapi.application.ModalityState in project intellij-community by JetBrains.
the class HgRunConflictResolverDialog method onChangeRepository.
private void onChangeRepository() {
VirtualFile repo = repositorySelector.getRepository().getRoot();
HgResolveCommand command = new HgResolveCommand(project);
final ModalityState modalityState = ApplicationManager.getApplication().getModalityStateForComponent(getRootPane());
command.getListAsynchronously(repo, new Consumer<Map<HgFile, HgResolveStatusEnum>>() {
@Override
public void consume(Map<HgFile, HgResolveStatusEnum> status) {
final DefaultListModel model = new DefaultListModel();
for (Map.Entry<HgFile, HgResolveStatusEnum> entry : status.entrySet()) {
if (entry.getValue() == HgResolveStatusEnum.UNRESOLVED) {
model.addElement(entry.getKey().getRelativePath());
}
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
setOKActionEnabled(!model.isEmpty());
if (model.isEmpty()) {
model.addElement("No conflicts to resolve");
}
conflictsList.setModel(model);
}
}, modalityState);
}
});
}
use of com.intellij.openapi.application.ModalityState in project intellij-community by JetBrains.
the class RepositoryLoader method startLoadTask.
private void startLoadTask(@NotNull final Pair<RepositoryTreeNode, Expander> data) {
final ModalityState state = ModalityState.current();
ApplicationManager.getApplication().executeOnPooledThread(() -> ProgressManager.getInstance().runProcess(new LoadTask(data), new EmptyProgressIndicator(state)));
}
use of com.intellij.openapi.application.ModalityState in project intellij-community by JetBrains.
the class CompilerTask method addMessage.
public void addMessage(final CompilerMessage message) {
prepareMessageView();
final CompilerMessageCategory messageCategory = message.getCategory();
if (CompilerMessageCategory.WARNING.equals(messageCategory)) {
myWarningCount += 1;
} else if (CompilerMessageCategory.ERROR.equals(messageCategory)) {
myErrorCount += 1;
informWolf(message);
}
if (ApplicationManager.getApplication().isDispatchThread()) {
openMessageView();
doAddMessage(message);
} else {
final Window window = getWindow();
final ModalityState modalityState = window != null ? ModalityState.stateForComponent(window) : ModalityState.NON_MODAL;
ApplicationManager.getApplication().invokeLater(() -> {
if (myProject != null && !myProject.isDisposed()) {
openMessageView();
doAddMessage(message);
}
}, modalityState);
}
}
use of com.intellij.openapi.application.ModalityState in project intellij-community by JetBrains.
the class WaitForProgressToShow method runOrInvokeAndWaitAboveProgress.
public static void runOrInvokeAndWaitAboveProgress(final Runnable command, @Nullable final ModalityState modalityState) {
final Application application = ApplicationManager.getApplication();
if (application.isDispatchThread()) {
command.run();
} else {
final ProgressIndicator pi = ProgressManager.getInstance().getProgressIndicator();
if (pi != null) {
execute(pi);
application.invokeAndWait(command);
} else {
final ModalityState notNullModalityState = modalityState == null ? ModalityState.NON_MODAL : modalityState;
application.invokeAndWait(command, notNullModalityState);
}
}
}
use of com.intellij.openapi.application.ModalityState in project intellij-community by JetBrains.
the class WaitForProgressToShow method runOrInvokeLaterAboveProgress.
public static void runOrInvokeLaterAboveProgress(final Runnable command, @Nullable final ModalityState modalityState, @NotNull final Project project) {
final Application application = ApplicationManager.getApplication();
if (application.isDispatchThread()) {
command.run();
} else {
final ProgressIndicator pi = ProgressManager.getInstance().getProgressIndicator();
if (pi != null) {
execute(pi);
application.invokeLater(command, pi.getModalityState(), o -> (!project.isOpen()) || project.isDisposed());
} else {
final ModalityState notNullModalityState = modalityState == null ? ModalityState.NON_MODAL : modalityState;
application.invokeLater(command, notNullModalityState, project.getDisposed());
}
}
}
Aggregations