From c0fd649156f68f9040b16eba6f87fec3568837fc Mon Sep 17 00:00:00 2001 From: spark_xp Date: Sun, 17 Oct 2010 07:50:42 +0000 Subject: [PATCH] =?utf8?q?=E3=83=AA=E3=82=B9=E3=83=88=E6=83=85=E5=A0=B1?= =?utf8?q?=E3=82=92=E8=A1=A8=E7=A4=BA=E3=81=99=E3=82=8B=E3=81=9F=E3=82=81?= =?utf8?q?=E3=81=AETable=E3=83=A2=E3=83=87=E3=83=AB=E3=82=92=E4=BD=9C?= =?utf8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.sourceforge.jp/svnroot/nt-manager/NishioTweetManager/trunk@94 d8c9ecd3-d47d-4367-8645-de82c00e513f --- src/twitter/gui/component/TweetListTableModel.java | 125 +++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 src/twitter/gui/component/TweetListTableModel.java diff --git a/src/twitter/gui/component/TweetListTableModel.java b/src/twitter/gui/component/TweetListTableModel.java new file mode 100644 index 0000000..a84d18b --- /dev/null +++ b/src/twitter/gui/component/TweetListTableModel.java @@ -0,0 +1,125 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package twitter.gui.component; + +import java.util.ArrayList; +import java.util.List; +import javax.swing.ImageIcon; +import javax.swing.table.DefaultTableModel; +import twitter.util.HTMLEncode; +import twitter4j.UserList; + +/** + * リスト情報一覧のテーブルモデル + * @author nishio + */ +public class TweetListTableModel extends DefaultTableModel { + + private static class ColumnContext { + public final Class columnClass; + public final String columnName; + public final boolean isEditable; + + public ColumnContext(String columnName, Class columnClass, + boolean isEditable) { + this.columnName = columnName; + this.columnClass = columnClass; + this.isEditable = isEditable; + } + } + + private static final ColumnContext[] columnArray = { + new ColumnContext("UserIcon", ImageIcon.class, false), + new ColumnContext("ListName", String.class, false), + new ColumnContext("ListUser", String.class, false), + new ColumnContext("Description", String.class, false), + }; + + // 取得した情報を蓄えておく + private List listInfo = null; + + /** + * + */ + public TweetListTableModel() { + super(); + listInfo = new ArrayList(); + } + + /** + * 取得していた情報をすべて削除する + */ + public void clearStatus() { + listInfo.clear(); + } + + @Override + public Class getColumnClass(int modelIndex) { + return columnArray[modelIndex].columnClass; + } + + @Override + public int getColumnCount() { + return columnArray.length; + } + + @Override + public String getColumnName(int modelIndex) { + return columnArray[modelIndex].columnName; + } + + /** + * 指定した行のリスト情報を取得 + * + * @param row + * @return + */ + public UserList getTweetStatus(int row) { + UserList s = null; + try { + s = listInfo.get(row); + }catch(Exception e) { + e.printStackTrace(); + } + return s; + } + + /** + * テーブルに追加 + * + * @param t + */ + public void insertTweet(UserList t) { + Object[] obj = { + new ImageIcon(t.getUser().getProfileImageURL()), + new String(t.getName()), + new String(t.getUser().getScreenName()), + new String(t.getDescription()) + }; + + try { + super.insertRow(0, obj); + listInfo.add(0, t); + } catch (Exception e) { + e.printStackTrace(); + } + } + + /** + * テーブルに存在する要素数 + * + * @return + */ + public int getTweetTableSize() { + return this.listInfo.size(); + } + + @Override + public boolean isCellEditable(int row, int column) { + return false; + //return true; + } +} -- 2.11.0