-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathabastecDataModel.java
More file actions
90 lines (74 loc) · 2.16 KB
/
Copy pathabastecDataModel.java
File metadata and controls
90 lines (74 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package relatorpostoeaton.business.datamodels;
import java.text.SimpleDateFormat;
import java.util.List;
import javax.swing.table.AbstractTableModel;
import relatorpostoeaton.entities.Abastecimento;
/**
*
* @author icarlos
*/
public class AbastecimentoDataModel extends AbstractTableModel{
private static final long serialVersionUID = 1L;
private Object[] data[];
private String[] columnNames = {"ID", "Motorista", "Carro", "DataAbastecimento", "Frentista","Combustivel","KM","Litros"};
public AbastecimentoDataModel(List<Abastecimento> mytabledata) {
data = new Object[mytabledata.size()][columnNames.length];
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
int i = 0;
for (Abastecimento abt : mytabledata) {
data[i][0] = abt.getId();
data[i][1] = abt.getMotorista();
data[i][2] = abt.getCarro();
data[i][3] = sdf.format(abt.getDataAbastecimento());
data[i][4] = abt.getFrentista();
data[i][5] = abt.getCombustivel();
data[i][6] = abt.getKm();
data[i][7] = abt.getLitros();
i++;
}
}
public int getRowCount() {
if (data != null) {
return data.length;
}
return 0;
}
public int getColumnCount() {
return columnNames.length;
}
public Object getValueAt(int rowIndex, int columnIndex) {
return data[rowIndex][columnIndex];
}
@Override
public String getColumnName(int column) {
return columnNames[column];
}
/**
* @return the data
*/
public Object[][] getData() {
return data;
}
/**
* @param data the data to set
*/
public void setData(Object[][] data) {
this.data = data;
}
/**
* @return the columnNames
*/
public String[] getColumnNames() {
return columnNames;
}
/**
* @param columnNames the columnNames to set
*/
public void setColumnNames(String[] columnNames) {
this.columnNames = columnNames;
}
}