OSDN Git Service

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