OSDN Git Service

オプションファイルに誤りがあった場合はエラーを送出する。
authoryuki <yuki@c066991c-cf13-ec4a-a49a-846e61667af5>
Fri, 25 Dec 2009 09:12:36 +0000 (09:12 +0000)
committeryuki <yuki@c066991c-cf13-ec4a-a49a-846e61667af5>
Fri, 25 Dec 2009 09:12:36 +0000 (09:12 +0000)
git-svn-id: http://192.168.11.7/svn/saccubus/trunk@322 c066991c-cf13-ec4a-a49a-846e61667af5

frontend/src/saccubus/MainFrame.java
frontend/src/saccubus/prompt/Prompt.java
frontend/src/saccubus/properties/SProperties.java

index 912c1d1..80eedee 100644 (file)
@@ -1,5 +1,6 @@
 package saccubus;
 
+import java.io.IOException;
 import saccubus.converter.Converter;
 import java.awt.BorderLayout;
 import java.awt.Dimension;
@@ -36,6 +37,7 @@ import javax.swing.JTabbedPane;
 import javax.swing.JTextField;
 import javax.swing.SwingUtilities;
 import nicobrowser.entity.NicoContent;
+import org.apache.commons.lang.StringUtils;
 import saccubus.ConvertStopFlag.State;
 import saccubus.converter.profile.FfmpegOption;
 import saccubus.converter.profile.NgSetting;
@@ -805,63 +807,15 @@ public class MainFrame extends JFrame {
 
     public void DoButton_actionPerformed(ActionEvent e) {
         if (Converter == null || Converter.isConverted()) {
-            String url;
-
-            // NicoBrowser\83t\83@\83C\83\8b\82ð\97\98\97p\82·\82é\8fê\8d\87\82Í\81A\83t\83@\83C\83\8b\96¼\82©\82ç\83r\83f\83IID\82ð\93Á\92è.
-            if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected()) {
-                try {
-                    String fileName = videoSaveInfoPanel.getNibrFileField().getText();
-                    NicoDBFinder finder = NicoDBFinder.getInstance();
-                    NicoContent info = finder.findNicoContent(fileName);
-                    if (info != null) {
-                        url = info.getNicoId();
-                    } else {
-                        url = "";
-                    }
-                } catch (Exception ex) {
-                    JOptionPane.showMessageDialog(this, ex.getMessage(), "\83G\83\89\81[", JOptionPane.ERROR_MESSAGE);
-                    return;
+            try {
+                executeConvert();
+            } catch (Exception ex) {
+                String text = ex.getMessage();
+                if (StringUtils.isEmpty(text)) {
+                    text = "\97\\8aú\82µ\82È\82¢\83G\83\89\81[\82Ì\82½\82ß\92\86\92f\82µ\82Ü\82µ\82½\81B";
                 }
-            } else {
-                url = VideoID_TextField.getText();
+                statusBar.setText(text);
             }
-
-            TextProgressListener sl = new TextProgressListener() {
-
-                public void setText(final String text) {
-                    SwingUtilities.invokeLater(new Runnable() {
-
-                        public void run() {
-                            statusBar.setText(text);
-                        }
-                    });
-                }
-            };
-
-            ConvertStopFlag.StateChangeListener scl = new ConvertStopFlag.StateChangeListener() {
-
-                public void changeState(final State s) {
-                    SwingUtilities.invokeLater(new Runnable() {
-
-                        public void run() {
-                            switch (s) {
-                                case PROCESSING:
-                                    DoButton.setText(DoButtonStopString);
-                                    break;
-                                case STOPPING:
-                                    DoButton.setText(DoButtonWaitString);
-                                    break;
-                                case FINISHED:
-                                    DoButton.setText(DoButtonDefString);
-                            }
-                        }
-                    });
-                }
-            };
-
-            Converter = new Converter(url, WayBackField.getText(), getSetting().toProfile(), sl,
-                    new ConvertStopFlag(scl));
-            new Thread(Converter).start();
         } else { /* \8aJ\8en\82µ\82Ä\82¢\82é\82Ì\82Å\81A\83X\83g\83b\83v\82·\82é\81B */
             final ConvertStopFlag flag = Converter.getStopFlag();
             if (!flag.needStop()) { /* \82Ü\82¾\83X\83g\83b\83v\82µ\82Ä\82¢\82È\82¢\81B */
@@ -870,6 +824,67 @@ public class MainFrame extends JFrame {
         }
     }
 
+    private void executeConvert() throws IOException {
+        String url;
+
+        // NicoBrowser\83t\83@\83C\83\8b\82ð\97\98\97p\82·\82é\8fê\8d\87\82Í\81A\83t\83@\83C\83\8b\96¼\82©\82ç\83r\83f\83IID\82ð\93Á\92è.
+        if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected()) {
+            try {
+                String fileName = videoSaveInfoPanel.getNibrFileField().getText();
+                NicoDBFinder finder = NicoDBFinder.getInstance();
+                NicoContent info = finder.findNicoContent(fileName);
+                if (info != null) {
+                    url = info.getNicoId();
+                } else {
+                    url = "";
+                }
+            } catch (Exception ex) {
+                JOptionPane.showMessageDialog(this, ex.getMessage(), "\83G\83\89\81[", JOptionPane.ERROR_MESSAGE);
+                return;
+            }
+        } else {
+            url = VideoID_TextField.getText();
+        }
+
+        TextProgressListener sl = new TextProgressListener() {
+
+            public void setText(final String text) {
+                SwingUtilities.invokeLater(new Runnable() {
+
+                    public void run() {
+                        statusBar.setText(text);
+                    }
+                });
+            }
+        };
+
+        ConvertStopFlag.StateChangeListener scl = new ConvertStopFlag.StateChangeListener() {
+
+            public void changeState(final State s) {
+                SwingUtilities.invokeLater(new Runnable() {
+
+                    public void run() {
+                        switch (s) {
+                            case PROCESSING:
+                                DoButton.setText(DoButtonStopString);
+                                break;
+                            case STOPPING:
+                                DoButton.setText(DoButtonWaitString);
+                                break;
+                            case FINISHED:
+                                DoButton.setText(DoButtonDefString);
+                        }
+                    }
+                });
+            }
+        };
+
+        Converter = new Converter(url, WayBackField.getText(), getSetting().toProfile(), sl,
+                new ConvertStopFlag(scl));
+        new Thread(Converter).start();
+
+    }
+
     /* FFmpeg\82Ö\82Ì\83p\83X */
     public void SettingFFmpegPathButton_actionPerformed(ActionEvent e) {
         showSaveDialog("FFmpeg\82Ö\82Ì\83p\83X", FFmpegPathField, false, false);
index 052c0d6..e2f2dc5 100644 (file)
@@ -1,5 +1,6 @@
 package saccubus.prompt;
 
+import java.io.IOException;
 import saccubus.ConvertStopFlag;
 import saccubus.ConvertStopFlag.State;
 import saccubus.converter.Converter;
@@ -27,7 +28,7 @@ import saccubus.net.TextProgressListener;
  * @version 1.0
  */
 public class Prompt {
-       public static void main(String[] args) {
+       public static void main(String[] args) throws IOException {
         TextProgressListener sl = new TextProgressListener() {
 
             public void setText(String text) {
index 7db8241..a58a25c 100644 (file)
@@ -86,13 +86,13 @@ public class SProperties {
         this.convertSetting = convertSetting;
     }
 
-    public Profile toProfile() {
+    public Profile toProfile() throws IOException {
         return new ProfileBuilder().build();
     }
 
     private class ProfileBuilder {
 
-        private Profile build() {
+        private Profile build() throws IOException {
             LoginInfo loginInfo = buildLoginInfo();
             InputFileSetting videoSetting = buildVideoSetting();
             InputFileSetting commentSetting = buildCommentSetting();
@@ -175,7 +175,7 @@ public class SProperties {
                     isAddComment(), setting.isAddTcomment());
         }
 
-        private Ffmpeg buildFfmpeg() {
+        private Ffmpeg buildFfmpeg() throws IOException {
             final MovieSetting movie = getMovieSetting();
             final ConvertSetting conv = getConvertSetting();
 
@@ -184,7 +184,7 @@ public class SProperties {
                 try {
                     fo = FfmpegOption.load(movie.getOptionFile());
                 } catch (IOException ex) {
-                    ex.printStackTrace();
+                    throw new IOException("\83I\83v\83V\83\87\83\93\83t\83@\83C\83\8b\82Ì\8f\91\8e®\82ª\8cë\82Á\82Ä\82¢\82Ü\82·\81F" + movie.getOptionFile().getName(), ex);
                 }
             }