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.ExperienceBean;
32  import org.xmlcv.model.CvDocumentBean.Cv.Experiences;
33  
34  /***
35   * @version $Revision: 114 $
36   * @author <a href="mailto:drazzib@drazzib.com">Damien Raude-Morvan</a>
37   */
38  public class ExperienceTableModel extends AbstractTableModel {
39  
40  	private static String[] columnNames = new String[] { "Contrat", "Date",
41  			"Duree", "Outils", "Ville", "Entreprise", "Poste", "Sujet"
42  
43  	};
44  
45  	private static final int CONTRAT = 0;
46  
47  	private static final int DATE = 1;
48  
49  	private static final int DUREE = 2;
50  
51  	private static final int TOOLS = 3;
52  
53  	private static final int VILLE = 4;
54  
55  	private static final int ENTREPRISE = 5;
56  
57  	private static final int POSTE = 6;
58  
59  	private static final int SUJET = 7;
60  
61  	private Experiences _experiences;
62  
63  	public ExperienceTableModel(Experiences experiences) {
64  		assert experiences != null;
65  
66  		this._experiences = experiences;
67  	}
68  
69  	/*
70  	 * (non-Javadoc)
71  	 * 
72  	 * @see javax.swing.table.TableModel#getColumnCount()
73  	 */
74  	public int getColumnCount() {
75  		return 8;
76  	}
77  
78  	/*
79  	 * (non-Javadoc)
80  	 * 
81  	 * @see javax.swing.table.AbstractTableModel#getColumnName(int)
82  	 */
83  	public String getColumnName(int col) {
84  		return ExperienceTableModel.columnNames[col];
85  	}
86  
87  	/*
88  	 * (non-Javadoc)
89  	 * 
90  	 * @see javax.swing.table.TableModel#getRowCount()
91  	 */
92  	public int getRowCount() {
93  		return this._experiences.sizeOfExperienceArray();
94  	}
95  
96  	/*
97  	 * (non-Javadoc)
98  	 * 
99  	 * @see javax.swing.table.TableModel#getValueAt(int, int)
100 	 */
101 	public Object getValueAt(int row, int column) {
102 
103 		String sLabel = null;
104 
105 		ExperienceBean experience = this._experiences.getExperienceArray(row);
106 
107 		switch (column) {
108 		case CONTRAT:
109 			sLabel = experience.getContrat();
110 			break;
111 
112 		case DATE:
113 			sLabel = experience.getDate();
114 			break;
115 
116 		case DUREE:
117 			sLabel = experience.getDuree();
118 			break;
119 
120 		case TOOLS:
121 			sLabel = experience.getOutils();
122 			break;
123 
124 		case VILLE:
125 			sLabel = experience.getVille();
126 			break;
127 
128 		case ENTREPRISE:
129 			if (experience.getEntreprise() != null) {
130 				// FIXME experience.getEntreprise().getUrl();
131 				sLabel = experience.getEntreprise().getStringValue();
132 			}
133 			break;
134 
135 		case POSTE:
136 			if (experience.getPoste() != null) {
137 				sLabel = experience.getPoste().getStringValue();
138 			}
139 			break;
140 
141 		case SUJET:
142 			if (experience.getSujet() != null) {
143 				sLabel = experience.getSujet().getStringValue();
144 			}
145 			break;
146 
147 		}
148 
149 		return sLabel;
150 	}
151 
152 }