package org.lodder.subtools.multisubdownloader.gui.dialog.progress.fileindexer;

import org.lodder.subtools.multisubdownloader.MainWindow;
import org.lodder.subtools.multisubdownloader.gui.actions.ActionException;
import org.lodder.subtools.multisubdownloader.gui.dialog.Cancelable;
import org.lodder.subtools.multisubdownloader.gui.dialog.ProgressDialog;
import org.lodder.subtools.multisubdownloader.gui.extra.progress.StatusMessenger;

public class IndexingProgressDialog extends ProgressDialog implements IndexingProgressListener {

  private final MainWindow window;
  private boolean completed;

  public IndexingProgressDialog(MainWindow window, Cancelable sft) {
    super(window, sft);
    this.window = window;
    this.completed = false;
    StatusMessenger.instance.removeListener(this);
  }

  @Override
  public void progress(int progress) {
    this.setVisible();
    updateProgress(progress);
  }

  @Override
  public void progress(String directory) {
    this.setVisible();
    setMessage(directory);
  }

  @Override
  public void completed() {
    this.setVisible(false);
  }

  @Override
  public void onError(ActionException exception) {
    this.setVisible(false);
    this.window.showErrorMessage(exception.getMessage());
  }

  @Override
  public void onStatus(String message) {
    this.window.setStatusMessage(message);
  }

  private void setVisible() {
    if (this.completed) {
      return;
    }
    this.setVisible(true);
  }
}

@@ -74,16 +74,40 @@
 dexer;%0A%0A
+import java.awt.Color;%0A%0A
 import o
@@ -156,16 +156,16 @@
 Window;%0A
-
 import o
@@ -617,16 +617,36 @@
 mpleted;
+%0A  private Color bg;
 %0A%0A  publ
@@ -833,24 +833,142 @@
 ener(this);%0A
+    // workaround for not showing correct contents of dialog (works only in  java 1.8)%0A    bg = this.getBackground();%0A
   %7D%0A%0A  @Over
@@ -1507,16 +1507,16 @@
 );%0A  %7D%0A%0A
-
   privat
@@ -1533,24 +1533,175 @@
 Visible() %7B%0A
+    // workaround for not showing correct contents of dialog (works only in  java 1.8)%0A    this.setBackground(Color.gray);%0A    this.setBackground(bg);%0A
     if (this

Work around for a bug, IndexingProgressDialog progress not visible. The workaround only works with java 1.8