/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-
-/*
* MainFrame.java
*
* Created on 2011/05/28, 18:14:51
*/
package yukihane.inqubus.gui;
+import java.awt.Image;
+import java.awt.ItemSelectable;
+import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.KeyEvent;
import java.io.File;
+import java.io.FilenameFilter;
+import java.io.IOException;
+import java.net.URL;
+import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.swing.BorderFactory;
+import javax.swing.DropMode;
+import javax.swing.GroupLayout;
+import javax.swing.GroupLayout.Alignment;
+import javax.swing.JButton;
+import javax.swing.JCheckBox;
+import javax.swing.JFrame;
+import javax.swing.JLabel;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+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.UIManager;
-import javax.swing.UIManager.LookAndFeelInfo;
-import yukihane.inqubus.model.SourceTypeComboBoxModel;
+import javax.swing.WindowConstants;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import saccubus.MainFrame_AboutBox;
+import saccubus.util.WayBackTimeParser;
+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.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;
*
* @author yuki
*/
-public class MainFrame extends javax.swing.JFrame {
+public class MainFrame extends JFrame {
+ private static final long serialVersionUID = 1L;
+ private static final Logger logger = Logger.getLogger(MainFrame.class.getName());
+ private static final String ID_FIELD_TOOLTIP = "動画のIDまたはURLを入力します。";
+ private static final String FILE_LOCALBUTTON_TOOLTIP
+ = "ダウンロードする場合はチェックを外します。ローカルファイルを使用する場合はチェックを入れます。";
+ private static final String FILE_INPUTFIELD_TOOLTIP
+ = "ダウンロードする場合はファイル命名規則を入力します。"
+ + "ローカルファイルを使用する場合はパスを含むファイル名を入力します。";
+ private static final String FILE_OUTPUTFIELD_TOOLTIP
+ = "ファイル命名規則入力します。";
private final TargetsTableModel targetModel = new TargetsTableModel();
+ private final TaskManage taskManager;
/** Creates new form MainFrame */
public MainFrame() {
- initComponents();
- jPanel1.setTransferHandler(new DownloadListTransferHandler());
- jTable1.setTransferHandler(new TableTransferHandler());
- }
+ final URL url = MainFrame_AboutBox.class.getResource("icon.png");
+ final Image icon1 = Toolkit.getDefaultToolkit().createImage(url);
+ final URL url32 = MainFrame_AboutBox.class.getResource("icon32.png");
+ final Image icon2 = Toolkit.getDefaultToolkit().createImage(url32);
+ final List<Image> images = new ArrayList<Image>(2);
+ images.add(icon1);
+ images.add(icon2);
+ setIconImages(images);
- /** 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() {
+ final JPanel pnlMain = new JPanel();
+ final JScrollPane scrDisplay = new JScrollPane();
+ tblDisplay = new JTable(targetModel, new TargetsColumnModel());
+ tblDisplay.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
+ final JPanel pnlButton = new JPanel();
+ 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();
+ cbVideoLocal.setToolTipText(FILE_LOCALBUTTON_TOOLTIP);
+ fldVideo = new JTextField();
+ fldVideo.setToolTipText(FILE_INPUTFIELD_TOOLTIP);
+ btnVideo = new JButton();
+ final JLabel lblComment = new JLabel();
+ cbCommentLocal = new JCheckBox();
+ cbCommentLocal.setToolTipText(FILE_LOCALBUTTON_TOOLTIP);
+ cbCommentLocal.addItemListener(new ItemListener() {
- jPanel1 = new javax.swing.JPanel();
- jScrollPane1 = new javax.swing.JScrollPane();
- jTable1 = new javax.swing.JTable();
- jPanel2 = new javax.swing.JPanel();
- jButton2 = new javax.swing.JButton();
- jButton3 = new javax.swing.JButton();
- jButton4 = new javax.swing.JButton();
- jPanel3 = new javax.swing.JPanel();
- jButton1 = new javax.swing.JButton();
- jLabel1 = new javax.swing.JLabel();
- jLabel2 = new javax.swing.JLabel();
- jLabel3 = new javax.swing.JLabel();
- jComboBox1 = new javax.swing.JComboBox();
- jComboBox2 = new javax.swing.JComboBox();
- jComboBox3 = new javax.swing.JComboBox();
- jCheckBox1 = new javax.swing.JCheckBox();
- jCheckBox2 = new javax.swing.JCheckBox();
- jTextField1 = new javax.swing.JTextField();
- jTextField2 = new javax.swing.JTextField();
- jTextField3 = new javax.swing.JTextField();
- jMenuBar1 = new javax.swing.JMenuBar();
- jMenu1 = new javax.swing.JMenu();
- jMenu2 = new javax.swing.JMenu();
-
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
-
- jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
-
- jTable1.setModel(targetModel);
- jTable1.setDropMode(javax.swing.DropMode.INSERT_ROWS);
- jScrollPane1.setViewportView(jTable1);
-
- jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
-
- jButton2.setText("開始");
-
- jButton3.setText("停止");
-
- jButton4.setText("選択解除");
-
- javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
- jPanel2.setLayout(jPanel2Layout);
- jPanel2Layout.setHorizontalGroup(
- jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel2Layout.createSequentialGroup()
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ final boolean selected = (e.getStateChange() == ItemEvent.SELECTED);
+ cbBackLogReduce.setEnabled(!selected);
+ cbBackLog.setEnabled(!selected);
+ if(selected) {
+ cbBackLog.setSelected(false);
+ }
+ }
+ });
+ fldComment = new JTextField();
+ fldComment.setToolTipText(FILE_INPUTFIELD_TOOLTIP);
+ btnComment = new JButton();
+ final JLabel lblOutput = new JLabel();
+ cbOutputEnable = new JCheckBox();
+ fldOutput = new JTextField();
+ fldOutput.setToolTipText(FILE_OUTPUTFIELD_TOOLTIP);
+
+ setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
+
+ btnStop.addActionListener(new StopActionListener());
+ btnApply.addActionListener(new ApplyActionListener());
+
+ pnlMain.setBorder(BorderFactory.createEtchedBorder());
+
+ tblDisplay.setDropMode(DropMode.INSERT_ROWS);
+ scrDisplay.setViewportView(tblDisplay);
+
+ pnlButton.setBorder(BorderFactory.createEtchedBorder());
+
+ GroupLayout gl_pnlButton = new GroupLayout(pnlButton);
+ pnlButton.setLayout(gl_pnlButton);
+ gl_pnlButton.setHorizontalGroup(
+ gl_pnlButton.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_pnlButton.createSequentialGroup()
.addContainerGap()
- .addComponent(jButton2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jButton3)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 250, Short.MAX_VALUE)
- .addComponent(jButton4)
+ .addComponent(btnStart)
+ .addPreferredGap(ComponentPlacement.RELATED)
+ .addComponent(btnStop)
+ .addPreferredGap(ComponentPlacement.RELATED, 250, Short.MAX_VALUE)
+ .addComponent(btnDeselect)
.addContainerGap())
);
- jPanel2Layout.setVerticalGroup(
- jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel2Layout.createSequentialGroup()
+ gl_pnlButton.setVerticalGroup(
+ gl_pnlButton.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_pnlButton.createSequentialGroup()
.addContainerGap()
- .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jButton2)
- .addComponent(jButton3)
- .addComponent(jButton4))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addGroup(gl_pnlButton.createParallelGroup(Alignment.BASELINE)
+ .addComponent(btnStart)
+ .addComponent(btnStop)
+ .addComponent(btnDeselect))
+ .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
- jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
+ pnlInputMain.setBorder(BorderFactory.createEtchedBorder());
+
+ lblId.setText("ID");
+
+ fldId.addFocusListener(new java.awt.event.FocusAdapter() {
+
+ public void focusLost(java.awt.event.FocusEvent evt) {
+ idFieldFocusLost(evt);
+ }
+ });
- jButton1.setText("適用");
+ lblVideo.setText("動画");
- jLabel1.setText("動画");
+ cbVideoLocal.setText("local");
+ cbVideoLocal.addItemListener(new java.awt.event.ItemListener() {
- jLabel2.setText("コメント");
+ public void itemStateChanged(java.awt.event.ItemEvent evt) {
+ useMovieLocalCheckBoxItemStateChanged(evt);
+ }
+ });
- jLabel3.setText("投コメ");
+ btnVideo.setText("...");
- jComboBox1.setModel(new SourceTypeComboBoxModel());
+ lblComment.setText("コメント");
- jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
+ cbCommentLocal.setText("local");
+ cbCommentLocal.addItemListener(new java.awt.event.ItemListener() {
- jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
+ public void itemStateChanged(java.awt.event.ItemEvent evt) {
+ useMovieLocalCheckBoxItemStateChanged(evt);
+ }
+ });
- jCheckBox1.setText("変換を行う");
+ btnComment.setText("...");
- jCheckBox2.setText("自動で処理開始");
+ lblOutput.setText("出力");
- jTextField1.setText("jTextField1");
+ cbOutputEnable.setText("変換");
+ cbOutputEnable.addItemListener(new java.awt.event.ItemListener() {
- jTextField2.setText("jTextField2");
+ public void itemStateChanged(java.awt.event.ItemEvent evt) {
+ outputConvertCheckBoxItemStateChanged(evt);
+ }
+ });
- jTextField3.setText("jTextField3");
- javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
- jPanel3.setLayout(jPanel3Layout);
- jPanel3Layout.setHorizontalGroup(
- jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel3Layout.createSequentialGroup()
+ GroupLayout gl_pnlInputMain = new GroupLayout(pnlInputMain);
+ pnlInputMain.setLayout(gl_pnlInputMain);
+ gl_pnlInputMain.setHorizontalGroup(
+ gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_pnlInputMain.createSequentialGroup()
.addContainerGap()
- .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel3Layout.createSequentialGroup()
- .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel3)
- .addComponent(jLabel2)
- .addComponent(jLabel1))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel3Layout.createSequentialGroup()
- .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE))
- .addGroup(jPanel3Layout.createSequentialGroup()
- .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jTextField2, javax.swing.GroupLayout.DEFAULT_SIZE, 352, Short.MAX_VALUE))
- .addGroup(jPanel3Layout.createSequentialGroup()
- .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE))))
- .addGroup(jPanel3Layout.createSequentialGroup()
- .addComponent(jCheckBox1)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jCheckBox2)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 209, Short.MAX_VALUE)
- .addComponent(jButton1)))
+ .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_pnlInputMain.createSequentialGroup()
+ .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
+ .addComponent(lblComment)
+ .addComponent(lblVideo)
+ .addComponent(lblId)
+ .addComponent(lblOutput))
+ .addPreferredGap(ComponentPlacement.RELATED)
+ .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_pnlInputMain.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()
+ .addComponent(cbOutputEnable)
+ .addPreferredGap(ComponentPlacement.RELATED)
+ .addComponent(fldOutput, GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE))
+ .addGroup(gl_pnlInputMain.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())
);
- jPanel3Layout.setVerticalGroup(
- jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(jPanel3Layout.createSequentialGroup()
+ gl_pnlInputMain.setVerticalGroup(
+ gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
+ .addGroup(gl_pnlInputMain.createSequentialGroup()
.addContainerGap()
- .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel1)
- .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel2)
- .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel3)
- .addComponent(jComboBox3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(18, 18, 18)
- .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jCheckBox1)
- .addComponent(jCheckBox2)
- .addComponent(jButton1))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.BASELINE)
+ .addComponent(fldId, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(lblId)
+ .addComponent(cbBackLogReduce)
+ .addComponent(cbBackLog)
+ .addComponent(fldBackLog)
+ )
+ .addPreferredGap(ComponentPlacement.RELATED)
+ .addGroup(gl_pnlInputMain.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)
+ .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)
+ .addComponent(lblOutput)
+ .addComponent(fldOutput, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
+ .addComponent(cbOutputEnable))
+ .addPreferredGap(ComponentPlacement.UNRELATED)
+ .addComponent(btnApply)
+ .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
- javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
- jPanel1.setLayout(jPanel1Layout);
- jPanel1Layout.setHorizontalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
+ GroupLayout gl_pnlMain = new GroupLayout(pnlMain);
+ pnlMain.setLayout(gl_pnlMain);
+ gl_pnlMain.setHorizontalGroup(
+ gl_pnlMain.createParallelGroup(Alignment.LEADING)
+ .addGroup(Alignment.TRAILING, gl_pnlMain.createSequentialGroup()
.addContainerGap()
- .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
- .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .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))
.addContainerGap())
);
- jPanel1Layout.setVerticalGroup(
- jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
+ gl_pnlMain.setVerticalGroup(
+ gl_pnlMain.createParallelGroup(Alignment.LEADING)
+ .addGroup(Alignment.TRAILING, gl_pnlMain.createSequentialGroup()
.addContainerGap()
- .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 188, Short.MAX_VALUE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap())
+ .addComponent(scrDisplay, GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
+ .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))
);
- jMenu1.setText("File");
- jMenuBar1.add(jMenu1);
-
- jMenu2.setText("Edit");
- jMenuBar1.add(jMenu2);
- setJMenuBar(jMenuBar1);
+ JMenuBar menuBar = initMenuBar();
+ setJMenuBar(menuBar);
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+ GroupLayout layout = new GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ layout.createParallelGroup(Alignment.LEADING)
+ .addComponent(pnlMain, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ layout.createParallelGroup(Alignment.LEADING)
+ .addComponent(pnlMain, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
- }// </editor-fold>//GEN-END:initComponents
+ initInputPanel();
+ pnlMain.setTransferHandler(new DownloadListTransferHandler());
+ tblDisplay.setTransferHandler(new TableTransferHandler());
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- try {
- for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
- if ("Nimbus".equals(info.getName())) {
- UIManager.setLookAndFeel(info.getClassName());
- break;
+ final Config p = Config.INSTANCE;
+ // TODO コンフィグからスレッド数
+ // TODO downloadの連続処理時待ち時間設定も必要...
+ 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);
}
- }
- } catch (Exception e) {
- try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- } catch (Exception ex) {
- }
+ });
+ }
+ }
+
+ private class StopActionListener implements ActionListener {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ // FIXME 待機中に停止しても「状態」の表示が変わらない。
+ 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});
+ }
+ }
+
+ private class ApplyActionListener implements ActionListener {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ 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));
}
- java.awt.EventQueue.invokeLater(new Runnable() {
+ }
+ /** 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
- public void run() {
- new MainFrame().setVisible(true);
+ private File searchFileMatchId(final File dir, final String id) {
+ // TODO 候補は複数返すようにして、その後の対処は呼び出しもとで行ってもらった方が良いかも
+ if (id.isEmpty()) {
+ return null;
+ }
+
+ final File[] lists = dir.listFiles(new FilenameFilter() {
+
+ final Pattern pattern = Pattern.compile(id + "\\D");
+
+ @Override
+ public boolean accept(File dir, String name) {
+ return pattern.matcher(name).find();
}
});
+
+ if (lists.length == 1) {
+ return lists[0];
+ } else if (lists.length > 1) {
+ throw new UnsupportedOperationException();
+ } else {
+ return null;
+ }
}
+
+ private void useMovieLocalCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_useMovieLocalCheckBoxItemStateChanged
+ final Config p = Config.INSTANCE;
+
+ final ItemSelectable source = evt.getItemSelectable();
+
+ JButton btn;
+ JTextField field;
+ File dir;
+ if (source == cbVideoLocal) {
+ btn = btnVideo;
+ field = fldVideo;
+ dir = new File(p.getVideoDir());
+ } else {
+ btn = btnComment;
+ field = fldComment;
+ dir = new File(p.getCommentDir());
+ }
+
+ final boolean useLocal = (evt.getStateChange() == ItemEvent.SELECTED);
+ btn.setEnabled(useLocal);
+
+ String text;
+ if (useLocal) {
+ final File f = searchFileMatchId(dir, fldId.getText());
+ if (f != null) {
+ text = f.getPath();
+ } else {
+ text = "";
+ }
+ } else {
+ text = p.getVideoFileNamePattern();
+ }
+ 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
+ final boolean convert = (evt.getStateChange() == ItemEvent.SELECTED);
+ fldOutput.setEnabled(convert);
+ }//GEN-LAST:event_outputConvertCheckBoxItemStateChanged
+
+ private void idFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_idFieldFocusLost
+ final Config p = Config.INSTANCE;
+ final String id = fldId.getText();
+ if (id.isEmpty()) {
+ return;
+ }
+
+ if (cbVideoLocal.isSelected() && fldVideo.getText().isEmpty()) {
+ final File dir = new File(p.getVideoDir());
+ final File file = searchFileMatchId(dir, id);
+ if (file != null) {
+ fldVideo.setText(file.getPath());
+ }
+ }
+
+ if (cbCommentLocal.isSelected() && fldComment.getText().isEmpty()) {
+ final File dir = new File(p.getCommentDir());
+ final File file = searchFileMatchId(dir, id);
+ if (file != null) {
+ fldComment.setText(file.getPath());
+ }
+ }
+
+ }//GEN-LAST:event_idFieldFocusLost
// Variables declaration - do not modify//GEN-BEGIN:variables
- private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton2;
- private javax.swing.JButton jButton3;
- private javax.swing.JButton jButton4;
- private javax.swing.JCheckBox jCheckBox1;
- private javax.swing.JCheckBox jCheckBox2;
- private javax.swing.JComboBox jComboBox1;
- private javax.swing.JComboBox jComboBox2;
- private javax.swing.JComboBox jComboBox3;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JMenu jMenu1;
- private javax.swing.JMenu jMenu2;
- private javax.swing.JMenuBar jMenuBar1;
- private javax.swing.JPanel jPanel1;
- private javax.swing.JPanel jPanel2;
- private javax.swing.JPanel jPanel3;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JTable jTable1;
- private javax.swing.JTextField jTextField1;
- private javax.swing.JTextField jTextField2;
- private javax.swing.JTextField jTextField3;
+ private final JTable tblDisplay;
+ // ボタン領域
+ private final JButton btnStart = new JButton("開始");
+ private final JButton btnStop = new JButton("停止");
+ private final JButton btnDeselect = new JButton("選択解除");
+ //入力領域 - 標準
+ private final JTextField fldId;
+ private final JCheckBox cbBackLogReduce = new JCheckBox("コメ数減少");
+ private final JCheckBox cbBackLog = new JCheckBox("過去ログ");
+ private final JTextField fldBackLog = new JTextField();
+ private final JCheckBox cbVideoLocal;
+ private final JTextField fldVideo;
+ private final JButton btnVideo;
+ private final JCheckBox cbCommentLocal;
+ private final JTextField fldComment;
+ private final JButton btnComment;
+ private final JCheckBox cbOutputEnable;
+ private final JTextField fldOutput;
+ // 適用
+ private final JButton btnApply = new JButton("適用");
// End of variables declaration//GEN-END:variables
+ private void initInputPanel() {
+ 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);
+ btnVideo.setEnabled(movieLocal);
+ if (!movieLocal) {
+ fldVideo.setText(p.getVideoFileNamePattern());
+ }
+
+ final boolean commentLocal = p.getCommentUseLocal();
+ cbCommentLocal.setSelected(commentLocal);
+ btnComment.setEnabled(commentLocal);
+ if (!commentLocal) {
+ fldComment.setText(p.getCommentFileNamePattern());
+ }
+
+ final boolean convert = p.getOutputEnable();
+ cbOutputEnable.setSelected(convert);
+ fldOutput.setEnabled(convert);
+ fldOutput.setText(p.getOutputFileNamePattern());
+
+ }
+
+ private JMenuBar initMenuBar() {
+ final JMenuBar menuBar = new JMenuBar();
+
+ final JMenu mnFile = new JMenu("ファイル(F)");
+ menuBar.add(mnFile);
+
+ final JMenuItem itExit = new JMenuItem("終了(X)", KeyEvent.VK_X);
+ itExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
+ itExit.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+ });
+ mnFile.add(itExit);
+
+ final JMenu mnTool = new JMenu("ツール(T)");
+ menuBar.add(mnTool);
+
+ final JMenuItem itOption = new JMenuItem("オプション(O)...", KeyEvent.VK_O);
+ // TODO ショートカットキー
+ itOption.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ final yukihane.inqubus.gui.ConfigDialog dlg = new yukihane.inqubus.gui.ConfigDialog(MainFrame.this);
+ dlg.setLocationRelativeTo(MainFrame.this);
+ dlg.setModal(true);
+ dlg.setVisible(true);
+ }
+ });
+ mnTool.add(itOption);
+
+ final JMenu mnHelp = new JMenu("ヘルプ(H)");
+ menuBar.add(mnHelp);
+
+ final JMenuItem itAbout = new JMenuItem("このソフトウェアについて(A)...", KeyEvent.VK_A);
+ itAbout.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ MainFrame_AboutBox dlg = new MainFrame_AboutBox(MainFrame.this);
+ dlg.pack();
+ dlg.setLocationRelativeTo(MainFrame.this);
+ dlg.setModal(true);
+ dlg.setVisible(true);
+ }
+ });
+ mnHelp.add(itAbout);
+
+ return menuBar;
+ }
+
+ 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 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.");
+ }
+ }
+
+
+
private class DownloadListTransferHandler extends TransferHandler {
+ private static final long serialVersionUID = 1L;
private final Pattern movieIdPattern = Pattern.compile("(\\w\\w\\d+)");
@Override
@Override
public boolean importData(TransferHandler.TransferSupport support) {
- try {
- Transferable transferable = support.getTransferable();
- if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
- 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) {
- e.printStackTrace();
- 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;
}
}
private class TableTransferHandler extends DownloadListTransferHandler {
+ private static final long serialVersionUID = 1L;
+
@Override
public boolean canImport(TransferHandler.TransferSupport support) {
return super.canImport(support);
return super.importData(support);
}
}
+
+ /*
+ * ここからDownloadProfile作成用クラスの定義
+ */
+
+ private class InqubusDownloadProfile implements DownloadProfile {
+
+ private final LoginProfile loginProfile;
+ private final ProxyProfile proxyProfile;
+ private final VideoProfile videoProfile;
+ private final CommentProfile commentProfile;
+ private final GeneralProfile generalProfile;
+
+ private InqubusDownloadProfile() {
+ this.loginProfile = new InqubusLoginProfile();
+ this.proxyProfile = new InqubusProxyProfile();
+ this.videoProfile = new InqubusVideoProfile();
+ this.commentProfile = new InqubusCommentProfile();
+ this.generalProfile = new InqubusGeneralProfile();
+ }
+
+ @Override
+ public LoginProfile getLoginInfo() {
+ return this.loginProfile;
+ }
+
+ @Override
+ public ProxyProfile getProxyProfile() {
+ return this.proxyProfile;
+ }
+
+ @Override
+ public VideoProfile getVideoProfile() {
+ return this.videoProfile;
+ }
+
+ @Override
+ public CommentProfile getCommentProfile() {
+ return this.commentProfile;
+ }
+
+ @Override
+ public GeneralProfile getGeneralProfile() {
+ return this.generalProfile;
+ }
+
+ @Override
+ public String toString(){
+ return ToStringBuilder.reflectionToString(this);
+ }
+ }
+
+ private class InqubusLoginProfile implements LoginProfile {
+ private final String mail;
+ private final String password;
+
+ private InqubusLoginProfile(){
+ final Config p = Config.INSTANCE;
+ this.mail = p.getId();
+ this.password = p.getPassword();
+ }
+
+ @Override
+ public String getMail() {
+ return this.mail;
+ }
+
+ @Override
+ public String getPassword() {
+ return this.password;
+ }
+
+ @Override
+ public String toString(){
+ return ToStringBuilder.reflectionToString(this);
+ }
+ }
+
+ private class InqubusProxyProfile implements ProxyProfile {
+ private final boolean use;
+ private final String host;
+ private final int port;
+
+ private InqubusProxyProfile(){
+ final Config p = Config.INSTANCE;
+ this.use = p.getProxyUse();
+ this.host = p.getProxyHost();
+ final String pp = p.getProxyPort();
+ this.port = StringUtils.isBlank(pp) ? -1 : Integer.parseInt(pp);
+ }
+
+ @Override
+ public boolean use() {
+ return this.use;
+ }
+
+ @Override
+ public String getHost() {
+ return this.host;
+ }
+
+ @Override
+ public int getPort() {
+ return this.port;
+ }
+
+ @Override
+ public String toString(){
+ return ToStringBuilder.reflectionToString(this);
+ }
+ }
+
+ private class InqubusVideoProfile implements VideoProfile {
+ private final boolean download;
+ private final File dir;
+ private final String fileName;
+ private final File localFile;
+
+ private InqubusVideoProfile(){
+ final Config p = Config.INSTANCE;
+ this.download = !cbVideoLocal.isSelected();
+ if (this.download) {
+ this.dir = new File(p.getVideoDir());
+ this.fileName = fldVideo.getText();
+ this.localFile = null;
+ } else {
+ this.dir = null;
+ this.fileName = null;
+ this.localFile = new File(fldVideo.getText());
+ }
+ }
+
+ @Override
+ public boolean isDownload() {
+ return this.download;
+ }
+
+ @Override
+ public File getDir() {
+ return this.dir;
+ }
+
+ @Override
+ public String getFileName() {
+ return this.fileName;
+ }
+
+ @Override
+ public File getLocalFile() {
+ return this.localFile;
+ }
+
+ @Override
+ public String toString(){
+ return ToStringBuilder.reflectionToString(this);
+ }
+ }
+
+ private class InqubusCommentProfile implements CommentProfile {
+ private final boolean download;
+ private final File dir;
+ private final String fileName;
+ private final File localFile;
+ private final int lengthRelatedCommentSize;
+ private final boolean disablePerMinComment;
+ private final int perMinCommentSize;
+ private final long backLogPoint;
+
+ private InqubusCommentProfile() {
+ final Config p = Config.INSTANCE;
+ this.download = !cbCommentLocal.isSelected();
+ if (this.download) {
+ this.dir = new File(p.getCommentDir());
+ this.fileName = fldComment.getText();
+ this.localFile = null;
+ } else {
+ this.dir = null;
+ this.fileName = null;
+ this.localFile = new File(fldComment.getText());
+ }
+
+ if(cbBackLog.isSelected()) {
+ try {
+ this.backLogPoint = WayBackTimeParser.parse(fldBackLog.getText());
+ } catch (IOException ex) {
+ throw new IllegalArgumentException("過去ログ時刻指定が誤っています。", ex);
+ }
+ } else {
+ this.backLogPoint = -1L;
+ }
+
+ this.disablePerMinComment = cbBackLogReduce.isSelected();
+ this.lengthRelatedCommentSize
+ = (p.getCommentSizeAutosize()) ? -1 : Integer.parseInt(p.getCommentSizeManual());
+ this.perMinCommentSize
+ = (p.getCommentMinSizeAutosize()) ? -1 : Integer.parseInt(p.getCommentMinSizeManual());
+ }
+
+ @Override
+ public boolean isDownload() {
+ return this.download;
+ }
+
+ @Override
+ public File getDir() {
+ return this.dir;
+ }
+
+ @Override
+ public String getFileName() {
+ return this.fileName;
+ }
+
+ @Override
+ public File getLocalFile() {
+ return this.localFile;
+ }
+
+ @Override
+ public int getLengthRelatedCommentSize() {
+ return this.lengthRelatedCommentSize;
+ }
+
+ @Override
+ public boolean isDisablePerMinComment() {
+ return this.disablePerMinComment;
+ }
+
+ @Override
+ public int getPerMinCommentSize() {
+ return this.perMinCommentSize;
+ }
+
+ @Override
+ public long getBackLogPoint() {
+ return this.backLogPoint;
+ }
+
+ @Override
+ public String toString(){
+ return ToStringBuilder.reflectionToString(this);
+ }
+ }
+
+ private class InqubusGeneralProfile implements GeneralProfile {
+ private final String replaceFrom;
+ private final String replaceTo;
+ private InqubusGeneralProfile() {
+ final Config p = Config.INSTANCE;
+ this.replaceFrom = p.getReplaceFrom();
+ this.replaceTo = p.getReplaceTo();
+ }
+
+ @Override
+ public String getReplaceFrom() {
+ return this.replaceFrom;
+ }
+
+ @Override
+ public String getReplaceTo() {
+ return this.replaceTo;
+ }
+
+ @Override
+ public String toString(){
+ 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() {
+ 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());
+ // TODO コンフィグに設定なし
+ this.tmpDir = new File(".");
+ 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() {
+ // TODO FFMPEGオプションは、後でメイン画面でも設定できるようにするかも
+ final Config p = Config.INSTANCE;
+ this.extOption = p.getFfmpegExtension();
+ this.inOption = p.getFfmpegInOption();
+ this.mainOption = p.getFfmpegMainOption();
+ this.outOption = p.getFfmpegOutOption();
+ this.avOption = p.getFfmpegAvOption();
+ this.resize = p.getFfmpegResizeEnable();
+ this.resizeWidth = Integer.parseInt(p.getFfmpegResizeWidth());
+ this.resizeHeight = Integer.parseInt(p.getFfmpegResizeHeight());
+ this.adjustRatio = p.getFfmpegKeepAspect();
+ }
+
+ @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);
+ }
+ }
}