KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ozoneDB > adminGui > feature > account > users > UserTableModel


1 // You can redistribute this software and/or modify it under the terms of
2
// the Ozone Library License version 1 published by ozone-db.org.
3
//
4
// The original code and portions created by SMB are
5
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
6
//
7
package org.ozoneDB.adminGui.feature.account.users;
8
9 import org.ozoneDB.core.User;
10 import org.ozoneDB.DxLib.DxCollection;
11 import org.ozoneDB.DxLib.DxIterator;
12 import org.ozoneDB.adminGui.feature.account.Account;
13 import org.ozoneDB.adminGui.widget.TableMap;
14
15
16 //#############################################################################
17
/**
18  * This class is used to manage the account table.
19  *
20  * @author <p align=center>Ibsen Ramos-Bonilla
21  * <br>Copyright &copy 1997-@year@ by SMB GmbH. All Rights Reserved.</p>
22  *
23  * @version 1.0
24  */

25 //#############################################################################
26

27 public class UserTableModel extends TableMap {
28
29     /**
30      * The default constructor initializes the model.
31      */

32     public UserTableModel() {
33         setHeaders();
34         setTableData(null);
35     }
36
37     /**
38      * This method sets the headers for the account list data set.
39      */

40     private void setHeaders() {
41         //set the header names
42
String JavaDoc[] headers = {Account.COLUMN_USER_ID, Account.COLUMN_USER_NAME,
43                             Account.COLUMN_USER_PWD, Account.COLUMN_USER_STATUS};
44
45         //set the column count
46
this.columnCount = headers.length;
47
48         //load the headers into the table
49
for (int i = 0; i < headers.length; i++)
50             this.columnNames.add(headers[i]);
51     }
52
53     /**
54      * This method loads the data for the account list data set.
55      *
56      * @param users - a collection of the database users.
57      */

58     public void setTableData(DxCollection users) {
59         //first clear everything in the model
60
this.data.clear();
61
62         //users found
63
if (users != null) {
64
65             User user;
66
67             for (DxIterator it = users.iterator(); it.next() != null;) {
68
69                 //get next account in the collection
70
user = (User) it.object();
71
72 //fill in the information from the collection
73
Object JavaDoc[][] record =
74                         {{
75                             user.id(),
76                             user.name(),
77                             user.password(),
78                             "connected?" //TODO:add status getter to core.User
79
}};
80
81 //send to the table
82
this.data.addElement(record[0]);
83             }
84         }
85     }
86
87 } //--------------------------------- E O F -----------------------------------
88
Popular Tags