forked from LyricU/ProjetJavaL3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTableModel.java
More file actions
109 lines (92 loc) · 2.38 KB
/
TableModel.java
File metadata and controls
109 lines (92 loc) · 2.38 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import javax.swing.table.AbstractTableModel;
import allConnexion.Offres;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
public class TableModel extends AbstractTableModel{
protected List<Offres> data; //données
protected List<String> columnNames; //noms de colonnes
protected String[] nomCol= {"Nom_Entreprise", "Domaine", "Libelle", "Date", "Duree", "Description"};
protected String a="Nom_Entreprise", b="Domaine", c="Libelle", d="Date", e="Duree", f="Description";
/** Creates a new instance of TableModelC */
public TableModel(List<Offres> data) {
columnNames = new ArrayList<>();
this.columnNames.add(this.a);
this.columnNames.add(this.b);
this.columnNames.add(this.c);
this.columnNames.add(this.d);
this.columnNames.add(this.e);
this.columnNames.add(this.f);
this.data=data;
}
public int getRowCount() {
return data.size();//data.size()/getColumnCount();
}
public int getColumnCount() {
return columnNames.size();
}
/**
* noms des colonnes
*/
public String getColumnName(int columnIndex) {
return this.nomCol[columnIndex];
}
/**
* type de contenu d'une colonne : ici il s'agit toujours de chaînes
* de caractères.
*/
public Class<? extends Object> getColumnClass(int c){
return getValueAt(0,c).getClass();
}
/**
* possibilité d'édition des données
*/
public boolean isCellEditable(int rowIndex, int columnIndex) {
return true;
}
/**
* contenu d'une cellule
*/
public Object getValueAt(int rowIndex, int columnIndex) {
switch (columnIndex) {
case 0:
// NomEnt
return data.get(rowIndex).getNomEnt();
case 1:
// Domaine
return data.get(rowIndex).getDomaine();
case 2:
// Libelle
return data.get(rowIndex).getLibelle();
case 3:
// Date
return data.get(rowIndex).getDate();
case 4:
// Duree
return data.get(rowIndex).getDuree();
case 5:
//Description
return data.get(rowIndex).getDescriptif();
default:
throw new IllegalArgumentException();
}
}
/**
* changement du contenu d'une cellule
*/
public void setValueAt(Offres aValue, int rowIndex, int columnIndex) {
data.set((rowIndex*getColumnCount())+columnIndex, aValue);
}
public void saveVectors() {
saveAs();
}
public void saveAs() {
}
public List<Offres> getData() {
return data;
}
public void setData(List<Offres> data) {
this.data = data;
}
}