* 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") @Define("hi")
public String getHeightAndInterlacement() { public String getHeightAndInterlacement() {
String height = getMediaInfo(StreamKind.Video, 0, "Height"); 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) if (height == null || interlacement == null)
return null; return null;

View File

@ -26,7 +26,7 @@ public class MediaInfo implements Closeable {
public boolean open(File file) { 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.ExceptionUtilities;
import net.sourceforge.tuned.ui.GradientStyle; import net.sourceforge.tuned.ui.GradientStyle;
import net.sourceforge.tuned.ui.LinkButton; import net.sourceforge.tuned.ui.LinkButton;
import net.sourceforge.tuned.ui.ProgressIndicator;
import net.sourceforge.tuned.ui.TunedUtilities; import net.sourceforge.tuned.ui.TunedUtilities;
import net.sourceforge.tuned.ui.notification.SeparatorBorder; import net.sourceforge.tuned.ui.notification.SeparatorBorder;
import net.sourceforge.tuned.ui.notification.SeparatorBorder.Position; import net.sourceforge.tuned.ui.notification.SeparatorBorder.Position;
@ -77,6 +78,8 @@ public class EpisodeFormatDialog extends JDialog {
private ExecutorService previewExecutor = createPreviewExecutor(); private ExecutorService previewExecutor = createPreviewExecutor();
private ProgressIndicator progressIndicator = new ProgressIndicator();
private JTextField editor = new JTextField(); private JTextField editor = new JTextField();
private Color defaultColor = preview.getForeground(); private Color defaultColor = preview.getForeground();
@ -102,7 +105,9 @@ public class EpisodeFormatDialog extends JDialog {
errorMessage.setVisible(false); errorMessage.setVisible(false);
warningMessage.setVisible(false); warningMessage.setVisible(false);
progressIndicator.setVisible(false);
header.add(progressIndicator, "pos 1al 0al, hidemode 3");
header.add(title, "wrap unrel:push"); header.add(title, "wrap unrel:push");
header.add(preview, "gap indent, hidemode 3, wmax 90%"); header.add(preview, "gap indent, hidemode 3, wmax 90%");
header.add(errorMessage, "gap indent, hidemode 3, newline"); header.add(errorMessage, "gap indent, hidemode 3, newline");
@ -203,7 +208,7 @@ public class EpisodeFormatDialog extends JDialog {
EpisodeFormatDialog.this.firePropertyChange("previewSample", null, previewSample()); 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() { private void checkFormatInBackground() {
final Timer progressIndicatorTimer = TunedUtilities.invokeLater(400, new Runnable() {
@Override
public void run() {
progressIndicator.setVisible(true);
}
});
previewExecutor.execute(new SwingWorker<String, Void>() { previewExecutor.execute(new SwingWorker<String, Void>() {
private ScriptException warning = null; private ScriptException warning = null;
@ -326,6 +339,7 @@ public class EpisodeFormatDialog extends JDialog {
@Override @Override
protected void done() { protected void done() {
Exception error = null; Exception error = null;
try { try {
@ -342,6 +356,9 @@ public class EpisodeFormatDialog extends JDialog {
preview.setVisible(error == null); preview.setVisible(error == null);
editor.setForeground(error == null ? defaultColor : errorColor); 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) { private void finish(Format format) {
this.selectedFormat = format; this.selectedFormat = format;
previewExecutor.shutdownNow();
setVisible(false); setVisible(false);
dispose(); 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); final JDialog dialog = new JDialog(TunedUtilities.getWindow(parent), "MediaInfo", ModalityType.DOCUMENT_MODAL);
dialog.setLocation(TunedUtilities.getPreferredLocation(dialog));
JComponent c = (JComponent) dialog.getContentPane(); JComponent c = (JComponent) dialog.getContentPane();
c.setLayout(new MigLayout("fill", "[align center]", "[fill][pref!]")); c.setLayout(new MigLayout("fill", "[align center]", "[fill][pref!]"));