You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
|
package ru.egspt;
|
|
|
|
|
|
|
|
import javax.swing.table.AbstractTableModel;
|
|
|
|
|
|
|
|
public class ReportTableModel extends AbstractTableModel{
|
|
|
|
private String[] header = {"id", "login", "mail"};
|
|
|
|
private Object[][] data;
|
|
|
|
public ReportTableModel(Data data){
|
|
|
|
setData(data);
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public int getRowCount() {
|
|
|
|
return getData().length;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getColumnCount() {
|
|
|
|
return getHeader().length;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Object getValueAt(int rowIndex, int columnIndex) {
|
|
|
|
return getData()[rowIndex][columnIndex];
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @return the data
|
|
|
|
*/
|
|
|
|
public Object[][] getData() {
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
public void setData(Data data) {
|
|
|
|
//создаем объект data - инициализация переменной
|
|
|
|
int row = 0;
|
|
|
|
row = data.getUsers().size();
|
|
|
|
int col = 3;//по количеству заголовков
|
|
|
|
this.data = new Object[row][col];
|
|
|
|
//заполняем модель данными пользователей
|
|
|
|
int i = 0;
|
|
|
|
while (i < data.getUsers().size()){
|
|
|
|
this.data[i][0] = data.getUsers().get(i).getId();
|
|
|
|
this.data[i][1] = data.getUsers().get(i).getLogin();
|
|
|
|
this.data[i][2] = data.getUsers().get(i).getMail();
|
|
|
|
i++;
|
|
|
|
this.fireTableDataChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @return the header
|
|
|
|
*/
|
|
|
|
public String[] getHeader() {
|
|
|
|
return header;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @param header the header to set
|
|
|
|
*/
|
|
|
|
public void setHeader(String[] header) {
|
|
|
|
this.header = header;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|