root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / table / gui / TableModelProperties.java @ 29596
History | View | Annotate | Download (5.02 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.app.project.documents.table.gui; |
42 |
|
43 |
|
44 |
import java.util.BitSet; |
45 |
|
46 |
import javax.swing.table.AbstractTableModel; |
47 |
|
48 |
import org.gvsig.andami.PluginServices; |
49 |
import org.gvsig.app.project.documents.table.FeatureTableDocument; |
50 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
51 |
|
52 |
|
53 |
|
54 |
/**
|
55 |
* Modelo para la JTable de MapProperties
|
56 |
*
|
57 |
* @author Fernando Gonz?lez Cort?s
|
58 |
*/
|
59 |
public class TableModelProperties extends AbstractTableModel { |
60 |
/**
|
61 |
*
|
62 |
*/
|
63 |
private static final long serialVersionUID = -5988213143909485019L; |
64 |
private BitSet visibles = new BitSet(); |
65 |
private String[] alias; |
66 |
private FeatureTableDocument table;
|
67 |
|
68 |
/**
|
69 |
* Creates a new MyTableModel object.
|
70 |
*
|
71 |
* @param t Tabla del proyecto que se quiere mostrar
|
72 |
* @throws DriverException
|
73 |
*/
|
74 |
public TableModelProperties(FeatureTableDocument t) {
|
75 |
FeatureStore store = t.getStore(); |
76 |
// alias = t.getAliases();
|
77 |
// int[] mapping = t.getMapping();
|
78 |
// visibles = new BitSet();
|
79 |
// for (int i = 0; i < mapping.length; i++) {
|
80 |
// visibles.set(mapping[i]);
|
81 |
// }
|
82 |
|
83 |
table = t; |
84 |
} |
85 |
|
86 |
/**
|
87 |
* @see javax.swing.table.TableModel#getColumnCount()
|
88 |
*/
|
89 |
public int getColumnCount() { |
90 |
return 3; |
91 |
} |
92 |
|
93 |
/* (non-Javadoc)
|
94 |
* @see javax.swing.table.TableModel#getRowCount()
|
95 |
*/
|
96 |
public int getRowCount() { |
97 |
// try {
|
98 |
// return table.getModelo().getRecordset().getFieldCount();
|
99 |
// } catch (ReadDriverException e) {
|
100 |
// NotificationManager.addError("No se pudo leer la informaci?n de la tabla",
|
101 |
// e);
|
102 |
// return 0;
|
103 |
// }
|
104 |
return 0; // FIXME |
105 |
} |
106 |
|
107 |
/* (non-Javadoc)
|
108 |
* @see javax.swing.table.TableModel#getValueAt(int, int)
|
109 |
*/
|
110 |
public Object getValueAt(int rowIndex, int columnIndex) { |
111 |
// if (columnIndex == 0) {
|
112 |
// return new Boolean(visibles.get(rowIndex));
|
113 |
// } else if (columnIndex == 1) {
|
114 |
// try {
|
115 |
// return table.getModelo().getRecordset().getFieldName(rowIndex);
|
116 |
// } catch (ReadDriverException e) {
|
117 |
// NotificationManager.addError("Error accediendo al nombre del campo",
|
118 |
// e);
|
119 |
// return "error!";
|
120 |
// }
|
121 |
// } else {
|
122 |
// // rowIndex++;
|
123 |
// return alias[rowIndex];
|
124 |
// }
|
125 |
return null; // FIXME |
126 |
} |
127 |
|
128 |
/* (non-Javadoc)
|
129 |
* @see javax.swing.table.TableModel#getColumnClass(int)
|
130 |
*/
|
131 |
public Class getColumnClass(int columnIndex) { |
132 |
if (columnIndex == 0) { |
133 |
return Boolean.class; |
134 |
} |
135 |
|
136 |
return String.class; |
137 |
} |
138 |
|
139 |
/* (non-Javadoc)
|
140 |
* @see javax.swing.table.TableModel#isCellEditable(int, int)
|
141 |
*/
|
142 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
143 |
return (columnIndex != 1); |
144 |
} |
145 |
|
146 |
/* (non-Javadoc)
|
147 |
* @see javax.swing.table.TableModel#setValueAt(java.lang.Object, int, int)
|
148 |
*/
|
149 |
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
150 |
if (columnIndex == 0) { |
151 |
visibles.set(rowIndex, ((Boolean) aValue).booleanValue());
|
152 |
} else {
|
153 |
alias[rowIndex] = aValue.toString(); |
154 |
} |
155 |
} |
156 |
|
157 |
/* (non-Javadoc)
|
158 |
* @see javax.swing.table.TableModel#getColumnName(int)
|
159 |
*/
|
160 |
public String getColumnName(int column) { |
161 |
String ret = null; |
162 |
|
163 |
switch (column) {
|
164 |
case 0: |
165 |
ret = PluginServices.getText(this, "visible"); |
166 |
|
167 |
break;
|
168 |
|
169 |
case 1: |
170 |
ret = PluginServices.getText(this, "campo"); |
171 |
|
172 |
break;
|
173 |
|
174 |
case 2: |
175 |
ret = PluginServices.getText(this, "alias"); |
176 |
|
177 |
break;
|
178 |
} |
179 |
|
180 |
return ret;
|
181 |
} |
182 |
|
183 |
public String[] getAliases() { |
184 |
// return table.getAliases();
|
185 |
return alias;
|
186 |
} |
187 |
|
188 |
public int[] getFieldMapping() { |
189 |
int[] mapping = new int[visibles.cardinality()]; |
190 |
int index = 0; |
191 |
for(int i=visibles.nextSetBit(0); i>=0; i=visibles.nextSetBit(i+1)) { |
192 |
mapping[index] = i; |
193 |
index++; |
194 |
} |
195 |
|
196 |
return mapping;
|
197 |
} |
198 |
} |