-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrentistaDataModel.java
More file actions
94 lines (80 loc) · 2.43 KB
/
Copy pathFrentistaDataModel.java
File metadata and controls
94 lines (80 loc) · 2.43 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
90
91
92
93
/*
* 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.Colaborador;
import relatorpostoeaton.entities.Frentista;
/**
*
* @author icarlos
*/
public class ColaboradorDataModel extends AbstractTableModel {
private static final long serialVersionUID = 1L;
private Object[] data[];
private String[] columnNames = {"Nome", "Apelido", "NumeroCadastro", "DataNasc", "TipoColaborador", "Sexo", "RegLocal", "Função","NumTag"};
public ColaboradorDataModel(List<Colaborador> mytabledata) {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy");
data = new Object[mytabledata.size()][columnNames.length];
int i = 0;
for (Colaborador colab : mytabledata) {
data[i][0] = colab.getNomFun();
data[i][1] = colab.getApeFun();
data[i][2] = colab.getColaboradorPK().getNumCad();
data[i][3] = sdf.format(colab.getDatNas());
data[i][4] = colab.getColaboradorPK().getTipCol();
data[i][5] = colab.getTipSex();
data[i][6] = colab.getColaboradorPK().getRegLocal();
if (colab instanceof Frentista) {
data[i][7] = "Frentista";
} else {
data[i][7] = "Colaborador";
}
data[i][8] = colab.getTag();
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;
}
}