--- /dev/null
+/*
+ * 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;
+ }
+
+}
+
--- /dev/null
+/*
+ * 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;
+ }
+
+}
+
--- /dev/null
+/*
+ * 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;
+ }
+
+}
+
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;
public void run() {
// 一定時間ごとにTweet情報をアップデート
try {
- if (currentGetTimelinePeriodNum == 0) {
+ /*if (currentGetTimelinePeriodNum == 0) {
// Tweetテーブルの情報を更新
actionTweetTableUpdate();
}
actionSendDirectMessageTableUpdate();
}
currentGetSendDirectMessagePeriodNum = (currentGetSendDirectMessagePeriodNum + 1)
- % getSendDirectMessagePeriodNum;
+ % getSendDirectMessagePeriodNum;*/
//設定ファイルを保存
saveProperties();
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
}
/**
- * 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);
}
/**
+ * 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);