myDetailsPanel = new DetailsPanel();
myDetailsPanel.loading();
myDetailsPanel.layout();
-
- myDetailsLoader = new GenericDetailsLoader<>(ticket -> {
- final Loader loader = new Loader(project, loadingTitle, myTicket.copy());
- loader.runSteadily(backgroundable -> myQueue.run(backgroundable));
- }, (ticket, t) -> acceptData(t));
+
+ myDetailsLoader = new GenericDetailsLoader<>(
+ ticket -> myQueue.run(new Loader(project, loadingTitle, myTicket.copy())),
+ (ticket, t) -> acceptData(t));
}
@Override
}
@Override
- protected void doInAwtIfFail(Exception e) {
+ protected void doInAwtIfFail(@NotNull Exception e) {
final Exception cause;
if (e instanceof RuntimeException && e.getCause() != null) {
cause = (Exception) e.getCause();
package com.intellij.util.continuation;
import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.progress.PerformInBackgroundOption;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
import com.intellij.openapi.project.Project;
-import com.intellij.util.Consumer;
-import com.intellij.util.TimeoutUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
-/**
- * Created by IntelliJ IDEA.
- * User: Irina.Chernushina
- * Date: 8/19/11
- * Time: 12:14 PM
- */
public abstract class ModalityIgnorantBackgroundableTask extends Task.Backgroundable {
- private final static Logger LOG = Logger.getInstance("#com.intellij.util.continuation.ModalityIgnorantBackgroundableTask");
- private Consumer<Task.Backgroundable> myRunner;
- private int myCnt;
-
- public ModalityIgnorantBackgroundableTask(@Nullable Project project,
- @NotNull String title,
- boolean canBeCancelled,
- @Nullable PerformInBackgroundOption backgroundOption) {
- super(project, title, canBeCancelled, backgroundOption);
- }
+ private final static Logger LOG = Logger.getInstance(ModalityIgnorantBackgroundableTask.class);
- public ModalityIgnorantBackgroundableTask(@Nullable Project project,
- @NotNull String title,
- boolean canBeCancelled) {
+ public ModalityIgnorantBackgroundableTask(@Nullable Project project, @NotNull String title, boolean canBeCancelled) {
super(project, title, canBeCancelled);
}
- public ModalityIgnorantBackgroundableTask(@Nullable Project project, @NotNull String title) {
- super(project, title);
- }
-
- protected abstract void doInAwtIfFail(final Exception e);
+ protected abstract void doInAwtIfFail(@NotNull Exception e);
protected abstract void doInAwtIfCancel();
protected abstract void doInAwtIfSuccess();
protected abstract void runImpl(@NotNull ProgressIndicator indicator);
- public void runSteadily(final Consumer<Backgroundable> consumer) {
- myRunner = consumer;
- myCnt = 100;
- consumer.consume(this);
- }
-
@Override
- public void run(@NotNull final ProgressIndicator indicator) {
+ public void run(@NotNull ProgressIndicator indicator) {
try {
runImpl(indicator);
- } catch (final ToBeRepeatedException tbre) {
- if (myRunner != null && myCnt > 0) {
- -- myCnt;
- // we are on some background thread and do not want to reschedule too often
- TimeoutUtil.sleep(100);
- myRunner.consume(this);
- return;
- }
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- doInAwtIfFail(tbre);
- }
- });
- } catch (final Exception e) {
+ }
+ catch (Exception e) {
LOG.info(e);
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- doInAwtIfFail(e);
- }
- });
+ SwingUtilities.invokeLater(() -> doInAwtIfFail(e));
return;
}
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- if (indicator.isCanceled()) {
- doInAwtIfCancel();
- } else {
- doInAwtIfSuccess();
- }
+ SwingUtilities.invokeLater(() -> {
+ if (indicator.isCanceled()) {
+ doInAwtIfCancel();
+ }
+ else {
+ doInAwtIfSuccess();
}
});
}
-
- public static class ToBeRepeatedException extends RuntimeException {}
}