OSDN Git Service

ログを保存しない機能を実装  #23192
authorspark_xp <spark_xp@d8c9ecd3-d47d-4367-8645-de82c00e513f>
Sun, 21 Aug 2011 13:27:55 +0000 (13:27 +0000)
committerspark_xp <spark_xp@d8c9ecd3-d47d-4367-8645-de82c00e513f>
Sun, 21 Aug 2011 13:27:55 +0000 (13:27 +0000)
git-svn-id: http://svn.sourceforge.jp/svnroot/nt-manager/NishioTweetManager/trunk@163 d8c9ecd3-d47d-4367-8645-de82c00e513f

src/twitter/action/TweetTimelineGetter.java
src/twitter/gui/action/TweetMainAction.java
src/twitter/gui/form/NishioTweetManager.form
src/twitter/gui/form/NishioTweetManager.java
src/twitter/manage/TweetManager.java

index f59dacc..f034bdc 100644 (file)
@@ -5,9 +5,12 @@
 
 package twitter.action;
 
+import java.io.IOException;
 import java.util.List;
 import java.util.logging.Level;
 import java.util.logging.Logger;
+import twitter.gui.action.TweetMainAction;
+import twitter.log.TwitterLogManager;
 import twitter.manage.TweetManager;
 import twitter4j.Status;
 import twitter4j.TwitterException;
@@ -20,13 +23,17 @@ public class TweetTimelineGetter implements TweetGetter{
 
     //tweet管理用
     private TweetManager tweetManager;
+    private TweetMainAction mainAction = null;
+    private TwitterLogManager logManager = null;
 
     /**
      *
      * @param tweetManager
      */
-    public TweetTimelineGetter(TweetManager tweetManager) {
+    public TweetTimelineGetter(TweetManager tweetManager, TweetMainAction mainAction) {
         this.tweetManager = tweetManager;
+        this.mainAction = mainAction;
+        this.logManager = new TwitterLogManager();
     }
 
     /**
@@ -39,6 +46,14 @@ public class TweetTimelineGetter implements TweetGetter{
         List<Status> status = null;
         try {
             status = tweetManager.getTimeline(num);
+            if( mainAction.isSaveLog() == true && status != null ) {
+                try {
+                    // ログ保存
+                    logManager.add(status);
+                } catch (IOException ex) {
+                    Logger.getLogger(TweetTimelineGetter.class.getName()).log(Level.SEVERE, null, ex);
+                }
+            }
         } catch (TwitterException ex) {
             Logger.getLogger(TweetMentionGetter.class.getName()).log(Level.SEVERE, null, ex);
         }
@@ -54,6 +69,14 @@ public class TweetTimelineGetter implements TweetGetter{
         List<Status> status = null;
         try {
             status = tweetManager.getNewTimelineData();
+             if( mainAction.isSaveLog() == true && status != null ) {
+                try {
+                    // ログ保存
+                    logManager.add(status);
+                } catch (IOException ex) {
+                    Logger.getLogger(TweetTimelineGetter.class.getName()).log(Level.SEVERE, null, ex);
+                }
+            }
         } catch (TwitterException ex) {
             Logger.getLogger(TweetMentionGetter.class.getName()).log(Level.SEVERE, null, ex);
         }
index d4f10e3..13780ea 100644 (file)
@@ -552,7 +552,7 @@ public class TweetMainAction {
                        // 既にIDが存在していたらここで例外発生
                        timerID.addID(id);
                        // 検索結果を表示するタブを生成
-                       actionAddTab(id, period, new TweetTimelineGetter(tweetManager),
+                       actionAddTab(id, period, new TweetTimelineGetter(tweetManager, this),
                                        TweetMainAction.TAB_TIMELINE_STRING);
                } catch (ExistTimerIDException ex) {
                        JOptionPane.showMessageDialog(null, "そのタブは既に存在しています", "Error",
index e6cb311..09588d2 100644 (file)
               </Group>
               <Group type="102" alignment="0" attributes="0">
                   <Component id="jScrollPane9" min="-2" pref="53" max="-2" attributes="0"/>
-                  <EmptySpace max="32767" attributes="0"/>
+                  <EmptySpace pref="27" max="32767" attributes="0"/>
               </Group>
           </Group>
         </DimensionLayout>
index 97772fa..6b27eac 100644 (file)
@@ -1440,8 +1440,9 @@ private void logSaveCheckItemActionPerformed(java.awt.event.ActionEvent evt) {//
                // twitterログイン
                boolean login = false;
                try {
-                       tweetManager.loginTwitter();
-                       login = true;
+                    tweetManager = new TweetManager();
+                    tweetManager.loginTwitter();
+                    login = true;
                } catch (Exception e) {
                        e.printStackTrace();
                }
@@ -1519,7 +1520,7 @@ private void logSaveCheckItemActionPerformed(java.awt.event.ActionEvent evt) {//
        private JPopupMenu rightClickPopup = null;
        private TweetMainAction mainAction = null;
        // TweetManager
-       private TweetManager tweetManager = new TweetManager();
+       private TweetManager tweetManager = null;
     // Variables declaration - do not modify//GEN-BEGIN:variables
     private javax.swing.JEditorPane clientNameLabel;
     private javax.swing.JLabel followerLabel;
index 62312cc..036a1a8 100644 (file)
@@ -18,7 +18,7 @@ import java.util.Properties;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import twitter.log.TwitterLogManager;
+import twitter.gui.action.TweetMainAction;
 import twitter4j.Annotations;
 import twitter4j.DirectMessage;
 import twitter4j.GeoLocation;
@@ -232,8 +232,6 @@ public class TweetManager {
        private Properties property = null;
        // アカウント設定ファイル
        private Properties accountProperty = null;
-       // ログ保存
-       private TwitterLogManager logManager = null;
 
        //following IDリスト keyはユーザ名, valueはユーザがfollowingしているid
        private Map<String, List<Long>> followingUserIDList = new HashMap<String, List<Long>>();
@@ -241,7 +239,6 @@ public class TweetManager {
         private Map<String, List<Long>> followerUserIDList = new HashMap<String, List<Long>>();
 
        public TweetManager() {
-               logManager = new TwitterLogManager();
        }
 
        /**
@@ -621,15 +618,6 @@ public class TweetManager {
                        Collections.reverse(statuses);
                        tweetList.addAll(statuses);
                }
-               // ログ保存
-               try {
-                       /*
-                        * for (Status s : tweetList) { logManager.add(s); }
-                        */
-                       logManager.add(tweetList);
-               } catch (IOException e) {
-                       e.printStackTrace();
-               }
                // 設定ファイル保存
                try {
                        saveProperties();
@@ -663,15 +651,6 @@ public class TweetManager {
                        Collections.reverse(statuses);
                        tweetList.addAll(statuses);
                }
-               // ログ保存
-               try {
-                       // for (Status s : tweetList) {
-                       // logManager.add(s);
-                       // }
-                       logManager.add(tweetList);
-               } catch (IOException e) {
-                       e.printStackTrace();
-               }
                try {
                        saveProperties();
                } catch (IOException e) {