OSDN Git Service

GUIでのCommentProfileインスタンス生成
authoryukihane <yukihane.feather@gmail.com>
Thu, 25 Aug 2011 11:18:37 +0000 (20:18 +0900)
committeryukihane <yukihane.feather@gmail.com>
Thu, 25 Aug 2011 11:18:37 +0000 (20:18 +0900)
frontend/src/yukihane/inqubus/gui/MainFrame.java

index 71f9a25..ee98a66 100644 (file)
@@ -17,6 +17,7 @@ import java.awt.event.ItemListener;
 import java.awt.event.KeyEvent;
 import java.io.File;
 import java.io.FilenameFilter;
+import java.io.IOException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -46,6 +47,7 @@ import javax.swing.TransferHandler;
 import javax.swing.WindowConstants;
 import org.apache.commons.lang.StringUtils;
 import saccubus.MainFrame_AboutBox;
+import saccubus.util.WayBackTimeParser;
 import saccubus.worker.Download;
 import saccubus.worker.profile.CommentProfile;
 import saccubus.worker.profile.DownloadProfile;
@@ -722,11 +724,11 @@ public class MainFrame extends JFrame {
         private final File localFile;
 
         private InqubusVideoProfile(){
+            final Config p = Config.INSTANCE;
             this.download = !cbVideoLocal.isSelected();
             if (this.download) {
-                this.dir = new File(fldVideo.getText());
-                // TODO ディレクトリとファイル名の入力欄を分ける
-                this.fileName = "{id}_{title}";
+                this.dir = new File(p.getVideoDir());
+                this.fileName = fldVideo.getText();
                 this.localFile = null;
             } else {
                 this.dir = null;
@@ -757,47 +759,84 @@ public class MainFrame extends JFrame {
     }
 
     private class InqubusCommentProfile implements CommentProfile {
+        private final boolean download;
+        private final File dir;
+        private final String fileName;
+        private final File localFile;
+        private final int lengthRelatedCommentSize;
+        private final boolean disablePerMinComment;
+        private final int perMinCommentSize;
+        private final long backLogPoint;
 
-        @Override
-        public int getLengthRelatedCommentSize() {
-            throw new UnsupportedOperationException("Not supported yet.");
+        private InqubusCommentProfile() {
+            final Config p = Config.INSTANCE;
+            this.download = !cbVideoLocal.isSelected();
+            if (this.download) {
+                this.dir = new File(p.getVideoDir());
+                this.fileName = fldVideo.getText();
+                this.localFile = null;
+            } else {
+                this.dir = null;
+                this.fileName = null;
+                this.localFile = new File(fldVideo.getText());
+            }
+
+            if(cbBackLog.isSelected()) {
+                try {
+                    this.backLogPoint = WayBackTimeParser.parse(fldBackLog.getText());
+                } catch (IOException ex) {
+                    throw new IllegalArgumentException("過去ログ時刻指定が誤っています。", ex);
+                }
+            } else {
+                this.backLogPoint = -1L;
+            }
+
+            this.disablePerMinComment = cbBackLogReduce.isSelected();
+            this.lengthRelatedCommentSize
+                    = (p.getCommentSizeAutosize()) ? -1 : Integer.parseInt(p.getCommentSizeManual());
+            this.perMinCommentSize
+                    = (p.getCommentMinSizeAutosize()) ? -1 : Integer.parseInt(p.getCommentMinSizeManual());
         }
 
         @Override
-        public boolean isDisablePerMinComment() {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public boolean isDownload() {
+            return this.download;
         }
 
         @Override
-        public int getPerMinCommentSize() {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public File getDir() {
+            return this.dir;
         }
 
         @Override
-        public long getBackLogPoint() {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public String getFileName() {
+            return this.fileName;
         }
 
         @Override
-        public boolean isDownload() {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public File getLocalFile() {
+            return this.localFile;
         }
 
         @Override
-        public File getDir() {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public int getLengthRelatedCommentSize() {
+            return this.lengthRelatedCommentSize;
         }
 
         @Override
-        public String getFileName() {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public boolean isDisablePerMinComment() {
+            return this.disablePerMinComment;
         }
 
         @Override
-        public File getLocalFile() {
-            throw new UnsupportedOperationException("Not supported yet.");
+        public int getPerMinCommentSize() {
+            return this.perMinCommentSize;
         }
 
+        @Override
+        public long getBackLogPoint() {
+            return this.backLogPoint;
+        }
     }
 
     private class InqubusGeneralProfile implements GeneralProfile {