1 package twitter.gui.action;
4 import java.awt.Desktop;
5 import java.awt.Dimension;
8 import java.awt.event.ActionEvent;
10 import java.io.FileInputStream;
11 import java.io.FileNotFoundException;
12 import java.io.FileOutputStream;
13 import java.io.IOException;
14 import java.io.UnsupportedEncodingException;
17 import java.net.URLEncoder;
18 import java.text.DateFormat;
19 import java.util.ArrayList;
20 import java.util.List;
21 import java.util.Properties;
23 import java.util.TreeSet;
24 import java.util.logging.Level;
25 import java.util.logging.Logger;
26 import java.util.regex.Matcher;
27 import java.util.regex.Pattern;
28 import javax.swing.ImageIcon;
30 import javax.swing.JEditorPane;
31 import javax.swing.JFrame;
32 import javax.swing.JLabel;
33 import javax.swing.JOptionPane;
34 import javax.swing.JPanel;
35 import javax.swing.JScrollPane;
36 import javax.swing.JTabbedPane;
37 import javax.swing.JTable;
38 import javax.swing.JTextPane;
39 import javax.swing.table.TableModel;
40 import javax.swing.text.Style;
41 import javax.swing.text.StyleConstants;
42 import javax.swing.text.html.HTMLDocument;
43 import javax.swing.text.html.StyleSheet;
44 import twitter.action.TweetDirectMessageGetter;
45 import twitter.action.TweetGetter;
46 import twitter.action.TweetMentionGetter;
47 import twitter.action.TweetSearchResultGetter;
48 import twitter.action.TweetSendDirectMessageGetter;
49 import twitter.action.TweetTimelineGetter;
51 import twitter.gui.component.TweetTabbedTable;
52 import twitter.gui.component.TweetTableModel;
53 import twitter.gui.form.AboutDialog;
54 import twitter.gui.form.AccountDialog;
55 import twitter.gui.form.ConfigurationDialog;
56 import twitter.gui.form.DirectMessageDialog;
57 import twitter.gui.form.KeywordSearchDialog;
58 import twitter.manage.TweetConfiguration;
59 import twitter.manage.TweetManager;
60 import twitter.task.ExistTimerIDException;
61 import twitter.task.TimerID;
62 import twitter.task.TweetTaskException;
63 import twitter.task.TweetTaskManager;
64 import twitter.task.TweetUpdateTask;
65 import twitter4j.Status;
66 import twitter4j.TwitterException;
74 public class TweetMainAction {
77 public static final String BASIC_SETTING_FILENAME = TweetConfiguration.BASIC_SETTING_FILENAME;
79 private static final Pattern convURLLinkPtn = Pattern.compile(
80 "(http://|https://){1}[\\w\\.\\-/:\\#\\?\\=\\&\\;\\%\\~\\+]+",
81 Pattern.CASE_INSENSITIVE);
82 // default char encoding
83 private static final String DEFAULT_CHARACTER_ENCODING = "UTF-8";
85 public static final String PROPERTIES_DIRECTORY = "properties";
87 private static final String SEARCH_QUERY = "search?q=";
89 private static final String SEARCH_TWITTER_URL = "http://search.twitter.com/";
90 // Direct Messageタブに表示する文字
91 public static final String TAB_DIRECT_MESSAGE_STRING = "Message";
93 public static final String TAB_MENTION_STRING = "Mention";
95 public static final String TAB_TIMELINE_STRING = "Timeline";
96 //Send Direct Messageタブに表示する文字
97 public static final String TAB_SEND_DIRECT_MESSAGE_STRING = "Send";
98 // テーブルのデータ量が以下の値を超えたら古いデータから削除
99 private static final int TABLE_ELEMENT_MAX_SIZE = 200;
101 private static final String TWITTER_URL = "http://twitter.com/";
103 private ConfigurationDialog configurationDialog = null;
105 private Status currentStatus = null;
107 private JPanel detailInfoPanel = null;
108 // ダイレクトメッセージ送信用ダイアログ
109 private DirectMessageDialog directMessageDialog = null;
110 //Twitter全体からキーワード検索ダイアログ
111 private KeywordSearchDialog keywordSearchDialog = null;
113 private Color newTableColor = new Color(224, 255, 255);
115 private String tlFontName = "Takao Pゴシック";
117 private int tlFontSize = 13;
119 private String detailFontName = "Takao Pゴシック";
121 private int detailFontSize = 13;
123 private int tableElementHeight = 50;
125 private int mainFrameWidth = 729;
127 private int mainFrameHeight = 629;
129 private JFrame mainFrame = null;
131 private Properties property = null;
132 // 現在テーブルで選択しているユーザ画像のURL
133 private URL selectedUserImageURL = null;
134 // 現在テーブルで選択しているユーザの名前
135 private String selectedUsername = null;
137 private JLabel statusBarLabel = null;
139 private JTextPane tweetBoxPane = null;
140 //自分がつぶやきを書く領域のスクロールペーン
141 private JScrollPane tweetBoxScrollPane = null;
143 private JTabbedPane tweetMainTab = null;
145 private TweetManager tweetManager = null;
146 // tweetを表示するTextPane
147 private JEditorPane tweetMessageBox = null;
148 // つぶやくことができる文字数を表示するラベル
149 private JLabel tweetMessageCountLabel = null;
150 private int uncheckedDirectMessageCount = 0;
151 private int uncheckedMentionTweetCount = 0;
154 private JLabel userImageLabel = null;
155 private JLabel userNameLabel = null;
156 private JLabel updateTimeLabel = null;
157 private JLabel followerLabel = null;
158 private JLabel followingLabel = null;
159 private JLabel locationLabel = null;
160 private JEditorPane clientNameLabel = null;
161 private JLabel updateLabel = null;
162 private JEditorPane userIntroBox = null;
163 private JEditorPane userWebBox = null;
165 // 新しく取得したtweetでまだ参照していない数
166 private int uncheckedTimelineTweetCount = 0;
167 private AboutDialog aboutDialog = null;
169 private AccountDialog accountDialog;
171 private List<TweetTabbedTable> tweetTabbedTableList = new ArrayList<TweetTabbedTable>();
172 //ツイートテーブルの情報を一定間隔で更新するクラスを作成
173 private TweetTaskManager tweetTaskManager = new TweetTaskManager();
176 private int getTimelinePeriod = 60;
177 private int getMentionPeriod = 60 * 3;
178 private int getDirectMessagePeriod = 60 * 15;
179 private int getSendDirectMessagePeriod = 60 * 30;
184 * @param tweetManager
185 * @param statusBarLabel
186 * @param tweetTableModel
187 * @param mentionTableModel
188 * @param directMessageTableModel
189 * @param sendDirectMessageTableModel
190 * @param mainTweetTable
191 * @param mentionTable
192 * @param directMessageTable
193 * @param sendDirectMessageTable
194 * @param tweetBoxPane
195 * @param tweetBoxScrollPane
196 * @param tweetMessageCountLabel
197 * @param detailInfoPanel
198 * @param tweetMainTab
199 * @param tweetMessageBox
200 * @param userImageLabel
201 * @param userNameLabel
202 * @param updateTimeLabel
203 * @param followerLabel
204 * @param followingLabel
205 * @param locationLabel
206 * @param clientNameLabel
208 * @param userIntroBox
211 public TweetMainAction(JFrame mainFrame,
212 TweetManager tweetManager,
213 JLabel statusBarLabel,
214 JTextPane tweetBoxPane,
215 JScrollPane tweetBoxScrollPane,
216 JLabel tweetMessageCountLabel,
217 JPanel detailInfoPanel,
218 JTabbedPane tweetMainTab,
219 JEditorPane tweetMessageBox,
220 JLabel userImageLabel,
221 JLabel userNameLabel,
222 JLabel updateTimeLabel,
223 JLabel followerLabel,
224 JLabel followingLabel,
225 JLabel locationLabel,
226 JEditorPane clientNameLabel,
228 JEditorPane userIntroBox,
229 JEditorPane userWebBox) {
230 this.mainFrame = mainFrame;
231 this.tweetManager = tweetManager;
232 this.statusBarLabel = statusBarLabel;
233 this.tweetBoxPane = tweetBoxPane;
234 this.tweetMessageCountLabel = tweetMessageCountLabel;
235 this.detailInfoPanel = detailInfoPanel;
236 this.tweetMainTab = tweetMainTab;
237 this.tweetMessageBox = tweetMessageBox;
238 this.tweetBoxScrollPane = tweetBoxScrollPane;
241 this.userImageLabel = userImageLabel;
242 this.userNameLabel = userNameLabel;
243 this.updateTimeLabel = updateTimeLabel;
244 this.userIntroBox = userIntroBox;
245 this.followerLabel = followerLabel;
246 this.followingLabel = followingLabel;
247 this.locationLabel = locationLabel;
248 this.userWebBox = userWebBox;
249 this.clientNameLabel = clientNameLabel;
250 this.updateLabel = updateLabel;
255 } catch (FileNotFoundException e) {
257 } catch (IOException e) {
261 updateFontInformationToComponent();
264 mainFrame.setSize(this.mainFrameWidth, this.mainFrameHeight);
265 mainFrame.setPreferredSize(new Dimension(this.mainFrameWidth, this.mainFrameHeight));
269 public void updateFontInformationToComponent() {
272 if (this.tlFontName != null) {
273 tlFont = new Font(this.tlFontName, Font.PLAIN, this.tlFontSize);
275 Font detailFont = null;
276 if (this.detailFontName != null) {
277 detailFont = new Font(this.detailFontName, Font.PLAIN,
278 this.detailFontSize);
282 for( TweetTabbedTable t : this.tweetTabbedTableList) {
283 t.getTable().setFont(tlFont);
286 // tweetメッセージボックスのフォントはhtmlレベルで変更する必要がある
287 this.tweetMessageBox.setFont(detailFont);
289 HTMLDocument doc = (HTMLDocument) this.tweetMessageBox.getDocument();
290 StyleSheet[] style = doc.getStyleSheet().getStyleSheets();
291 for (int i = style.length - 1; i >= 0; i--) {
292 Style body = style[i].getStyle("body");
294 StyleConstants.setFontFamily(body, detailFont.getFontName());
295 StyleConstants.setFontSize(body, detailFont.getSize());
299 } catch (Exception e) {
306 * @param timerID TimerIDクラスで生成したタイマーID
307 * @param period 情報更新間隔[sec]
308 * @param tweetGetter 実行するアクション
309 * @param tabTitle 追加するタブのタイトル
311 public void actionAddTab(String timerID, int period, TweetGetter tweetGetter, String tabTitle) {
312 int numOfTab = this.tweetTabbedTableList.size();
319 final TweetTabbedTable table = new TweetTabbedTable(tweetGetter, tabTitle,
320 this.tweetMainTab, numOfTab,
321 this.tableElementHeight, this.tweetManager,
322 this, newTableColor, tableElementHeight, timerID);
324 this.tweetTaskManager.addTask(timerID, new TweetUpdateTask() {
327 public void runTask() throws TweetTaskException {
329 table.updateTweetTable();
333 this.tweetTaskManager.startTask(timerID, period * 1000L);
336 table.addTableToTab();
338 this.tweetTabbedTableList.add(table);
339 //searchTable.updateTweetTable();
340 } catch (TweetTaskException ex) {
341 Logger.getLogger(TweetMainAction.class.getName()).log(Level.SEVERE, null, ex);
346 this.updateFontInformationToComponent();
348 this.updateTableHeight( this.getTableElementHeight() );
353 * @param period 情報更新間隔[sec]
355 public void actionAddMentionTab(int period) {
356 TimerID timerID = TimerID.getInstance();
357 String id = TimerID.createMentionID();
359 //既にIDが存在していたらここで例外発生
362 actionAddTab(id, period, new TweetMentionGetter(tweetManager),
363 TweetMainAction.TAB_MENTION_STRING);
364 } catch (ExistTimerIDException ex) {
365 JOptionPane.showMessageDialog(null, "そのタブは既に存在しています",
366 "Error", JOptionPane.ERROR_MESSAGE);
374 public void actionAddTimelineTab(int period) {
375 TimerID timerID = TimerID.getInstance();
376 String id = TimerID.createTimelineID();
378 //既にIDが存在していたらここで例外発生
381 actionAddTab(id, period, new TweetTimelineGetter(tweetManager),
382 TweetMainAction.TAB_TIMELINE_STRING);
383 } catch (ExistTimerIDException ex) {
384 JOptionPane.showMessageDialog(null, "そのタブは既に存在しています",
385 "Error", JOptionPane.ERROR_MESSAGE);
391 * @param period 更新間隔[sec]
393 public void actionAddDirectMessageTab(int period) {
394 TimerID timerID = TimerID.getInstance();
395 String id = TimerID.createDirectMessageID();
397 //既にIDが存在していたらここで例外発生
400 actionAddTab(id, period, new TweetDirectMessageGetter(tweetManager),
401 TweetMainAction.TAB_DIRECT_MESSAGE_STRING);
402 } catch (ExistTimerIDException ex) {
403 JOptionPane.showMessageDialog(null, "そのタブは既に存在しています",
404 "Error", JOptionPane.ERROR_MESSAGE);
412 public void actionAddSendDirectMessageTab(int period) {
413 TimerID timerID = TimerID.getInstance();
414 String id = TimerID.createSendDirectMessageID();
416 //既にIDが存在していたらここで例外発生
419 actionAddTab(id, period, new TweetSendDirectMessageGetter(tweetManager),
420 TweetMainAction.TAB_SEND_DIRECT_MESSAGE_STRING);
421 } catch (ExistTimerIDException ex) {
422 JOptionPane.showMessageDialog(null, "そのタブは既に存在しています",
423 "Error", JOptionPane.ERROR_MESSAGE);
429 * ツイート検索結果を表示するタブを新しく追加
431 * @param period 更新周期[sec] 0以下の場合は更新しない
433 public void actionAddNewSearchResultTab(String searchWord, int period) {
434 TimerID timerID = TimerID.getInstance();
435 String id = TimerID.createSearchTimerID(searchWord);
437 //既にIDが存在していたらここで例外発生
440 actionAddTab(id, period, new TweetSearchResultGetter(this.tweetManager, searchWord), searchWord);
441 } catch (ExistTimerIDException ex) {
442 JOptionPane.showMessageDialog(null, "そのタブは既に存在しています",
443 "Error", JOptionPane.ERROR_MESSAGE);
450 public void actionBasicSettingDialog() {
451 // ダイレクトメッセージ送信用ダイアログを開く
452 Point loc = getConfigurationDialog().getLocation();
453 loc.translate(20, 20);
454 ConfigurationDialog dialog = getConfigurationDialog();
455 dialog.setLocation(loc);
456 dialog.setVisible(true);
462 public void actionCopySelectedStatusToTweetBoxPane() {
464 String username = this.currentStatus.getUser().getScreenName();
466 String message = this.currentStatus.getText();
467 this.tweetBoxPane.setText("RT: @" + username + ": " + message);
475 public void actionDetailInfoButton(ActionEvent e) {
476 if (detailInfoPanel.isVisible()) {
477 detailInfoPanel.setVisible(false);
479 detailInfoPanel.setVisible(true);
484 * 書き込みメッセージボックスの表示ONOFFボタンを押した時の動作
487 public void actionShowTweetboxButton(ActionEvent e) {
488 if( this.tweetBoxScrollPane.isVisible() ) {
489 this.tweetBoxScrollPane.setVisible(false);
491 this.tweetBoxScrollPane.setVisible(true);
498 public void actionRemoveFocusedTabbedTable() {
499 int selected = this.tweetMainTab.getSelectedIndex();
500 int deleteTabIndex = selected;
502 if( deleteTabIndex >= 0 ) {
504 this.tweetMainTab.remove(deleteTabIndex);
505 int tabSetNum = this.tweetTabbedTableList.get(deleteTabIndex).getTabSetNum();
507 String timerID = this.tweetTabbedTableList.get(deleteTabIndex).getTimerID();
510 this.tweetTabbedTableList.remove(deleteTabIndex);
512 //削除した分,既存のタブ番号を1つずつずらさなければならない
513 int tabNum = this.tweetTabbedTableList.size();
514 for(int i = tabSetNum; i < tabNum; i++) {
515 TweetTabbedTable table = this.tweetTabbedTableList.get( i );
516 table.setTabSetNum( table.getTabSetNum() - 1);
520 this.tweetTaskManager.shutdownTask( timerID );
522 TimerID idManager = TimerID.getInstance();
523 idManager.removeID(timerID);
532 public void actionExitButton(ActionEvent e) {
539 public void actionOpenStatusURL() {
542 String userName = this.currentStatus.getUser().getScreenName();
544 long statusID = this.currentStatus.getId();
545 Desktop.getDesktop().browse(
546 new URI(TWITTER_URL + userName + "/statuses/" + statusID));
547 } catch (Exception ex) {
548 ex.printStackTrace();
549 JOptionPane.showMessageDialog(null, "エラーによりブラウザを起動できませんでした.",
550 "Error", JOptionPane.ERROR_MESSAGE);
557 public void actionOpenUserURL() {
559 String userName = this.currentStatus.getUser().getScreenName();
560 Desktop.getDesktop().browse(new URI(TWITTER_URL + userName));
561 } catch (Exception ex) {
562 ex.printStackTrace();
563 JOptionPane.showMessageDialog(null, "エラーによりブラウザを起動できませんでした.",
564 "Error", JOptionPane.ERROR_MESSAGE);
571 public void actionRefreshTime() {
573 for(TweetTabbedTable t : this.tweetTabbedTableList ) {
574 TweetTableModel model = t.getModel();
575 if( model != null ) {
582 * TweetMessageBox内にある#ハッシュタグ の部分をa hrefリンクに変換
586 public String actionReplaceTweetMessageBoxHashTab(String message) {
588 Pattern userPtn = Pattern.compile("#[0-9A-Z_]+",
589 Pattern.CASE_INSENSITIVE);
590 Matcher matcher = userPtn.matcher(message);
592 * if( matcher.matches() ) { matcher. }
595 Set<String> findList = new TreeSet<String>();
596 while (matcher.find()) {
597 findList.add(matcher.group(0));
600 for (String f : findList) {
602 message = message.replaceAll(f, "<a href=\""
603 + SEARCH_TWITTER_URL + SEARCH_QUERY
604 + URLEncoder.encode(f, DEFAULT_CHARACTER_ENCODING)
605 + "\">" + f + "</a>");
606 } catch (UnsupportedEncodingException e) {
614 * TweetMessageBox内にあるリンクをa hrefリンクに変換
618 public String actionReplaceTweetMessageBoxURLLink(String message) {
619 Matcher matcher = convURLLinkPtn.matcher(message);
620 return matcher.replaceAll("<a href=\"$0\">$0</a>");
624 * @ユーザ名の部分をa hrefリンクに変換
627 public String actionReplaceTweetMessageBoxUserInfo(String message) {
629 Pattern userPtn = Pattern.compile("@[0-9A-Z_]+",
630 Pattern.CASE_INSENSITIVE);
631 Matcher matcher = userPtn.matcher(message);
633 Set<String> findList = new TreeSet<String>();
634 while (matcher.find()) {
635 findList.add(matcher.group(0));
637 // 指定したユーザ名をすべてリンクへ変更
638 for (String f : findList) {
639 message = message.replaceAll(f, "<a href=\"" + TWITTER_URL
640 + f.substring(1) + "\">" + f + "</a>");
646 * まだ見ていないdirectMessage数を0にする
648 public void actionResetUncheckedDirectMessageCount() {
649 uncheckedDirectMessageCount = 0;
650 tweetMainTab.setTitleAt(2, TAB_DIRECT_MESSAGE_STRING);
654 * まだ見ていないmention数を0にする
656 public void actionResetUncheckedMentionTweetCount() {
657 uncheckedMentionTweetCount = 0;
658 tweetMainTab.setTitleAt(1, TAB_MENTION_STRING);
664 public void actionResetUncheckedTimelineTweetCount() {
665 uncheckedTimelineTweetCount = 0;
666 tweetMainTab.setTitleAt(0, TAB_TIMELINE_STRING);
670 * 現在選択しているステータスを公式Retweet
672 public void actionRetweet() {
673 // 選択しているtweetのstatus id
674 long statusID = this.currentStatus.getId();
676 String username = this.currentStatus.getUser().getScreenName();
678 String message = this.currentStatus.getText();
680 if (message.length() > 30) {
681 message = message.substring(0, 30) + " ...(以下略)";
683 // Retweetしていいかどうかの確認
684 int ret = JOptionPane.showConfirmDialog(mainFrame, username + " さんの発言:"
685 + message + "\nをRetweetしますか?", "Retweetの確認",
686 JOptionPane.YES_NO_OPTION);
687 if (ret == JOptionPane.YES_OPTION) {
690 this.tweetManager.retweet(statusID);
691 } catch (TwitterException e) {
692 JOptionPane.showMessageDialog(null, "エラーによりRetweetできませんでした.",
693 "Retweet Error", JOptionPane.ERROR_MESSAGE);
703 public void updateTableHeight(int height) {
704 this.tableElementHeight = height;
705 for( TweetTabbedTable t : this.tweetTabbedTableList) {
706 t.getTable().setRowHeight(tableElementHeight);
713 public void actionShowDirectMessageDialog() {
714 // ダイレクトメッセージ送信用ダイアログを開く
715 Point loc = getDirectMessageDialog().getLocation();
716 //loc.translate(20, 20);
717 DirectMessageDialog dialog = getDirectMessageDialog();
718 //dialog.setLocation(loc);
719 dialog.setLocationRelativeTo(null);
720 dialog.setVisible(true);
721 dialog.setUserInformation(this.selectedUsername,
722 this.selectedUserImageURL, this.tweetManager);
728 public void actionShowAboutDialog() {
729 Point loc = getDirectMessageDialog().getLocation();
730 //loc.translate(20, 20);
731 AboutDialog dialog = getAboutDialog();
732 dialog.setLocationRelativeTo(null);
733 //dialog.setLocation(loc);
734 dialog.setVisible(true);
740 public void actionShowAccountDialog() {
741 Point loc = getDirectMessageDialog().getLocation();
742 //loc.translate(20, 20);
743 AccountDialog dialog = getAccountDialog();
744 dialog.setLocationRelativeTo(null);
745 // dialog.setLocation(loc);
746 dialog.setVisible(true);
750 * Twitter全体からキーワード検索ダイアログを表示
752 public void actionShowKeywordSearchDialog() {
753 Point loc = getDirectMessageDialog().getLocation();
754 KeywordSearchDialog dialog = getKeywordSearchDialog();
755 dialog.setLocationRelativeTo(null);
756 dialog.setVisible(true);
760 * tweetBoxPaneに書かれた文字をつぶやく
762 public void actionTweet() {
763 tweetManager.tweet(tweetBoxPane.getText());
764 tweetBoxPane.setText(""); // テキストをクリア
772 public void actionUpdateButton(java.awt.event.ActionEvent e) {
775 for(TweetTabbedTable t : this.tweetTabbedTableList ) {
776 t.updateTweetTable();
780 int remainingHits = tweetManager.getRateLimitStatus().getRemainingHits();
781 // 取得したコメント数をステータスバーに表示
784 + " 件の新しいツイートを取得しました. (APIリクエスト残数は" + remainingHits
786 } catch (Exception e1) {
787 e1.printStackTrace();
796 public void actionUpdateTweetMessageCount() {
797 int len = 140 - (tweetBoxPane.getText().length());
801 tweetMessageCountLabel.setText(len + "");
809 public ConfigurationDialog getConfigurationDialog() {
810 if (configurationDialog == null) {
811 configurationDialog = new ConfigurationDialog(mainFrame, this);
813 return configurationDialog;
817 * twitter全体からキーワード検索ダイアログを表示
820 public KeywordSearchDialog getKeywordSearchDialog() {
821 if( keywordSearchDialog == null ) {
822 keywordSearchDialog = new KeywordSearchDialog(mainFrame, true, this);
824 return keywordSearchDialog;
831 public AccountDialog getAccountDialog() {
832 if( accountDialog == null ) {
833 accountDialog = new AccountDialog(mainFrame, true, tweetManager, this);
835 return accountDialog;
839 * ダイレクトメッセージ送信用ダイアログを取得
843 public DirectMessageDialog getDirectMessageDialog() {
844 if (directMessageDialog == null) {
845 directMessageDialog = new DirectMessageDialog(mainFrame);
846 directMessageDialog.setTitle("ダイレクトメッセージを送信");
848 return directMessageDialog;
852 * テーブルで選択したツイートを詳細情報としてセット
855 public void setDetailInformationFromTable(JTable table) {
856 int sc = table.getSelectedRowCount();
857 String infoMessage = "";
860 Status st = getTweetTableInformation(table, table.getModel());
861 infoMessage = st.getText();
862 // tweetMessageBox内のURLをhtmlリンクへ変換
863 infoMessage = actionReplaceTweetMessageBoxURLLink(infoMessage);
865 infoMessage = actionReplaceTweetMessageBoxUserInfo(infoMessage);
866 // #ハッシュタグ情報をhtmlリンクへ変換
867 infoMessage = actionReplaceTweetMessageBoxHashTab(infoMessage);
868 // 詳細情報にテーブルで選択した人のツイート情報を表示
869 tweetMessageBox.setText(infoMessage);
871 userImageLabel.setIcon(new ImageIcon(st.getUser().getProfileImageURL()));
873 userNameLabel.setText(st.getUser().getName()
874 + " / " + st.getUser().getScreenName());
876 updateTimeLabel.setText(DateFormat.getInstance().format( st.getCreatedAt() ));
878 userIntroBox.setText(st.getUser().getDescription());
880 followerLabel.setText(st.getUser().getFollowersCount()
883 followingLabel.setText(st.getUser().getFriendsCount()
886 locationLabel.setText(st.getUser().getLocation());
888 if (st.getUser().getURL() != null) {
889 userWebBox.setText("<a href=\""
890 + st.getUser().getURL() + "\">"
891 + st.getUser().getScreenName()
892 + "のWebを開く" + "</a>");
894 userWebBox.setText("");
897 clientNameLabel.setText(" via " + st.getSource());
899 updateLabel.setText(st.getUser().getStatusesCount()
908 public AboutDialog getAboutDialog() {
909 if (aboutDialog == null) {
910 aboutDialog = new AboutDialog(mainFrame, true);
916 * テーブルで選択した場所のTweet情報を取得
920 public Status getTweetTableInformation(JTable table, TableModel model) {
921 int index = table.convertRowIndexToModel(table.getSelectedRow());
922 Status status = null;
923 if (model instanceof TweetTableModel) {
924 status = ((TweetTableModel) model).getTweetStatus(index);
925 // 現在選択したセルのユーザ名を保存しておく
926 this.selectedUsername = status.getUser().getScreenName();
927 // 現在選択したセルのユーザURLを保存しておく
928 this.selectedUserImageURL = status.getUser().getProfileImageURL();
930 this.currentStatus = status;
940 private void information(String message) {
941 statusBarLabel.setText(message);
947 * @throws IOException
948 * @throws FileNotFoundException
950 public void loadProperties() throws FileNotFoundException, IOException {
951 if (property == null) {
952 this.property = new Properties();
954 property.load(new FileInputStream("./" + PROPERTIES_DIRECTORY + "/"
955 + BASIC_SETTING_FILENAME));
957 String gtp = this.property.getProperty("getTimelinePeriod");
958 String gmp = this.property.getProperty("getMentionPeriod");
959 String gdmp = this.property.getProperty("getDirectMessagePeriod");
960 String gsdmp = this.property.getProperty("getSendDirectMessagePeriod");
962 String ntrgb = this.property.getProperty("newTableColorRGB");
964 this.tlFontName = this.property.getProperty("tlFontName");
965 this.detailFontName = this.property.getProperty("detailFontName");
967 String tfs = this.property.getProperty("tlFontSize");
968 String dfs = this.property.getProperty("detailFontSize");
969 String teh = this.property.getProperty("tableElementHeight");
972 String mfw = this.property.getProperty("mainFrameWidth");
973 String mfh = this.property.getProperty("mainFrameHeight");
976 this.newTableColor = new Color(Integer.parseInt(ntrgb));
977 this.tlFontSize = Integer.parseInt(tfs);
978 this.detailFontSize = Integer.parseInt(dfs);
979 this.tableElementHeight = Integer.parseInt(teh);
980 this.mainFrameWidth = Integer.parseInt(mfw);
981 this.mainFrameHeight = Integer.parseInt(mfh);
984 this.getTimelinePeriod = Integer.parseInt(gtp);
985 this.getMentionPeriod = Integer.parseInt(gmp);
986 this.getDirectMessagePeriod = Integer.parseInt(gdmp);
987 this.getSendDirectMessagePeriod = Integer.parseInt(gsdmp);
988 } catch (NumberFormatException e) {
996 * @throws IOException
998 public void saveProperties() throws IOException {
1000 File logDir = new File("./" + PROPERTIES_DIRECTORY);
1001 if (!logDir.exists()) {
1002 // ディレクトリが存在しないので作成する
1003 if (logDir.mkdir() == false) {
1004 throw new IOException(PROPERTIES_DIRECTORY
1005 + "ディレクトリを作成できませんでした.");
1008 if (property == null) {
1009 this.property = new Properties();
1013 this.property.setProperty("getTimelinePeriod", this.getTimelinePeriod + "");
1014 this.property.setProperty("getMentionPeriod", this.getMentionPeriod + "");
1015 this.property.setProperty("getDirectMessagePeriod", this.getDirectMessagePeriod + "");
1016 this.property.setProperty("getSendDirectMessagePeriod", this.getSendDirectMessagePeriod + "");
1018 this.property.setProperty("newTableColorRGB", newTableColor.getRGB()
1020 this.property.setProperty("tlFontName", this.tlFontName);
1021 this.property.setProperty("tlFontSize", this.tlFontSize + "");
1022 this.property.setProperty("detailFontName", this.detailFontName);
1023 this.property.setProperty("detailFontSize", this.detailFontSize + "");
1024 this.property.setProperty("tableElementHeight", this.tableElementHeight
1028 if( this.mainFrame.getExtendedState() == JFrame.NORMAL ) {
1029 this.mainFrameWidth = this.mainFrame.getWidth();
1030 this.mainFrameHeight = this.mainFrame.getHeight();
1032 this.property.setProperty("mainFrameWidth", this.mainFrameWidth + "");
1033 this.property.setProperty("mainFrameHeight", this.mainFrameHeight + "");
1035 property.store(new FileOutputStream("./" + PROPERTIES_DIRECTORY + "/"
1036 + BASIC_SETTING_FILENAME), null);
1040 * newTableColorを取得します。
1042 * @return newTableColor
1044 public Color getNewTableColor() {
1045 return newTableColor;
1049 * newTableColorを設定します。
1051 * @param newTableColor
1054 public void setNewTableColor(Color newTableColor) {
1055 this.newTableColor = newTableColor;
1061 * @return tlFontName
1063 public String getTlFontName() {
1073 public void setTlFontName(String tlFontName) {
1074 this.tlFontName = tlFontName;
1080 * @return tlFontSize
1082 public int getTlFontSize() {
1092 public void setTlFontSize(int tlFontSize) {
1093 this.tlFontSize = tlFontSize;
1097 * detailFontNameを取得します。
1099 * @return detailFontName
1101 public String getDetailFontName() {
1102 return detailFontName;
1106 * detailFontNameを設定します。
1108 * @param detailFontName
1111 public void setDetailFontName(String detailFontName) {
1112 this.detailFontName = detailFontName;
1116 * detailFontSizeを取得します。
1118 * @return detailFontSize
1120 public int getDetailFontSize() {
1121 return detailFontSize;
1125 * detailFontSizeを設定します。
1127 * @param detailFontSize
1130 public void setDetailFontSize(int detailFontSize) {
1131 this.detailFontSize = detailFontSize;
1135 * tableElementHeightを取得します。
1137 * @return tableElementHeight
1139 public int getTableElementHeight() {
1140 return tableElementHeight;
1144 * tableElementHeightを設定します。
1146 * @param tableElementHeight
1147 * tableElementHeight
1149 public void setTableElementHeight(int tableElementHeight) {
1150 this.tableElementHeight = tableElementHeight;
1154 * @return the getTimelinePeriod
1156 public int getGetTimelinePeriod() {
1157 return getTimelinePeriod;
1161 * @param getTimelinePeriod the getTimelinePeriod to set
1163 public void setGetTimelinePeriod(int getTimelinePeriod) {
1164 this.getTimelinePeriod = getTimelinePeriod;
1168 * @return the getMentionPeriod
1170 public int getGetMentionPeriod() {
1171 return getMentionPeriod;
1175 * @param getMentionPeriod the getMentionPeriod to set
1177 public void setGetMentionPeriod(int getMentionPeriod) {
1178 this.getMentionPeriod = getMentionPeriod;
1182 * @return the getDirectMessagePeriod
1184 public int getGetDirectMessagePeriod() {
1185 return getDirectMessagePeriod;
1189 * @param getDirectMessagePeriod the getDirectMessagePeriod to set
1191 public void setGetDirectMessagePeriod(int getDirectMessagePeriod) {
1192 this.getDirectMessagePeriod = getDirectMessagePeriod;
1196 * @return the getSendDirectMessagePeriod
1198 public int getGetSendDirectMessagePeriod() {
1199 return getSendDirectMessagePeriod;
1203 * @param getSendDirectMessagePeriod the getSendDirectMessagePeriod to set
1205 public void setGetSendDirectMessagePeriod(int getSendDirectMessagePeriod) {
1206 this.getSendDirectMessagePeriod = getSendDirectMessagePeriod;