Statistics
| Revision:

root / tags / v1_0_1_RELEASE / extensions / extWFS2 / src-test / com / iver / cit / gvsig / gui / panels / AttributesTableTest.java @ 9531

History | View | Annotate | Download (4.5 KB)

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

    
3
import java.awt.Component;
4
import java.io.File;
5
import java.util.Vector;
6

    
7
import javax.swing.JFrame;
8
import javax.swing.JScrollPane;
9
import javax.swing.JTree;
10

    
11
import org.gvsig.remoteClient.gml.factories.XMLElementsFactory;
12
import org.gvsig.remoteClient.gml.schemas.IXMLType;
13
import org.gvsig.remoteClient.gml.schemas.XMLComplexType;
14
import org.gvsig.remoteClient.gml.schemas.XMLElement;
15
import org.gvsig.remoteClient.gml.schemas.XMLSchemaParser;
16

    
17
import com.iver.cit.gvsig.gui.panels.attributesTree.AttributesTreeTable;
18
import com.iver.cit.gvsig.gui.panels.attributesTree.AttributesTreeTableModel;
19
import com.iver.cit.gvsig.gui.panels.attributesTree.CheckBoxTreeCellEditor;
20
import com.iver.cit.gvsig.gui.panels.attributesTree.CheckBoxTreeCellRenderer;
21
import com.iver.cit.gvsig.gui.panels.attributesTree.TreeTableModelWithCheckBoxes;
22

    
23
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
24
 *
25
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
26
 *
27
 * This program is free software; you can redistribute it and/or
28
 * modify it under the terms of the GNU General Public License
29
 * as published by the Free Software Foundation; either version 2
30
 * of the License, or (at your option) any later version.
31
 *
32
 * This program is distributed in the hope that it will be useful,
33
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
34
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
35
 * GNU General Public License for more details.
36
 *
37
 * You should have received a copy of the GNU General Public License
38
 * along with this program; if not, write to the Free Software
39
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
40
 *
41
 * For more information, contact:
42
 *
43
 *  Generalitat Valenciana
44
 *   Conselleria d'Infraestructures i Transport
45
 *   Av. Blasco Ib??ez, 50
46
 *   46010 VALENCIA
47
 *   SPAIN
48
 *
49
 *      +34 963862235
50
 *   gvsig@gva.es
51
 *      www.gvsig.gva.es
52
 *
53
 *    or
54
 *
55
 *   IVER T.I. S.A
56
 *   Salamanca 50
57
 *   46005 Valencia
58
 *   Spain
59
 *
60
 *   +34 963163400
61
 *   dac@iver.es
62
 */
63
/* CVS MESSAGES:
64
 *
65
 * $Id: AttributesTableTest.java 9531 2007-01-03 17:07:37Z  $
66
 * $Log$
67
 * Revision 1.7.2.2  2006-11-17 11:28:45  ppiqueras
68
 * Corregidos bugs y a?adida nueva funcionalidad.
69
 *
70
 * Revision 1.7  2006/11/01 17:29:08  jorpiell
71
 * 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
72
 *
73
 * Revision 1.6  2006/10/31 09:37:18  jorpiell
74
 * Se devuelve el tipo de la entidad completo, y no sus hijos
75
 *
76
 * Revision 1.5  2006/10/27 12:25:57  jorpiell
77
 * Modificado el test
78
 *
79
 * Revision 1.3  2006/10/24 07:58:14  jorpiell
80
 * Eliminado el parametro booleano que hac?a que apareciesen mas de una columna en el tree table
81
 *
82
 * Revision 1.2  2006/10/24 07:27:56  jorpiell
83
 * Algunos cambios en el modelo que usa la tabla
84
 *
85
 * Revision 1.1  2006/10/23 07:37:04  jorpiell
86
 * Ya funciona el filterEncoding
87
 *
88
 *
89
 */
90
/**
91
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
92
 */
93
public class AttributesTableTest{
94
        private String gmlFile = "src-test/WFS-DescribeFeatureTypeAves.xml";
95
        
96
        public static void main(String[] args) {
97
                AttributesTableTest att = new AttributesTableTest();
98
                att.initializeTable();        
99
                //att.initializeTree();
100
        }        
101
        
102
        private void initializeTree(){
103
                Vector att = describeFeatureType();
104
                        
105
                TreeTableModelWithCheckBoxes model = new TreeTableModelWithCheckBoxes(att.get(0));
106
                JTree tree = new JTree(model);                
107
                
108
                createFrame(tree);
109
        }
110
        private void initializeTable(){
111
                Vector att = describeFeatureType();
112
                                                                
113
                TreeTableModelWithCheckBoxes model = new TreeTableModelWithCheckBoxes();
114
                AttributesTreeTable treetable = new AttributesTreeTable(model);
115
                                                
116
                JScrollPane scrollPane = new JScrollPane(); 
117
                scrollPane.setViewportView(treetable);         
118
                                
119
                createFrame(scrollPane);
120
                
121
                //Sets the model
122
                treetable.setModel(new TreeTableModelWithCheckBoxes(att.get(0)));                
123
        }
124
        
125
        private void createFrame(Component component){
126
                JFrame f = new JFrame();
127
                f.addWindowListener(new java.awt.event.WindowAdapter() {
128
            public void windowClosing(java.awt.event.WindowEvent evt) {
129
                    System.exit(0);
130
            }
131
        });
132
                f.getContentPane().add(component);            
133
                f.setBounds(0,0,600,500);
134
                f.setVisible(true);
135
        }
136
        
137

    
138
        private Vector describeFeatureType(){
139
                XMLSchemaParser schemaParser = new XMLSchemaParser();
140
                schemaParser.parse(new File(gmlFile),"ms");
141
                XMLElement entity = XMLElementsFactory.getElement("Blyr");
142
                if (entity != null){
143
                                Vector vector = new Vector();
144
                                vector.add(entity);
145
                                return vector;
146
                }
147
                
148
                return null;
149
        }
150
        
151
}