OSDN Git Service

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