svn-gvsig-desktop / trunk / extensions / extWFS2 / src-test / com / iver / cit / gvsig / gui / panels / AttributesTableTest.java @ 8273
History | View | Annotate | Download (4.38 KB)
1 |
package com.iver.cit.gvsig.gui.panels; |
---|---|
2 |
|
3 |
import java.awt.event.WindowEvent; |
4 |
import java.awt.event.WindowListener; |
5 |
import java.io.File; |
6 |
import java.util.Vector; |
7 |
|
8 |
import javax.swing.JFrame; |
9 |
import javax.swing.JScrollPane; |
10 |
import javax.swing.JTree; |
11 |
import javax.swing.table.JTableHeader; |
12 |
import javax.swing.tree.DefaultTreeCellRenderer; |
13 |
import javax.swing.tree.TreeCellRenderer; |
14 |
|
15 |
import org.gvsig.gui.beans.swing.treeTable.TreeTable; |
16 |
import org.gvsig.gui.beans.swing.treeTable.TreeTableCellRenderer; |
17 |
import org.gvsig.gui.beans.swing.treeTable.TreeTableModelAdapter; |
18 |
import org.gvsig.remoteClient.gml.factories.XMLElementsFactory; |
19 |
import org.gvsig.remoteClient.gml.schemas.IXMLType; |
20 |
import org.gvsig.remoteClient.gml.schemas.XMLComplexType; |
21 |
import org.gvsig.remoteClient.gml.schemas.XMLElement; |
22 |
import org.gvsig.remoteClient.gml.schemas.XMLSchemaParser; |
23 |
|
24 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
25 |
*
|
26 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
27 |
*
|
28 |
* This program is free software; you can redistribute it and/or
|
29 |
* modify it under the terms of the GNU General Public License
|
30 |
* as published by the Free Software Foundation; either version 2
|
31 |
* of the License, or (at your option) any later version.
|
32 |
*
|
33 |
* This program is distributed in the hope that it will be useful,
|
34 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
35 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
36 |
* GNU General Public License for more details.
|
37 |
*
|
38 |
* You should have received a copy of the GNU General Public License
|
39 |
* along with this program; if not, write to the Free Software
|
40 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
41 |
*
|
42 |
* For more information, contact:
|
43 |
*
|
44 |
* Generalitat Valenciana
|
45 |
* Conselleria d'Infraestructures i Transport
|
46 |
* Av. Blasco Ib??ez, 50
|
47 |
* 46010 VALENCIA
|
48 |
* SPAIN
|
49 |
*
|
50 |
* +34 963862235
|
51 |
* gvsig@gva.es
|
52 |
* www.gvsig.gva.es
|
53 |
*
|
54 |
* or
|
55 |
*
|
56 |
* IVER T.I. S.A
|
57 |
* Salamanca 50
|
58 |
* 46005 Valencia
|
59 |
* Spain
|
60 |
*
|
61 |
* +34 963163400
|
62 |
* dac@iver.es
|
63 |
*/
|
64 |
/* CVS MESSAGES:
|
65 |
*
|
66 |
* $Id: AttributesTableTest.java 8273 2006-10-24 07:27:56Z jorpiell $
|
67 |
* $Log$
|
68 |
* Revision 1.2 2006-10-24 07:27:56 jorpiell
|
69 |
* Algunos cambios en el modelo que usa la tabla
|
70 |
*
|
71 |
* Revision 1.1 2006/10/23 07:37:04 jorpiell
|
72 |
* Ya funciona el filterEncoding
|
73 |
*
|
74 |
*
|
75 |
*/
|
76 |
/**
|
77 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
78 |
*/
|
79 |
public class AttributesTableTest implements WindowListener{ |
80 |
private String gmlFile = "src-test/WFS-DescribeFeatureTypeAves.xml"; |
81 |
|
82 |
public static void main(String[] args) { |
83 |
AttributesTableTest att = new AttributesTableTest();
|
84 |
att.initialize(); |
85 |
} |
86 |
|
87 |
private void initialize(){ |
88 |
Vector att = describeFeatureType();
|
89 |
Object[] objs = new Object[att.size()]; |
90 |
for (int i=0 ; i<att.size() ; i++){ |
91 |
objs[i] = att.get(i); |
92 |
} |
93 |
TreeTable treetable = new TreeTable(new AttributesTreeTableModel(false)); |
94 |
treetable.deleteIcons(); |
95 |
treetable.setRootVisible(false);
|
96 |
|
97 |
AttributesTreeTableModel model = new AttributesTreeTableModel(objs,true); |
98 |
treetable.setModel(model); |
99 |
treetable.deleteIcons(); |
100 |
treetable.setRootVisible(false);
|
101 |
|
102 |
JScrollPane scrollPane = new JScrollPane(); |
103 |
scrollPane.setViewportView(treetable); |
104 |
|
105 |
createFrame(scrollPane); |
106 |
} |
107 |
|
108 |
private void createFrame(JScrollPane scrollPane){ |
109 |
JFrame f = new JFrame(); |
110 |
f.addWindowListener(this);
|
111 |
f.getContentPane().add(scrollPane); |
112 |
f.setBounds(0,0,600,500); |
113 |
f.setVisible(true);
|
114 |
} |
115 |
|
116 |
|
117 |
private Vector describeFeatureType(){ |
118 |
XMLSchemaParser schemaParser = new XMLSchemaParser();
|
119 |
schemaParser.parse(new File(gmlFile),"ms"); |
120 |
XMLElement entity = XMLElementsFactory.getElement("Blyr");
|
121 |
if (entity != null){ |
122 |
IXMLType type = entity.getEntityType(); |
123 |
if ((type != null) && (type instanceof XMLComplexType)){ |
124 |
return (((XMLComplexType)type).getAttributes());
|
125 |
} |
126 |
} |
127 |
return null; |
128 |
} |
129 |
|
130 |
public void windowActivated(WindowEvent e) { |
131 |
// TODO Auto-generated method stub
|
132 |
|
133 |
} |
134 |
|
135 |
public void windowClosed(WindowEvent e) { |
136 |
// TODO Auto-generated method stub
|
137 |
System.exit(0); |
138 |
} |
139 |
|
140 |
public void windowClosing(WindowEvent e) { |
141 |
// TODO Auto-generated method stub
|
142 |
|
143 |
} |
144 |
|
145 |
public void windowDeactivated(WindowEvent e) { |
146 |
// TODO Auto-generated method stub
|
147 |
|
148 |
} |
149 |
|
150 |
public void windowDeiconified(WindowEvent e) { |
151 |
// TODO Auto-generated method stub
|
152 |
|
153 |
} |
154 |
|
155 |
public void windowIconified(WindowEvent e) { |
156 |
// TODO Auto-generated method stub
|
157 |
|
158 |
} |
159 |
|
160 |
public void windowOpened(WindowEvent e) { |
161 |
// TODO Auto-generated method stub
|
162 |
|
163 |
} |
164 |
} |