OSDN Git Service

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