OSDN Git Service

クラス名変更
[coroid/inqubus.git] / frontend / src / yukihane / inqubus / gui / MainFrame.java
index ee98a66..bedeb76 100644 (file)
@@ -46,9 +46,12 @@ import javax.swing.LayoutStyle.ComponentPlacement;
 import javax.swing.TransferHandler;
 import javax.swing.WindowConstants;
 import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.builder.ToStringBuilder;
 import saccubus.MainFrame_AboutBox;
 import saccubus.util.WayBackTimeParser;
-import saccubus.worker.Download;
+import saccubus.worker.convert.ConvertProgress;
+import saccubus.worker.download.DownloadProgress;
+import saccubus.worker.WorkerListener;
 import saccubus.worker.profile.CommentProfile;
 import saccubus.worker.profile.DownloadProfile;
 import saccubus.worker.profile.GeneralProfile;
@@ -57,6 +60,7 @@ import saccubus.worker.profile.ProxyProfile;
 import saccubus.worker.profile.VideoProfile;
 import yukihane.Util;
 import yukihane.inqubus.Config;
+import yukihane.inqubus.manager.TaskManage;
 import yukihane.inqubus.model.Target;
 import yukihane.inqubus.model.TargetsTableModel;
 
@@ -77,6 +81,9 @@ public class MainFrame extends JFrame {
     private static final String FILE_OUTPUTFIELD_TOOLTIP
             = "ファイル命名規則入力します。";
     private final TargetsTableModel targetModel = new TargetsTableModel();
+    private final TaskManage taskManager;
+    private final DownloadProgressListener downloadProgressListener = new DownloadProgressListener();
+    private final ConvertProgressListener convertProgressListener = new ConvertProgressListener();
 
     /** Creates new form MainFrame */
     public MainFrame() {
@@ -336,6 +343,11 @@ public class MainFrame extends JFrame {
         initInputPanel();
         pnlMain.setTransferHandler(new DownloadListTransferHandler());
         tblDisplay.setTransferHandler(new TableTransferHandler());
+
+        final Config p = Config.INSTANCE;
+        // TODO コンフィグからスレッド数
+        taskManager = new TaskManage(1, 1);
+
     }
 
     private class ApplyActionListener implements ActionListener {
@@ -344,8 +356,9 @@ public class MainFrame extends JFrame {
         public void actionPerformed(ActionEvent e) {
             final DownloadProfile prof = new InqubusDownloadProfile();
             final String id = Util.getVideoId(fldId.getText());
-
-            new Download(prof, id).execute();
+            logger.log(Level.INFO, prof.toString());
+            // TODO 処理開始
+//            new Download(prof, id).execute();
         }
     }
     /** This method is called from within the constructor to
@@ -358,7 +371,7 @@ public class MainFrame extends JFrame {
     private void initComponents() {
     }// </editor-fold>//GEN-END:initComponents
 
-    private File searchFileMatchId(final File dir, final String id) throws UnsupportedOperationException {
+    private File searchFileMatchId(final File dir, final String id) {
         // TODO 候補は複数返すようにして、その後の対処は呼び出しもとで行ってもらった方が良いかも
         if (id.isEmpty()) {
             return null;
@@ -565,6 +578,24 @@ public class MainFrame extends JFrame {
         return menuBar;
     }
 
+    private class DownloadProgressListener implements WorkerListener<DownloadProgress> {
+
+        @Override
+        public void process(DownloadProgress progress) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+    }
+
+    private class ConvertProgressListener implements WorkerListener<ConvertProgress> {
+
+        @Override
+        public void process(ConvertProgress progress) {
+            throw new UnsupportedOperationException("Not supported yet.");
+        }
+    }
+
+
+
     private class DownloadListTransferHandler extends TransferHandler {
 
         private static final long serialVersionUID = 1L;
@@ -665,6 +696,11 @@ public class MainFrame extends JFrame {
         public GeneralProfile getGeneralProfile() {
             return this.generalProfile;
         }
+
+        @Override
+        public String toString(){
+            return ToStringBuilder.reflectionToString(this);
+        }
     }
 
     private class InqubusLoginProfile implements LoginProfile {
@@ -686,6 +722,11 @@ public class MainFrame extends JFrame {
         public String getPassword() {
             return this.password;
         }
+
+        @Override
+        public String toString(){
+            return ToStringBuilder.reflectionToString(this);
+        }
     }
 
     private class InqubusProxyProfile implements ProxyProfile {
@@ -715,6 +756,11 @@ public class MainFrame extends JFrame {
         public int getPort() {
             return this.port;
         }
+
+        @Override
+        public String toString(){
+            return ToStringBuilder.reflectionToString(this);
+        }
     }
 
     private class InqubusVideoProfile implements VideoProfile {
@@ -756,6 +802,11 @@ public class MainFrame extends JFrame {
         public File getLocalFile() {
             return this.localFile;
         }
+
+        @Override
+        public String toString(){
+            return ToStringBuilder.reflectionToString(this);
+        }
     }
 
     private class InqubusCommentProfile implements CommentProfile {
@@ -837,26 +888,35 @@ public class MainFrame extends JFrame {
         public long getBackLogPoint() {
             return this.backLogPoint;
         }
+
+        @Override
+        public String toString(){
+            return ToStringBuilder.reflectionToString(this);
+        }
     }
 
     private class InqubusGeneralProfile implements GeneralProfile {
-//        private final String replaceFrom;
+        private final String replaceFrom;
+        private final String replaceTo;
         private InqubusGeneralProfile() {
             final Config p = Config.INSTANCE;
-            // TODO 置換文字設定コンフィグが無い
-//            this.replaceFrom = p.get
+            this.replaceFrom = p.getReplaceFrom();
+            this.replaceTo = p.getReplaceTo();
         }
 
         @Override
         public String getReplaceFrom() {
-//            return this.replaceFrom;
-            throw new UnsupportedOperationException("Not supported yet.");
+            return this.replaceFrom;
         }
 
         @Override
         public String getReplaceTo() {
-            throw new UnsupportedOperationException("Not supported yet.");
+            return this.replaceTo;
         }
 
+        @Override
+        public String toString(){
+            return ToStringBuilder.reflectionToString(this);
+        }
     }
 }