Revision 623
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/DEMO/PruebasGT2.java | ||
---|---|---|
1 |
/* |
|
2 |
* Created on 22-dic-2004 |
|
3 |
*/ |
|
4 |
package com.iver.cit.gvsig.DEMO; |
|
5 |
|
|
6 |
import java.awt.event.ActionEvent; |
|
7 |
import java.awt.event.ActionListener; |
|
8 |
import java.io.IOException; |
|
9 |
import java.util.HashMap; |
|
10 |
import java.util.Map; |
|
11 |
|
|
12 |
import java.net.URL; |
|
13 |
import javax.swing.JFileChooser; |
|
14 |
import javax.swing.JOptionPane; |
|
15 |
|
|
16 |
import org.geotools.data.DataStore; |
|
17 |
import org.geotools.data.arcsde.ArcSDEDataStoreFactory; |
|
18 |
/* import org.geotools.data.postgis.PostgisDataStoreFactory; |
|
19 |
import org.geotools.data.shapefile.ShapefileDataStore; */ |
|
20 |
|
|
21 |
/** |
|
22 |
* Pruebas de capas GT2 (ArcSDE, etc), hechas por Fran, sacadas del |
|
23 |
* CommandListener |
|
24 |
* @author Luis W. Sevilla (sevilla_lui@gva.es) |
|
25 |
*/ |
|
26 |
public class PruebasGT2 implements ActionListener { |
|
27 |
// static PostgisDataStoreFactory postGisFactory = new PostgisDataStoreFactory(); |
|
28 |
static ArcSDEDataStoreFactory arcSdeFactory = new ArcSDEDataStoreFactory(); |
|
29 |
|
|
30 |
Map remote; |
|
31 |
|
|
32 |
|
|
33 |
/** |
|
34 |
* |
|
35 |
*/ |
|
36 |
protected void addLayerGT2_Shp() { |
|
37 |
/* JFileChooser fileChooser = new JFileChooser(); // lastFolder); |
|
38 |
fileChooser.addChoosableFileFilter(new SimpleFileFilter("shp", "Shapefile (*.shp)")); |
|
39 |
|
|
40 |
int result = fileChooser.showOpenDialog(theView); |
|
41 |
|
|
42 |
if (result == JFileChooser.APPROVE_OPTION) { |
|
43 |
File file = fileChooser.getSelectedFile(); |
|
44 |
// lastFolder = file.getParentFile(); |
|
45 |
|
|
46 |
try { |
|
47 |
// Load the file |
|
48 |
URL url = file.toURL(); |
|
49 |
|
|
50 |
DataStore store; |
|
51 |
|
|
52 |
// Para shapes |
|
53 |
store = new ShapefileDataStore(url); |
|
54 |
|
|
55 |
loadLayer(store, store.getTypeNames()[0]); |
|
56 |
} catch (Throwable t) { |
|
57 |
JOptionPane.showMessageDialog(null, "An error occurred while loading the file", |
|
58 |
"Demo GT2", JOptionPane.ERROR_MESSAGE); |
|
59 |
t.printStackTrace(); |
|
60 |
} |
|
61 |
} */ |
|
62 |
} |
|
63 |
protected void addLayerGT2_PostGIS() |
|
64 |
{ |
|
65 |
/* remote = new HashMap(); |
|
66 |
remote.put("dbtype","postgis"); |
|
67 |
remote.put("host","213.172.37.189"); //Jos? Miguel |
|
68 |
remote.put("port", new Integer(5432)); |
|
69 |
remote.put("database", "geomarketing"); |
|
70 |
remote.put("user", "Geomarketing"); |
|
71 |
remote.put("passwd", "geomarketing"); |
|
72 |
remote.put("charset", ""); |
|
73 |
remote.put("namespace", ""); |
|
74 |
|
|
75 |
DataStore store; |
|
76 |
try { |
|
77 |
store = postGisFactory.createDataStore(remote); |
|
78 |
loadLayer(store, "ferrocarril"); |
|
79 |
|
|
80 |
} catch (IOException e) { |
|
81 |
// TODO Auto-generated catch block |
|
82 |
e.printStackTrace(); |
|
83 |
} */ |
|
84 |
|
|
85 |
|
|
86 |
} |
|
87 |
protected void addLayerGT2_ArcSDE() |
|
88 |
{ |
|
89 |
remote = new HashMap(); |
|
90 |
remote.put("dbtype","arcsde"); |
|
91 |
remote.put("server","192.168.0.165"); //Jos? Miguel |
|
92 |
remote.put("port", new Integer(5151)); |
|
93 |
remote.put("instance", "sde"); |
|
94 |
remote.put("user", "sde"); |
|
95 |
remote.put("password", "aquilina"); |
|
96 |
|
|
97 |
|
|
98 |
DataStore store; |
|
99 |
try { |
|
100 |
store = arcSdeFactory.createDataStore(remote); |
|
101 |
loadLayer(store, "SDE.VIAS"); |
|
102 |
|
|
103 |
} catch (IOException e) { |
|
104 |
// TODO Auto-generated catch block |
|
105 |
e.printStackTrace(); |
|
106 |
} |
|
107 |
|
|
108 |
|
|
109 |
} |
|
110 |
|
|
111 |
public void actionPerformed(ActionEvent e) { |
|
112 |
if (e.getActionCommand() == "ADD_GT2_POSTGIS") { |
|
113 |
addLayerGT2_PostGIS(); |
|
114 |
} |
|
115 |
if (e.getActionCommand() == "ADD_GT2_SHP") { |
|
116 |
addLayerGT2_Shp(); |
|
117 |
} |
|
118 |
if (e.getActionCommand() == "ADD_GT2_ARCSDE") { |
|
119 |
addLayerGT2_ArcSDE(); |
|
120 |
} |
|
121 |
} |
|
122 |
} |
|
0 | 123 |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/DEMO/ComandosListener.java | ||
---|---|---|
18 | 18 |
import java.io.File; |
19 | 19 |
import java.io.FileNotFoundException; |
20 | 20 |
import java.io.IOException; |
21 |
import java.net.URL; |
|
22 |
import java.util.HashMap; |
|
23 |
import java.util.Map; |
|
24 | 21 |
|
25 | 22 |
import javax.swing.JDialog; |
26 |
import javax.swing.JFileChooser; |
|
27 |
import javax.swing.JOptionPane; |
|
28 | 23 |
|
29 | 24 |
import org.cresques.cts.IProjection; |
30 | 25 |
import org.cresques.cts.ProjectionPool; |
31 | 26 |
import org.geotools.data.DataSourceException; |
32 | 27 |
import org.geotools.data.DataStore; |
33 | 28 |
import org.geotools.data.FeatureSource; |
34 |
import org.geotools.data.arcsde.ArcSDEDataStoreFactory; |
|
35 |
/* import org.geotools.data.postgis.PostgisDataStoreFactory; |
|
36 |
import org.geotools.data.shapefile.ShapefileDataStore; */ |
|
37 | 29 |
import org.geotools.map.DefaultMapLayer; |
38 | 30 |
import org.geotools.map.MapLayer; |
39 | 31 |
import org.geotools.styling.Style; |
... | ... | |
74 | 66 |
private FMap m_Mapa; |
75 | 67 |
private SingleView theView; |
76 | 68 |
|
77 |
// static PostgisDataStoreFactory postGisFactory = new PostgisDataStoreFactory(); |
|
78 |
static ArcSDEDataStoreFactory arcSdeFactory = new ArcSDEDataStoreFactory(); |
|
79 |
Map remote; |
|
80 |
|
|
81 | 69 |
private static final boolean WKB_ENABLED = true; |
82 | 70 |
|
71 |
ActionListener pruebasGT2 = null; //new PruebasGT2(); |
|
83 | 72 |
|
84 | 73 |
public ComandosListener(NewMapControl mapa, SingleView Owner) { |
85 | 74 |
m_Mapa = mapa.getMapContext(); |
... | ... | |
132 | 121 |
} |
133 | 122 |
|
134 | 123 |
|
135 |
/** |
|
136 |
* |
|
137 |
*/ |
|
138 |
protected void addLayerGT2_Shp() { |
|
139 |
/* JFileChooser fileChooser = new JFileChooser(); // lastFolder); |
|
140 |
fileChooser.addChoosableFileFilter(new SimpleFileFilter("shp", "Shapefile (*.shp)")); |
|
141 |
|
|
142 |
int result = fileChooser.showOpenDialog(theView); |
|
143 |
|
|
144 |
if (result == JFileChooser.APPROVE_OPTION) { |
|
145 |
File file = fileChooser.getSelectedFile(); |
|
146 |
// lastFolder = file.getParentFile(); |
|
147 |
|
|
148 |
try { |
|
149 |
// Load the file |
|
150 |
URL url = file.toURL(); |
|
151 |
|
|
152 |
DataStore store; |
|
153 |
|
|
154 |
// Para shapes |
|
155 |
store = new ShapefileDataStore(url); |
|
156 |
|
|
157 |
loadLayer(store, store.getTypeNames()[0]); |
|
158 |
} catch (Throwable t) { |
|
159 |
JOptionPane.showMessageDialog(null, "An error occurred while loading the file", |
|
160 |
"Demo GT2", JOptionPane.ERROR_MESSAGE); |
|
161 |
t.printStackTrace(); |
|
162 |
} |
|
163 |
} */ |
|
164 |
} |
|
165 |
protected void addLayerGT2_PostGIS() |
|
166 |
{ |
|
167 |
/* remote = new HashMap(); |
|
168 |
remote.put("dbtype","postgis"); |
|
169 |
remote.put("host","213.172.37.189"); //Jos? Miguel |
|
170 |
remote.put("port", new Integer(5432)); |
|
171 |
remote.put("database", "geomarketing"); |
|
172 |
remote.put("user", "Geomarketing"); |
|
173 |
remote.put("passwd", "geomarketing"); |
|
174 |
remote.put("charset", ""); |
|
175 |
remote.put("namespace", ""); |
|
176 |
|
|
177 |
DataStore store; |
|
178 |
try { |
|
179 |
store = postGisFactory.createDataStore(remote); |
|
180 |
loadLayer(store, "ferrocarril"); |
|
181 |
|
|
182 |
} catch (IOException e) { |
|
183 |
// TODO Auto-generated catch block |
|
184 |
e.printStackTrace(); |
|
185 |
} */ |
|
186 |
|
|
187 |
|
|
188 |
} |
|
189 |
protected void addLayerGT2_ArcSDE() |
|
190 |
{ |
|
191 |
remote = new HashMap(); |
|
192 |
remote.put("dbtype","arcsde"); |
|
193 |
remote.put("server","192.168.0.165"); //Jos? Miguel |
|
194 |
remote.put("port", new Integer(5151)); |
|
195 |
remote.put("instance", "sde"); |
|
196 |
remote.put("user", "sde"); |
|
197 |
remote.put("password", "aquilina"); |
|
198 |
|
|
199 |
|
|
200 |
DataStore store; |
|
201 |
try { |
|
202 |
store = arcSdeFactory.createDataStore(remote); |
|
203 |
loadLayer(store, "SDE.VIAS"); |
|
204 |
|
|
205 |
} catch (IOException e) { |
|
206 |
// TODO Auto-generated catch block |
|
207 |
e.printStackTrace(); |
|
208 |
} |
|
209 |
|
|
210 |
|
|
211 |
} |
|
212 |
|
|
213 | 124 |
/* (non-Javadoc) |
214 | 125 |
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) |
215 | 126 |
*/ |
... | ... | |
231 | 142 |
if (e.getActionCommand() == "ZOOM_PREVIO") { |
232 | 143 |
vp.setExtentPrev(); |
233 | 144 |
} |
234 |
if (e.getActionCommand() == "ADD_GT2_POSTGIS") { |
|
235 |
addLayerGT2_PostGIS(); |
|
236 |
} |
|
237 |
if (e.getActionCommand() == "ADD_GT2_SHP") { |
|
238 |
addLayerGT2_Shp(); |
|
239 |
} |
|
240 |
if (e.getActionCommand() == "ADD_GT2_ARCSDE") { |
|
241 |
addLayerGT2_ArcSDE(); |
|
242 |
} |
|
145 |
if (e.getActionCommand().indexOf("GT2") != -1 && pruebasGT2 != null) |
|
146 |
pruebasGT2.actionPerformed(e); |
|
243 | 147 |
|
244 | 148 |
/* if (e.getActionCommand() == "OPEN_LOCATOR") { |
245 | 149 |
//Set up the dialog that the button brings up. |
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/FileOpenDialog.java | ||
---|---|---|
137 | 137 |
if (LayerFactory.getDM().isA(driverNames[i], driverClasses[j])) |
138 | 138 |
is = true; |
139 | 139 |
} |
140 |
if (is){
|
|
140 |
if (true) { // (is) TODO LWS (porque lo dijo fernando)
|
|
141 | 141 |
fileChooser.addChoosableFileFilter(new DriverFileFilter(driverNames[i])); } |
142 | 142 |
} |
143 | 143 |
} catch (DriverLoadException e1) { |
Also available in: Unified diff