root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / table / gui / TableModelProperties.java @ 31496
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.TableDocument; |
50 |
|
51 |
|
52 |
/**
|
53 |
* Modelo para la JTable de MapProperties
|
54 |
*
|
55 |
* @author Fernando Gonz?lez Cort?s
|
56 |
*/
|
57 |
public class TableModelProperties extends AbstractTableModel { |
58 |
/**
|
59 |
*
|
60 |
*/
|
61 |
private static final long serialVersionUID = -5988213143909485019L; |
62 |
private BitSet visibles = new BitSet(); |
63 |
private String[] alias; |
64 |
// private FeatureTableDocument table;
|
65 |
|
66 |
/**
|
67 |
* Creates a new MyTableModel object.
|
68 |
*
|
69 |
* @param t Tabla del proyecto que se quiere mostrar
|
70 |
*/
|
71 |
public TableModelProperties(TableDocument t) {
|
72 |
// FeatureStore store = t.getStore();
|
73 |
// alias = t.getAliases();
|
74 |
// int[] mapping = t.getMapping();
|
75 |
// visibles = new BitSet();
|
76 |
// for (int i = 0; i < mapping.length; i++) {
|
77 |
// visibles.set(mapping[i]);
|
78 |
// }
|
79 |
|
80 |
// table = t;
|
81 |
} |
82 |
|
83 |
/**
|
84 |
* @see javax.swing.table.TableModel#getColumnCount()
|
85 |
*/
|
86 |
public int getColumnCount() { |
87 |
return 3; |
88 |
} |
89 |
|
90 |
/* (non-Javadoc)
|
91 |
* @see javax.swing.table.TableModel#getRowCount()
|
92 |
*/
|
93 |
public int getRowCount() { |
94 |
// try {
|
95 |
// return table.getModelo().getRecordset().getFieldCount();
|
96 |
// } catch (ReadDriverException e) {
|
97 |
// NotificationManager.addError("No se pudo leer la informaci?n de la tabla",
|
98 |
// e);
|
99 |
// return 0;
|
100 |
// }
|
101 |
return 0; // FIXME falta por calcular el row count |
102 |
} |
103 |
|
104 |
/* (non-Javadoc)
|
105 |
* @see javax.swing.table.TableModel#getValueAt(int, int)
|
106 |
*/
|
107 |
public Object getValueAt(int rowIndex, int columnIndex) { |
108 |
// if (columnIndex == 0) {
|
109 |
// return new Boolean(visibles.get(rowIndex));
|
110 |
// } else if (columnIndex == 1) {
|
111 |
// try {
|
112 |
// return table.getModelo().getRecordset().getFieldName(rowIndex);
|
113 |
// } catch (ReadDriverException e) {
|
114 |
// NotificationManager.addError("Error accediendo al nombre del campo",
|
115 |
// e);
|
116 |
// return "error!";
|
117 |
// }
|
118 |
// } else {
|
119 |
// // rowIndex++;
|
120 |
// return alias[rowIndex];
|
121 |
// }
|
122 |
return null; // FIXME ? siempre retorna null ? |
123 |
} |
124 |
|
125 |
/* (non-Javadoc)
|
126 |
* @see javax.swing.table.TableModel#getColumnClass(int)
|
127 |
*/
|
128 |
@SuppressWarnings("unchecked") |
129 |
public Class getColumnClass(int columnIndex) { |
130 |
if (columnIndex == 0) { |
131 |
return Boolean.class; |
132 |
} |
133 |
|
134 |
return String.class; |
135 |
} |
136 |
|
137 |
/* (non-Javadoc)
|
138 |
* @see javax.swing.table.TableModel#isCellEditable(int, int)
|
139 |
*/
|
140 |
public boolean isCellEditable(int rowIndex, int columnIndex) { |
141 |
return (columnIndex != 1); |
142 |
} |
143 |
|
144 |
/* (non-Javadoc)
|
145 |
* @see javax.swing.table.TableModel#setValueAt(java.lang.Object, int, int)
|
146 |
*/
|
147 |
public void setValueAt(Object aValue, int rowIndex, int columnIndex) { |
148 |
if (columnIndex == 0) { |
149 |
visibles.set(rowIndex, ((Boolean) aValue).booleanValue());
|
150 |
} else {
|
151 |
alias[rowIndex] = aValue.toString(); |
152 |
} |
153 |
} |
154 |
|
155 |
/* (non-Javadoc)
|
156 |
* @see javax.swing.table.TableModel#getColumnName(int)
|
157 |
*/
|
158 |
public String getColumnName(int column) { |
159 |
String ret = null; |
160 |
|
161 |
switch (column) {
|
162 |
case 0: |
163 |
ret = PluginServices.getText(this, "visible"); |
164 |
|
165 |
break;
|
166 |
|
167 |
case 1: |
168 |
ret = PluginServices.getText(this, "campo"); |
169 |
|
170 |
break;
|
171 |
|
172 |
case 2: |
173 |
ret = PluginServices.getText(this, "alias"); |
174 |
|
175 |
break;
|
176 |
} |
177 |
|
178 |
return ret;
|
179 |
} |
180 |
|
181 |
public String[] getAliases() { |
182 |
// return table.getAliases();
|
183 |
return alias;
|
184 |
} |
185 |
|
186 |
public int[] getFieldMapping() { |
187 |
int[] mapping = new int[visibles.cardinality()]; |
188 |
int index = 0; |
189 |
for(int i=visibles.nextSetBit(0); i>=0; i=visibles.nextSetBit(i+1)) { |
190 |
mapping[index] = i; |
191 |
index++; |
192 |
} |
193 |
|
194 |
return mapping;
|
195 |
} |
196 |
} |