root / branches / v10 / extensions / extSDE / src / com / iver / cit / gvsig / sde / gui / sdewizard / WizardSDEOld.java @ 11197
History | View | Annotate | Download (14.9 KB)
1 | 10942 | caballero | /*
|
---|---|---|---|
2 | * Created on 23-abr-2004
|
||
3 | *
|
||
4 | * To change the template for this generated file go to
|
||
5 | * Window>Preferences>Java>Code Generation>Code and Comments
|
||
6 | */
|
||
7 | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
||
8 | *
|
||
9 | * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
||
10 | *
|
||
11 | * This program is free software; you can redistribute it and/or
|
||
12 | * modify it under the terms of the GNU General Public License
|
||
13 | * as published by the Free Software Foundation; either version 2
|
||
14 | * of the License, or (at your option) any later version.
|
||
15 | *
|
||
16 | * This program is distributed in the hope that it will be useful,
|
||
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
19 | * GNU General Public License for more details.
|
||
20 | *
|
||
21 | * You should have received a copy of the GNU General Public License
|
||
22 | * along with this program; if not, write to the Free Software
|
||
23 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
||
24 | *
|
||
25 | * For more information, contact:
|
||
26 | *
|
||
27 | * Generalitat Valenciana
|
||
28 | * Conselleria d'Infraestructures i Transport
|
||
29 | * Av. Blasco Ib??ez, 50
|
||
30 | * 46010 VALENCIA
|
||
31 | * SPAIN
|
||
32 | *
|
||
33 | * +34 963862235
|
||
34 | * gvsig@gva.es
|
||
35 | * www.gvsig.gva.es
|
||
36 | *
|
||
37 | * or
|
||
38 | *
|
||
39 | * IVER T.I. S.A
|
||
40 | * Salamanca 50
|
||
41 | * 46005 Valencia
|
||
42 | * Spain
|
||
43 | *
|
||
44 | * +34 963163400
|
||
45 | * dac@iver.es
|
||
46 | */
|
||
47 | package com.iver.cit.gvsig.sde.gui.sdewizard; |
||
48 | |||
49 | import java.awt.BorderLayout; |
||
50 | |||
51 | import javax.swing.JLabel; |
||
52 | import javax.swing.JPanel; |
||
53 | import javax.swing.JPasswordField; |
||
54 | import javax.swing.JTextField; |
||
55 | |||
56 | import org.apache.log4j.Logger; |
||
57 | import org.cresques.cts.IProjection; |
||
58 | |||
59 | import com.iver.andami.PluginServices; |
||
60 | import com.iver.cit.gvsig.fmap.core.ICanReproject; |
||
61 | import com.iver.cit.gvsig.fmap.crs.CRSFactory; |
||
62 | 11197 | caballero | import com.iver.cit.gvsig.fmap.drivers.sde.ArcSDELayerDefinition; |
63 | 10942 | caballero | import com.iver.cit.gvsig.fmap.drivers.sde.ArcSdeDriver; |
64 | import com.iver.cit.gvsig.fmap.layers.FLayer; |
||
65 | import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
||
66 | import com.iver.cit.gvsig.gui.WizardPanel; |
||
67 | import com.iver.cit.gvsig.gui.wizards.LayerListModel; |
||
68 | import com.iver.cit.gvsig.gui.wizards.WizardDataSource; |
||
69 | import com.iver.cit.gvsig.gui.wizards.WizardListener; |
||
70 | import com.iver.cit.gvsig.gui.wizards.WizardListenerSupport; |
||
71 | |||
72 | /**
|
||
73 | * DOCUMENT ME!
|
||
74 | * @author Fernando Gonz?lez Cort?s
|
||
75 | */
|
||
76 | public class WizardSDEOld extends WizardPanel { |
||
77 | private static Logger logger = Logger.getLogger(WizardSDE.class.getName()); |
||
78 | private int page = 0; |
||
79 | private boolean conectado = false; |
||
80 | private javax.swing.JPanel jContentPane = null; |
||
81 | /**
|
||
82 | * @uml.property name="panelPage1"
|
||
83 | */
|
||
84 | private javax.swing.JPanel panelPage1 = null; |
||
85 | private LayerListModel selectedLayersModel = new LayerListModel(); |
||
86 | /**
|
||
87 | * @uml.property name="jPanel1"
|
||
88 | */
|
||
89 | private javax.swing.JPanel jPanel1 = null; |
||
90 | private WizardListenerSupport listenerSupport = new WizardListenerSupport(); |
||
91 | private WizardDataSource dataSource;
|
||
92 | /**
|
||
93 | * @uml.property name="jPanel"
|
||
94 | */
|
||
95 | private JPanel jPanel = null; |
||
96 | private JLabel jLabel = null; |
||
97 | /**
|
||
98 | * @uml.property name="jTxtUser"
|
||
99 | */
|
||
100 | private JTextField jTxtUser = null; |
||
101 | private JLabel jLabel1 = null; |
||
102 | /**
|
||
103 | * @uml.property name="jTxtPassword"
|
||
104 | */
|
||
105 | private JPasswordField jTxtPassword = null; |
||
106 | private JLabel jLabel2 = null; |
||
107 | /**
|
||
108 | * @uml.property name="jTxtNomTabla"
|
||
109 | */
|
||
110 | private JTextField jTxtNomTabla = null; |
||
111 | private JLabel jLabel4 = null; |
||
112 | /**
|
||
113 | * @uml.property name="jTxtSqlWhere"
|
||
114 | */
|
||
115 | private JTextField jTxtSqlWhere = null; |
||
116 | /**
|
||
117 | * @uml.property name="jTxtHost"
|
||
118 | */
|
||
119 | private JTextField jTxtHost = null; |
||
120 | private JLabel jLabel5 = null; |
||
121 | private JLabel jLabel6 = null; |
||
122 | /**
|
||
123 | * @uml.property name="jTxtPort"
|
||
124 | */
|
||
125 | private JTextField jTxtPort = null; |
||
126 | private JTextField jTxtSchema = null; |
||
127 | private JLabel jLabel3 = null; |
||
128 | /**
|
||
129 | * @uml.property name="jTxtEsquema"
|
||
130 | */
|
||
131 | private JTextField jTxtEsquema = null; |
||
132 | /**
|
||
133 | * This is the default constructor
|
||
134 | */
|
||
135 | public WizardSDEOld() {
|
||
136 | super();
|
||
137 | initialize(); |
||
138 | } |
||
139 | |||
140 | /**
|
||
141 | * This method initializes this
|
||
142 | */
|
||
143 | private void initialize() { |
||
144 | setTabName("ArcSDE");
|
||
145 | this.setSize(510, 311); |
||
146 | this.setLayout(null); |
||
147 | this.setPreferredSize(new java.awt.Dimension(750, 320)); |
||
148 | this.setVisible(true); |
||
149 | this.add(getPanelPage1(), null); |
||
150 | |||
151 | listenerSupport.callStateChanged(true);
|
||
152 | // activarVisualizarBotones();
|
||
153 | } |
||
154 | |||
155 | |||
156 | |||
157 | |||
158 | |||
159 | |||
160 | /**
|
||
161 | * This method initializes panelPage1
|
||
162 | * @return javax.swing.JPanel
|
||
163 | * @uml.property name="panelPage1"
|
||
164 | */
|
||
165 | private javax.swing.JPanel getPanelPage1() {
|
||
166 | if (panelPage1 == null) { |
||
167 | panelPage1 = new javax.swing.JPanel();
|
||
168 | panelPage1.setLayout(new BorderLayout()); |
||
169 | panelPage1.setPreferredSize(new java.awt.Dimension(480, 220)); |
||
170 | panelPage1.setVisible(true);
|
||
171 | panelPage1.setBounds(15, 5, 480, 262); |
||
172 | panelPage1.add(getJPanel1(), java.awt.BorderLayout.NORTH); |
||
173 | panelPage1.add(getJPanel(), java.awt.BorderLayout.CENTER); |
||
174 | } |
||
175 | |||
176 | return panelPage1;
|
||
177 | } |
||
178 | |||
179 | /**
|
||
180 | * This method initializes jPanel1
|
||
181 | * @return javax.swing.JPanel
|
||
182 | * @uml.property name="jPanel1"
|
||
183 | */
|
||
184 | private javax.swing.JPanel getJPanel1() {
|
||
185 | if (jPanel1 == null) { |
||
186 | jLabel6 = new JLabel(); |
||
187 | jLabel6.setText("Puerto:");
|
||
188 | jLabel6.setPreferredSize(new java.awt.Dimension(94,15)); |
||
189 | jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
||
190 | jLabel5 = new JLabel(); |
||
191 | jLabel5.setText("Host:");
|
||
192 | jLabel5.setPreferredSize(new java.awt.Dimension(95,15)); |
||
193 | jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
||
194 | jPanel1 = new javax.swing.JPanel();
|
||
195 | jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder( |
||
196 | null, PluginServices.getText(this, "Servidor ArcSDE"), |
||
197 | javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
||
198 | javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
||
199 | |||
200 | jPanel1.add(jLabel5, null);
|
||
201 | jPanel1.add(getJTxtHost(), null);
|
||
202 | |||
203 | jPanel1.add(jLabel6, null);
|
||
204 | jPanel1.add(getJTxtPort(), null);
|
||
205 | } |
||
206 | |||
207 | return jPanel1;
|
||
208 | } |
||
209 | |||
210 | /**
|
||
211 | * DOCUMENT ME!
|
||
212 | *
|
||
213 | * @param listener
|
||
214 | */
|
||
215 | public void addWizardListener(WizardListener listener) { |
||
216 | listenerSupport.addWizardListener(listener); |
||
217 | } |
||
218 | |||
219 | /**
|
||
220 | * DOCUMENT ME!
|
||
221 | *
|
||
222 | * @param listener
|
||
223 | */
|
||
224 | public void removeWizardListener(WizardListener listener) { |
||
225 | listenerSupport.removeWizardListener(listener); |
||
226 | } |
||
227 | |||
228 | /**
|
||
229 | * DOCUMENT ME!
|
||
230 | * @return
|
||
231 | * @uml.property name="dataSource"
|
||
232 | */
|
||
233 | public WizardDataSource getDataSource() {
|
||
234 | return dataSource;
|
||
235 | } |
||
236 | |||
237 | /**
|
||
238 | * DOCUMENT ME!
|
||
239 | * @param source
|
||
240 | * @uml.property name="dataSource"
|
||
241 | */
|
||
242 | public void setDataSource(WizardDataSource source) { |
||
243 | dataSource = source; |
||
244 | } |
||
245 | |||
246 | |||
247 | |||
248 | |||
249 | |||
250 | public String getHost() { |
||
251 | return getJTxtHost().getText();
|
||
252 | } |
||
253 | |||
254 | public String getSchema() { |
||
255 | return getJTxtEsquema().getText();
|
||
256 | } |
||
257 | /**
|
||
258 | * DOCUMENT ME!
|
||
259 | *
|
||
260 | * @return Nombre de la capa que aparece en el TOC.
|
||
261 | */
|
||
262 | public String getLayerName() { |
||
263 | return jTxtNomTabla.getText();
|
||
264 | } |
||
265 | public String getUser() { |
||
266 | return jTxtUser.getText();
|
||
267 | } |
||
268 | public String getPassword() { |
||
269 | return jTxtPassword.getText();
|
||
270 | } |
||
271 | public String getPort() |
||
272 | { |
||
273 | return jTxtPort.getText();
|
||
274 | } |
||
275 | public String getSqlWhere() |
||
276 | { |
||
277 | return jTxtSqlWhere.getText();
|
||
278 | } |
||
279 | |||
280 | /**
|
||
281 | * This method initializes jPanel
|
||
282 | * @return JPanel
|
||
283 | * @uml.property name="jPanel"
|
||
284 | */
|
||
285 | private JPanel getJPanel() { |
||
286 | if (jPanel == null) { |
||
287 | jPanel = new JPanel(); |
||
288 | jLabel = new JLabel(); |
||
289 | jLabel1 = new JLabel(); |
||
290 | jLabel2 = new JLabel(); |
||
291 | jLabel4 = new JLabel(); |
||
292 | jPanel.setLayout(null);
|
||
293 | jLabel.setText("Usuario:");
|
||
294 | jLabel.setName("jLabel");
|
||
295 | jLabel.setSize(80, 19); |
||
296 | jLabel.setLocation(151, 12); |
||
297 | jLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
||
298 | jLabel1.setBounds(149, 41, 82, 19); |
||
299 | jLabel1.setText("Contrase?a:");
|
||
300 | jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
||
301 | jLabel2.setBounds(122, 98, 110, 20); |
||
302 | jLabel2.setText("Nombre de la tabla:");
|
||
303 | jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
||
304 | jLabel4.setBounds(125, 130, 106, 22); |
||
305 | jLabel4.setText("Cl?usula Where:");
|
||
306 | jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
||
307 | jPanel.add(jLabel, null);
|
||
308 | jPanel.add(getJTxtUser(), null);
|
||
309 | jPanel.add(jLabel1, null);
|
||
310 | jPanel.add(getJTxtPassword(), null);
|
||
311 | jPanel.add(getJTxtEsquema(), null);
|
||
312 | jPanel.add(jLabel2, null);
|
||
313 | jPanel.add(getJTxtNomTabla(), null);
|
||
314 | jPanel.add(jLabel4, null);
|
||
315 | jPanel.add(getJTxtSqlWhere(), null);
|
||
316 | } |
||
317 | return jPanel;
|
||
318 | } |
||
319 | /**
|
||
320 | * This method initializes jTextField
|
||
321 | * @return javax.swing.JTextField
|
||
322 | * @uml.property name="jTxtUser"
|
||
323 | */
|
||
324 | private JTextField getJTxtUser() { |
||
325 | if (jTxtUser == null) { |
||
326 | jTxtUser = new JTextField(); |
||
327 | jTxtUser.setName("jTextField");
|
||
328 | jTxtUser.setColumns(0);
|
||
329 | jTxtUser.setBounds(241, 12, 169, 19); |
||
330 | jTxtUser.setText("sde");
|
||
331 | jTxtUser.addFocusListener(new java.awt.event.FocusListener() {
|
||
332 | public void focusLost(java.awt.event.FocusEvent e) { |
||
333 | listenerSupport.callStateChanged(true);
|
||
334 | System.out.println("focusLost()"); // TODO Auto-generated Event stub focusLost() |
||
335 | } |
||
336 | public void focusGained(java.awt.event.FocusEvent e) {} |
||
337 | }); |
||
338 | } |
||
339 | return jTxtUser;
|
||
340 | } |
||
341 | /**
|
||
342 | * This method initializes jPasswordField
|
||
343 | * @return javax.swing.JPasswordField
|
||
344 | * @uml.property name="jTxtPassword"
|
||
345 | */
|
||
346 | private JPasswordField getJTxtPassword() { |
||
347 | if (jTxtPassword == null) { |
||
348 | jTxtPassword = new JPasswordField(); |
||
349 | jTxtPassword.setBounds(241, 39, 169, 20); |
||
350 | jTxtPassword.setText("iver");
|
||
351 | jTxtPassword.addFocusListener(new java.awt.event.FocusListener() {
|
||
352 | public void focusLost(java.awt.event.FocusEvent e) { |
||
353 | listenerSupport.callStateChanged(true);
|
||
354 | System.out.println("focusLost()"); // TODO Auto-generated Event stub focusLost() |
||
355 | } |
||
356 | public void focusGained(java.awt.event.FocusEvent e) {} |
||
357 | }); |
||
358 | } |
||
359 | return jTxtPassword;
|
||
360 | } |
||
361 | /**
|
||
362 | * This method initializes jTextField
|
||
363 | * @return javax.swing.JTextField
|
||
364 | * @uml.property name="jTxtNomTabla"
|
||
365 | */
|
||
366 | private JTextField getJTxtNomTabla() { |
||
367 | if (jTxtNomTabla == null) { |
||
368 | jTxtNomTabla = new JTextField(); |
||
369 | jTxtNomTabla.setBounds(241, 99, 169, 20); |
||
370 | jTxtNomTabla.setText("TEXTOS");
|
||
371 | } |
||
372 | return jTxtNomTabla;
|
||
373 | } |
||
374 | /**
|
||
375 | * This method initializes jTextField
|
||
376 | * @return javax.swing.JTextField
|
||
377 | * @uml.property name="jTxtSqlWhere"
|
||
378 | */
|
||
379 | private JTextField getJTxtSqlWhere() { |
||
380 | if (jTxtSqlWhere == null) { |
||
381 | jTxtSqlWhere = new JTextField(); |
||
382 | jTxtSqlWhere.setBounds(241, 129, 169, 24); |
||
383 | } |
||
384 | return jTxtSqlWhere;
|
||
385 | } |
||
386 | |||
387 | /**
|
||
388 | * This method initializes jTextField
|
||
389 | * @return javax.swing.JTextField
|
||
390 | * @uml.property name="jTxtHost"
|
||
391 | */
|
||
392 | private JTextField getJTxtHost() { |
||
393 | if (jTxtHost == null) { |
||
394 | jTxtHost = new JTextField(); |
||
395 | jTxtHost.setText("192.168.0.114");
|
||
396 | jTxtHost.setPreferredSize(new java.awt.Dimension(143,20)); |
||
397 | } |
||
398 | return jTxtHost;
|
||
399 | } |
||
400 | |||
401 | /**
|
||
402 | * This method initializes jTextField
|
||
403 | * @return javax.swing.JTextField
|
||
404 | * @uml.property name="jTxtPort"
|
||
405 | */
|
||
406 | private JTextField getJTxtPort() { |
||
407 | if (jTxtPort == null) { |
||
408 | jTxtPort = new JTextField(); |
||
409 | jTxtPort.setText("5151");
|
||
410 | } |
||
411 | return jTxtPort;
|
||
412 | } |
||
413 | |||
414 | /**
|
||
415 | * This method initializes jTextField
|
||
416 | * @return javax.swing.JTextField
|
||
417 | * @uml.property name="jTxtEsquema"
|
||
418 | */
|
||
419 | private JTextField getJTxtEsquema() { |
||
420 | if (jTxtEsquema == null) { |
||
421 | jTxtEsquema = new JTextField(); |
||
422 | jTxtEsquema.setBounds(241, 69, 168, 20); |
||
423 | jTxtEsquema.setText("ProvinciasPruebas");
|
||
424 | } |
||
425 | return jTxtEsquema;
|
||
426 | } |
||
427 | |||
428 | public void initWizard() { |
||
429 | } |
||
430 | |||
431 | /* (non-Javadoc)
|
||
432 | * @see com.iver.cit.gvsig.gui.WizardPanel#execute()
|
||
433 | */
|
||
434 | public void execute() { |
||
435 | } |
||
436 | |||
437 | /* (non-Javadoc)
|
||
438 | * @see com.iver.cit.gvsig.gui.WizardPanel#getLayer()
|
||
439 | */
|
||
440 | // public FLayer getLayer() {
|
||
441 | // WizardSDE arcsde_wizard = this;
|
||
442 | // String dbHost = arcsde_wizard.getHost();
|
||
443 | // String port = arcsde_wizard.getPort();
|
||
444 | // String user = arcsde_wizard.getUser();
|
||
445 | // String pwd = arcsde_wizard.getPassword();
|
||
446 | // // String layerName = arcsde_wizard.getLayerName();
|
||
447 | // // String fields = StringUtilities.getComaSeparated(wiz.getFields());
|
||
448 | // String tableName = arcsde_wizard.getLayerName();
|
||
449 | // String schema = arcsde_wizard.getSchema();
|
||
450 | // String whereClause = "";
|
||
451 | // String [] fields = null;
|
||
452 | //
|
||
453 | // // VectorialDatabaseDriver driver;
|
||
454 | // // try {
|
||
455 | // // driver = (VectorialDatabaseDriver) LayerFactory.getDM().getDriver("ArcSDE driver");
|
||
456 | // ArcSdeDriver driver = new ArcSdeDriver();
|
||
457 | // // ArcSdeDriver drv = (ArcSdeDriver) driver;
|
||
458 | // driver.setData(dbHost, Integer.parseInt(port), schema, user, pwd, tableName, fields, whereClause);
|
||
459 | //
|
||
460 | // return LayerFactory.createDBLayer(driver, tableName, null);
|
||
461 | // /* } catch (DriverLoadException e) {
|
||
462 | // // TODO Auto-generated catch block
|
||
463 | // e.printStackTrace();
|
||
464 | // return null;
|
||
465 | // } */
|
||
466 | //
|
||
467 | // }
|
||
468 | public FLayer getLayer() {
|
||
469 | IProjection proj = null;
|
||
470 | WizardSDEOld arcsde_wizard = this;
|
||
471 | String dbHost = arcsde_wizard.getHost();
|
||
472 | String port = arcsde_wizard.getPort();
|
||
473 | String user = arcsde_wizard.getUser();
|
||
474 | String pwd = arcsde_wizard.getPassword();
|
||
475 | String layerName = arcsde_wizard.getLayerName();
|
||
476 | // String fields = StringUtilities.getComaSeparated(wiz.getFields());
|
||
477 | String tableName = arcsde_wizard.getLayerName();
|
||
478 | String schema = arcsde_wizard.getSchema();
|
||
479 | String whereClause = ""; |
||
480 | String [] fields = new String[]{"SHAPE","OBJECTID"}; |
||
481 | |||
482 | String strEPSG = getMapCtrl().getViewPort()
|
||
483 | .getProjection().getAbrev() |
||
484 | .substring(5);
|
||
485 | |||
486 | 11197 | caballero | ArcSDELayerDefinition lyrDef = new ArcSDELayerDefinition();
|
487 | 10942 | caballero | lyrDef.setHost(dbHost); |
488 | lyrDef.setPort(port); |
||
489 | lyrDef.setSchema(schema); |
||
490 | lyrDef.setUser(user); |
||
491 | lyrDef.setPassword(pwd); |
||
492 | lyrDef.setName(layerName); |
||
493 | lyrDef.setTableName(tableName); |
||
494 | lyrDef.setWhereClause(whereClause); |
||
495 | lyrDef.setFieldNames(new String[]{"SHAPE","OBJECTID","AREA","PERIMETER","CODMUNI","MUNI_","MUNI_ID","CODPROV","CODAUTO","CODCOMAR"}); |
||
496 | lyrDef.setFieldGeometry("SHAPE");
|
||
497 | lyrDef.setFieldID("OBJECTID");
|
||
498 | lyrDef.setSRID_EPSG(strEPSG); |
||
499 | ArcSdeDriver driver = new ArcSdeDriver();
|
||
500 | if (driver instanceof ICanReproject){ |
||
501 | ((ICanReproject)driver).setDestProjection(strEPSG); |
||
502 | } |
||
503 | driver.setData(null, lyrDef);
|
||
504 | // driver.setData(dbHost, Integer.parseInt(port), schema, user, pwd, tableName, fields, whereClause);
|
||
505 | if (driver instanceof ICanReproject) |
||
506 | { |
||
507 | proj = CRSFactory.getCRS("EPSG:" + ((ICanReproject)driver).getSourceProjection());
|
||
508 | } |
||
509 | 11197 | caballero | //return SDELayerFactory.getLayerSDE(driver, tableName, proj);
|
510 | return LayerFactory.createDBLayer(driver, tableName, proj);
|
||
511 | 10942 | caballero | /* } catch (DriverLoadException e) {
|
512 | // TODO Auto-generated catch block
|
||
513 | e.printStackTrace();
|
||
514 | return null;
|
||
515 | } */
|
||
516 | |||
517 | } |
||
518 | |||
519 | |||
520 | |||
521 | |||
522 | |||
523 | |||
524 | |||
525 | |||
526 | } |
||
527 |