OSDN Git Service

サムネイル情報を取得し画面(新規)に表示する機能
[coroid/inqubus.git] / frontend / src / saccubus / MainFrame.java
1 package saccubus;
2
3 import java.io.IOException;
4 import javax.swing.event.ChangeEvent;
5 import saccubus.converter.Converter;
6 import java.awt.BorderLayout;
7 import java.awt.Dimension;
8 import java.awt.GridBagConstraints;
9 import java.awt.GridBagLayout;
10 import java.awt.GridLayout;
11 import java.awt.Image;
12 import java.awt.Insets;
13 import java.awt.Toolkit;
14 import java.awt.dnd.DnDConstants;
15 import java.awt.dnd.DropTarget;
16 import java.awt.event.ActionEvent;
17 import java.awt.event.ActionListener;
18 import java.awt.event.KeyEvent;
19 import java.awt.event.WindowAdapter;
20 import java.awt.event.WindowEvent;
21 import java.io.File;
22 import java.util.logging.Level;
23 import java.util.logging.Logger;
24 import javax.swing.BorderFactory;
25 import javax.swing.ButtonGroup;
26 import javax.swing.GroupLayout;
27 import javax.swing.JButton;
28 import javax.swing.JCheckBox;
29 import javax.swing.JComboBox;
30 import javax.swing.JFileChooser;
31 import javax.swing.JFrame;
32 import javax.swing.JLabel;
33 import javax.swing.JMenu;
34 import javax.swing.JMenuBar;
35 import javax.swing.JMenuItem;
36 import javax.swing.JOptionPane;
37 import javax.swing.JPanel;
38 import javax.swing.JPasswordField;
39 import javax.swing.JRadioButton;
40 import javax.swing.JTabbedPane;
41 import javax.swing.JTextField;
42 import javax.swing.LayoutStyle.ComponentPlacement;
43 import javax.swing.SwingUtilities;
44 import nicobrowser.entity.NicoContent;
45 import nicobrowser.main.Main;
46 import org.apache.commons.lang.StringUtils;
47 import saccubus.ConvertStopFlag.State;
48 import saccubus.converter.profile.FfmpegOption;
49 import saccubus.converter.profile.NgSetting;
50 import saccubus.net.TextProgressListener;
51 import saccubus.properties.BasicSetting;
52 import saccubus.properties.ConvertSetting;
53 import saccubus.properties.InputCommentSetting;
54 import saccubus.properties.InputVideoSetting;
55 import saccubus.properties.SProperties;
56 import saccubus.properties.InputTcommentSetting;
57 import saccubus.properties.MovieSetting;
58 import saccubus.properties.OutputVideoSetting;
59 import saccubus.util.FileDropTarget;
60 import saccubus.util.PopupRightClick;
61 import yukihane.Util;
62 import yukihane.nicovideo.NicoDBFinder;
63
64 /**
65  * <p>
66  * タイトル: さきゅばす
67  * </p>
68  *
69  * <p>
70  * 説明: ニコニコ動画の動画をコメントつきで保存
71  * </p>
72  *
73  * <p>
74  * 著作権: Copyright (c) 2007 PSI
75  * </p>
76  *
77  * <p>
78  * 会社名:
79  * </p>
80  *
81  * @author 未入力
82  * @version 1.0
83  */
84 public class MainFrame extends JFrame {
85
86     private static final long serialVersionUID = 2564486741331062989L;
87     public static final String PRODUCT_NAME = "いんきゅばす";
88     public static final String VERSION = "1.7.2 (NicoBrowser" + Main.VERSION + ")";
89     public static final Image WinIcon = Toolkit.getDefaultToolkit().createImage(saccubus.MainFrame.class.getResource(
90             "icon32.png"));
91     // TODO GUIが無いためフィールドに保持.
92     private File tempDir;
93     JPanel contentPane;
94     BorderLayout borderLayout1 = new BorderLayout();
95     JMenuBar jMenuBar1 = new JMenuBar();
96     JMenu jMenuFile = new JMenu();
97     JMenuItem jMenuFileExit = new JMenuItem();
98     JMenu jMenuHelp = new JMenu();
99     JMenuItem jMenuHelpAbout = new JMenuItem();
100     JLabel statusBar = new JLabel();
101     JTabbedPane mainTabbedPane = new JTabbedPane();
102     JPanel SavingInfoTabPanel = new JPanel();
103     JPanel FFMpegTabPanel = new JPanel();
104     // メインウィンドウ
105     private JPanel videoInfoPanel = new JPanel();
106     private JPanel opPanel = new JPanel();
107     private JLabel videoIdLabel = new JLabel();
108     private JTextField videoIdField = new JTextField();
109     private JButton infoViewButton = new JButton("INFO");
110     private JLabel wayBackLabel = new JLabel();
111     private JTextField wayBackField = new JTextField();
112     private JCheckBox reduceCommentCheckBox = new JCheckBox();
113     private JButton doButton = new JButton();
114     public static final String DoButtonDefString = "変換";
115     public static final String DoButtonStopString = "停止";
116     public static final String DoButtonWaitString = "待機";
117     JPanel UserInfoPanel = new JPanel();
118     GridBagLayout gridBagLayout3 = new GridBagLayout();
119     // ユーザ設定
120     JLabel mailAddressLabel = new JLabel();
121     JTextField mailAddressField = new JTextField();
122     JLabel passwordLabel = new JLabel();
123     JPasswordField passwordField = new JPasswordField();
124     GridBagLayout gridBagLayout4 = new GridBagLayout();
125     GridBagLayout gridBagLayout6 = new GridBagLayout();
126     ButtonGroup CommentSaveButtonGroup = new ButtonGroup();
127     ButtonGroup ConvSaveButtonGroup = new ButtonGroup();
128
129     // 動画情報表示ダイアログ
130     private VideoInfoViewer videoInfoViewer;
131
132     private class FfmpegOptionCheckBoxListener implements ActionListener{
133
134         @Override
135         public void actionPerformed(ActionEvent e) {
136             setFFMpegOptionCheckbox();
137         }
138     }
139     private final FfmpegOptionCheckBoxListener ffmpegOptionCheckBoxListener = new FfmpegOptionCheckBoxListener();
140
141     private void setFFMpegOptionCheckbox() {
142         boolean resizable = (resizeCheckBox.isEnabled() && resizeCheckBox.isSelected());
143         resizeWidthField.setEnabled(resizable);
144         resizeHeigitField.setEnabled(resizable);
145         adjustRatioCheckBox.setEnabled(resizable);
146
147     }
148
149     private void setNames() {
150         mainTabbedPane.setName("mainTabbedPane");
151
152         mailAddressField.setName("mailAddressField");
153         passwordField.setName("passwordField");
154
155         ffmpegPathField.setName("ffmpegPathField");
156         vhookPathField.setName("vhookPathField");
157
158         mainOptionField.setName("mainOptionField");
159         inputOptionField.setName("inputOptionField");
160         outputOptionField.setName("outputOptionField");
161
162         fontPathField.setName("fontPathField");
163         fontIndexField.setName("fontIndexField");
164         showConvVideoCheckBox.setName("showConvVideoCheckBox");
165     }
166
167     public MainFrame() {
168         setNames();
169
170         videoSaveInfoPanel = savePanel.getVideoSaveInfoPanel();
171
172         try {
173             setDefaultCloseOperation(EXIT_ON_CLOSE);
174             jbInit();
175             setPopup();
176             setDropTarget();
177             SProperties setting = SProperties.loadSetting(null,
178                     null);
179             this.setSetting(setting);
180         } catch (Exception exception) {
181             exception.printStackTrace();
182         }
183     }
184
185     private class InfoViewButtonListener implements ActionListener {
186
187         @Override
188         public void actionPerformed(ActionEvent e) {
189             try {
190                 showVideoInfoView(Util.getVideoId(videoIdField.getText()));
191             } catch (Exception ex) {
192                 statusBar.setText(ex.getMessage());
193             }
194         }
195
196         private void showVideoInfoView(String videoId) {
197             if(videoInfoViewer == null){
198                 videoInfoViewer = new VideoInfoViewer(MainFrame.this);
199             }
200             videoInfoViewer.setBasicSetting(getBasicSetting());
201             videoInfoViewer.setVisible(true);
202             videoInfoViewer.load(videoId);
203         }
204     }
205
206     /**
207      * メイン画面最上部(ID/URL, 過去ログ, 変換ボタン)のパネルを初期化します.
208      */
209     private void initVideoInfoPanel() {
210
211         videoIdLabel.setText("URL/ID");
212         wayBackLabel.setText("過去ログ");
213         videoIdField.setText("http://www.nicovideo.jp/watch/");
214         reduceCommentCheckBox.setText("旧仕様コメント数");
215
216         infoViewButton.addActionListener(new InfoViewButtonListener());
217
218         final GroupLayout oppLayout = new GroupLayout(opPanel);
219         opPanel.setLayout(oppLayout);
220
221         oppLayout.setHorizontalGroup(oppLayout.createSequentialGroup()
222                 .addGroup(oppLayout.createParallelGroup()
223                     .addComponent(videoIdLabel)
224                     .addComponent(wayBackLabel))
225                 .addGroup(oppLayout.createParallelGroup()
226                     .addGroup(oppLayout.createSequentialGroup()
227                         .addComponent(videoIdField)
228                         .addComponent(infoViewButton))
229                     .addGroup(oppLayout.createSequentialGroup()
230                         .addComponent(wayBackField)
231                         .addComponent(reduceCommentCheckBox)))
232                 );
233
234         oppLayout.setVerticalGroup(oppLayout.createSequentialGroup()
235                     .addGroup(oppLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
236                         .addComponent(videoIdLabel)
237                         .addComponent(videoIdField)
238                         .addComponent(infoViewButton))
239                     .addGroup(oppLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
240                         .addComponent(wayBackLabel)
241                         .addComponent(wayBackField)
242                         .addComponent(reduceCommentCheckBox))
243                 );
244
245         doButton.setText(DoButtonDefString);
246         doButton.addActionListener(new MainFrame_DoButton_actionAdapter(this));
247
248         final GroupLayout vipLayout = new GroupLayout(videoInfoPanel);
249         videoInfoPanel.setLayout(vipLayout);
250
251         vipLayout.setHorizontalGroup(vipLayout.createSequentialGroup()
252                 .addComponent(opPanel).addComponent(doButton));
253
254         vipLayout.setVerticalGroup(vipLayout.createParallelGroup()
255                 .addComponent(opPanel).addComponent(doButton, 10, 20, 50));
256     }
257
258     /**
259      * コンポーネントの初期化。
260      *
261      * @throws java.lang.Exception
262      */
263     private void jbInit() throws Exception {
264
265         initVideoInfoPanel();
266
267         GridBagConstraints gridBagConstraints74 = new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
268                 GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0);
269         gridBagConstraints74.gridwidth = 2;
270         GridBagConstraints gridBagConstraints73 = new GridBagConstraints();
271         gridBagConstraints73.fill = GridBagConstraints.HORIZONTAL;
272         gridBagConstraints73.gridy = 6;
273         gridBagConstraints73.weightx = 1.0;
274         gridBagConstraints73.gridwidth = 4;
275         gridBagConstraints73.insets = new Insets(0, 0, 0, 5);
276         gridBagConstraints73.gridx = 1;
277         GridBagConstraints gridBagConstraints72 = new GridBagConstraints();
278         gridBagConstraints72.gridx = 0;
279         gridBagConstraints72.anchor = GridBagConstraints.WEST;
280         gridBagConstraints72.insets = new Insets(0, 5, 0, 5);
281         gridBagConstraints72.fill = GridBagConstraints.NONE;
282         gridBagConstraints72.gridwidth = 1;
283         gridBagConstraints72.gridy = 6;
284         ShadowKindLabel = new JLabel();
285         ShadowKindLabel.setText("影の種類");
286         ShadowKindLabel.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED);
287         GridBagConstraints gridBagConstraints66 = new GridBagConstraints();
288         gridBagConstraints66.gridx = 0;
289         gridBagConstraints66.insets = new Insets(0, 5, 5, 5);
290         gridBagConstraints66.anchor = GridBagConstraints.WEST;
291         gridBagConstraints66.gridwidth = 2;
292         gridBagConstraints66.gridy = 1;
293         ViewCommentLabel = new JLabel();
294         ViewCommentLabel.setText("表示コメント数");
295         GridBagConstraints gridBagConstraints65 = new GridBagConstraints();
296         gridBagConstraints65.fill = GridBagConstraints.HORIZONTAL;
297         gridBagConstraints65.gridy = 1;
298         gridBagConstraints65.weightx = 1.0;
299         gridBagConstraints65.gridwidth = 6;
300         gridBagConstraints65.insets = new Insets(0, 5, 5, 5);
301         gridBagConstraints65.gridx = 3;
302         GridBagConstraints gridBagConstraints64 = new GridBagConstraints(1, 1,
303                 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
304                 GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0);
305         gridBagConstraints64.gridy = 3;
306         gridBagConstraints64.fill = GridBagConstraints.HORIZONTAL;
307         gridBagConstraints64.gridx = 4;
308         GridBagConstraints gridBagConstraints63 = new GridBagConstraints(0, 4,
309                 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
310                 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
311         gridBagConstraints63.gridy = 7;
312         gridBagConstraints63.gridx = 0;
313         gridBagConstraints63.gridwidth = 5;
314         GridBagConstraints gridBagConstraints62 = new GridBagConstraints(0, 3,
315                 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
316                 GridBagConstraints.BOTH, new Insets(0, 5, 5, 5), 0, 0);
317         gridBagConstraints62.gridy = 5;
318         gridBagConstraints62.gridx = 1;
319         gridBagConstraints62.fill = GridBagConstraints.HORIZONTAL;
320         gridBagConstraints62.insets = new Insets(0, 0, 5, 5);
321         gridBagConstraints62.gridwidth = 4;
322         GridBagConstraints gridBagConstraints61 = new GridBagConstraints(0, 2,
323                 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
324                 GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0);
325         gridBagConstraints61.gridy = 5;
326         gridBagConstraints61.gridx = 0;
327         gridBagConstraints61.fill = GridBagConstraints.VERTICAL;
328         gridBagConstraints61.anchor = GridBagConstraints.WEST;
329         gridBagConstraints61.gridwidth = 1;
330         GridBagConstraints gridBagConstraints60 = new GridBagConstraints(0, 1,
331                 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
332                 GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 0);
333         gridBagConstraints60.gridy = 3;
334         gridBagConstraints60.gridx = 1;
335         gridBagConstraints60.fill = GridBagConstraints.HORIZONTAL;
336         gridBagConstraints60.insets = new Insets(0, 0, 0, 5);
337         gridBagConstraints60.gridwidth = 3;
338         GridBagConstraints gridBagConstraints59 = new GridBagConstraints(0, 0,
339                 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
340                 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0);
341         gridBagConstraints59.gridy = 3;
342         gridBagConstraints59.insets = new Insets(5, 5, 5, 5);
343         gridBagConstraints59.gridx = 0;
344         gridBagConstraints59.fill = GridBagConstraints.NONE;
345         gridBagConstraints59.anchor = GridBagConstraints.WEST;
346         gridBagConstraints59.weightx = 0.0;
347         gridBagConstraints59.gridwidth = 1;
348         GridBagConstraints gridBagConstraints58 = new GridBagConstraints();
349         gridBagConstraints58.gridx = 0;
350         gridBagConstraints58.anchor = GridBagConstraints.WEST;
351         gridBagConstraints58.insets = new Insets(0, 5, 5, 5);
352         gridBagConstraints58.gridwidth = 5;
353         gridBagConstraints58.weightx = 1.0;
354         gridBagConstraints58.fill = GridBagConstraints.HORIZONTAL;
355         gridBagConstraints58.gridy = 0;
356
357         GridBagConstraints gridBagConstraints54 = new GridBagConstraints(0, 2, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
358                 GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0);
359         gridBagConstraints54.gridwidth = 3;
360
361         GridBagConstraints gridBagConstraints33 = new GridBagConstraints();
362         gridBagConstraints33.gridx = 0;
363         gridBagConstraints33.fill = GridBagConstraints.HORIZONTAL;
364         gridBagConstraints33.weightx = 1.0;
365         gridBagConstraints33.insets = new Insets(0, 5, 5, 5);
366         gridBagConstraints33.gridwidth = 5;
367         gridBagConstraints33.gridy = 9;
368
369         GridBagConstraints gridBagConstraints14 = new GridBagConstraints();
370         gridBagConstraints14.gridx = 0;
371         gridBagConstraints14.anchor = GridBagConstraints.WEST;
372         gridBagConstraints14.fill = GridBagConstraints.HORIZONTAL;
373         gridBagConstraints14.weightx = 1.0;
374         gridBagConstraints14.gridwidth = 5;
375         gridBagConstraints14.insets = new Insets(0, 5, 0, 5);
376         gridBagConstraints14.gridy = 8;
377         GridBagConstraints gridBagConstraints7 = new GridBagConstraints(0, 0,
378                 1, 1, 1.0, 1.0, GridBagConstraints.NORTH,
379                 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
380         gridBagConstraints7.weighty = 0.0;
381         GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
382         gridBagConstraints6.gridx = 0;
383         gridBagConstraints6.weighty = 1.0;
384         gridBagConstraints6.weightx = 1.0;
385         gridBagConstraints6.insets = new Insets(0, 5, 0, 5);
386         gridBagConstraints6.fill = GridBagConstraints.HORIZONTAL;
387         gridBagConstraints6.anchor = GridBagConstraints.NORTH;
388         gridBagConstraints6.gridy = 1;
389         GridBagConstraints gridBagConstraints1 = new GridBagConstraints(0, 1,
390                 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
391                 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
392         gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
393         gridBagConstraints1.anchor = GridBagConstraints.NORTH;
394         gridBagConstraints1.weighty = 1.0;
395
396         this.setIconImage(WinIcon);
397         contentPane = (JPanel) this.getContentPane();
398         contentPane.setLayout(borderLayout1);
399         setSize(new Dimension(400, 450));
400         setTitle(PRODUCT_NAME + " " + VERSION);
401         this.addWindowListener(new MainFrame_this_windowAdapter(this));
402         statusBar.setText(" ");
403         jMenuFile.setText("ファイル");
404         jMenuFileExit.setText("終了");
405         jMenuFileExit.addActionListener(new MainFrame_jMenuFileExit_ActionAdapter(
406                 this));
407         jMenuHelp.setText("ヘルプ");
408         jMenuHelpAbout.setText("バージョン情報");
409         jMenuHelpAbout.addActionListener(new MainFrame_jMenuHelpAbout_ActionAdapter(
410                 this));
411         SavingInfoTabPanel.setLayout(new GridLayout());
412         UserInfoPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "ユーザ設定"));
413         UserInfoPanel.setLayout(gridBagLayout3);
414         mailAddressLabel.setText("メールアドレス");
415         passwordLabel.setText("パスワード");
416
417         setListenerToSavePanelButton();
418
419         FFMpegTabPanel.setLayout(gridBagLayout6);
420         PathSettingPanel.setBorder(BorderFactory.createTitledBorder(
421                 BorderFactory.createEtchedBorder(), "プログラムの位置の設定"));
422         PathSettingPanel.setLayout(gridBagLayout7);
423         FFmpegPathLabel.setText("FFmpeg");
424         SettingFFmpegPathButton.setText("参照");
425         SettingFFmpegPathButton.addActionListener(new MainFrame_SettingFFmpegPathButton_actionAdapter(
426                 this));
427         VhookPathLabel.setText("拡張vhookライブラリ");
428         SettingVhookPathButton.setText("参照");
429         SettingVhookPathButton.addActionListener(new MainFrame_SettingVhookPathButton_actionAdapter(
430                 this));
431         VhookSettingPanel.setLayout(gridBagLayout8);
432         VhookSettingPanel.setBorder(BorderFactory.createTitledBorder(
433                 BorderFactory.createEtchedBorder(), "拡張vhookライブラリの設定"));
434         FFmpegSettingPanel.setBorder(BorderFactory.createTitledBorder(
435                 BorderFactory.createEtchedBorder(), "FFmpegの設定"));
436         FFmpegSettingPanel.setLayout(gblFFmpegSettingPanel);
437         FontPathLabel.setText("フォントパス");
438         SettingFontPathButton.setText("参照");
439         SettingFontPathButton.addActionListener(new MainFrame_SettingFontPathButton_actionAdapter(
440                 this));
441         showConvVideoCheckBox.setText("変換中の画像を表示する");
442
443         extOptionLabel.setText("出力動画の拡張子");
444         inputOptionLabel.setText("入力オプション");
445         outputOptionLabel.setText("出力オプション");
446         mainOptionLabel.setText("メインオプション");
447         avfilterOptionLabel.setText("avfilterオプション");
448
449         FontIndexLabel.setText("フォント番号");
450
451         BasicInfoTabPanel.setLayout(gridBagLayout12);
452         jMenuBar1.add(jMenuFile);
453         jMenuFile.add(jMenuFileExit);
454         jMenuBar1.add(jMenuHelp);
455         jMenuHelp.add(jMenuHelpAbout);
456         setJMenuBar(jMenuBar1);
457
458         contentPane.add(statusBar, BorderLayout.SOUTH);
459         contentPane.add(mainTabbedPane, java.awt.BorderLayout.CENTER);
460         contentPane.add(videoInfoPanel, java.awt.BorderLayout.NORTH);
461         UserInfoPanel.add(passwordField, new GridBagConstraints(1, 1, 1, 1,
462                 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
463                 new Insets(0, 5, 5, 5), 0, 0));
464         UserInfoPanel.add(mailAddressField, new GridBagConstraints(1, 0, 1, 1,
465                 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
466                 new Insets(0, 5, 5, 5), 0, 0));
467         UserInfoPanel.add(passwordLabel, new GridBagConstraints(0, 1, 1, 1,
468                 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
469                 new Insets(0, 5, 5, 0), 0, 0));
470         UserInfoPanel.add(mailAddressLabel, new GridBagConstraints(0, 0, 1, 1,
471                 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE,
472                 new Insets(0, 5, 5, 0), 0, 0));
473         PathSettingPanel.add(ffmpegPathField, new GridBagConstraints(0, 1, 1,
474                 1, 1.0, 0.0, GridBagConstraints.CENTER,
475                 GridBagConstraints.BOTH, new Insets(0, 5, 0, 5), 0, 0));
476         PathSettingPanel.add(SettingFFmpegPathButton, gridBagConstraints74);
477         PathSettingPanel.add(FFmpegPathLabel, new GridBagConstraints(0, 0, 2,
478                 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
479                 new Insets(0, 5, 5, 5), 0, 0));
480         PathSettingPanel.add(vhookPathField, new GridBagConstraints(0, 3, 1, 1,
481                 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
482                 new Insets(0, 5, 5, 5), 0, 0));
483         PathSettingPanel.add(SettingVhookPathButton, new GridBagConstraints(1,
484                 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
485                 GridBagConstraints.BOTH, new Insets(0, 0, 5, 5), 0, 0));
486         PathSettingPanel.add(VhookPathLabel, gridBagConstraints54);
487
488
489         final GroupLayout layout = new GroupLayout(FFmpegSettingPanel);
490         FFmpegSettingPanel.setLayout(layout);
491
492         layout.setHorizontalGroup(layout.createParallelGroup()
493                 .addComponent(getFFmpegOptionComboBoxPanel())
494                 .addGroup(layout.createSequentialGroup()
495                     .addGroup(layout.createParallelGroup()
496                         .addComponent(extOptionLabel)
497                         .addComponent(mainOptionLabel)
498                         .addComponent(inputOptionLabel)
499                         .addComponent(outputOptionLabel)
500                         .addComponent(avfilterOptionLabel)
501                     )
502                     .addPreferredGap(ComponentPlacement.RELATED)
503                     .addGroup(layout.createParallelGroup()
504                         .addComponent(extOptionField)
505                         .addComponent(mainOptionField)
506                         .addComponent(inputOptionField)
507                         .addComponent(outputOptionField)
508                         .addComponent(avfilterOptionField)
509                     )
510                 )
511                 .addGroup(layout.createParallelGroup()
512                     .addGroup(layout.createSequentialGroup()
513                         .addComponent(resizeCheckBox)
514                         .addPreferredGap(ComponentPlacement.UNRELATED)
515                         .addComponent(resizeWidthLabel)
516                         .addPreferredGap(ComponentPlacement.RELATED)
517                         .addComponent(resizeWidthField)
518                         .addPreferredGap(ComponentPlacement.UNRELATED)
519                         .addComponent(resizeHeightLabel)
520                         .addPreferredGap(ComponentPlacement.RELATED)
521                         .addComponent(resizeHeigitField)
522                     )
523                 )
524                 .addGroup(layout.createSequentialGroup()
525                     .addGap(10)
526                     .addComponent(adjustRatioCheckBox))
527                 .addGroup(layout.createSequentialGroup()
528                     .addGap(20)
529                 )
530             );
531
532         layout.setVerticalGroup(layout.createSequentialGroup()
533             .addComponent(getFFmpegOptionComboBoxPanel())
534             .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
535                 .addComponent(extOptionLabel)
536                 .addComponent(extOptionField))
537             .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
538                 .addComponent(mainOptionLabel)
539                 .addComponent(mainOptionField))
540             .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
541                 .addComponent(inputOptionLabel)
542                 .addComponent(inputOptionField))
543             .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
544                 .addComponent(outputOptionLabel)
545                 .addComponent(outputOptionField))
546             .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
547                 .addComponent(avfilterOptionLabel)
548                 .addComponent(avfilterOptionField))
549             .addGroup(layout.createSequentialGroup()
550                 .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
551                     .addComponent(resizeCheckBox)
552                     .addComponent(resizeWidthLabel)
553                     .addComponent(resizeWidthField)
554                     .addComponent(resizeHeightLabel)
555                     .addComponent(resizeHeigitField))
556                 .addComponent(adjustRatioCheckBox)
557                 )
558             );
559
560         resizeCheckBox.addActionListener(ffmpegOptionCheckBoxListener);
561         adjustRatioCheckBox.addActionListener(ffmpegOptionCheckBoxListener);
562         setFFMpegOptionCheckbox();
563
564
565
566         mainTabbedPane.add(BasicInfoTabPanel, "基本設定");
567         mainTabbedPane.add(SavingInfoTabPanel, "保存設定");
568         mainTabbedPane.add(FFMpegTabPanel, "動画設定");
569         mainTabbedPane.addTab("変換設定", null, getConvertingSettingPanel(), null);
570         SavingInfoTabPanel.add(savePanel);
571         BasicInfoTabPanel.add(UserInfoPanel, gridBagConstraints7);
572         BasicInfoTabPanel.add(getProxyInfoPanel(), gridBagConstraints6);
573         VhookSettingPanel.add(FontPathLabel, gridBagConstraints59);
574         VhookSettingPanel.add(showConvVideoCheckBox, gridBagConstraints63);
575         VhookSettingPanel.add(fontPathField, gridBagConstraints60);
576         VhookSettingPanel.add(fontIndexField, gridBagConstraints62);
577         VhookSettingPanel.add(FontIndexLabel, gridBagConstraints61);
578         VhookSettingPanel.add(SettingFontPathButton, gridBagConstraints64);
579         VhookSettingPanel.add(getFixFontSizeCheckBox(), gridBagConstraints14);
580         VhookSettingPanel.add(getOpaqueCommentCheckBox(), gridBagConstraints33);
581         VhookSettingPanel.add(getNotUseVhookCheckBox(), gridBagConstraints58);
582         VhookSettingPanel.add(getViewCommentField(), gridBagConstraints65);
583         VhookSettingPanel.add(ViewCommentLabel, gridBagConstraints66);
584         VhookSettingPanel.add(ShadowKindLabel, gridBagConstraints72);
585         VhookSettingPanel.add(getShadowComboBox(), gridBagConstraints73);
586
587         FFMpegTabPanel.add(PathSettingPanel, new GridBagConstraints(0, 0, 1, 1,
588                 1.0, 0.0, GridBagConstraints.NORTHEAST,
589                 GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0));
590         FFMpegTabPanel.add(FFmpegSettingPanel, gridBagConstraints1);
591     }
592
593     /**
594      * 保存設定パネル内のボタンにアクションリスナを割り当てる.
595      */
596     private void setListenerToSavePanelButton() {
597         ActionListener al;
598         al = new InputVideoPanelButtonListener();
599         videoSaveInfoPanel.getShowSavingVideoFolderDialogButton().addActionListener(al);
600         videoSaveInfoPanel.getShowSavingVideoFileDialogButton().addActionListener(al);
601         videoSaveInfoPanel.getNibrFileChooserButton().addActionListener(al);
602
603         al = new VideoUseRadioButtonListener();
604         videoSaveInfoPanel.getVideoNoSaveButton().addActionListener(al);
605         videoSaveInfoPanel.getVideoSaveButton().addActionListener(al);
606         videoSaveInfoPanel.getVideoUseNiBrButton().addActionListener(al);
607
608         al = new InputCommentPanelButtonListener();
609         savePanel.getShowSavingCommentFolderDialogButton().addActionListener(al);
610         savePanel.getShowSavingCommentFileDialogButton().addActionListener(al);
611
612         al = new OutputVideoPanelButtonListener();
613         savePanel.getShowSavingConvertedVideoFolderDialogButton().addActionListener(al);
614         savePanel.getShowSavingConvertedVideoFileDialogButton().addActionListener(al);
615     }
616
617     private void setPopup() {
618         mainOptionField.addMouseListener(new PopupRightClick(
619                 this.mainOptionField));
620         inputOptionField.addMouseListener(new PopupRightClick(
621                 this.inputOptionField));
622         outputOptionField.addMouseListener(new PopupRightClick(
623                 this.outputOptionField));
624         savePanel.getCommentNumField().addMouseListener(new PopupRightClick(
625                 savePanel.getCommentNumField()));
626
627         savePanel.getCommentSavedFileField().addMouseListener(new PopupRightClick(
628                 savePanel.getCommentSavedFileField()));
629         savePanel.getCommentSavedFolderField().addMouseListener(new PopupRightClick(
630                 savePanel.getCommentSavedFolderField()));
631
632         savePanel.getConvertedVideoSavedFileField().addMouseListener(new PopupRightClick(
633                 savePanel.getConvertedVideoSavedFileField()));
634         savePanel.getConvertedVideoSavedFolderField().addMouseListener(new PopupRightClick(
635                 savePanel.getConvertedVideoSavedFolderField()));
636
637         videoSaveInfoPanel.getVideoSavedFileField().addMouseListener(new PopupRightClick(
638                 videoSaveInfoPanel.getVideoSavedFileField()));
639         videoSaveInfoPanel.getVideoSavedFolderField().addMouseListener(new PopupRightClick(
640                 videoSaveInfoPanel.getVideoSavedFolderField()));
641         videoSaveInfoPanel.getNibrFileField().addMouseListener(
642                 new PopupRightClick(videoSaveInfoPanel.getNibrFileField()));
643
644         ffmpegPathField.addMouseListener(new PopupRightClick(
645                 this.ffmpegPathField));
646         vhookPathField.addMouseListener(new PopupRightClick(this.vhookPathField));
647         videoIdField.addMouseListener(new PopupRightClick(
648                 this.videoIdField));
649         viewCommentField.addMouseListener(new PopupRightClick(
650                 this.viewCommentField));
651         fontPathField.addMouseListener(new PopupRightClick(this.fontPathField));
652         mailAddressField.addMouseListener(new PopupRightClick(this.mailAddressField));
653         passwordField.addMouseListener(new PopupRightClick(this.passwordField));
654         wayBackField.addMouseListener(new PopupRightClick(this.wayBackField));
655
656         proxyTextField.addMouseListener(new PopupRightClick(this.proxyTextField));
657         proxyPortTextField.addMouseListener(new PopupRightClick(
658                 this.proxyPortTextField));
659
660         fontIndexField.addMouseListener(new PopupRightClick(this.fontIndexField));
661
662         ngWordTextField.addMouseListener(new PopupRightClick(
663                 this.ngWordTextField));
664         ngIdTextField.addMouseListener(new PopupRightClick(this.ngIdTextField));
665     }
666
667     private void setDropTarget() {
668         addTarget(videoSaveInfoPanel.getVideoSavedFileField(), false);
669         addTarget(videoSaveInfoPanel.getVideoSavedFolderField(), true);
670         addTarget(videoSaveInfoPanel.getNibrFileField(), false);
671
672         addTarget(savePanel.getCommentSavedFileField(), false);
673         addTarget(savePanel.getCommentSavedFolderField(), true);
674
675         addTarget(savePanel.getConvertedVideoSavedFileField(), false);
676         addTarget(savePanel.getConvertedVideoSavedFolderField(), true);
677
678         addTarget(ffmpegPathField, false);
679         addTarget(vhookPathField, false);
680         addTarget(fontPathField, false);
681
682     }
683
684     /**
685      * テキストフィールドに対しドロップを行った場合にファイルもしくはディレクトリの文字列を設定できるようにする.
686      * @param c 設定対象のテキストフィールドオブジェクト.
687      * @param isDir ディレクトリを設定する場合はtrue, ファイルの場合はfalse.
688      * @return ドロップターゲット(用途無し).
689      */
690     private DropTarget addTarget(JTextField c, boolean isDir) {
691         return new DropTarget(c, DnDConstants.ACTION_COPY, new FileDropTarget(
692                 c, isDir), true);
693     }
694     private File CurrentDir = new File(".");
695     private JPanel PathSettingPanel = new JPanel();
696     private JLabel FFmpegPathLabel = new JLabel();
697     private GridBagLayout gridBagLayout7 = new GridBagLayout();
698     private JTextField ffmpegPathField = new JTextField();
699     private JButton SettingFFmpegPathButton = new JButton();
700     private JLabel VhookPathLabel = new JLabel();
701     private JTextField vhookPathField = new JTextField();
702     private JButton SettingVhookPathButton = new JButton();
703     private JPanel VhookSettingPanel = new JPanel();
704     private GridBagLayout gridBagLayout8 = new GridBagLayout();
705     private JPanel FFmpegSettingPanel = new JPanel();
706     private GridBagLayout gblFFmpegSettingPanel = new GridBagLayout();
707     private JLabel FontPathLabel = new JLabel();
708     private JTextField fontPathField = new JTextField();
709     private JButton SettingFontPathButton = new JButton();
710     private JCheckBox showConvVideoCheckBox = new JCheckBox();
711
712     private void showSaveDialog(String title, JTextField field, boolean isSave,
713             boolean isDir) {
714         JFileChooser chooser = new JFileChooser(CurrentDir);
715         chooser.setDialogTitle(title);
716         int code = 0;
717         if (isDir) {
718             chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
719         }
720         if (isSave) {
721             code = chooser.showSaveDialog(this);
722         } else {
723             code = chooser.showOpenDialog(this);
724         }
725         if (code == JFileChooser.APPROVE_OPTION) {
726             if (isDir) {
727                 CurrentDir = chooser.getSelectedFile();
728                 field.setText(CurrentDir.getAbsolutePath());
729             } else {
730                 File selected = chooser.getSelectedFile();
731                 CurrentDir = chooser.getCurrentDirectory();
732                 field.setText(selected.getAbsolutePath());
733             }
734         }
735     }
736
737     private SProperties getSetting() {
738         SProperties setting = new SProperties(
739                 getBasicSetting(),
740                 getInputVideoSetting(),
741                 getInputCommentSetting(),
742                 getTcommentSetting(),
743                 getOutputVideoSetting(),
744                 getMovieSetting(),
745                 getConvertSetting());
746         return setting;
747     }
748
749     /**
750      * 設定を画面に反映する.
751      * @param setting 反映する設定.
752      */
753     private void setSetting(SProperties setting) {
754         // 基本設定
755         final BasicSetting basic = setting.getBasicSetting();
756         tempDir = basic.getTempDir();
757         mailAddressField.setText(basic.getUser().getMail());
758         passwordField.setText(basic.getUser().getPassword());
759         // プロキシ関連
760         useProxyCheckBox.setSelected(basic.isProxyUse());
761         proxyTextField.setText(basic.getProxyHost());
762         int proxy_port = basic.getProxyPort();
763         if (proxy_port >= 0 && proxy_port <= 65535) {
764             proxyPortTextField.setText(Integer.toString(proxy_port));
765         } else {
766             proxyPortTextField.setText("");
767         }
768
769         // 保存設定 - 入力動画
770         final InputVideoSetting inVideo = setting.getInputVideoSetting();
771         JRadioButton activeButton;
772         switch (inVideo.getProcessKind()) {
773             case NO_SAVE:
774                 activeButton = videoSaveInfoPanel.getVideoNoSaveButton();
775                 break;
776             case NICOBROWSER:
777                 activeButton = videoSaveInfoPanel.getVideoUseNiBrButton();
778                 break;
779             case SAVE:
780             default:
781                 activeButton = videoSaveInfoPanel.getVideoSaveButton();
782                 break;
783         }
784         activeButton.doClick();
785
786         videoSaveInfoPanel.getVideoSavedFileField().setText(inVideo.getFile().getPath());
787         videoSaveInfoPanel.getVideoSavedFolderField().setText(inVideo.getFolder().getPath());
788         videoSaveInfoPanel.getDelVideoCheckBox().setSelected(inVideo.isDeleteAfterConvert());
789         final boolean videoFixName = inVideo.isAutoNaming();
790         videoSaveInfoPanel.getSaveFileRadioButton().setSelected(!videoFixName);
791         videoSaveInfoPanel.getSaveFolderRadioButton().setSelected(videoFixName);
792         videoSaveInfoPanel.getNibrFileField().setText(inVideo.getNicoBrowserFile().getPath());
793
794         // 保存設定 - 入力コメント
795         final InputCommentSetting inputComment = setting.getInputCommentSetting();
796         savePanel.getSavingCommentCheckBox().setSelected(inputComment.getProcessKind());
797         savePanel.getCommentSavedFileField().setText(inputComment.getFile().getPath());
798         savePanel.getDelCommentCheckBox().setSelected(inputComment.isDeleteAfterConvert());
799         savePanel.getCommentSavedFolderField().setText(inputComment.getFolder().getPath());
800         savePanel.getCommentNumField().setText(Integer.toString(inputComment.getNumOfComment()));
801         savePanel.getFixCommentNumCheckBox().setSelected(inputComment.isSelfAdjustNumOfComment());
802         boolean commentFixName = inputComment.isAutoNaming();
803         savePanel.getCommentSaveFileRadioButton().setSelected(!commentFixName);
804         savePanel.getCommentSaveFolderRadioButton().setSelected(commentFixName);
805
806         // 投稿者コメント
807         InputTcommentSetting tcom = setting.getInputTcommentSetting();
808         savePanel.setTcommentDownload(tcom.getProcessKind());
809         savePanel.setTcommentDelete(tcom.isDeleteAfterConvert());
810         savePanel.setTcommentAutoFileName(tcom.isAutoNaming());
811         savePanel.setTcommentDirectoryName(tcom.getFolder().getPath());
812         savePanel.setTcommentFileName(tcom.getFile().getPath());
813
814         // 保存設定 - 出力コメント付き動画
815         final OutputVideoSetting outputVideo = setting.getOutputVideoSetting();
816         savePanel.getSavingConvertedVideoCheckBox().setSelected(outputVideo.getProcessKind());
817         savePanel.getAddCommentCheckBox().setSelected(outputVideo.isAddComment());
818         savePanel.getAddTcommentCheckBox().setSelected(outputVideo.isAddTcomment());
819         savePanel.getConvertedVideoSavedFileField().setText(outputVideo.getFile().getPath());
820         savePanel.getConvertedVideoSavedFolderField().setText(outputVideo.getFolder().getPath());
821         savePanel.getNotAddVideoIdConvVideoCheckBox().setSelected(outputVideo.isCutIdName());
822         boolean convFixName = outputVideo.isAutoNaming();
823         savePanel.getConvSaveFileRadioButton().setSelected(!convFixName);
824         savePanel.getConvSaveFolderRadioButton().setSelected(convFixName);
825
826         // 動画設定
827         final MovieSetting movie = setting.getMovieSetting();
828         ffmpegPathField.setText(movie.getFfmpeg().toString());
829         vhookPathField.setText(movie.getVhook().toString());
830         extOptionField.setText(movie.getFfmpegOption().getExtOption());
831         mainOptionField.setText(movie.getFfmpegOption().getMainOption());
832         inputOptionField.setText(movie.getFfmpegOption().getInOption());
833         outputOptionField.setText(movie.getFfmpegOption().getOutOption());
834         avfilterOptionField.setText(movie.getFfmpegOption().getAvfilterOption());
835         resizeCheckBox.setSelected(movie.getFfmpegOption().isResize());
836         resizeWidthField.setText(Integer.toString(movie.getFfmpegOption().getResizeWidth()));
837         resizeHeigitField.setText(Integer.toString(movie.getFfmpegOption().getResizeHeight()));
838         adjustRatioCheckBox.setSelected(movie.getFfmpegOption().isAdjustRatio());
839         FFmpegOptionModel.reload(movie.getOptionFile());
840
841         // 変換設定
842         final ConvertSetting conv = setting.getConvertSetting();
843         disableVhookCheckBox.setSelected(conv.isVhookDisabled());
844         viewCommentField.setText(Integer.toString(conv.getMaxNumOfComment()));
845         fontPathField.setText(conv.getFont().toString());
846         fontIndexField.setText(Integer.toString(conv.getFontIndex()));
847         shadowComboBox.setSelectedIndex(conv.getShadowIndex());
848         showConvVideoCheckBox.setSelected(conv.isShowConverting());
849         fixFontSizeCheckBox.setSelected(conv.isSelfAdjustFontSize());
850         opaqueCommentCheckBox.setSelected(conv.isCommentOpaque());
851         ngWordTextField.setText(conv.getNgSetting().getWord());
852         ngIdTextField.setText(conv.getNgSetting().getId());
853     }
854
855     /**
856      * [ファイル|終了] アクションが実行されました。
857      *
858      * @param actionEvent
859      *            ActionEvent
860      */
861     void jMenuFileExit_actionPerformed(ActionEvent actionEvent) {
862         try {
863             SProperties setting = getSetting();
864             SProperties.saveSetting(setting);
865         } catch (Throwable t) {
866             Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, "設定保存に失敗", t);
867         }
868         System.exit(0);
869     }
870
871     /**
872      * [ヘルプ|バージョン情報] アクションが実行されました。
873      *
874      * @param actionEvent
875      *            ActionEvent
876      */
877     void jMenuHelpAbout_actionPerformed(ActionEvent actionEvent) {
878         MainFrame_AboutBox dlg = new MainFrame_AboutBox(this);
879         dlg.pack();
880         dlg.setLocationRelativeTo(this);
881         dlg.setVisible(true);
882     }
883
884     /* 変換・保存する */
885     private Converter Converter = null;
886     // FFmpegの設定 ここから
887     private final JLabel extOptionLabel = new JLabel();
888     private final JTextField extOptionField = new JTextField();
889     private JLabel mainOptionLabel = new JLabel();
890     private JTextField mainOptionField = new JTextField();
891     private JLabel inputOptionLabel = new JLabel();
892     private JTextField inputOptionField = new JTextField();
893     private JLabel outputOptionLabel = new JLabel();
894     private JTextField outputOptionField = new JTextField();
895     private final JLabel avfilterOptionLabel = new JLabel();
896     private final JTextField avfilterOptionField = new JTextField();
897     private final JCheckBox resizeCheckBox = new JCheckBox("次のサイズに収まるよう縮小(-s)");
898     private final JLabel resizeWidthLabel = new JLabel("横");
899     private final JTextField resizeWidthField = new NumberFormattedTextField();
900     private final JLabel resizeHeightLabel = new JLabel("縦");
901     private final JTextField resizeHeigitField = new NumberFormattedTextField();
902     private final JCheckBox adjustRatioCheckBox = new JCheckBox("アスペクト比を維持");
903     // FFmpegの設定 ここまで
904     private JLabel FontIndexLabel = new JLabel();
905     private JTextField fontIndexField = new JTextField();
906     private JPanel BasicInfoTabPanel = new JPanel();
907     private GridBagLayout gridBagLayout12 = new GridBagLayout();
908     private JPanel ConvertingSettingPanel = null;
909     private JPanel NGWordSettingPanel = null;
910     private JLabel NGWordLabel = null;
911     private JTextField ngWordTextField = null;
912     private JLabel NGIDLabel = null;
913     private JTextField ngIdTextField = null;
914     // プロキシ設定
915     private JPanel ProxyInfoPanel = null;
916     private JCheckBox useProxyCheckBox = null;
917     private JLabel proxyLabel = null;
918     private JTextField proxyTextField = null;
919     private JLabel proxyPortLabel = null;
920     private JTextField proxyPortTextField = null;
921     //
922     private JCheckBox fixFontSizeCheckBox = null;
923     private JCheckBox opaqueCommentCheckBox = null;
924     private final SavePanel savePanel = new SavePanel();
925     private final VideoSaveInfoPanel videoSaveInfoPanel;
926     private JComboBox FFmpegOptionComboBox = null;
927     private JButton FFmpegOptionReloadButton = null;
928     private JPanel FFmpegOptionComboBoxPanel = null;
929
930     public void DoButton_actionPerformed(ActionEvent e) {
931         if (Converter == null || Converter.isConverted()) {
932             try {
933                 executeConvert();
934             } catch (Exception ex) {
935                 String text = ex.getMessage();
936                 if (StringUtils.isEmpty(text)) {
937                     text = "予期しないエラーのため中断しました。";
938                 }
939                 ex.printStackTrace();
940                 statusBar.setText(text);
941             }
942         } else { /* 開始しているので、ストップする。 */
943             final ConvertStopFlag flag = Converter.getStopFlag();
944             if (!flag.needStop()) { /* まだストップしていない。 */
945                 flag.requestStop();
946             }
947         }
948     }
949
950     private void executeConvert() throws IOException {
951         String url;
952
953         // NicoBrowserファイルを利用する場合は、ファイル名からビデオIDを特定.
954         if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected()) {
955             try {
956                 String fileName = videoSaveInfoPanel.getNibrFileField().getText();
957                 NicoDBFinder finder = NicoDBFinder.getInstance();
958                 NicoContent info = finder.findNicoContent(fileName);
959                 if (info != null) {
960                     url = info.getNicoId();
961                 } else {
962                     url = "";
963                 }
964             } catch (Exception ex) {
965                 JOptionPane.showMessageDialog(this, ex.getMessage(), "エラー", JOptionPane.ERROR_MESSAGE);
966                 return;
967             }
968         } else {
969             url = videoIdField.getText();
970         }
971
972         TextProgressListener sl = new TextProgressListener() {
973
974             public void setText(final String text) {
975                 SwingUtilities.invokeLater(new Runnable() {
976
977                     public void run() {
978                         statusBar.setText(text);
979                     }
980                 });
981             }
982         };
983
984         ConvertStopFlag.StateChangeListener scl = new ConvertStopFlag.StateChangeListener() {
985
986             public void changeState(final State s) {
987                 SwingUtilities.invokeLater(new Runnable() {
988
989                     public void run() {
990                         switch (s) {
991                             case STOPPING:
992                                 doButton.setText(DoButtonWaitString);
993                                 break;
994                             case FINISHED:
995                                 doButton.setText(DoButtonDefString);
996                         }
997                     }
998                 });
999             }
1000         };
1001
1002         Converter = new Converter(url, wayBackField.getText(), getSetting().toProfile(), sl,
1003                 new ConvertStopFlag(scl));
1004         doButton.setText(DoButtonStopString);
1005         new Thread(Converter).start();
1006
1007     }
1008
1009     /* FFmpegへのパス */
1010     public void SettingFFmpegPathButton_actionPerformed(ActionEvent e) {
1011         showSaveDialog("FFmpegへのパス", ffmpegPathField, false, false);
1012     }
1013
1014     public void SettingVhookPathButton_actionPerformed(ActionEvent e) {
1015         showSaveDialog("拡張vhookライブラリへのパス", vhookPathField, false, false);
1016     }
1017
1018     public void SettingFontPathButton_actionPerformed(ActionEvent e) {
1019         showSaveDialog("フォントへのパス", fontPathField, false, false);
1020     }
1021
1022     public void this_windowClosing(WindowEvent e) {
1023         this.jMenuFileExit_actionPerformed(null);
1024     }
1025
1026     /**
1027      * This method initializes ConvertingSettingPanel
1028      *
1029      * @return javax.swing.JPanel
1030      */
1031     private JPanel getConvertingSettingPanel() {
1032         if (ConvertingSettingPanel == null) {
1033             GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
1034             gridBagConstraints11.weighty = 1.0;
1035             gridBagConstraints11.weightx = 1.0;
1036             gridBagConstraints11.insets = new Insets(0, 5, 0, 5);
1037             gridBagConstraints11.gridy = 1;
1038             gridBagConstraints11.gridx = 0;
1039             gridBagConstraints11.anchor = GridBagConstraints.NORTH;
1040             gridBagConstraints11.fill = GridBagConstraints.HORIZONTAL;
1041             GridBagConstraints gridBagConstraints = new GridBagConstraints(0,
1042                     2, 1, 1, 1.0, 1.0, GridBagConstraints.NORTH,
1043                     GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0);
1044             gridBagConstraints.gridx = 0;
1045             gridBagConstraints.anchor = GridBagConstraints.CENTER;
1046             gridBagConstraints.weighty = 0.0;
1047             gridBagConstraints.gridy = 0;
1048             ConvertingSettingPanel = new JPanel();
1049             ConvertingSettingPanel.setLayout(new GridBagLayout());
1050             ConvertingSettingPanel.add(getNGWordSettingPanel(),
1051                     gridBagConstraints11);
1052             ConvertingSettingPanel.add(VhookSettingPanel, gridBagConstraints);
1053         }
1054         return ConvertingSettingPanel;
1055     }
1056
1057     /**
1058      * This method initializes NGWordSettingPanel
1059      *
1060      * @return javax.swing.JPanel
1061      */
1062     private JPanel getNGWordSettingPanel() {
1063         if (NGWordSettingPanel == null) {
1064             GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
1065             gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL;
1066             gridBagConstraints5.gridy = 1;
1067             gridBagConstraints5.weightx = 1.0;
1068             gridBagConstraints5.insets = new Insets(0, 5, 5, 5);
1069             gridBagConstraints5.gridx = 1;
1070             GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
1071             gridBagConstraints4.gridx = 0;
1072             gridBagConstraints4.anchor = GridBagConstraints.WEST;
1073             gridBagConstraints4.insets = new Insets(0, 5, 5, 0);
1074             gridBagConstraints4.gridy = 1;
1075             NGIDLabel = new JLabel();
1076             NGIDLabel.setText("NG ID");
1077             GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
1078             gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL;
1079             gridBagConstraints3.gridy = 0;
1080             gridBagConstraints3.weightx = 1.0;
1081             gridBagConstraints3.insets = new Insets(0, 5, 5, 5);
1082             gridBagConstraints3.gridx = 1;
1083             GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
1084             gridBagConstraints2.gridx = 0;
1085             gridBagConstraints2.insets = new Insets(0, 5, 5, 0);
1086             gridBagConstraints2.gridy = 0;
1087             NGWordLabel = new JLabel();
1088             NGWordLabel.setText("NGワード");
1089             NGWordSettingPanel = new JPanel();
1090             NGWordSettingPanel.setLayout(new GridBagLayout());
1091             NGWordSettingPanel.setBorder(BorderFactory.createTitledBorder(null,
1092                     "NGワード・ID設定(半角スペース区切りで複数入力)"));
1093             NGWordSettingPanel.add(NGWordLabel, gridBagConstraints2);
1094             NGWordSettingPanel.add(getNGWordTextField(), gridBagConstraints3);
1095             NGWordSettingPanel.add(NGIDLabel, gridBagConstraints4);
1096             NGWordSettingPanel.add(getNGIDTextField(), gridBagConstraints5);
1097         }
1098         return NGWordSettingPanel;
1099     }
1100
1101     /**
1102      * This method initializes NGWordTextField
1103      *
1104      * @return javax.swing.JTextField
1105      */
1106     private JTextField getNGWordTextField() {
1107         if (ngWordTextField == null) {
1108             ngWordTextField = new JTextField();
1109             ngWordTextField.setName("ngWordTextField");
1110         }
1111         return ngWordTextField;
1112     }
1113
1114     /**
1115      * This method initializes NGIDTextField
1116      *
1117      * @return javax.swing.JTextField
1118      */
1119     private JTextField getNGIDTextField() {
1120         if (ngIdTextField == null) {
1121             ngIdTextField = new JTextField();
1122             ngIdTextField.setName("ngIdTextField");
1123         }
1124         return ngIdTextField;
1125     }
1126
1127     /**
1128      * This method initializes ProxyInfoPanel
1129      *
1130      * @return javax.swing.JPanel
1131      */
1132     private JPanel getProxyInfoPanel() {
1133         if (ProxyInfoPanel == null) {
1134             GridBagConstraints gridBagConstraints13 = new GridBagConstraints();
1135             gridBagConstraints13.gridx = 0;
1136             gridBagConstraints13.gridwidth = 2;
1137             gridBagConstraints13.weightx = 1.0;
1138             gridBagConstraints13.fill = GridBagConstraints.HORIZONTAL;
1139             gridBagConstraints13.insets = new Insets(0, 5, 0, 5);
1140             gridBagConstraints13.gridy = 0;
1141             GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
1142             gridBagConstraints12.fill = GridBagConstraints.HORIZONTAL;
1143             gridBagConstraints12.gridy = 2;
1144             gridBagConstraints12.weightx = 1.0;
1145             gridBagConstraints12.insets = new Insets(5, 0, 5, 5);
1146             gridBagConstraints12.gridx = 1;
1147             GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
1148             gridBagConstraints10.gridx = 0;
1149             gridBagConstraints10.insets = new Insets(5, 5, 5, 5);
1150             gridBagConstraints10.gridy = 2;
1151             proxyPortLabel = new JLabel();
1152             proxyPortLabel.setText("ポート番号");
1153             GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
1154             gridBagConstraints9.fill = GridBagConstraints.BOTH;
1155             gridBagConstraints9.gridy = 1;
1156             gridBagConstraints9.weightx = 1.0;
1157             gridBagConstraints9.insets = new Insets(0, 0, 0, 5);
1158             gridBagConstraints9.gridx = 1;
1159             GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
1160             gridBagConstraints8.gridx = 0;
1161             gridBagConstraints8.insets = new Insets(0, 5, 0, 5);
1162             gridBagConstraints8.fill = GridBagConstraints.NONE;
1163             gridBagConstraints8.anchor = GridBagConstraints.EAST;
1164             gridBagConstraints8.gridy = 1;
1165             proxyLabel = new JLabel();
1166             proxyLabel.setText("プロキシ");
1167             ProxyInfoPanel = new JPanel();
1168             ProxyInfoPanel.setLayout(new GridBagLayout());
1169             ProxyInfoPanel.setBorder(BorderFactory.createTitledBorder(null,
1170                     "プロキシ設定"));
1171             ProxyInfoPanel.add(proxyLabel, gridBagConstraints8);
1172             ProxyInfoPanel.add(getProxyTextField(), gridBagConstraints9);
1173             ProxyInfoPanel.add(proxyPortLabel, gridBagConstraints10);
1174             ProxyInfoPanel.add(getProxyPortTextField(), gridBagConstraints12);
1175             ProxyInfoPanel.add(getUseProxyCheckBox(), gridBagConstraints13);
1176         }
1177         return ProxyInfoPanel;
1178     }
1179
1180     /**
1181      * This method initializes ProxyTextField
1182      *
1183      * @return javax.swing.JTextField
1184      */
1185     private JTextField getProxyTextField() {
1186         if (proxyTextField == null) {
1187             proxyTextField = new JTextField();
1188             proxyTextField.setName("proxyTextField");
1189         }
1190         return proxyTextField;
1191     }
1192
1193     /**
1194      * This method initializes ProxyPortTextField
1195      *
1196      * @return javax.swing.JTextField
1197      */
1198     private JTextField getProxyPortTextField() {
1199         if (proxyPortTextField == null) {
1200             proxyPortTextField = new JTextField();
1201             proxyPortTextField.setName("proxyPortTextField");
1202         }
1203         return proxyPortTextField;
1204     }
1205
1206     /**
1207      * This method initializes UseProxyCheckBox
1208      *
1209      * @return javax.swing.JCheckBox
1210      */
1211     private JCheckBox getUseProxyCheckBox() {
1212         if (useProxyCheckBox == null) {
1213             useProxyCheckBox = new JCheckBox();
1214             useProxyCheckBox.setText("プロキシを使う");
1215             useProxyCheckBox.setName("useProxyCheckBox");
1216         }
1217         return useProxyCheckBox;
1218     }
1219
1220     /**
1221      * This method initializes FixFontSizeCheckBox
1222      *
1223      * @return javax.swing.JCheckBox
1224      */
1225     private JCheckBox getFixFontSizeCheckBox() {
1226         if (fixFontSizeCheckBox == null) {
1227             fixFontSizeCheckBox = new JCheckBox();
1228             fixFontSizeCheckBox.setText("フォントサイズを画面にあわせて自動調整する");
1229             fixFontSizeCheckBox.setName("fixFontSizeCheckBox");
1230         }
1231         return fixFontSizeCheckBox;
1232     }
1233
1234     /**
1235      * This method initializes OpaqueCommentCheckBox
1236      *
1237      * @return javax.swing.JCheckBox
1238      */
1239     private JCheckBox getOpaqueCommentCheckBox() {
1240         if (opaqueCommentCheckBox == null) {
1241             opaqueCommentCheckBox = new JCheckBox();
1242             opaqueCommentCheckBox.setText("全てのコメントを不透明にする");
1243             opaqueCommentCheckBox.setName("opaqueCommentCheckBox");
1244         }
1245         return opaqueCommentCheckBox;
1246     }
1247     /**
1248      * This method initializes FFmpegOptionComboBox
1249      *
1250      * @return javax.swing.JComboBox
1251      */
1252     private final OptionComboBoxModel FFmpegOptionModel = new OptionComboBoxModel();
1253     private JCheckBox disableVhookCheckBox = null;
1254     private JTextField viewCommentField = null;
1255     private JLabel ViewCommentLabel = null;
1256     private JLabel ShadowKindLabel = null;
1257     private JComboBox shadowComboBox = null;
1258
1259     private JComboBox getFFmpegOptionComboBox() {
1260         if (FFmpegOptionComboBox == null) {
1261             FFmpegOptionComboBox = new JComboBox(FFmpegOptionModel);
1262             FFmpegOptionComboBox.addActionListener(new java.awt.event.ActionListener() {
1263
1264                 public void actionPerformed(java.awt.event.ActionEvent e) {
1265                     if (FFmpegOptionModel.isFile()) {// ファイル
1266                         setFFMpegOptionEnabled(false);
1267                     } else {// ファイルでない
1268                         setFFMpegOptionEnabled(true);
1269                         setFFMpegOptionCheckbox();
1270                     }
1271                 }
1272
1273                 private void setFFMpegOptionEnabled(boolean enable) {
1274                     extOptionField.setEnabled(enable);
1275                     mainOptionField.setEnabled(enable);
1276                     inputOptionField.setEnabled(enable);
1277                     outputOptionField.setEnabled(enable);
1278                     avfilterOptionField.setEnabled(enable);
1279                     resizeCheckBox.setEnabled(enable);
1280                     resizeWidthField.setEnabled(enable);
1281                     resizeHeigitField.setEditable(enable);
1282                     adjustRatioCheckBox.setEnabled(enable);
1283                 }
1284             });
1285         }
1286         return FFmpegOptionComboBox;
1287     }
1288
1289     /**
1290      * This method initializes FFmpegOptionReloadButton
1291      *
1292      * @return javax.swing.JButton
1293      */
1294     private JButton getFFmpegOptionReloadButton() {
1295         if (FFmpegOptionReloadButton == null) {
1296             FFmpegOptionReloadButton = new JButton();
1297             FFmpegOptionReloadButton.setText("更新");
1298             FFmpegOptionReloadButton.addActionListener(new java.awt.event.ActionListener() {
1299
1300                 public void actionPerformed(java.awt.event.ActionEvent e) {
1301                     FFmpegOptionModel.reload();
1302                 }
1303             });
1304         }
1305         return FFmpegOptionReloadButton;
1306     }
1307
1308     /**
1309      * This method initializes FFmpegOptionComboBoxPanel
1310      *
1311      * @return javax.swing.JPanel
1312      */
1313     private JPanel getFFmpegOptionComboBoxPanel() {
1314         if (FFmpegOptionComboBoxPanel == null) {
1315             GridBagConstraints gridBagConstraints47 = new GridBagConstraints();
1316             gridBagConstraints47.fill = GridBagConstraints.BOTH;
1317             gridBagConstraints47.gridx = -1;
1318             gridBagConstraints47.gridy = -1;
1319             gridBagConstraints47.insets = new Insets(0, 0, 5, 5);
1320             GridBagConstraints gridBagConstraints46 = new GridBagConstraints();
1321             gridBagConstraints46.fill = GridBagConstraints.HORIZONTAL;
1322             gridBagConstraints46.gridwidth = 3;
1323             gridBagConstraints46.gridx = -1;
1324             gridBagConstraints46.gridy = -1;
1325             gridBagConstraints46.weightx = 1.0;
1326             gridBagConstraints46.insets = new Insets(0, 5, 5, 5);
1327             FFmpegOptionComboBoxPanel = new JPanel();
1328             FFmpegOptionComboBoxPanel.setLayout(new GridBagLayout());
1329             FFmpegOptionComboBoxPanel.add(getFFmpegOptionComboBox(),
1330                     gridBagConstraints46);
1331             FFmpegOptionComboBoxPanel.add(getFFmpegOptionReloadButton(),
1332                     gridBagConstraints47);
1333         }
1334         return FFmpegOptionComboBoxPanel;
1335     }
1336
1337     /**
1338      * This method initializes NotUseVhookCheckBox
1339      *
1340      * @return javax.swing.JCheckBox
1341      */
1342     private JCheckBox getNotUseVhookCheckBox() {
1343         if (disableVhookCheckBox == null) {
1344             disableVhookCheckBox = new JCheckBox();
1345             disableVhookCheckBox.setText("拡張vhookライブラリを無効にする(デバッグ用)");
1346             disableVhookCheckBox.setName("disableVhookCheckBox");
1347         }
1348         return disableVhookCheckBox;
1349     }
1350
1351     /**
1352      * This method initializes ViewCommentField
1353      *
1354      * @return javax.swing.JTextField
1355      */
1356     private JTextField getViewCommentField() {
1357         if (viewCommentField == null) {
1358             viewCommentField = new JTextField();
1359             viewCommentField.setName("viewCommentField");
1360         }
1361         return viewCommentField;
1362     }
1363
1364     /**
1365      * This method initializes ShadowComboBox
1366      *
1367      * @return javax.swing.JComboBox
1368      */
1369     private JComboBox getShadowComboBox() {
1370         if (shadowComboBox == null) {
1371             shadowComboBox = new JComboBox(SProperties.ShadowKindArray);
1372             shadowComboBox.setName("shadowComboBox");
1373         }
1374         return shadowComboBox;
1375     }
1376
1377     private BasicSetting getBasicSetting() {
1378         String mail = mailAddressField.getText();
1379         String pass = String.valueOf(passwordField.getPassword());
1380         boolean proxyUse = useProxyCheckBox.isSelected();
1381         String proxyHost = proxyTextField.getText();
1382         int proxyPort;
1383         try {
1384             proxyPort = Integer.parseInt(proxyPortTextField.getText());
1385         } catch (NumberFormatException e) {
1386             proxyPort = -1;
1387         }
1388         // TODO 作業用ディレクトリの設定GUI無し
1389         return new BasicSetting(tempDir, mail, pass, proxyUse, proxyHost, proxyPort);
1390     }
1391
1392     private InputVideoSetting getInputVideoSetting() {
1393         VideoSaveKind kind;
1394         if (videoSaveInfoPanel.getVideoNoSaveButton().isSelected() == true) {
1395             kind = VideoSaveKind.NO_SAVE;
1396         } else if (videoSaveInfoPanel.getVideoUseNiBrButton().isSelected() == true) {
1397             kind = VideoSaveKind.NICOBROWSER;
1398         } else {
1399             kind = VideoSaveKind.SAVE;
1400         }
1401         boolean autoNaming = videoSaveInfoPanel.getSaveFolderRadioButton().isSelected();
1402         String folder = videoSaveInfoPanel.getVideoSavedFolderField().getText();
1403         String file = videoSaveInfoPanel.getVideoSavedFileField().getText();
1404         boolean delete = videoSaveInfoPanel.getDelVideoCheckBox().isSelected();
1405         String nibrFile = videoSaveInfoPanel.getNibrFileField().getText();
1406
1407         return new InputVideoSetting(kind, autoNaming, new File(folder), new File(file), delete, new File(nibrFile));
1408     }
1409
1410     private InputCommentSetting getInputCommentSetting() {
1411         boolean download = savePanel.getSavingCommentCheckBox().isSelected();
1412         String file = savePanel.getCommentSavedFileField().getText();
1413         int back_comment;
1414         try {
1415             back_comment = Integer.parseInt(savePanel.getCommentNumField().getText());
1416         } catch (NumberFormatException ex) {
1417             back_comment = 500;
1418         }
1419         boolean delete = savePanel.getDelCommentCheckBox().isSelected();
1420         boolean autoNaming = savePanel.getCommentSaveFolderRadioButton().isSelected();
1421         String folder = savePanel.getCommentSavedFolderField().getText();
1422         boolean adjustNumOfCom = savePanel.getFixCommentNumCheckBox().isSelected();
1423
1424         return new InputCommentSetting(download, autoNaming, new File(folder), new File(file), delete, adjustNumOfCom,
1425                 back_comment, reduceCommentCheckBox.isSelected());
1426     }
1427
1428     /**
1429      * 画面入力値から投稿者コメント設定を作成する.
1430      * @return 作成した投稿者コメント設定.
1431      */
1432     private InputTcommentSetting getTcommentSetting() {
1433         boolean down = savePanel.isTcommentDownload();
1434         boolean del = savePanel.isTcommentDelete();
1435         boolean naming = savePanel.isTcommentAutoFileName();
1436         String dir = savePanel.getTcommentDirectoryName();
1437         String f = savePanel.getTcommentFileName();
1438         return new InputTcommentSetting(down, naming, dir, f, del);
1439     }
1440
1441     private OutputVideoSetting getOutputVideoSetting() {
1442         boolean process = savePanel.getSavingConvertedVideoCheckBox().isSelected();
1443         boolean addComment = savePanel.getAddCommentCheckBox().isSelected();
1444         boolean addTcomment = savePanel.getAddTcommentCheckBox().isSelected();
1445         String file = savePanel.getConvertedVideoSavedFileField().getText();
1446         boolean cutId = savePanel.getNotAddVideoIdConvVideoCheckBox().isSelected();
1447         boolean autoNaming = savePanel.getConvSaveFolderRadioButton().isSelected();
1448         String folder = savePanel.getConvertedVideoSavedFolderField().getText();
1449
1450         return new OutputVideoSetting(process, autoNaming, new File(folder), new File(file), cutId, addComment,
1451                 addTcomment);
1452     }
1453
1454     private MovieSetting getMovieSetting() {
1455         String ffmpeg = ffmpegPathField.getText();
1456         String vhook = vhookPathField.getText();
1457         String ext = extOptionField.getText();
1458         String main = mainOptionField.getText();
1459         String in = inputOptionField.getText();
1460         String out = outputOptionField.getText();
1461         String avfilter = avfilterOptionField.getText();
1462         boolean resize = resizeCheckBox.isSelected();
1463         String width = resizeWidthField.getText();
1464         String height = resizeHeigitField.getText();
1465         boolean adjust = adjustRatioCheckBox.isSelected();
1466         File optionFile = FFmpegOptionModel.getSelectedFile();
1467
1468         FfmpegOption opt = new FfmpegOption(ext, main, in, out, avfilter, resize, width, height, adjust);
1469         return new MovieSetting(new File(ffmpeg), new File(vhook), optionFile, opt);
1470     }
1471
1472     private ConvertSetting getConvertSetting() {
1473         boolean vhookDisabled = disableVhookCheckBox.isSelected();
1474         int maxComment = 30;
1475         try {
1476             maxComment = Integer.parseInt(viewCommentField.getText());
1477         } catch (NumberFormatException ex) {
1478         }
1479         File font = new File(fontPathField.getText());
1480         int fontIndex = Integer.parseInt(fontIndexField.getText());
1481         int shadowIndex = shadowComboBox.getSelectedIndex();
1482         boolean showConv = showConvVideoCheckBox.isSelected();
1483         boolean adjustFont = fixFontSizeCheckBox.isSelected();
1484         boolean commentOpaque = opaqueCommentCheckBox.isSelected();
1485         NgSetting ngSetting = new NgSetting(ngWordTextField.getText(), ngIdTextField.getText());
1486
1487         return new ConvertSetting(vhookDisabled, maxComment, font, fontIndex, shadowIndex, showConv, adjustFont,
1488                 commentOpaque, ngSetting);
1489     }
1490
1491     private class InputVideoPanelButtonListener implements ActionListener {
1492
1493         public void actionPerformed(ActionEvent e) {
1494             final Object source = e.getSource();
1495             final VideoSaveInfoPanel panel = videoSaveInfoPanel;
1496             String title;
1497             JTextField field;
1498             boolean isSave;
1499             boolean isDir;
1500
1501             if (source == panel.getShowSavingVideoFolderDialogButton()) {
1502                 title = "動画の保存先(フォルダ)";
1503                 field = panel.getVideoSavedFolderField();
1504                 isSave = true;
1505                 isDir = true;
1506             } else if (source == panel.getShowSavingVideoFileDialogButton()) {
1507                 title = "動画の保存先(ファイル)";
1508                 field = panel.getVideoSavedFileField();
1509                 isSave = true;
1510                 isDir = false;
1511             } else if (source == panel.getNibrFileChooserButton()) {
1512                 title = "NicoBrowserファイル選択";
1513                 field = panel.getNibrFileField();
1514                 isSave = false;
1515                 isDir = false;
1516             } else {
1517                 return;
1518             }
1519             showSaveDialog(title, field, isSave, isDir);
1520         }
1521     }
1522
1523     private class InputCommentPanelButtonListener implements ActionListener {
1524
1525         public void actionPerformed(ActionEvent e) {
1526             final Object source = e.getSource();
1527             String title;
1528             JTextField field;
1529             boolean isSave;
1530             boolean isDir;
1531             if (source == savePanel.getShowSavingCommentFolderDialogButton()) {
1532                 title = "コメントの保存先(フォルダ)";
1533                 field = savePanel.getCommentSavedFolderField();
1534                 isSave = true;
1535                 isDir = true;
1536             } else if (source == savePanel.getShowSavingCommentFileDialogButton()) {
1537                 title = "コメントの保存先(ファイル)";
1538                 field = savePanel.getCommentSavedFileField();
1539                 isSave = true;
1540                 isDir = false;
1541             } else {
1542                 return;
1543             }
1544             showSaveDialog(title, field, isSave, isDir);
1545         }
1546     }
1547
1548     private class OutputVideoPanelButtonListener implements ActionListener {
1549
1550         public void actionPerformed(ActionEvent e) {
1551             final Object source = e.getSource();
1552             String title;
1553             JTextField field;
1554             boolean isSave;
1555             boolean isDir;
1556             if (source == savePanel.getShowSavingConvertedVideoFolderDialogButton()) {
1557                 title = "コメント付き動画の保存先(フォルダ)";
1558                 field = savePanel.getConvertedVideoSavedFolderField();
1559                 isSave = true;
1560                 isDir = true;
1561             } else if (source == savePanel.getShowSavingConvertedVideoFileDialogButton()) {
1562                 title = "コメント付き動画の保存先(ファイル)";
1563                 field = savePanel.getConvertedVideoSavedFileField();
1564                 isSave = true;
1565                 isDir = false;
1566             } else {
1567                 return;
1568             }
1569             showSaveDialog(title, field, isSave, isDir);
1570         }
1571     }
1572
1573     private class VideoUseRadioButtonListener implements ActionListener {
1574
1575         public void actionPerformed(ActionEvent e) {
1576             Object source = e.getSource();
1577             if (source == videoSaveInfoPanel.getVideoUseNiBrButton()) {
1578                 maskExt();
1579             } else {
1580                 maskBase();
1581             }
1582         }
1583
1584         private void maskBase() {
1585             mask(true);
1586         }
1587
1588         private void maskExt() {
1589             mask(false);
1590         }
1591
1592         private void mask(boolean b) {
1593             final VideoSaveInfoPanel panel = videoSaveInfoPanel;
1594             videoIdField.setEditable(b);
1595             panel.getDelVideoCheckBox().setEnabled(b);
1596
1597             panel.getSaveFolderRadioButton().setEnabled(b);
1598             panel.getVideoSavedFolderField().setEnabled(b);
1599             panel.getShowSavingVideoFolderDialogButton().setEnabled(b);
1600
1601             panel.getSaveFileRadioButton().setEnabled(b);
1602             panel.getVideoSavedFileField().setEnabled(b);
1603             panel.getShowSavingVideoFileDialogButton().setEnabled(b);
1604
1605             panel.getNibrFileField().setEnabled(!b);
1606             panel.getNibrFileChooserButton().setEnabled(!b);
1607         }
1608     }
1609 }
1610
1611 class MainFrame_this_windowAdapter extends WindowAdapter {
1612
1613     private MainFrame adaptee;
1614
1615     MainFrame_this_windowAdapter(MainFrame adaptee) {
1616         this.adaptee = adaptee;
1617     }
1618
1619     @Override
1620     public void windowClosing(WindowEvent e) {
1621         adaptee.this_windowClosing(e);
1622     }
1623 }
1624
1625 class MainFrame_SettingFontPathButton_actionAdapter implements ActionListener {
1626
1627     private MainFrame adaptee;
1628
1629     MainFrame_SettingFontPathButton_actionAdapter(MainFrame adaptee) {
1630         this.adaptee = adaptee;
1631     }
1632
1633     public void actionPerformed(ActionEvent e) {
1634         adaptee.SettingFontPathButton_actionPerformed(e);
1635     }
1636 }
1637
1638 class MainFrame_SettingVhookPathButton_actionAdapter implements ActionListener {
1639
1640     private MainFrame adaptee;
1641
1642     MainFrame_SettingVhookPathButton_actionAdapter(MainFrame adaptee) {
1643         this.adaptee = adaptee;
1644     }
1645
1646     public void actionPerformed(ActionEvent e) {
1647         adaptee.SettingVhookPathButton_actionPerformed(e);
1648     }
1649 }
1650
1651 class MainFrame_SettingFFmpegPathButton_actionAdapter implements ActionListener {
1652
1653     private MainFrame adaptee;
1654
1655     MainFrame_SettingFFmpegPathButton_actionAdapter(MainFrame adaptee) {
1656         this.adaptee = adaptee;
1657     }
1658
1659     public void actionPerformed(ActionEvent e) {
1660         adaptee.SettingFFmpegPathButton_actionPerformed(e);
1661     }
1662 }
1663
1664 class MainFrame_DoButton_actionAdapter implements ActionListener {
1665
1666     private MainFrame adaptee;
1667
1668     MainFrame_DoButton_actionAdapter(MainFrame adaptee) {
1669         this.adaptee = adaptee;
1670     }
1671
1672     public void actionPerformed(ActionEvent e) {
1673         adaptee.DoButton_actionPerformed(e);
1674     }
1675 }
1676
1677 class MainFrame_jMenuFileExit_ActionAdapter implements ActionListener {
1678
1679     MainFrame adaptee;
1680
1681     MainFrame_jMenuFileExit_ActionAdapter(MainFrame adaptee) {
1682         this.adaptee = adaptee;
1683     }
1684
1685     public void actionPerformed(ActionEvent actionEvent) {
1686         adaptee.jMenuFileExit_actionPerformed(actionEvent);
1687     }
1688 }
1689
1690 class MainFrame_jMenuHelpAbout_ActionAdapter implements ActionListener {
1691
1692     MainFrame adaptee;
1693
1694     MainFrame_jMenuHelpAbout_ActionAdapter(MainFrame adaptee) {
1695         this.adaptee = adaptee;
1696     }
1697
1698     public void actionPerformed(ActionEvent actionEvent) {
1699         adaptee.jMenuHelpAbout_actionPerformed(actionEvent);
1700     }
1701 }