Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / AttributesTableModel.java @ 8225

History | View | Annotate | Download (4.54 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.sun.rsasign.v;
15

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

    
85
        protected Object[] getChildren(Object node) {
86
                XMLElement element = (XMLElement)node;                        
87
                if (element.getEntityType().getType() == IXMLType.COMPLEX){
88
                        Vector vector = ((XMLComplexType)element.getEntityType()).getAttributes();
89
                        Object[] objs = new Object[vector.size()];
90
                        for (int i=0 ; i<vector.size() ; i++){
91
                                objs[i] = vector.get(i);
92
                        }
93
                }
94
                return null;        
95
        }
96
        
97
        //
98
        // The TreeModel interface
99
        //
100
        
101
        public int getChildCount(Object node) { 
102
                if (node instanceof AbstractTreeTableModel.Root){
103
                        return ((AbstractTreeTableModel.Root)node).getChildCount();
104
                }
105
                XMLElement element = (XMLElement)node;                        
106
                if (element.getEntityType().getType() == IXMLType.COMPLEX){
107
                        return ((XMLComplexType)element.getEntityType()).getAttributes().size();
108
                }else{
109
                        return 0;
110
                }
111
        }
112
        
113
        public Object getChild(Object node, int i) { 
114
                if (node instanceof AbstractTreeTableModel.Root){
115
                        return ((AbstractTreeTableModel.Root)node).getChildren()[i];
116
                }
117
                XMLElement element = (XMLElement)node;                        
118
                if (element.getEntityType().getType() == IXMLType.COMPLEX){
119
                        Vector vector = ((XMLComplexType)element.getEntityType()).getAttributes();
120
                        return vector.get(i);
121
                }
122
                return null;
123
        }
124
        
125
        // The superclass's implementation would work, but this is more efficient. 
126
        public boolean isLeaf(Object node) { 
127
                if (node instanceof AbstractTreeTableModel.Root){
128
                        return false;
129
                }
130
                XMLElement element = (XMLElement)node;                        
131
                if (element.getEntityType().getType() == IXMLType.COMPLEX){
132
                        return false;
133
                }
134
                return true;
135
        }
136
        
137
        //
138
        //  The TreeTableNode interface. 
139
        //
140
        
141
        public int getColumnCount() {
142
                return cNames.length;
143
        }
144
        
145
        public String getColumnName(int column) {
146
                return cNames[column];
147
        }
148
        
149
        public Class getColumnClass(int column) {
150
                return cTypes[column];
151
        }
152
        
153
        public Object getValueAt(Object node, int column) {
154
                if (node instanceof AbstractTreeTableModel.Root){
155
                        return "";
156
                }
157
                XMLElement element = (XMLElement)node;        
158
                try {
159
                        switch(column) {
160
                        case 0:
161
                                return element.getName();
162
                        case 1:
163
                                return element.getEntityType().getName();
164
                        }
165
                }
166
                catch  (SecurityException se) { }
167
                
168
                return null; 
169
        }
170
}
171

    
172