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 org.apache.commons.lang.builder.ToStringBuilder;
50 import saccubus.MainFrame_AboutBox;
51 import saccubus.util.WayBackTimeParser;
52 import saccubus.worker.convert.ConvertProgress;
53 import saccubus.worker.download.DownloadProgress;
54 import saccubus.worker.WorkerListener;
55 import saccubus.worker.profile.CommentProfile;
56 import saccubus.worker.profile.DownloadProfile;
57 import saccubus.worker.profile.GeneralProfile;
58 import saccubus.worker.profile.LoginProfile;
59 import saccubus.worker.profile.ProxyProfile;
60 import saccubus.worker.profile.VideoProfile;
62 import yukihane.inqubus.Config;
63 import yukihane.inqubus.manager.TaskManage;
64 import yukihane.inqubus.model.Target;
65 import yukihane.inqubus.model.TargetsTableModel;
71 public class MainFrame extends JFrame {
73 private static final long serialVersionUID = 1L;
74 private static final Logger logger = Logger.getLogger(MainFrame.class.getName());
75 private static final String ID_FIELD_TOOLTIP = "動画のIDまたはURLを入力します。";
76 private static final String FILE_LOCALBUTTON_TOOLTIP
77 = "ダウンロードする場合はチェックを外します。ローカルファイルを使用する場合はチェックを入れます。";
78 private static final String FILE_INPUTFIELD_TOOLTIP
79 = "ダウンロードする場合はファイル命名規則を入力します。"
80 + "ローカルファイルを使用する場合はパスを含むファイル名を入力します。";
81 private static final String FILE_OUTPUTFIELD_TOOLTIP
83 private final TargetsTableModel targetModel = new TargetsTableModel();
84 private final TaskManage taskManager;
85 private final DownloadProgressListener downloadProgressListener = new DownloadProgressListener();
86 private final ConvertProgressListener convertProgressListener = new ConvertProgressListener();
88 /** Creates new form MainFrame */
90 final URL url = MainFrame_AboutBox.class.getResource("icon.png");
91 final Image icon1 = Toolkit.getDefaultToolkit().createImage(url);
92 final URL url32 = MainFrame_AboutBox.class.getResource("icon32.png");
93 final Image icon2 = Toolkit.getDefaultToolkit().createImage(url32);
94 final List<Image> images = new ArrayList<Image>(2);
97 setIconImages(images);
99 final JPanel pnlMain = new JPanel();
100 final JScrollPane scrDisplay = new JScrollPane();
101 tblDisplay = new JTable();
102 final JPanel pnlButton = new JPanel();
103 btnStart = new JButton();
104 btnStop = new JButton();
105 btnDeselect = new JButton();
106 final JPanel pnlInputMain = new JPanel();
107 final JLabel lblId = new JLabel();
108 fldId = new JTextField();
109 fldId.setToolTipText(ID_FIELD_TOOLTIP);
110 final JLabel lblVideo = new JLabel();
111 cbVideoLocal = new JCheckBox();
112 cbVideoLocal.setToolTipText(FILE_LOCALBUTTON_TOOLTIP);
113 fldVideo = new JTextField();
114 fldVideo.setToolTipText(FILE_INPUTFIELD_TOOLTIP);
115 btnVideo = new JButton();
116 final JLabel lblComment = new JLabel();
117 cbCommentLocal = new JCheckBox();
118 cbCommentLocal.setToolTipText(FILE_LOCALBUTTON_TOOLTIP);
119 cbCommentLocal.addItemListener(new ItemListener() {
122 public void itemStateChanged(ItemEvent e) {
123 final boolean selected = (e.getStateChange() == ItemEvent.SELECTED);
124 cbBackLogReduce.setEnabled(!selected);
125 cbBackLog.setEnabled(!selected);
127 cbBackLog.setSelected(false);
131 fldComment = new JTextField();
132 fldComment.setToolTipText(FILE_INPUTFIELD_TOOLTIP);
133 btnComment = new JButton();
134 final JLabel lblOutput = new JLabel();
135 cbOutputEnable = new JCheckBox();
136 fldOutput = new JTextField();
137 fldOutput.setToolTipText(FILE_OUTPUTFIELD_TOOLTIP);
139 setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
141 btnApply.addActionListener(new ApplyActionListener());
143 pnlMain.setBorder(BorderFactory.createEtchedBorder());
145 tblDisplay.setModel(targetModel);
146 tblDisplay.setDropMode(DropMode.INSERT_ROWS);
147 scrDisplay.setViewportView(tblDisplay);
149 pnlButton.setBorder(BorderFactory.createEtchedBorder());
151 btnStart.setText("開始");
153 btnStop.setText("停止");
155 btnDeselect.setText("選択解除");
157 GroupLayout gl_pnlButton = new GroupLayout(pnlButton);
158 pnlButton.setLayout(gl_pnlButton);
159 gl_pnlButton.setHorizontalGroup(
160 gl_pnlButton.createParallelGroup(Alignment.LEADING)
161 .addGroup(gl_pnlButton.createSequentialGroup()
163 .addComponent(btnStart)
164 .addPreferredGap(ComponentPlacement.RELATED)
165 .addComponent(btnStop)
166 .addPreferredGap(ComponentPlacement.RELATED, 250, Short.MAX_VALUE)
167 .addComponent(btnDeselect)
170 gl_pnlButton.setVerticalGroup(
171 gl_pnlButton.createParallelGroup(Alignment.LEADING)
172 .addGroup(gl_pnlButton.createSequentialGroup()
174 .addGroup(gl_pnlButton.createParallelGroup(Alignment.BASELINE)
175 .addComponent(btnStart)
176 .addComponent(btnStop)
177 .addComponent(btnDeselect))
178 .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
181 pnlInputMain.setBorder(BorderFactory.createEtchedBorder());
185 fldId.addFocusListener(new java.awt.event.FocusAdapter() {
187 public void focusLost(java.awt.event.FocusEvent evt) {
188 idFieldFocusLost(evt);
192 lblVideo.setText("動画");
194 cbVideoLocal.setText("local");
195 cbVideoLocal.addItemListener(new java.awt.event.ItemListener() {
197 public void itemStateChanged(java.awt.event.ItemEvent evt) {
198 useMovieLocalCheckBoxItemStateChanged(evt);
202 btnVideo.setText("...");
204 lblComment.setText("コメント");
206 cbCommentLocal.setText("local");
207 cbCommentLocal.addItemListener(new java.awt.event.ItemListener() {
209 public void itemStateChanged(java.awt.event.ItemEvent evt) {
210 useMovieLocalCheckBoxItemStateChanged(evt);
214 btnComment.setText("...");
216 lblOutput.setText("出力");
218 cbOutputEnable.setText("変換");
219 cbOutputEnable.addItemListener(new java.awt.event.ItemListener() {
221 public void itemStateChanged(java.awt.event.ItemEvent evt) {
222 outputConvertCheckBoxItemStateChanged(evt);
227 GroupLayout gl_pnlInputMain = new GroupLayout(pnlInputMain);
228 pnlInputMain.setLayout(gl_pnlInputMain);
229 gl_pnlInputMain.setHorizontalGroup(
230 gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
231 .addGroup(gl_pnlInputMain.createSequentialGroup()
233 .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
234 .addGroup(gl_pnlInputMain.createSequentialGroup()
235 .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
236 .addComponent(lblComment)
237 .addComponent(lblVideo)
239 .addComponent(lblOutput))
240 .addPreferredGap(ComponentPlacement.RELATED)
241 .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
242 .addGroup(gl_pnlInputMain.createSequentialGroup()
243 .addComponent(cbVideoLocal)
244 .addPreferredGap(ComponentPlacement.RELATED)
245 .addComponent(fldVideo, GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)
246 .addPreferredGap(ComponentPlacement.RELATED)
247 .addComponent(btnVideo))
248 .addGroup(gl_pnlInputMain.createSequentialGroup()
249 .addComponent(fldId, GroupLayout.PREFERRED_SIZE, 100, GroupLayout.PREFERRED_SIZE)
250 .addPreferredGap(ComponentPlacement.UNRELATED)
251 .addComponent(cbBackLogReduce)
252 .addComponent(cbBackLog)
253 .addComponent(fldBackLog, GroupLayout.PREFERRED_SIZE, 150, GroupLayout.PREFERRED_SIZE)
255 .addGroup(Alignment.TRAILING, gl_pnlInputMain.createSequentialGroup()
256 .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.TRAILING)
257 .addGroup(Alignment.LEADING, gl_pnlInputMain.createSequentialGroup()
258 .addComponent(cbOutputEnable)
259 .addPreferredGap(ComponentPlacement.RELATED)
260 .addComponent(fldOutput, GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE))
261 .addGroup(gl_pnlInputMain.createSequentialGroup()
262 .addComponent(cbCommentLocal)
263 .addPreferredGap(ComponentPlacement.RELATED)
264 .addComponent(fldComment, GroupLayout.DEFAULT_SIZE, 317, Short.MAX_VALUE)))
265 .addPreferredGap(ComponentPlacement.RELATED)
266 .addComponent(btnComment))))
267 .addComponent(btnApply, Alignment.TRAILING))
270 gl_pnlInputMain.setVerticalGroup(
271 gl_pnlInputMain.createParallelGroup(Alignment.LEADING)
272 .addGroup(gl_pnlInputMain.createSequentialGroup()
274 .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.BASELINE)
275 .addComponent(fldId, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
277 .addComponent(cbBackLogReduce)
278 .addComponent(cbBackLog)
279 .addComponent(fldBackLog)
281 .addPreferredGap(ComponentPlacement.RELATED)
282 .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.BASELINE)
283 .addComponent(lblVideo)
284 .addComponent(fldVideo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
285 .addComponent(btnVideo)
286 .addComponent(cbVideoLocal))
287 .addPreferredGap(ComponentPlacement.RELATED)
288 .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.BASELINE)
289 .addComponent(lblComment)
290 .addComponent(fldComment, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
291 .addComponent(btnComment)
292 .addComponent(cbCommentLocal))
293 .addPreferredGap(ComponentPlacement.RELATED)
294 .addGroup(gl_pnlInputMain.createParallelGroup(Alignment.BASELINE)
295 .addComponent(lblOutput)
296 .addComponent(fldOutput, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
297 .addComponent(cbOutputEnable))
298 .addPreferredGap(ComponentPlacement.UNRELATED)
299 .addComponent(btnApply)
300 .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
303 GroupLayout gl_pnlMain = new GroupLayout(pnlMain);
304 pnlMain.setLayout(gl_pnlMain);
305 gl_pnlMain.setHorizontalGroup(
306 gl_pnlMain.createParallelGroup(Alignment.LEADING)
307 .addGroup(Alignment.TRAILING, gl_pnlMain.createSequentialGroup()
309 .addGroup(gl_pnlMain.createParallelGroup(Alignment.TRAILING)
310 .addComponent(pnlInputMain, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
311 .addComponent(scrDisplay, Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 480, Short.MAX_VALUE)
312 .addComponent(pnlButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
315 gl_pnlMain.setVerticalGroup(
316 gl_pnlMain.createParallelGroup(Alignment.LEADING)
317 .addGroup(Alignment.TRAILING, gl_pnlMain.createSequentialGroup()
319 .addComponent(scrDisplay, GroupLayout.DEFAULT_SIZE, 197, Short.MAX_VALUE)
320 .addPreferredGap(ComponentPlacement.RELATED)
321 .addComponent(pnlButton, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
322 .addPreferredGap(ComponentPlacement.RELATED)
323 .addComponent(pnlInputMain, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
328 JMenuBar menuBar = initMenuBar();
329 setJMenuBar(menuBar);
331 GroupLayout layout = new GroupLayout(getContentPane());
332 getContentPane().setLayout(layout);
333 layout.setHorizontalGroup(
334 layout.createParallelGroup(Alignment.LEADING)
335 .addComponent(pnlMain, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
337 layout.setVerticalGroup(
338 layout.createParallelGroup(Alignment.LEADING)
339 .addComponent(pnlMain, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
344 pnlMain.setTransferHandler(new DownloadListTransferHandler());
345 tblDisplay.setTransferHandler(new TableTransferHandler());
347 final Config p = Config.INSTANCE;
349 taskManager = new TaskManage(1, 1);
353 private class ApplyActionListener implements ActionListener {
356 public void actionPerformed(ActionEvent e) {
357 final DownloadProfile prof = new InqubusDownloadProfile();
358 final String id = Util.getVideoId(fldId.getText());
359 logger.log(Level.INFO, prof.toString());
361 // new Download(prof, id).execute();
364 /** This method is called from within the constructor to
365 * initialize the form.
366 * WARNING: Do NOT modify this code. The content of this method is
367 * always regenerated by the Form Editor.
369 @SuppressWarnings("unchecked")
370 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
371 private void initComponents() {
372 }// </editor-fold>//GEN-END:initComponents
374 private File searchFileMatchId(final File dir, final String id) {
375 // TODO 候補は複数返すようにして、その後の対処は呼び出しもとで行ってもらった方が良いかも
380 final File[] lists = dir.listFiles(new FilenameFilter() {
382 final Pattern pattern = Pattern.compile(id + "\\D");
385 public boolean accept(File dir, String name) {
386 return pattern.matcher(name).find();
390 if (lists.length == 1) {
392 } else if (lists.length > 1) {
393 throw new UnsupportedOperationException();
399 private void useMovieLocalCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_useMovieLocalCheckBoxItemStateChanged
400 final Config p = Config.INSTANCE;
402 final ItemSelectable source = evt.getItemSelectable();
407 if (source == cbVideoLocal) {
410 dir = new File(p.getVideoDir());
414 dir = new File(p.getCommentDir());
417 final boolean useLocal = (evt.getStateChange() == ItemEvent.SELECTED);
418 btn.setEnabled(useLocal);
422 final File f = searchFileMatchId(dir, fldId.getText());
429 text = p.getVideoFileNamePattern();
433 fldId.setEnabled(!(cbVideoLocal.isSelected() && cbCommentLocal.isSelected()));
435 }//GEN-LAST:event_useMovieLocalCheckBoxItemStateChanged
437 private void outputConvertCheckBoxItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_outputConvertCheckBoxItemStateChanged
438 final boolean convert = (evt.getStateChange() == ItemEvent.SELECTED);
439 fldOutput.setEnabled(convert);
440 }//GEN-LAST:event_outputConvertCheckBoxItemStateChanged
442 private void idFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_idFieldFocusLost
443 final Config p = Config.INSTANCE;
444 final String id = fldId.getText();
449 if (cbVideoLocal.isSelected() && fldVideo.getText().isEmpty()) {
450 final File dir = new File(p.getVideoDir());
451 final File file = searchFileMatchId(dir, id);
453 fldVideo.setText(file.getPath());
457 if (cbCommentLocal.isSelected() && fldComment.getText().isEmpty()) {
458 final File dir = new File(p.getCommentDir());
459 final File file = searchFileMatchId(dir, id);
461 fldComment.setText(file.getPath());
465 }//GEN-LAST:event_idFieldFocusLost
466 // Variables declaration - do not modify//GEN-BEGIN:variables
467 private final JTable tblDisplay;
469 private final JButton btnStart;
470 private final JButton btnStop;
471 private final JButton btnDeselect;
473 private final JTextField fldId;
474 private final JCheckBox cbBackLogReduce = new JCheckBox("コメ数減少");
475 private final JCheckBox cbBackLog = new JCheckBox("過去ログ");
476 private final JTextField fldBackLog = new JTextField();
477 private final JCheckBox cbVideoLocal;
478 private final JTextField fldVideo;
479 private final JButton btnVideo;
480 private final JCheckBox cbCommentLocal;
481 private final JTextField fldComment;
482 private final JButton btnComment;
483 private final JCheckBox cbOutputEnable;
484 private final JTextField fldOutput;
486 private final JButton btnApply = new JButton("適用");
487 // End of variables declaration//GEN-END:variables
489 private void initInputPanel() {
490 final Config p = Config.INSTANCE;
493 fldBackLog.setEnabled(false);
494 fldBackLog.setToolTipText("YYYY/MM/DD hh:mm:ss形式、あるいは1970/01/01からの経過秒を入力します。");
495 cbBackLog.setEnabled(true);
496 cbBackLog.addItemListener(new ItemListener() {
499 public void itemStateChanged(ItemEvent e) {
500 final boolean selected = (e.getStateChange() == ItemEvent.SELECTED);
501 fldBackLog.setEnabled(selected);
504 cbBackLogReduce.setToolTipText("「コメントの量を減らす」場合はチェックを付けます。");
506 final boolean movieLocal = p.getVideoUseLocal();
507 cbVideoLocal.setSelected(movieLocal);
508 btnVideo.setEnabled(movieLocal);
510 fldVideo.setText(p.getVideoFileNamePattern());
513 final boolean commentLocal = p.getCommentUseLocal();
514 cbCommentLocal.setSelected(commentLocal);
515 btnComment.setEnabled(commentLocal);
517 fldComment.setText(p.getCommentFileNamePattern());
520 final boolean convert = p.getOutputEnable();
521 cbOutputEnable.setSelected(convert);
522 fldOutput.setEnabled(convert);
523 fldOutput.setText(p.getOutputFileNamePattern());
527 private JMenuBar initMenuBar() {
528 final JMenuBar menuBar = new JMenuBar();
530 final JMenu mnFile = new JMenu("ファイル(F)");
533 final JMenuItem itExit = new JMenuItem("終了(X)", KeyEvent.VK_X);
534 itExit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Q, ActionEvent.CTRL_MASK));
535 itExit.addActionListener(new ActionListener() {
538 public void actionPerformed(ActionEvent e) {
539 throw new UnsupportedOperationException("Not supported yet.");
544 final JMenu mnTool = new JMenu("ツール(T)");
547 final JMenuItem itOption = new JMenuItem("オプション(O)...", KeyEvent.VK_O);
549 itOption.addActionListener(new ActionListener() {
552 public void actionPerformed(ActionEvent e) {
553 final yukihane.inqubus.gui.ConfigDialog dlg = new yukihane.inqubus.gui.ConfigDialog(MainFrame.this);
554 dlg.setLocationRelativeTo(MainFrame.this);
556 dlg.setVisible(true);
559 mnTool.add(itOption);
561 final JMenu mnHelp = new JMenu("ヘルプ(H)");
564 final JMenuItem itAbout = new JMenuItem("このソフトウェアについて(A)...", KeyEvent.VK_A);
565 itAbout.addActionListener(new ActionListener() {
568 public void actionPerformed(ActionEvent e) {
569 MainFrame_AboutBox dlg = new MainFrame_AboutBox(MainFrame.this);
571 dlg.setLocationRelativeTo(MainFrame.this);
573 dlg.setVisible(true);
581 private class DownloadProgressListener implements WorkerListener<DownloadProgress> {
584 public void process(DownloadProgress progress) {
585 throw new UnsupportedOperationException("Not supported yet.");
589 private class ConvertProgressListener implements WorkerListener<ConvertProgress> {
592 public void process(ConvertProgress progress) {
593 throw new UnsupportedOperationException("Not supported yet.");
599 private class DownloadListTransferHandler extends TransferHandler {
601 private static final long serialVersionUID = 1L;
602 private final Pattern movieIdPattern = Pattern.compile("(\\w\\w\\d+)");
605 public boolean canImport(TransferHandler.TransferSupport support) {
606 Transferable transferable = support.getTransferable();
607 if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)
608 || transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
615 public boolean importData(TransferHandler.TransferSupport support) {
617 Transferable transferable = support.getTransferable();
618 if (transferable.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) {
619 @SuppressWarnings("unchecked")
620 final List<File> data = (List<File>) transferable.getTransferData(DataFlavor.javaFileListFlavor);
621 Collection<Target> targets = Target.from(data);
622 targetModel.addTarget(targets);
623 } else if (transferable.isDataFlavorSupported(DataFlavor.stringFlavor)) {
624 String data = (String) transferable.getTransferData(DataFlavor.stringFlavor);
625 Matcher matcher = movieIdPattern.matcher(data);
626 if (matcher.find()) {
627 String movieId = matcher.group(1);
628 Target target = Target.fromId(movieId);
629 targetModel.addTarget(target);
636 } catch (Exception e) {
637 logger.log(Level.SEVERE, null, e);
643 private class TableTransferHandler extends DownloadListTransferHandler {
645 private static final long serialVersionUID = 1L;
648 public boolean canImport(TransferHandler.TransferSupport support) {
649 return super.canImport(support);
653 public boolean importData(TransferHandler.TransferSupport support) {
654 return super.importData(support);
659 private class InqubusDownloadProfile implements DownloadProfile {
661 private final LoginProfile loginProfile;
662 private final ProxyProfile proxyProfile;
663 private final VideoProfile videoProfile;
664 private final CommentProfile commentProfile;
665 private final GeneralProfile generalProfile;
667 private InqubusDownloadProfile() {
668 this.loginProfile = new InqubusLoginProfile();
669 this.proxyProfile = new InqubusProxyProfile();
670 this.videoProfile = new InqubusVideoProfile();
671 this.commentProfile = new InqubusCommentProfile();
672 this.generalProfile = new InqubusGeneralProfile();
676 public LoginProfile getLoginInfo() {
677 return this.loginProfile;
681 public ProxyProfile getProxyProfile() {
682 return this.proxyProfile;
686 public VideoProfile getVideoProfile() {
687 return this.videoProfile;
691 public CommentProfile getCommentProfile() {
692 return this.commentProfile;
696 public GeneralProfile getGeneralProfile() {
697 return this.generalProfile;
701 public String toString(){
702 return ToStringBuilder.reflectionToString(this);
706 private class InqubusLoginProfile implements LoginProfile {
707 private final String mail;
708 private final String password;
710 private InqubusLoginProfile(){
711 final Config p = Config.INSTANCE;
712 this.mail = p.getId();
713 this.password = p.getPassword();
717 public String getMail() {
722 public String getPassword() {
723 return this.password;
727 public String toString(){
728 return ToStringBuilder.reflectionToString(this);
732 private class InqubusProxyProfile implements ProxyProfile {
733 private final boolean use;
734 private final String host;
735 private final int port;
737 private InqubusProxyProfile(){
738 final Config p = Config.INSTANCE;
739 this.use = p.getProxyUse();
740 this.host = p.getProxyHost();
741 final String pp = p.getProxyPort();
742 this.port = StringUtils.isBlank(pp) ? -1 : Integer.parseInt(pp);
746 public boolean use() {
751 public String getHost() {
756 public int getPort() {
761 public String toString(){
762 return ToStringBuilder.reflectionToString(this);
766 private class InqubusVideoProfile implements VideoProfile {
767 private final boolean download;
768 private final File dir;
769 private final String fileName;
770 private final File localFile;
772 private InqubusVideoProfile(){
773 final Config p = Config.INSTANCE;
774 this.download = !cbVideoLocal.isSelected();
776 this.dir = new File(p.getVideoDir());
777 this.fileName = fldVideo.getText();
778 this.localFile = null;
781 this.fileName = null;
782 this.localFile = new File(fldVideo.getText());
787 public boolean isDownload() {
788 return this.download;
792 public File getDir() {
797 public String getFileName() {
798 return this.fileName;
802 public File getLocalFile() {
803 return this.localFile;
807 public String toString(){
808 return ToStringBuilder.reflectionToString(this);
812 private class InqubusCommentProfile implements CommentProfile {
813 private final boolean download;
814 private final File dir;
815 private final String fileName;
816 private final File localFile;
817 private final int lengthRelatedCommentSize;
818 private final boolean disablePerMinComment;
819 private final int perMinCommentSize;
820 private final long backLogPoint;
822 private InqubusCommentProfile() {
823 final Config p = Config.INSTANCE;
824 this.download = !cbVideoLocal.isSelected();
826 this.dir = new File(p.getVideoDir());
827 this.fileName = fldVideo.getText();
828 this.localFile = null;
831 this.fileName = null;
832 this.localFile = new File(fldVideo.getText());
835 if(cbBackLog.isSelected()) {
837 this.backLogPoint = WayBackTimeParser.parse(fldBackLog.getText());
838 } catch (IOException ex) {
839 throw new IllegalArgumentException("過去ログ時刻指定が誤っています。", ex);
842 this.backLogPoint = -1L;
845 this.disablePerMinComment = cbBackLogReduce.isSelected();
846 this.lengthRelatedCommentSize
847 = (p.getCommentSizeAutosize()) ? -1 : Integer.parseInt(p.getCommentSizeManual());
848 this.perMinCommentSize
849 = (p.getCommentMinSizeAutosize()) ? -1 : Integer.parseInt(p.getCommentMinSizeManual());
853 public boolean isDownload() {
854 return this.download;
858 public File getDir() {
863 public String getFileName() {
864 return this.fileName;
868 public File getLocalFile() {
869 return this.localFile;
873 public int getLengthRelatedCommentSize() {
874 return this.lengthRelatedCommentSize;
878 public boolean isDisablePerMinComment() {
879 return this.disablePerMinComment;
883 public int getPerMinCommentSize() {
884 return this.perMinCommentSize;
888 public long getBackLogPoint() {
889 return this.backLogPoint;
893 public String toString(){
894 return ToStringBuilder.reflectionToString(this);
898 private class InqubusGeneralProfile implements GeneralProfile {
899 private final String replaceFrom;
900 private final String replaceTo;
901 private InqubusGeneralProfile() {
902 final Config p = Config.INSTANCE;
903 this.replaceFrom = p.getReplaceFrom();
904 this.replaceTo = p.getReplaceTo();
908 public String getReplaceFrom() {
909 return this.replaceFrom;
913 public String getReplaceTo() {
914 return this.replaceTo;
918 public String toString(){
919 return ToStringBuilder.reflectionToString(this);