OSDN Git Service

TL, DM, SendDMの処理を変更.検索結果を表示するテーブルとの共通部分を統一
authorspark_xp <spark_xp@d8c9ecd3-d47d-4367-8645-de82c00e513f>
Wed, 15 Sep 2010 15:32:44 +0000 (15:32 +0000)
committerspark_xp <spark_xp@d8c9ecd3-d47d-4367-8645-de82c00e513f>
Wed, 15 Sep 2010 15:32:44 +0000 (15:32 +0000)
git-svn-id: http://svn.sourceforge.jp/svnroot/nt-manager/NishioTweetManager/trunk@43 d8c9ecd3-d47d-4367-8645-de82c00e513f

src/twitter/action/TweetDirectMessageGetter.java [new file with mode: 0644]
src/twitter/action/TweetMentionGetter.java
src/twitter/action/TweetSendDirectMessageGetter.java [new file with mode: 0644]
src/twitter/action/TweetTimelineGetter.java [new file with mode: 0644]
src/twitter/gui/action/TweetMainAction.java
src/twitter/gui/form/NishioTweetManager.java

diff --git a/src/twitter/action/TweetDirectMessageGetter.java b/src/twitter/action/TweetDirectMessageGetter.java
new file mode 100644 (file)
index 0000000..5b477ed
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package twitter.action;
+
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import twitter.manage.TweetManager;
+import twitter4j.Status;
+import twitter4j.TwitterException;
+
+/**
+ *
+ * @author nishio
+ */
+public class TweetDirectMessageGetter implements TweetGetter{
+
+    //tweet管理用
+    private TweetManager tweetManager;
+
+    /**
+     *
+     * @param tweetManager
+     */
+    public TweetDirectMessageGetter(TweetManager tweetManager) {
+        this.tweetManager = tweetManager;
+    }
+
+    /**
+     * DirectMessageツイートを指定した数だけ取得
+     * @param num
+     * @return
+     */
+    @Override
+    public List<Status> getTweetData(int num) {
+        List<Status> status = null;
+        try {
+            status = tweetManager.getDirectMessages(num);
+        } catch (TwitterException ex) {
+            Logger.getLogger(TweetMentionGetter.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return status;
+    }
+
+    /**
+     * DirectMessageツイートの新しく投稿されたものだけを取得
+     * @param sinceID
+     * @return
+     */
+    @Override
+    public List<Status> getNewTweetData() {
+        List<Status> status = null;
+        try {
+            status = tweetManager.getNewDirectMessages();
+        } catch (TwitterException ex) {
+            Logger.getLogger(TweetMentionGetter.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return status;
+    }
+
+}
+
index 6614f65..12db606 100644 (file)
@@ -47,7 +47,6 @@ public class TweetMentionGetter implements TweetGetter{
 
     /**
      * Mentionツイートの新しく投稿されたものだけを取得
-     * @param sinceID
      * @return
      */
     @Override
diff --git a/src/twitter/action/TweetSendDirectMessageGetter.java b/src/twitter/action/TweetSendDirectMessageGetter.java
new file mode 100644 (file)
index 0000000..9fcdfb8
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package twitter.action;
+
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import twitter.manage.TweetManager;
+import twitter4j.Status;
+import twitter4j.TwitterException;
+
+/**
+ *
+ * @author nishio
+ */
+public class TweetSendDirectMessageGetter implements TweetGetter{
+
+    //tweet管理用
+    private TweetManager tweetManager;
+
+    /**
+     *
+     * @param tweetManager
+     */
+    public TweetSendDirectMessageGetter(TweetManager tweetManager) {
+        this.tweetManager = tweetManager;
+    }
+
+    /**
+     * SendDMツイートを指定した数だけ取得
+     * @param num
+     * @return
+     */
+    @Override
+    public List<Status> getTweetData(int num) {
+        List<Status> status = null;
+        try {
+            status = tweetManager.getSendDirectMessages(num);
+        } catch (TwitterException ex) {
+            Logger.getLogger(TweetMentionGetter.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return status;
+    }
+
+    /**
+     * SendDMツイートの新しく投稿されたものだけを取得
+     * @param sinceID
+     * @return
+     */
+    @Override
+    public List<Status> getNewTweetData() {
+        List<Status> status = null;
+        try {
+            status = tweetManager.getNewSendDirectMessages();
+        } catch (TwitterException ex) {
+            Logger.getLogger(TweetMentionGetter.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return status;
+    }
+
+}
+
diff --git a/src/twitter/action/TweetTimelineGetter.java b/src/twitter/action/TweetTimelineGetter.java
new file mode 100644 (file)
index 0000000..f59dacc
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package twitter.action;
+
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import twitter.manage.TweetManager;
+import twitter4j.Status;
+import twitter4j.TwitterException;
+
+/**
+ *
+ * @author nishio
+ */
+public class TweetTimelineGetter implements TweetGetter{
+
+    //tweet管理用
+    private TweetManager tweetManager;
+
+    /**
+     *
+     * @param tweetManager
+     */
+    public TweetTimelineGetter(TweetManager tweetManager) {
+        this.tweetManager = tweetManager;
+    }
+
+    /**
+     * timelineツイートを指定した数だけ取得
+     * @param num
+     * @return
+     */
+    @Override
+    public List<Status> getTweetData(int num) {
+        List<Status> status = null;
+        try {
+            status = tweetManager.getTimeline(num);
+        } catch (TwitterException ex) {
+            Logger.getLogger(TweetMentionGetter.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return status;
+    }
+
+    /**
+     * timelineツイートの新しく投稿されたものだけを取得
+     * @return
+     */
+    @Override
+    public List<Status> getNewTweetData() {
+        List<Status> status = null;
+        try {
+            status = tweetManager.getNewTimelineData();
+        } catch (TwitterException ex) {
+            Logger.getLogger(TweetMentionGetter.class.getName()).log(Level.SEVERE, null, ex);
+        }
+        return status;
+    }
+
+}
+
index 63eb542..165c450 100644 (file)
@@ -46,9 +46,12 @@ import javax.swing.text.Style;
 import javax.swing.text.StyleConstants;
 import javax.swing.text.html.HTMLDocument;
 import javax.swing.text.html.StyleSheet;
+import twitter.action.TweetDirectMessageGetter;
 import twitter.action.TweetGetter;
 import twitter.action.TweetMentionGetter;
 import twitter.action.TweetSearchResultGetter;
+import twitter.action.TweetSendDirectMessageGetter;
+import twitter.action.TweetTimelineGetter;
 
 import twitter.gui.component.TweetCommentRenderer;
 import twitter.gui.component.TweetTabbedTable;
@@ -90,7 +93,7 @@ public class TweetMainAction {
         public void run() {
             // 一定時間ごとにTweet情報をアップデート
             try {
-                if (currentGetTimelinePeriodNum == 0) {
+                /*if (currentGetTimelinePeriodNum == 0) {
                     // Tweetテーブルの情報を更新
                     actionTweetTableUpdate();
                 }
@@ -116,7 +119,7 @@ public class TweetMainAction {
                     actionSendDirectMessageTableUpdate();
                 }
                 currentGetSendDirectMessagePeriodNum = (currentGetSendDirectMessagePeriodNum + 1)
-                        % getSendDirectMessagePeriodNum;
+                        % getSendDirectMessagePeriodNum;*/
 
                 //設定ファイルを保存
                 saveProperties();
@@ -204,6 +207,8 @@ public class TweetMainAction {
     public static final String TAB_MENTION_STRING = "Mention";
     // タイムラインタブに表示する文字
     public static final String TAB_TIMELINE_STRING = "Timeline";
+    //Send Direct Messageタブに表示する文字
+    public static final String TAB_SEND_DIRECT_MESSAGE_STRING = "Send";
     // テーブルのデータ量が以下の値を超えたら古いデータから削除
     private static final int TABLE_ELEMENT_MAX_SIZE = 200;
     // twitterの公式URL
@@ -498,17 +503,18 @@ public class TweetMainAction {
     }
 
     /**
-     * mentionã\82\92追å\8a ã\81\99ã\82\8bã\82¿ã\83\96
+     * mentionã\82¿ã\83\96ã\82\92追å\8a ã\81\99ã\82\8b
      * @param period 情報更新間隔[sec]
      */
     public void actionAddMentionTab(int period) {
         TimerID timerID = TimerID.getInstance();
-        String id = timerID.createMentionID();
+        String id = TimerID.createMentionID();
         try {
             //既にIDが存在していたらここで例外発生
             timerID.addID(id);
             //検索結果を表示するタブを生成
-            actionAddTab(id, period, new TweetMentionGetter(tweetManager), this.TAB_MENTION_STRING);
+            actionAddTab(id, period, new TweetMentionGetter(tweetManager),
+                    TweetMainAction.TAB_MENTION_STRING);
         } catch (ExistTimerIDException ex) {
             JOptionPane.showMessageDialog(null, "そのタブは既に存在しています",
                     "Error", JOptionPane.ERROR_MESSAGE);
@@ -516,13 +522,71 @@ public class TweetMainAction {
     }
 
     /**
+     * timelineタブを追加する
+     * @param period[sec]
+     */
+    public void actionAddTimelineTab(int period) {
+        TimerID timerID = TimerID.getInstance();
+        String id = TimerID.createTimelineID();
+        try {
+            //既にIDが存在していたらここで例外発生
+            timerID.addID(id);
+            //検索結果を表示するタブを生成
+            actionAddTab(id, period, new TweetTimelineGetter(tweetManager),
+                    TweetMainAction.TAB_TIMELINE_STRING);
+        } catch (ExistTimerIDException ex) {
+            JOptionPane.showMessageDialog(null, "そのタブは既に存在しています",
+                    "Error", JOptionPane.ERROR_MESSAGE);
+        }
+    }
+
+    /**
+     * ダイレクトメッセージタブを追加する
+     * @param period 更新間隔[sec]
+     */
+    public void actionAddDirectMessageTab(int period) {
+        TimerID timerID = TimerID.getInstance();
+        String id = TimerID.createDirectMessageID();
+        try {
+            //既にIDが存在していたらここで例外発生
+            timerID.addID(id);
+            //検索結果を表示するタブを生成
+            actionAddTab(id, period, new TweetDirectMessageGetter(tweetManager),
+                    TweetMainAction.TAB_DIRECT_MESSAGE_STRING);
+        } catch (ExistTimerIDException ex) {
+            JOptionPane.showMessageDialog(null, "そのタブは既に存在しています",
+                    "Error", JOptionPane.ERROR_MESSAGE);
+        }
+    }
+
+    /**
+     * SendDMタブを追加する
+     * @param period
+     */
+    public void actionAddSendDirectMessageTab(int period) {
+        TimerID timerID = TimerID.getInstance();
+        String id = TimerID.createSendDirectMessageID();
+        try {
+            //既にIDが存在していたらここで例外発生
+            timerID.addID(id);
+            //検索結果を表示するタブを生成
+            actionAddTab(id, period, new TweetSendDirectMessageGetter(tweetManager),
+                    TweetMainAction.TAB_SEND_DIRECT_MESSAGE_STRING);
+        } catch (ExistTimerIDException ex) {
+            JOptionPane.showMessageDialog(null, "そのタブは既に存在しています",
+                    "Error", JOptionPane.ERROR_MESSAGE);
+        }
+    }
+
+
+    /**
      * ツイート検索結果を表示するタブを新しく追加
      * @param searchWord
      * @param period 更新周期[sec] 0以下の場合は更新しない
      */
     public void actionAddNewSearchResultTab(String searchWord, int period) {
         TimerID timerID = TimerID.getInstance();
-        String id = timerID.createSearchTimerID(searchWord);
+        String id = TimerID.createSearchTimerID(searchWord);
         try {
             //既にIDが存在していたらここで例外発生
             timerID.addID(id);
index 57f4621..52d071a 100644 (file)
@@ -802,6 +802,9 @@ public class NishioTweetManager extends javax.swing.JFrame {
 
     private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
         mainAction.actionAddMentionTab(60);
+        mainAction.actionAddTimelineTab(60);
+        mainAction.actionAddDirectMessageTab(60);
+        mainAction.actionAddSendDirectMessageTab(60);
     }//GEN-LAST:event_jMenuItem9ActionPerformed
 
     /**