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