OSDN Git Service

Merge remote-tracking branch 'origin/master'
[coroid/inqubus.git] / frontend / src / yukihane / inqubus / gui / ConfigDialog.java
1 /*
2  * Properties.java
3  *
4  * Created on 2011/08/20, 16:33:03
5  */
6 package yukihane.inqubus.gui;
7
8 import static javax.swing.GroupLayout.DEFAULT_SIZE;
9 import static javax.swing.GroupLayout.PREFERRED_SIZE;
10
11 import java.awt.event.ActionEvent;
12 import java.awt.event.ActionListener;
13 import java.io.File;
14 import java.util.List;
15 import org.slf4j.Logger;
16 import org.slf4j.LoggerFactory;
17 import javax.swing.BorderFactory;
18 import javax.swing.ButtonGroup;
19 import javax.swing.ComboBoxModel;
20 import javax.swing.DefaultComboBoxModel;
21 import javax.swing.GroupLayout;
22 import javax.swing.GroupLayout.Alignment;
23 import javax.swing.JButton;
24 import javax.swing.JCheckBox;
25 import javax.swing.JComboBox;
26 import javax.swing.JDialog;
27 import javax.swing.JFileChooser;
28 import javax.swing.JFrame;
29 import javax.swing.JLabel;
30 import javax.swing.JPanel;
31 import javax.swing.JPasswordField;
32 import javax.swing.JRadioButton;
33 import javax.swing.JSpinner;
34 import javax.swing.JTabbedPane;
35 import javax.swing.JTextField;
36 import javax.swing.LayoutStyle.ComponentPlacement;
37 import javax.swing.SpinnerNumberModel;
38 import javax.swing.WindowConstants;
39 import org.apache.commons.configuration.ConfigurationException;
40 import yukihane.inqubus.config.Config;
41 import yukihane.inqubus.config.Config.CookieBrowser;
42
43 /**
44  *
45  * @author yuki
46  */
47 public class ConfigDialog extends JDialog {
48     private static final long serialVersionUID = 1L;
49     private static final Logger logger = LoggerFactory.getLogger(ConfigDialog.class);
50     private static final String NEED_REBOOT = "設定を有効にするにはいんきゅばすの再起動が必要です";
51
52     /** Creates new form Properties */
53     public ConfigDialog() {
54         this(null);
55     }
56
57     public ConfigDialog(JFrame owner){
58         super(owner);
59
60         final JTabbedPane tabbedPane = new JTabbedPane();
61         final JPanel pnlNetwork = new JPanel();
62         final JPanel pnlAccount = new JPanel();
63         fldMail = new JTextField();
64         fldPassword.setEchoChar('*');
65         final JPanel pnlProxy = new JPanel();
66         cbProxyUse = new JCheckBox();
67         final JLabel lblProxyHost = new JLabel();
68         final JLabel lblProxyPort = new JLabel();
69         final JPanel pnlFile = new JPanel();
70         final JPanel pnlFileOutput = new JPanel();
71         final JLabel lblOutputDir = new JLabel();
72         final JLabel lblOutputFileNamePattern = new JLabel();
73         fldOutputDir = new JTextField();
74         fldOutputFileNamePattern = new JTextField();
75         cbOutputEnable = new JCheckBox();
76         cbOutputCommentOverlay = new JCheckBox();
77         cbOutputDisplayProgress = new JCheckBox();
78         final JPanel pnlComment = new JPanel();
79         final JPanel pnlCommentStandard = new JPanel();
80         final JLabel lblCommentSize = new JLabel();
81         final JLabel lblCommentSizeManual = new JLabel();
82         final JLabel lblCommentMinSize = new JLabel();
83         final JLabel lblCommentMinSizeManual = new JLabel();
84         final JLabel lblCommentDisplayMax = new JLabel();
85         final JLabel lblCommentDisplayMaxManual = new JLabel();
86         final JPanel pnlCommentAdvanced = new JPanel();
87         final JLabel lblFontPath = new JLabel();
88         cbFontSizeArrangeDisable = new JCheckBox();
89         cbCommentOpaque = new JCheckBox();
90         fldFontPath = new JTextField();
91         final JLabel lblFontIndex = new JLabel();
92         final JLabel lblFontShadow = new JLabel();
93         fldFontIndex = new JTextField();
94         final JPanel pnlFfmpeg = new JPanel();
95         final JPanel pnlFfmpegBinPath = new JPanel();
96         final JLabel lblFfmpegPath = new JLabel("ffmpeg");
97         final JLabel lblFfmpegDllPath = new JLabel("拡張ライブラリ");
98         final JLabel lblMediaInfoPath = new JLabel("MediaInfo");
99         final JPanel pnlNgSetting = new JPanel();
100         final JPanel pnlSearch = new JPanel();
101
102         setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
103
104         pnlNetwork.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
105
106         pnlAccount.setBorder(BorderFactory.createTitledBorder("アカウント"));
107
108         final JLabel lblMail = new JLabel("ID(メールアドレス)");
109         final JLabel lblPassword = new JLabel("パスワード");
110
111         GroupLayout gl_pnlAccount = new GroupLayout(pnlAccount);
112         pnlAccount.setLayout(gl_pnlAccount);
113         gl_pnlAccount.setHorizontalGroup(gl_pnlAccount.createParallelGroup(GroupLayout.Alignment.LEADING)
114             .addComponent(btnAccount)
115             .addGroup(gl_pnlAccount.createSequentialGroup()
116                 .addContainerGap()
117                 .addGap(10)
118                 .addGroup(gl_pnlAccount.createParallelGroup(GroupLayout.Alignment.LEADING)
119                     .addComponent(lblMail)
120                     .addComponent(lblPassword)
121                 )
122                 .addPreferredGap(ComponentPlacement.RELATED)
123                 .addGroup(gl_pnlAccount.createParallelGroup(GroupLayout.Alignment.LEADING)
124                     .addComponent(fldPassword, GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)
125                     .addComponent(fldMail, GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)
126                 )
127                 .addContainerGap()
128             )
129         );
130         gl_pnlAccount.setVerticalGroup(
131             gl_pnlAccount.createParallelGroup(GroupLayout.Alignment.LEADING)
132             .addGroup(gl_pnlAccount.createSequentialGroup()
133                 .addContainerGap()
134                 .addComponent(btnAccount)
135                 .addPreferredGap(ComponentPlacement.RELATED)
136                 .addGroup(gl_pnlAccount.createParallelGroup(GroupLayout.Alignment.BASELINE)
137                     .addComponent(lblMail)
138                     .addComponent(fldMail, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
139                 .addPreferredGap(ComponentPlacement.RELATED)
140                 .addGroup(gl_pnlAccount.createParallelGroup(GroupLayout.Alignment.BASELINE)
141                     .addComponent(lblPassword)
142                     .addComponent(fldPassword, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
143                 .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
144         );
145
146
147         final JButton btnCookie = new JButton("...");
148         btnCookie.addActionListener(new FileChooseActionListener(this, JFileChooser.DIRECTORIES_ONLY, fldCookie));
149
150         final ButtonGroup grpLoginType = new ButtonGroup();
151         grpLoginType.add(btnAccount);
152         grpLoginType.add(btnLoginCookie);
153
154         final ButtonGroup grpCookie = new ButtonGroup();
155         grpCookie.add(btnCookieIe);
156         grpCookie.add(btnCookieFirefox);
157         grpCookie.add(btnCookieChrome);
158         grpCookie.add(btnCookieChromium);
159         grpCookie.add(btnCookieOpera);
160         grpCookie.add(btnCookieOther);
161
162         final JPanel pnlCookie = new JPanel();
163         pnlCookie.setBorder(BorderFactory.createTitledBorder("cookie"));
164         final GroupLayout glCookie = new GroupLayout(pnlCookie);
165         pnlCookie.setLayout(glCookie);
166         glCookie.setAutoCreateContainerGaps(true);
167         glCookie.setAutoCreateGaps(true);
168
169         glCookie.setHorizontalGroup(glCookie.createParallelGroup()
170             .addComponent(btnLoginCookie)
171             .addGroup(glCookie.createSequentialGroup()
172                 .addGap(10)
173                 .addGroup(glCookie.createParallelGroup()
174                     .addComponent(btnCookieIe)
175                     .addComponent(btnCookieFirefox)
176                     .addComponent(btnCookieChrome)
177                     .addComponent(btnCookieChromium)
178                     .addComponent(btnCookieOpera)
179                     .addComponent(btnCookieOther)
180                     .addGroup(glCookie.createSequentialGroup()
181                         .addComponent(fldCookie)
182                         .addComponent(btnCookie)
183                     )
184                 )
185             )
186         );
187
188         glCookie.setVerticalGroup(glCookie.createSequentialGroup()
189             .addComponent(btnLoginCookie)
190             .addComponent(btnCookieIe)
191             .addComponent(btnCookieFirefox)
192             .addComponent(btnCookieChrome)
193             .addComponent(btnCookieChromium)
194             .addComponent(btnCookieOpera)
195             .addComponent(btnCookieOther)
196             .addGroup(glCookie.createParallelGroup(Alignment.BASELINE)
197                 .addComponent(fldCookie)
198                 .addComponent(btnCookie)
199             )
200         );
201
202
203         pnlProxy.setBorder(BorderFactory.createTitledBorder("プロキシ"));
204
205         cbProxyUse.setText("プロキシを使用する");
206
207         lblProxyHost.setText("ホスト名");
208
209         lblProxyPort.setText("ポート番号");
210
211         GroupLayout gl_pnlProxy = new GroupLayout(pnlProxy);
212         pnlProxy.setLayout(gl_pnlProxy);
213         gl_pnlProxy.setHorizontalGroup(
214             gl_pnlProxy.createParallelGroup(GroupLayout.Alignment.LEADING)
215             .addGroup(gl_pnlProxy.createSequentialGroup()
216                 .addContainerGap()
217                 .addGroup(gl_pnlProxy.createParallelGroup(GroupLayout.Alignment.LEADING)
218                     .addComponent(cbProxyUse)
219                     .addGroup(gl_pnlProxy.createSequentialGroup()
220                         .addComponent(lblProxyHost)
221                         .addGap(18, 18, 18)
222                         .addComponent(fldProxyHost, GroupLayout.PREFERRED_SIZE, 168, GroupLayout.PREFERRED_SIZE))
223                     .addGroup(gl_pnlProxy.createSequentialGroup()
224                         .addComponent(lblProxyPort)
225                         .addPreferredGap(ComponentPlacement.RELATED)
226                         .addComponent(fldProxyPort, GroupLayout.PREFERRED_SIZE, 76, GroupLayout.PREFERRED_SIZE)))
227                 .addContainerGap(181, Short.MAX_VALUE))
228         );
229         gl_pnlProxy.setVerticalGroup(
230             gl_pnlProxy.createParallelGroup(GroupLayout.Alignment.LEADING)
231             .addGroup(gl_pnlProxy.createSequentialGroup()
232                 .addContainerGap()
233                 .addComponent(cbProxyUse)
234                 .addPreferredGap(ComponentPlacement.RELATED)
235                 .addGroup(gl_pnlProxy.createParallelGroup(GroupLayout.Alignment.BASELINE)
236                     .addComponent(lblProxyHost)
237                     .addComponent(fldProxyHost, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
238                 .addPreferredGap(ComponentPlacement.RELATED)
239                 .addGroup(gl_pnlProxy.createParallelGroup(GroupLayout.Alignment.BASELINE)
240                     .addComponent(lblProxyPort)
241                     .addComponent(fldProxyPort, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
242                 .addContainerGap())
243         );
244
245
246         GroupLayout gl_pnlNetwork = new GroupLayout(pnlNetwork);
247         pnlNetwork.setLayout(gl_pnlNetwork);
248         gl_pnlNetwork.setHorizontalGroup(
249             gl_pnlNetwork.createParallelGroup(GroupLayout.Alignment.LEADING)
250             .addGroup(GroupLayout.Alignment.TRAILING, gl_pnlNetwork.createSequentialGroup()
251                 .addContainerGap()
252                 .addGroup(gl_pnlNetwork.createParallelGroup(GroupLayout.Alignment.TRAILING)
253                     .addComponent(pnlAccount, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
254                     .addComponent(pnlCookie, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
255                     .addComponent(pnlProxy, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
256                 )
257                 .addContainerGap())
258         );
259         gl_pnlNetwork.setVerticalGroup(
260             gl_pnlNetwork.createParallelGroup(GroupLayout.Alignment.LEADING)
261             .addGroup(gl_pnlNetwork.createSequentialGroup()
262                 .addContainerGap()
263                 .addComponent(pnlAccount, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
264                 .addPreferredGap(ComponentPlacement.RELATED)
265                 .addComponent(pnlCookie, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
266                 .addPreferredGap(ComponentPlacement.RELATED)
267                 .addComponent(pnlProxy, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
268                 .addContainerGap()
269             )
270         );
271
272         tabbedPane.addTab("ネットワーク", pnlNetwork);
273
274         pnlFileVideo.setBorder(BorderFactory.createTitledBorder("動画"));
275
276         pnlFileComment.setBorder(BorderFactory.createTitledBorder("コメント"));
277
278         pnlFileOutput.setBorder(BorderFactory.createTitledBorder("変換動画"));
279
280         lblOutputDir.setText("保存フォルダ");
281
282         lblOutputFileNamePattern.setText("ファイル名規則");
283
284         btnOutputDir.addActionListener(
285                 new FileChooseActionListener(ConfigDialog.this, JFileChooser.DIRECTORIES_ONLY, fldOutputDir));
286
287         cbOutputEnable.setText("変換");
288
289         cbOutputCommentOverlay.setText("コメント付与");
290
291         cbOutputDisplayProgress.setText("変換中動画表示");
292
293         GroupLayout gl_pnlFileOutput = new GroupLayout(pnlFileOutput);
294         pnlFileOutput.setLayout(gl_pnlFileOutput);
295         gl_pnlFileOutput.setHorizontalGroup(
296             gl_pnlFileOutput.createParallelGroup(GroupLayout.Alignment.LEADING)
297             .addGroup(gl_pnlFileOutput.createSequentialGroup()
298                 .addContainerGap()
299                 .addGroup(gl_pnlFileOutput.createParallelGroup(GroupLayout.Alignment.LEADING)
300                     .addComponent(lblOutputFileNamePattern)
301                     .addComponent(lblOutputDir))
302                 .addPreferredGap(ComponentPlacement.RELATED)
303                 .addGroup(gl_pnlFileOutput.createParallelGroup(GroupLayout.Alignment.LEADING)
304                     .addGroup(gl_pnlFileOutput.createSequentialGroup()
305                         .addComponent(fldOutputDir, GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
306                         .addPreferredGap(ComponentPlacement.RELATED)
307                         .addComponent(btnOutputDir)
308                         .addContainerGap())
309                     .addGroup(GroupLayout.Alignment.TRAILING, gl_pnlFileOutput.createSequentialGroup()
310                         .addComponent(fldOutputFileNamePattern, GroupLayout.PREFERRED_SIZE, 167, GroupLayout.PREFERRED_SIZE)
311                         .addPreferredGap(ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
312                         .addGroup(gl_pnlFileOutput.createParallelGroup(GroupLayout.Alignment.LEADING)
313                             .addComponent(cbOutputDisplayProgress)
314                             .addGroup(gl_pnlFileOutput.createSequentialGroup()
315                                 .addComponent(cbOutputEnable)
316                                 .addPreferredGap(ComponentPlacement.RELATED)
317                                 .addComponent(cbOutputCommentOverlay))))))
318         );
319         gl_pnlFileOutput.setVerticalGroup(
320             gl_pnlFileOutput.createParallelGroup(GroupLayout.Alignment.LEADING)
321             .addGroup(gl_pnlFileOutput.createSequentialGroup()
322                 .addGroup(gl_pnlFileOutput.createParallelGroup(GroupLayout.Alignment.BASELINE)
323                     .addComponent(lblOutputDir)
324                     .addComponent(fldOutputDir, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
325                     .addComponent(btnOutputDir))
326                 .addPreferredGap(ComponentPlacement.RELATED)
327                 .addGroup(gl_pnlFileOutput.createParallelGroup(GroupLayout.Alignment.BASELINE)
328                     .addComponent(lblOutputFileNamePattern)
329                     .addComponent(fldOutputFileNamePattern, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
330                     .addComponent(cbOutputCommentOverlay)
331                     .addComponent(cbOutputEnable))
332                 .addPreferredGap(ComponentPlacement.RELATED)
333                 .addComponent(cbOutputDisplayProgress)
334                 .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
335         );
336
337         final JPanel pnlFileProhibit = new JPanel();
338         pnlFileProhibit.setBorder(BorderFactory.createTitledBorder("禁則文字"));
339         final JLabel lblReplaceFrom = new JLabel("置換対象文字");
340         final JLabel lblReplaceTo = new JLabel("置換後文字");
341
342         final GroupLayout glProhibit = new GroupLayout(pnlFileProhibit);
343         glProhibit.setAutoCreateContainerGaps(true);
344         glProhibit.setAutoCreateGaps(true);
345         pnlFileProhibit.setLayout(glProhibit);
346
347         glProhibit.setHorizontalGroup(glProhibit.createSequentialGroup()
348             .addGroup(glProhibit.createParallelGroup()
349                 .addComponent(lblReplaceFrom)
350                 .addComponent(lblReplaceTo)
351             )
352             .addGroup(glProhibit.createParallelGroup()
353                 .addComponent(fldReplaceFrom)
354                 .addComponent(fldReplaceTo)
355             )
356         );
357
358         glProhibit.setVerticalGroup(glProhibit.createSequentialGroup()
359             .addGroup(glProhibit.createParallelGroup(Alignment.BASELINE)
360                 .addComponent(lblReplaceFrom)
361                 .addComponent(fldReplaceFrom)
362             )
363             .addGroup(glProhibit.createParallelGroup(Alignment.BASELINE)
364                 .addComponent(lblReplaceTo)
365                 .addComponent(fldReplaceTo)
366             )
367         );
368
369         GroupLayout gl_pnlFile = new GroupLayout(pnlFile);
370         pnlFile.setLayout(gl_pnlFile);
371         gl_pnlFile.setHorizontalGroup(
372             gl_pnlFile.createParallelGroup(GroupLayout.Alignment.LEADING)
373             .addGroup(GroupLayout.Alignment.TRAILING, gl_pnlFile.createSequentialGroup()
374                 .addContainerGap()
375                 .addGroup(gl_pnlFile.createParallelGroup(GroupLayout.Alignment.TRAILING)
376                     .addComponent(pnlFileOutput, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
377                     .addComponent(pnlFileVideo, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
378                     .addComponent(pnlFileComment, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
379                     .addComponent(pnlFileProhibit, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
380                 )
381                 .addContainerGap())
382         );
383         gl_pnlFile.setVerticalGroup(
384             gl_pnlFile.createParallelGroup(GroupLayout.Alignment.LEADING)
385             .addGroup(gl_pnlFile.createSequentialGroup()
386                 .addContainerGap()
387                 .addComponent(pnlFileVideo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
388                 .addPreferredGap(ComponentPlacement.RELATED)
389                 .addComponent(pnlFileComment, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
390                 .addPreferredGap(ComponentPlacement.RELATED)
391                 .addComponent(pnlFileOutput, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
392                 .addPreferredGap(ComponentPlacement.RELATED)
393                 .addComponent(pnlFileProhibit, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
394                 .addContainerGap())
395         );
396
397         tabbedPane.addTab("ファイル", pnlFile);
398
399         pnlCommentStandard.setBorder(BorderFactory.createTitledBorder(""));
400
401         lblCommentSize.setText("再生時間に応じたコメントの取得数");
402
403         lblCommentSizeManual.setText("手動取得");
404
405         lblCommentMinSize.setText("1分当たりのコメント取得数");
406
407         lblCommentMinSizeManual.setText("手動取得");
408
409         lblCommentDisplayMax.setText("1画面に表示する最大コメント数");
410
411         lblCommentDisplayMaxManual.setText("手動設定");
412
413         GroupLayout gl_pnlCommentStandard = new GroupLayout(pnlCommentStandard);
414         pnlCommentStandard.setLayout(gl_pnlCommentStandard);
415         gl_pnlCommentStandard.setAutoCreateContainerGaps(true);
416         gl_pnlCommentStandard.setAutoCreateGaps(true);
417         gl_pnlCommentStandard.setHorizontalGroup(
418             gl_pnlCommentStandard.createSequentialGroup()
419                 .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.LEADING)
420                     .addComponent(lblCommentSize)
421                     .addComponent(lblCommentMinSize)
422                     .addComponent(lblCommentDisplayMax))
423                 .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.LEADING)
424                     .addComponent(cbCommentSizeAuto)
425                     .addComponent(cbCommentMinDisable)
426                     .addComponent(cbCommentMinSizeAuto)
427                     .addComponent(cbCommentDisplaySizeDefault))
428                 .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.LEADING)
429                     .addComponent(lblCommentSizeManual)
430                     .addComponent(lblCommentMinSizeManual)
431                     .addComponent(lblCommentDisplayMaxManual))
432                 .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.LEADING)
433                     .addComponent(fldCommentSizeManual, 48, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
434                     .addComponent(fldCommentMinSizeManual, 48, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
435                     .addComponent(fldCommentDisplaySizeManual, 48, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
436         );
437         gl_pnlCommentStandard.setVerticalGroup(
438             gl_pnlCommentStandard.createSequentialGroup()
439                 .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.BASELINE)
440                     .addComponent(lblCommentSize)
441                     .addComponent(cbCommentSizeAuto)
442                     .addComponent(lblCommentSizeManual)
443                     .addComponent(fldCommentSizeManual))
444                 .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.BASELINE)
445                     .addComponent(lblCommentMinSize)
446                     .addComponent(cbCommentMinDisable)
447                 )
448                 .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.BASELINE)
449                     .addComponent(cbCommentMinSizeAuto)
450                     .addComponent(lblCommentMinSizeManual)
451                     .addComponent(fldCommentMinSizeManual))
452                 .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.BASELINE)
453                     .addComponent(lblCommentDisplayMax)
454                     .addComponent(cbCommentDisplaySizeDefault)
455                     .addComponent(lblCommentDisplayMaxManual)
456                     .addComponent(fldCommentDisplaySizeManual))
457         );
458
459         pnlCommentAdvanced.setBorder(BorderFactory.createTitledBorder("高度な設定"));
460
461         lblFontPath.setText("フォントパス");
462
463         cbFontSizeArrangeDisable.setText("フォントサイズ調整を行わない");
464
465         cbCommentOpaque.setText("コメント透明化を行わない");
466
467         final JButton btnFontPath = new JButton("...");
468         btnFontPath.addActionListener(
469                 new FileChooseActionListener(ConfigDialog.this, JFileChooser.FILES_ONLY, fldFontPath));
470
471         lblFontIndex.setText("フォント番号");
472
473         lblFontShadow.setText("影の種類");
474         final ComboBoxModel<String> cbmFontShadow
475                 = new DefaultComboBoxModel<>(new String[]{"0:なし", "1:ニコニコ動画風", "2:右下", "3:囲い込み"});
476         cmbFontShadow.setModel(cbmFontShadow);
477
478         GroupLayout gl_pnlCommentAdvanced = new GroupLayout(pnlCommentAdvanced);
479         pnlCommentAdvanced.setLayout(gl_pnlCommentAdvanced);
480         gl_pnlCommentAdvanced.setHorizontalGroup(
481             gl_pnlCommentAdvanced.createParallelGroup(GroupLayout.Alignment.LEADING)
482             .addGroup(gl_pnlCommentAdvanced.createSequentialGroup()
483                 .addContainerGap()
484                 .addGroup(gl_pnlCommentAdvanced.createParallelGroup(GroupLayout.Alignment.LEADING)
485                     .addComponent(cbCommentOpaque)
486                     .addGroup(gl_pnlCommentAdvanced.createSequentialGroup()
487                         .addGroup(gl_pnlCommentAdvanced.createParallelGroup(GroupLayout.Alignment.LEADING)
488                             .addComponent(lblFontPath)
489                             .addComponent(lblFontIndex)
490                             .addComponent(lblFontShadow))
491                         .addGap(18, 18, 18)
492                         .addGroup(gl_pnlCommentAdvanced.createParallelGroup(GroupLayout.Alignment.LEADING)
493                             .addComponent(fldFontPath, GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)
494                             .addGroup(gl_pnlCommentAdvanced.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
495                                 .addComponent(cmbFontShadow, GroupLayout.Alignment.LEADING)
496                                 .addComponent(fldFontIndex, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 48, Short.MAX_VALUE)))
497                         .addPreferredGap(ComponentPlacement.RELATED)
498                         .addComponent(btnFontPath))
499                     .addComponent(cbFontSizeArrangeDisable))
500                 .addContainerGap())
501         );
502         gl_pnlCommentAdvanced.setVerticalGroup(
503             gl_pnlCommentAdvanced.createParallelGroup(GroupLayout.Alignment.LEADING)
504             .addGroup(gl_pnlCommentAdvanced.createSequentialGroup()
505                 .addGroup(gl_pnlCommentAdvanced.createParallelGroup(GroupLayout.Alignment.BASELINE)
506                     .addComponent(lblFontPath)
507                     .addComponent(fldFontPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
508                     .addComponent(btnFontPath))
509                 .addPreferredGap(ComponentPlacement.RELATED)
510                 .addGroup(gl_pnlCommentAdvanced.createParallelGroup(GroupLayout.Alignment.BASELINE)
511                     .addComponent(lblFontIndex)
512                     .addComponent(fldFontIndex, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
513                 .addPreferredGap(ComponentPlacement.RELATED)
514                 .addGroup(gl_pnlCommentAdvanced.createParallelGroup(GroupLayout.Alignment.BASELINE)
515                     .addComponent(lblFontShadow)
516                     .addComponent(cmbFontShadow, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
517                 .addPreferredGap(ComponentPlacement.RELATED)
518                 .addComponent(cbFontSizeArrangeDisable)
519                 .addPreferredGap(ComponentPlacement.RELATED)
520                 .addComponent(cbCommentOpaque)
521                 .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
522         );
523
524         GroupLayout gl_pnlComment = new GroupLayout(pnlComment);
525         pnlComment.setLayout(gl_pnlComment);
526         gl_pnlComment.setHorizontalGroup(
527             gl_pnlComment.createParallelGroup(GroupLayout.Alignment.LEADING)
528             .addGroup(GroupLayout.Alignment.TRAILING, gl_pnlComment.createSequentialGroup()
529                 .addContainerGap()
530                 .addGroup(gl_pnlComment.createParallelGroup(GroupLayout.Alignment.TRAILING)
531                     .addComponent(pnlCommentAdvanced, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
532                     .addComponent(pnlCommentStandard, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
533                 .addContainerGap())
534         );
535         gl_pnlComment.setVerticalGroup(
536             gl_pnlComment.createParallelGroup(GroupLayout.Alignment.LEADING)
537             .addGroup(gl_pnlComment.createSequentialGroup()
538                 .addContainerGap()
539                 .addComponent(pnlCommentStandard, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
540                 .addPreferredGap(ComponentPlacement.RELATED)
541                 .addComponent(pnlCommentAdvanced, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
542                 .addContainerGap(168, Short.MAX_VALUE))
543         );
544
545         tabbedPane.addTab("コメント", pnlComment);
546
547         pnlFfmpegBinPath.setBorder(BorderFactory.createTitledBorder("ファイルパス"));
548
549         final JButton btnFfmpegPath = new JButton("...");
550         btnFfmpegPath.addActionListener(
551                 new FileChooseActionListener(ConfigDialog.this, JFileChooser.FILES_ONLY, fldFfmpegPath));
552
553         final JButton btnFfmpegDllPath = new JButton("...");
554         btnFfmpegDllPath.addActionListener(
555                 new FileChooseActionListener(ConfigDialog.this, JFileChooser.FILES_ONLY, fldFfmpegDllPath));
556
557         final JButton btnMediaInfoPath = new JButton("...");
558         btnMediaInfoPath.addActionListener(
559                 new FileChooseActionListener(ConfigDialog.this, JFileChooser.FILES_ONLY, fldMediaInfoPath));
560
561         GroupLayout gl_jPanel10 = new GroupLayout(pnlFfmpegBinPath);
562         pnlFfmpegBinPath.setLayout(gl_jPanel10);
563         gl_jPanel10.setHorizontalGroup(
564             gl_jPanel10.createParallelGroup(GroupLayout.Alignment.LEADING)
565             .addGroup(gl_jPanel10.createSequentialGroup()
566                 .addContainerGap()
567                 .addGroup(gl_jPanel10.createParallelGroup(GroupLayout.Alignment.LEADING)
568                     .addComponent(lblFfmpegPath)
569                     .addComponent(lblFfmpegDllPath)
570                     .addComponent(lblMediaInfoPath)
571                 )
572                 .addPreferredGap(ComponentPlacement.RELATED)
573                 .addGroup(gl_jPanel10.createParallelGroup(GroupLayout.Alignment.LEADING)
574                     .addComponent(fldFfmpegDllPath, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
575                     .addComponent(fldFfmpegPath, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
576                     .addComponent(fldMediaInfoPath, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
577                 )
578                 .addPreferredGap(ComponentPlacement.RELATED)
579                 .addGroup(gl_jPanel10.createParallelGroup(GroupLayout.Alignment.LEADING)
580                     .addComponent(btnFfmpegPath, GroupLayout.Alignment.TRAILING)
581                     .addComponent(btnFfmpegDllPath, GroupLayout.Alignment.TRAILING)
582                     .addComponent(btnMediaInfoPath, GroupLayout.Alignment.TRAILING)
583                 )
584                 .addContainerGap())
585         );
586         gl_jPanel10.setVerticalGroup(
587             gl_jPanel10.createParallelGroup(GroupLayout.Alignment.LEADING)
588             .addGroup(gl_jPanel10.createSequentialGroup()
589                 .addGroup(gl_jPanel10.createParallelGroup(GroupLayout.Alignment.BASELINE)
590                     .addComponent(lblFfmpegPath)
591                     .addComponent(fldFfmpegPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
592                     .addComponent(btnFfmpegPath))
593                 .addGroup(gl_jPanel10.createParallelGroup(GroupLayout.Alignment.BASELINE)
594                     .addComponent(lblFfmpegDllPath)
595                     .addComponent(fldFfmpegDllPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
596                     .addComponent(btnFfmpegDllPath))
597                 .addGroup(gl_jPanel10.createParallelGroup(GroupLayout.Alignment.BASELINE)
598                     .addComponent(lblMediaInfoPath)
599                     .addComponent(fldMediaInfoPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
600                     .addComponent(btnMediaInfoPath))
601             )
602         );
603
604         pnlFfmpegParam.setBorder(BorderFactory.createTitledBorder("ffmpegパラメータ"));
605
606         // ffmpeg - その他
607         final JPanel pnlFffmpegEtc = new JPanel();
608         pnlFffmpegEtc.setBorder(BorderFactory.createTitledBorder("その他"));
609         final GroupLayout glFfmpegEtc = new GroupLayout(pnlFffmpegEtc);
610         glFfmpegEtc.setAutoCreateContainerGaps(true);
611         glFfmpegEtc.setAutoCreateGaps(true);
612         pnlFffmpegEtc.setLayout(glFfmpegEtc);
613
614         glFfmpegEtc.setHorizontalGroup(glFfmpegEtc.createParallelGroup()
615             .addComponent(cbDisplayConverting)
616             .addComponent(cbDllDisabled)
617         );
618         glFfmpegEtc.setVerticalGroup(glFfmpegEtc.createSequentialGroup()
619             .addComponent(cbDisplayConverting)
620             .addComponent(cbDllDisabled)
621         );
622
623         final GroupLayout glFfmpeg = new GroupLayout(pnlFfmpeg);
624         glFfmpeg.setAutoCreateContainerGaps(true);
625         pnlFfmpeg.setLayout(glFfmpeg);
626         glFfmpeg.setHorizontalGroup(glFfmpeg.createParallelGroup(GroupLayout.Alignment.LEADING)
627             .addComponent(pnlFfmpegBinPath)
628             .addComponent(pnlFfmpegParam)
629             .addComponent(pnlFffmpegEtc)
630         );
631         glFfmpeg.setVerticalGroup(glFfmpeg.createSequentialGroup()
632             .addComponent(pnlFfmpegBinPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
633             .addPreferredGap(ComponentPlacement.RELATED)
634             .addComponent(pnlFfmpegParam)
635             .addComponent(pnlFffmpegEtc)
636         );
637
638         tabbedPane.addTab("ffmpeg", pnlFfmpeg);
639
640         pnlNgWord.setBorder(BorderFactory.createTitledBorder("NGワード"));
641         pnlNgId.setBorder(BorderFactory.createTitledBorder("NGID"));
642
643         GroupLayout gl_pnlNgSetting = new GroupLayout(pnlNgSetting);
644         pnlNgSetting.setLayout(gl_pnlNgSetting);
645         gl_pnlNgSetting.setHorizontalGroup(
646             gl_pnlNgSetting.createParallelGroup(GroupLayout.Alignment.LEADING)
647             .addGroup(GroupLayout.Alignment.TRAILING, gl_pnlNgSetting.createSequentialGroup()
648                 .addContainerGap()
649                 .addGroup(gl_pnlNgSetting.createParallelGroup(GroupLayout.Alignment.TRAILING)
650                     .addComponent(pnlNgId, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
651                     .addComponent(pnlNgWord, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
652                 .addContainerGap())
653         );
654         gl_pnlNgSetting.setVerticalGroup(
655             gl_pnlNgSetting.createParallelGroup(GroupLayout.Alignment.LEADING)
656             .addGroup(gl_pnlNgSetting.createSequentialGroup()
657                 .addContainerGap()
658                 .addComponent(pnlNgWord, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
659                 .addPreferredGap(ComponentPlacement.RELATED)
660                 .addComponent(pnlNgId, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
661                 .addContainerGap())
662         );
663
664         tabbedPane.addTab("NG設定", pnlNgSetting);
665
666         pnlSearchVideo.setBorder(BorderFactory.createTitledBorder("動画検索対象フォルダ"));
667         pnlSearchComment.setBorder(BorderFactory.createTitledBorder("コメント検索対象フォルダ"));
668
669         final JLabel lblSearchNeedReboot = new JLabel(NEED_REBOOT);
670
671         GroupLayout gl_pnlSearch = new GroupLayout(pnlSearch);
672         pnlSearch.setLayout(gl_pnlSearch);
673         gl_pnlSearch.setHorizontalGroup(
674             gl_pnlSearch.createParallelGroup(GroupLayout.Alignment.LEADING)
675             .addGroup(GroupLayout.Alignment.TRAILING, gl_pnlSearch.createSequentialGroup()
676                 .addContainerGap()
677                 .addGroup(gl_pnlSearch.createParallelGroup(GroupLayout.Alignment.TRAILING)
678                     .addComponent(lblSearchNeedReboot, Alignment.CENTER)
679                     .addComponent(pnlSearchComment, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
680                     .addComponent(pnlSearchVideo, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
681                 .addContainerGap())
682         );
683         gl_pnlSearch.setVerticalGroup(
684             gl_pnlSearch.createParallelGroup(GroupLayout.Alignment.LEADING)
685             .addGroup(gl_pnlSearch.createSequentialGroup()
686                 .addContainerGap()
687                 .addComponent(lblSearchNeedReboot)
688                 .addComponent(pnlSearchVideo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
689                 .addPreferredGap(ComponentPlacement.RELATED)
690                 .addComponent(pnlSearchComment, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
691                 .addContainerGap()
692             )
693         );
694
695         tabbedPane.addTab("検索", pnlSearch);
696
697         final JButton btnOk = new JButton("保存");
698         btnOk.addActionListener(new ActionListener() {
699
700             @Override
701             public void actionPerformed(ActionEvent e) {
702                 saveConfig();
703                 dispose();
704             }
705         });
706         final JButton btnCancel = new JButton("取消");
707         btnCancel.addActionListener(new ActionListener() {
708
709             @Override
710             public void actionPerformed(ActionEvent e) {
711                 dispose();
712             }
713         });
714         final JPanel pnlButton = new JPanel();
715
716         final GroupLayout glButton = new GroupLayout(pnlButton);
717         pnlButton.setLayout(glButton);
718         glButton.setHorizontalGroup(glButton.createSequentialGroup()
719             .addPreferredGap(ComponentPlacement.UNRELATED, PREFERRED_SIZE, Short.MAX_VALUE)
720             .addComponent(btnOk)
721             .addPreferredGap(ComponentPlacement.UNRELATED)
722             .addComponent(btnCancel)
723             .addContainerGap()
724         );
725         glButton.setVerticalGroup(glButton.createSequentialGroup()
726             .addGroup(glButton.createParallelGroup(Alignment.BASELINE)
727                 .addComponent(btnOk)
728                 .addComponent(btnCancel)
729             )
730         );
731
732         GroupLayout layout = new GroupLayout(getContentPane());
733         layout.setAutoCreateContainerGaps(true);
734         getContentPane().setLayout(layout);
735         layout.setHorizontalGroup(
736             layout.createParallelGroup(GroupLayout.Alignment.LEADING)
737             .addComponent(tabbedPane, GroupLayout.DEFAULT_SIZE, 460, Short.MAX_VALUE)
738             .addComponent(pnlButton)
739         );
740         layout.setVerticalGroup(
741             layout.createSequentialGroup()
742                 .addComponent(tabbedPane,GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
743                 .addComponent(pnlButton)
744         );
745
746         final JLabel lblSystemThreadDownload = new JLabel("ダウンロードスレッド数");
747         final JLabel lblSystemWaitDownload = new JLabel("ダウンロード開始最小間隔(秒)");
748         final JLabel lblSystemThreadConvert = new JLabel("変換スレッド数");
749         final JLabel lblSystemTempDir = new JLabel("作業フォルダ");
750         final JButton btnSystemTempDir = new JButton("...");
751         btnSystemTempDir.addActionListener(
752                 new FileChooseActionListener(ConfigDialog.this, JFileChooser.DIRECTORIES_ONLY, fldSystemTempDir));
753
754         mdlSystemThreadDownload.setMinimum(1);
755         final JSpinner fldSystemThreadDownload = new JSpinner(mdlSystemThreadDownload);
756         mdlSystemWaitDownload.setMinimum(0);
757         final JSpinner fldSystemWaitDownload = new JSpinner(mdlSystemWaitDownload);
758         mdlSystemThreadConvert.setMinimum(1);
759         final JSpinner fldSystemThreadConvert = new JSpinner(mdlSystemThreadConvert);
760
761         final JPanel pnlSystemGeneral = new JPanel();
762         pnlSystemGeneral.setBorder(BorderFactory.createTitledBorder("システム"));
763         final GroupLayout glSystemGenegal = new GroupLayout(pnlSystemGeneral);
764         glSystemGenegal.setAutoCreateGaps(true);
765         glSystemGenegal.setAutoCreateContainerGaps(true);
766         pnlSystemGeneral.setLayout(glSystemGenegal);
767
768         glSystemGenegal.setHorizontalGroup(glSystemGenegal.createParallelGroup()
769             .addGroup(glSystemGenegal.createSequentialGroup()
770                 .addGroup(glSystemGenegal.createParallelGroup()
771                     .addComponent(lblSystemThreadDownload)
772                     .addComponent(lblSystemWaitDownload)
773                     .addComponent(lblSystemThreadConvert))
774                 .addGroup(glSystemGenegal.createParallelGroup()
775                     .addComponent(fldSystemThreadDownload, PREFERRED_SIZE, 50, PREFERRED_SIZE)
776                     .addComponent(fldSystemWaitDownload, PREFERRED_SIZE, 55, PREFERRED_SIZE)
777                     .addComponent(fldSystemThreadConvert, PREFERRED_SIZE, 50, PREFERRED_SIZE)
778                 )
779             )
780             .addGroup(glSystemGenegal.createSequentialGroup()
781                 .addComponent(lblSystemTempDir)
782                 .addComponent(fldSystemTempDir, DEFAULT_SIZE, 400, Short.MAX_VALUE)
783                 .addComponent(btnSystemTempDir)
784                 )
785             );
786
787         glSystemGenegal.setVerticalGroup(glSystemGenegal.createSequentialGroup()
788             .addGroup(glSystemGenegal.createParallelGroup(Alignment.BASELINE)
789                 .addComponent(lblSystemThreadDownload)
790                 .addComponent(fldSystemThreadDownload, DEFAULT_SIZE, PREFERRED_SIZE, PREFERRED_SIZE))
791             .addGroup(glSystemGenegal.createParallelGroup(Alignment.BASELINE)
792                 .addComponent(lblSystemWaitDownload)
793                 .addComponent(fldSystemWaitDownload, DEFAULT_SIZE, PREFERRED_SIZE, PREFERRED_SIZE))
794             .addGroup(glSystemGenegal.createParallelGroup(Alignment.BASELINE)
795                 .addComponent(lblSystemThreadConvert)
796                 .addComponent(fldSystemThreadConvert, DEFAULT_SIZE, PREFERRED_SIZE, PREFERRED_SIZE))
797             .addGroup(glSystemGenegal.createParallelGroup(Alignment.BASELINE)
798                 .addComponent(lblSystemTempDir)
799                 .addComponent(fldSystemTempDir, DEFAULT_SIZE, PREFERRED_SIZE, PREFERRED_SIZE)
800                 .addComponent(btnSystemTempDir)
801             )
802         );
803
804         final JLabel lblSystemNeedReboot = new JLabel("設定を有効にするにはいんきゅばすの再起動が必要です");
805
806         final JPanel pnlSystem = new JPanel();
807         pnlSystem.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
808         final GroupLayout glSystem = new GroupLayout(pnlSystem);
809         glSystem.setAutoCreateGaps(true);
810         glSystem.setAutoCreateContainerGaps(true);
811         pnlSystem.setLayout(glSystem);
812
813         glSystem.setHorizontalGroup(glSystem.createParallelGroup()
814             .addComponent(lblSystemNeedReboot, Alignment.CENTER)
815             .addComponent(pnlSystemGeneral));
816
817         glSystem.setVerticalGroup(glSystem.createSequentialGroup()
818             .addComponent(lblSystemNeedReboot)
819             .addComponent(pnlSystemGeneral));
820
821         tabbedPane.add("システム", pnlSystem);
822
823         pack();
824         setMinimumSize(getSize());
825         loadConfig();
826     }
827
828     // ネットワーク
829     // ネットワーク - アカウント
830     final JRadioButton btnAccount = new JRadioButton("次の情報を使用してログインする");
831     private final JTextField fldMail;
832     private final JPasswordField fldPassword = new JPasswordField();
833     // ネットワーク - cookie
834     final JRadioButton btnLoginCookie = new JRadioButton("ブラウザのログイン情報を使用してアクセスする");
835     final JRadioButton btnCookieIe = new JRadioButton("IE(7以降) (Windows)");
836     final JRadioButton btnCookieFirefox = new JRadioButton("Firefox(4以降) (Windows)");
837     final JRadioButton btnCookieChrome = new JRadioButton("Google Chrome (Windows)");
838     final JRadioButton btnCookieChromium = new JRadioButton("Chrome派生ブラウザ (Windows)");
839     final JRadioButton btnCookieOpera = new JRadioButton("Opera (Windows)");
840     final JRadioButton btnCookieOther = new JRadioButton("上記以外 - cookie保存ディレクトリを次に入力");
841     final JTextField fldCookie = new JTextField();
842     // ネットワーク - プロキシ
843     private final JCheckBox cbProxyUse;
844     private final JTextField fldProxyHost = new JTextField();
845     private final NumberFormattedTextField fldProxyPort = new NumberFormattedTextField();
846     // ファイル
847     // ファイル - 動画
848     private final DownloadLocationPanel pnlFileVideo = new DownloadLocationPanel();
849     // ファイル - コメント
850     private final DownloadLocationPanel pnlFileComment = new DownloadLocationPanel();
851     // ファイル - 変換動画
852     private final JTextField fldOutputDir;
853     private final JTextField fldOutputFileNamePattern;
854     private final JButton btnOutputDir = new JButton("...");
855     private final JCheckBox cbOutputEnable;
856     private final JCheckBox cbOutputCommentOverlay;
857     private final JCheckBox cbOutputDisplayProgress;
858     // ファイル - 禁則文字
859     private final JTextField fldReplaceFrom = new JTextField();
860     private final JTextField fldReplaceTo = new JTextField();
861     // コメント
862     // コメント
863     private final JCheckBox cbCommentSizeAuto = new JCheckBox("自動調整");
864     private final NumberFormattedTextField fldCommentSizeManual = new NumberFormattedTextField();
865     private final JCheckBox cbCommentMinDisable = new JCheckBox("少コメ");
866     private final JCheckBox cbCommentMinSizeAuto = new JCheckBox("自動調整");
867     private final NumberFormattedTextField fldCommentMinSizeManual = new NumberFormattedTextField();
868     private final JCheckBox cbCommentDisplaySizeDefault = new JCheckBox("標準(30)");
869     private final NumberFormattedTextField fldCommentDisplaySizeManual = new NumberFormattedTextField();
870     // コメント - 高度な設定
871     private final JTextField fldFontPath;
872     private final JTextField fldFontIndex;
873     private final JComboBox<String> cmbFontShadow = new JComboBox<>();
874     private final JCheckBox cbFontSizeArrangeDisable;
875     private final JCheckBox cbCommentOpaque;
876     // ffmpeg
877     // ffmpeg - ファイルパス
878     private final JTextField fldFfmpegPath = new JTextField();
879     private final JTextField fldFfmpegDllPath = new JTextField();
880     private final JTextField fldMediaInfoPath = new JTextField();
881     // ffmpeg - ffmpegパラメータ
882     private final FfmpegParamPanel pnlFfmpegParam = new FfmpegParamPanel();
883     // ffmpeg - その他
884     private final JCheckBox cbDisplayConverting = new JCheckBox("変換中動画表示");
885     private final JCheckBox cbDllDisabled = new JCheckBox("拡張DLL無効化(デバッグ用)");
886     // NG設定
887     // NG設定 - NGワード
888     private final NgRegisterPanel pnlNgWord = new NgRegisterPanel();
889     // NG設定 - NGID
890     private final NgRegisterPanel pnlNgId = new NgRegisterPanel();
891     // 検索
892     // 検索 - 動画検索対象フォルダ
893     private final DirectoryRegisterPanel pnlSearchVideo = new DirectoryRegisterPanel();
894     // 検索 - コメント検索対象フォルダ
895     private final DirectoryRegisterPanel pnlSearchComment = new DirectoryRegisterPanel();
896     // システム
897     private final SpinnerNumberModel mdlSystemThreadDownload = new SpinnerNumberModel();
898     private final SpinnerNumberModel mdlSystemWaitDownload = new SpinnerNumberModel();
899     private final SpinnerNumberModel mdlSystemThreadConvert = new SpinnerNumberModel();
900     private final JTextField fldSystemTempDir = new JTextField();
901
902
903     // End of variables declaration//GEN-END:variables
904
905     private void loadConfig() {
906         final Config p = Config.INSTANCE;
907
908         /*
909          * ネットワーク - アカウント
910          */
911         btnAccount.setSelected(p.getNeedsLogin());
912         fldMail.setText(p.getId());
913         fldPassword.setText(p.getPassword());
914
915         /*
916          * ネットワーク - cookie
917          */
918         btnLoginCookie.setSelected(!p.getNeedsLogin());
919         final CookieBrowser cookieBrowser = p.getCookieBrowser();
920         final JRadioButton enabledBrowser;
921         switch(cookieBrowser){
922             case MSIE:
923                 enabledBrowser = btnCookieIe;
924                 break;
925             case FIREFOX:
926                 enabledBrowser = btnCookieFirefox;
927                 break;
928             case CHROME:
929                 enabledBrowser = btnCookieChrome;
930                 break;
931             case CHROMIUM:
932                 enabledBrowser = btnCookieChromium;
933                 break;
934             case OPERA:
935                 enabledBrowser = btnCookieOpera;
936                 break;
937             case OTHER:
938                 enabledBrowser = btnCookieOther;
939                 break;
940             default:
941                 throw new UnsupportedOperationException();
942         }
943         enabledBrowser.setSelected(true);
944         fldCookie.setText(p.getCookieDir());
945
946         /*
947          * ネットワーク - プロキシ
948          */
949         cbProxyUse.setSelected(p.getProxyUse());
950         fldProxyHost.setText(p.getProxyHost());
951         fldProxyPort.setText(p.getProxyPort());
952
953         /*
954          * ファイル - 動画
955          */
956         pnlFileVideo.fldDir.setText(p.getVideoDir());
957         pnlFileVideo.fldFileNamePattern.setText(p.getVideoFileNamePattern());
958         pnlFileVideo.cbLocal.setSelected(p.getVideoUseLocal());
959
960         /*
961          * ファイル - コメント
962          */
963         pnlFileComment.fldDir.setText(p.getCommentDir());
964         pnlFileComment.fldFileNamePattern.setText(p.getCommentFileNamePattern());
965         pnlFileComment.cbLocal.setSelected(p.getCommentUseLocal());
966
967         /*
968          * ファイル - 変換動画
969          */
970         fldOutputDir.setText(p.getOutputDir());
971         fldOutputFileNamePattern.setText(p.getOutputFileNamePattern());
972         cbOutputEnable.setSelected(p.getOutputEnable());
973         cbOutputCommentOverlay.setSelected(p.getOutputCommentOverlay());
974         cbOutputDisplayProgress.setSelected(p.getOutputDisplayProgress());
975
976         /*
977          * ファイル - 禁則文字
978          */
979         fldReplaceFrom.setText(p.getReplaceFrom());
980         fldReplaceTo.setText(p.getReplaceTo());
981
982         /**
983          * コメント
984          */
985         cbCommentSizeAuto.setSelected(p.getCommentSizeAutosize());
986         fldCommentSizeManual.setText(p.getCommentSizeManual());
987         cbCommentMinDisable.setSelected(p.getCommentMinDisabled());
988         cbCommentMinSizeAuto.setSelected(p.getCommentMinSizeAutosize());
989         fldCommentSizeManual.setText(p.getCommentMinSizeManual());
990         cbCommentDisplaySizeDefault.setSelected(p.getCommentDisplaySizeDefault());
991         fldCommentDisplaySizeManual.setText(p.getCommentDisplaySizeManual());
992
993         /**
994          * コメント - 高度な設定
995          */
996         fldFontPath.setText(p.getFontPath());
997         fldFontIndex.setText(p.getFontIndex());
998         cmbFontShadow.setSelectedIndex(p.getFontShadow());
999         cbFontSizeArrangeDisable.setSelected(p.getFontSizeArrangeDisable());
1000         cbCommentOpaque.setSelected(p.getCommentOpaque());
1001
1002         /*
1003          * ffmpeg - ファイルパス
1004          */
1005         fldFfmpegPath.setText(p.getFfmpegPath());
1006         fldFfmpegDllPath.setText(p.getFfmpegDllPath());
1007         fldMediaInfoPath.setText(p.getMediaInfoPath());
1008
1009         /*
1010          * ffmpeg - ffmpegパラメータ
1011          */
1012         pnlFfmpegParam.init(p);
1013
1014         /*
1015          * ffmpeg - その他
1016          */
1017         cbDisplayConverting.setSelected(p.getFfmpegDisplayConverting());
1018         cbDllDisabled.setSelected(p.getFfmpegDllDisabled());
1019
1020         /*
1021          * NG 設定
1022          */
1023         final List<String> ngWords = p.getNgWords();
1024         pnlNgWord.init(ngWords);
1025         final List<String> ngIds = p.getNgIds();
1026         pnlNgId.init(ngIds);
1027
1028         /*
1029          * 検索
1030          */
1031         pnlSearchVideo.init(p.getSearchVideoDirs());
1032         pnlSearchComment.init(p.getSearchCommentDirs());
1033
1034         /*
1035          * システム
1036          */
1037         mdlSystemThreadDownload.setValue(p.getSystemDownloadThread());
1038         mdlSystemWaitDownload.setValue(p.getSystemDownloadWait());
1039         mdlSystemThreadConvert.setValue(p.getSystemConvertThread());
1040         fldSystemTempDir.setText(p.getSystemTempDir());
1041     }
1042
1043     private void saveConfig() {
1044         final Config p = Config.INSTANCE;
1045
1046         /*
1047          * ネットワーク - アカウント
1048          */
1049         p.setNeedsLogin(btnAccount.isSelected());
1050         p.setId(fldMail.getText());
1051         p.setPassword(String.valueOf(fldPassword.getPassword()));
1052
1053         /*
1054          * ネットワーク - cookie
1055          */
1056         final CookieBrowser cookieBrowser;
1057         if(btnCookieIe.isSelected()) {
1058             cookieBrowser = CookieBrowser.MSIE;
1059         } else if(btnCookieFirefox.isSelected()) {
1060             cookieBrowser = CookieBrowser.FIREFOX;
1061         } else if (btnCookieChrome.isSelected()) {
1062             cookieBrowser = CookieBrowser.CHROME;
1063         } else if (btnCookieChromium.isSelected()) {
1064             cookieBrowser = CookieBrowser.CHROMIUM;
1065         } else if(btnCookieOpera.isSelected()) {
1066             cookieBrowser = CookieBrowser.OPERA;
1067         } else if(btnCookieOther.isSelected()) {
1068             cookieBrowser = CookieBrowser.OTHER;
1069         } else {
1070             throw new UnsupportedOperationException();
1071         }
1072         p.setCookieBrowser(cookieBrowser);
1073         p.setCookieDir(fldCookie.getText());
1074
1075         /*
1076          * ネットワーク - プロキシ
1077          */
1078         p.setProxyUse(cbProxyUse.isSelected());
1079         p.setProxyHost(fldProxyHost.getText());
1080         p.setProxyPort(fldProxyPort.getText());
1081
1082         /*
1083          * ファイル - 動画
1084          */
1085         p.setVideoDir(pnlFileVideo.fldDir.getText());
1086         p.setVideoFileNamePattern(pnlFileVideo.fldFileNamePattern.getText());
1087         p.setVideoUseLocal(pnlFileVideo.cbLocal.isSelected());
1088
1089         /*
1090          * ファイル - コメント
1091          */
1092         p.setCommentDir(pnlFileComment.fldDir.getText());
1093         p.setCommentFileNamePattern(pnlFileComment.fldFileNamePattern.getText());
1094         p.setCommentUseLocal(pnlFileComment.cbLocal.isSelected());
1095
1096         /*
1097          * ファイル - 変換動画
1098          */
1099         p.setOutputDir(fldOutputDir.getText());
1100         p.setOutputFileNamePattern(fldOutputFileNamePattern.getText());
1101         p.setOutputEnable(cbOutputEnable.isSelected());
1102         p.setOutputCommentOverlay(cbOutputCommentOverlay.isSelected());
1103         p.setOutputDisplayProgress(cbOutputDisplayProgress.isSelected());
1104
1105         /*
1106          * ファイル - 禁則文字
1107          */
1108         p.setReplaceFrom(fldReplaceFrom.getText());
1109         p.setReplaceTo(fldReplaceTo.getText());
1110
1111         /*
1112          * コメント
1113          */
1114         p.setCommentSizeAutosize(cbCommentSizeAuto.isSelected());
1115         p.setCommentSizeManual(fldCommentSizeManual.getText());
1116         p.setCommentMinDisabled(cbCommentMinDisable.isSelected());
1117         p.setCommentMinSizeAutosize(cbCommentMinSizeAuto.isSelected());
1118         p.setCommentMinSizeManual(fldCommentSizeManual.getText());
1119         p.setCommentDisplaySizeDefault(cbCommentDisplaySizeDefault.isSelected());
1120         p.setCommentDisplaySizeManual(fldCommentDisplaySizeManual.getText());
1121
1122         /**
1123          * コメント - 高度な設定
1124          */
1125         p.setFontPath(fldFontPath.getText());
1126         p.setFontIndex(fldFontIndex.getText());
1127         p.setFontShadow(cmbFontShadow.getSelectedIndex());
1128         p.setFontSizeArrangeDisable(cbFontSizeArrangeDisable.isSelected());
1129         p.setCommentOpaque(cbCommentOpaque.isSelected());
1130
1131         /*
1132          * ffmpeg - ファイルパス
1133          */
1134         p.setFfmpegPath(fldFfmpegPath.getText());
1135         p.setFfmpegDllPath(fldFfmpegDllPath.getText());
1136         p.setMediaInfoPath(fldMediaInfoPath.getText());
1137
1138         /*
1139          * ffmpeg - ffmpegパラメータ
1140          */
1141         final File fileFfmpegOption = pnlFfmpegParam.mdlFfmpegOption.getSelectedFile();
1142         p.setFfmpegOptionFile(fileFfmpegOption != null ? fileFfmpegOption.getPath() : null);
1143         p.setFfmpegExtension(pnlFfmpegParam.fldFfmpegOptionExtension.getText());
1144         p.setFfmpegMainOption(pnlFfmpegParam.fldFfmpegOptionMain.getText());
1145         p.setFfmpegInOption(pnlFfmpegParam.fldFfmpegOptionIn.getText());
1146         p.setFfmpegOutOption(pnlFfmpegParam.fldFfmpegOptionOut.getText());
1147         p.setFfmpegAvOption(pnlFfmpegParam.fldFfmpegOptionAv.getText());
1148         p.setFfmpegResizeEnable(pnlFfmpegParam.cbFfmpegOptionResize.isSelected());
1149         p.setFfmpegResizeWidth(pnlFfmpegParam.fldFfmpegOptionResizeWidth.getText());
1150         p.setFfmpegResizeHeight(pnlFfmpegParam.fldFfmpegOptionResizeHeight.getText());
1151         p.setFfmpegKeepAspect(pnlFfmpegParam.cbFfmpegOptionKeepAspect.isSelected());
1152
1153         /*
1154          * ffmpeg - その他
1155          */
1156         p.setFfmpegDisplayConverting(cbDisplayConverting.isSelected());
1157         p.setFfmpegDllDisabled(cbDllDisabled.isSelected());
1158
1159         /*
1160          * NG 設定
1161          */
1162         p.setNgWords(pnlNgWord.getAllElements());
1163         p.setNgIds(pnlNgId.getAllElements());
1164
1165         /*
1166          * 検索
1167          */
1168         p.setSearchVideoDirs(pnlSearchVideo.getAllElements());
1169         p.setSearchCommentDirs(pnlSearchComment.getAllElements());
1170
1171         /*
1172          * システム
1173          */
1174         p.setSystemDownloadThread(mdlSystemThreadDownload.getNumber().intValue());
1175         p.setSystemDownloadWait(mdlSystemWaitDownload.getNumber().intValue());
1176         p.setSystemConvertThread(mdlSystemThreadConvert.getNumber().intValue());
1177         p.setSystemTempDir(fldSystemTempDir.getText());
1178
1179         try {
1180             p.save();
1181         } catch (ConfigurationException ex) {
1182             logger.error("コンフィグファイル保存に失敗", ex);
1183         }
1184     }
1185 }
1186
1187 class DownloadLocationPanel extends JPanel {
1188
1189     private static final long serialVersionUID = 1L;
1190     final JTextField fldDir = new JTextField();
1191     final JTextField fldFileNamePattern = new JTextField();
1192     final JCheckBox cbLocal = new JCheckBox("local");
1193
1194     DownloadLocationPanel(){
1195         super();
1196
1197         final JLabel lblVideoDir = new JLabel("保存フォルダ");
1198         final JLabel lblVideoFileNamepattern = new JLabel("ファイル名規則");
1199
1200         final JButton btnDir = new JButton("...");
1201         btnDir.addActionListener(
1202                 new FileChooseActionListener(DownloadLocationPanel.this, JFileChooser.DIRECTORIES_ONLY, fldDir));
1203
1204         final GroupLayout gl = new GroupLayout(this);
1205         setLayout(gl);
1206         gl.setHorizontalGroup(
1207             gl.createParallelGroup(GroupLayout.Alignment.LEADING)
1208             .addGroup(GroupLayout.Alignment.TRAILING, gl.createSequentialGroup()
1209                 .addContainerGap()
1210                 .addGroup(gl.createParallelGroup(GroupLayout.Alignment.LEADING)
1211                     .addComponent(lblVideoFileNamepattern)
1212                     .addComponent(lblVideoDir))
1213                 .addPreferredGap(ComponentPlacement.RELATED)
1214                 .addGroup(gl.createParallelGroup(GroupLayout.Alignment.LEADING)
1215                     .addGroup(gl.createSequentialGroup()
1216                         .addComponent(fldDir, GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
1217                         .addPreferredGap(ComponentPlacement.RELATED)
1218                         .addComponent(btnDir))
1219                     .addGroup(GroupLayout.Alignment.TRAILING, gl.createSequentialGroup()
1220                         .addComponent(fldFileNamePattern, GroupLayout.PREFERRED_SIZE, 165, GroupLayout.PREFERRED_SIZE)
1221                         .addPreferredGap(ComponentPlacement.RELATED, 94, Short.MAX_VALUE)
1222                         .addComponent(cbLocal)))
1223                 .addContainerGap())
1224         );
1225         gl.setVerticalGroup(
1226             gl.createParallelGroup(GroupLayout.Alignment.LEADING)
1227             .addGroup(gl.createSequentialGroup()
1228                 .addGroup(gl.createParallelGroup(GroupLayout.Alignment.BASELINE)
1229                     .addComponent(lblVideoDir)
1230                     .addComponent(fldDir, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
1231                     .addComponent(btnDir))
1232                 .addPreferredGap(ComponentPlacement.RELATED)
1233                 .addGroup(gl.createParallelGroup(GroupLayout.Alignment.BASELINE)
1234                     .addComponent(lblVideoFileNamepattern)
1235                     .addComponent(fldFileNamePattern, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
1236                     .addComponent(cbLocal))
1237                 .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
1238         );
1239
1240     }
1241 }