Coverage details for net.sourceforge.demetrix.ui.balancesheets.BalanceSheetTableModel

LineHitsSource
1 /*******************************************************************************
2  
3  * Demetrix process modelling system
4  
5  *
6  
7  * Copyright (c) 2003, 2004 Dimitri A. Pissarenko
8  
9  *
10  
11  * This file is part of Demetrix.
12  
13  *
14  
15  * Demetrix is free software; you can redistribute it and/or modify
16  
17  * it under the terms of the GNU General Public License as published by
18  
19  * the Free Software Foundation; either version 2.1 of the License, or
20  
21  * (at your option) any later version.
22  
23  *
24  
25  * Demetrix is distributed in the hope that it will be useful,
26  
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of
28  
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  
31  * GNU General Public License for more details.
32  
33  *
34  
35  * You should have received a copy of the GNU General Public License
36  
37  * along with Demetrix; if not, write to the Free Software
38  
39  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
40  
41  *
42  
43  * For further information you may
44  
45  *
46  
47  * - send an e-mail in Russian, German or English to dimitri.pissarenko@gmx.net
48  
49  * - look at http://sourceforge.net/projects/demetrix/
50  
51  * - look at http://demetrix.sourceforge.net/
52  
53  * - look at http://members.inode.at/d.pissarenko/
54  
55  *
56  
57  *****************************************************************************/
58  
59  
60  
61 package net.sourceforge.demetrix.ui.balancesheets;
62  
63  
64  
65 import java.util.ArrayList;
66  
67  
68  
69 import javax.swing.table.DefaultTableModel;
70  
71  
72  
73 import net.sourceforge.demetrix.properties.DemetrixPropertiesHolder;
74  
75 import net.sourceforge.demetrix.properties.DemetrixPropertiesStorage;
76  
77  
78  
79 public class BalanceSheetTableModel extends DefaultTableModel {
80  
81     private ArrayList columnNames;
82  
83     private ArrayList rows;
84  
85     public BalanceSheetTableModel(ArrayList resources)
86  
87     {
88  
892        super();
90  
91         
92  
932        this.rows=resources;
94  
952        this.columnNames=DemetrixPropertiesStorage.getAllPropertyNames(this.rows);
96  
972    }
98  
99     
100  
101     /* (non-Javadoc)
102  
103      * @see javax.swing.table.TableModel#getColumnClass(int)
104  
105      */
106  
107     public Class getColumnClass(int col) {
108  
1090        return getValueAt(0, col).getClass();
110  
111     }
112  
113     /* (non-Javadoc)
114  
115      * @see javax.swing.table.TableModel#getColumnCount()
116  
117      */
118  
119     public int getColumnCount() {
120  
1212        return this.columnNames.size();
122  
123     }
124  
125     /* (non-Javadoc)
126  
127      * @see javax.swing.table.TableModel#getColumnName(int)
128  
129      */
130  
131     public String getColumnName(int index) {
132  
1330        return (String)this.columnNames.get(index);
134  
135     }
136  
137  
138  
139     /* (non-Javadoc)
140  
141      * @see javax.swing.table.TableModel#getRowCount()
142  
143      */
144  
145     public int getRowCount() {
146  
1474        if (this.rows!=null)
148  
149         {
150  
1510            return this.rows.size();
152  
153         }
154  
155         else
156  
157         {
158  
1594            return 0;
160  
161         }
162  
163     }
164  
165  
166  
167     /* (non-Javadoc)
168  
169      * @see javax.swing.table.TableModel#getValueAt(int, int)
170  
171      */
172  
173     public Object getValueAt(int row, int col) {
174  
1750        DemetrixPropertiesHolder inputOrOutput=null;
176  
1770        String propertyName=null;
178  
179         
180  
1810        inputOrOutput=(DemetrixPropertiesHolder)this.rows.get(row);
182  
1830        propertyName=(String)this.columnNames.get(col);
184  
185             
186  
1870        return inputOrOutput.getProperty(propertyName).getValue();
188  
189     }
190  
191  
192  
193     /* (non-Javadoc)
194  
195      * @see javax.swing.table.TableModel#isCellEditable(int, int)
196  
197      */
198  
199     public boolean isCellEditable(int row, int col) {
200  
2010        DemetrixPropertiesHolder inputOrOutput=null;
202  
2030        String propertyName=null;
204  
205         
206  
2070        inputOrOutput=(DemetrixPropertiesHolder)this.rows.get(row);
208  
2090        propertyName=(String)this.columnNames.get(col);
210  
211         
212  
2130        return !(inputOrOutput.getProperty(propertyName).isReadOnly());
214  
215  
216  
217     }
218  
219  
220  
221     /* (non-Javadoc)
222  
223      * @see javax.swing.table.TableModel#setValueAt(java.lang.Object, int, int)
224  
225      */
226  
227     public void setValueAt(Object value, int row, int col) {
228  
2290        DemetrixPropertiesHolder inputOrOutput=null;
230  
2310        String propertyName=null;
232  
233         
234  
2350        inputOrOutput=(DemetrixPropertiesHolder)this.rows.get(row);
236  
2370        propertyName=(String)this.columnNames.get(col);
238  
239  
240  
2410        inputOrOutput.getProperty(propertyName).setValue(value);
242  
2430    }
244  
245 }
246  

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.