KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > config > accountlist > AccountListDataModel


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.mail.gui.config.accountlist;
17
18 import javax.swing.table.AbstractTableModel JavaDoc;
19
20 import org.columba.mail.config.AccountItem;
21 import org.columba.mail.config.AccountList;
22 import org.columba.mail.util.MailResourceLoader;
23
24
25  class AccountListDataModel extends AbstractTableModel JavaDoc {
26     final String JavaDoc[] columnNames = {
27         MailResourceLoader.getString("dialog", "account", "accountname"), //$NON-NLS-1$
28
MailResourceLoader.getString("dialog", "account", "type"), //$NON-NLS-1$
29
};
30     private AccountList accountList;
31
32     public AccountListDataModel(AccountList list) {
33         super();
34         this.accountList = list;
35     }
36
37     public int getColumnCount() {
38         return columnNames.length;
39     }
40
41     public int getRowCount() {
42         return accountList.count();
43     }
44
45     public String JavaDoc getColumnName(int col) {
46         return columnNames[col];
47     }
48
49     public Object JavaDoc getValueAt(int row, int col) {
50         AccountItem item = accountList.get(row);
51
52         if (item == null) {
53             return "";
54         }
55
56         if (col == 0) {
57             /*
58 String description = item.getName();
59 if ( description == null ) return "";
60 return description;
61 */

62             return item;
63         } else {
64             return item.isPopAccount() ? "POP3" : "IMAP4";
65         }
66     }
67
68     public Class JavaDoc getColumnClass(int c) {
69         if (c == 0) {
70             return AccountItem.class;
71         } else {
72             return String JavaDoc.class;
73         }
74     }
75
76     /*
77 public boolean isCellEditable(int row, int col)
78 {
79     if ( col == 1 )
80        return true;
81     else
82        return false;
83 }
84 */

85 }
86
Popular Tags