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 package org.xmlcv.gui.tables;
28
29 import javax.swing.table.AbstractTableModel;
30
31 import org.xmlcv.model.RealisationBean;
32 import org.xmlcv.model.AuteursBean.Auteur;
33 import org.xmlcv.model.CvDocumentBean.Cv.Realisations;
34
35 /***
36 * @version $Revision: 114 $
37 * @author <a href="mailto:drazzib@drazzib.com">Damien Raude-Morvan</a>
38 */
39 public class ProjectsTableModel extends AbstractTableModel {
40
41 private static String[] columnNames = new String[] { "Titre", "Date",
42 "Description", "Lieux", "Outils", "Auteurs"
43
44 };
45
46 private static final int TITRE = 0;
47
48 private static final int DATE = 1;
49
50 private static final int DESCRIPTION = 2;
51
52 private static final int LIEUX = 3;
53
54 private static final int OUTILS = 4;
55
56 private static final int AUTEURS = 5;
57
58 private Realisations _realisations;
59
60 public ProjectsTableModel(Realisations pRealisations) {
61 assert pRealisations != null;
62
63 this._realisations = pRealisations;
64 }
65
66
67
68
69
70
71 public int getColumnCount() {
72 return 6;
73 }
74
75
76
77
78
79
80 public String getColumnName(int col) {
81 return ProjectsTableModel.columnNames[col];
82 }
83
84
85
86
87
88
89 public int getRowCount() {
90 return this._realisations.sizeOfRealisationArray();
91 }
92
93
94
95
96
97
98 public Object getValueAt(int row, int column) {
99
100 String label = null;
101
102 RealisationBean realisation = this._realisations
103 .getRealisationArray(row);
104
105 switch (column) {
106 case TITRE:
107 if (realisation.getTitre() != null) {
108 label = realisation.getTitre().getStringValue();
109
110 }
111 break;
112
113 case DATE:
114 label = realisation.getDate();
115 break;
116
117 case DESCRIPTION:
118 if (realisation.getDescription() != null) {
119 label = new String(realisation.getDescription()
120 .getStringValue()).trim();
121 }
122 break;
123
124 case LIEUX:
125 label = realisation.getLieux();
126 break;
127
128 case OUTILS:
129 label = realisation.getOutils();
130 break;
131
132 case AUTEURS:
133 if (realisation.getAuteurs() != null) {
134 Auteur[] auteurs = realisation.getAuteurs().getAuteurArray();
135 for (int i = 0; i < auteurs.length; i++) {
136 if (auteurs[i].getPrenom() != null
137 && auteurs[i].getNom() != null) {
138 label = label + auteurs[i].getPrenom()
139 + " " + auteurs[i].getNom() + " ";
140 }
141 }
142 label = label + "...";
143 }
144 break;
145 }
146
147 return label;
148
149 }
150
151 }