OSDN Git Service

リスト一覧を表示するダイアログを作成
authorspark_xp <spark_xp@d8c9ecd3-d47d-4367-8645-de82c00e513f>
Sun, 17 Oct 2010 08:50:55 +0000 (08:50 +0000)
committerspark_xp <spark_xp@d8c9ecd3-d47d-4367-8645-de82c00e513f>
Sun, 17 Oct 2010 08:50:55 +0000 (08:50 +0000)
git-svn-id: http://svn.sourceforge.jp/svnroot/nt-manager/NishioTweetManager/trunk@95 d8c9ecd3-d47d-4367-8645-de82c00e513f

src/twitter/gui/action/TweetMainAction.java
src/twitter/gui/component/TweetListTableModel.java
src/twitter/gui/form/NishioTweetManager.form
src/twitter/gui/form/NishioTweetManager.java
src/twitter/gui/form/UserListDialog.form [new file with mode: 0644]
src/twitter/gui/form/UserListDialog.java [new file with mode: 0644]

index 16c3478..5199f5b 100644 (file)
@@ -61,6 +61,7 @@ import twitter.gui.form.ConfigurationDialog;
 import twitter.gui.form.DirectMessageDialog;
 import twitter.gui.form.HashtagSearchDialog;
 import twitter.gui.form.KeywordSearchDialog;
+import twitter.gui.form.UserListDialog;
 import twitter.manage.TweetConfiguration;
 import twitter.manage.TweetManager;
 import twitter.task.ExistTimerIDException;
@@ -194,6 +195,9 @@ public class TweetMainAction {
     //ツイートテーブルの情報を一定間隔で更新するクラスを作成
     private TweetTaskManager tweetTaskManager = new TweetTaskManager();
 
+    //リストダイアログ
+    private UserListDialog userListDialog = null;
+
     //情報更新間隔[sec]
     private int getTimelinePeriod = 60;
     private int getMentionPeriod = 60 * 3;
@@ -1190,6 +1194,17 @@ public class TweetMainAction {
     }
 
     /**
+     * リストダイアログを表示
+     * @param listUserName リストを保持しているユーザの名前
+     */
+    public void actionShowUserListDialog(String listUserName) {
+        UserListDialog dialog = getUserListDialog( listUserName );
+        Point loc = dialog.getLocation();
+        dialog.setLocationRelativeTo(null);
+        dialog.setVisible(true);
+    }
+
+    /**
      * tweetBoxPaneに書かれた文字をつぶやく
      */
     public void actionTweet() {
@@ -1302,6 +1317,16 @@ public class TweetMainAction {
     }
 
     /**
+     * リストダイアログを取得
+     * @param listUserName リストを保持しているユーザの名前
+     * @return
+     */
+    public UserListDialog getUserListDialog(String listUserName) {
+        userListDialog = new UserListDialog(mainFrame, true, this, tweetManager, listUserName);
+        return userListDialog;
+    }
+
+    /**
      * twitter全体からキーワード検索ダイアログを表示
      * @return
      */
index a84d18b..8033fd1 100644 (file)
@@ -32,7 +32,7 @@ public class TweetListTableModel extends DefaultTableModel {
        }
 
        private static final ColumnContext[] columnArray = {
-        new ColumnContext("UserIcon", ImageIcon.class, false),
+        new ColumnContext("User", ImageIcon.class, false),
         new ColumnContext("ListName", String.class, false),
         new ColumnContext("ListUser", String.class, false),
         new ColumnContext("Description", String.class, false),
@@ -77,7 +77,7 @@ public class TweetListTableModel extends DefaultTableModel {
         * @param row
         * @return
         */
-       public UserList getTweetStatus(int row) {
+       public UserList getUserList(int row) {
         UserList s = null;
         try {
             s = listInfo.get(row);
@@ -92,7 +92,7 @@ public class TweetListTableModel extends DefaultTableModel {
         *
         * @param t
         */
-       public void insertTweet(UserList t) {
+       public void insertUserList(UserList t) {
         Object[] obj = {
             new ImageIcon(t.getUser().getProfileImageURL()),
             new String(t.getName()),
@@ -113,7 +113,7 @@ public class TweetListTableModel extends DefaultTableModel {
         *
         * @return
         */
-       public int getTweetTableSize() {
+       public int getTableSize() {
                return this.listInfo.size();
        }
 
index 2422c6a..64bc4ed 100644 (file)
               </Group>
               <Group type="102" alignment="0" attributes="0">
                   <Component id="jScrollPane9" min="-2" pref="53" max="-2" attributes="0"/>
-                  <EmptySpace max="32767" attributes="0"/>
+                  <EmptySpace pref="29" max="32767" attributes="0"/>
               </Group>
           </Group>
         </DimensionLayout>
index 8c7c74a..0a5cc01 100644 (file)
@@ -989,7 +989,7 @@ public class NishioTweetManager extends javax.swing.JFrame {
     }//GEN-LAST:event_jMenuItem8ActionPerformed
 
     private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
-        mainAction.information("とても長い文章のテストとても長い文章のテストとても長い文章のテストとても長い文章のテストとても長い文章のテストとても長い文章のテスト");
+        mainAction.actionShowUserListDialog("yumi_rua");
     }//GEN-LAST:event_jMenuItem9ActionPerformed
 
     private void jTextPaneCaretUpdate(javax.swing.event.CaretEvent evt) {//GEN-FIRST:event_jTextPaneCaretUpdate
diff --git a/src/twitter/gui/form/UserListDialog.form b/src/twitter/gui/form/UserListDialog.form
new file mode 100644 (file)
index 0000000..b24a152
--- /dev/null
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
+  <Properties>
+    <Property name="defaultCloseOperation" type="int" value="2"/>
+  </Properties>
+  <SyntheticProperties>
+    <SyntheticProperty name="formSizePolicy" type="int" value="1"/>
+  </SyntheticProperties>
+  <AuxValues>
+    <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
+    <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
+    <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
+    <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
+    <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
+  </AuxValues>
+
+  <Layout>
+    <DimensionLayout dim="0">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Component id="jScrollPane1" alignment="0" pref="753" max="32767" attributes="0"/>
+          <Group type="102" alignment="1" attributes="0">
+              <EmptySpace pref="533" max="32767" attributes="0"/>
+              <Component id="jButton1" min="-2" pref="100" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Component id="jButton2" min="-2" pref="102" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+    <DimensionLayout dim="1">
+      <Group type="103" groupAlignment="0" attributes="0">
+          <Group type="102" alignment="0" attributes="0">
+              <Component id="jScrollPane1" min="-2" pref="380" max="-2" attributes="0"/>
+              <EmptySpace max="-2" attributes="0"/>
+              <Group type="103" groupAlignment="0" max="-2" attributes="0">
+                  <Component id="jButton1" max="32767" attributes="1"/>
+                  <Component id="jButton2" alignment="0" pref="42" max="32767" attributes="1"/>
+              </Group>
+              <EmptySpace max="-2" attributes="0"/>
+          </Group>
+      </Group>
+    </DimensionLayout>
+  </Layout>
+  <SubComponents>
+    <Container class="javax.swing.JScrollPane" name="jScrollPane1">
+      <AuxValues>
+        <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
+      </AuxValues>
+
+      <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
+      <SubComponents>
+        <Component class="javax.swing.JTable" name="jTable1">
+          <Properties>
+            <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
+              <Connection code="listTableModel" type="code"/>
+            </Property>
+          </Properties>
+        </Component>
+      </SubComponents>
+    </Container>
+    <Component class="javax.swing.JButton" name="jButton1">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="OK"/>
+      </Properties>
+    </Component>
+    <Component class="javax.swing.JButton" name="jButton2">
+      <Properties>
+        <Property name="text" type="java.lang.String" value="&#x30ad;&#x30e3;&#x30f3;&#x30bb;&#x30eb;"/>
+      </Properties>
+    </Component>
+  </SubComponents>
+</Form>
diff --git a/src/twitter/gui/form/UserListDialog.java b/src/twitter/gui/form/UserListDialog.java
new file mode 100644 (file)
index 0000000..03e34a4
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/*
+ * UserListDialog.java
+ *
+ * Created on 2010/10/17, 16:55:08
+ */
+
+package twitter.gui.form;
+
+import java.util.List;
+import javax.swing.table.TableColumn;
+import javax.swing.table.TableColumnModel;
+import twitter.action.TweetUserTimelineGetter;
+import twitter.gui.action.TweetMainAction;
+import twitter.gui.component.TweetListTableModel;
+import twitter.manage.TweetManager;
+import twitter4j.UserList;
+
+/**
+ *
+ * @author nishio
+ */
+public class UserListDialog extends javax.swing.JDialog {
+
+    //メインアクション
+    private TweetMainAction mainAction = null;
+    //tweetmanager
+    private TweetManager tweetManager = null;
+    //リストを取得するユーザの名前
+    private String listUserName = null;
+    //リストモデル
+    private TweetListTableModel listTableModel = new TweetListTableModel();
+    //アイコンの大きさ
+    private static final int iconSize = 50;
+
+    /** Creates new form UserListDialog */
+    public UserListDialog(java.awt.Frame parent, boolean modal, TweetMainAction mainAction,
+            TweetManager tweetManager, String listUserName) {
+        super(parent, modal);
+        initComponents();
+        this.tweetManager = tweetManager;
+        this.mainAction = mainAction;
+        this.listUserName = listUserName;
+
+        addUserListToTable(listUserName);
+    }
+
+    /**
+     * テーブルにリスト一覧を挿入
+     * @param username
+     */
+    public void addUserListToTable(String username) {
+        this.listTableModel.clearStatus();
+        this.setTableEnvironment();
+        if( this.tweetManager != null ) {
+            List<UserList> list = this.tweetManager.getUserLists(username);
+            for(UserList u : list ) {
+                this.listTableModel.insertUserList(u);
+            }
+        }
+    }
+
+    /**
+     * テーブルの大きさ等の情報を設定
+     */
+    public void setTableEnvironment() {
+        TableColumnModel columnModel = this.jTable1.getColumnModel();
+        TableColumn column = columnModel.getColumn(0);
+        column.setMinWidth( this.iconSize );
+        column.setMaxWidth( this.iconSize );
+    }
+
+    /** This method is called from within the constructor to
+     * initialize the form.
+     * WARNING: Do NOT modify this code. The content of this method is
+     * always regenerated by the Form Editor.
+     */
+    @SuppressWarnings("unchecked")
+    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+    private void initComponents() {
+
+        jScrollPane1 = new javax.swing.JScrollPane();
+        jTable1 = new javax.swing.JTable();
+        jButton1 = new javax.swing.JButton();
+        jButton2 = new javax.swing.JButton();
+
+        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+
+        jTable1.setModel(listTableModel);
+        jScrollPane1.setViewportView(jTable1);
+
+        jButton1.setText("OK");
+
+        jButton2.setText("キャンセル");
+
+        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
+        getContentPane().setLayout(layout);
+        layout.setHorizontalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 753, Short.MAX_VALUE)
+            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
+                .addContainerGap(533, Short.MAX_VALUE)
+                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
+                .addContainerGap())
+        );
+        layout.setVerticalGroup(
+            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+            .addGroup(layout.createSequentialGroup()
+                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 380, javax.swing.GroupLayout.PREFERRED_SIZE)
+                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+                    .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+                    .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 42, Short.MAX_VALUE))
+                .addContainerGap())
+        );
+
+        pack();
+    }// </editor-fold>//GEN-END:initComponents
+
+    // Variables declaration - do not modify//GEN-BEGIN:variables
+    private javax.swing.JButton jButton1;
+    private javax.swing.JButton jButton2;
+    private javax.swing.JScrollPane jScrollPane1;
+    private javax.swing.JTable jTable1;
+    // End of variables declaration//GEN-END:variables
+
+}