com.intellij.openapi.progress.util.ProgressWindow Java Examples

The following examples show how to use com.intellij.openapi.progress.util.ProgressWindow. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UploadExerciseAction.java    From tmc-intellij with MIT License 6 votes vote down vote up
public void uploadExercise(Project project) {

        new ButtonInputListener().receiveSubmit();

        ProgressWindow window =
                ProgressWindowMaker.make(
                        "Uploading exercise, this may take several minutes",
                        project,
                        true,
                        true,
                        true);
        CoreProgressObserver observer = new CoreProgressObserver(window);
        FileDocumentManager.getInstance().saveAllDocuments();

        callExerciseUploadService(project, observer, window);
    }
 
Example #2
Source File: UploadExerciseAction.java    From tmc-intellij with MIT License 6 votes vote down vote up
private void callExerciseUploadService(
        Project project, CoreProgressObserver observer, ProgressWindow window) {

    new ExerciseUploadingService()
            .startUploadExercise(
                    project,
                    TmcCoreHolder.get(),
                    new ObjectFinder(),
                    new CheckForExistingExercises(),
                    new SubmissionResultHandler(),
                    TmcSettingsManager.get(),
                    new CourseAndExerciseManager(),
                    new ThreadingService(),
                    new TestRunningService(),
                    observer,
                    window);
}
 
Example #3
Source File: DownloadExerciseAction.java    From tmc-intellij with MIT License 6 votes vote down vote up
private void startDownloadExercise(Project project, boolean downloadAll) throws Exception {
    ProgressWindow window =
            ProgressWindowMaker.make(
                    "Downloading exercises, this may take several minutes",
                    project,
                    true,
                    true,
                    true);
    ExerciseDownloadingService
            .startDownloadExercise(
                    TmcCoreHolder.get(),
                    TmcSettingsManager.get(),
                    new CheckForExistingExercises(),
                    new ObjectFinder(),
                    new ThreadingService(),
                    project,
                    downloadAll,
                    window);
}
 
Example #4
Source File: TestRunningService.java    From tmc-intellij with MIT License 6 votes vote down vote up
public void runTests(
        final Exercise exercise,
        Project project,
        ThreadingService threadingService,
        ObjectFinder finder) {
    logger.info("Starting to run tests for current project. @TestRunningService");

    ProgressWindow window =
            ProgressWindowMaker.make("Running tests", project, true, true, true);
    CoreProgressObserver observer = new CoreProgressObserver(window);

    if (exercise != null) {
        prepareThreadForRunningTests(
                exercise, project, threadingService, finder, window, observer);
    } else {
        Exception exception = new Exception();
        logger.warn(
                "Running tests failed, exercise {} was not "
                        + "recognized. @TestRunningService",
                exercise,
                exception);
        new ErrorMessageService()
                .showErrorMessageWithExceptionDetails(
                        exception, "Running tests failed, exercise was not recognized", true);
    }
}
 
Example #5
Source File: DiffViewerBase.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
public void rediff(boolean trySync) {
  if (isDisposed()) return;
  abortRediff();

  fireEvent(EventType.BEFORE_REDIFF);
  onBeforeRediff();

  boolean forceEDT = forceRediffSynchronously();
  int waitMillis = trySync || tryRediffSynchronously() ? ProgressWindow.DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS : 0;

  myTaskExecutor.executeAndTryWait(
          indicator -> {
            final Runnable callback = performRediff(indicator);
            return () -> {
              callback.run();
              onAfterRediff();
              fireEvent(EventType.AFTER_REDIFF);
            };
          },
          this::onSlowRediff, waitMillis, forceEDT
  );
}
 
Example #6
Source File: ExerciseDownloadingService.java    From tmc-intellij with MIT License 6 votes vote down vote up
public static void startDownloadExercise(
        final TmcCore core,
        final SettingsTmc settings,
        final CheckForExistingExercises checker,
        ObjectFinder objectFinder,
        ThreadingService threadingService,
        Project project,
        boolean downloadAll,
        ProgressWindow window) {

    logger.info(
            "Preparing to start checking for available exercises."
                    + "@ExerciseDownloadingService");
    Thread run = checkAvailableExercises(core, settings, checker, objectFinder, downloadAll);
    threadingService.runWithNotification(run, project, window);
}
 
Example #7
Source File: ANTLRv4PluginController.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public void parseText(final VirtualFile grammarFile, String inputText) {
	// Wipes out the console and also any error annotations
	previewPanel.inputPanel.clearParseErrors();

	final PreviewState previewState = getPreviewState(grammarFile);

	abortCurrentParsing();

	// Parse text in a background thread to avoid freezing the UI if the grammar is badly written
	// an takes ages to interpret the input.
	parsingProgressIndicator = BackgroundTaskUtil.executeAndTryWait(
			(indicator) -> {
				long start = System.nanoTime();

				previewState.parsingResult = ParsingUtils.parseText(
						previewState.g, previewState.lg, previewState.startRuleName,
						grammarFile, inputText, project
				);

				return () -> previewPanel.onParsingCompleted(previewState, System.nanoTime() - start);
			},
			() -> previewPanel.notifySlowParsing(),
			ProgressWindow.DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS,
			false
	);
}
 
Example #8
Source File: ProjectListWindow.java    From tmc-intellij with MIT License 6 votes vote down vote up
@NotNull
private JButton addFunctionalityToRefreshButton() {
    logger.info("Adding functionality to refresh projects button. "
            + "@ProjectListWindow");
    JButton refreshButton = new JButton(TmcIcons.REFRESH);
    refreshButton.setBorderPainted(true);
    refreshButton.setEnabled(true);

    ProgressWindow window = ProgressWindowMaker.make("Refreshing project list",
            new ObjectFinder().findCurrentProject(), false, true, true);

    refreshButton.addActionListener(actionEvent -> {
        ThreadingService threadingService = new ThreadingService();
        threadingService.runWithNotification(
                new Thread(() -> refreshProjectList()),
                new ObjectFinder().findCurrentProject(),
                window);
    });

    return refreshButton;
}
 
Example #9
Source File: FormatUtils.java    From intellij with Apache License 2.0 6 votes vote down vote up
/** Runs a format future under a progress dialog. */
public static void formatWithProgressDialog(
    Project project, String title, ListenableFuture<?> future) {
  ProgressWindow progressWindow =
      new BackgroundableProcessIndicator(
          project, title, PerformInBackgroundOption.DEAF, "Cancel", "Cancel", true);
  progressWindow.setIndeterminate(true);
  progressWindow.start();
  progressWindow.addStateDelegate(
      new AbstractProgressIndicatorExBase() {
        @Override
        public void cancel() {
          super.cancel();
          future.cancel(true);
        }
      });
  future.addListener(
      () -> {
        if (progressWindow.isRunning()) {
          progressWindow.stop();
          progressWindow.processFinish();
        }
      },
      MoreExecutors.directExecutor());
}
 
Example #10
Source File: PendingAsyncTestContext.java    From intellij with Apache License 2.0 5 votes vote down vote up
/**
 * Waits for the run configuration to be configured, displaying a progress dialog if necessary.
 *
 * @throws com.intellij.execution.ExecutionException if the run configuration is not successfully
 *     configured
 */
private void waitForFutureUnderProgressDialog(Project project)
    throws com.intellij.execution.ExecutionException {
  if (future.isDone()) {
    getFutureHandlingErrors();
  }
  // The progress indicator must be created on the UI thread.
  ProgressWindow indicator =
      UIUtil.invokeAndWaitIfNeeded(
          () ->
              new BackgroundableProcessIndicator(
                  project,
                  progressMessage,
                  PerformInBackgroundOption.ALWAYS_BACKGROUND,
                  "Cancel",
                  "Cancel",
                  /* cancellable= */ true));

  indicator.setIndeterminate(true);
  indicator.start();
  indicator.addStateDelegate(
      new AbstractProgressIndicatorExBase() {
        @Override
        public void cancel() {
          super.cancel();
          future.cancel(true);
        }
      });
  try {
    getFutureHandlingErrors();
  } finally {
    if (indicator.isRunning()) {
      indicator.stop();
      indicator.processFinish();
    }
  }
}
 
Example #11
Source File: DesktopProgressDialogFactory.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public ProgressDialog create(ProgressWindow progressWindow, boolean shouldShowBackground, JComponent parentComponent, Project project, String cancelText) {
  Component parent = parentComponent;
  if (parent == null && project == null && !myApplication.isHeadlessEnvironment()) {
    parent = JOptionPane.getRootFrame();
  }

  return parent == null
         ? new com.intellij.openapi.progress.util.ProgressDialog(progressWindow, shouldShowBackground, project, cancelText)
         : new com.intellij.openapi.progress.util.ProgressDialog(progressWindow, shouldShowBackground, parent, cancelText);
}
 
Example #12
Source File: CacheChangeProcessor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@CalledInAwt
public void updateRequest(final boolean force, boolean useCache, @javax.annotation.Nullable final ScrollToPolicy scrollToChangePolicy) {
  if (isDisposed()) return;
  final Change change = myCurrentChange;

  DiffRequest cachedRequest = loadRequestFast(change, useCache);
  if (cachedRequest != null) {
    applyRequest(cachedRequest, force, scrollToChangePolicy);
    return;
  }

  // TODO: check if current loading change is the same as we want to load now? (and not interrupt loading)
  myQueue.executeAndTryWait(
          new Function<ProgressIndicator, Runnable>() {
            @Override
            public Runnable fun(ProgressIndicator indicator) {
              final DiffRequest request = loadRequest(change, indicator);
              return new Runnable() {
                @Override
                @CalledInAwt
                public void run() {
                  myRequestCache.put(change, Pair.create(change, request));
                  applyRequest(request, force, scrollToChangePolicy);
                }
              };
            }
          },
          new Runnable() {
            @Override
            public void run() {
              applyRequest(new LoadingDiffRequest(ChangeDiffRequestProducer.getRequestTitle(change)), force, scrollToChangePolicy);
            }
          },
          ProgressWindow.DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS
  );
}
 
Example #13
Source File: CacheDiffRequestProcessor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
public void updateRequest(final boolean force, boolean useCache, @Nullable final ScrollToPolicy scrollToChangePolicy) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  if (isDisposed()) return;

  final T requestProvider = getCurrentRequestProvider();
  if (requestProvider == null) {
    applyRequest(NoDiffRequest.INSTANCE, force, scrollToChangePolicy);
    return;
  }

  DiffRequest cachedRequest = useCache ? loadRequestFast(requestProvider) : null;
  if (cachedRequest != null) {
    applyRequest(cachedRequest, force, scrollToChangePolicy);
    return;
  }

  myQueue.executeAndTryWait(indicator -> {
    final DiffRequest request = doLoadRequest(requestProvider, indicator);
    return () -> {
      myRequestCache.put(requestProvider, request);
      applyRequest(request, force, scrollToChangePolicy);
    };
  }, () -> {
    applyRequest(new LoadingDiffRequest(getRequestName(requestProvider)), force, scrollToChangePolicy);
  }, ProgressWindow.DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS);
}
 
Example #14
Source File: DiffViewerBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
public final void scheduleRediff() {
  if (isDisposed()) return;

  abortRediff();
  myTaskAlarm.addRequest(this::rediff, ProgressWindow.DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS);
}
 
Example #15
Source File: TextMergeViewer.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
private void schedule() {
  if (myProgress != null) return;
  if (myScheduled.isEmpty()) return;

  myAlarm.cancelAllRequests();
  myAlarm.addRequest(this::launchRediff, ProgressWindow.DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS);
}
 
Example #16
Source File: ProgressHelper.java    From PackageTemplates with Apache License 2.0 5 votes vote down vote up
public static void runProcessWithProgress(Project project, Runnable runnable) {
        ProgressWindow progressIndicator = new ProgressWindow(false, project);
        progressIndicator.setIndeterminate(true);

        runSync(project, runnable);
//        runAsync(project, runnable, progressIndicator);
    }
 
Example #17
Source File: UploadExerciseServiceTest.java    From tmc-intellij with MIT License 5 votes vote down vote up
@Test
public void afterUploadingExercisesTheCourseIsUpdated() {
    CheckForExistingExercises checker = mock(CheckForExistingExercises.class);
    ThreadingService threadingService = mock(ThreadingService.class);
    Course course = new Course("home");
    Exercise exercise = new Exercise("user");

    SettingsTmc settings = mock(SettingsTmc.class);
    when(settings.getToken()).thenReturn(Optional.of("token"));

    Project project = mock(Project.class);
    when(project.getBasePath()).thenReturn("/home/user");

    CourseAndExerciseManager mockCourseAndExerciseManager = mock(CourseAndExerciseManager.class);
    when(mockCourseAndExerciseManager.isCourseInDatabase(null)).thenReturn(true);
    when(mockCourseAndExerciseManager.getExercise(null, exercise.getName())).thenReturn(exercise);

    ProgressWindow window = mock(ProgressWindow.class);
    CoreProgressObserver observer = mock(CoreProgressObserver.class);

    ObjectFinder finder = mock(ObjectFinder.class);
    when(finder.findCourse("home", "name")).thenReturn(course);

    new ExerciseUploadingService().startUploadExercise(project, mock(TmcCore.class), finder, checker,
            mock(SubmissionResultHandler.class), settings,
            mockCourseAndExerciseManager, threadingService, mock(TestRunningService.class),
            observer, window);

    verify(threadingService).runWithNotification(any(Runnable.class), any(Project.class), any(ProgressWindow.class));
    verify(mockCourseAndExerciseManager).updateSingleCourse(null,
            checker, finder, settings);
}
 
Example #18
Source File: ExerciseDownloadingService.java    From tmc-intellij with MIT License 5 votes vote down vote up
public static void startDownloading(List<Exercise> exercises) {
    logger.info("Preparing to start downloading exercises. @ExerciseDownloadingService");
    ProgressWindow window =
            ProgressWindowMaker.make(
                    "Downloading exercises, this may take a while",
                    new ObjectFinder().findCurrentProject(),
                    true,
                    true,
                    false);
    CoreProgressObserver observer = new CoreProgressObserver(window);
    Thread run = downloadSelectedExercises(TmcCoreHolder.get(), exercises, observer);
    ThreadingService threadingService = new ThreadingService();
    Project project = new ObjectFinder().findCurrentProject();
    threadingService.runWithNotification(run, project, window);
}
 
Example #19
Source File: ProgressWindowMaker.java    From tmc-intellij with MIT License 5 votes vote down vote up
public static ProgressWindow make(
        String title,
        Project project,
        boolean cancelable,
        boolean hidable,
        boolean indeterminate) {
    logger.info("Creating progress window. @ProgressWindowMaker");
    ProgressWindow progressWindow = new ProgressWindow(cancelable, hidable, project);
    progressWindow.setIndeterminate(indeterminate);
    progressWindow.setTitle(title);
    progressWindow.setDelayInMillis(500);

    return progressWindow;
}
 
Example #20
Source File: ThreadingService.java    From tmc-intellij with MIT License 5 votes vote down vote up
public void runWithNotification(
        final Runnable run, Project project, ProgressWindow progressWindow) {
    logger.info("Processing runWithNotification. @ThreadingService");

    ApplicationManager.getApplication()
            .executeOnPooledThread(
                    () -> ProgressManager.getInstance().runProcess(run, progressWindow));
}
 
Example #21
Source File: ProgressHelper.java    From PackageTemplates with Apache License 2.0 4 votes vote down vote up
private static void runAsync(Project project, Runnable runnable, ProgressWindow progressIndicator) {
    ProgressManager.getInstance().runProcessWithProgressAsynchronously(
            new RunnableBackgroundableWrapper(project, "Executing PackageTemplate", runnable), progressIndicator);
}
 
Example #22
Source File: ProgressiveTaskWithProgressIndicator.java    From intellij with Apache License 2.0 4 votes vote down vote up
/**
 * Runs the given task on the specified executor (defaulting to BlazeExecutor's executor) with a
 * progress dialog.
 */
public <T> ListenableFuture<T> submitTaskWithResult(ProgressiveWithResult<T> progressive) {
  // The progress indicator must be created on the UI thread.
  final ProgressWindow indicator =
      UIUtil.invokeAndWaitIfNeeded(
          () -> {
            if (modality == Modality.MODAL) {
              ProgressWindow window = new ProgressWindow(cancelable, project);
              window.setTitle(title);
              return window;
            } else {
              PerformInBackgroundOption backgroundOption =
                  modality == Modality.BACKGROUNDABLE
                      ? PerformInBackgroundOption.DEAF
                      : PerformInBackgroundOption.ALWAYS_BACKGROUND;
              return new BackgroundableProcessIndicator(
                  project, title, backgroundOption, "Cancel", "Cancel", cancelable);
            }
          });

  indicator.setIndeterminate(true);
  indicator.start();
  final ListenableFuture<T> future =
      executor.submit(
          () ->
              ProgressManager.getInstance()
                  .runProcess(() -> progressive.compute(indicator), indicator));
  if (cancelable) {
    indicator.addStateDelegate(
        new AbstractProgressIndicatorExBase() {
          @Override
          public void cancel() {
            super.cancel();
            future.cancel(true);
          }
        });
  }
  future.addListener(
      () -> {
        if (indicator.isRunning()) {
          indicator.stop();
          indicator.processFinish();
        }
      },
      MoreExecutors.directExecutor());
  return future;
}
 
Example #23
Source File: WebProgressDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
public WebProgressDialog(ProgressWindow progressWindow) {
  myProgressWindow = progressWindow;
}
 
Example #24
Source File: WebProgressDialogFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public ProgressDialog create(ProgressWindow progressWindow, boolean shouldShowBackground, JComponent parent, Project project, String cancelText) {
  return new WebProgressDialog(progressWindow);
}
 
Example #25
Source File: StartupEvent.java    From tmc-intellij with MIT License 4 votes vote down vote up
@Override
public void runActivity(@NotNull Project project) {

    logger.info("Opening project {} and running startup actions. @StartupEvent", project);

    ExerciseDatabaseManager.setup();

    ThreadingService threadingService = new ThreadingService();

    ProgressWindow progressWindow =
            ProgressWindowMaker.make(
                    "Running TMC startup actions.", project, false, false, false);

    CoreProgressObserver observer = new CoreProgressObserver(progressWindow);
    new ErrorMessageService()
            .showInfoBalloon(
                    "The Test My Code Plugin for Intellij is in BETA and"
                            + " may not work properly. Use at your own risk. ");

    threadingService.runWithNotification(
            new Thread(
                    () -> {
                        setupLoggers(observer);
                        setupTmcSettings(observer);
                        CheckForOneDrive.run();
                        setupCoreHolder(observer);
                        setupSnapshots(observer, project);
                        setupDatabase(observer);
                        setupHandlersForSnapshots(observer);

                        if (TmcSettingsManager.get().getFirstRun()) {
                            TmcSettingsManager.get().setFirstRun(false);
                        } else {
                            sendDiagnostics(observer);
                        }

                        checkForNewExercises(observer);

                        ApplicationManager.getApplication()
                                .invokeLater(
                                        () -> {
                                            while (project.isDisposed()) {
                                                try {
                                                    Thread.sleep(5);
                                                } catch (Exception e) {

                                                }
                                            }

                                            if (ToolWindowManager.getInstance(project)
                                                            .getToolWindow("Project")
                                                    != null) {
                                                ToolWindowManager.getInstance(project)
                                                        .getToolWindow("Project")
                                                        .activate(null);
                                            }
                                        });
                    }),
            project,
            progressWindow);

    showLoginWindow();
}
 
Example #26
Source File: ProgressManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
/**
 * The passes progress won't count in {@link #hasUnsafeProgressIndicator()} and won't stop from application exiting.
 */
public void markProgressSafe(@Nonnull ProgressWindow progress) {
  progress.putUserData(SAFE_PROGRESS_INDICATOR, true);
}
 
Example #27
Source File: ProgressManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static boolean isUnsafeIndicator(ProgressIndicator indicator) {
  return indicator instanceof ProgressWindow && ((ProgressWindow)indicator).getUserData(SAFE_PROGRESS_INDICATOR) == null;
}
 
Example #28
Source File: DumbServiceImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void runBackgroundProcess(@Nonnull final ProgressIndicator visibleIndicator) {
  ((ProgressManagerImpl)ProgressManager.getInstance()).markProgressSafe((ProgressWindow)visibleIndicator);

  if (!myState.compareAndSet(State.SCHEDULED_TASKS, State.RUNNING_DUMB_TASKS)) return;

  // Only one thread can execute this method at the same time at this point.

  try (ProgressSuspender suspender = ProgressSuspender.markSuspendable(visibleIndicator, "Indexing paused")) {
    myCurrentSuspender = suspender;
    suspendIfRequested(suspender);

    //IdeActivity activity = IdeActivity.started(myProject, "indexing");
    final ShutDownTracker shutdownTracker = ShutDownTracker.getInstance();
    final Thread self = Thread.currentThread();
    try {
      shutdownTracker.registerStopperThread(self);

      ((ProgressIndicatorEx)visibleIndicator).addStateDelegate(new AppIconProgress());

      DumbModeTask task = null;
      while (true) {
        Pair<DumbModeTask, ProgressIndicatorEx> pair = getNextTask(task);
        if (pair == null) break;

        task = pair.first;
        //activity.stageStarted(task.getClass());
        ProgressIndicatorEx taskIndicator = pair.second;
        suspender.attachToProgress(taskIndicator);
        taskIndicator.addStateDelegate(new AbstractProgressIndicatorExBase() {
          @Override
          protected void delegateProgressChange(@Nonnull IndicatorAction action) {
            super.delegateProgressChange(action);
            action.execute((ProgressIndicatorEx)visibleIndicator);
          }
        });
        try (AccessToken ignored = HeavyProcessLatch.INSTANCE.processStarted("Performing indexing tasks")) {
          runSingleTask(task, taskIndicator);
        }
      }
    }
    catch (Throwable unexpected) {
      LOG.error(unexpected);
    }
    finally {
      shutdownTracker.unregisterStopperThread(self);
      // myCurrentSuspender should already be null at this point unless we got here by exception. In any case, the suspender might have
      // got suspended after the the last dumb task finished (or even after the last check cancelled call). This case is handled by
      // the ProgressSuspender close() method called at the exit of this try-with-resources block which removes the hook if it has been
      // previously installed.
      myCurrentSuspender = null;
      //activity.finished();
    }
  }
}
 
Example #29
Source File: ProgressDialogFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
ProgressDialog create(ProgressWindow progressWindow, boolean shouldShowBackground, JComponent parent, Project project, String cancelText);
 
Example #30
Source File: DetailsPanel.java    From consulo with Apache License 2.0 4 votes vote down vote up
DetailsPanel(@Nonnull VcsLogData logData,
             @Nonnull VcsLogColorManager colorManager,
             @Nonnull Disposable parent) {
  myLogData = logData;
  myColorManager = colorManager;

  myScrollPane = new JBScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
  myMainContentPanel = new ScrollablePanel() {
    @Override
    public boolean getScrollableTracksViewportWidth() {
      boolean expanded = false;
      for (Component c : getComponents()) {
        if (c instanceof CommitPanel && ((CommitPanel)c).isExpanded()) {
          expanded = true;
          break;
        }
      }
      return !expanded;
    }

    @Override
    public Dimension getPreferredSize() {
      Dimension preferredSize = super.getPreferredSize();
      int height = Math.max(preferredSize.height, myScrollPane.getViewport().getHeight());
      JBScrollPane scrollPane = UIUtil.getParentOfType(JBScrollPane.class, this);
      if (scrollPane == null || getScrollableTracksViewportWidth()) {
        return new Dimension(preferredSize.width, height);
      }
      else {
        return new Dimension(Math.max(preferredSize.width, scrollPane.getViewport().getWidth()), height);
      }
    }

    @Override
    public Color getBackground() {
      return CommitPanel.getCommitDetailsBackground();
    }

    @Override
    protected void paintChildren(Graphics g) {
      if (StringUtil.isNotEmpty(myEmptyText.getText())) {
        myEmptyText.paint(this, g);
      }
      else {
        super.paintChildren(g);
      }
    }
  };
  myEmptyText = new StatusText(myMainContentPanel) {
    @Override
    protected boolean isStatusVisible() {
      return StringUtil.isNotEmpty(getText());
    }
  };
  myMainContentPanel.setLayout(new VerticalFlowLayout(VerticalFlowLayout.TOP, 0, 0, true, false));

  myMainContentPanel.setOpaque(false);
  myScrollPane.setViewportView(myMainContentPanel);
  myScrollPane.setBorder(IdeBorderFactory.createEmptyBorder());
  myScrollPane.setViewportBorder(IdeBorderFactory.createEmptyBorder());

  myLoadingPanel = new JBLoadingPanel(new BorderLayout(), parent, ProgressWindow.DEFAULT_PROGRESS_DIALOG_POSTPONE_TIME_MILLIS) {
    @Override
    public Color getBackground() {
      return CommitPanel.getCommitDetailsBackground();
    }
  };
  myLoadingPanel.add(myScrollPane);

  setLayout(new BorderLayout());
  add(myLoadingPanel, BorderLayout.CENTER);

  myEmptyText.setText("Commit details");
}