OSDN Git Service

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