OSDN Git Service

指定したユーザが誰をフォローしている/されているか表示できる機能を作成。 refs #23442
authorspark_xp <spark_xp@d8c9ecd3-d47d-4367-8645-de82c00e513f>
Sat, 28 May 2011 08:02:35 +0000 (08:02 +0000)
committerspark_xp <spark_xp@d8c9ecd3-d47d-4367-8645-de82c00e513f>
Sat, 28 May 2011 08:02:35 +0000 (08:02 +0000)
メニューバー内のラベルテキストを一部変更。
その他、NullPointerExceptionが発生していた部分を修正。

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

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

index b2f163b..2a6aefd 100644 (file)
@@ -970,6 +970,32 @@ public class TweetMainAction {
                }
        }
 
+        /**
+         * 選択したユーザのfollowingを表示
+         */
+        public void actionOpenFollowing() {
+            // ユーザ名
+            try {
+                String userName = this.getCurrentStatus().getUser().getScreenName();
+                this.actionShowFollowingFollowerDialog(userName, true);
+            }catch(Exception e) {
+                e.printStackTrace();
+            }
+        }
+
+        /**
+         * 選択したユーザのfollowingを表示
+         */
+        public void actionOpenFollower() {
+            try {
+                // ユーザ名
+                String userName = this.getCurrentStatus().getUser().getScreenName();
+                this.actionShowFollowingFollowerDialog(userName, false);
+            }catch(Exception e) {
+                e.printStackTrace();
+            }
+        }
+
        /**
         * 選択したユーザのFavを開く
         */
@@ -1378,6 +1404,20 @@ public class TweetMainAction {
             dialog.setVisible(true);
         }
 
+        /**
+         * following follower表示ダイアログを表示
+         * @param username 取得したいユーザ
+         * @param ff trueでfollowing/ falseでfollower取得
+         */
+        public void actionShowFollowingFollowerDialog(String username, boolean ff) {
+            FollowingFollowerDialog dialog = getFollowingFollowerDialog();
+            //following follower取得開始
+            dialog.actionUserSearch(username, ff);
+
+            dialog.setLocationRelativeTo(null);
+            dialog.setVisible(true);
+        }
+
        /**
         * ハッシュタグ検索ダイアログを表示
         */
@@ -1535,19 +1575,7 @@ public class TweetMainAction {
         * デバッグ用
         */
        public void debug() {
-/*             String message = "こんにちは http://densan-labs.net/でした。 http://google.com/ あいうえお";
-               System.out.println( this.actionConvertURLToBitly( message ));*/
-               //this.actionConvertTweetBoxURLToBitly();
-               for(int i=0; i < 5; i++) {
-                       List<User> lists = this.tweetManager.getFollowingUser("nishio_dens", i);
-                       if( lists != null) {
-                               for(User u : lists) {
-                                       System.out.println( u );
-                               }
-                       }
-               }
-//             String url = "http://google.com";
-//             System.out.println( URLBitlyConverter.convertUrlToBitly(url));
+            //this.actionShowFollowingFollowerDialog("nishio_dens", false);
        }
 
         /**
index a74c0b1..72cbe1c 100644 (file)
@@ -458,6 +458,30 @@ public class TweetTabbedTable {
                                        }
                                });
 
+                JMenuItem followingUserMenuItem = new JMenuItem(
+                               "このユーザがフォローしているユーザ一覧");
+               followingUserMenuItem
+                               .addActionListener(new java.awt.event.ActionListener() {
+
+                                       @Override
+                                       public void actionPerformed(java.awt.event.ActionEvent e) {
+                                               // 選択したセルのユーザ情報をブラウザで開く
+                                               mainAction.actionOpenFollowing();
+                                       }
+                               });
+
+                JMenuItem followerUserMenuItem = new JMenuItem(
+                               "このユーザがフォローされているユーザ一覧");
+               followerUserMenuItem
+                               .addActionListener(new java.awt.event.ActionListener() {
+
+                                       @Override
+                                       public void actionPerformed(java.awt.event.ActionEvent e) {
+                                               // 選択したセルのユーザ情報をブラウザで開く
+                                               mainAction.actionOpenFollower();
+                                       }
+                               });
+
                // 指定した発言がRTかどうか判定
                int sc = table.getSelectedRowCount();
                if (sc == 1 && table != null) {
@@ -509,6 +533,10 @@ public class TweetTabbedTable {
                        rightClickPopup.add(openBrowserUserInformationMenuItem);
                        // この人のfavを開く
                        rightClickPopup.add(openFavMenuItem);
+                        //この人のfollowing開く
+                        rightClickPopup.add(followingUserMenuItem);
+                        //この人のfollower開く
+                        rightClickPopup.add(followerUserMenuItem);
                        // この人が作成したリスト
                        rightClickPopup.add(createdListMenuItem);
                        // この人が購読しているリスト
index dbff1a4..0a20a97 100644 (file)
@@ -99,28 +99,32 @@ public class FollowingFollowerDialog extends javax.swing.JDialog {
                 //データプログレス表示
                 InsertProgressListener progressListener = new InsertProgressListener(jProgressBar1);
 
-                if (userName != null && userName.length() > 0) {
-                    boolean update = false;
-                    switch (ffIndex) {
-                        case 0:
-                            //following
-                            update = addFollowingToTable(userName, numOfPage, progressListener);
-                            break;
-                        default:
-                            //follewer
-                            update = addFollowerToTable(userName, numOfPage, progressListener);
-                            break;
+                try {
+                    if (userName != null && userName.length() > 0) {
+                        boolean update = false;
+                        switch (ffIndex) {
+                            case 0:
+                                //following
+                                update = addFollowingToTable(userName, numOfPage, progressListener);
+                                break;
+                            default:
+                                //follewer
+                                update = addFollowerToTable(userName, numOfPage, progressListener);
+                                break;
+                        }
+                        if (update == true) {
+                            numOfPage++;
+                            jLabel2.setText((numOfPage * 100) + "");
+                        }
+                        //前回取得情報
+                        prevUsername = userName;
+                        prevGetFollowingFollower = ffIndex;
                     }
-                    if (update == true) {
-                        numOfPage++;
-                        jLabel2.setText((numOfPage * 100) + "");
-                    }
-                    //前回取得情報
-                    prevUsername = userName;
-                    prevGetFollowingFollower = ffIndex;
+                    //データ取得完了を表示
+                    setInformation("データ取得が完了しました");
+                }catch(Exception e) {
+                    setInformation("データ取得に失敗しました。指定したユーザは存在しない可能性があります。");
                 }
-                //データ取得完了を表示
-                setInformation("データ取得が完了しました");
             }
         };
     }
@@ -240,12 +244,12 @@ public class FollowingFollowerDialog extends javax.swing.JDialog {
         String screenName = user.getScreenName();
         //update time
         String updateTime = "";
-        if( user.getStatus().getCreatedAt() != null ) {
+        if( user.getStatus() != null ) {
             updateTime = user.getStatus().getCreatedAt().toString();
         }
         //location
         String location = "";
-        if( user.getStatus().getPlace() != null ) {
+        if( user.getLocation() != null ) {
             location = user.getLocation().toString();
         }
         //following
@@ -260,9 +264,13 @@ public class FollowingFollowerDialog extends javax.swing.JDialog {
             url = user.getURL().toString();
         }
         //client
-        String client = user.getStatus().getSource();
-        //最後の更新テキスト
-        String text = user.getStatus().getText();
+        String client = "";
+        String text = "";
+        if( user.getStatus() != null ) {
+            client = user.getStatus().getSource();
+            //最後の更新テキスト
+            text = user.getStatus().getText();
+        }
         //profile
         String profile = user.getDescription();
 
@@ -715,6 +723,25 @@ public class FollowingFollowerDialog extends javax.swing.JDialog {
     }//GEN-LAST:event_jButton2ActionPerformed
 
     /**
+     * Userのサーチを開始する
+     * @param username 取得したいユーザ
+     * @param ff trueでfollowing/ falseでfollowerを取得
+     */
+    public void actionUserSearch(String username, boolean ff) {
+        if( username != null ) {
+            jTextField1.setText(username);
+        }
+        if( ff == true ) {
+            //following
+            jComboBox1.setSelectedIndex(0);
+        }else {
+            //follower
+            jComboBox1.setSelectedIndex(1);
+        }
+        jButton2ActionPerformed( null );
+    }
+
+    /**
      * 現在の状態をラベルに表示する
      * @param msg
      */
index f07f750..f9cb864 100644 (file)
                   <KeyStroke key="Ctrl+S"/>
                 </Property>
                 <Property name="mnemonic" type="int" value="83"/>
-                <Property name="text" type="java.lang.String" value="&#x9078;&#x629e;&#x3057;&#x305f;&#x4eba;&#x306e;&#x767a;&#x8a00;&#x3092;&#x5225;&#x30bf;&#x30d6;&#x3067;&#x958b;&#x304f;(S)"/>
+                <Property name="text" type="java.lang.String" value="&#x9078;&#x629e;&#x3057;&#x305f;&#x30e6;&#x30fc;&#x30b6;&#x306e;&#x767a;&#x8a00;&#x3092;&#x5225;&#x30bf;&#x30d6;&#x3067;&#x958b;&#x304f;(S)"/>
               </Properties>
               <Events>
                 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem18ActionPerformed"/>
                   <KeyStroke key="Ctrl+B"/>
                 </Property>
                 <Property name="mnemonic" type="int" value="66"/>
-                <Property name="text" type="java.lang.String" value="&#x9078;&#x629e;&#x3057;&#x305f;&#x4eba;&#x306e;&#x767a;&#x8a00;&#x3092;&#x30d6;&#x30e9;&#x30a6;&#x30b6;&#x3067;&#x958b;&#x304f;(B)"/>
+                <Property name="text" type="java.lang.String" value="&#x9078;&#x629e;&#x3057;&#x305f;&#x30e6;&#x30fc;&#x30b6;&#x306e;&#x767a;&#x8a00;&#x3092;&#x30d6;&#x30e9;&#x30a6;&#x30b6;&#x3067;&#x958b;&#x304f;(B)"/>
               </Properties>
               <Events>
                 <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem21ActionPerformed"/>
               </Events>
             </MenuItem>
+            <MenuItem class="javax.swing.JMenuItem" name="jMenuItem35">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="&#x9078;&#x629e;&#x3057;&#x305f;&#x30e6;&#x30fc;&#x30b6;&#x304c;&#x30d5;&#x30a9;&#x30ed;&#x30fc;&#x3057;&#x3066;&#x3044;&#x308b;&#x30e6;&#x30fc;&#x30b6;&#x4e00;&#x89a7;&#x3092;&#x958b;&#x304f;"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem35ActionPerformed"/>
+              </Events>
+            </MenuItem>
+            <MenuItem class="javax.swing.JMenuItem" name="jMenuItem36">
+              <Properties>
+                <Property name="text" type="java.lang.String" value="&#x9078;&#x629e;&#x3057;&#x305f;&#x30e6;&#x30fc;&#x30b6;&#x304c;&#x30d5;&#x30a9;&#x30ed;&#x30fc;&#x3055;&#x308c;&#x3066;&#x3044;&#x308b;&#x30e6;&#x30fc;&#x30b6;&#x4e00;&#x89a7;&#x3092;&#x958b;&#x304f;"/>
+              </Properties>
+              <Events>
+                <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem36ActionPerformed"/>
+              </Events>
+            </MenuItem>
             <MenuItem class="javax.swing.JPopupMenu$Separator" name="jSeparator6">
             </MenuItem>
             <MenuItem class="javax.swing.JMenuItem" name="jMenuItem30">
index d81dbb0..b0d2867 100644 (file)
@@ -199,6 +199,8 @@ public class NishioTweetManager extends javax.swing.JFrame {
         jMenuItem17 = new javax.swing.JMenuItem();
         jMenuItem18 = new javax.swing.JMenuItem();
         jMenuItem21 = new javax.swing.JMenuItem();
+        jMenuItem35 = new javax.swing.JMenuItem();
+        jMenuItem36 = new javax.swing.JMenuItem();
         jSeparator6 = new javax.swing.JPopupMenu.Separator();
         jMenuItem30 = new javax.swing.JMenuItem();
         jMenuItem22 = new javax.swing.JMenuItem();
@@ -727,7 +729,7 @@ public class NishioTweetManager extends javax.swing.JFrame {
 
         jMenuItem18.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
         jMenuItem18.setMnemonic('S');
-        jMenuItem18.setText("選択したの発言を別タブで開く(S)");
+        jMenuItem18.setText("選択したユーザの発言を別タブで開く(S)");
         jMenuItem18.addActionListener(new java.awt.event.ActionListener() {
             public void actionPerformed(java.awt.event.ActionEvent evt) {
                 jMenuItem18ActionPerformed(evt);
@@ -737,13 +739,29 @@ public class NishioTweetManager extends javax.swing.JFrame {
 
         jMenuItem21.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_B, java.awt.event.InputEvent.CTRL_MASK));
         jMenuItem21.setMnemonic('B');
-        jMenuItem21.setText("選択したの発言をブラウザで開く(B)");
+        jMenuItem21.setText("選択したユーザの発言をブラウザで開く(B)");
         jMenuItem21.addActionListener(new java.awt.event.ActionListener() {
             public void actionPerformed(java.awt.event.ActionEvent evt) {
                 jMenuItem21ActionPerformed(evt);
             }
         });
         jMenu6.add(jMenuItem21);
+
+        jMenuItem35.setText("選択したユーザがフォローしているユーザ一覧を開く");
+        jMenuItem35.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jMenuItem35ActionPerformed(evt);
+            }
+        });
+        jMenu6.add(jMenuItem35);
+
+        jMenuItem36.setText("選択したユーザがフォローされているユーザ一覧を開く");
+        jMenuItem36.addActionListener(new java.awt.event.ActionListener() {
+            public void actionPerformed(java.awt.event.ActionEvent evt) {
+                jMenuItem36ActionPerformed(evt);
+            }
+        });
+        jMenu6.add(jMenuItem36);
         jMenu6.add(jSeparator6);
 
         jMenuItem30.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
@@ -1069,6 +1087,14 @@ public class NishioTweetManager extends javax.swing.JFrame {
             mainAction.actionShowFollowingFollowerDialog();
         }//GEN-LAST:event_jMenuItem34ActionPerformed
 
+        private void jMenuItem35ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem35ActionPerformed
+            mainAction.actionOpenFollowing();
+        }//GEN-LAST:event_jMenuItem35ActionPerformed
+
+        private void jMenuItem36ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem36ActionPerformed
+            mainAction.actionOpenFollower();
+        }//GEN-LAST:event_jMenuItem36ActionPerformed
+
        private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton4ActionPerformed
                // メッセージをつぶやく
                mainAction.actionTweet();
@@ -1525,6 +1551,8 @@ public class NishioTweetManager extends javax.swing.JFrame {
     private javax.swing.JMenuItem jMenuItem32;
     private javax.swing.JMenuItem jMenuItem33;
     private javax.swing.JMenuItem jMenuItem34;
+    private javax.swing.JMenuItem jMenuItem35;
+    private javax.swing.JMenuItem jMenuItem36;
     private javax.swing.JMenuItem jMenuItem4;
     private javax.swing.JMenuItem jMenuItem5;
     private javax.swing.JMenuItem jMenuItem6;