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 FileChooseActionListener(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(cbCommentMinDisable)
360                     .addComponent(cbCommentMinSizeAuto)
361                     .addComponent(cbCommentDisplaySizeDefault))
362                 .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.LEADING)
363                     .addComponent(lblCommentSizeManual)
364                     .addComponent(lblCommentMinSizeManual)
365                     .addComponent(lblCommentDisplayMaxManual))
366                 .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.LEADING)
367                     .addComponent(fldCommentSizeManual, 48, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
368                     .addComponent(fldCommentMinSizeManual, 48, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
369                     .addComponent(fldCommentDisplaySizeManual, 48, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
370         );
371         gl_pnlCommentStandard.setVerticalGroup(
372             gl_pnlCommentStandard.createSequentialGroup()
373                 .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.BASELINE)
374                     .addComponent(lblCommentSize)
375                     .addComponent(cbCommentSizeAuto)
376                     .addComponent(lblCommentSizeManual)
377                     .addComponent(fldCommentSizeManual))
378                 .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.BASELINE)
379                     .addComponent(lblCommentMinSize)
380                     .addComponent(cbCommentMinDisable)
381                 )
382                 .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.BASELINE)
383                     .addComponent(cbCommentMinSizeAuto)
384                     .addComponent(lblCommentMinSizeManual)
385                     .addComponent(fldCommentMinSizeManual))
386                 .addGroup(gl_pnlCommentStandard.createParallelGroup(GroupLayout.Alignment.BASELINE)
387                     .addComponent(lblCommentDisplayMax)
388                     .addComponent(cbCommentDisplaySizeDefault)
389                     .addComponent(lblCommentDisplayMaxManual)
390                     .addComponent(fldCommentDisplaySizeManual))
391         );
392
393         pnlCommentAdvanced.setBorder(BorderFactory.createTitledBorder("高度な設定"));
394
395         lblFontPath.setText("フォントパス");
396
397         cbFontSizeArrangeDisable.setText("フォントサイズ調整を行わない");
398
399         cbCommentOpaque.setText("コメント透明化を行わない");
400
401         final JButton btnFontPath = new JButton("...");
402         btnFontPath.addActionListener(
403                 new FileChooseActionListener(ConfigDialog.this, JFileChooser.FILES_ONLY, fldFontPath));
404
405         lblFontIndex.setText("フォント番号");
406
407         lblFontShadow.setText("影の種類");
408         final ComboBoxModel<String> cbmFontShadow
409                 = new DefaultComboBoxModel<>(new String[]{"0:なし", "1:ニコニコ動画風", "2:右下", "3:囲い込み"});
410         cmbFontShadow.setModel(cbmFontShadow);
411
412         GroupLayout gl_pnlCommentAdvanced = new GroupLayout(pnlCommentAdvanced);
413         pnlCommentAdvanced.setLayout(gl_pnlCommentAdvanced);
414         gl_pnlCommentAdvanced.setHorizontalGroup(
415             gl_pnlCommentAdvanced.createParallelGroup(GroupLayout.Alignment.LEADING)
416             .addGroup(gl_pnlCommentAdvanced.createSequentialGroup()
417                 .addContainerGap()
418                 .addGroup(gl_pnlCommentAdvanced.createParallelGroup(GroupLayout.Alignment.LEADING)
419                     .addComponent(cbCommentOpaque)
420                     .addGroup(gl_pnlCommentAdvanced.createSequentialGroup()
421                         .addGroup(gl_pnlCommentAdvanced.createParallelGroup(GroupLayout.Alignment.LEADING)
422                             .addComponent(lblFontPath)
423                             .addComponent(lblFontIndex)
424                             .addComponent(lblFontShadow))
425                         .addGap(18, 18, 18)
426                         .addGroup(gl_pnlCommentAdvanced.createParallelGroup(GroupLayout.Alignment.LEADING)
427                             .addComponent(fldFontPath, GroupLayout.DEFAULT_SIZE, 275, Short.MAX_VALUE)
428                             .addGroup(gl_pnlCommentAdvanced.createParallelGroup(GroupLayout.Alignment.TRAILING, false)
429                                 .addComponent(cmbFontShadow, GroupLayout.Alignment.LEADING)
430                                 .addComponent(fldFontIndex, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 48, Short.MAX_VALUE)))
431                         .addPreferredGap(ComponentPlacement.RELATED)
432                         .addComponent(btnFontPath))
433                     .addComponent(cbFontSizeArrangeDisable))
434                 .addContainerGap())
435         );
436         gl_pnlCommentAdvanced.setVerticalGroup(
437             gl_pnlCommentAdvanced.createParallelGroup(GroupLayout.Alignment.LEADING)
438             .addGroup(gl_pnlCommentAdvanced.createSequentialGroup()
439                 .addGroup(gl_pnlCommentAdvanced.createParallelGroup(GroupLayout.Alignment.BASELINE)
440                     .addComponent(lblFontPath)
441                     .addComponent(fldFontPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
442                     .addComponent(btnFontPath))
443                 .addPreferredGap(ComponentPlacement.RELATED)
444                 .addGroup(gl_pnlCommentAdvanced.createParallelGroup(GroupLayout.Alignment.BASELINE)
445                     .addComponent(lblFontIndex)
446                     .addComponent(fldFontIndex, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
447                 .addPreferredGap(ComponentPlacement.RELATED)
448                 .addGroup(gl_pnlCommentAdvanced.createParallelGroup(GroupLayout.Alignment.BASELINE)
449                     .addComponent(lblFontShadow)
450                     .addComponent(cmbFontShadow, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
451                 .addPreferredGap(ComponentPlacement.RELATED)
452                 .addComponent(cbFontSizeArrangeDisable)
453                 .addPreferredGap(ComponentPlacement.RELATED)
454                 .addComponent(cbCommentOpaque)
455                 .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
456         );
457
458         GroupLayout gl_pnlComment = new GroupLayout(pnlComment);
459         pnlComment.setLayout(gl_pnlComment);
460         gl_pnlComment.setHorizontalGroup(
461             gl_pnlComment.createParallelGroup(GroupLayout.Alignment.LEADING)
462             .addGroup(GroupLayout.Alignment.TRAILING, gl_pnlComment.createSequentialGroup()
463                 .addContainerGap()
464                 .addGroup(gl_pnlComment.createParallelGroup(GroupLayout.Alignment.TRAILING)
465                     .addComponent(pnlCommentAdvanced, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
466                     .addComponent(pnlCommentStandard, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
467                 .addContainerGap())
468         );
469         gl_pnlComment.setVerticalGroup(
470             gl_pnlComment.createParallelGroup(GroupLayout.Alignment.LEADING)
471             .addGroup(gl_pnlComment.createSequentialGroup()
472                 .addContainerGap()
473                 .addComponent(pnlCommentStandard, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
474                 .addPreferredGap(ComponentPlacement.RELATED)
475                 .addComponent(pnlCommentAdvanced, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
476                 .addContainerGap(168, Short.MAX_VALUE))
477         );
478
479         tabbedPane.addTab("コメント", pnlComment);
480
481         pnlFfmpegBinPath.setBorder(BorderFactory.createTitledBorder("ファイルパス"));
482
483         lblFfmpegPath.setText("ffmpeg");
484
485         lblFfmpegDllPath.setText("拡張ライブラリ");
486
487         final JButton btnFfmpegPath = new JButton("...");
488         btnFfmpegPath.addActionListener(
489                 new FileChooseActionListener(ConfigDialog.this, JFileChooser.FILES_ONLY, fldFfmpegPath));
490
491         final JButton btnFfmpegDllPath = new JButton("...");
492         btnFfmpegDllPath.addActionListener(
493                 new FileChooseActionListener(ConfigDialog.this, JFileChooser.FILES_ONLY, fldFfmpegDllPath));
494
495         GroupLayout gl_jPanel10 = new GroupLayout(pnlFfmpegBinPath);
496         pnlFfmpegBinPath.setLayout(gl_jPanel10);
497         gl_jPanel10.setHorizontalGroup(
498             gl_jPanel10.createParallelGroup(GroupLayout.Alignment.LEADING)
499             .addGroup(gl_jPanel10.createSequentialGroup()
500                 .addContainerGap()
501                 .addGroup(gl_jPanel10.createParallelGroup(GroupLayout.Alignment.LEADING)
502                     .addComponent(lblFfmpegDllPath)
503                     .addComponent(lblFfmpegPath))
504                 .addPreferredGap(ComponentPlacement.RELATED)
505                 .addGroup(gl_jPanel10.createParallelGroup(GroupLayout.Alignment.LEADING)
506                     .addComponent(fldFfmpegDllPath, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE)
507                     .addComponent(fldFfmpegPath, GroupLayout.Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 280, Short.MAX_VALUE))
508                 .addPreferredGap(ComponentPlacement.RELATED)
509                 .addGroup(gl_jPanel10.createParallelGroup(GroupLayout.Alignment.LEADING)
510                     .addComponent(btnFfmpegPath, GroupLayout.Alignment.TRAILING)
511                     .addComponent(btnFfmpegDllPath, GroupLayout.Alignment.TRAILING))
512                 .addContainerGap())
513         );
514         gl_jPanel10.setVerticalGroup(
515             gl_jPanel10.createParallelGroup(GroupLayout.Alignment.LEADING)
516             .addGroup(gl_jPanel10.createSequentialGroup()
517                 .addGroup(gl_jPanel10.createParallelGroup(GroupLayout.Alignment.BASELINE)
518                     .addComponent(lblFfmpegPath)
519                     .addComponent(fldFfmpegPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
520                     .addComponent(btnFfmpegPath))
521                 .addPreferredGap(ComponentPlacement.RELATED)
522                 .addGroup(gl_jPanel10.createParallelGroup(GroupLayout.Alignment.BASELINE)
523                     .addComponent(lblFfmpegDllPath)
524                     .addComponent(fldFfmpegDllPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
525                     .addComponent(btnFfmpegDllPath))
526                 .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
527         );
528
529         pnlFfmpegParam.setBorder(BorderFactory.createTitledBorder("ffmpegパラメータ"));
530
531         // ffmpeg - その他
532         final JPanel pnlFffmpegEtc = new JPanel();
533         pnlFffmpegEtc.setBorder(BorderFactory.createTitledBorder("その他"));
534         final GroupLayout glFfmpegEtc = new GroupLayout(pnlFffmpegEtc);
535         glFfmpegEtc.setAutoCreateContainerGaps(true);
536         glFfmpegEtc.setAutoCreateGaps(true);
537         pnlFffmpegEtc.setLayout(glFfmpegEtc);
538
539         glFfmpegEtc.setHorizontalGroup(glFfmpegEtc.createParallelGroup()
540             .addComponent(cbDisplayConverting)
541             .addComponent(cbDllDisabled)
542         );
543         glFfmpegEtc.setVerticalGroup(glFfmpegEtc.createSequentialGroup()
544             .addComponent(cbDisplayConverting)
545             .addComponent(cbDllDisabled)
546         );
547
548         final GroupLayout glFfmpeg = new GroupLayout(pnlFfmpeg);
549         glFfmpeg.setAutoCreateContainerGaps(true);
550         pnlFfmpeg.setLayout(glFfmpeg);
551         glFfmpeg.setHorizontalGroup(glFfmpeg.createParallelGroup(GroupLayout.Alignment.LEADING)
552             .addComponent(pnlFfmpegBinPath)
553             .addComponent(pnlFfmpegParam)
554             .addComponent(pnlFffmpegEtc)
555         );
556         glFfmpeg.setVerticalGroup(glFfmpeg.createSequentialGroup()
557             .addComponent(pnlFfmpegBinPath, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
558             .addPreferredGap(ComponentPlacement.RELATED)
559             .addComponent(pnlFfmpegParam)
560             .addComponent(pnlFffmpegEtc)
561         );
562
563         tabbedPane.addTab("ffmpeg", pnlFfmpeg);
564
565         pnlNgWord.setBorder(BorderFactory.createTitledBorder("NGワード"));
566         pnlNgId.setBorder(BorderFactory.createTitledBorder("NGID"));
567
568         GroupLayout gl_pnlNgSetting = new GroupLayout(pnlNgSetting);
569         pnlNgSetting.setLayout(gl_pnlNgSetting);
570         gl_pnlNgSetting.setHorizontalGroup(
571             gl_pnlNgSetting.createParallelGroup(GroupLayout.Alignment.LEADING)
572             .addGroup(GroupLayout.Alignment.TRAILING, gl_pnlNgSetting.createSequentialGroup()
573                 .addContainerGap()
574                 .addGroup(gl_pnlNgSetting.createParallelGroup(GroupLayout.Alignment.TRAILING)
575                     .addComponent(pnlNgId, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
576                     .addComponent(pnlNgWord, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
577                 .addContainerGap())
578         );
579         gl_pnlNgSetting.setVerticalGroup(
580             gl_pnlNgSetting.createParallelGroup(GroupLayout.Alignment.LEADING)
581             .addGroup(gl_pnlNgSetting.createSequentialGroup()
582                 .addContainerGap()
583                 .addComponent(pnlNgWord, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
584                 .addPreferredGap(ComponentPlacement.RELATED)
585                 .addComponent(pnlNgId, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
586                 .addContainerGap())
587         );
588
589         tabbedPane.addTab("NG設定", pnlNgSetting);
590
591         pnlSearchVideo.setBorder(BorderFactory.createTitledBorder("動画検索対象フォルダ"));
592         pnlSearchComment.setBorder(BorderFactory.createTitledBorder("コメント検索対象フォルダ"));
593
594         final JLabel lblSearchNeedReboot = new JLabel(NEED_REBOOT);
595
596         GroupLayout gl_pnlSearch = new GroupLayout(pnlSearch);
597         pnlSearch.setLayout(gl_pnlSearch);
598         gl_pnlSearch.setHorizontalGroup(
599             gl_pnlSearch.createParallelGroup(GroupLayout.Alignment.LEADING)
600             .addGroup(GroupLayout.Alignment.TRAILING, gl_pnlSearch.createSequentialGroup()
601                 .addContainerGap()
602                 .addGroup(gl_pnlSearch.createParallelGroup(GroupLayout.Alignment.TRAILING)
603                     .addComponent(lblSearchNeedReboot, Alignment.CENTER)
604                     .addComponent(pnlSearchComment, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
605                     .addComponent(pnlSearchVideo, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
606                 .addContainerGap())
607         );
608         gl_pnlSearch.setVerticalGroup(
609             gl_pnlSearch.createParallelGroup(GroupLayout.Alignment.LEADING)
610             .addGroup(gl_pnlSearch.createSequentialGroup()
611                 .addContainerGap()
612                 .addComponent(lblSearchNeedReboot)
613                 .addComponent(pnlSearchVideo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
614                 .addPreferredGap(ComponentPlacement.RELATED)
615                 .addComponent(pnlSearchComment, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
616                 .addContainerGap()
617             )
618         );
619
620         tabbedPane.addTab("検索", pnlSearch);
621
622         final JButton btnOk = new JButton("保存");
623         btnOk.addActionListener(new ActionListener() {
624
625             @Override
626             public void actionPerformed(ActionEvent e) {
627                 saveConfig();
628                 dispose();
629             }
630         });
631         final JButton btnCancel = new JButton("取消");
632         btnCancel.addActionListener(new ActionListener() {
633
634             @Override
635             public void actionPerformed(ActionEvent e) {
636                 dispose();
637             }
638         });
639         final JPanel pnlButton = new JPanel();
640
641         final GroupLayout glButton = new GroupLayout(pnlButton);
642         pnlButton.setLayout(glButton);
643         glButton.setHorizontalGroup(glButton.createSequentialGroup()
644             .addPreferredGap(ComponentPlacement.UNRELATED, PREFERRED_SIZE, Short.MAX_VALUE)
645             .addComponent(btnOk)
646             .addPreferredGap(ComponentPlacement.UNRELATED)
647             .addComponent(btnCancel)
648             .addContainerGap()
649         );
650         glButton.setVerticalGroup(glButton.createSequentialGroup()
651             .addGroup(glButton.createParallelGroup(Alignment.BASELINE)
652                 .addComponent(btnOk)
653                 .addComponent(btnCancel)
654             )
655         );
656
657         GroupLayout layout = new GroupLayout(getContentPane());
658         layout.setAutoCreateContainerGaps(true);
659         getContentPane().setLayout(layout);
660         layout.setHorizontalGroup(
661             layout.createParallelGroup(GroupLayout.Alignment.LEADING)
662             .addComponent(tabbedPane, GroupLayout.DEFAULT_SIZE, 460, Short.MAX_VALUE)
663             .addComponent(pnlButton)
664         );
665         layout.setVerticalGroup(
666             layout.createSequentialGroup()
667                 .addComponent(tabbedPane,GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE, Short.MAX_VALUE)
668                 .addComponent(pnlButton)
669         );
670
671         final JLabel lblSystemThreadDownload = new JLabel("ダウンロードスレッド数");
672         final JLabel lblSystemWaitDownload = new JLabel("ダウンロード開始最小間隔(秒)");
673         final JLabel lblSystemThreadConvert = new JLabel("変換スレッド数");
674         final JLabel lblSystemTempDir = new JLabel("作業フォルダ");
675         final JButton btnSystemTempDir = new JButton("...");
676         btnSystemTempDir.addActionListener(
677                 new FileChooseActionListener(ConfigDialog.this, JFileChooser.DIRECTORIES_ONLY, fldSystemTempDir));
678
679         mdlSystemThreadDownload.setMinimum(1);
680         final JSpinner fldSystemThreadDownload = new JSpinner(mdlSystemThreadDownload);
681         mdlSystemWaitDownload.setMinimum(0);
682         final JSpinner fldSystemWaitDownload = new JSpinner(mdlSystemWaitDownload);
683         mdlSystemThreadConvert.setMinimum(1);
684         final JSpinner fldSystemThreadConvert = new JSpinner(mdlSystemThreadConvert);
685
686         final JPanel pnlSystemGeneral = new JPanel();
687         pnlSystemGeneral.setBorder(BorderFactory.createTitledBorder("システム"));
688         final GroupLayout glSystemGenegal = new GroupLayout(pnlSystemGeneral);
689         glSystemGenegal.setAutoCreateGaps(true);
690         glSystemGenegal.setAutoCreateContainerGaps(true);
691         pnlSystemGeneral.setLayout(glSystemGenegal);
692
693         glSystemGenegal.setHorizontalGroup(glSystemGenegal.createParallelGroup()
694             .addGroup(glSystemGenegal.createSequentialGroup()
695                 .addGroup(glSystemGenegal.createParallelGroup()
696                     .addComponent(lblSystemThreadDownload)
697                     .addComponent(lblSystemWaitDownload)
698                     .addComponent(lblSystemThreadConvert))
699                 .addGroup(glSystemGenegal.createParallelGroup()
700                     .addComponent(fldSystemThreadDownload, PREFERRED_SIZE, 50, PREFERRED_SIZE)
701                     .addComponent(fldSystemWaitDownload, PREFERRED_SIZE, 55, PREFERRED_SIZE)
702                     .addComponent(fldSystemThreadConvert, PREFERRED_SIZE, 50, PREFERRED_SIZE)
703                 )
704             )
705             .addGroup(glSystemGenegal.createSequentialGroup()
706                 .addComponent(lblSystemTempDir)
707                 .addComponent(fldSystemTempDir, DEFAULT_SIZE, 400, Short.MAX_VALUE)
708                 .addComponent(btnSystemTempDir)
709                 )
710             );
711
712         glSystemGenegal.setVerticalGroup(glSystemGenegal.createSequentialGroup()
713             .addGroup(glSystemGenegal.createParallelGroup(Alignment.BASELINE)
714                 .addComponent(lblSystemThreadDownload)
715                 .addComponent(fldSystemThreadDownload, DEFAULT_SIZE, PREFERRED_SIZE, PREFERRED_SIZE))
716             .addGroup(glSystemGenegal.createParallelGroup(Alignment.BASELINE)
717                 .addComponent(lblSystemWaitDownload)
718                 .addComponent(fldSystemWaitDownload, DEFAULT_SIZE, PREFERRED_SIZE, PREFERRED_SIZE))
719             .addGroup(glSystemGenegal.createParallelGroup(Alignment.BASELINE)
720                 .addComponent(lblSystemThreadConvert)
721                 .addComponent(fldSystemThreadConvert, DEFAULT_SIZE, PREFERRED_SIZE, PREFERRED_SIZE))
722             .addGroup(glSystemGenegal.createParallelGroup(Alignment.BASELINE)
723                 .addComponent(lblSystemTempDir)
724                 .addComponent(fldSystemTempDir, DEFAULT_SIZE, PREFERRED_SIZE, PREFERRED_SIZE)
725                 .addComponent(btnSystemTempDir)
726             )
727         );
728
729         final JLabel lblSystemNeedReboot = new JLabel("設定を有効にするにはいんきゅばすの再起動が必要です");
730
731         final JPanel pnlSystem = new JPanel();
732         pnlSystem.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
733         final GroupLayout glSystem = new GroupLayout(pnlSystem);
734         glSystem.setAutoCreateGaps(true);
735         glSystem.setAutoCreateContainerGaps(true);
736         pnlSystem.setLayout(glSystem);
737
738         glSystem.setHorizontalGroup(glSystem.createParallelGroup()
739             .addComponent(lblSystemNeedReboot, Alignment.CENTER)
740             .addComponent(pnlSystemGeneral));
741
742         glSystem.setVerticalGroup(glSystem.createSequentialGroup()
743             .addComponent(lblSystemNeedReboot)
744             .addComponent(pnlSystemGeneral));
745
746         tabbedPane.add("システム", pnlSystem);
747
748         pack();
749         setMinimumSize(getSize());
750         loadConfig();
751     }
752
753     /**
754      * @param args the command line arguments
755      */
756     public static void main(String args[]) {
757         /* Set the Nimbus look and feel */
758         /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
759          * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
760          */
761         try {
762             for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
763                 if ("Nimbus".equals(info.getName())) {
764                     UIManager.setLookAndFeel(info.getClassName());
765                     break;
766                 }
767             }
768         } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
769             java.util.logging.Logger.getLogger(ConfigDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
770         }
771
772         /* Create and display the form */
773         java.awt.EventQueue.invokeLater(new Runnable() {
774
775             @Override
776             public void run() {
777                 new ConfigDialog().setVisible(true);
778             }
779         });
780     }
781     // Variables declaration - do not modify//GEN-BEGIN:variables
782
783     // ネットワーク
784     // ネットワーク - アカウント
785     private final JTextField fldMail;
786     private final JPasswordField fldPassword = new JPasswordField();
787     // ネットワーク - プロキシ
788     private final JCheckBox cbProxyUse;
789     private final JTextField fldProxyHost = new JTextField();
790     private final NumberFormattedTextField fldProxyPort = new NumberFormattedTextField();
791     // ファイル
792     // ファイル - 動画
793     private final DownloadLocationPanel pnlFileVideo = new DownloadLocationPanel();
794     // ファイル - コメント
795     private final DownloadLocationPanel pnlFileComment = new DownloadLocationPanel();
796     // ファイル - 変換動画
797     private final JTextField fldOutputDir;
798     private final JTextField fldOutputFileNamePattern;
799     private final JButton btnOutputDir = new JButton("...");
800     private final JCheckBox cbOutputEnable;
801     private final JCheckBox cbOutputCommentOverlay;
802     private final JCheckBox cbOutputDisplayProgress;
803     // ファイル - 禁則文字
804     private final JTextField fldReplaceFrom = new JTextField();
805     private final JTextField fldReplaceTo = new JTextField();
806     // コメント
807     // コメント
808     private final JCheckBox cbCommentSizeAuto = new JCheckBox("自動調整");
809     private final NumberFormattedTextField fldCommentSizeManual = new NumberFormattedTextField();
810     private final JCheckBox cbCommentMinDisable = new JCheckBox("少コメ");
811     private final JCheckBox cbCommentMinSizeAuto = new JCheckBox("自動調整");
812     private final NumberFormattedTextField fldCommentMinSizeManual = new NumberFormattedTextField();
813     private final JCheckBox cbCommentDisplaySizeDefault = new JCheckBox("標準(30)");
814     private final NumberFormattedTextField fldCommentDisplaySizeManual = new NumberFormattedTextField();
815     // コメント - 高度な設定
816     private final JTextField fldFontPath;
817     private final JTextField fldFontIndex;
818     private final JComboBox<String> cmbFontShadow = new JComboBox<>();
819     private final JCheckBox cbFontSizeArrangeDisable;
820     private final JCheckBox cbCommentOpaque;
821     // ffmpeg
822     // ffmpeg - ファイルパス
823     private final JTextField fldFfmpegPath;
824     private final JTextField fldFfmpegDllPath;
825     // ffmpeg - ffmpegパラメータ
826     private final FfmpegParamPanel pnlFfmpegParam = new FfmpegParamPanel();
827     // ffmpeg - その他
828     private final JCheckBox cbDisplayConverting = new JCheckBox("変換中動画表示");
829     private final JCheckBox cbDllDisabled = new JCheckBox("拡張DLL無効化(デバッグ用)");
830     // NG設定
831     // NG設定 - NGワード
832     private final NgRegisterPanel pnlNgWord = new NgRegisterPanel();
833     // NG設定 - NGID
834     private final NgRegisterPanel pnlNgId = new NgRegisterPanel();
835     // 検索
836     // 検索 - 動画検索対象フォルダ
837     private final DirectoryRegisterPanel pnlSearchVideo = new DirectoryRegisterPanel();
838     // 検索 - コメント検索対象フォルダ
839     private final DirectoryRegisterPanel pnlSearchComment = new DirectoryRegisterPanel();
840     // システム
841     private final SpinnerNumberModel mdlSystemThreadDownload = new SpinnerNumberModel();
842     private final SpinnerNumberModel mdlSystemWaitDownload = new SpinnerNumberModel();
843     private final SpinnerNumberModel mdlSystemThreadConvert = new SpinnerNumberModel();
844     private final JTextField fldSystemTempDir = new JTextField();
845
846
847     // End of variables declaration//GEN-END:variables
848
849     private void loadConfig() {
850         final Config p = Config.INSTANCE;
851
852         /*
853          * ネットワーク - アカウント
854          */
855         fldMail.setText(p.getId());
856         fldPassword.setText(p.getPassword());
857
858         /*
859          * ネットワーク - プロキシ
860          */
861         cbProxyUse.setSelected(p.getProxyUse());
862         fldProxyHost.setText(p.getProxyHost());
863         fldProxyPort.setText(p.getProxyPort());
864
865         /*
866          * ファイル - 動画
867          */
868         pnlFileVideo.fldDir.setText(p.getVideoDir());
869         pnlFileVideo.fldFileNamePattern.setText(p.getVideoFileNamePattern());
870         pnlFileVideo.cbLocal.setSelected(p.getVideoUseLocal());
871
872         /*
873          * ファイル - コメント
874          */
875         pnlFileComment.fldDir.setText(p.getCommentDir());
876         pnlFileComment.fldFileNamePattern.setText(p.getCommentFileNamePattern());
877         pnlFileComment.cbLocal.setSelected(p.getCommentUseLocal());
878
879         /*
880          * ファイル - 変換動画
881          */
882         fldOutputDir.setText(p.getOutputDir());
883         fldOutputFileNamePattern.setText(p.getOutputFileNamePattern());
884         cbOutputEnable.setSelected(p.getOutputEnable());
885         cbOutputCommentOverlay.setSelected(p.getOutputCommentOverlay());
886         cbOutputDisplayProgress.setSelected(p.getOutputDisplayProgress());
887
888         /*
889          * ファイル - 禁則文字
890          */
891         fldReplaceFrom.setText(p.getReplaceFrom());
892         fldReplaceTo.setText(p.getReplaceTo());
893
894         /**
895          * コメント
896          */
897         cbCommentSizeAuto.setSelected(p.getCommentSizeAutosize());
898         fldCommentSizeManual.setText(p.getCommentSizeManual());
899         cbCommentMinDisable.setSelected(p.getCommentMinDisabled());
900         cbCommentMinSizeAuto.setSelected(p.getCommentMinSizeAutosize());
901         fldCommentSizeManual.setText(p.getCommentMinSizeManual());
902         cbCommentDisplaySizeDefault.setSelected(p.getCommentDisplaySizeDefault());
903         fldCommentDisplaySizeManual.setText(p.getCommentDisplaySizeManual());
904
905         /**
906          * コメント - 高度な設定
907          */
908         fldFontPath.setText(p.getFontPath());
909         fldFontIndex.setText(p.getFontIndex());
910         cmbFontShadow.setSelectedIndex(p.getFontShadow());
911         cbFontSizeArrangeDisable.setSelected(p.getFontSizeArrangeDisable());
912         cbCommentOpaque.setSelected(p.getCommentOpaque());
913
914         /*
915          * ffmpeg - ファイルパス
916          */
917         fldFfmpegPath.setText(p.getFfmpegPath());
918         fldFfmpegDllPath.setText(p.getFfmpegDllPath());
919
920         /*
921          * ffmpeg - ffmpegパラメータ
922          */
923         pnlFfmpegParam.init(p);
924
925         /*
926          * ffmpeg - その他
927          */
928         cbDisplayConverting.setSelected(p.getFfmpegDisplayConverting());
929         cbDllDisabled.setSelected(p.getFfmpegDllDisabled());
930
931         /*
932          * NG 設定
933          */
934         final List<String> ngWords = p.getNgWords();
935         pnlNgWord.init(ngWords);
936         final List<String> ngIds = p.getNgIds();
937         pnlNgId.init(ngIds);
938
939         /*
940          * 検索
941          */
942         pnlSearchVideo.init(p.getSearchVideoDirs());
943         pnlSearchComment.init(p.getSearchCommentDirs());
944
945         /*
946          * システム
947          */
948         mdlSystemThreadDownload.setValue(p.getSystemDownloadThread());
949         mdlSystemWaitDownload.setValue(p.getSystemDownloadWait());
950         mdlSystemThreadConvert.setValue(p.getSystemConvertThread());
951         fldSystemTempDir.setText(p.getSystemTempDir());
952     }
953
954     private void saveConfig() {
955         final Config p = Config.INSTANCE;
956
957         /*
958          * ネットワーク - アカウント
959          */
960
961         p.setId(fldMail.getText());
962         p.setPassword(String.valueOf(fldPassword.getPassword()));
963
964         /*
965          * ネットワーク - プロキシ
966          */
967         p.setProxyUse(cbProxyUse.isSelected());
968         p.setProxyHost(fldProxyHost.getText());
969         p.setProxyPort(fldProxyPort.getText());
970
971         /*
972          * ファイル - 動画
973          */
974         p.setVideoDir(pnlFileVideo.fldDir.getText());
975         p.setVideoFileNamePattern(pnlFileVideo.fldFileNamePattern.getText());
976         p.setVideoUseLocal(pnlFileVideo.cbLocal.isSelected());
977
978         /*
979          * ファイル - コメント
980          */
981         p.setCommentDir(pnlFileComment.fldDir.getText());
982         p.setCommentFileNamePattern(pnlFileComment.fldFileNamePattern.getText());
983         p.setCommentUseLocal(pnlFileComment.cbLocal.isSelected());
984
985         /*
986          * ファイル - 変換動画
987          */
988         p.setOutputDir(fldOutputDir.getText());
989         p.setOutputFileNamePattern(fldOutputFileNamePattern.getText());
990         p.setOutputEnable(cbOutputEnable.isSelected());
991         p.setOutputCommentOverlay(cbOutputCommentOverlay.isSelected());
992         p.setOutputDisplayProgress(cbOutputDisplayProgress.isSelected());
993
994         /*
995          * ファイル - 禁則文字
996          */
997         p.setReplaceFrom(fldReplaceFrom.getText());
998         p.setReplaceTo(fldReplaceTo.getText());
999
1000         /*
1001          * コメント
1002          */
1003         p.setCommentSizeAutosize(cbCommentSizeAuto.isSelected());
1004         p.setCommentSizeManual(fldCommentSizeManual.getText());
1005         p.setCommentMinDisabled(cbCommentMinDisable.isSelected());
1006         p.setCommentMinSizeAutosize(cbCommentMinSizeAuto.isSelected());
1007         p.setCommentMinSizeManual(fldCommentSizeManual.getText());
1008         p.setCommentDisplaySizeDefault(cbCommentDisplaySizeDefault.isSelected());
1009         p.setCommentDisplaySizeManual(fldCommentDisplaySizeManual.getText());
1010
1011         /**
1012          * コメント - 高度な設定
1013          */
1014         p.setFontPath(fldFontPath.getText());
1015         p.setFontIndex(fldFontIndex.getText());
1016         p.setFontShadow(cmbFontShadow.getSelectedIndex());
1017         p.setFontSizeArrangeDisable(cbFontSizeArrangeDisable.isSelected());
1018         p.setCommentOpaque(cbCommentOpaque.isSelected());
1019
1020         /*
1021          * ffmpeg - ファイルパス
1022          */
1023         p.setFfmpegPath(fldFfmpegPath.getText());
1024         p.setFfmpegDllPath(fldFfmpegDllPath.getText());
1025
1026         /*
1027          * ffmpeg - ffmpegパラメータ
1028          */
1029         final File fileFfmpegOption = pnlFfmpegParam.mdlFfmpegOption.getSelectedFile();
1030         p.setFfmpegOptionFile(fileFfmpegOption != null ? fileFfmpegOption.getPath() : null);
1031         p.setFfmpegExtension(pnlFfmpegParam.fldFfmpegOptionExtension.getText());
1032         p.setFfmpegMainOption(pnlFfmpegParam.fldFfmpegOptionMain.getText());
1033         p.setFfmpegInOption(pnlFfmpegParam.fldFfmpegOptionIn.getText());
1034         p.setFfmpegOutOption(pnlFfmpegParam.fldFfmpegOptionOut.getText());
1035         p.setFfmpegAvOption(pnlFfmpegParam.fldFfmpegOptionAv.getText());
1036         p.setFfmpegResizeEnable(pnlFfmpegParam.cbFfmpegOptionResize.isSelected());
1037         p.setFfmpegResizeWidth(pnlFfmpegParam.fldFfmpegOptionResizeWidth.getText());
1038         p.setFfmpegResizeHeight(pnlFfmpegParam.fldFfmpegOptionResizeHeight.getText());
1039         p.setFfmpegKeepAspect(pnlFfmpegParam.cbFfmpegOptionKeepAspect.isSelected());
1040
1041         /*
1042          * ffmpeg - その他
1043          */
1044         p.setFfmpegDisplayConverting(cbDisplayConverting.isSelected());
1045         p.setFfmpegDllDisabled(cbDllDisabled.isSelected());
1046
1047         /*
1048          * NG 設定
1049          */
1050         p.setNgWords(pnlNgWord.getAllElements());
1051         p.setNgIds(pnlNgId.getAllElements());
1052
1053         /*
1054          * 検索
1055          */
1056         p.setSearchVideoDirs(pnlSearchVideo.getAllElements());
1057         p.setSearchCommentDirs(pnlSearchComment.getAllElements());
1058
1059         /*
1060          * システム
1061          */
1062         p.setSystemDownloadThread(mdlSystemThreadDownload.getNumber().intValue());
1063         p.setSystemDownloadWait(mdlSystemWaitDownload.getNumber().intValue());
1064         p.setSystemConvertThread(mdlSystemThreadConvert.getNumber().intValue());
1065         p.setSystemTempDir(fldSystemTempDir.getText());
1066
1067         try {
1068             p.save();
1069         } catch (ConfigurationException ex) {
1070             logger.log(Level.SEVERE, "コンフィグファイル保存に失敗", ex);
1071         }
1072     }
1073 }
1074
1075 class DownloadLocationPanel extends JPanel {
1076     final JTextField fldDir = new JTextField();
1077     final JTextField fldFileNamePattern = new JTextField();
1078     final JCheckBox cbLocal = new JCheckBox("local");
1079
1080     DownloadLocationPanel(){
1081         super();
1082
1083         final JLabel lblVideoDir = new JLabel("保存フォルダ");
1084         final JLabel lblVideoFileNamepattern = new JLabel("ファイル名規則");
1085
1086         final JButton btnDir = new JButton("...");
1087         btnDir.addActionListener(
1088                 new FileChooseActionListener(DownloadLocationPanel.this, JFileChooser.DIRECTORIES_ONLY, fldDir));
1089
1090         final GroupLayout gl = new GroupLayout(this);
1091         setLayout(gl);
1092         gl.setHorizontalGroup(
1093             gl.createParallelGroup(GroupLayout.Alignment.LEADING)
1094             .addGroup(GroupLayout.Alignment.TRAILING, gl.createSequentialGroup()
1095                 .addContainerGap()
1096                 .addGroup(gl.createParallelGroup(GroupLayout.Alignment.LEADING)
1097                     .addComponent(lblVideoFileNamepattern)
1098                     .addComponent(lblVideoDir))
1099                 .addPreferredGap(ComponentPlacement.RELATED)
1100                 .addGroup(gl.createParallelGroup(GroupLayout.Alignment.LEADING)
1101                     .addGroup(gl.createSequentialGroup()
1102                         .addComponent(fldDir, GroupLayout.DEFAULT_SIZE, 262, Short.MAX_VALUE)
1103                         .addPreferredGap(ComponentPlacement.RELATED)
1104                         .addComponent(btnDir))
1105                     .addGroup(GroupLayout.Alignment.TRAILING, gl.createSequentialGroup()
1106                         .addComponent(fldFileNamePattern, GroupLayout.PREFERRED_SIZE, 165, GroupLayout.PREFERRED_SIZE)
1107                         .addPreferredGap(ComponentPlacement.RELATED, 94, Short.MAX_VALUE)
1108                         .addComponent(cbLocal)))
1109                 .addContainerGap())
1110         );
1111         gl.setVerticalGroup(
1112             gl.createParallelGroup(GroupLayout.Alignment.LEADING)
1113             .addGroup(gl.createSequentialGroup()
1114                 .addGroup(gl.createParallelGroup(GroupLayout.Alignment.BASELINE)
1115                     .addComponent(lblVideoDir)
1116                     .addComponent(fldDir, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
1117                     .addComponent(btnDir))
1118                 .addPreferredGap(ComponentPlacement.RELATED)
1119                 .addGroup(gl.createParallelGroup(GroupLayout.Alignment.BASELINE)
1120                     .addComponent(lblVideoFileNamepattern)
1121                     .addComponent(fldFileNamePattern, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
1122                     .addComponent(cbLocal))
1123                 .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
1124         );
1125
1126     }
1127 }