Guest User

Untitled

a guest
Jul 7th, 2021
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.85 KB | None | 0 0
  1. package de.sist.gitlab.pipelinemonitor;
  2.  
  3. import com.intellij.openapi.progress.ProgressIndicator;
  4. import com.intellij.openapi.progress.ProgressManager;
  5. import com.intellij.openapi.progress.Task;
  6. import com.intellij.openapi.progress.impl.BackgroundableProcessIndicator;
  7. import com.intellij.openapi.project.Project;
  8. import com.intellij.util.concurrency.AppExecutorUtil;
  9. import org.jetbrains.annotations.NotNull;
  10.  
  11. import java.util.concurrent.TimeUnit;
  12.  
  13. public class ProgressBarReproductionService {
  14.  
  15.  
  16.     public ProgressBarReproductionService(Project project) {
  17.         AppExecutorUtil.getAppScheduledExecutorService().scheduleWithFixedDelay(() -> reproduceBackgroundProgressBarBug(project), 5, 5, TimeUnit.SECONDS);
  18.     }
  19.  
  20.     public void reproduceBackgroundProgressBarBug(Project project) {
  21.         Task.Backgroundable shortRunningTask = new Task.Backgroundable(project, "This progress bar doesn't go away", false) {
  22.             @Override
  23.             public void run(@NotNull ProgressIndicator indicator) {
  24.                 System.out.println("Doesn't go away");
  25.             }
  26.         };
  27.         ProgressManager.getInstance().runProcessWithProgressAsynchronously(shortRunningTask, new BackgroundableProcessIndicator(shortRunningTask));
  28.  
  29.         Task.Backgroundable longRunningTask = new Task.Backgroundable(project, "This progress bar does go away", false) {
  30.             @Override
  31.             public void run(@NotNull ProgressIndicator indicator) {
  32.                 try {
  33.                     System.out.println("Goes away");
  34.                     Thread.sleep(1000);
  35.                 } catch (InterruptedException e) {
  36.                     e.printStackTrace();
  37.                 }
  38.             }
  39.         };
  40.         ProgressManager.getInstance().runProcessWithProgressAsynchronously(longRunningTask, new BackgroundableProcessIndicator(shortRunningTask));
  41.     }
  42.  
  43.  
  44. }
  45.  
Add Comment
Please, Sign In to add comment