Statistics
| Revision:

root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / AttributesTreeTableModel.java @ 8273

History | View | Annotate | Download (5.67 KB)

1
package com.iver.cit.gvsig.gui.panels;
2

    
3
import java.io.File;
4
import java.util.Vector;
5

    
6
import org.gvsig.gui.beans.swing.treeTable.AbstractTreeTableModel;
7
import org.gvsig.gui.beans.swing.treeTable.MergeSort;
8
import org.gvsig.gui.beans.swing.treeTable.TreeTableModel;
9
import org.gvsig.remoteClient.gml.schemas.IXMLType;
10
import org.gvsig.remoteClient.gml.schemas.XMLComplexType;
11
import org.gvsig.remoteClient.gml.schemas.XMLElement;
12

    
13
import com.iver.andami.PluginServices;
14
import com.iver.cit.gvsig.fmap.drivers.wfs.WFSUtils;
15
import com.sun.rsasign.v;
16

    
17
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
18
 *
19
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
20
 *
21
 * This program is free software; you can redistribute it and/or
22
 * modify it under the terms of the GNU General Public License
23
 * as published by the Free Software Foundation; either version 2
24
 * of the License, or (at your option) any later version.
25
 *
26
 * This program is distributed in the hope that it will be useful,
27
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
 * GNU General Public License for more details.
30
 *
31
 * You should have received a copy of the GNU General Public License
32
 * along with this program; if not, write to the Free Software
33
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
34
 *
35
 * For more information, contact:
36
 *
37
 *  Generalitat Valenciana
38
 *   Conselleria d'Infraestructures i Transport
39
 *   Av. Blasco Ib??ez, 50
40
 *   46010 VALENCIA
41
 *   SPAIN
42
 *
43
 *      +34 963862235
44
 *   gvsig@gva.es
45
 *      www.gvsig.gva.es
46
 *
47
 *    or
48
 *
49
 *   IVER T.I. S.A
50
 *   Salamanca 50
51
 *   46005 Valencia
52
 *   Spain
53
 *
54
 *   +34 963163400
55
 *   dac@iver.es
56
 */
57
/* CVS MESSAGES:
58
 *
59
 * $Id: AttributesTreeTableModel.java 8273 2006-10-24 07:27:56Z jorpiell $
60
 * $Log$
61
 * Revision 1.1  2006-10-24 07:27:56  jorpiell
62
 * Algunos cambios en el modelo que usa la tabla
63
 *
64
 * Revision 1.2  2006/10/23 08:17:18  jorpiell
65
 * Algunos cambios realizados para tener un ?rbol com m?s de una ra?z
66
 *
67
 * Revision 1.1  2006/10/23 07:37:04  jorpiell
68
 * Ya funciona el filterEncoding
69
 *
70
 *
71
 */
72
/**
73
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
74
 */
75
public class AttributesTreeTableModel extends AbstractTreeTableModel {
76
        private String[]  cNames = null;
77
        private Class[]  cTypes = null;
78
        private Object[] attributes = null;
79
                
80
        public AttributesTreeTableModel(Object[] attributes,boolean isTypeShowed) { 
81
                super(attributes);
82
                setTypeShowed(isTypeShowed);
83
                this.attributes = attributes;
84
        }                
85
        
86
        public AttributesTreeTableModel(boolean isTypeShowed) { 
87
                super(null); 
88
                setTypeShowed(isTypeShowed);
89
                this.attributes = null;
90
        }
91
        
92
        public void setNodes(Object[] attributes){
93
                this.attributes = attributes;                
94
        }
95
        
96
        private void setTypeShowed(boolean isTypeShowed){
97
                if (isTypeShowed){
98
                        cNames = new String[2];
99
                        cNames[0] = PluginServices.getText(this,"attributeName");
100
                        cNames[1] = PluginServices.getText(this,"attributeType");
101
                        cTypes = new Class[2];
102
                        cTypes[0] = TreeTableModel.class;
103
                        cTypes[1] = String.class;
104
                }else{
105
                        cNames = new String[1];
106
                        cNames[0] = PluginServices.getText(this,"attributeName");
107
                        cTypes = new Class[1];
108
                        cTypes[0] = TreeTableModel.class;
109
                }
110
        }
111

    
112
        protected Object[] getChildren(Object node) {
113
                XMLElement element = (XMLElement)node;                        
114
                if (element.getEntityType().getType() == IXMLType.COMPLEX){
115
                        Vector vector = ((XMLComplexType)element.getEntityType()).getAttributes();
116
                        Object[] objs = new Object[vector.size()];
117
                        for (int i=0 ; i<vector.size() ; i++){
118
                                objs[i] = vector.get(i);
119
                        }
120
                }
121
                return null;        
122
        }
123
        
124
        //
125
        // The TreeModel interface
126
        //
127
        
128
        public int getChildCount(Object node) { 
129
                if (node instanceof AbstractTreeTableModel.Root){
130
                        return ((AbstractTreeTableModel.Root)node).getChildCount();
131
                }
132
                XMLElement element = (XMLElement)node;                        
133
                if (element.getEntityType().getType() == IXMLType.COMPLEX){
134
                        return ((XMLComplexType)element.getEntityType()).getAttributes().size();
135
                }else{
136
                        return 0;
137
                }
138
        }
139
        
140
        public Object getChild(Object node, int i) { 
141
                if (node instanceof AbstractTreeTableModel.Root){
142
                        return ((AbstractTreeTableModel.Root)node).getChildren()[i];
143
                }
144
                XMLElement element = (XMLElement)node;                        
145
                if (element.getEntityType().getType() == IXMLType.COMPLEX){
146
                        Vector vector = ((XMLComplexType)element.getEntityType()).getAttributes();
147
                        return vector.get(i);
148
                }
149
                return null;
150
        }
151
        
152
        // The superclass's implementation would work, but this is more efficient. 
153
        public boolean isLeaf(Object node) { 
154
                if (node instanceof AbstractTreeTableModel.Root){
155
                        return false;
156
                }
157
                XMLElement element = (XMLElement)node;                        
158
                if (element.getEntityType().getType() == IXMLType.COMPLEX){
159
                        return false;
160
                }
161
                return true;
162
        }
163

    
164
        /*
165
         *  (non-Javadoc)
166
         * @see org.gvsig.gui.beans.swing.treeTable.TreeTableModel#getColumnCount()
167
         */
168
        public int getColumnCount() {
169
                return cNames.length;
170
        }
171
        
172
        /*
173
         *  (non-Javadoc)
174
         * @see org.gvsig.gui.beans.swing.treeTable.TreeTableModel#getColumnName(int)
175
         */
176
        public String getColumnName(int column) {
177
                return cNames[column];
178
        }
179
        
180
        /*
181
         *  (non-Javadoc)
182
         * @see org.gvsig.gui.beans.swing.treeTable.TreeTableModel#getColumnClass(int)
183
         */
184
        public Class getColumnClass(int column) {
185
                return cTypes[column];
186
        }
187
        
188
        /*
189
         *  (non-Javadoc)
190
         * @see org.gvsig.gui.beans.swing.treeTable.TreeTableModel#getValueAt(java.lang.Object, int)
191
         */
192
        public Object getValueAt(Object node, int column) {
193
                if (node instanceof AbstractTreeTableModel.Root){
194
                        return "";
195
                }
196
                XMLElement element = (XMLElement)node;        
197
                try {
198
                        switch(column) {
199
                        case 0:
200
                                return element.getName();
201
                        case 1:
202
                                return PluginServices.getText(this,WFSUtils.getAttributeType(element.getEntityType()));
203
                        }
204
                }
205
                catch  (SecurityException se) { }
206
                
207
                return null; 
208
        }
209
}
210

    
211