OSDN Git Service

reply, QT機能を導入.
authorspark_xp <spark_xp@d8c9ecd3-d47d-4367-8645-de82c00e513f>
Fri, 17 Sep 2010 13:48:54 +0000 (13:48 +0000)
committerspark_xp <spark_xp@d8c9ecd3-d47d-4367-8645-de82c00e513f>
Fri, 17 Sep 2010 13:48:54 +0000 (13:48 +0000)
ツイート時に発言した旨をステータスバーに表示するように変更.

git-svn-id: http://svn.sourceforge.jp/svnroot/nt-manager/NishioTweetManager/trunk@59 d8c9ecd3-d47d-4367-8645-de82c00e513f

src/twitter/gui/action/TweetMainAction.java
src/twitter/gui/component/TweetTabbedTable.java
src/twitter/gui/form/NishioTweetManager.form
src/twitter/gui/form/NishioTweetManager.java

index f808680..32d5d46 100644 (file)
@@ -106,6 +106,8 @@ public class TweetMainAction {
     private ConfigurationDialog configurationDialog = null;
     // 現在選択しているStatus情報
     private Status currentStatus = null;
+    // reply予定のStatus
+    private Status replyStatus = null;
     // 詳細情報パネル
     private JPanel detailInfoPanel = null;
     // ダイレクトメッセージ送信用ダイアログ
@@ -485,14 +487,44 @@ public class TweetMainAction {
     }
 
     /**
-     * 選択したtweetをRT
+     * reply設定
+     */
+    public void actionSetReplyStatusToTweetBoxPane() {
+        //選択した部分
+        this.setReplyStatus( currentStatus );
+        // コメントしたユーザ名
+        String username = this.getCurrentStatus().getUser().getScreenName();
+        this.tweetBoxPane.setText("@" + username + " ");
+
+        //情報表示
+        this.information(username + "さんに返信");
+    }
+
+    /**
+     * 引用Tweet
+     */
+    public void actionSetQuoteStatusToTweetBoxPane() {
+        //選択した部分
+        this.setReplyStatus( currentStatus );
+        // コメントしたユーザ名
+        String username = this.getCurrentStatus().getUser().getScreenName();
+        // コメント
+        String message = this.getCurrentStatus().getText();
+        this.tweetBoxPane.setText("QT @" + username + ": " + message);
+
+        //情報表示
+        this.information(username + "さんのメッセージを引用ツイート");
+    }
+
+    /**
+     * 選択したtweetを非公式RT
      */
     public void actionCopySelectedStatusToTweetBoxPane() {
         // コメントしたユーザ名
-        String username = this.currentStatus.getUser().getScreenName();
+        String username = this.getCurrentStatus().getUser().getScreenName();
         // コメント
-        String message = this.currentStatus.getText();
-        this.tweetBoxPane.setText("RT: @" + username + ": " + message);
+        String message = this.getCurrentStatus().getText();
+        this.tweetBoxPane.setText("RT @" + username + ": " + message);
     }
 
     /**
@@ -579,9 +611,9 @@ public class TweetMainAction {
     public void actionOpenStatusURL() {
         try {
             // ユーザ名
-            String userName = this.currentStatus.getUser().getScreenName();
+            String userName = this.getCurrentStatus().getUser().getScreenName();
             // 発言のstatusID
-            long statusID = this.currentStatus.getId();
+            long statusID = this.getCurrentStatus().getId();
             Desktop.getDesktop().browse(
                     new URI(TWITTER_URL + userName + "/statuses/" + statusID));
         } catch (Exception ex) {
@@ -596,7 +628,7 @@ public class TweetMainAction {
      */
     public void actionOpenUserURL() {
         try {
-            String userName = this.currentStatus.getUser().getScreenName();
+            String userName = this.getCurrentStatus().getUser().getScreenName();
             Desktop.getDesktop().browse(new URI(TWITTER_URL + userName));
         } catch (Exception ex) {
             ex.printStackTrace();
@@ -711,10 +743,10 @@ public class TweetMainAction {
      */
     public void actionRetweet() {
         Status status = null;
-        if( this.currentStatus.isRetweet() ) {
-            status = this.currentStatus.getRetweetedStatus();
+        if( this.getCurrentStatus().isRetweet() ) {
+            status = this.getCurrentStatus().getRetweetedStatus();
         }else {
-            status = this.currentStatus;
+            status = this.getCurrentStatus();
         }
 
         // 選択しているtweetのstatus id
@@ -807,8 +839,16 @@ public class TweetMainAction {
      * tweetBoxPaneに書かれた文字をつぶやく
      */
     public void actionTweet() {
-        tweetManager.tweet(tweetBoxPane.getText());
+        if( this.replyStatus != null ) {
+            tweetManager.replyTweet(tweetBoxPane.getText(), this.replyStatus.getId());
+        }else {
+            tweetManager.tweet(tweetBoxPane.getText());
+        }
+        //ツイートした旨を表示
+        this.information("メッセージをつぶやきました. 発言:" + tweetBoxPane.getText());
+        
         tweetBoxPane.setText(""); // テキストをクリア
+        
     }
 
     /**
@@ -845,6 +885,11 @@ public class TweetMainAction {
             len = 0;
         }
         tweetMessageCountLabel.setText(len + "");
+
+        //残りつぶやき数140の場合,reply状態も解除する
+        if( len == 140 ) {
+            this.setReplyStatus(null);
+        }
     }
 
     /**
@@ -974,7 +1019,7 @@ public class TweetMainAction {
             // 現在選択したセルのユーザURLを保存しておく
             this.selectedUserImageURL = status.getUser().getProfileImageURL();
             // 選択したStatusを保存しておく
-            this.currentStatus = status;
+            this.setCurrentStatus(status);
         }
         return status;
     }
@@ -1252,4 +1297,35 @@ public class TweetMainAction {
     public void setGetSendDirectMessagePeriod(int getSendDirectMessagePeriod) {
         this.getSendDirectMessagePeriod = getSendDirectMessagePeriod;
     }
+
+    /**
+     * @return the currentStatus
+     */
+    public Status getCurrentStatus() {
+        return currentStatus;
+    }
+
+    /**
+     * @param currentStatus the currentStatus to set
+     */
+    public void setCurrentStatus(Status currentStatus) {
+        this.currentStatus = currentStatus;
+    }
+
+    /**
+     * 
+     * @return
+     */
+    public Status getReplyStatus() {
+        return replyStatus;
+    }
+
+    /**
+     *
+     * @param status
+     * @return
+     */
+    public void setReplyStatus(Status status) {
+        this.replyStatus = status;
+    }
 }
index 44498cc..4bda806 100644 (file)
@@ -289,37 +289,65 @@ public class TweetTabbedTable {
     private JPopupMenu getRightClickPopup() {
         if (rightClickPopup == null) {
             rightClickPopup = new JPopupMenu();
-            JMenuItem directMessageMenuItem = new JMenuItem("ダイレクトメッセージを送信");
-            directMessageMenuItem.addActionListener(new java.awt.event.ActionListener() {
+
+            JMenuItem replyMenuItem = new JMenuItem("この発言に返信する(Reply)");
+            replyMenuItem.addActionListener(new java.awt.event.ActionListener() {
 
                 public void actionPerformed(java.awt.event.ActionEvent e) {
-                    // ダイレクトメッセージ送信ダイアログを表示
-                    mainAction.actionShowDirectMessageDialog();
+                    // 選択したセルのステータスにreply
+                    mainAction.actionSetReplyStatusToTweetBoxPane();
                 }
             });
-            rightClickPopup.add(directMessageMenuItem);
-            JMenuItem retweetMenuItem = new JMenuItem("発言を公式リツイート");
+            rightClickPopup.add(replyMenuItem);
+            
+            JMenuItem retweetMenuItem = new JMenuItem("発言を公式リツイート(RT)");
             retweetMenuItem.addActionListener(new java.awt.event.ActionListener() {
 
+                @Override
                 public void actionPerformed(java.awt.event.ActionEvent e) {
                     // 選択したセルのステータスをRetweet
                     mainAction.actionRetweet();
                 }
             });
             rightClickPopup.add(retweetMenuItem);
-            JMenuItem quoteMenuItem = new JMenuItem("発言をコメント付きリツイート");
+
+            JMenuItem quoteMenuItem = new JMenuItem("発言を引用ツイート(QT)");
             quoteMenuItem.addActionListener(new java.awt.event.ActionListener() {
 
+                @Override
+                public void actionPerformed(java.awt.event.ActionEvent e) {
+                    // 選択したセルのステータスをQT
+                    mainAction.actionSetQuoteStatusToTweetBoxPane();
+                }
+            });
+            rightClickPopup.add(quoteMenuItem);
+
+            JMenuItem unofficialRetweetMenuItem = new JMenuItem("発言をコメント付きリツイート(非公式RT)");
+            unofficialRetweetMenuItem.addActionListener(new java.awt.event.ActionListener() {
+
+                @Override
                 public void actionPerformed(java.awt.event.ActionEvent e) {
                     // 選択したセルのステータスをコメント付Retweet
                     mainAction.actionCopySelectedStatusToTweetBoxPane();
                 }
             });
-            rightClickPopup.add(quoteMenuItem);
+            rightClickPopup.add(unofficialRetweetMenuItem);
+
+            JMenuItem directMessageMenuItem = new JMenuItem("ダイレクトメッセージを送信");
+            directMessageMenuItem.addActionListener(new java.awt.event.ActionListener() {
+
+                @Override
+                public void actionPerformed(java.awt.event.ActionEvent e) {
+                    // ダイレクトメッセージ送信ダイアログを表示
+                    mainAction.actionShowDirectMessageDialog();
+                }
+            });
+            rightClickPopup.add(directMessageMenuItem);
 
-            JMenuItem statusBrowserMenuItem = new JMenuItem("発言をブラウザで開く");
+            JMenuItem statusBrowserMenuItem = new JMenuItem("この発言をブラウザで開く");
             statusBrowserMenuItem.addActionListener(new java.awt.event.ActionListener() {
 
+                @Override
                 public void actionPerformed(java.awt.event.ActionEvent e) {
                     // 選択したセルのステータスをブラウザで開く
                     mainAction.actionOpenStatusURL();
@@ -331,6 +359,7 @@ public class TweetTabbedTable {
                     "この人のTimelineをブラウザで開く");
             openBrowserUserInformationMenuItem.addActionListener(new java.awt.event.ActionListener() {
 
+                @Override
                 public void actionPerformed(java.awt.event.ActionEvent e) {
                     // 選択したセルのユーザ情報をブラウザで開く
                     mainAction.actionOpenUserURL();
index abf4646..1c8be23 100644 (file)
             </Property>
           </Properties>
           <Events>
+            <EventHandler event="caretUpdate" listener="javax.swing.event.CaretListener" parameters="javax.swing.event.CaretEvent" handler="jTextPaneCaretUpdate"/>
             <EventHandler event="focusGained" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jTextPaneFocusGained"/>
             <EventHandler event="focusLost" listener="java.awt.event.FocusListener" parameters="java.awt.event.FocusEvent" handler="jTextPaneFocusLost"/>
             <EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="jTextPaneKeyReleased"/>
index c86385b..4d7a9e0 100644 (file)
@@ -374,6 +374,11 @@ public class NishioTweetManager extends javax.swing.JFrame {
         jScrollPane9.setMinimumSize(new java.awt.Dimension(26, 80));
 
         jTextPane.setMaximumSize(new java.awt.Dimension(2147483647, 20));
+        jTextPane.addCaretListener(new javax.swing.event.CaretListener() {
+            public void caretUpdate(javax.swing.event.CaretEvent evt) {
+                jTextPaneCaretUpdate(evt);
+            }
+        });
         jTextPane.addFocusListener(new java.awt.event.FocusAdapter() {
             public void focusGained(java.awt.event.FocusEvent evt) {
                 jTextPaneFocusGained(evt);
@@ -677,6 +682,10 @@ public class NishioTweetManager extends javax.swing.JFrame {
         
     }//GEN-LAST:event_jMenuItem9ActionPerformed
 
+    private void jTextPaneCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jTextPaneCaretUpdate
+        // TODO add your handling code here:
+    }//GEN-LAST:event_jTextPaneCaretUpdate
+
     /**
      *
      */