OSDN Git Service

ffmpegオプションパネルのイベント処理
[coroid/inqubus.git] / frontend / src / yukihane / inqubus / gui / MainFrame.java
1 /*
2  * MainFrame.java
3  *
4  * Created on 2011/05/28, 18:14:51
5  */
6 package yukihane.inqubus.gui;
7
8 import java.awt.Image;
9 import java.awt.ItemSelectable;
10 import java.awt.Toolkit;
11 import java.awt.datatransfer.DataFlavor;
12 import java.awt.datatransfer.Transferable;
13 import java.awt.event.ActionEvent;
14 import java.awt.event.ActionListener;
15 import java.awt.event.ItemEvent;
16 import java.awt.event.ItemListener;
17 import java.awt.event.KeyEvent;
18 import java.beans.PropertyChangeEvent;
19 import java.beans.PropertyChangeListener;
20 import java.io.File;
21 import java.io.FilenameFilter;
22 import java.io.IOException;
23 import java.net.URL;
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.List;
27 import java.util.logging.Level;
28 import java.util.logging.Logger;
29 import java.util.regex.Matcher;
30 import java.util.regex.Pattern;
31 import javax.swing.BorderFactory;
32 import javax.swing.DropMode;
33 import javax.swing.GroupLayout;
34 import javax.swing.GroupLayout.Alignment;
35 import javax.swing.JButton;
36 import javax.swing.JCheckBox;
37 import javax.swing.JFrame;
38 import javax.swing.JLabel;
39 import javax.swing.JMenu;
40 import javax.swing.JMenuBar;
41 import javax.swing.JMenuItem;
42 import javax.swing.JOptionPane;
43 import javax.swing.JPanel;
44 import javax.swing.JScrollPane;
45 import javax.swing.JTabbedPane;
46 import javax.swing.JTable;
47 import javax.swing.JTextField;
48 import javax.swing.KeyStroke;
49 import javax.swing.LayoutStyle.ComponentPlacement;
50 import javax.swing.SwingUtilities;
51 import javax.swing.TransferHandler;
52 import javax.swing.WindowConstants;
53 import javax.swing.border.BevelBorder;
54 import org.apache.commons.lang.StringUtils;
55 import org.apache.commons.lang.builder.ToStringBuilder;
56 import saccubus.FfmpegOption;
57 import saccubus.MainFrame_AboutBox;
58 import saccubus.OptionComboBoxModel;
59 import saccubus.util.WayBackTimeParser;
60 import saccubus.worker.impl.convert.ConvertProgress;
61 import saccubus.worker.impl.download.DownloadProgress;
62 import saccubus.worker.WorkerListener;
63 import saccubus.worker.impl.convert.ConvertResult;
64 import saccubus.worker.impl.download.DownloadResult;
65 import saccubus.worker.profile.CommentProfile;
66 import saccubus.worker.profile.ConvertProfile;
67 import saccubus.worker.profile.DownloadProfile;
68 import saccubus.worker.profile.FfmpegProfile;
69 import saccubus.worker.profile.GeneralProfile;
70 import saccubus.worker.profile.LoginProfile;
71 import saccubus.worker.profile.OutputProfile;
72 import saccubus.worker.profile.ProxyProfile;
73 import saccubus.worker.profile.VideoProfile;
74 import yukihane.Util;
75 import yukihane.inqubus.Config;
76 import yukihane.inqubus.manager.RequestProcess;
77 import yukihane.inqubus.manager.TaskKind;
78 import yukihane.inqubus.manager.TaskManage;
79 import yukihane.inqubus.manager.TaskManageListener;
80 import yukihane.inqubus.manager.TaskStatus;
81 import yukihane.inqubus.model.Target;
82 import yukihane.inqubus.model.TargetsTableModel;
83
84 /**
85  *
86  * @author yuki
87  */
88 public class MainFrame extends JFrame {
89
90     private static final long serialVersionUID = 1L;
91     private static final Logger logger = Logger.getLogger(MainFrame.class.getName());
92     private static final String ID_FIELD_TOOLTIP = "動画のIDまたはURLを入力します。";
93     private static final String FILE_LOCALBUTTON_TOOLTIP
94             = "ダウンロードする場合はチェックを外します。ローカルファイルを使用する場合はチェックを入れます。";
95     private static final String FILE_INPUTFIELD_TOOLTIP
96             = "ダウンロードする場合はファイル命名規則を入力します。"
97             + "ローカルファイルを使用する場合はパスを含むファイル名を入力します。";
98     private static final String FILE_OUTPUTFIELD_TOOLTIP
99             = "ファイル命名規則入力します。";
100     private final TargetsTableModel targetModel = new TargetsTableModel();
101     private final TaskManage taskManager;
102
103     /** Creates new form MainFrame */
104     public MainFrame() {
105         final URL url = MainFrame_AboutBox.class.getResource("icon.png");
106         final Image icon1 = Toolkit.getDefaultToolkit().createImage(url);
107         final URL url32 = MainFrame_AboutBox.class.getResource("icon32.png");
108         final Image icon2 = Toolkit.getDefaultToolkit().createImage(url32);
109         final List<Image> images = new ArrayList<Image>(2);
110         images.add(icon1);
111         images.add(icon2);
112         setIconImages(images);
113
114         final JPanel pnlMain = new JPanel();
115         final JScrollPane scrDisplay = new JScrollPane();
116         tblDisplay = new JTable(targetModel, new TargetsColumnModel());
117         tblDisplay.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
118         final JPanel pnlButton = new JPanel();
119         final JTabbedPane tbpInput = new JTabbedPane();
120         final JPanel pnlInputMain = new JPanel();
121         final JLabel lblId = new JLabel();
122         fldId.setToolTipText(ID_FIELD_TOOLTIP);
123         final JLabel lblVideo = new JLabel();
124         cbVideoLocal = new JCheckBox();
125         cbVideoLocal.setToolTipText(FILE_LOCALBUTTON_TOOLTIP);
126         fldVideo = new JTextField();
127         fldVideo.setToolTipText(FILE_INPUTFIELD_TOOLTIP);
128         btnVideo = new JButton();
129         final JLabel lblComment = new JLabel();
130
131         fldBackLog.setToolTipText("YYYY/MM/DD hh:mm:ss形式、あるいは1970/01/01からの経過秒を入力します。");
132         cbBackLog.addItemListener(new ItemListener() {
133
134             @Override
135             public void itemStateChanged(ItemEvent e) {
136                 final boolean selected = (e.getStateChange() == ItemEvent.SELECTED);
137                 fldBackLog.setEnabled(selected);
138             }
139         });
140         cbBackLog.addPropertyChangeListener("enabled", new PropertyChangeListener() {
141
142             @Override
143             public void propertyChange(PropertyChangeEvent evt) {
144                 final boolean enabled = ((Boolean) evt.getNewValue()).booleanValue();
145                 final boolean fldEnabled = enabled ? cbBackLog.isSelected() : false;
146                 fldBackLog.setEnabled(fldEnabled);
147             }
148         });
149         cbBackLogReduce.setToolTipText("「コメントの量を減らす」場合はチェックを付けます。");
150
151         cbCommentLocal = new JCheckBox();
152         cbCommentLocal.setToolTipText(FILE_LOCALBUTTON_TOOLTIP);
153         cbCommentLocal.addItemListener(new ItemListener() {
154
155             @Override
156             public void itemStateChanged(ItemEvent e) {
157                 final boolean selected = (e.getStateChange() == ItemEvent.SELECTED);
158                 cbBackLogReduce.setEnabled(!selected);
159                 cbBackLog.setEnabled(!selected);
160             }
161         });
162         fldComment = new JTextField();
163         fldComment.setToolTipText(FILE_INPUTFIELD_TOOLTIP);
164         btnComment = new JButton();
165         final JLabel lblOutput = new JLabel();
166         cbOutputEnable = new JCheckBox();
167         fldOutput = new JTextField();
168         fldOutput.setToolTipText(FILE_OUTPUTFIELD_TOOLTIP);
169
170         setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
171
172         btnStop.addActionListener(new StopActionListener());
173         btnApply.addActionListener(new ApplyActionListener());
174
175         pnlMain.setBorder(BorderFactory.createEtchedBorder());
176
177         tblDisplay.setDropMode(DropMode.INSERT_ROWS);
178         scrDisplay.setViewportView(tblDisplay);
179
180         pnlButton.setBorder(BorderFactory.createEtchedBorder());
181
182         GroupLayout gl_pnlButton = new GroupLayout(pnlButton);
183         pnlButton.setLayout(gl_pnlButton);
184         gl_pnlButton.setHorizontalGroup(
185             gl_pnlButton.createParallelGroup(Alignment.LEADING)
186             .addGroup(gl_pnlButton.createSequentialGroup()
187                 .addContainerGap()
188                 .addComponent(btnStart)
189                 .addPreferredGap(ComponentPlacement.RELATED)
190                 .addComponent(btnStop)
191                 .addPreferredGap(ComponentPlacement.RELATED, 250, Short.MAX_VALUE)
192                 .addComponent(btnDeselect)
193                 .addContainerGap())
194         );
195         gl_pnlButton.setVerticalGroup(
196             gl_pnlButton.createParallelGroup(Alignment.LEADING)
197             .addGroup(gl_pnlButton.createSequentialGroup()
198                 .addContainerGap()
199                 .addGroup(gl_pnlButton.createParallelGroup(Alignment.BASELINE)
200                     .addComponent(btnStart)
201                     .addComponent(btnStop)
202                     .addComponent(btnDeselect))
203                 .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
204         );
205
206         lblId.setText("ID");
207
208         fldId.addFocusListener(new java.awt.event.FocusAdapter() {
209
210             public void focusLost(java.awt.event.FocusEvent evt) {
211                 idFieldFocusLost(evt);
212             }
213         });
214
215         lblVideo.setText("動画");
216
217         cbVideoLocal.setText("local");
218         cbVideoLocal.addItemListener(new java.awt.event.ItemListener() {
219
220             public void itemStateChanged(java.awt.event.ItemEvent evt) {
221                 useMovieLocalCheckBoxItemStateChanged(evt);
222             }
223         });
224
225         btnVideo.setText("...");
226
227         lblComment.setText("コメント");
228
229         cbCommentLocal.setText("local");
230         cbCommentLocal.addItemListener(new java.awt.event.ItemListener() {
231
232             public void itemStateChanged(java.awt.event.ItemEvent evt) {
233                 useMovieLocalCheckBoxItemStateChanged(evt);
234             }
235         });
236
237         btnComment.setText("...");
238
239         lblOutput.setText("出力");
240
241         cbOutputEnable.setText("変換");
242         cbOutputEnable.addItemListener(new java.awt.event.ItemListener() {
243
244             public void itemStateChanged(java.awt.event.ItemEvent evt) {
245                 outputConvertCheckBoxItemStateChanged(evt);
246             }
247         });
248
249
250         final GroupLayout glInputMain = new GroupLayout(pnlInputMain);
251         pnlInputMain.setLayout(glInputMain);
252         glInputMain.setHorizontalGroup(
253             glInputMain.createParallelGroup(Alignment.LEADING)
254             .addGroup(glInputMain.createSequentialGroup()
255                 .addContainerGap()
256                 .addComponent(lblId)
257                 .addPreferredGap(ComponentPlacement.RELATED)
258                 .addComponent(fldId, GroupLayout.PREFERRED_SIZE, 100, Short.MAX_VALUE)
259                 .addPreferredGap(ComponentPlacement.UNRELATED)
260                 .addComponent(cbBackLogReduce)
261                 .addPreferredGap(ComponentPlacement.UNRELATED)
262                 .addComponent(cbBackLog)
263                 .addPreferredGap(ComponentPlacement.RELATED)
264                 .addComponent(fldBackLog, GroupLayout.PREFERRED_SIZE, 150, GroupLayout.PREFERRED_SIZE)
265                 .addContainerGap()
266             )
267             .addGroup(glInputMain.createSequentialGroup()
268                 .addContainerGap()
269                 .addGroup(glInputMain.createParallelGroup(Alignment.LEADING)
270                     .addGroup(glInputMain.createSequentialGroup()
271                         .addGroup(glInputMain.createParallelGroup(Alignment.LEADING)
272                             .addComponent(lblVideo)
273                             .addComponent(lblComment)
274                             .addComponent(lblOutput))
275                         .addPreferredGap(ComponentPlacement.RELATED)
276                         .addGroup(glInputMain.createParallelGroup(Alignment.LEADING)
277                             .addGroup(glInputMain.createSequentialGroup()
278                                 .addComponent(cbVideoLocal)
279                                 .addPreferredGap(ComponentPlacement.RELATED)
280                                 .addComponent(fldVideo, GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)
281                                 .addPreferredGap(ComponentPlacement.RELATED)
282                                 .addComponent(btnVideo))
283                             .addGroup(Alignment.TRAILING, glInputMain.createSequentialGroup()
284                                 .addGroup(glInputMain.createParallelGroup(Alignment.TRAILING)
285                                     .addGroup(Alignment.LEADING, glInputMain.createSequentialGroup()
286                                         .addComponent(cbOutputEnable)
287                                         .addPreferredGap(ComponentPlacement.RELATED)
288                                         .addComponent(fldOutput, GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE))
289                                     .addGroup(glInputMain.createSequentialGroup()
290                                         .addComponent(cbCommentLocal)
291                                         .addPreferredGap(ComponentPlacement.RELATED)
292                                         .addComponent(fldComment, GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)))
293                                 .addPreferredGap(ComponentPlacement.RELATED)
294                                 .addComponent(btnComment))))
295                     )
296                 .addContainerGap())
297         );
298         glInputMain.setVerticalGroup(
299             glInputMain.createParallelGroup(Alignment.LEADING)
300             .addGroup(glInputMain.createSequentialGroup()
301                 .addContainerGap()
302                 .addGroup(glInputMain.createParallelGroup(Alignment.BASELINE)
303                     .addComponent(fldId, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
304                     .addComponent(lblId)
305                     .addComponent(cbBackLogReduce)
306                     .addComponent(cbBackLog)
307                     .addComponent(fldBackLog)
308                 )
309                 .addPreferredGap(ComponentPlacement.RELATED)
310                 .addGroup(glInputMain.createParallelGroup(Alignment.BASELINE)
311                     .addComponent(lblVideo)
312                     .addComponent(fldVideo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
313                     .addComponent(btnVideo)
314                     .addComponent(cbVideoLocal))
315                 .addPreferredGap(ComponentPlacement.RELATED)
316                 .addGroup(glInputMain.createParallelGroup(Alignment.BASELINE)
317                     .addComponent(lblComment)
318                     .addComponent(fldComment, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
319                     .addComponent(btnComment)
320                     .addComponent(cbCommentLocal))
321                 .addPreferredGap(ComponentPlacement.RELATED)
322                 .addGroup(glInputMain.createParallelGroup(Alignment.BASELINE)
323                     .addComponent(lblOutput)
324                     .addComponent(fldOutput, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
325                     .addComponent(cbOutputEnable))
326             )
327         );
328
329         // ffmpeg入力パネル
330         pnlInputFfmpeg.fldFfmpegOptionResizeWidth.setEnabled(false);
331         pnlInputFfmpeg.fldFfmpegOptionResizeHeight.setEnabled(false);
332         pnlInputFfmpeg.cbFfmpegOptionKeepAspect.setEnabled(false);
333         pnlInputFfmpeg.cmbFfmpegOptionFile.addActionListener(new ActionListener() {
334
335             @Override
336             public void actionPerformed(ActionEvent e) {
337                 final boolean notFile = !pnlInputFfmpeg.mdlFfmpegOption.isFile();
338                 pnlInputFfmpeg.fldFfmpegOptionExtension.setEnabled(notFile);
339                 pnlInputFfmpeg.fldFfmpegOptionMain.setEnabled(notFile);
340                 pnlInputFfmpeg.fldFfmpegOptionIn.setEnabled(notFile);
341                 pnlInputFfmpeg.fldFfmpegOptionOut.setEnabled(notFile);
342                 pnlInputFfmpeg.fldFfmpegOptionAv.setEnabled(notFile);
343                 pnlInputFfmpeg.cbFfmpegOptionResize.setEnabled(notFile);
344             }
345         });
346         pnlInputFfmpeg.cbFfmpegOptionResize.addItemListener(new ItemListener() {
347
348             @Override
349             public void itemStateChanged(ItemEvent e) {
350                 final boolean selected = (e.getStateChange() == ItemEvent.SELECTED);
351                 pnlInputFfmpeg.fldFfmpegOptionResizeWidth.setEnabled(selected);
352                 pnlInputFfmpeg.fldFfmpegOptionResizeHeight.setEnabled(selected);
353                 pnlInputFfmpeg.cbFfmpegOptionKeepAspect.setEnabled(selected);
354             }
355         });
356         pnlInputFfmpeg.cbFfmpegOptionResize.addPropertyChangeListener("enabled", new PropertyChangeListener() {
357
358             @Override
359             public void propertyChange(PropertyChangeEvent evt) {
360                 final boolean enabled = ((Boolean) evt.getNewValue()).booleanValue();
361                 final boolean fldEnabled = enabled ? pnlInputFfmpeg.cbFfmpegOptionResize.isSelected() : false;
362                 pnlInputFfmpeg.fldFfmpegOptionResizeWidth.setEnabled(fldEnabled);
363                 pnlInputFfmpeg.fldFfmpegOptionResizeHeight.setEnabled(fldEnabled);
364                 pnlInputFfmpeg.cbFfmpegOptionKeepAspect.setEnabled(fldEnabled);
365             }
366         });
367
368
369         tbpInput.add("メイン", pnlInputMain);
370         tbpInput.add("ffmpeg", pnlInputFfmpeg);
371
372         // 入力部のボタンやメッセージ表示部
373         fldInputMessage.setEditable(false);
374         fldInputMessage.setEnabled(false);
375         fldInputMessage.setBorder(BorderFactory.createEmptyBorder());
376
377         final JPanel pnlInputButton = new JPanel();
378         final GroupLayout glInputButton = new GroupLayout(pnlInputButton);
379         pnlInputButton.setLayout(glInputButton);
380         glInputButton.setHorizontalGroup(glInputButton.createSequentialGroup()
381             .addContainerGap()
382             .addComponent(fldInputMessage, GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
383             .addPreferredGap(ComponentPlacement.UNRELATED)
384             .addComponent(btnApply)
385             .addContainerGap()
386         );
387         glInputButton.setVerticalGroup(glInputButton.createSequentialGroup()
388             .addContainerGap()
389             .addGroup(glInputButton.createParallelGroup(Alignment.BASELINE)
390                 .addComponent(fldInputMessage, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
391                 .addComponent(btnApply)
392             )
393             .addContainerGap()
394         );
395
396         // 画面下半分の入力部分
397         final JPanel pnlInputAll = new JPanel();
398         pnlInputAll.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED));
399         final GroupLayout glInputAll = new GroupLayout(pnlInputAll);
400         pnlInputAll.setLayout(glInputAll);
401         glInputAll.setHorizontalGroup(glInputAll.createParallelGroup()
402             .addComponent(tbpInput)
403             .addComponent(pnlInputButton)
404         );
405         glInputAll.setVerticalGroup(glInputAll.createSequentialGroup()
406             .addComponent(tbpInput)
407             .addComponent(pnlInputButton)
408         );
409
410         GroupLayout gl_pnlMain = new GroupLayout(pnlMain);
411         pnlMain.setLayout(gl_pnlMain);
412         gl_pnlMain.setHorizontalGroup(
413             gl_pnlMain.createParallelGroup(Alignment.LEADING)
414             .addGroup(Alignment.TRAILING, gl_pnlMain.createSequentialGroup()
415                 .addContainerGap()
416                 .addGroup(gl_pnlMain.createParallelGroup(Alignment.TRAILING)
417                     .addComponent(scrDisplay, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
418                     .addComponent(pnlButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
419                     .addComponent(pnlInputAll, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
420                 )
421                 .addContainerGap())
422         );
423         gl_pnlMain.setVerticalGroup(
424             gl_pnlMain.createParallelGroup(Alignment.LEADING)
425             .addGroup(Alignment.TRAILING, gl_pnlMain.createSequentialGroup()
426                 .addContainerGap()
427                 .addComponent(scrDisplay, GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
428                 .addPreferredGap(ComponentPlacement.RELATED)
429                 .addComponent(pnlButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
430                 .addPreferredGap(ComponentPlacement.RELATED)
431                 .addComponent(pnlInputAll, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
432                 .addContainerGap()
433             )
434         );
435
436
437         JMenuBar menuBar = initMenuBar();
438         setJMenuBar(menuBar);
439
440         GroupLayout layout = new GroupLayout(getContentPane());
441         getContentPane().setLayout(layout);
442         layout.setHorizontalGroup(
443             layout.createParallelGroup(Alignment.LEADING)
444             .addComponent(pnlMain, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
445         );
446         layout.setVerticalGroup(
447             layout.createParallelGroup(Alignment.LEADING)
448             .addComponent(pnlMain, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
449         );
450
451         pack();
452         initInputPanel();
453         pnlMain.setTransferHandler(new DownloadListTransferHandler());
454         tblDisplay.setTransferHandler(new TableTransferHandler());
455
456         final Config p = Config.INSTANCE;
457         final int thDownload = p.getSystemDownloadThread();
458         final int secDownload = p.getSystemDownloadWait();
459         final int thConvert = p.getSystemConvertThread();
460         taskManager = new TaskManage(thDownload, secDownload,thConvert, new GuiTaskManageListener());
461     }
462
463     private class GuiTaskManageListener implements TaskManageListener {
464
465         @Override
466         public void process(final int id, final TaskKind kind, final TaskStatus status, final double percentage,
467                 final String message) {
468             SwingUtilities.invokeLater(new Runnable() {
469
470                 @Override
471                 public void run() {
472                     targetModel.setStatus(id, kind, status, percentage, message);
473                 }
474             });
475         }
476     }
477
478     private class StopActionListener implements ActionListener {
479
480         @Override
481         public void actionPerformed(ActionEvent e) {
482             final int row = tblDisplay.getSelectedRow();
483             final Target t = targetModel.getTarget(row);
484             final boolean res = taskManager.cancel(t.getRowId());
485             logger.log(Level.FINE, "停止: {0} {1}", new Object[]{t.getVideoId(), res});
486             if (res) {
487                 targetModel.setStatus(t.getRowId(), null, TaskStatus.CANCELLED, -1.0, "キャンセル");
488             }
489         }
490     }
491
492     private class ApplyActionListener implements ActionListener {
493
494         @Override
495         public void actionPerformed(ActionEvent e) {
496             try {
497                 final DownloadProfile downProf = new InqubusDownloadProfile();
498                 final String id = Util.getVideoId(fldId.getText());
499                 final InqubusConvertProfile convProf = new InqubusConvertProfile();
500                 logger.log(Level.INFO, downProf.toString());
501                 logger.log(Level.INFO, convProf.toString());
502                 final RequestProcess rp = new RequestProcess(downProf, id, convProf);
503                 taskManager.add(rp);
504                 targetModel.addTarget(new Target(rp));
505                 initInputPanel();
506             } catch (Throwable th) {
507                 logger.log(Level.SEVERE, null, th);
508                 JOptionPane.showMessageDialog(MainFrame.this, th.getMessage(), "中断しました", JOptionPane.ERROR_MESSAGE);
509             }
510         }
511     }
512
513     private File searchFileMatchId(final File dir, final String id) {
514         // TODO 候補は複数返すようにして、その後の対処は呼び出しもとで行ってもらった方が良いかも
515         if (id.isEmpty()) {
516             return null;
517         }
518
519         final File[] lists = dir.listFiles(new FilenameFilter() {
520
521             final Pattern pattern = Pattern.compile(id + "\\D");
522
523             @Override
524             public boolean accept(File dir, String name) {
525                 return pattern.matcher(name).find();
526             }
527         });
528
529         if (lists.length == 1) {
530             return lists[0];
531         } else if (lists.length > 1) {
532             throw new UnsupportedOperationException();
533         } else {
534             return null;
535         }
536     }
537
538     /**
539      * 動画, コメントの"local"チェックボックス更新時の処理.
540      */
541     private void useMovieLocalCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_useMovieLocalCheckBoxItemStateChanged
542         final Config p = Config.INSTANCE;
543
544         final ItemSelectable source = evt.getItemSelectable();
545
546         JButton btn;
547         JTextField field;
548         File dir;
549         if (source == cbVideoLocal) {
550             btn = btnVideo;
551             field = fldVideo;
552             dir = new File(p.getVideoDir());
553         } else {
554             btn = btnComment;
555             field = fldComment;
556             dir = new File(p.getCommentDir());
557         }
558
559         final boolean useLocal = (evt.getStateChange() == ItemEvent.SELECTED);
560         btn.setEnabled(useLocal);
561
562         String text;
563         if (useLocal) {
564             final File f = searchFileMatchId(dir, fldId.getText());
565             if (f != null) {
566                 text = f.getPath();
567             } else {
568                 text = "";
569             }
570         } else {
571             text = p.getVideoFileNamePattern();
572         }
573         field.setText(text);
574
575     }//GEN-LAST:event_useMovieLocalCheckBoxItemStateChanged
576
577     private void outputConvertCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_outputConvertCheckBoxItemStateChanged
578         final boolean convert = (evt.getStateChange() == ItemEvent.SELECTED);
579         fldOutput.setEnabled(convert);
580     }//GEN-LAST:event_outputConvertCheckBoxItemStateChanged
581
582     private void idFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_idFieldFocusLost
583         final Config p = Config.INSTANCE;
584         final String id = fldId.getText();
585         if (id.isEmpty()) {
586             return;
587         }
588
589         if (cbVideoLocal.isSelected() && fldVideo.getText().isEmpty()) {
590             final File dir = new File(p.getVideoDir());
591             final File file = searchFileMatchId(dir, id);
592             if (file != null) {
593                 fldVideo.setText(file.getPath());
594             }
595         }
596
597         if (cbCommentLocal.isSelected() && fldComment.getText().isEmpty()) {
598             final File dir = new File(p.getCommentDir());
599             final File file = searchFileMatchId(dir, id);
600             if (file != null) {
601                 fldComment.setText(file.getPath());
602             }
603         }
604
605     }//GEN-LAST:event_idFieldFocusLost
606     // Variables declaration - do not modify//GEN-BEGIN:variables
607     private final JTable tblDisplay;
608     // ボタン領域
609     private final JButton btnStart = new JButton("開始");
610     private final JButton btnStop = new JButton("停止");
611     private final JButton btnDeselect = new JButton("選択解除");
612     // 入力領域 - メイン
613     private final JTextField fldId = new JTextField();
614     private final JCheckBox cbBackLogReduce = new JCheckBox("コメ数減少");
615     private final JCheckBox cbBackLog = new JCheckBox("過去ログ");
616     private final JTextField fldBackLog = new JTextField();
617     private final JCheckBox cbVideoLocal;
618     private final JTextField fldVideo;
619     private final JButton btnVideo;
620     private final JCheckBox cbCommentLocal;
621     private final JTextField fldComment;
622     private final JButton btnComment;
623     private final JCheckBox cbOutputEnable;
624     private final JTextField fldOutput;
625     // 入力領域 - ffmpeg
626     private final FfmpegParamPanel pnlInputFfmpeg = new FfmpegParamPanel();
627     // 適用
628     private final JTextField fldInputMessage = new JTextField();
629     private final JButton btnApply = new JButton("適用");
630     // End of variables declaration//GEN-END:variables
631
632     private void initInputPanel() {
633         initMainTab();
634         initFfmpegTab();
635     }
636
637     private void initMainTab() {
638         final Config p = Config.INSTANCE;
639
640         fldId.setText("");
641         fldBackLog.setEnabled(false);
642         cbBackLog.setEnabled(true);
643
644         final boolean movieLocal = p.getVideoUseLocal();
645         cbVideoLocal.setSelected(movieLocal);
646         btnVideo.setEnabled(movieLocal);
647         if (!movieLocal) {
648             fldVideo.setText(p.getVideoFileNamePattern());
649         }
650
651         final boolean commentLocal = p.getCommentUseLocal();
652         cbCommentLocal.setSelected(commentLocal);
653         btnComment.setEnabled(commentLocal);
654         if (!commentLocal) {
655             fldComment.setText(p.getCommentFileNamePattern());
656         }
657
658         final boolean convert = p.getOutputEnable();
659         cbOutputEnable.setSelected(convert);
660         fldOutput.setEnabled(convert);
661         fldOutput.setText(p.getOutputFileNamePattern());
662     }
663
664     private void initFfmpegTab() {
665         pnlInputFfmpeg.init(Config.INSTANCE);
666     }
667
668     private JMenuBar initMenuBar() {
669         final JMenuBar menuBar = new JMenuBar();
670
671         final JMenu mnFile = new JMenu("ファイル(F)");
672         menuBar.add(mnFile);
673
674         final JMenuItem itExit = new JMenuItem("終了(X)", KeyEvent.VK_X);
675         itExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
676         itExit.addActionListener(new ActionListener() {
677
678             @Override
679             public void actionPerformed(ActionEvent e) {
680                 throw new UnsupportedOperationException("Not supported yet.");
681             }
682         });
683         mnFile.add(itExit);
684
685         final JMenu mnTool = new JMenu("ツール(T)");
686         menuBar.add(mnTool);
687
688         final JMenuItem itOption = new JMenuItem("オプション(O)...", KeyEvent.VK_O);
689         // TODO ショートカットキー
690         itOption.addActionListener(new ActionListener() {
691
692             @Override
693             public void actionPerformed(ActionEvent e) {
694                 final yukihane.inqubus.gui.ConfigDialog dlg = new yukihane.inqubus.gui.ConfigDialog(MainFrame.this);
695                 dlg.setLocationRelativeTo(MainFrame.this);
696                 dlg.setModal(true);
697                 dlg.setVisible(true);
698             }
699         });
700         mnTool.add(itOption);
701
702         final JMenu mnHelp = new JMenu("ヘルプ(H)");
703         menuBar.add(mnHelp);
704
705         final JMenuItem itAbout = new JMenuItem("このソフトウェアについて(A)...", KeyEvent.VK_A);
706         itAbout.addActionListener(new ActionListener() {
707
708             @Override
709             public void actionPerformed(ActionEvent e) {
710                 MainFrame_AboutBox dlg = new MainFrame_AboutBox(MainFrame.this);
711                 dlg.pack();
712                 dlg.setLocationRelativeTo(MainFrame.this);
713                 dlg.setModal(true);
714                 dlg.setVisible(true);
715             }
716         });
717         mnHelp.add(itAbout);
718
719         return menuBar;
720     }
721
722     private class DownloadProgressListener implements WorkerListener<DownloadResult, DownloadProgress> {
723
724         @Override
725         public void process(DownloadProgress progress) {
726             throw new UnsupportedOperationException("Not supported yet.");
727         }
728
729         @Override
730         public void cancelled() {
731             throw new UnsupportedOperationException("Not supported yet.");
732         }
733
734         @Override
735         public void done(DownloadResult result) {
736             throw new UnsupportedOperationException("Not supported yet.");
737         }
738
739         @Override
740         public void error(Throwable th) {
741             throw new UnsupportedOperationException("Not supported yet.");
742         }
743     }
744
745     private class ConvertProgressListener implements WorkerListener<ConvertResult, ConvertProgress> {
746
747         @Override
748         public void process(ConvertProgress progress) {
749             throw new UnsupportedOperationException("Not supported yet.");
750         }
751
752         @Override
753         public void cancelled() {
754             throw new UnsupportedOperationException("Not supported yet.");
755         }
756
757         @Override
758         public void done(ConvertResult result) {
759             throw new UnsupportedOperationException("Not supported yet.");
760         }
761
762         @Override
763         public void error(Throwable th) {
764             throw new UnsupportedOperationException("Not supported yet.");
765         }
766     }
767
768
769
770     private class DownloadListTransferHandler extends TransferHandler {
771
772         private static final long serialVersionUID = 1L;
773         private final Pattern movieIdPattern = Pattern.compile("(\\w\\w\\d+)");
774
775         @Override
776         public boolean canImport(TransferHandler.TransferSupport support) {
777             Transferable transferable = support.getTransferable();
778             if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)
779                     || transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
780                 return true;
781             }
782             return false;
783         }
784
785         @Override
786         public boolean importData(TransferHandler.TransferSupport support) {
787 //            try {
788 //                Transferable transferable = support.getTransferable();
789 //                if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
790 //                    @SuppressWarnings("unchecked")
791 //                    final List<File> data = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
792 //                    Collection<Target> targets = Target.from(data);
793 //                    targetModel.addTarget(targets);
794 //                } else if (transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
795 //                    String data = (String) transferable.getTransferData(DataFlavor.stringFlavor);
796 //                    Matcher matcher = movieIdPattern.matcher(data);
797 //                    if (matcher.find()) {
798 //                        String movieId = matcher.group(1);
799 //                        Target target = Target.fromId(movieId);
800 //                        targetModel.addTarget(target);
801 //                    } else {
802 //                        return false;
803 //                    }
804 //
805 //                }
806 //                return false;
807 //            } catch (Exception e) {
808 //                logger.log(Level.SEVERE, null, e);
809 //                return false;
810 //            }
811             // TODO 上記実装見直し(Locationは削除された)
812             return false;
813         }
814     }
815
816     private class TableTransferHandler extends DownloadListTransferHandler {
817
818         private static final long serialVersionUID = 1L;
819
820         @Override
821         public boolean canImport(TransferHandler.TransferSupport support) {
822             return super.canImport(support);
823         }
824
825         @Override
826         public boolean importData(TransferHandler.TransferSupport support) {
827             return super.importData(support);
828         }
829     }
830
831     /*
832      * ここからDownloadProfile作成用クラスの定義
833      */
834
835     private class InqubusDownloadProfile implements DownloadProfile {
836
837         private final LoginProfile loginProfile;
838         private final ProxyProfile proxyProfile;
839         private final VideoProfile videoProfile;
840         private final CommentProfile commentProfile;
841         private final GeneralProfile generalProfile;
842
843         private InqubusDownloadProfile() {
844             this.loginProfile = new InqubusLoginProfile();
845             this.proxyProfile = new InqubusProxyProfile();
846             this.videoProfile = new InqubusVideoProfile();
847             this.commentProfile = new InqubusCommentProfile();
848             this.generalProfile = new InqubusGeneralProfile();
849         }
850
851         @Override
852         public LoginProfile getLoginInfo() {
853             return this.loginProfile;
854         }
855
856         @Override
857         public ProxyProfile getProxyProfile() {
858             return this.proxyProfile;
859         }
860
861         @Override
862         public VideoProfile getVideoProfile() {
863             return this.videoProfile;
864         }
865
866         @Override
867         public CommentProfile getCommentProfile() {
868             return this.commentProfile;
869         }
870
871         @Override
872         public GeneralProfile getGeneralProfile() {
873             return this.generalProfile;
874         }
875
876         @Override
877         public String toString(){
878             return ToStringBuilder.reflectionToString(this);
879         }
880     }
881
882     private class InqubusLoginProfile implements LoginProfile {
883         private final String mail;
884         private final String password;
885
886         private InqubusLoginProfile(){
887             final Config p = Config.INSTANCE;
888             this.mail = p.getId();
889             this.password = p.getPassword();
890         }
891
892         @Override
893         public String getMail() {
894             return this.mail;
895         }
896
897         @Override
898         public String getPassword() {
899             return this.password;
900         }
901
902         @Override
903         public String toString(){
904             return ToStringBuilder.reflectionToString(this);
905         }
906     }
907
908     private class InqubusProxyProfile implements ProxyProfile {
909         private final boolean use;
910         private final String host;
911         private final int port;
912
913         private InqubusProxyProfile(){
914             final Config p = Config.INSTANCE;
915             this.use = p.getProxyUse();
916             this.host = p.getProxyHost();
917             final String pp = p.getProxyPort();
918             this.port = StringUtils.isBlank(pp) ? -1 : Integer.parseInt(pp);
919         }
920
921         @Override
922         public boolean use() {
923             return this.use;
924         }
925
926         @Override
927         public String getHost() {
928             return this.host;
929         }
930
931         @Override
932         public int getPort() {
933             return this.port;
934         }
935
936         @Override
937         public String toString(){
938             return ToStringBuilder.reflectionToString(this);
939         }
940     }
941
942     private class InqubusVideoProfile implements VideoProfile {
943         private final boolean download;
944         private final File dir;
945         private final String fileName;
946         private final File localFile;
947
948         private InqubusVideoProfile(){
949             final Config p = Config.INSTANCE;
950             this.download = !cbVideoLocal.isSelected();
951             if (this.download) {
952                 this.dir = new File(p.getVideoDir());
953                 this.fileName = fldVideo.getText();
954                 this.localFile = null;
955             } else {
956                 this.dir = null;
957                 this.fileName = null;
958                 this.localFile = new File(fldVideo.getText());
959             }
960         }
961
962         @Override
963         public boolean isDownload() {
964             return this.download;
965         }
966
967         @Override
968         public File getDir() {
969             return this.dir;
970         }
971
972         @Override
973         public String getFileName() {
974             return this.fileName;
975         }
976
977         @Override
978         public File getLocalFile() {
979             return this.localFile;
980         }
981
982         @Override
983         public String toString(){
984             return ToStringBuilder.reflectionToString(this);
985         }
986     }
987
988     private class InqubusCommentProfile implements CommentProfile {
989         private final boolean download;
990         private final File dir;
991         private final String fileName;
992         private final File localFile;
993         private final int lengthRelatedCommentSize;
994         private final boolean disablePerMinComment;
995         private final int perMinCommentSize;
996         private final long backLogPoint;
997
998         private InqubusCommentProfile() {
999             final Config p = Config.INSTANCE;
1000             this.download = !cbCommentLocal.isSelected();
1001             if (this.download) {
1002                 this.dir = new File(p.getCommentDir());
1003                 this.fileName = fldComment.getText();
1004                 this.localFile = null;
1005             } else {
1006                 this.dir = null;
1007                 this.fileName = null;
1008                 this.localFile = new File(fldComment.getText());
1009             }
1010
1011             if(cbBackLog.isSelected()) {
1012                 try {
1013                     this.backLogPoint = WayBackTimeParser.parse(fldBackLog.getText());
1014                 } catch (IOException ex) {
1015                     throw new IllegalArgumentException("過去ログ時刻指定が誤っています。", ex);
1016                 }
1017             } else {
1018                 this.backLogPoint = -1L;
1019             }
1020
1021             this.disablePerMinComment = cbBackLogReduce.isSelected();
1022             this.lengthRelatedCommentSize
1023                     = (p.getCommentSizeAutosize()) ? -1 : Integer.parseInt(p.getCommentSizeManual());
1024             this.perMinCommentSize
1025                     = (p.getCommentMinSizeAutosize()) ? -1 : Integer.parseInt(p.getCommentMinSizeManual());
1026         }
1027
1028         @Override
1029         public boolean isDownload() {
1030             return this.download;
1031         }
1032
1033         @Override
1034         public File getDir() {
1035             return this.dir;
1036         }
1037
1038         @Override
1039         public String getFileName() {
1040             return this.fileName;
1041         }
1042
1043         @Override
1044         public File getLocalFile() {
1045             return this.localFile;
1046         }
1047
1048         @Override
1049         public int getLengthRelatedCommentSize() {
1050             return this.lengthRelatedCommentSize;
1051         }
1052
1053         @Override
1054         public boolean isDisablePerMinComment() {
1055             return this.disablePerMinComment;
1056         }
1057
1058         @Override
1059         public int getPerMinCommentSize() {
1060             return this.perMinCommentSize;
1061         }
1062
1063         @Override
1064         public long getBackLogPoint() {
1065             return this.backLogPoint;
1066         }
1067
1068         @Override
1069         public String toString(){
1070             return ToStringBuilder.reflectionToString(this);
1071         }
1072     }
1073
1074     private class InqubusGeneralProfile implements GeneralProfile {
1075         private final String replaceFrom;
1076         private final String replaceTo;
1077         private InqubusGeneralProfile() {
1078             final Config p = Config.INSTANCE;
1079             this.replaceFrom = p.getReplaceFrom();
1080             this.replaceTo = p.getReplaceTo();
1081         }
1082
1083         @Override
1084         public String getReplaceFrom() {
1085             return this.replaceFrom;
1086         }
1087
1088         @Override
1089         public String getReplaceTo() {
1090             return this.replaceTo;
1091         }
1092
1093         @Override
1094         public String toString(){
1095             return ToStringBuilder.reflectionToString(this);
1096         }
1097     }
1098
1099     /*
1100      * ここからConvertProfile作成用クラスの定義
1101      */
1102     private class InqubusConvertProfile implements ConvertProfile {
1103         private final OutputProfile outputProfile;
1104         private final GeneralProfile generalProfile;
1105         private final FfmpegProfile ffmpegProfile;
1106         private final boolean convert;
1107         private final File ffmpeg;
1108         private final boolean vhookDisabled;
1109         private final boolean commentOverlay;
1110         private final File vhook;
1111         private final File tmpDir;
1112         private final File font;
1113         private final int fontIndex;
1114         private final boolean commentOpaque;
1115         private final boolean disableFontSizeArrange;
1116         private final int shadowIndex;
1117         private final boolean showConvrting;
1118         private final int maxNumOfComment;
1119         private final HideCondition ngSetting;
1120
1121         private InqubusConvertProfile() throws IOException {
1122             final Config p = Config.INSTANCE;
1123             this.outputProfile = new InqubusOutputProfile();
1124             this.generalProfile = new InqubusGeneralProfile();
1125             this.ffmpegProfile = new InqubusFfmpegProfile();
1126             this.convert = cbOutputEnable.isSelected();
1127             this.ffmpeg = new File(p.getFfmpegPath());
1128             // TODO コンフィグに設定なし
1129             this.vhookDisabled = false;
1130             this.commentOverlay = p.getOutputCommentOverlay();
1131             this.vhook = new File(p.getFfmpegDllPath());
1132             this.tmpDir = new File(p.getSystemTempDir());
1133             this.font = new File(p.getFontPath());
1134             this.fontIndex = Integer.parseInt(p.getFontIndex());
1135             this.commentOpaque = p.getCommentOpaque();
1136             this.disableFontSizeArrange = p.getFontSizeArrangeDisable();
1137             this.shadowIndex = p.getFontShadow();
1138             // TODO コンフィグに設定なし
1139             this.showConvrting = true;
1140             this.maxNumOfComment = (p.getCommentDisplaySizeDefault()) ? -1 : Integer.parseInt(p.
1141                     getCommentDisplaySizeManual());
1142             this.ngSetting = new InqubusHideCondition();
1143         }
1144
1145         @Override
1146         public OutputProfile getOutputProfile() {
1147             return this.outputProfile;
1148         }
1149
1150         @Override
1151         public GeneralProfile getGeneralProfile() {
1152             return this.generalProfile;
1153         }
1154
1155         @Override
1156         public FfmpegProfile getFfmpegOption() {
1157             return this.ffmpegProfile;
1158         }
1159
1160         @Override
1161         public boolean isConvert() {
1162             return this.convert;
1163         }
1164
1165         @Override
1166         public File getFfmpeg() {
1167             return this.ffmpeg;
1168         }
1169
1170         @Override
1171         public boolean isVhookDisabled() {
1172             return this.vhookDisabled;
1173         }
1174
1175         @Override
1176         public boolean isCommentOverlay() {
1177             return this.commentOverlay;
1178         }
1179
1180         @Override
1181         public File getVhook() {
1182             return this.vhook;
1183         }
1184
1185         @Override
1186         public File getTempDir() {
1187             return this.tmpDir;
1188         }
1189
1190         @Override
1191         public File getFont() {
1192             return this.font;
1193         }
1194
1195         @Override
1196         public int getFontIndex() {
1197             return this.fontIndex;
1198         }
1199
1200         @Override
1201         public boolean isCommentOpaque() {
1202             return this.commentOpaque;
1203         }
1204
1205         @Override
1206         public boolean isDisableFontSizeArrange() {
1207             return this.disableFontSizeArrange;
1208         }
1209
1210         @Override
1211         public int getShadowIndex() {
1212             return this.shadowIndex;
1213         }
1214
1215         @Override
1216         public boolean isShowConverting() {
1217             return this.showConvrting;
1218         }
1219
1220         @Override
1221         public int getMaxNumOfComment() {
1222             return this.maxNumOfComment;
1223         }
1224
1225         @Override
1226         public HideCondition getNgSetting() {
1227             return this.ngSetting;
1228         }
1229
1230         @Override
1231         public String toString(){
1232             return ToStringBuilder.reflectionToString(this);
1233         }
1234     }
1235
1236     private class InqubusOutputProfile implements OutputProfile {
1237         private final File dir;
1238         private final String fileName;
1239         private final String videoId;
1240         private final String title;
1241
1242
1243         private InqubusOutputProfile(){
1244             final Config p = Config.INSTANCE;
1245             this.dir = new File(p.getOutputDir());
1246             this.fileName = fldOutput.getText();
1247             // TODO この時点でのID/Titleはどうするか…
1248             this.videoId = "";
1249             this.title = "";
1250         }
1251
1252         @Override
1253         public File getDir() {
1254             return this.dir;
1255         }
1256
1257         @Override
1258         public String getFileName() {
1259             return this.fileName;
1260         }
1261
1262         @Override
1263         public String getVideoId() {
1264             return this.videoId;
1265         }
1266
1267         @Override
1268         public String getTitile() {
1269             return this.title;
1270         }
1271
1272         @Override
1273         public String toString(){
1274             return ToStringBuilder.reflectionToString(this);
1275         }
1276     }
1277
1278     private class InqubusFfmpegProfile implements FfmpegProfile {
1279         private final String extOption;
1280         private final String inOption;
1281         private final String mainOption;
1282         private final String outOption;
1283         private final String avOption;
1284         private final boolean resize;
1285         private final int resizeWidth;
1286         private final int resizeHeight;
1287         private final boolean adjustRatio;
1288
1289         private InqubusFfmpegProfile() throws IOException {
1290             // TODO FFMPEGオプションは、後でメイン画面でも設定できるようにするかも
1291             final Config p = Config.INSTANCE;
1292             final String opf = p.getFfmpegOptionFile();
1293             if (StringUtils.isNotEmpty(opf)) {
1294                 final File file = new File(opf);
1295                 final FfmpegOption ffop = FfmpegOption.load(file);
1296                 this.extOption = ffop.getExtOption();
1297                 this.inOption = ffop.getInOption();
1298                 this.mainOption = ffop.getMainOption();
1299                 this.outOption = ffop.getMainOption();
1300                 this.avOption = ffop.getAvfilterOption();
1301                 this.resize = ffop.isResize();
1302                 this.resizeWidth = ffop.getResizeWidth();
1303                 this.resizeHeight = ffop.getResizeHeight();
1304                 this.adjustRatio = ffop.isAdjustRatio();
1305                 return;
1306             }
1307             this.extOption = p.getFfmpegExtension();
1308             this.inOption = p.getFfmpegInOption();
1309             this.mainOption = p.getFfmpegMainOption();
1310             this.outOption = p.getFfmpegOutOption();
1311             this.avOption = p.getFfmpegAvOption();
1312             this.resize = p.getFfmpegResizeEnable();
1313             this.resizeWidth = Integer.parseInt(p.getFfmpegResizeWidth());
1314             this.resizeHeight = Integer.parseInt(p.getFfmpegResizeHeight());
1315             this.adjustRatio = p.getFfmpegKeepAspect();
1316         }
1317
1318         @Override
1319         public String getExtOption() {
1320             return this.extOption;
1321         }
1322
1323         @Override
1324         public String getInOption() {
1325             return this.inOption;
1326         }
1327
1328         @Override
1329         public String getMainOption() {
1330             return this.mainOption;
1331         }
1332
1333         @Override
1334         public String getOutOption() {
1335             return this.outOption;
1336         }
1337
1338         @Override
1339         public String getAvfilterOption() {
1340             return this.avOption;
1341         }
1342
1343         @Override
1344         public boolean isResize() {
1345             return this.resize;
1346         }
1347
1348         @Override
1349         public int getResizeWidth() {
1350             return this.resizeWidth;
1351         }
1352
1353         @Override
1354         public int getResizeHeight() {
1355             return this.resizeHeight;
1356         }
1357
1358         @Override
1359         public boolean isAdjustRatio() {
1360             return this.adjustRatio;
1361         }
1362
1363         @Override
1364         public String toString(){
1365             return ToStringBuilder.reflectionToString(this);
1366         }
1367     }
1368
1369     private class InqubusHideCondition implements ConvertProfile.HideCondition{
1370
1371         @Override
1372         public String getWord() {
1373             // TODO
1374             return "";
1375         }
1376
1377         @Override
1378         public String getId() {
1379             // TODO
1380             return "";
1381         }
1382
1383         @Override
1384         public String toString(){
1385             return ToStringBuilder.reflectionToString(this);
1386         }
1387     }
1388 }