|
|
@ -5,18 +5,20 @@ import java.util.ArrayList; |
|
|
|
import javax.swing.table.AbstractTableModel; |
|
|
|
import javax.swing.table.AbstractTableModel; |
|
|
|
|
|
|
|
|
|
|
|
public class ReportTableModel extends AbstractTableModel{ |
|
|
|
public class ReportTableModel extends AbstractTableModel{ |
|
|
|
private Object[] header;// = new String[]{"id", "login", "mail"};
|
|
|
|
private Object[] header; |
|
|
|
private Object[][] data; |
|
|
|
private Object[][] data; |
|
|
|
|
|
|
|
//создаем модель без данных
|
|
|
|
public ReportTableModel(){} |
|
|
|
public ReportTableModel(){} |
|
|
|
public ReportTableModel(Object[] header, Object[][] data){ |
|
|
|
public ReportTableModel(Object[] header, Object[][] data){ |
|
|
|
setHeader(header); |
|
|
|
setHeader(header); |
|
|
|
setData(data); |
|
|
|
setData(data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//создаем модель по данным Data
|
|
|
|
public ReportTableModel(Data data){ |
|
|
|
public ReportTableModel(Data data){ |
|
|
|
setHeader(getHeaderByQuize(data)); |
|
|
|
setHeader(getHeaderByQuize(data)); |
|
|
|
setData(data); |
|
|
|
setData(data); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//создаем модель по данным предварительно переданным в App
|
|
|
|
public ReportTableModel(App app){ |
|
|
|
public ReportTableModel(App app){ |
|
|
|
setHeader(getHeaderByQuize(app.getData())); |
|
|
|
setHeader(getHeaderByQuize(app.getData())); |
|
|
|
setData(app.getData()); |
|
|
|
setData(app.getData()); |
|
|
@ -62,7 +64,7 @@ public class ReportTableModel extends AbstractTableModel{ |
|
|
|
int i = 0; |
|
|
|
int i = 0; |
|
|
|
while (i < report.getQuizes().size()){ |
|
|
|
while (i < report.getQuizes().size()){ |
|
|
|
header.add(report.getQuizes().get(i).getName()); |
|
|
|
header.add(report.getQuizes().get(i).getName()); |
|
|
|
System.out.println("Пишем заголовок: " + report.getQuizes().get(i).getName()); |
|
|
|
//System.out.println("Пишем заголовок: " + report.getQuizes().get(i).getName());
|
|
|
|
header.add(""); |
|
|
|
header.add(""); |
|
|
|
i++; |
|
|
|
i++; |
|
|
|
} |
|
|
|
} |
|
|
@ -86,6 +88,9 @@ public class ReportTableModel extends AbstractTableModel{ |
|
|
|
public void setData(Data report) { |
|
|
|
public void setData(Data report) { |
|
|
|
//создаем объект data - инициализация переменной
|
|
|
|
//создаем объект data - инициализация переменной
|
|
|
|
Object[][] d = new Object[report.getUsers().size()][3 + 2*report.getQuizes().size()]; |
|
|
|
Object[][] d = new Object[report.getUsers().size()][3 + 2*report.getQuizes().size()]; |
|
|
|
|
|
|
|
System.out.println("Количество столбцов Object[][] d: " + (3 + 2*report.getQuizes().size())); |
|
|
|
|
|
|
|
System.out.println("Количество строк Object[][] d: " + report.getUsers().size()); |
|
|
|
|
|
|
|
|
|
|
|
//построчно заполняем модель отчета данными
|
|
|
|
//построчно заполняем модель отчета данными
|
|
|
|
int userCurr = 0; |
|
|
|
int userCurr = 0; |
|
|
|
while (userCurr < report.getUsers().size()){ |
|
|
|
while (userCurr < report.getUsers().size()){ |
|
|
@ -115,13 +120,16 @@ public class ReportTableModel extends AbstractTableModel{ |
|
|
|
} |
|
|
|
} |
|
|
|
//пишем строку в d
|
|
|
|
//пишем строку в d
|
|
|
|
int j = 0; |
|
|
|
int j = 0; |
|
|
|
while (j < d[userCurr].length){ |
|
|
|
while (j < string.size()){ |
|
|
|
|
|
|
|
//while (j < 3){
|
|
|
|
d[userCurr][j] = string.toArray()[j]; |
|
|
|
d[userCurr][j] = string.toArray()[j]; |
|
|
|
j++; |
|
|
|
j++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
userCurr++; |
|
|
|
userCurr++; |
|
|
|
} |
|
|
|
} |
|
|
|
this.data = d; |
|
|
|
this.data = d; |
|
|
|
|
|
|
|
fireTableDataChanged(); |
|
|
|
} |
|
|
|
} |
|
|
|
/** |
|
|
|
/** |
|
|
|
* @return the data |
|
|
|
* @return the data |
|
|
|