OSDN Git Service

コミット漏れ
[coroid/inqubus.git] / frontend / src / saccubus / MainFrame.java
index 2684653..d50d5d4 100644 (file)
@@ -18,6 +18,7 @@ import java.awt.event.KeyEvent;
 import java.awt.event.WindowAdapter;
 import java.awt.event.WindowEvent;
 import java.io.File;
+import java.util.concurrent.FutureTask;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.swing.BorderFactory;
@@ -44,8 +45,8 @@ import nicobrowser.entity.NicoContent;
 import nicobrowser.main.Main;
 import org.apache.commons.lang.StringUtils;
 import saccubus.ConvertStopFlag.State;
-import saccubus.converter.profile.FfmpegOption;
-import saccubus.converter.profile.NgSetting;
+import saccubus.converter.classic.profile.FfmpegOption;
+import saccubus.converter.classic.profile.NgSetting;
 import saccubus.net.TextProgressListener;
 import saccubus.properties.BasicSetting;
 import saccubus.properties.ConvertSetting;
@@ -57,6 +58,8 @@ import saccubus.properties.MovieSetting;
 import saccubus.properties.OutputVideoSetting;
 import saccubus.util.FileDropTarget;
 import saccubus.util.PopupRightClick;
+import saccubus.util.WayBackTimeParser;
+import yukihane.Util;
 import yukihane.nicovideo.NicoDBFinder;
 
 /**
@@ -83,7 +86,7 @@ public class MainFrame extends JFrame {
 
     private static final long serialVersionUID = 2564486741331062989L;
     public static final String PRODUCT_NAME = "いんきゅばす";
-    public static final String VERSION = "1.7.1 (NicoBrowser" + Main.VERSION + ")";
+    public static final String VERSION = "1.7.2 (NicoBrowser" + Main.VERSION + ")";
     public static final Image WinIcon = Toolkit.getDefaultToolkit().createImage(saccubus.MainFrame.class.getResource(
             "icon32.png"));
     // TODO GUIが無いためフィールドに保持.
@@ -106,7 +109,8 @@ public class MainFrame extends JFrame {
     private JTextField videoIdField = new JTextField();
     private JLabel wayBackLabel = new JLabel();
     private JTextField wayBackField = new JTextField();
-    JButton DoButton = new JButton();
+    private JCheckBox reduceCommentCheckBox = new JCheckBox();
+    private JButton doButton = new JButton();
     public static final String DoButtonDefString = "変換";
     public static final String DoButtonStopString = "停止";
     public static final String DoButtonWaitString = "待機";
@@ -176,11 +180,61 @@ public class MainFrame extends JFrame {
     }
 
     /**
+     * メイン画面最上部(ID/URL, 過去ログ, 変換ボタン)のパネルを初期化します.
+     */
+    private void initVideoInfoPanel() {
+
+        videoIdLabel.setText("URL/ID");
+        wayBackLabel.setText("過去ログ");
+        videoIdField.setText("http://www.nicovideo.jp/watch/");
+        reduceCommentCheckBox.setText("旧仕様コメント数");
+
+        final GroupLayout oppLayout = new GroupLayout(opPanel);
+        opPanel.setLayout(oppLayout);
+
+        oppLayout.setHorizontalGroup(oppLayout.createSequentialGroup()
+                .addGroup(oppLayout.createParallelGroup()
+                    .addComponent(videoIdLabel)
+                    .addComponent(wayBackLabel))
+                .addGroup(oppLayout.createParallelGroup()
+                    .addComponent(videoIdField)
+                    .addGroup(oppLayout.createSequentialGroup()
+                        .addComponent(wayBackField)
+                        .addComponent(reduceCommentCheckBox)))
+                );
+
+        oppLayout.setVerticalGroup(oppLayout.createSequentialGroup()
+                    .addGroup(oppLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+                        .addComponent(videoIdLabel)
+                        .addComponent(videoIdField))
+                    .addGroup(oppLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
+                        .addComponent(wayBackLabel)
+                        .addComponent(wayBackField)
+                        .addComponent(reduceCommentCheckBox))
+                );
+
+        doButton.setText(DoButtonDefString);
+        doButton.addActionListener(new MainFrame_DoButton_actionAdapter(this));
+
+        final GroupLayout vipLayout = new GroupLayout(videoInfoPanel);
+        videoInfoPanel.setLayout(vipLayout);
+
+        vipLayout.setHorizontalGroup(vipLayout.createSequentialGroup()
+                .addComponent(opPanel).addComponent(doButton));
+
+        vipLayout.setVerticalGroup(vipLayout.createParallelGroup()
+                .addComponent(opPanel).addComponent(doButton, 10, 20, 50));
+    }
+
+    /**
      * コンポーネントの初期化。
      *
      * @throws java.lang.Exception
      */
     private void jbInit() throws Exception {
+
+        initVideoInfoPanel();
+
         GridBagConstraints gridBagConstraints74 = new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                 GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0);
         gridBagConstraints74.gridwidth = 2;
@@ -201,39 +255,6 @@ public class MainFrame extends JFrame {
         ShadowKindLabel = new JLabel();
         ShadowKindLabel.setText("影の種類");
         ShadowKindLabel.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED);
-        GridBagConstraints gridBagConstraints71 = new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
-                GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 6);
-        gridBagConstraints71.fill = GridBagConstraints.BOTH;
-        gridBagConstraints71.ipady = 0;
-        GridBagConstraints gridBagConstraints70 = new GridBagConstraints();
-        gridBagConstraints70.fill = GridBagConstraints.HORIZONTAL;
-        gridBagConstraints70.gridy = 1;
-        gridBagConstraints70.ipadx = 0;
-        gridBagConstraints70.ipady = 0;
-        gridBagConstraints70.weightx = 1.0;
-        gridBagConstraints70.insets = new Insets(0, 0, 0, 0);
-        gridBagConstraints70.gridx = 1;
-        GridBagConstraints gridBagConstraints69 = new GridBagConstraints();
-        gridBagConstraints69.gridx = 0;
-        gridBagConstraints69.ipadx = 0;
-        gridBagConstraints69.ipady = 0;
-        gridBagConstraints69.insets = new Insets(0, 5, 0, 5);
-        gridBagConstraints69.anchor = GridBagConstraints.WEST;
-        gridBagConstraints69.gridy = 1;
-        GridBagConstraints gridBagConstraints68 = new GridBagConstraints();
-        gridBagConstraints68.fill = GridBagConstraints.BOTH;
-        gridBagConstraints68.gridy = 0;
-        gridBagConstraints68.ipady = 0;
-        gridBagConstraints68.weightx = 1.0;
-        gridBagConstraints68.insets = new Insets(0, 0, 0, 0);
-        gridBagConstraints68.gridx = 1;
-        GridBagConstraints gridBagConstraints67 = new GridBagConstraints();
-        gridBagConstraints67.gridx = 0;
-        gridBagConstraints67.ipadx = 0;
-        gridBagConstraints67.ipady = 0;
-        gridBagConstraints67.insets = new Insets(0, 5, 0, 5);
-        gridBagConstraints67.anchor = GridBagConstraints.WEST;
-        gridBagConstraints67.gridy = 0;
         GridBagConstraints gridBagConstraints66 = new GridBagConstraints();
         gridBagConstraints66.gridx = 0;
         gridBagConstraints66.insets = new Insets(0, 5, 5, 5);
@@ -358,9 +379,6 @@ public class MainFrame extends JFrame {
         jMenuHelpAbout.setText("バージョン情報");
         jMenuHelpAbout.addActionListener(new MainFrame_jMenuHelpAbout_ActionAdapter(
                 this));
-        videoInfoPanel.setLayout(gridBagLayout1);
-        DoButton.setText(DoButtonDefString);
-        DoButton.addActionListener(new MainFrame_DoButton_actionAdapter(this));
         SavingInfoTabPanel.setLayout(new GridLayout());
         UserInfoPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "ユーザ設定"));
         UserInfoPanel.setLayout(gridBagLayout3);
@@ -515,21 +533,6 @@ public class MainFrame extends JFrame {
         setFFMpegOptionCheckbox();
 
 
-        videoInfoPanel.add(DoButton, gridBagConstraints71);
-
-        videoIdLabel.setText("URL/ID");
-        wayBackLabel.setText("過去ログ");
-        videoIdField.setText("http://www.nicovideo.jp/watch/");
-
-        opPanel.setLayout(new GridBagLayout());
-
-        videoInfoPanel.add(opPanel, new GridBagConstraints(0, 0, 1, 1, 1.0,
-                0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
-                new Insets(0, 0, 0, 0), 0, 0));
-        opPanel.add(videoIdLabel, gridBagConstraints67);
-        opPanel.add(videoIdField, gridBagConstraints68);
-        opPanel.add(wayBackLabel, gridBagConstraints69);
-        opPanel.add(wayBackField, gridBagConstraints70);
 
         mainTabbedPane.add(BasicInfoTabPanel, "基本設定");
         mainTabbedPane.add(SavingInfoTabPanel, "保存設定");
@@ -871,7 +874,6 @@ public class MainFrame extends JFrame {
     // FFmpegの設定 ここまで
     private JLabel FontIndexLabel = new JLabel();
     private JTextField fontIndexField = new JTextField();
-    private GridBagLayout gridBagLayout1 = new GridBagLayout();
     private JPanel BasicInfoTabPanel = new JPanel();
     private GridBagLayout gridBagLayout12 = new GridBagLayout();
     private JPanel ConvertingSettingPanel = null;
@@ -928,6 +930,7 @@ public class MainFrame extends JFrame {
                 if (info != null) {
                     url = info.getNicoId();
                 } else {
+                    // TODO これはダメ…だけどそのうちこの処理自体削除になる
                     url = "";
                 }
             } catch (Exception ex) {
@@ -958,20 +961,22 @@ public class MainFrame extends JFrame {
                     public void run() {
                         switch (s) {
                             case STOPPING:
-                                DoButton.setText(DoButtonWaitString);
+                                doButton.setText(DoButtonWaitString);
                                 break;
                             case FINISHED:
-                                DoButton.setText(DoButtonDefString);
+                                doButton.setText(DoButtonDefString);
                         }
                     }
                 });
             }
         };
 
-        Converter = new Converter(url, wayBackField.getText(), getSetting().toProfile(), sl,
+        final String id = Util.getVideoId(url);
+        Converter = new Converter(id, getSetting().toProfile(), sl,
                 new ConvertStopFlag(scl));
-        DoButton.setText(DoButtonStopString);
-        new Thread(Converter).start();
+        doButton.setText(DoButtonStopString);
+        FutureTask<Boolean> task = new FutureTask<Boolean>(Converter);
+        new Thread(task).start();
 
     }
 
@@ -1390,8 +1395,15 @@ public class MainFrame extends JFrame {
         String folder = savePanel.getCommentSavedFolderField().getText();
         boolean adjustNumOfCom = savePanel.getFixCommentNumCheckBox().isSelected();
 
+        final String txt = wayBackField.getText();
+        long backLogPoint;
+        try {
+            backLogPoint = (StringUtils.isNotBlank(txt)) ? WayBackTimeParser.parse(txt) : -1;
+        } catch (IOException ex) {
+            backLogPoint = -1;
+        }
         return new InputCommentSetting(download, autoNaming, new File(folder), new File(file), delete, adjustNumOfCom,
-                back_comment);
+                back_comment, reduceCommentCheckBox.isSelected(), backLogPoint);
     }
 
     /**