-public class TweetMainAction {
-
- // 基本設定を保存するファイル名
- public static final String BASIC_SETTING_FILENAME = TweetConfiguration.BASIC_SETTING_FILENAME;
- // httpのパターン
- private static final Pattern convURLLinkPtn = Pattern.compile(
- "(http://|https://){1}[\\w\\.\\-/:\\#\\?\\=\\&\\;\\%\\~\\+]+",
- Pattern.CASE_INSENSITIVE);
- // default char encoding
- private static final String DEFAULT_CHARACTER_ENCODING = "UTF-8";
- // 設定ファイルを保存するディレクトリ名
- public static final String PROPERTIES_DIRECTORY = "properties";
- // search twitterのクエリ
- private static final String SEARCH_QUERY = "search?q=";
- // search twitterのURL
- private static final String SEARCH_TWITTER_URL = "http://search.twitter.com/";
- // Direct Messageタブに表示する文字
- public static final String TAB_DIRECT_MESSAGE_STRING = "Message";
- // Mentionタブに表示する文字
- 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
- private static final String TWITTER_URL = "http://twitter.com/";
- // 基本設定用ダイアログ
- private ConfigurationDialog configurationDialog = null;
- // 現在選択しているStatus情報
- private Status currentStatus = null;
- // 詳細情報パネル
- private JPanel detailInfoPanel = null;
- // ダイレクトメッセージ送信用ダイアログ
- private DirectMessageDialog directMessageDialog = null;
- //Twitter全体からキーワード検索ダイアログ
- private KeywordSearchDialog keywordSearchDialog = null;
- // 新しく取得した部分のテーブルカラー
- private Color newTableColor = new Color(224, 255, 255);
- // TLのフォント名
- private String tlFontName = "Takao Pゴシック";
- // TLのフォントサイズ
- private int tlFontSize = 13;
- // 詳細情報のフォント名
- private String detailFontName = "Takao Pゴシック";
- // 詳細情報のフォントサイズ
- private int detailFontSize = 13;
- // テーブル1要素の高さ
- private int tableElementHeight = 50;
- //メインフレームの幅
- private int mainFrameWidth = 729;
- //メインフレームの高さ
- private int mainFrameHeight = 629;
- // MainFrame
- private JFrame mainFrame = null;
- // 設定
- private Properties property = null;
- // 現在テーブルで選択しているユーザ画像のURL
- private URL selectedUserImageURL = null;
- // 現在テーブルで選択しているユーザの名前
- private String selectedUsername = null;
- // ステータス表示ラベル
- private JLabel statusBarLabel = null;
- // 自分がつぶやきをかく領域
- private JTextPane tweetBoxPane = null;
- //自分がつぶやきを書く領域のスクロールペーン
- private JScrollPane tweetBoxScrollPane = null;
- // tweet情報などを表示するタブ
- private JTabbedPane tweetMainTab = null;
- // Tweet管理
- private TweetManager tweetManager = null;
- // tweetを表示するTextPane
- private JEditorPane tweetMessageBox = null;
- // つぶやくことができる文字数を表示するラベル
- private JLabel tweetMessageCountLabel = null;
- private int uncheckedDirectMessageCount = 0;
- private int uncheckedMentionTweetCount = 0;
-
- //Tweetの詳細情報を表示する部分
- private JLabel userImageLabel = null;
- private JLabel userNameLabel = null;
- private JLabel updateTimeLabel = null;
- private JLabel followerLabel = null;
- private JLabel followingLabel = null;
- private JLabel locationLabel = null;
- private JEditorPane clientNameLabel = null;
- private JLabel updateLabel = null;
- private JEditorPane userIntroBox = null;
- private JEditorPane userWebBox = null;
-
- // 新しく取得したtweetでまだ参照していない数
- private int uncheckedTimelineTweetCount = 0;
- private AboutDialog aboutDialog = null;
- //アカウント情報表示ダイアログ
- private AccountDialog accountDialog;
- //ツイートを表示するテーブル管理
- private List<TweetTabbedTable> tweetTabbedTableList = new ArrayList<TweetTabbedTable>();
- //ツイートテーブルの情報を一定間隔で更新するクラスを作成
- private TweetTaskManager tweetTaskManager = new TweetTaskManager();
-
- //情報更新間隔[sec]
- private int getTimelinePeriod = 60;
- private int getMentionPeriod = 60 * 3;
- private int getDirectMessagePeriod = 60 * 15;
- private int getSendDirectMessagePeriod = 60 * 30;
-
- /**
- *
- * @param mainFrame
- * @param tweetManager
- * @param statusBarLabel
- * @param tweetTableModel
- * @param mentionTableModel
- * @param directMessageTableModel
- * @param sendDirectMessageTableModel
- * @param mainTweetTable
- * @param mentionTable
- * @param directMessageTable
- * @param sendDirectMessageTable
- * @param tweetBoxPane
- * @param tweetBoxScrollPane
- * @param tweetMessageCountLabel
- * @param detailInfoPanel
- * @param tweetMainTab
- * @param tweetMessageBox
- * @param userImageLabel
- * @param userNameLabel
- * @param updateTimeLabel
- * @param followerLabel
- * @param followingLabel
- * @param locationLabel
- * @param clientNameLabel
- * @param updateLabel
- * @param userIntroBox
- * @param userWebBox
- */
- public TweetMainAction(JFrame mainFrame,
- TweetManager tweetManager,
- JLabel statusBarLabel,
- JTextPane tweetBoxPane,
- JScrollPane tweetBoxScrollPane,
- JLabel tweetMessageCountLabel,
- JPanel detailInfoPanel,
- JTabbedPane tweetMainTab,
- JEditorPane tweetMessageBox,
- JLabel userImageLabel,
- JLabel userNameLabel,
- JLabel updateTimeLabel,
- JLabel followerLabel,
- JLabel followingLabel,
- JLabel locationLabel,
- JEditorPane clientNameLabel,
- JLabel updateLabel,
- JEditorPane userIntroBox,
- JEditorPane userWebBox) {
- this.mainFrame = mainFrame;
- this.tweetManager = tweetManager;
- this.statusBarLabel = statusBarLabel;
- this.tweetBoxPane = tweetBoxPane;
- this.tweetMessageCountLabel = tweetMessageCountLabel;
- this.detailInfoPanel = detailInfoPanel;
- this.tweetMainTab = tweetMainTab;
- this.tweetMessageBox = tweetMessageBox;
- this.tweetBoxScrollPane = tweetBoxScrollPane;
-
- //詳細情報部分
- this.userImageLabel = userImageLabel;
- this.userNameLabel = userNameLabel;
- this.updateTimeLabel = updateTimeLabel;
- this.userIntroBox = userIntroBox;
- this.followerLabel = followerLabel;
- this.followingLabel = followingLabel;
- this.locationLabel = locationLabel;
- this.userWebBox = userWebBox;
- this.clientNameLabel = clientNameLabel;
- this.updateLabel = updateLabel;
-
- // 設定ファイルの読み込み
- try {
- loadProperties();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- // フォント情報を反映
- updateFontInformationToComponent();
-
- //フレームの大きさを反映
- mainFrame.setSize(this.mainFrameWidth, this.mainFrameHeight);
- mainFrame.setPreferredSize(new Dimension(this.mainFrameWidth, this.mainFrameHeight));
- }
-
- /**
- * Timeline, Mention , DM, SendDMの情報更新間隔を取得し,その情報をテーブルに反映
- */
- public void updatePeriodInformationToComponent() {
- //すべてのテーブルにフォント情報を反映
- for (TweetTabbedTable t : this.tweetTabbedTableList) {
- String timerID = t.getTimerID();
- if( timerID.equals( TimerID.createTimelineID() ) ) {
- //TLの周期情報更新
- this.tweetTaskManager.updateTaskPeriod(timerID, this.getGetTimelinePeriod());
- }else if( timerID.equals( TimerID.createMentionID() ) ) {
- //Mentionの周期情報更新
- this.tweetTaskManager.updateTaskPeriod(timerID, this.getGetMentionPeriod() );
- }else if( timerID.equals( TimerID.createDirectMessageID() ) ) {
- //DMの周期情報更新
- this.tweetTaskManager.updateTaskPeriod(timerID, this.getGetDirectMessagePeriod());
- }else if( timerID.equals( TimerID.createSendDirectMessageID() ) ) {
- //SendDMの周期情報更新
- this.tweetTaskManager.updateTaskPeriod(timerID, this.getGetSendDirectMessagePeriod());
+public class TweetMainAction implements ConnectionLifeCycleListener{
+
+ // 基本設定を保存するファイル名
+ public static final String BASIC_SETTING_FILENAME = TweetConfiguration.BASIC_SETTING_FILENAME;
+ // httpのパターン
+ private static final Pattern convURLLinkPtn = Pattern.compile(
+ "(http://|https://){1}[\\w\\.\\-/:\\#\\?\\=\\&\\;\\%\\~\\+]+",
+ Pattern.CASE_INSENSITIVE);
+ // default char encoding
+ private static final String DEFAULT_CHARACTER_ENCODING = "UTF-8";
+ // 設定ファイルを保存するディレクトリ名
+ public static final String PROPERTIES_DIRECTORY = "properties";
+ // search twitterのクエリ
+ private static final String SEARCH_QUERY = "search?q=";
+ // search twitterのURL
+ private static final String SEARCH_TWITTER_URL = "http://"
+ + TweetConfiguration.SEARCH_TWITTER_HOSTNAME + "/";
+ // Direct Messageタブに表示する文字
+ public static final String TAB_DIRECT_MESSAGE_STRING = "Message";
+ // Mentionタブに表示する文字
+ 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 int tableElementMaxSize = 200;
+ // twitterの公式URL
+ private static final String TWITTER_URL = "http://twitter.com/";
+ // 基本設定用ダイアログ
+ private ConfigurationDialog configurationDialog = null;
+ // 現在選択しているStatus情報
+ private Status currentStatus = null;
+ // reply予定のStatus
+ private Status replyStatus = null;
+ // 詳細情報パネル
+ private JPanel detailInfoPanel = null;
+ // ダイレクトメッセージ送信用ダイアログ
+ private DirectMessageDialog directMessageDialog = null;
+ // Twitter全体からキーワード検索ダイアログ
+ private KeywordSearchDialog keywordSearchDialog = null;
+ // hashtag search dialog
+ private HashtagSearchDialog hashtagSearchDialog = null;
+ // 新しく取得した部分のテーブルカラー
+ private Color newTableColor = new Color(230,230,250);
+ // TLのフォント名
+ private String tlFontName = "MS Pゴシック";
+ // TLのフォントサイズ
+ private int tlFontSize = 12;
+ // 詳細情報のフォント名
+ private String detailFontName = "MS Pゴシック";
+ // 詳細情報のフォントサイズ
+ private int detailFontSize = 12;
+ // テーブル1要素の高さ
+ private int tableElementHeight = 40;
+ // メインフレームの幅
+ private int mainFrameWidth = 729;
+ // メインフレームの高さ
+ private int mainFrameHeight = 629;
+ // MainFrame
+ private JFrame mainFrame = null;
+ // 設定
+ private Properties property = null;
+ // 現在テーブルで選択しているユーザ画像のURL
+ private URL selectedUserImageURL = null;
+ // 現在テーブルで選択しているユーザの名前
+ private String selectedUsername = null;
+ // ステータス表示ラベル
+ private JLabel statusBarLabel = null;
+ // 自分がつぶやきをかく領域
+ private JTextPane tweetBoxPane = null;
+ // 自分がつぶやきを書く領域のスクロールペーン
+ private JPanel tweetBoxRegionPane = null;
+ // tweet情報などを表示するタブ
+ private JTabbedPane tweetMainTab = null;
+ // Tweet管理
+ private TweetManager tweetManager = null;
+ // tweetを表示するTextPane
+ private JEditorPane tweetMessageBox = null;
+ // つぶやくことができる文字数を表示するラベル
+ private JLabel tweetMessageCountLabel = null;
+ private int uncheckedDirectMessageCount = 0;
+ private int uncheckedMentionTweetCount = 0;
+ // 自分宛のメッセージを通知バーに表示するか
+ private boolean isNotifyMentionMessage = true;
+ private boolean isNotifyDirectMessage = true;
+ //前回開いていたタブの情報を復活する際に利用する(最初の一回だけ利用)
+ private boolean isTempOpenedTimelineTab = true;
+ private boolean isTempOpenedMentionTab = true;
+ private boolean isTempOpenedDMTab = true;
+ private boolean isTempOpenedSendDMTab = true;
+ //ログを保存するかどうか
+ private boolean saveLog = false;
+ //update通知をするかどうか
+ private boolean isUpdateNotify = true;
+ //streaming apiを利用するかどうか
+ private boolean isUsingStreaming = true;
+ //現在streaming apiが開始されているかどうか
+ private boolean isCurrentUsingStreaming = false;
+ //favられた時に通知をするかどうか
+ private boolean favNotify = true;
+
+ // Tweetの詳細情報を表示する部分
+ private JLabel userImageLabel = null;
+ private JLabel userNameLabel = null;
+ private JLabel updateTimeLabel = null;
+ private JLabel followerLabel = null;
+ private JLabel followingLabel = null;
+ private JLabel locationLabel = null;
+ private JEditorPane clientNameLabel = null;
+ private JLabel updateLabel = null;
+ private JEditorPane userIntroBox = null;
+ private JEditorPane userWebBox = null;
+ // トレイアイコン
+ private TrayIcon trayIcon = null;
+
+ // checkbox関係
+ private javax.swing.JToggleButton timelineToggleButton;
+ private javax.swing.JToggleButton mentionToggleButton;
+ private javax.swing.JToggleButton dmToggleButton;
+ private javax.swing.JToggleButton sendDMToggleButton;
+
+ private javax.swing.JCheckBoxMenuItem timelineCheckBoxMenuItem;
+ private javax.swing.JCheckBoxMenuItem mentionCheckBoxMenuItem;
+ private javax.swing.JCheckBoxMenuItem dmCheckBoxMenuItem;
+ private javax.swing.JCheckBoxMenuItem sendCheckBoxMenuItem;
+
+ // 新しく取得したtweetでまだ参照していない数
+ private int uncheckedTimelineTweetCount = 0;
+ private AboutDialog aboutDialog = null;
+ //update dialog
+ private UpdateNotifyDialog updateDialog = null;
+ // アカウント情報表示ダイアログ
+ private AccountDialog accountDialog;
+ // ツイートを表示するテーブル管理
+ private List<TweetTabbedTable> tweetTabbedTableList = new ArrayList<TweetTabbedTable>();
+ // ツイートテーブルの情報を一定間隔で更新するクラスを作成
+ private TweetTaskManager tweetTaskManager = new TweetTaskManager();
+
+ // リストダイアログ
+ private UserListDialog userListDialog = null;
+ //ユーザサーチダイアログ
+ private UserSearchDialog userSearchDialog = null;
+ //CSVログ出力ダイアログ
+ private OutputCSVLogDialog outputCSVLogDialog = null;
+ //following follower表示ダイアログ
+ private FollowingFollowerDialog followingFollowerDialog = null;
+
+ // 情報更新間隔[sec]
+ private int getTimelinePeriod = 60;
+ private int getMentionPeriod = 60 * 3;
+ private int getDirectMessagePeriod = 60 * 15;
+ private int getSendDirectMessagePeriod = 60 * 30;
+
+ /**
+ *
+ * @param mainFrame
+ * @param tweetManager
+ * @param statusBarLabel
+ * @param tweetTableModel
+ * @param mentionTableModel
+ * @param directMessageTableModel
+ * @param sendDirectMessageTableModel
+ * @param mainTweetTable
+ * @param mentionTable
+ * @param directMessageTable
+ * @param sendDirectMessageTable
+ * @param tweetBoxPane
+ * @param tweetBoxScrollPane
+ * @param tweetMessageCountLabel
+ * @param detailInfoPanel
+ * @param tweetMainTab
+ * @param tweetMessageBox
+ * @param userImageLabel
+ * @param userNameLabel
+ * @param updateTimeLabel
+ * @param followerLabel
+ * @param followingLabel
+ * @param locationLabel
+ * @param clientNameLabel
+ * @param updateLabel
+ * @param userIntroBox
+ * @param userWebBox
+ */
+ public TweetMainAction(JFrame mainFrame, TweetManager tweetManager,
+ JLabel statusBarLabel, JTextPane tweetBoxPane,
+ JPanel tweetBoxScrollPane, JLabel tweetMessageCountLabel,
+ JPanel detailInfoPanel, JTabbedPane tweetMainTab,
+ JEditorPane tweetMessageBox, JLabel userImageLabel,
+ JLabel userNameLabel, JLabel updateTimeLabel, JLabel followerLabel,
+ JLabel followingLabel, JLabel locationLabel,
+ JEditorPane clientNameLabel, JLabel updateLabel,
+ JEditorPane userIntroBox, JEditorPane userWebBox,
+ JToggleButton timelineToggleButton,
+ JToggleButton mentionToggleButton, JToggleButton dmToggleButton,
+ JToggleButton sendToggleButton,
+ JCheckBoxMenuItem timelineCheckBoxMenuItem,
+ JCheckBoxMenuItem mentionCheckBoxMenuItem,
+ JCheckBoxMenuItem dmCheckBoxMenuItem,
+ JCheckBoxMenuItem sendCheckBoxMenuItem, TrayIcon trayIcon) {
+ this.mainFrame = mainFrame;
+ this.tweetManager = tweetManager;
+ this.statusBarLabel = statusBarLabel;
+ this.tweetBoxPane = tweetBoxPane;
+ this.tweetMessageCountLabel = tweetMessageCountLabel;
+ this.detailInfoPanel = detailInfoPanel;
+ this.tweetMainTab = tweetMainTab;
+ this.tweetMessageBox = tweetMessageBox;
+ this.tweetBoxRegionPane = tweetBoxScrollPane;
+
+ // 詳細情報部分
+ this.userImageLabel = userImageLabel;
+ this.userNameLabel = userNameLabel;
+ this.updateTimeLabel = updateTimeLabel;
+ this.userIntroBox = userIntroBox;
+ this.followerLabel = followerLabel;
+ this.followingLabel = followingLabel;
+ this.locationLabel = locationLabel;
+ this.userWebBox = userWebBox;
+ this.clientNameLabel = clientNameLabel;
+ this.updateLabel = updateLabel;
+
+ this.timelineCheckBoxMenuItem = timelineCheckBoxMenuItem;
+ this.timelineToggleButton = timelineToggleButton;
+ this.mentionCheckBoxMenuItem = mentionCheckBoxMenuItem;
+ this.mentionToggleButton = mentionToggleButton;
+ this.dmCheckBoxMenuItem = dmCheckBoxMenuItem;
+ this.dmToggleButton = dmToggleButton;
+ this.sendCheckBoxMenuItem = sendCheckBoxMenuItem;
+ this.sendDMToggleButton = sendToggleButton;
+
+ // トレイアイコン
+ this.trayIcon = trayIcon;
+
+ // 罰ボタンを押した時のイベントを追加
+ if (this.tweetMainTab instanceof DnDTabbedPane) {
+ ((DnDTabbedPane) this.tweetMainTab).setMainAction(this);
+ }
+
+ // 設定ファイルの読み込み
+ try {
+ loadProperties();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ // フォント情報を反映
+ updateFontInformationToComponent();
+
+ // フレームの大きさを反映
+ mainFrame.setSize(this.mainFrameWidth, this.mainFrameHeight);
+ mainFrame.setPreferredSize(new Dimension(this.mainFrameWidth,
+ this.mainFrameHeight));
+ //update通知の更新
+ updateNotifyInformation();
+
+ //streaming apiの状態listener設定
+ this.tweetManager.getStreamManager().addCollectionLifeCycleListener(this);
+ }
+
+ /**
+ * チェックボックスの状態を更新
+ */
+ public void updateCheckboxInformation() {
+ boolean timeline = this.isExistTimelineTab();
+ boolean mention = this.isExistMentionTab();
+ boolean dm = this.isExistDirectMessageTab();
+ boolean send = this.isExistSendDirectMessageTab();
+
+ this.timelineCheckBoxMenuItem.setSelected(timeline);
+ this.timelineToggleButton.setSelected(timeline);
+ this.mentionCheckBoxMenuItem.setSelected(mention);
+ this.mentionToggleButton.setSelected(mention);
+ this.dmCheckBoxMenuItem.setSelected(dm);
+ this.dmToggleButton.setSelected(dm);
+ this.sendCheckBoxMenuItem.setSelected(send);
+ this.sendDMToggleButton.setSelected(send);
+ }
+
+ /**
+ * Timeline, Mention , DM, SendDMの情報更新間隔を取得し,その情報をテーブルに反映
+ */
+ public void updatePeriodInformationToComponent() {
+ // すべてのテーブルにフォント情報を反映
+ for (TweetTabbedTable t : this.tweetTabbedTableList) {
+ String timerID = t.getTimerID();
+ if (timerID.equals(TimerID.createTimelineID())) {
+ // TLの周期情報更新
+ if( isCurrentUsingStreaming ) {
+ //streaming api利用時は定期的に情報更新を行わない
+ //更新時間をとてつもなく伸ばすことで対応することにした
+ this.tweetTaskManager.updateTaskPeriod(timerID, 100000, false);
+ }else {
+ this.tweetTaskManager.updateTaskPeriod(timerID, this
+ .getGetTimelinePeriod(), false);
+ }
+ } else if (timerID.equals(TimerID.createMentionID())) {
+ // Mentionの周期情報更新
+ if( isCurrentUsingStreaming ) {
+ this.tweetTaskManager.updateTaskPeriod(timerID, 100000, false);
+ }else {
+ this.tweetTaskManager.updateTaskPeriod(timerID, this
+ .getGetMentionPeriod(), false);
+ }
+ } else if (timerID.equals(TimerID.createDirectMessageID())) {
+ if( isCurrentUsingStreaming ) {
+ this.tweetTaskManager.updateTaskPeriod(timerID, 100000, false);
+ }else{
+ // DMの周期情報更新
+ this.tweetTaskManager.updateTaskPeriod(timerID, this
+ .getGetDirectMessagePeriod(), false);
+ }
+ } else if (timerID.equals(TimerID.createSendDirectMessageID())) {
+ // SendDMの周期情報更新
+ this.tweetTaskManager.updateTaskPeriod(timerID, this
+ .getGetSendDirectMessagePeriod(), false);
+ }
+ }
+ }
+
+ // フォント情報をコンポーネントに反映
+ public void updateFontInformationToComponent() {
+ try {
+ Font tlFont = null;
+ if (this.tlFontName != null) {
+ tlFont = new Font(this.tlFontName, Font.PLAIN, this.tlFontSize);
+ }
+ Font detailFont = null;
+ if (this.detailFontName != null) {
+ detailFont = new Font(this.detailFontName, Font.PLAIN,
+ this.detailFontSize);
+ }
+
+ // すべてのテーブルにフォント情報を反映
+ for (TweetTabbedTable t : this.tweetTabbedTableList) {
+ t.getTable().setFont(tlFont);
+ }
+
+ // tweetメッセージボックスのフォントはhtmlレベルで変更する必要がある
+ this.tweetMessageBox.setFont(detailFont);
+ // htmlフォント変更
+ HTMLDocument doc = (HTMLDocument) this.tweetMessageBox
+ .getDocument();
+ StyleSheet[] style = doc.getStyleSheet().getStyleSheets();
+ for (int i = style.length - 1; i >= 0; i--) {
+ Style body = style[i].getStyle("body");
+ if (body != null) {
+ StyleConstants
+ .setFontFamily(body, detailFont.getFontName());
+ StyleConstants.setFontSize(body, detailFont.getSize());
+ }
+ }
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * notify通知ウィンドウ情報の更新
+ */
+ public void updateNotifyInformation() {
+ //streaming api利用時、fav通知
+ if( this.favNotify ) {
+ this.tweetManager.getStreamManager().setFavNotifyManager(new TweetFavNotifyManager(this.trayIcon));
+ }
+ }
+
+ /**
+ * 新しいタブを追加
+ *
+ * @param timerID
+ * TimerIDクラスで生成したタイマーID
+ * @param period
+ * 情報更新間隔[sec]
+ * @param tweetGetter
+ * 実行するアクション
+ * @param tabTitle
+ * 追加するタブのタイトル
+ */
+ public void actionAddTab(String timerID, int period,
+ TweetGetter tweetGetter, String tabTitle) {
+ // 周期的に情報を更新する
+ if (period > 0) {
+ try {
+ // テーブルを作成
+ final TweetTabbedTable table = new TweetTabbedTable(
+ tweetGetter, tabTitle, this.tweetMainTab,
+ this.tweetManager, this,
+ newTableColor, this.tableElementMaxSize, timerID);
+
+ this.tweetTaskManager.addTask(timerID, new TweetUpdateTask() {
+
+ @Override
+ public void runTask() throws TweetTaskException {
+ // ツイート情報を一定間隔で更新
+ table.updateTweetTable();
+ }
+ });
+ // 更新開始
+ this.tweetTaskManager.startTask(timerID, period * 1000L);
+
+ // タブにテーブルを追加
+ table.addTableToTab();
+ // タブリストに追加
+ this.tweetTabbedTableList.add(table);
+ //設定を保存
+ this.saveProperties();
+ // searchTable.updateTweetTable();
+ // フォーカスを新しいタブに移す
+ this.actionRequestForusToLastTab();
+ } catch (TweetTaskException ex) {
+ Logger.getLogger(TweetMainAction.class.getName()).log(
+ Level.SEVERE, null, ex);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ // フォント情報を更新
+ this.updateFontInformationToComponent();
+ // テーブルの高さをすべて更新
+ this.updateTableHeight(this.getTableElementHeight());
+ }
+
+ /**
+ * mentionタブを追加する
+ *
+ * @param period
+ * 情報更新間隔[sec]
+ */
+ public void actionAddMentionTab(int period) {
+ TimerID timerID = TimerID.getInstance();
+ String id = TimerID.createMentionID();
+ try {
+ // 既にIDが存在していたらここで例外発生
+ timerID.addID(id);
+ // 検索結果を表示するタブを生成
+ if (this.isNotifyMentionMessage) {
+ // メッセージが到着したら通知を行う
+ actionAddTab(id, period, new TweetMentionGetter(tweetManager,
+ this.trayIcon), TweetMainAction.TAB_MENTION_STRING);
+ } else {
+ actionAddTab(id, period, new TweetMentionGetter(tweetManager),
+ TweetMainAction.TAB_MENTION_STRING);
+ }
+ } catch (ExistTimerIDException ex) {
+ JOptionPane.showMessageDialog(null, "そのタブは既に存在しています", "Error",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+
+ /**
+ * お気に入りタブを追加
+ *
+ * @param screenName
+ * nullで自分自身を取得,指定するとscreenNameのFav取得
+ */
+ public void actionAddFavoriteTab(String screenName) {
+ TimerID timerID = TimerID.getInstance();
+ String id = TimerID.createFavoriteID(screenName);
+ try {
+ // 既にIDが存在していたらここで例外発生
+ timerID.addID(id);
+ String favTitle;
+ if (screenName == null) {
+ favTitle = "お気に入り";
+ } else {
+ favTitle = screenName + "のお気に入り";
+ }
+ // 検索結果を表示するタブを生成
+ actionAddTab(id, Integer.MAX_VALUE, new TweetFavoriteGetter(
+ tweetManager, screenName), favTitle);
+ } 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, this),
+ 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);
+ // 検索結果を表示するタブを生成
+ if (this.isNotifyDirectMessage == true) {
+ actionAddTab(id, period, new TweetDirectMessageGetter(
+ tweetManager, this.trayIcon),
+ TweetMainAction.TAB_DIRECT_MESSAGE_STRING);
+ } else {
+ 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 username
+ * @param listID
+ * @param listFullname
+ * @param period
+ */
+ public void actionAddListTab(String username, int listID,
+ String listFullname, int period) {
+ TimerID timerID = TimerID.getInstance();
+ String id = TimerID.createUserListID(username, listID);
+ try {
+ // 既にIDが存在していたらここで例外発生
+ timerID.addID(id);
+ // 検索結果を表示するタブを生成
+ actionAddTab(id, period, new TweetListGetter(tweetManager,
+ username, listID), listFullname);
+ } 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);
+ try {
+ // 既にIDが存在していたらここで例外発生
+ timerID.addID(id);
+ // 検索結果を表示するタブを生成
+ actionAddTab(id, period, new TweetSearchResultGetter(
+ this.tweetManager, searchWord), searchWord);
+ } catch (ExistTimerIDException ex) {
+ JOptionPane.showMessageDialog(null, "そのタブは既に存在しています", "Error",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+
+ /**
+ * 指定したユーザの発言を表示
+ *
+ * @param username
+ * タブのタイトルにつけるユーザ名
+ * @param period
+ * 更新周期[sec]
+ */
+ public void actionAddUserTimelineTab(String username,
+ int period) {
+ TimerID timerID = TimerID.getInstance();
+ String id = TimerID.createUserTimelineID(username);
+ try {
+ // 既にIDが存在していたらここで例外発生
+ timerID.addID(id);
+ // 検索結果を表示するタブを生成
+ actionAddTab(id, period, new TweetUserTimelineGetter(tweetManager,
+ username), username + "の発言");
+ } catch (ExistTimerIDException ex) {
+ JOptionPane.showMessageDialog(null, "そのタブは既に存在しています", "Error",
+ JOptionPane.ERROR_MESSAGE);
+ }
+ }
+
+ /**
+ * タイムラインタブが存在しているか
+ *
+ * @return
+ */
+ public boolean isExistTimelineTab() {
+ TimerID timerID = TimerID.getInstance();
+ String id = TimerID.createTimelineID();
+ return timerID.contains(id);
+ }
+
+ /**
+ * Mentionタブが存在するか
+ *
+ * @return
+ */
+ public boolean isExistMentionTab() {
+ TimerID timerID = TimerID.getInstance();
+ String id = TimerID.createMentionID();
+ return timerID.contains(id);
+ }
+
+ /**
+ * DMタブが存在するか
+ *
+ * @return
+ */
+ public boolean isExistDirectMessageTab() {
+ TimerID timerID = TimerID.getInstance();
+ String id = TimerID.createDirectMessageID();
+ return timerID.contains(id);
+ }
+
+ /**
+ * 送信済みDMタブが存在するか
+ *
+ * @return
+ */
+ public boolean isExistSendDirectMessageTab() {
+ TimerID timerID = TimerID.getInstance();
+ String id = TimerID.createSendDirectMessageID();
+ return timerID.contains(id);
+ }
+
+ /**
+ * 基本設定ダイアログを開く
+ */
+ public void actionBasicSettingDialog() {
+ // ダイレクトメッセージ送信用ダイアログを開く
+ Point loc = getConfigurationDialog().getLocation();
+ loc.translate(20, 20);
+ ConfigurationDialog dialog = getConfigurationDialog();
+ dialog.setLocation(loc);
+ dialog.setVisible(true);
+ }
+
+ /**
+ * reply設定
+ */
+ public void actionSetReplyStatusToTweetBoxPane() {
+ // 選択した部分
+ this.setReplyStatus(currentStatus);
+
+ Status s = this.getCurrentStatus();
+ if (s.isRetweet()) {
+ s = s.getRetweetedStatus();
+ }
+ // コメントしたユーザ名
+ String username = s.getUser().getScreenName();
+ this.tweetBoxPane.setText("@" + username + " ");
+
+ // 情報表示
+ this.information(username + "さんに返信");
+ }
+
+ /**
+ * reply All設定
+ */
+ public void actionSetReplyAllStatusToTweetBoxPane() {
+ // 選択し多分
+ this.setReplyStatus(null);
+
+ Status s = this.getCurrentStatus();
+ if (s.isRetweet()) {
+ s = s.getRetweetedStatus();
+ }
+ // コメントしたユーザ名
+ String username = s.getUser().getScreenName();
+ this.tweetBoxPane.setText("@" + username + " ");
+
+ // 情報表示
+ this.information(username + "さんに返信");
+ }
+
+ /**
+ * 引用Tweet
+ */
+ public void actionSetQuoteStatusToTweetBoxPane() {
+ // 選択した部分
+ this.setReplyStatus(currentStatus);
+ Status s = this.getCurrentStatus();
+ if (s.isRetweet()) {
+ s = s.getRetweetedStatus();
+ }
+ // コメントしたユーザ名
+ String username = s.getUser().getScreenName();
+ // コメント
+ String message = s.getText();
+ this.tweetBoxPane.setText("QT @" + username + ": " + message);
+
+ // 情報表示
+ this.information(username + "さんのメッセージを引用ツイート");
+ }
+
+ /**
+ * 選択したtweetを非公式RT
+ */
+ public void actionCopySelectedStatusToTweetBoxPane() {
+ Status s = this.getCurrentStatus();
+ if (s.isRetweet()) {
+ s = s.getRetweetedStatus();
+ }
+ // コメントしたユーザ名
+ String username = s.getUser().getScreenName();
+ // コメント
+ String message = s.getText();
+ this.tweetBoxPane.setText("RT @" + username + ": " + message);
+ }
+
+ /**
+ * 詳細情報表示ボタンを押した時の動作
+ *
+ * @param e
+ */
+ public void actionDetailInfoButton(ActionEvent e) {
+ if (detailInfoPanel.isVisible()) {
+ detailInfoPanel.setVisible(false);
+ } else {
+ detailInfoPanel.setVisible(true);
+ }
+ }
+
+ /**
+ * 詳細情報ボタンが表示されているか
+ *
+ * @return
+ */
+ public boolean isDetailInfoPanelVisible() {
+ return detailInfoPanel.isVisible();
+ }
+
+ /**
+ * 書き込みメッセージボックスの表示ONOFFボタンを押した時の動作
+ *
+ * @param e
+ */
+ public void actionShowTweetboxButton(ActionEvent e) {
+ if (this.tweetBoxRegionPane.isVisible()) {
+ this.tweetBoxRegionPane.setVisible(false);
+ } else {
+ this.tweetBoxRegionPane.setVisible(true);
+ }
+ }
+
+ /**
+ * 書き込みメッセージボックス領域が表示されているか
+ */
+ public boolean isShowTweetBoxVisible() {
+ return this.tweetBoxRegionPane.isVisible();
+ }
+
+ /**
+ * 選択しているタブを削除
+ */
+ public void actionRemoveFocusedTabbedTable() {
+ int selected = this.tweetMainTab.getSelectedIndex();
+ actionRemoveTabbedTable(selected);
+ }
+
+ /**
+ * 指定したIDのタブを削除
+ *
+ * @param timerID
+ */
+ public void actionRemoveTabbedTable(String timerID) {
+ int deleteTabIndex = -1;
+
+ for (int i = 0; i < tweetTabbedTableList.size(); i++) {
+ TweetTabbedTable table = tweetTabbedTableList.get(i);
+ if (table.getTimerID().equals(timerID)) {
+ // 消したいタブが見つかった
+ deleteTabIndex = i;
+ break;
+ }
+ }
+ actionRemoveTabbedTable(deleteTabIndex);
+ }
+
+ /**
+ * 指定した場所にあるタブを削除
+ *
+ * @param removeTabIndex
+ */
+ public void actionRemoveTabbedTable(int removeTabIndex) {
+ int selected = removeTabIndex;
+ // タブの何番目に消したいテーブルがあるのかと,tweetTabbedTableListの何番目に消したいテーブルがあるのかは違う
+ // これを探してくる必要がある
+
+ // 選択したタブのテーブルを取得
+ int deleteTabIndex = -1;
+ for (int i = 0; i < tweetTabbedTableList.size(); i++) {
+ TweetTabbedTable table = tweetTabbedTableList.get(i);
+ if (selected == table.getTabSetNum()) {
+ // 消したいタブが見つかった
+ deleteTabIndex = i;
+ break;
+ }
+ }
+
+ if (deleteTabIndex >= 0) {
+ // タブを削除
+ this.tweetMainTab.remove(selected);
+ // タブのタイマーID
+ String timerID = this.tweetTabbedTableList.get(deleteTabIndex)
+ .getTimerID();
+ // 削除
+ TweetTabbedTable table = this.tweetTabbedTableList.get(deleteTabIndex);
+ if( table != null ) {
+ //streaming api使っている場合はlistenerをストップ
+ TweetGetter getter = table.getTweetGetter();
+ if( getter != null ) {
+ //streaming apiのストップ
+ getter.stopUpdateListener();
+ }
+ }
+ // 削除
+ this.tweetTabbedTableList.remove(deleteTabIndex);
+ // 自動更新しているタブを削除
+ this.tweetTaskManager.shutdownTask(timerID);
+ // ID削除
+ TimerID idManager = TimerID.getInstance();
+ idManager.removeID(timerID);
+
+ // checkboxの状態更新
+ this.updateCheckboxInformation();
+ //設定保存
+ try {
+ saveProperties();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * 終了ボタンを押した時の動作
+ *
+ * @param e
+ */
+ public void actionExitButton(ActionEvent e) {
+ System.exit(0);
+ }
+
+ /**
+ * 選択した発言をブラウザで開く
+ */
+ public void actionOpenStatusURL() {
+ try {
+ // ユーザ名
+ String userName = this.getCurrentStatus().getUser().getScreenName();
+ // 発言のstatusID
+ long statusID = this.getCurrentStatus().getId();
+ Desktop.getDesktop().browse(
+ new URI(TWITTER_URL + userName + "/statuses/" + statusID));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ JOptionPane.showMessageDialog(null, "エラーによりブラウザを起動できませんでした.",
+ "Error", JOptionPane.ERROR_MESSAGE);
+ }
+ }
+
+ /**
+ * 選択したユーザのfollowingを表示
+ */
+ public void actionOpenFollowing() {
+ // ユーザ名
+ try {
+ String userName = this.getCurrentStatus().getUser().getScreenName();
+ this.actionShowFollowingFollowerDialog(userName, true);
+ }catch(Exception e) {
+ e.printStackTrace();