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.ConnaissanceBean;
32  import org.xmlcv.model.ConnaissanceBean.Nom;
33  import org.xmlcv.model.CvDocumentBean.Cv.Connaissances;
34  
35  /***
36   * @version $Revision: 114 $
37   * @author <a href="mailto:drazzib@drazzib.com">Damien Raude-Morvan</a>
38   */
39  public class KnowledgeTableModel extends AbstractTableModel {
40  
41  	private Connaissances _connaissances;
42  
43  	public KnowledgeTableModel(Connaissances pConnaissances) {
44  		assert pConnaissances != null;
45  
46  		this._connaissances = pConnaissances;
47  	}
48  
49  	/*
50  	 * (non-Javadoc)
51  	 * 
52  	 * @see javax.swing.table.TableModel#getColumnCount()
53  	 */
54  	public int getColumnCount() {
55  		return 1;
56  	}
57  
58  	/*
59  	 * (non-Javadoc)
60  	 * 
61  	 * @see javax.swing.table.TableModel#getColumnName(int)
62  	 */
63  	public String getColumnName(int col) {
64  		return "Connaissance";
65  	}
66  
67  	/*
68  	 * (non-Javadoc)
69  	 * 
70  	 * @see javax.swing.table.TableModel#getRowCount()
71  	 */
72  	public int getRowCount() {
73  		return this._connaissances.sizeOfDisciplineArray();
74  	}
75  
76  	/*
77  	 * (non-Javadoc)
78  	 * 
79  	 * @see javax.swing.table.TableModel#getValueAt(int, int)
80  	 */
81  	public Object getValueAt(int row, int column) {
82  
83  		ConnaissanceBean connaissance = this._connaissances
84  				.getDisciplineArray(row);
85  
86  		String label = null;
87  
88  		label = connaissance.getNom2() + " : "; //$NON-NLS-1$
89  
90  		Nom[] noms = connaissance.getNomArray();
91  		for (int i = 0; i < noms.length; i++) {
92  			if (noms[i].getStringValue() != null) {
93  				label = label + noms[i].getStringValue() + " "; //$NON-NLS-1$
94  			}
95  		}
96  		label = label + "..."; //$NON-NLS-1$
97  
98  		return label;
99  	}
100 
101 }