* added progress indicator to format dialog

This commit is contained in:
Reinhard Pointner 2009-04-05 15:07:51 +00:00
parent 23dc93bf20
commit 49d0ca648d
4 changed files with 25 additions and 5 deletions

View File

@ -83,7 +83,7 @@ public class EpisodeFormatBindingBean {
@Define("hi")
public String getHeightAndInterlacement() {
String height = getMediaInfo(StreamKind.Video, 0, "Height");
String interlacement = getMediaInfo(StreamKind.Video, 0, "Interlacement");
String interlacement = getMediaInfo(StreamKind.Video, 0, "Interlacement/String");
if (height == null || interlacement == null)
return null;

View File

@ -26,7 +26,7 @@ public class MediaInfo implements Closeable {
public boolean open(File file) {
return MediaInfoLibrary.INSTANCE.Open(handle, new WString(file.getPath())) > 0;
return MediaInfoLibrary.INSTANCE.Open(handle, new WString(file.getAbsolutePath())) > 0;
}

View File

@ -58,6 +58,7 @@ import net.sourceforge.filebot.web.Episode.EpisodeFormat;
import net.sourceforge.tuned.ExceptionUtilities;
import net.sourceforge.tuned.ui.GradientStyle;
import net.sourceforge.tuned.ui.LinkButton;
import net.sourceforge.tuned.ui.ProgressIndicator;
import net.sourceforge.tuned.ui.TunedUtilities;
import net.sourceforge.tuned.ui.notification.SeparatorBorder;
import net.sourceforge.tuned.ui.notification.SeparatorBorder.Position;
@ -77,6 +78,8 @@ public class EpisodeFormatDialog extends JDialog {
private ExecutorService previewExecutor = createPreviewExecutor();
private ProgressIndicator progressIndicator = new ProgressIndicator();
private JTextField editor = new JTextField();
private Color defaultColor = preview.getForeground();
@ -102,7 +105,9 @@ public class EpisodeFormatDialog extends JDialog {
errorMessage.setVisible(false);
warningMessage.setVisible(false);
progressIndicator.setVisible(false);
header.add(progressIndicator, "pos 1al 0al, hidemode 3");
header.add(title, "wrap unrel:push");
header.add(preview, "gap indent, hidemode 3, wmax 90%");
header.add(errorMessage, "gap indent, hidemode 3, newline");
@ -203,7 +208,7 @@ public class EpisodeFormatDialog extends JDialog {
EpisodeFormatDialog.this.firePropertyChange("previewSample", null, previewSample());
MediaInfoComponent.showDialog(EpisodeFormatDialog.this, previewSampleMediaFile);
MediaInfoComponent.showMessageDialog(EpisodeFormatDialog.this, previewSampleMediaFile);
}
}
});
@ -303,6 +308,14 @@ public class EpisodeFormatDialog extends JDialog {
private void checkFormatInBackground() {
final Timer progressIndicatorTimer = TunedUtilities.invokeLater(400, new Runnable() {
@Override
public void run() {
progressIndicator.setVisible(true);
}
});
previewExecutor.execute(new SwingWorker<String, Void>() {
private ScriptException warning = null;
@ -326,6 +339,7 @@ public class EpisodeFormatDialog extends JDialog {
@Override
protected void done() {
Exception error = null;
try {
@ -342,6 +356,9 @@ public class EpisodeFormatDialog extends JDialog {
preview.setVisible(error == null);
editor.setForeground(error == null ? defaultColor : errorColor);
progressIndicatorTimer.stop();
progressIndicator.setVisible(false);
}
});
@ -356,6 +373,8 @@ public class EpisodeFormatDialog extends JDialog {
private void finish(Format format) {
this.selectedFormat = format;
previewExecutor.shutdownNow();
setVisible(false);
dispose();
}

View File

@ -44,8 +44,9 @@ public class MediaInfoComponent extends JTabbedPane {
}
public static void showDialog(Component parent, File file) {
public static void showMessageDialog(Component parent, File file) {
final JDialog dialog = new JDialog(TunedUtilities.getWindow(parent), "MediaInfo", ModalityType.DOCUMENT_MODAL);
dialog.setLocation(TunedUtilities.getPreferredLocation(dialog));
JComponent c = (JComponent) dialog.getContentPane();
c.setLayout(new MigLayout("fill", "[align center]", "[fill][pref!]"));