OSDN Git Service

バージョン表記、更新履歴更新。
[coroid/inqubus.git] / frontend / src / saccubus / MainFrame.java
index f0cace6..f030853 100644 (file)
@@ -1,5 +1,6 @@
 package saccubus;
 
+import java.io.IOException;
 import saccubus.converter.Converter;
 import java.awt.BorderLayout;
 import java.awt.Dimension;
@@ -17,7 +18,6 @@ import java.awt.event.KeyEvent;
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
 import java.io.File;
-import java.io.IOException;
 import javax.swing.BorderFactory;
 import javax.swing.ButtonGroup;
 import javax.swing.JButton;
@@ -37,8 +37,10 @@ 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.FfmpegOption;
+import saccubus.converter.profile.FfmpegOption;
+import saccubus.converter.profile.NgSetting;
 import saccubus.net.TextProgressListener;
 import saccubus.properties.BasicSetting;
 import saccubus.properties.ConvertSetting;
@@ -75,7 +77,7 @@ import yukihane.nicovideo.NicoDBFinder;
 public class MainFrame extends JFrame {
 
     private static final long serialVersionUID = 2564486741331062989L;
-    public static final String VERSION = "1.22r NicoBrowser\8ag\92£ 1.1.1";
+    public static final String VERSION = "1.22r NicoBrowser\8ag\92£ 1.3.5";
     public static final Image WinIcon = Toolkit.getDefaultToolkit().createImage(saccubus.MainFrame.class.getResource(
             "icon32.png"));
     JPanel contentPane;
@@ -646,8 +648,8 @@ public class MainFrame extends JFrame {
     private void setSetting(SProperties setting) {
         // \8aî\96{\90Ý\92è
         final BasicSetting basic = setting.getBasicSetting();
-        MailAddrField.setText(basic.getMail());
-        PasswordField.setText(basic.getPassword());
+        MailAddrField.setText(basic.getUser().getMail());
+        PasswordField.setText(basic.getUser().getPassword());
         // \83v\83\8d\83L\83V\8aÖ\98A
         UseProxyCheckBox.setSelected(basic.isProxyUse());
         ProxyTextField.setText(basic.getProxyHost());
@@ -681,6 +683,7 @@ public class MainFrame extends JFrame {
         final boolean videoFixName = inVideo.isAutoNaming();
         videoSaveInfoPanel.getSaveFileRadioButton().setSelected(!videoFixName);
         videoSaveInfoPanel.getSaveFolderRadioButton().setSelected(videoFixName);
+        videoSaveInfoPanel.getNibrFileField().setText(inVideo.getNicoBrowserFile().getPath());
 
         // \95Û\91\90Ý\92è - \93ü\97Í\83R\83\81\83\93\83g
         final InputCommentSetting inputComment = setting.getInputCommentSetting();
@@ -738,21 +741,6 @@ public class MainFrame extends JFrame {
         NGIDTextField.setText(conv.getNgSetting().getId());
     }
 
-    private FfmpegOption detectOption() throws IOException {
-        // TODO detectOption\82ð\8eg\97p\82·\82é\89Ó\8f\8a
-        final File ffmpegFile = FFmpegOptionModel.getSelectedFile();
-        if (ffmpegFile != null) {
-            return FfmpegOption.load(ffmpegFile);
-        }
-
-        final String extOption = ExtOptionField.getText();
-        final String mainOption = MainOptionField.getText();
-        final String inOption = CommandLineInOptionField.getText();
-        final String outOption = CommandLineOutOptionField.getText();
-
-        return new FfmpegOption(extOption, mainOption, inOption, outOption);
-    }
-
     /**
      * [\83t\83@\83C\83\8b|\8fI\97¹] \83A\83N\83V\83\87\83\93\82ª\8eÀ\8ds\82³\82ê\82Ü\82µ\82½\81B
      *
@@ -819,65 +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 ConvertStopFlag(this.DoButton, DoButtonStopString,
-//                                                     DoButtonWaitString, DoButtonDefString));
-            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 */
@@ -886,6 +824,65 @@ 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 STOPPING:
+                                DoButton.setText(DoButtonWaitString);
+                                break;
+                            case FINISHED:
+                                DoButton.setText(DoButtonDefString);
+                        }
+                    }
+                });
+            }
+        };
+
+        Converter = new Converter(url, WayBackField.getText(), getSetting().toProfile(), sl,
+                new ConvertStopFlag(scl));
+        DoButton.setText(DoButtonStopString);
+        new Thread(Converter).start();
+
+    }
+
     /* FFmpeg\82Ö\82Ì\83p\83X */
     public void SettingFFmpegPathButton_actionPerformed(ActionEvent e) {
         showSaveDialog("FFmpeg\82Ö\82Ì\83p\83X", FFmpegPathField, false, false);
@@ -1278,8 +1275,9 @@ public class MainFrame extends JFrame {
         String folder = videoSaveInfoPanel.getVideoSavedFolderField().getText();
         String file = videoSaveInfoPanel.getVideoSavedFileField().getText();
         boolean delete = videoSaveInfoPanel.getDelVideoCheckBox().isSelected();
+        String nibrFile = videoSaveInfoPanel.getNibrFileField().getText();
 
-        return new InputVideoSetting(kind, autoNaming, new File(folder), new File(file), delete);
+        return new InputVideoSetting(kind, autoNaming, new File(folder), new File(file), delete, new File(nibrFile));
     }
 
     private InputCommentSetting getInputCommentSetting() {
@@ -1336,7 +1334,7 @@ public class MainFrame extends JFrame {
         File optionFile = FFmpegOptionModel.getSelectedFile();
 
         FfmpegOption opt = new FfmpegOption(ext, main, in, out);
-        return new MovieSetting(new File(ffmpeg), new File(vhook), optionFile, null);
+        return new MovieSetting(new File(ffmpeg), new File(vhook), optionFile, opt);
     }
 
     private ConvertSetting getConvertSetting() {
@@ -1352,8 +1350,7 @@ public class MainFrame extends JFrame {
         boolean showConv = ShowConvVideoCheckBox.isSelected();
         boolean adjustFont = FixFontSizeCheckBox.isSelected();
         boolean commentOpaque = OpaqueCommentCheckBox.isSelected();
-        ConvertSetting.NgSetting ngSetting =
-                new ConvertSetting.NgSetting(NGWordTextField.getText(), NGIDTextField.getText());
+        NgSetting ngSetting = new NgSetting(NGWordTextField.getText(), NGIDTextField.getText());
 
         return new ConvertSetting(vhookDisabled, maxComment, font, fontIndex, shadowIndex, showConv, adjustFont,
                 commentOpaque, ngSetting);