OSDN Git Service

画面でプロファイル構築時にffmpegオプションをコンフィグからでなく画面設定から読むように変更
[coroid/inqubus.git] / frontend / src / yukihane / inqubus / gui / MainFrame.java
index e3a2dd1..4643fea 100644 (file)
@@ -15,6 +15,8 @@ import java.awt.event.ActionListener;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
 import java.awt.event.KeyEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
 import java.io.File;
 import java.io.FilenameFilter;
 import java.io.IOException;
@@ -37,30 +39,45 @@ import javax.swing.JLabel;
 import javax.swing.JMenu;
 import javax.swing.JMenuBar;
 import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
+import javax.swing.JTabbedPane;
 import javax.swing.JTable;
 import javax.swing.JTextField;
 import javax.swing.KeyStroke;
 import javax.swing.LayoutStyle.ComponentPlacement;
+import javax.swing.SwingUtilities;
 import javax.swing.TransferHandler;
 import javax.swing.WindowConstants;
+import javax.swing.border.BevelBorder;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.builder.ToStringBuilder;
+import saccubus.FfmpegOption;
 import saccubus.MainFrame_AboutBox;
+import saccubus.OptionComboBoxModel;
 import saccubus.util.WayBackTimeParser;
-import saccubus.worker.ConvertProgress;
-import saccubus.worker.DownloadProgress;
-import saccubus.worker.Worker.SaccubusListener;
+import saccubus.worker.impl.convert.ConvertProgress;
+import saccubus.worker.impl.download.DownloadProgress;
+import saccubus.worker.WorkerListener;
+import saccubus.worker.impl.convert.ConvertResult;
+import saccubus.worker.impl.download.DownloadResult;
 import saccubus.worker.profile.CommentProfile;
+import saccubus.worker.profile.ConvertProfile;
 import saccubus.worker.profile.DownloadProfile;
+import saccubus.worker.profile.FfmpegProfile;
 import saccubus.worker.profile.GeneralProfile;
 import saccubus.worker.profile.LoginProfile;
+import saccubus.worker.profile.OutputProfile;
 import saccubus.worker.profile.ProxyProfile;
 import saccubus.worker.profile.VideoProfile;
 import yukihane.Util;
 import yukihane.inqubus.Config;
-import yukihane.inqubus.manager.TaskManager;
+import yukihane.inqubus.manager.RequestProcess;
+import yukihane.inqubus.manager.TaskKind;
+import yukihane.inqubus.manager.TaskManage;
+import yukihane.inqubus.manager.TaskManageListener;
+import yukihane.inqubus.manager.TaskStatus;
 import yukihane.inqubus.model.Target;
 import yukihane.inqubus.model.TargetsTableModel;
 
@@ -81,9 +98,7 @@ public class MainFrame extends JFrame {
     private static final String FILE_OUTPUTFIELD_TOOLTIP
             = "ファイル命名規則入力します。";
     private final TargetsTableModel targetModel = new TargetsTableModel();
-    private final TaskManager taskManager;
-    private final DownloadProgressListener downloadProgressListener = new DownloadProgressListener();
-    private final ConvertProgressListener convertProgressListener = new ConvertProgressListener();
+    private final TaskManage taskManager;
 
     /** Creates new form MainFrame */
     public MainFrame() {
@@ -98,14 +113,12 @@ public class MainFrame extends JFrame {
 
         final JPanel pnlMain = new JPanel();
         final JScrollPane scrDisplay = new JScrollPane();
-        tblDisplay = new JTable();
+        tblDisplay = new JTable(targetModel, new TargetsColumnModel());
+        tblDisplay.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
         final JPanel pnlButton = new JPanel();
-        btnStart = new JButton();
-        btnStop = new JButton();
-        btnDeselect = new JButton();
+        final JTabbedPane tbpInput = new JTabbedPane();
         final JPanel pnlInputMain = new JPanel();
         final JLabel lblId = new JLabel();
-        fldId = new JTextField();
         fldId.setToolTipText(ID_FIELD_TOOLTIP);
         final JLabel lblVideo = new JLabel();
         cbVideoLocal = new JCheckBox();
@@ -114,6 +127,27 @@ public class MainFrame extends JFrame {
         fldVideo.setToolTipText(FILE_INPUTFIELD_TOOLTIP);
         btnVideo = new JButton();
         final JLabel lblComment = new JLabel();
+
+        fldBackLog.setToolTipText("YYYY/MM/DD hh:mm:ss形式、あるいは1970/01/01からの経過秒を入力します。");
+        cbBackLog.addItemListener(new ItemListener() {
+
+            @Override
+            public void itemStateChanged(ItemEvent e) {
+                final boolean selected = (e.getStateChange() == ItemEvent.SELECTED);
+                fldBackLog.setEnabled(selected);
+            }
+        });
+        cbBackLog.addPropertyChangeListener("enabled", new PropertyChangeListener() {
+
+            @Override
+            public void propertyChange(PropertyChangeEvent evt) {
+                final boolean enabled = ((Boolean) evt.getNewValue()).booleanValue();
+                final boolean fldEnabled = enabled ? cbBackLog.isSelected() : false;
+                fldBackLog.setEnabled(fldEnabled);
+            }
+        });
+        cbBackLogReduce.setToolTipText("「コメントの量を減らす」場合はチェックを付けます。");
+
         cbCommentLocal = new JCheckBox();
         cbCommentLocal.setToolTipText(FILE_LOCALBUTTON_TOOLTIP);
         cbCommentLocal.addItemListener(new ItemListener() {
@@ -123,9 +157,6 @@ public class MainFrame extends JFrame {
                 final boolean selected = (e.getStateChange() == ItemEvent.SELECTED);
                 cbBackLogReduce.setEnabled(!selected);
                 cbBackLog.setEnabled(!selected);
-                if(selected) {
-                    cbBackLog.setSelected(false);
-                }
             }
         });
         fldComment = new JTextField();
@@ -138,22 +169,16 @@ public class MainFrame extends JFrame {
 
         setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
 
+        btnStop.addActionListener(new StopActionListener());
         btnApply.addActionListener(new ApplyActionListener());
 
         pnlMain.setBorder(BorderFactory.createEtchedBorder());
 
-        tblDisplay.setModel(targetModel);
         tblDisplay.setDropMode(DropMode.INSERT_ROWS);
         scrDisplay.setViewportView(tblDisplay);
 
         pnlButton.setBorder(BorderFactory.createEtchedBorder());
 
-        btnStart.setText("開始");
-
-        btnStop.setText("停止");
-
-        btnDeselect.setText("選択解除");
-
         GroupLayout gl_pnlButton = new GroupLayout(pnlButton);
         pnlButton.setLayout(gl_pnlButton);
         gl_pnlButton.setHorizontalGroup(
@@ -178,8 +203,6 @@ public class MainFrame extends JFrame {
                 .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
         );
 
-        pnlInputMain.setBorder(BorderFactory.createEtchedBorder());
-
         lblId.setText("ID");
 
         fldId.addFocusListener(new java.awt.event.FocusAdapter() {
@@ -224,54 +247,59 @@ public class MainFrame extends JFrame {
         });
 
 
-        GroupLayout gl_pnlInputMain = new GroupLayout(pnlInputMain);
-        pnlInputMain.setLayout(gl_pnlInputMain);
-        gl_pnlInputMain.setHorizontalGroup(
-            gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
-            .addGroup(gl_pnlInputMain.createSequentialGroup()
+        final GroupLayout glInputMain = new GroupLayout(pnlInputMain);
+        pnlInputMain.setLayout(glInputMain);
+        glInputMain.setHorizontalGroup(
+            glInputMain.createParallelGroup(Alignment.LEADING)
+            .addGroup(glInputMain.createSequentialGroup()
                 .addContainerGap()
-                .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
-                    .addGroup(gl_pnlInputMain.createSequentialGroup()
-                        .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
-                            .addComponent(lblComment)
+                .addComponent(lblId)
+                .addPreferredGap(ComponentPlacement.RELATED)
+                .addComponent(fldId, GroupLayout.PREFERRED_SIZE, 100, Short.MAX_VALUE)
+                .addPreferredGap(ComponentPlacement.UNRELATED)
+                .addComponent(cbBackLogReduce)
+                .addPreferredGap(ComponentPlacement.UNRELATED)
+                .addComponent(cbBackLog)
+                .addPreferredGap(ComponentPlacement.RELATED)
+                .addComponent(fldBackLog, GroupLayout.PREFERRED_SIZE, 150, GroupLayout.PREFERRED_SIZE)
+                .addContainerGap()
+            )
+            .addGroup(glInputMain.createSequentialGroup()
+                .addContainerGap()
+                .addGroup(glInputMain.createParallelGroup(Alignment.LEADING)
+                    .addGroup(glInputMain.createSequentialGroup()
+                        .addGroup(glInputMain.createParallelGroup(Alignment.LEADING)
                             .addComponent(lblVideo)
-                            .addComponent(lblId)
+                            .addComponent(lblComment)
                             .addComponent(lblOutput))
                         .addPreferredGap(ComponentPlacement.RELATED)
-                        .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
-                            .addGroup(gl_pnlInputMain.createSequentialGroup()
+                        .addGroup(glInputMain.createParallelGroup(Alignment.LEADING)
+                            .addGroup(glInputMain.createSequentialGroup()
                                 .addComponent(cbVideoLocal)
                                 .addPreferredGap(ComponentPlacement.RELATED)
                                 .addComponent(fldVideo, GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)
                                 .addPreferredGap(ComponentPlacement.RELATED)
                                 .addComponent(btnVideo))
-                            .addGroup(gl_pnlInputMain.createSequentialGroup()
-                                .addComponent(fldId, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
-                                .addPreferredGap(ComponentPlacement.UNRELATED)
-                                .addComponent(cbBackLogReduce)
-                                .addComponent(cbBackLog)
-                                .addComponent(fldBackLog, GroupLayout.PREFERRED_SIZE, 150, GroupLayout.PREFERRED_SIZE)
-                            )
-                            .addGroup(Alignment.TRAILING, gl_pnlInputMain.createSequentialGroup()
-                                .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.TRAILING)
-                                    .addGroup(Alignment.LEADING, gl_pnlInputMain.createSequentialGroup()
+                            .addGroup(Alignment.TRAILING, glInputMain.createSequentialGroup()
+                                .addGroup(glInputMain.createParallelGroup(Alignment.TRAILING)
+                                    .addGroup(Alignment.LEADING, glInputMain.createSequentialGroup()
                                         .addComponent(cbOutputEnable)
                                         .addPreferredGap(ComponentPlacement.RELATED)
                                         .addComponent(fldOutput, GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE))
-                                    .addGroup(gl_pnlInputMain.createSequentialGroup()
+                                    .addGroup(glInputMain.createSequentialGroup()
                                         .addComponent(cbCommentLocal)
                                         .addPreferredGap(ComponentPlacement.RELATED)
                                         .addComponent(fldComment, GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)))
                                 .addPreferredGap(ComponentPlacement.RELATED)
                                 .addComponent(btnComment))))
-                    .addComponent(btnApply, Alignment.TRAILING))
+                    )
                 .addContainerGap())
         );
-        gl_pnlInputMain.setVerticalGroup(
-            gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
-            .addGroup(gl_pnlInputMain.createSequentialGroup()
+        glInputMain.setVerticalGroup(
+            glInputMain.createParallelGroup(Alignment.LEADING)
+            .addGroup(glInputMain.createSequentialGroup()
                 .addContainerGap()
-                .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.BASELINE)
+                .addGroup(glInputMain.createParallelGroup(Alignment.BASELINE)
                     .addComponent(fldId, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                     .addComponent(lblId)
                     .addComponent(cbBackLogReduce)
@@ -279,25 +307,104 @@ public class MainFrame extends JFrame {
                     .addComponent(fldBackLog)
                 )
                 .addPreferredGap(ComponentPlacement.RELATED)
-                .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.BASELINE)
+                .addGroup(glInputMain.createParallelGroup(Alignment.BASELINE)
                     .addComponent(lblVideo)
                     .addComponent(fldVideo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                     .addComponent(btnVideo)
                     .addComponent(cbVideoLocal))
                 .addPreferredGap(ComponentPlacement.RELATED)
-                .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.BASELINE)
+                .addGroup(glInputMain.createParallelGroup(Alignment.BASELINE)
                     .addComponent(lblComment)
                     .addComponent(fldComment, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                     .addComponent(btnComment)
                     .addComponent(cbCommentLocal))
                 .addPreferredGap(ComponentPlacement.RELATED)
-                .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.BASELINE)
+                .addGroup(glInputMain.createParallelGroup(Alignment.BASELINE)
                     .addComponent(lblOutput)
                     .addComponent(fldOutput, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                     .addComponent(cbOutputEnable))
-                .addPreferredGap(ComponentPlacement.UNRELATED)
+            )
+        );
+
+        // ffmpeg入力パネル
+        pnlInputFfmpeg.fldFfmpegOptionResizeWidth.setEnabled(false);
+        pnlInputFfmpeg.fldFfmpegOptionResizeHeight.setEnabled(false);
+        pnlInputFfmpeg.cbFfmpegOptionKeepAspect.setEnabled(false);
+        pnlInputFfmpeg.cmbFfmpegOptionFile.addActionListener(new ActionListener() {
+
+            @Override
+            public void actionPerformed(ActionEvent e) {
+                final boolean notFile = !pnlInputFfmpeg.mdlFfmpegOption.isFile();
+                pnlInputFfmpeg.fldFfmpegOptionExtension.setEnabled(notFile);
+                pnlInputFfmpeg.fldFfmpegOptionMain.setEnabled(notFile);
+                pnlInputFfmpeg.fldFfmpegOptionIn.setEnabled(notFile);
+                pnlInputFfmpeg.fldFfmpegOptionOut.setEnabled(notFile);
+                pnlInputFfmpeg.fldFfmpegOptionAv.setEnabled(notFile);
+                pnlInputFfmpeg.cbFfmpegOptionResize.setEnabled(notFile);
+            }
+        });
+        pnlInputFfmpeg.cbFfmpegOptionResize.addItemListener(new ItemListener() {
+
+            @Override
+            public void itemStateChanged(ItemEvent e) {
+                final boolean selected = (e.getStateChange() == ItemEvent.SELECTED);
+                pnlInputFfmpeg.fldFfmpegOptionResizeWidth.setEnabled(selected);
+                pnlInputFfmpeg.fldFfmpegOptionResizeHeight.setEnabled(selected);
+                pnlInputFfmpeg.cbFfmpegOptionKeepAspect.setEnabled(selected);
+            }
+        });
+        pnlInputFfmpeg.cbFfmpegOptionResize.addPropertyChangeListener("enabled", new PropertyChangeListener() {
+
+            @Override
+            public void propertyChange(PropertyChangeEvent evt) {
+                final boolean enabled = ((Boolean) evt.getNewValue()).booleanValue();
+                final boolean fldEnabled = enabled ? pnlInputFfmpeg.cbFfmpegOptionResize.isSelected() : false;
+                pnlInputFfmpeg.fldFfmpegOptionResizeWidth.setEnabled(fldEnabled);
+                pnlInputFfmpeg.fldFfmpegOptionResizeHeight.setEnabled(fldEnabled);
+                pnlInputFfmpeg.cbFfmpegOptionKeepAspect.setEnabled(fldEnabled);
+            }
+        });
+
+
+        tbpInput.add("メイン", pnlInputMain);
+        tbpInput.add("ffmpeg", pnlInputFfmpeg);
+
+        // 入力部のボタンやメッセージ表示部
+        fldInputMessage.setEditable(false);
+        fldInputMessage.setEnabled(false);
+        fldInputMessage.setBorder(BorderFactory.createEmptyBorder());
+
+        final JPanel pnlInputButton = new JPanel();
+        final GroupLayout glInputButton = new GroupLayout(pnlInputButton);
+        pnlInputButton.setLayout(glInputButton);
+        glInputButton.setHorizontalGroup(glInputButton.createSequentialGroup()
+            .addContainerGap()
+            .addComponent(fldInputMessage, GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
+            .addPreferredGap(ComponentPlacement.UNRELATED)
+            .addComponent(btnApply)
+            .addContainerGap()
+        );
+        glInputButton.setVerticalGroup(glInputButton.createSequentialGroup()
+            .addContainerGap()
+            .addGroup(glInputButton.createParallelGroup(Alignment.BASELINE)
+                .addComponent(fldInputMessage, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                 .addComponent(btnApply)
-                .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+            )
+            .addContainerGap()
+        );
+
+        // 画面下半分の入力部分
+        final JPanel pnlInputAll = new JPanel();
+        pnlInputAll.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
+        final GroupLayout glInputAll = new GroupLayout(pnlInputAll);
+        pnlInputAll.setLayout(glInputAll);
+        glInputAll.setHorizontalGroup(glInputAll.createParallelGroup()
+            .addComponent(tbpInput)
+            .addComponent(pnlInputButton)
+        );
+        glInputAll.setVerticalGroup(glInputAll.createSequentialGroup()
+            .addComponent(tbpInput)
+            .addComponent(pnlInputButton)
         );
 
         GroupLayout gl_pnlMain = new GroupLayout(pnlMain);
@@ -307,9 +414,10 @@ public class MainFrame extends JFrame {
             .addGroup(Alignment.TRAILING, gl_pnlMain.createSequentialGroup()
                 .addContainerGap()
                 .addGroup(gl_pnlMain.createParallelGroup(Alignment.TRAILING)
-                    .addComponent(pnlInputMain, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                     .addComponent(scrDisplay, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
-                    .addComponent(pnlButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+                    .addComponent(pnlButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addComponent(pnlInputAll, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                )
                 .addContainerGap())
         );
         gl_pnlMain.setVerticalGroup(
@@ -320,8 +428,9 @@ public class MainFrame extends JFrame {
                 .addPreferredGap(ComponentPlacement.RELATED)
                 .addComponent(pnlButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                 .addPreferredGap(ComponentPlacement.RELATED)
-                .addComponent(pnlInputMain, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
-                .addGap(24, 24, 24))
+                .addComponent(pnlInputAll, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+                .addContainerGap()
+            )
         );
 
 
@@ -345,31 +454,61 @@ public class MainFrame extends JFrame {
         tblDisplay.setTransferHandler(new TableTransferHandler());
 
         final Config p = Config.INSTANCE;
-        // TODO コンフィグからスレッド数
-        taskManager = new TaskManager(1, 1);
+        final int thDownload = p.getSystemDownloadThread();
+        final int secDownload = p.getSystemDownloadWait();
+        final int thConvert = p.getSystemConvertThread();
+        taskManager = new TaskManage(thDownload, secDownload,thConvert, new GuiTaskManageListener());
+    }
+
+    private class GuiTaskManageListener implements TaskManageListener {
+
+        @Override
+        public void process(final int id, final TaskKind kind, final TaskStatus status, final double percentage,
+                final String message) {
+            SwingUtilities.invokeLater(new Runnable() {
+
+                @Override
+                public void run() {
+                    targetModel.setStatus(id, kind, status, percentage, message);
+                }
+            });
+        }
+    }
+
+    private class StopActionListener implements ActionListener {
 
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            final int row = tblDisplay.getSelectedRow();
+            final Target t = targetModel.getTarget(row);
+            final boolean res = taskManager.cancel(t.getRowId());
+            logger.log(Level.FINE, "停止: {0} {1}", new Object[]{t.getVideoId(), res});
+            if (res) {
+                targetModel.setStatus(t.getRowId(), null, TaskStatus.CANCELLED, -1.0, "キャンセル");
+            }
+        }
     }
 
     private class ApplyActionListener implements ActionListener {
 
         @Override
         public void actionPerformed(ActionEvent e) {
-            final DownloadProfile prof = new InqubusDownloadProfile();
-            final String id = Util.getVideoId(fldId.getText());
-            logger.log(Level.INFO, prof.toString());
-            // TODO 処理開始
-//            new Download(prof, id).execute();
+            try {
+                final DownloadProfile downProf = new InqubusDownloadProfile();
+                final String id = Util.getVideoId(fldId.getText());
+                final InqubusConvertProfile convProf = new InqubusConvertProfile();
+                logger.log(Level.INFO, downProf.toString());
+                logger.log(Level.INFO, convProf.toString());
+                final RequestProcess rp = new RequestProcess(downProf, id, convProf);
+                taskManager.add(rp);
+                targetModel.addTarget(new Target(rp));
+                initInputPanel();
+            } catch (Throwable th) {
+                logger.log(Level.SEVERE, null, th);
+                JOptionPane.showMessageDialog(MainFrame.this, th.getMessage(), "中断しました", JOptionPane.ERROR_MESSAGE);
+            }
         }
     }
-    /** This method is called from within the constructor to
-     * initialize the form.
-     * WARNING: Do NOT modify this code. The content of this method is
-     * always regenerated by the Form Editor.
-     */
-    @SuppressWarnings("unchecked")
-    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
-    private void initComponents() {
-    }// </editor-fold>//GEN-END:initComponents
 
     private File searchFileMatchId(final File dir, final String id) {
         // TODO 候補は複数返すようにして、その後の対処は呼び出しもとで行ってもらった方が良いかも
@@ -396,6 +535,9 @@ public class MainFrame extends JFrame {
         }
     }
 
+    /**
+     * 動画, コメントの"local"チェックボックス更新時の処理.
+     */
     private void useMovieLocalCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_useMovieLocalCheckBoxItemStateChanged
         final Config p = Config.INSTANCE;
 
@@ -430,8 +572,6 @@ public class MainFrame extends JFrame {
         }
         field.setText(text);
 
-        fldId.setEnabled(!(cbVideoLocal.isSelected() && cbCommentLocal.isSelected()));
-
     }//GEN-LAST:event_useMovieLocalCheckBoxItemStateChanged
 
     private void outputConvertCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_outputConvertCheckBoxItemStateChanged
@@ -466,11 +606,11 @@ public class MainFrame extends JFrame {
     // Variables declaration - do not modify//GEN-BEGIN:variables
     private final JTable tblDisplay;
     // ボタン領域
-    private final JButton btnStart;
-    private final JButton btnStop;
-    private final JButton btnDeselect;
-    //入力領域 - 標準
-    private final JTextField fldId;
+    private final JButton btnStart = new JButton("開始");
+    private final JButton btnStop = new JButton("停止");
+    private final JButton btnDeselect = new JButton("選択解除");
+    // 入力領域 - メイン
+    private final JTextField fldId = new JTextField();
     private final JCheckBox cbBackLogReduce = new JCheckBox("コメ数減少");
     private final JCheckBox cbBackLog = new JCheckBox("過去ログ");
     private final JTextField fldBackLog = new JTextField();
@@ -482,26 +622,24 @@ public class MainFrame extends JFrame {
     private final JButton btnComment;
     private final JCheckBox cbOutputEnable;
     private final JTextField fldOutput;
+    // 入力領域 - ffmpeg
+    private final FfmpegParamPanel pnlInputFfmpeg = new FfmpegParamPanel();
     // 適用
+    private final JTextField fldInputMessage = new JTextField();
     private final JButton btnApply = new JButton("適用");
     // End of variables declaration//GEN-END:variables
 
     private void initInputPanel() {
+        initMainTab();
+        initFfmpegTab();
+    }
+
+    private void initMainTab() {
         final Config p = Config.INSTANCE;
 
         fldId.setText("");
         fldBackLog.setEnabled(false);
-        fldBackLog.setToolTipText("YYYY/MM/DD hh:mm:ss形式、あるいは1970/01/01からの経過秒を入力します。");
         cbBackLog.setEnabled(true);
-        cbBackLog.addItemListener(new ItemListener() {
-
-            @Override
-            public void itemStateChanged(ItemEvent e) {
-                final boolean selected = (e.getStateChange() == ItemEvent.SELECTED);
-                fldBackLog.setEnabled(selected);
-            }
-        });
-        cbBackLogReduce.setToolTipText("「コメントの量を減らす」場合はチェックを付けます。");
 
         final boolean movieLocal = p.getVideoUseLocal();
         cbVideoLocal.setSelected(movieLocal);
@@ -521,7 +659,10 @@ public class MainFrame extends JFrame {
         cbOutputEnable.setSelected(convert);
         fldOutput.setEnabled(convert);
         fldOutput.setText(p.getOutputFileNamePattern());
+    }
 
+    private void initFfmpegTab() {
+        pnlInputFfmpeg.init(Config.INSTANCE);
     }
 
     private JMenuBar initMenuBar() {
@@ -578,20 +719,50 @@ public class MainFrame extends JFrame {
         return menuBar;
     }
 
-    private class DownloadProgressListener implements SaccubusListener<DownloadProgress> {
+    private class DownloadProgressListener implements WorkerListener<DownloadResult, DownloadProgress> {
 
         @Override
         public void process(DownloadProgress progress) {
             throw new UnsupportedOperationException("Not supported yet.");
         }
+
+        @Override
+        public void cancelled() {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public void done(DownloadResult result) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public void error(Throwable th) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
     }
 
-    private class ConvertProgressListener implements SaccubusListener<ConvertProgress> {
+    private class ConvertProgressListener implements WorkerListener<ConvertResult, ConvertProgress> {
 
         @Override
         public void process(ConvertProgress progress) {
             throw new UnsupportedOperationException("Not supported yet.");
         }
+
+        @Override
+        public void cancelled() {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public void done(ConvertResult result) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+
+        @Override
+        public void error(Throwable th) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
     }
 
 
@@ -613,30 +784,32 @@ public class MainFrame extends JFrame {
 
         @Override
         public boolean importData(TransferHandler.TransferSupport support) {
-            try {
-                Transferable transferable = support.getTransferable();
-                if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
-                    @SuppressWarnings("unchecked")
-                    final List<File> data = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
-                    Collection<Target> targets = Target.from(data);
-                    targetModel.addTarget(targets);
-                } else if (transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
-                    String data = (String) transferable.getTransferData(DataFlavor.stringFlavor);
-                    Matcher matcher = movieIdPattern.matcher(data);
-                    if (matcher.find()) {
-                        String movieId = matcher.group(1);
-                        Target target = Target.fromId(movieId);
-                        targetModel.addTarget(target);
-                    } else {
-                        return false;
-                    }
-
-                }
-                return false;
-            } catch (Exception e) {
-                logger.log(Level.SEVERE, null, e);
-                return false;
-            }
+//            try {
+//                Transferable transferable = support.getTransferable();
+//                if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
+//                    @SuppressWarnings("unchecked")
+//                    final List<File> data = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
+//                    Collection<Target> targets = Target.from(data);
+//                    targetModel.addTarget(targets);
+//                } else if (transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
+//                    String data = (String) transferable.getTransferData(DataFlavor.stringFlavor);
+//                    Matcher matcher = movieIdPattern.matcher(data);
+//                    if (matcher.find()) {
+//                        String movieId = matcher.group(1);
+//                        Target target = Target.fromId(movieId);
+//                        targetModel.addTarget(target);
+//                    } else {
+//                        return false;
+//                    }
+//
+//                }
+//                return false;
+//            } catch (Exception e) {
+//                logger.log(Level.SEVERE, null, e);
+//                return false;
+//            }
+            // TODO 上記実装見直し(Locationは削除された)
+            return false;
         }
     }
 
@@ -655,6 +828,9 @@ public class MainFrame extends JFrame {
         }
     }
 
+    /*
+     * ここからDownloadProfile作成用クラスの定義
+     */
 
     private class InqubusDownloadProfile implements DownloadProfile {
 
@@ -821,15 +997,15 @@ public class MainFrame extends JFrame {
 
         private InqubusCommentProfile() {
             final Config p = Config.INSTANCE;
-            this.download = !cbVideoLocal.isSelected();
+            this.download = !cbCommentLocal.isSelected();
             if (this.download) {
-                this.dir = new File(p.getVideoDir());
-                this.fileName = fldVideo.getText();
+                this.dir = new File(p.getCommentDir());
+                this.fileName = fldComment.getText();
                 this.localFile = null;
             } else {
                 this.dir = null;
                 this.fileName = null;
-                this.localFile = new File(fldVideo.getText());
+                this.localFile = new File(fldComment.getText());
             }
 
             if(cbBackLog.isSelected()) {
@@ -919,4 +1095,291 @@ public class MainFrame extends JFrame {
             return ToStringBuilder.reflectionToString(this);
         }
     }
+
+    /*
+     * ここからConvertProfile作成用クラスの定義
+     */
+    private class InqubusConvertProfile implements ConvertProfile {
+        private final OutputProfile outputProfile;
+        private final GeneralProfile generalProfile;
+        private final FfmpegProfile ffmpegProfile;
+        private final boolean convert;
+        private final File ffmpeg;
+        private final boolean vhookDisabled;
+        private final boolean commentOverlay;
+        private final File vhook;
+        private final File tmpDir;
+        private final File font;
+        private final int fontIndex;
+        private final boolean commentOpaque;
+        private final boolean disableFontSizeArrange;
+        private final int shadowIndex;
+        private final boolean showConvrting;
+        private final int maxNumOfComment;
+        private final HideCondition ngSetting;
+
+        private InqubusConvertProfile() throws IOException {
+            final Config p = Config.INSTANCE;
+            this.outputProfile = new InqubusOutputProfile();
+            this.generalProfile = new InqubusGeneralProfile();
+            this.ffmpegProfile = new InqubusFfmpegProfile();
+            this.convert = cbOutputEnable.isSelected();
+            this.ffmpeg = new File(p.getFfmpegPath());
+            // TODO コンフィグに設定なし
+            this.vhookDisabled = false;
+            this.commentOverlay = p.getOutputCommentOverlay();
+            this.vhook = new File(p.getFfmpegDllPath());
+            this.tmpDir = new File(p.getSystemTempDir());
+            this.font = new File(p.getFontPath());
+            this.fontIndex = Integer.parseInt(p.getFontIndex());
+            this.commentOpaque = p.getCommentOpaque();
+            this.disableFontSizeArrange = p.getFontSizeArrangeDisable();
+            this.shadowIndex = p.getFontShadow();
+            // TODO コンフィグに設定なし
+            this.showConvrting = true;
+            this.maxNumOfComment = (p.getCommentDisplaySizeDefault()) ? -1 : Integer.parseInt(p.
+                    getCommentDisplaySizeManual());
+            this.ngSetting = new InqubusHideCondition();
+        }
+
+        @Override
+        public OutputProfile getOutputProfile() {
+            return this.outputProfile;
+        }
+
+        @Override
+        public GeneralProfile getGeneralProfile() {
+            return this.generalProfile;
+        }
+
+        @Override
+        public FfmpegProfile getFfmpegOption() {
+            return this.ffmpegProfile;
+        }
+
+        @Override
+        public boolean isConvert() {
+            return this.convert;
+        }
+
+        @Override
+        public File getFfmpeg() {
+            return this.ffmpeg;
+        }
+
+        @Override
+        public boolean isVhookDisabled() {
+            return this.vhookDisabled;
+        }
+
+        @Override
+        public boolean isCommentOverlay() {
+            return this.commentOverlay;
+        }
+
+        @Override
+        public File getVhook() {
+            return this.vhook;
+        }
+
+        @Override
+        public File getTempDir() {
+            return this.tmpDir;
+        }
+
+        @Override
+        public File getFont() {
+            return this.font;
+        }
+
+        @Override
+        public int getFontIndex() {
+            return this.fontIndex;
+        }
+
+        @Override
+        public boolean isCommentOpaque() {
+            return this.commentOpaque;
+        }
+
+        @Override
+        public boolean isDisableFontSizeArrange() {
+            return this.disableFontSizeArrange;
+        }
+
+        @Override
+        public int getShadowIndex() {
+            return this.shadowIndex;
+        }
+
+        @Override
+        public boolean isShowConverting() {
+            return this.showConvrting;
+        }
+
+        @Override
+        public int getMaxNumOfComment() {
+            return this.maxNumOfComment;
+        }
+
+        @Override
+        public HideCondition getNgSetting() {
+            return this.ngSetting;
+        }
+
+        @Override
+        public String toString(){
+            return ToStringBuilder.reflectionToString(this);
+        }
+    }
+
+    private class InqubusOutputProfile implements OutputProfile {
+        private final File dir;
+        private final String fileName;
+        private final String videoId;
+        private final String title;
+
+
+        private InqubusOutputProfile(){
+            final Config p = Config.INSTANCE;
+            this.dir = new File(p.getOutputDir());
+            this.fileName = fldOutput.getText();
+            // TODO この時点でのID/Titleはどうするか…
+            this.videoId = "";
+            this.title = "";
+        }
+
+        @Override
+        public File getDir() {
+            return this.dir;
+        }
+
+        @Override
+        public String getFileName() {
+            return this.fileName;
+        }
+
+        @Override
+        public String getVideoId() {
+            return this.videoId;
+        }
+
+        @Override
+        public String getTitile() {
+            return this.title;
+        }
+
+        @Override
+        public String toString(){
+            return ToStringBuilder.reflectionToString(this);
+        }
+    }
+
+    private class InqubusFfmpegProfile implements FfmpegProfile {
+        private final String extOption;
+        private final String inOption;
+        private final String mainOption;
+        private final String outOption;
+        private final String avOption;
+        private final boolean resize;
+        private final int resizeWidth;
+        private final int resizeHeight;
+        private final boolean adjustRatio;
+
+        private InqubusFfmpegProfile() throws IOException {
+            final File file = pnlInputFfmpeg.mdlFfmpegOption.getSelectedFile();
+            if (file != null) {
+                final FfmpegOption ffop = FfmpegOption.load(file);
+                this.extOption = ffop.getExtOption();
+                this.inOption = ffop.getInOption();
+                this.mainOption = ffop.getMainOption();
+                this.outOption = ffop.getMainOption();
+                this.avOption = ffop.getAvfilterOption();
+                this.resize = ffop.isResize();
+                this.resizeWidth = ffop.getResizeWidth();
+                this.resizeHeight = ffop.getResizeHeight();
+                this.adjustRatio = ffop.isAdjustRatio();
+            } else {
+                this.extOption = pnlInputFfmpeg.fldFfmpegOptionExtension.getText();
+                this.inOption = pnlInputFfmpeg.fldFfmpegOptionIn.getText();
+                this.mainOption = pnlInputFfmpeg.fldFfmpegOptionMain.getText();
+                this.outOption = pnlInputFfmpeg.fldFfmpegOptionOut.getText();
+                this.avOption = pnlInputFfmpeg.fldFfmpegOptionAv.getText();
+                this.resize = pnlInputFfmpeg.cbFfmpegOptionResize.isSelected();
+                this.resizeWidth = Integer.parseInt(pnlInputFfmpeg.fldFfmpegOptionResizeWidth.getText());
+                this.resizeHeight = Integer.parseInt(pnlInputFfmpeg.fldFfmpegOptionResizeHeight.getText());
+                this.adjustRatio = pnlInputFfmpeg.cbFfmpegOptionKeepAspect.isSelected();
+            }
+        }
+
+        @Override
+        public String getExtOption() {
+            return this.extOption;
+        }
+
+        @Override
+        public String getInOption() {
+            return this.inOption;
+        }
+
+        @Override
+        public String getMainOption() {
+            return this.mainOption;
+        }
+
+        @Override
+        public String getOutOption() {
+            return this.outOption;
+        }
+
+        @Override
+        public String getAvfilterOption() {
+            return this.avOption;
+        }
+
+        @Override
+        public boolean isResize() {
+            return this.resize;
+        }
+
+        @Override
+        public int getResizeWidth() {
+            return this.resizeWidth;
+        }
+
+        @Override
+        public int getResizeHeight() {
+            return this.resizeHeight;
+        }
+
+        @Override
+        public boolean isAdjustRatio() {
+            return this.adjustRatio;
+        }
+
+        @Override
+        public String toString(){
+            return ToStringBuilder.reflectionToString(this);
+        }
+    }
+
+    private class InqubusHideCondition implements ConvertProfile.HideCondition{
+
+        @Override
+        public String getWord() {
+            // TODO
+            return "";
+        }
+
+        @Override
+        public String getId() {
+            // TODO
+            return "";
+        }
+
+        @Override
+        public String toString(){
+            return ToStringBuilder.reflectionToString(this);
+        }
+    }
 }