4 * Created on 2011/05/28, 18:14:51
6 package yukihane.inqubus.gui;
9 import java.awt.ItemSelectable;
10 import java.awt.Toolkit;
11 import java.awt.datatransfer.DataFlavor;
12 import java.awt.datatransfer.Transferable;
13 import java.awt.event.ActionEvent;
14 import java.awt.event.ActionListener;
15 import java.awt.event.ItemEvent;
16 import java.awt.event.ItemListener;
17 import java.awt.event.KeyEvent;
19 import java.io.FilenameFilter;
20 import java.io.IOException;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.List;
25 import java.util.logging.Level;
26 import java.util.logging.Logger;
27 import java.util.regex.Matcher;
28 import java.util.regex.Pattern;
29 import javax.swing.BorderFactory;
30 import javax.swing.DropMode;
31 import javax.swing.GroupLayout;
32 import javax.swing.GroupLayout.Alignment;
33 import javax.swing.JButton;
34 import javax.swing.JCheckBox;
35 import javax.swing.JFrame;
36 import javax.swing.JLabel;
37 import javax.swing.JMenu;
38 import javax.swing.JMenuBar;
39 import javax.swing.JMenuItem;
40 import javax.swing.JPanel;
41 import javax.swing.JScrollPane;
42 import javax.swing.JTable;
43 import javax.swing.JTextField;
44 import javax.swing.KeyStroke;
45 import javax.swing.LayoutStyle.ComponentPlacement;
46 import javax.swing.TransferHandler;
47 import javax.swing.WindowConstants;
48 import org.apache.commons.lang.StringUtils;
49 import saccubus.MainFrame_AboutBox;
50 import saccubus.util.WayBackTimeParser;
51 import saccubus.worker.Download;
52 import saccubus.worker.profile.CommentProfile;
53 import saccubus.worker.profile.DownloadProfile;
54 import saccubus.worker.profile.GeneralProfile;
55 import saccubus.worker.profile.LoginProfile;
56 import saccubus.worker.profile.ProxyProfile;
57 import saccubus.worker.profile.VideoProfile;
59 import yukihane.inqubus.Config;
60 import yukihane.inqubus.model.Target;
61 import yukihane.inqubus.model.TargetsTableModel;
67 public class MainFrame extends JFrame {
69 private static final long serialVersionUID = 1L;
70 private static final Logger logger = Logger.getLogger(MainFrame.class.getName());
71 private static final String ID_FIELD_TOOLTIP = "動画のIDまたはURLを入力します。";
72 private static final String FILE_LOCALBUTTON_TOOLTIP
73 = "ダウンロードする場合はチェックを外します。ローカルファイルを使用する場合はチェックを入れます。";
74 private static final String FILE_INPUTFIELD_TOOLTIP
75 = "ダウンロードする場合はファイル命名規則を入力します。"
76 + "ローカルファイルを使用する場合はパスを含むファイル名を入力します。";
77 private static final String FILE_OUTPUTFIELD_TOOLTIP
79 private final TargetsTableModel targetModel = new TargetsTableModel();
81 /** Creates new form MainFrame */
83 final URL url = MainFrame_AboutBox.class.getResource("icon.png");
84 final Image icon1 = Toolkit.getDefaultToolkit().createImage(url);
85 final URL url32 = MainFrame_AboutBox.class.getResource("icon32.png");
86 final Image icon2 = Toolkit.getDefaultToolkit().createImage(url32);
87 final List<Image> images = new ArrayList<Image>(2);
90 setIconImages(images);
92 final JPanel pnlMain = new JPanel();
93 final JScrollPane scrDisplay = new JScrollPane();
94 tblDisplay = new JTable();
95 final JPanel pnlButton = new JPanel();
96 btnStart = new JButton();
97 btnStop = new JButton();
98 btnDeselect = new JButton();
99 final JPanel pnlInputMain = new JPanel();
100 final JLabel lblId = new JLabel();
101 fldId = new JTextField();
102 fldId.setToolTipText(ID_FIELD_TOOLTIP);
103 final JLabel lblVideo = new JLabel();
104 cbVideoLocal = new JCheckBox();
105 cbVideoLocal.setToolTipText(FILE_LOCALBUTTON_TOOLTIP);
106 fldVideo = new JTextField();
107 fldVideo.setToolTipText(FILE_INPUTFIELD_TOOLTIP);
108 btnVideo = new JButton();
109 final JLabel lblComment = new JLabel();
110 cbCommentLocal = new JCheckBox();
111 cbCommentLocal.setToolTipText(FILE_LOCALBUTTON_TOOLTIP);
112 cbCommentLocal.addItemListener(new ItemListener() {
115 public void itemStateChanged(ItemEvent e) {
116 final boolean selected = (e.getStateChange() == ItemEvent.SELECTED);
117 cbBackLogReduce.setEnabled(!selected);
118 cbBackLog.setEnabled(!selected);
120 cbBackLog.setSelected(false);
124 fldComment = new JTextField();
125 fldComment.setToolTipText(FILE_INPUTFIELD_TOOLTIP);
126 btnComment = new JButton();
127 final JLabel lblOutput = new JLabel();
128 cbOutputEnable = new JCheckBox();
129 fldOutput = new JTextField();
130 fldOutput.setToolTipText(FILE_OUTPUTFIELD_TOOLTIP);
132 setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
134 btnApply.addActionListener(new ApplyActionListener());
136 pnlMain.setBorder(BorderFactory.createEtchedBorder());
138 tblDisplay.setModel(targetModel);
139 tblDisplay.setDropMode(DropMode.INSERT_ROWS);
140 scrDisplay.setViewportView(tblDisplay);
142 pnlButton.setBorder(BorderFactory.createEtchedBorder());
144 btnStart.setText("開始");
146 btnStop.setText("停止");
148 btnDeselect.setText("選択解除");
150 GroupLayout gl_pnlButton = new GroupLayout(pnlButton);
151 pnlButton.setLayout(gl_pnlButton);
152 gl_pnlButton.setHorizontalGroup(
153 gl_pnlButton.createParallelGroup(Alignment.LEADING)
154 .addGroup(gl_pnlButton.createSequentialGroup()
156 .addComponent(btnStart)
157 .addPreferredGap(ComponentPlacement.RELATED)
158 .addComponent(btnStop)
159 .addPreferredGap(ComponentPlacement.RELATED, 250, Short.MAX_VALUE)
160 .addComponent(btnDeselect)
163 gl_pnlButton.setVerticalGroup(
164 gl_pnlButton.createParallelGroup(Alignment.LEADING)
165 .addGroup(gl_pnlButton.createSequentialGroup()
167 .addGroup(gl_pnlButton.createParallelGroup(Alignment.BASELINE)
168 .addComponent(btnStart)
169 .addComponent(btnStop)
170 .addComponent(btnDeselect))
171 .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
174 pnlInputMain.setBorder(BorderFactory.createEtchedBorder());
178 fldId.addFocusListener(new java.awt.event.FocusAdapter() {
180 public void focusLost(java.awt.event.FocusEvent evt) {
181 idFieldFocusLost(evt);
185 lblVideo.setText("動画");
187 cbVideoLocal.setText("local");
188 cbVideoLocal.addItemListener(new java.awt.event.ItemListener() {
190 public void itemStateChanged(java.awt.event.ItemEvent evt) {
191 useMovieLocalCheckBoxItemStateChanged(evt);
195 btnVideo.setText("...");
197 lblComment.setText("コメント");
199 cbCommentLocal.setText("local");
200 cbCommentLocal.addItemListener(new java.awt.event.ItemListener() {
202 public void itemStateChanged(java.awt.event.ItemEvent evt) {
203 useMovieLocalCheckBoxItemStateChanged(evt);
207 btnComment.setText("...");
209 lblOutput.setText("出力");
211 cbOutputEnable.setText("変換");
212 cbOutputEnable.addItemListener(new java.awt.event.ItemListener() {
214 public void itemStateChanged(java.awt.event.ItemEvent evt) {
215 outputConvertCheckBoxItemStateChanged(evt);
220 GroupLayout gl_pnlInputMain = new GroupLayout(pnlInputMain);
221 pnlInputMain.setLayout(gl_pnlInputMain);
222 gl_pnlInputMain.setHorizontalGroup(
223 gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
224 .addGroup(gl_pnlInputMain.createSequentialGroup()
226 .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
227 .addGroup(gl_pnlInputMain.createSequentialGroup()
228 .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
229 .addComponent(lblComment)
230 .addComponent(lblVideo)
232 .addComponent(lblOutput))
233 .addPreferredGap(ComponentPlacement.RELATED)
234 .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
235 .addGroup(gl_pnlInputMain.createSequentialGroup()
236 .addComponent(cbVideoLocal)
237 .addPreferredGap(ComponentPlacement.RELATED)
238 .addComponent(fldVideo, GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)
239 .addPreferredGap(ComponentPlacement.RELATED)
240 .addComponent(btnVideo))
241 .addGroup(gl_pnlInputMain.createSequentialGroup()
242 .addComponent(fldId, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
243 .addPreferredGap(ComponentPlacement.UNRELATED)
244 .addComponent(cbBackLogReduce)
245 .addComponent(cbBackLog)
246 .addComponent(fldBackLog, GroupLayout.PREFERRED_SIZE, 150, GroupLayout.PREFERRED_SIZE)
248 .addGroup(Alignment.TRAILING, gl_pnlInputMain.createSequentialGroup()
249 .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.TRAILING)
250 .addGroup(Alignment.LEADING, gl_pnlInputMain.createSequentialGroup()
251 .addComponent(cbOutputEnable)
252 .addPreferredGap(ComponentPlacement.RELATED)
253 .addComponent(fldOutput, GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE))
254 .addGroup(gl_pnlInputMain.createSequentialGroup()
255 .addComponent(cbCommentLocal)
256 .addPreferredGap(ComponentPlacement.RELATED)
257 .addComponent(fldComment, GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)))
258 .addPreferredGap(ComponentPlacement.RELATED)
259 .addComponent(btnComment))))
260 .addComponent(btnApply, Alignment.TRAILING))
263 gl_pnlInputMain.setVerticalGroup(
264 gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
265 .addGroup(gl_pnlInputMain.createSequentialGroup()
267 .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.BASELINE)
268 .addComponent(fldId, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
270 .addComponent(cbBackLogReduce)
271 .addComponent(cbBackLog)
272 .addComponent(fldBackLog)
274 .addPreferredGap(ComponentPlacement.RELATED)
275 .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.BASELINE)
276 .addComponent(lblVideo)
277 .addComponent(fldVideo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
278 .addComponent(btnVideo)
279 .addComponent(cbVideoLocal))
280 .addPreferredGap(ComponentPlacement.RELATED)
281 .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.BASELINE)
282 .addComponent(lblComment)
283 .addComponent(fldComment, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
284 .addComponent(btnComment)
285 .addComponent(cbCommentLocal))
286 .addPreferredGap(ComponentPlacement.RELATED)
287 .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.BASELINE)
288 .addComponent(lblOutput)
289 .addComponent(fldOutput, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
290 .addComponent(cbOutputEnable))
291 .addPreferredGap(ComponentPlacement.UNRELATED)
292 .addComponent(btnApply)
293 .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
296 GroupLayout gl_pnlMain = new GroupLayout(pnlMain);
297 pnlMain.setLayout(gl_pnlMain);
298 gl_pnlMain.setHorizontalGroup(
299 gl_pnlMain.createParallelGroup(Alignment.LEADING)
300 .addGroup(Alignment.TRAILING, gl_pnlMain.createSequentialGroup()
302 .addGroup(gl_pnlMain.createParallelGroup(Alignment.TRAILING)
303 .addComponent(pnlInputMain, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
304 .addComponent(scrDisplay, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
305 .addComponent(pnlButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
308 gl_pnlMain.setVerticalGroup(
309 gl_pnlMain.createParallelGroup(Alignment.LEADING)
310 .addGroup(Alignment.TRAILING, gl_pnlMain.createSequentialGroup()
312 .addComponent(scrDisplay, GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
313 .addPreferredGap(ComponentPlacement.RELATED)
314 .addComponent(pnlButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
315 .addPreferredGap(ComponentPlacement.RELATED)
316 .addComponent(pnlInputMain, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
321 JMenuBar menuBar = initMenuBar();
322 setJMenuBar(menuBar);
324 GroupLayout layout = new GroupLayout(getContentPane());
325 getContentPane().setLayout(layout);
326 layout.setHorizontalGroup(
327 layout.createParallelGroup(Alignment.LEADING)
328 .addComponent(pnlMain, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
330 layout.setVerticalGroup(
331 layout.createParallelGroup(Alignment.LEADING)
332 .addComponent(pnlMain, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
337 pnlMain.setTransferHandler(new DownloadListTransferHandler());
338 tblDisplay.setTransferHandler(new TableTransferHandler());
341 private class ApplyActionListener implements ActionListener {
344 public void actionPerformed(ActionEvent e) {
345 final DownloadProfile prof = new InqubusDownloadProfile();
346 final String id = Util.getVideoId(fldId.getText());
348 new Download(prof, id).execute();
351 /** This method is called from within the constructor to
352 * initialize the form.
353 * WARNING: Do NOT modify this code. The content of this method is
354 * always regenerated by the Form Editor.
356 @SuppressWarnings("unchecked")
357 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
358 private void initComponents() {
359 }// </editor-fold>//GEN-END:initComponents
361 private File searchFileMatchId(final File dir, final String id) throws UnsupportedOperationException {
362 // TODO 候補は複数返すようにして、その後の対処は呼び出しもとで行ってもらった方が良いかも
367 final File[] lists = dir.listFiles(new FilenameFilter() {
369 final Pattern pattern = Pattern.compile(id + "\\D");
372 public boolean accept(File dir, String name) {
373 return pattern.matcher(name).find();
377 if (lists.length == 1) {
379 } else if (lists.length > 1) {
380 throw new UnsupportedOperationException();
386 private void useMovieLocalCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_useMovieLocalCheckBoxItemStateChanged
387 final Config p = Config.INSTANCE;
389 final ItemSelectable source = evt.getItemSelectable();
394 if (source == cbVideoLocal) {
397 dir = new File(p.getVideoDir());
401 dir = new File(p.getCommentDir());
404 final boolean useLocal = (evt.getStateChange() == ItemEvent.SELECTED);
405 btn.setEnabled(useLocal);
409 final File f = searchFileMatchId(dir, fldId.getText());
416 text = p.getVideoFileNamePattern();
420 fldId.setEnabled(!(cbVideoLocal.isSelected() && cbCommentLocal.isSelected()));
422 }//GEN-LAST:event_useMovieLocalCheckBoxItemStateChanged
424 private void outputConvertCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_outputConvertCheckBoxItemStateChanged
425 final boolean convert = (evt.getStateChange() == ItemEvent.SELECTED);
426 fldOutput.setEnabled(convert);
427 }//GEN-LAST:event_outputConvertCheckBoxItemStateChanged
429 private void idFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_idFieldFocusLost
430 final Config p = Config.INSTANCE;
431 final String id = fldId.getText();
436 if (cbVideoLocal.isSelected() && fldVideo.getText().isEmpty()) {
437 final File dir = new File(p.getVideoDir());
438 final File file = searchFileMatchId(dir, id);
440 fldVideo.setText(file.getPath());
444 if (cbCommentLocal.isSelected() && fldComment.getText().isEmpty()) {
445 final File dir = new File(p.getCommentDir());
446 final File file = searchFileMatchId(dir, id);
448 fldComment.setText(file.getPath());
452 }//GEN-LAST:event_idFieldFocusLost
453 // Variables declaration - do not modify//GEN-BEGIN:variables
454 private final JTable tblDisplay;
456 private final JButton btnStart;
457 private final JButton btnStop;
458 private final JButton btnDeselect;
460 private final JTextField fldId;
461 private final JCheckBox cbBackLogReduce = new JCheckBox("コメ数減少");
462 private final JCheckBox cbBackLog = new JCheckBox("過去ログ");
463 private final JTextField fldBackLog = new JTextField();
464 private final JCheckBox cbVideoLocal;
465 private final JTextField fldVideo;
466 private final JButton btnVideo;
467 private final JCheckBox cbCommentLocal;
468 private final JTextField fldComment;
469 private final JButton btnComment;
470 private final JCheckBox cbOutputEnable;
471 private final JTextField fldOutput;
473 private final JButton btnApply = new JButton("適用");
474 // End of variables declaration//GEN-END:variables
476 private void initInputPanel() {
477 final Config p = Config.INSTANCE;
480 fldBackLog.setEnabled(false);
481 fldBackLog.setToolTipText("YYYY/MM/DD hh:mm:ss形式、あるいは1970/01/01からの経過秒を入力します。");
482 cbBackLog.setEnabled(true);
483 cbBackLog.addItemListener(new ItemListener() {
486 public void itemStateChanged(ItemEvent e) {
487 final boolean selected = (e.getStateChange() == ItemEvent.SELECTED);
488 fldBackLog.setEnabled(selected);
491 cbBackLogReduce.setToolTipText("「コメントの量を減らす」場合はチェックを付けます。");
493 final boolean movieLocal = p.getVideoUseLocal();
494 cbVideoLocal.setSelected(movieLocal);
495 btnVideo.setEnabled(movieLocal);
497 fldVideo.setText(p.getVideoFileNamePattern());
500 final boolean commentLocal = p.getCommentUseLocal();
501 cbCommentLocal.setSelected(commentLocal);
502 btnComment.setEnabled(commentLocal);
504 fldComment.setText(p.getCommentFileNamePattern());
507 final boolean convert = p.getOutputEnable();
508 cbOutputEnable.setSelected(convert);
509 fldOutput.setEnabled(convert);
510 fldOutput.setText(p.getOutputFileNamePattern());
514 private JMenuBar initMenuBar() {
515 final JMenuBar menuBar = new JMenuBar();
517 final JMenu mnFile = new JMenu("ファイル(F)");
520 final JMenuItem itExit = new JMenuItem("終了(X)", KeyEvent.VK_X);
521 itExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
522 itExit.addActionListener(new ActionListener() {
525 public void actionPerformed(ActionEvent e) {
526 throw new UnsupportedOperationException("Not supported yet.");
531 final JMenu mnTool = new JMenu("ツール(T)");
534 final JMenuItem itOption = new JMenuItem("オプション(O)...", KeyEvent.VK_O);
536 itOption.addActionListener(new ActionListener() {
539 public void actionPerformed(ActionEvent e) {
540 final yukihane.inqubus.gui.ConfigDialog dlg = new yukihane.inqubus.gui.ConfigDialog(MainFrame.this);
541 dlg.setLocationRelativeTo(MainFrame.this);
543 dlg.setVisible(true);
546 mnTool.add(itOption);
548 final JMenu mnHelp = new JMenu("ヘルプ(H)");
551 final JMenuItem itAbout = new JMenuItem("このソフトウェアについて(A)...", KeyEvent.VK_A);
552 itAbout.addActionListener(new ActionListener() {
555 public void actionPerformed(ActionEvent e) {
556 MainFrame_AboutBox dlg = new MainFrame_AboutBox(MainFrame.this);
558 dlg.setLocationRelativeTo(MainFrame.this);
560 dlg.setVisible(true);
568 private class DownloadListTransferHandler extends TransferHandler {
570 private static final long serialVersionUID = 1L;
571 private final Pattern movieIdPattern = Pattern.compile("(\\w\\w\\d+)");
574 public boolean canImport(TransferHandler.TransferSupport support) {
575 Transferable transferable = support.getTransferable();
576 if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)
577 || transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
584 public boolean importData(TransferHandler.TransferSupport support) {
586 Transferable transferable = support.getTransferable();
587 if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
588 @SuppressWarnings("unchecked")
589 final List<File> data = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
590 Collection<Target> targets = Target.from(data);
591 targetModel.addTarget(targets);
592 } else if (transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
593 String data = (String) transferable.getTransferData(DataFlavor.stringFlavor);
594 Matcher matcher = movieIdPattern.matcher(data);
595 if (matcher.find()) {
596 String movieId = matcher.group(1);
597 Target target = Target.fromId(movieId);
598 targetModel.addTarget(target);
605 } catch (Exception e) {
606 logger.log(Level.SEVERE, null, e);
612 private class TableTransferHandler extends DownloadListTransferHandler {
614 private static final long serialVersionUID = 1L;
617 public boolean canImport(TransferHandler.TransferSupport support) {
618 return super.canImport(support);
622 public boolean importData(TransferHandler.TransferSupport support) {
623 return super.importData(support);
628 private class InqubusDownloadProfile implements DownloadProfile {
630 private final LoginProfile loginProfile;
631 private final ProxyProfile proxyProfile;
632 private final VideoProfile videoProfile;
633 private final CommentProfile commentProfile;
634 private final GeneralProfile generalProfile;
636 private InqubusDownloadProfile() {
637 this.loginProfile = new InqubusLoginProfile();
638 this.proxyProfile = new InqubusProxyProfile();
639 this.videoProfile = new InqubusVideoProfile();
640 this.commentProfile = new InqubusCommentProfile();
641 this.generalProfile = new InqubusGeneralProfile();
645 public LoginProfile getLoginInfo() {
646 return this.loginProfile;
650 public ProxyProfile getProxyProfile() {
651 return this.proxyProfile;
655 public VideoProfile getVideoProfile() {
656 return this.videoProfile;
660 public CommentProfile getCommentProfile() {
661 return this.commentProfile;
665 public GeneralProfile getGeneralProfile() {
666 return this.generalProfile;
670 private class InqubusLoginProfile implements LoginProfile {
671 private final String mail;
672 private final String password;
674 private InqubusLoginProfile(){
675 final Config p = Config.INSTANCE;
676 this.mail = p.getId();
677 this.password = p.getPassword();
681 public String getMail() {
686 public String getPassword() {
687 return this.password;
691 private class InqubusProxyProfile implements ProxyProfile {
692 private final boolean use;
693 private final String host;
694 private final int port;
696 private InqubusProxyProfile(){
697 final Config p = Config.INSTANCE;
698 this.use = p.getProxyUse();
699 this.host = p.getProxyHost();
700 final String pp = p.getProxyPort();
701 this.port = StringUtils.isBlank(pp) ? -1 : Integer.parseInt(pp);
705 public boolean use() {
710 public String getHost() {
715 public int getPort() {
720 private class InqubusVideoProfile implements VideoProfile {
721 private final boolean download;
722 private final File dir;
723 private final String fileName;
724 private final File localFile;
726 private InqubusVideoProfile(){
727 final Config p = Config.INSTANCE;
728 this.download = !cbVideoLocal.isSelected();
730 this.dir = new File(p.getVideoDir());
731 this.fileName = fldVideo.getText();
732 this.localFile = null;
735 this.fileName = null;
736 this.localFile = new File(fldVideo.getText());
741 public boolean isDownload() {
742 return this.download;
746 public File getDir() {
751 public String getFileName() {
752 return this.fileName;
756 public File getLocalFile() {
757 return this.localFile;
761 private class InqubusCommentProfile implements CommentProfile {
762 private final boolean download;
763 private final File dir;
764 private final String fileName;
765 private final File localFile;
766 private final int lengthRelatedCommentSize;
767 private final boolean disablePerMinComment;
768 private final int perMinCommentSize;
769 private final long backLogPoint;
771 private InqubusCommentProfile() {
772 final Config p = Config.INSTANCE;
773 this.download = !cbVideoLocal.isSelected();
775 this.dir = new File(p.getVideoDir());
776 this.fileName = fldVideo.getText();
777 this.localFile = null;
780 this.fileName = null;
781 this.localFile = new File(fldVideo.getText());
784 if(cbBackLog.isSelected()) {
786 this.backLogPoint = WayBackTimeParser.parse(fldBackLog.getText());
787 } catch (IOException ex) {
788 throw new IllegalArgumentException("過去ログ時刻指定が誤っています。", ex);
791 this.backLogPoint = -1L;
794 this.disablePerMinComment = cbBackLogReduce.isSelected();
795 this.lengthRelatedCommentSize
796 = (p.getCommentSizeAutosize()) ? -1 : Integer.parseInt(p.getCommentSizeManual());
797 this.perMinCommentSize
798 = (p.getCommentMinSizeAutosize()) ? -1 : Integer.parseInt(p.getCommentMinSizeManual());
802 public boolean isDownload() {
803 return this.download;
807 public File getDir() {
812 public String getFileName() {
813 return this.fileName;
817 public File getLocalFile() {
818 return this.localFile;
822 public int getLengthRelatedCommentSize() {
823 return this.lengthRelatedCommentSize;
827 public boolean isDisablePerMinComment() {
828 return this.disablePerMinComment;
832 public int getPerMinCommentSize() {
833 return this.perMinCommentSize;
837 public long getBackLogPoint() {
838 return this.backLogPoint;
842 private class InqubusGeneralProfile implements GeneralProfile {
843 private final String replaceFrom;
844 private final String replaceTo;
845 private InqubusGeneralProfile() {
846 final Config p = Config.INSTANCE;
847 this.replaceFrom = p.getReplaceFrom();
848 this.replaceTo = p.getReplaceTo();
852 public String getReplaceFrom() {
853 return this.replaceFrom;
857 public String getReplaceTo() {
858 return this.replaceTo;