* improved LinkageError handling

This commit is contained in:
Reinhard Pointner 2009-04-05 17:43:32 +00:00
parent 49d0ca648d
commit d7a5b58c32
3 changed files with 19 additions and 23 deletions

View File

@ -9,8 +9,6 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.SortedMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.zip.CRC32;
import net.sf.ehcache.Cache;
@ -143,19 +141,15 @@ public class EpisodeFormatBindingBean {
public synchronized MediaInfo getMediaInfo() {
if (mediaFile == null) {
throw new NullPointerException("Media file is null");
}
if (mediaInfo == null) {
try {
mediaInfo = new MediaInfo();
if (mediaFile == null || !mediaInfo.open(mediaFile)) {
throw new RuntimeException(String.format("Cannot open file: %s", mediaFile));
}
} catch (UnsatisfiedLinkError e) {
// MediaInfo native library is missing -> notify user
Logger.getLogger("ui").log(Level.SEVERE, e.getMessage(), e);
// rethrow error
throw e;
mediaInfo = new MediaInfo();
if (!mediaInfo.open(mediaFile)) {
throw new RuntimeException(String.format("Cannot open file: %s", mediaFile));
}
}

View File

@ -40,7 +40,6 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JTextField;
import javax.swing.KeyStroke;
import javax.swing.SwingWorker;
import javax.swing.Timer;
import javax.swing.border.LineBorder;
@ -133,14 +132,12 @@ public class EpisodeFormatDialog extends JDialog {
pane.add(header, "h 60px, growx, dock north");
pane.add(content, "grow");
setSize(485, 390);
setSize(485, 415);
header.setComponentPopupMenu(createPreviewSamplePopup());
setLocation(TunedUtilities.getPreferredLocation(this));
TunedUtilities.putActionForKeystroke(pane, KeyStroke.getKeyStroke("released ESCAPE"), cancelAction);
// update preview to current format
checkFormatInBackground();
@ -206,9 +203,17 @@ public class EpisodeFormatDialog extends JDialog {
previewSampleMediaFile = fileChooser.getSelectedFile();
Settings.userRoot().put("dialog.sample.file", previewSampleMediaFile.getAbsolutePath());
EpisodeFormatDialog.this.firePropertyChange("previewSample", null, previewSample());
try {
MediaInfoComponent.showMessageDialog(EpisodeFormatDialog.this, previewSampleMediaFile);
} catch (LinkageError e) {
// MediaInfo native library is missing -> notify user
Logger.getLogger("ui").log(Level.SEVERE, e.getMessage(), e);
// rethrow error
throw e;
}
MediaInfoComponent.showMessageDialog(EpisodeFormatDialog.this, previewSampleMediaFile);
EpisodeFormatDialog.this.firePropertyChange("previewSample", null, previewSample());
}
}
});

View File

@ -67,9 +67,6 @@ public class SelectDialog<T> extends JDialog {
// Shortcut Enter
TunedUtilities.putActionForKeystroke(list, KeyStroke.getKeyStroke("released ENTER"), selectAction);
// Shortcut Escape
TunedUtilities.putActionForKeystroke(list, KeyStroke.getKeyStroke("released ESCAPE"), cancelAction);
}