View Javadoc

1   /*
2    * XMLCV - Gestion de CV sous forme XML
3    * 
4    * Copyright (C) 2004-2005, Damien Raude-Morvan
5    * 
6    * This file is part of XMLCV.
7    *
8    * XMLCV is free software; you can redistribute it and/or modify
9    * it under the terms of the GNU General Public License as published by
10   * the Free Software Foundation; either version 2 of the License, or
11   * (at your option) any later version.
12   *
13   * XMLCV is distributed in the hope that it will be useful,
14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16   * GNU General Public License for more details.
17   *
18   * You should have received a copy of the GNU General Public License
19   * along with XMLCV; if not, write to the Free Software
20   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21   * 
22   * Contacts :
23   * - Sébastien Mathy <smathy@tuxfamily.org>
24   * - Emmanuel Berre <eberre@tuxfamily.org>
25   * - Damien Raude-Morvan <drazzib@drazzib.com>
26   */
27  package org.xmlcv.gui.tables;
28  
29  import javax.swing.table.AbstractTableModel;
30  
31  import org.xmlcv.model.FormationBean;
32  import org.xmlcv.model.CvDocumentBean.Cv.Formations;
33  
34  /***
35   * @version $Revision: 114 $
36   * @author <a href="mailto:drazzib@drazzib.com">Damien Raude-Morvan </a>
37   */
38  public class EducationTableModel extends AbstractTableModel {
39  
40  	private Formations _formations;
41  
42  	private static String[] columnNames = new String[] { "Diplome", "Option",
43  			"Description", "Ecole", "Ville", "Date"
44  
45  	};
46  
47  	private static final int DIPLOME = 0;
48  
49  	private static final int OPTION = 1;
50  
51  	private static final int DESC = 2;
52  
53  	private static final int ECOLE = 3;
54  
55  	private static final int VILLE = 4;
56  
57  	private static final int DATE = 5;
58  
59  	public EducationTableModel(Formations formations) {
60  		assert formations != null;
61  
62  		this._formations = formations;
63  	}
64  
65  	/*
66  	 * (non-Javadoc)
67  	 * 
68  	 * @see javax.swing.table.TableModel#getColumnCount()
69  	 */
70  	public int getColumnCount() {
71  		return 6;
72  	}
73  
74  	/*
75  	 * (non-Javadoc)
76  	 * 
77  	 * @see javax.swing.table.TableModel#getColumnName(int)
78  	 */
79  	public String getColumnName(int col) {
80  		return EducationTableModel.columnNames[col];
81  	}
82  
83  	/*
84  	 * (non-Javadoc)
85  	 * 
86  	 * @see javax.swing.table.TableModel#getRowCount()
87  	 */
88  	public int getRowCount() {
89  		return this._formations.sizeOfFormationArray();
90  	}
91  
92  	/*
93  	 * (non-Javadoc)
94  	 * 
95  	 * @see javax.swing.table.TableModel#getValueAt(int, int)
96  	 */
97  	public Object getValueAt(int row, int column) {
98  
99  		String label = null;
100 
101 		FormationBean formation = this._formations.getFormationArray(row);
102 
103 		switch (column) {
104 
105 		case EducationTableModel.DIPLOME:
106 			if (formation.getDiplome() != null) {
107 				label = formation.getDiplome().getStringValue() + "("
108 						+ formation.getDiplome().getAcronyme() + ")";
109 			}
110 			break;
111 
112 		case EducationTableModel.OPTION:
113 			if (formation.getOption() != null) {
114 				label = formation.getOption().getStringValue();
115 			}
116 			break;
117 
118 		case EducationTableModel.DESC:
119 			if (formation.getDescription() != null) {
120 				label = formation.getDescription().getStringValue();
121 			}
122 			break;
123 
124 		case EducationTableModel.ECOLE:
125 			if (formation.getEcole() != null) {
126 				label = formation.getEcole().getStringValue() + "("
127 						+ formation.getEcole().getAcronyme() + ")";
128 			}
129 			break;
130 
131 		case EducationTableModel.VILLE:
132 			label = formation.getVille();
133 			break;
134 
135 		case EducationTableModel.DATE:
136 			label = String.valueOf(formation.getDate());
137 			break;
138 
139 		}
140 
141 		return label;
142 	}
143 
144 }