📄 usertablemodel.java
字号:
// You can redistribute this software and/or modify it under the terms of
// the Ozone Library License version 1 published by ozone-db.org.
//
// The original code and portions created by SMB are
// Copyright (C) 1997-@year@ by SMB GmbH. All rights reserved.
//
package org.ozoneDB.adminGui.feature.account.users;
import org.ozoneDB.core.User;
import org.ozoneDB.DxLib.DxCollection;
import org.ozoneDB.DxLib.DxIterator;
import org.ozoneDB.adminGui.feature.account.Account;
import org.ozoneDB.adminGui.widget.TableMap;
//#############################################################################
/**
* This class is used to manage the account table.
*
* @author <p align=center>Ibsen Ramos-Bonilla
* <br>Copyright © 1997-@year@ by SMB GmbH. All Rights Reserved.</p>
*
* @version 1.0
*/
//#############################################################################
public class UserTableModel extends TableMap {
/**
* The default constructor initializes the model.
*/
public UserTableModel() {
setHeaders();
setTableData(null);
}
/**
* This method sets the headers for the account list data set.
*/
private void setHeaders() {
//set the header names
String[] headers = {Account.COLUMN_USER_ID, Account.COLUMN_USER_NAME,
Account.COLUMN_USER_PWD, Account.COLUMN_USER_STATUS};
//set the column count
this.columnCount = headers.length;
//load the headers into the table
for (int i = 0; i < headers.length; i++)
this.columnNames.add(headers[i]);
}
/**
* This method loads the data for the account list data set.
*
* @param users - a collection of the database users.
*/
public void setTableData(DxCollection users) {
//first clear everything in the model
this.data.clear();
//users found
if (users != null) {
User user;
for (DxIterator it = users.iterator(); it.next() != null;) {
//get next account in the collection
user = (User) it.object();
//fill in the information from the collection
Object[][] record =
{{
user.id(),
user.name(),
user.password(),
"connected?" //TODO:add status getter to core.User
}};
//send to the table
this.data.addElement(record[0]);
}
}
}
} //--------------------------------- E O F -----------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -