01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
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;
19:
20: import org.columba.mail.config.AccountItem;
21: import org.columba.mail.config.AccountList;
22: import org.columba.mail.util.MailResourceLoader;
23:
24: class AccountListDataModel extends AbstractTableModel {
25: final String[] columnNames = {
26: MailResourceLoader.getString(
27: "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 getColumnName(int col) {
46: return columnNames[col];
47: }
48:
49: public Object 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 getColumnClass(int c) {
69: if (c == 0) {
70: return AccountItem.class;
71: } else {
72: return String.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: }
|