svn-gvsig-desktop / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / attributesTree / AttributesTreeTableModel.java @ 8663
History | View | Annotate | Download (6.05 KB)
1 |
package com.iver.cit.gvsig.gui.panels.attributesTree; |
---|---|
2 |
|
3 |
import java.util.Vector; |
4 |
|
5 |
import org.gvsig.gui.beans.swing.treeTable.AbstractTreeTableModel; |
6 |
import org.gvsig.gui.beans.swing.treeTable.TreeTableModel; |
7 |
import org.gvsig.remoteClient.gml.schemas.GMLGeometryType; |
8 |
import org.gvsig.remoteClient.gml.schemas.IXMLType; |
9 |
import org.gvsig.remoteClient.gml.schemas.XMLComplexType; |
10 |
import org.gvsig.remoteClient.gml.schemas.XMLElement; |
11 |
|
12 |
import com.iver.andami.PluginServices; |
13 |
import com.iver.cit.gvsig.fmap.drivers.wfs.WFSUtils; |
14 |
|
15 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
16 |
*
|
17 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
18 |
*
|
19 |
* This program is free software; you can redistribute it and/or
|
20 |
* modify it under the terms of the GNU General Public License
|
21 |
* as published by the Free Software Foundation; either version 2
|
22 |
* of the License, or (at your option) any later version.
|
23 |
*
|
24 |
* This program is distributed in the hope that it will be useful,
|
25 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
26 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
27 |
* GNU General Public License for more details.
|
28 |
*
|
29 |
* You should have received a copy of the GNU General Public License
|
30 |
* along with this program; if not, write to the Free Software
|
31 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
32 |
*
|
33 |
* For more information, contact:
|
34 |
*
|
35 |
* Generalitat Valenciana
|
36 |
* Conselleria d'Infraestructures i Transport
|
37 |
* Av. Blasco Ib??ez, 50
|
38 |
* 46010 VALENCIA
|
39 |
* SPAIN
|
40 |
*
|
41 |
* +34 963862235
|
42 |
* gvsig@gva.es
|
43 |
* www.gvsig.gva.es
|
44 |
*
|
45 |
* or
|
46 |
*
|
47 |
* IVER T.I. S.A
|
48 |
* Salamanca 50
|
49 |
* 46005 Valencia
|
50 |
* Spain
|
51 |
*
|
52 |
* +34 963163400
|
53 |
* dac@iver.es
|
54 |
*/
|
55 |
/* CVS MESSAGES:
|
56 |
*
|
57 |
* $Id: AttributesTreeTableModel.java 8663 2006-11-10 09:04:33Z ppiqueras $
|
58 |
* $Log$
|
59 |
* Revision 1.5 2006-11-10 09:04:33 ppiqueras
|
60 |
* La geometr?a no se visualiza en el ?rbol del panel de filtro, pero s? en el de atributos
|
61 |
*
|
62 |
* Revision 1.4 2006/11/01 17:29:07 jorpiell
|
63 |
* Se ha elimiado el nodo virtual de la raiz. Adem?s ya se cargan los valores de un campo complejo en la pesta?a del filtro
|
64 |
*
|
65 |
* Revision 1.3 2006/10/31 13:51:15 ppiqueras
|
66 |
* Soporte parent Element
|
67 |
*
|
68 |
* Revision 1.2 2006/10/31 12:24:04 jorpiell
|
69 |
* Comprobado el caso en el que los atributos no tienen tipo
|
70 |
*
|
71 |
* Revision 1.1 2006/10/27 11:33:19 jorpiell
|
72 |
* A?adida la treetable con los check box para seleccionar los atributos
|
73 |
*
|
74 |
* Revision 1.2 2006/10/24 07:58:14 jorpiell
|
75 |
* Eliminado el parametro booleano que hac?a que apareciesen mas de una columna en el tree table
|
76 |
*
|
77 |
* Revision 1.1 2006/10/24 07:27:56 jorpiell
|
78 |
* Algunos cambios en el modelo que usa la tabla
|
79 |
*
|
80 |
* Revision 1.2 2006/10/23 08:17:18 jorpiell
|
81 |
* Algunos cambios realizados para tener un ?rbol com m?s de una ra?z
|
82 |
*
|
83 |
* Revision 1.1 2006/10/23 07:37:04 jorpiell
|
84 |
* Ya funciona el filterEncoding
|
85 |
*
|
86 |
*
|
87 |
*/
|
88 |
/**
|
89 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
90 |
*/
|
91 |
public class AttributesTreeTableModel extends AbstractTreeTableModel { |
92 |
private boolean showGeometry; |
93 |
private String[] cNames = {PluginServices.getText(this,"attributeName"), |
94 |
PluginServices.getText(this,"attributeType")}; |
95 |
private Class[] cTypes = {TreeTableModel.class,String.class}; |
96 |
|
97 |
public AttributesTreeTableModel(Object root) { |
98 |
super(root);
|
99 |
showGeometry = true;
|
100 |
} |
101 |
|
102 |
public AttributesTreeTableModel(Object root, boolean show_Geometry) { |
103 |
super(root);
|
104 |
showGeometry = show_Geometry; |
105 |
} |
106 |
|
107 |
public AttributesTreeTableModel() {
|
108 |
super(null); |
109 |
showGeometry = true;
|
110 |
} |
111 |
|
112 |
public boolean getShowGeometry() { |
113 |
return showGeometry;
|
114 |
} |
115 |
|
116 |
//
|
117 |
// The TreeModel interface
|
118 |
//
|
119 |
|
120 |
public int getChildCount(Object node) { |
121 |
XMLElement element = (XMLElement)node; |
122 |
if (element.getEntityType().getType() == IXMLType.COMPLEX){
|
123 |
|
124 |
// It's supposed that geometry is on level 1
|
125 |
Vector attributes = ((XMLComplexType)element.getEntityType()).getAttributes();
|
126 |
int size = attributes.size();
|
127 |
|
128 |
if (!showGeometry) {
|
129 |
for (int i = 0; i < attributes.size(); i++) { |
130 |
if (((XMLElement)attributes.get(i)).getEntityType().getType() == IXMLType.GML_GEOMETRY)
|
131 |
size --; |
132 |
} |
133 |
} |
134 |
|
135 |
return size;
|
136 |
}else{
|
137 |
return 0; |
138 |
} |
139 |
} |
140 |
|
141 |
public Object getChild(Object node, int i) { |
142 |
XMLElement element = (XMLElement)node; |
143 |
if (element.getEntityType().getType() == IXMLType.COMPLEX){
|
144 |
Vector attributes = ((XMLComplexType)element.getEntityType()).getAttributes();
|
145 |
XMLElement child = null;
|
146 |
int k = -1; |
147 |
|
148 |
if (!showGeometry) {
|
149 |
for (int j = 0; j < attributes.size(); j++) { |
150 |
child = (XMLElement) attributes.get(j); |
151 |
|
152 |
if (child.getEntityType().getType() != IXMLType.GML_GEOMETRY)
|
153 |
k++; |
154 |
|
155 |
if (i == k)
|
156 |
break;
|
157 |
} |
158 |
} |
159 |
else {
|
160 |
child = (XMLElement) attributes.get(i); |
161 |
} |
162 |
|
163 |
child.setParentElement(element); |
164 |
|
165 |
return child;
|
166 |
} |
167 |
return null; |
168 |
} |
169 |
|
170 |
// The superclass's implementation would work, but this is more efficient.
|
171 |
public boolean isLeaf(Object node) { |
172 |
if (node == null){ |
173 |
return true; |
174 |
} |
175 |
XMLElement element = (XMLElement)node; |
176 |
if (element.getEntityType() != null){ |
177 |
if (element.getEntityType().getType() == IXMLType.COMPLEX){
|
178 |
return false; |
179 |
} |
180 |
} |
181 |
return true; |
182 |
} |
183 |
|
184 |
/*
|
185 |
* (non-Javadoc)
|
186 |
* @see org.gvsig.gui.beans.swing.treeTable.TreeTableModel#getColumnCount()
|
187 |
*/
|
188 |
public int getColumnCount() { |
189 |
return cNames.length;
|
190 |
} |
191 |
|
192 |
/*
|
193 |
* (non-Javadoc)
|
194 |
* @see org.gvsig.gui.beans.swing.treeTable.TreeTableModel#getColumnName(int)
|
195 |
*/
|
196 |
public String getColumnName(int column) { |
197 |
return cNames[column];
|
198 |
} |
199 |
|
200 |
/*
|
201 |
* (non-Javadoc)
|
202 |
* @see org.gvsig.gui.beans.swing.treeTable.TreeTableModel#getColumnClass(int)
|
203 |
*/
|
204 |
public Class getColumnClass(int column) { |
205 |
return cTypes[column];
|
206 |
} |
207 |
|
208 |
/*
|
209 |
* (non-Javadoc)
|
210 |
* @see org.gvsig.gui.beans.swing.treeTable.TreeTableModel#getValueAt(java.lang.Object, int)
|
211 |
*/
|
212 |
public Object getValueAt(Object node, int column) { |
213 |
XMLElement element = (XMLElement)node; |
214 |
try {
|
215 |
switch(column) {
|
216 |
case 0: |
217 |
return element.getName();
|
218 |
case 1: |
219 |
return PluginServices.getText(this,WFSUtils.getAttributeType(element.getEntityType())); |
220 |
} |
221 |
} |
222 |
catch (SecurityException se) { } |
223 |
|
224 |
return null; |
225 |
} |
226 |
} |
227 |
|
228 |
|