svn-gvsig-desktop / tags / Root_v10 / extensions / extSDE / src / com / iver / cit / gvsig / sde / gui / sdewizard / WizardSDE.java @ 13670
History | View | Annotate | Download (12.2 KB)
1 |
/*
|
---|---|
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 |
|
58 |
import com.hardcode.driverManager.DriverLoadException; |
59 |
import com.iver.andami.PluginServices; |
60 |
import com.iver.cit.gvsig.fmap.drivers.VectorialDatabaseDriver; |
61 |
import com.iver.cit.gvsig.fmap.drivers.VectorialJDBCDriver; |
62 |
import com.iver.cit.gvsig.fmap.drivers.sde.ArcSdeDriver; |
63 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
64 |
import com.iver.cit.gvsig.fmap.layers.LayerFactory; |
65 |
import com.iver.cit.gvsig.gui.WizardPanel; |
66 |
import com.iver.cit.gvsig.gui.wizards.LayerListModel; |
67 |
import com.iver.cit.gvsig.gui.wizards.WizardDataSource; |
68 |
import com.iver.cit.gvsig.gui.wizards.WizardListener; |
69 |
import com.iver.cit.gvsig.gui.wizards.WizardListenerSupport; |
70 |
|
71 |
/**
|
72 |
* DOCUMENT ME!
|
73 |
*
|
74 |
* @author Fernando Gonz?lez Cort?s
|
75 |
*/
|
76 |
public class WizardSDE 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 |
private javax.swing.JPanel panelPage1 = null; |
82 |
private LayerListModel selectedLayersModel = new LayerListModel(); |
83 |
private javax.swing.JPanel jPanel1 = null; |
84 |
private WizardListenerSupport listenerSupport = new WizardListenerSupport(); |
85 |
private WizardDataSource dataSource;
|
86 |
private JPanel jPanel = null; |
87 |
private JLabel jLabel = null; |
88 |
private JTextField jTxtUser = null; |
89 |
private JLabel jLabel1 = null; |
90 |
private JPasswordField jTxtPassword = null; |
91 |
private JLabel jLabel2 = null; |
92 |
private JTextField jTxtNomTabla = null; |
93 |
private JLabel jLabel4 = null; |
94 |
private JTextField jTxtSqlWhere = null; |
95 |
private JTextField jTxtHost = null; |
96 |
private JLabel jLabel5 = null; |
97 |
private JLabel jLabel6 = null; |
98 |
private JTextField jTxtPort = null; |
99 |
private JTextField jTxtSchema = null; |
100 |
private JLabel jLabel3 = null; |
101 |
private JTextField jTxtEsquema = null; |
102 |
/**
|
103 |
* This is the default constructor
|
104 |
*/
|
105 |
public WizardSDE() {
|
106 |
super();
|
107 |
initialize(); |
108 |
} |
109 |
|
110 |
/**
|
111 |
* This method initializes this
|
112 |
*/
|
113 |
private void initialize() { |
114 |
setTabName("ArcSDE");
|
115 |
this.setSize(510, 311); |
116 |
this.setLayout(null); |
117 |
this.setPreferredSize(new java.awt.Dimension(750, 320)); |
118 |
this.setVisible(true); |
119 |
this.add(getPanelPage1(), null); |
120 |
|
121 |
listenerSupport.callStateChanged(true);
|
122 |
// activarVisualizarBotones();
|
123 |
} |
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
/**
|
131 |
* This method initializes panelPage1
|
132 |
*
|
133 |
* @return javax.swing.JPanel
|
134 |
*/
|
135 |
private javax.swing.JPanel getPanelPage1() {
|
136 |
if (panelPage1 == null) { |
137 |
panelPage1 = new javax.swing.JPanel();
|
138 |
panelPage1.setLayout(new BorderLayout()); |
139 |
panelPage1.setPreferredSize(new java.awt.Dimension(480, 220)); |
140 |
panelPage1.setVisible(true);
|
141 |
panelPage1.setBounds(15, 5, 480, 262); |
142 |
panelPage1.add(getJPanel1(), java.awt.BorderLayout.NORTH); |
143 |
panelPage1.add(getJPanel(), java.awt.BorderLayout.CENTER); |
144 |
} |
145 |
|
146 |
return panelPage1;
|
147 |
} |
148 |
|
149 |
/**
|
150 |
* This method initializes jPanel1
|
151 |
*
|
152 |
* @return javax.swing.JPanel
|
153 |
*/
|
154 |
private javax.swing.JPanel getJPanel1() {
|
155 |
if (jPanel1 == null) { |
156 |
jLabel6 = new JLabel(); |
157 |
jLabel6.setText("Puerto:");
|
158 |
jLabel6.setPreferredSize(new java.awt.Dimension(94,15)); |
159 |
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
160 |
jLabel5 = new JLabel(); |
161 |
jLabel5.setText("Host:");
|
162 |
jLabel5.setPreferredSize(new java.awt.Dimension(95,15)); |
163 |
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
164 |
jPanel1 = new javax.swing.JPanel();
|
165 |
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder( |
166 |
null, PluginServices.getText(this, "Servidor ArcSDE"), |
167 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
168 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
169 |
|
170 |
jPanel1.add(jLabel5, null);
|
171 |
jPanel1.add(getJTxtHost(), null);
|
172 |
|
173 |
jPanel1.add(jLabel6, null);
|
174 |
jPanel1.add(getJTxtPort(), null);
|
175 |
} |
176 |
|
177 |
return jPanel1;
|
178 |
} |
179 |
|
180 |
/**
|
181 |
* DOCUMENT ME!
|
182 |
*
|
183 |
* @param listener
|
184 |
*/
|
185 |
public void addWizardListener(WizardListener listener) { |
186 |
listenerSupport.addWizardListener(listener); |
187 |
} |
188 |
|
189 |
/**
|
190 |
* DOCUMENT ME!
|
191 |
*
|
192 |
* @param listener
|
193 |
*/
|
194 |
public void removeWizardListener(WizardListener listener) { |
195 |
listenerSupport.removeWizardListener(listener); |
196 |
} |
197 |
|
198 |
/**
|
199 |
* DOCUMENT ME!
|
200 |
*
|
201 |
* @return
|
202 |
*/
|
203 |
public WizardDataSource getDataSource() {
|
204 |
return dataSource;
|
205 |
} |
206 |
|
207 |
/**
|
208 |
* DOCUMENT ME!
|
209 |
*
|
210 |
* @param source
|
211 |
*/
|
212 |
public void setDataSource(WizardDataSource source) { |
213 |
dataSource = source; |
214 |
} |
215 |
|
216 |
|
217 |
|
218 |
|
219 |
|
220 |
public String getHost() { |
221 |
return getJTxtHost().getText();
|
222 |
} |
223 |
|
224 |
public String getSchema() { |
225 |
return getJTxtEsquema().getText();
|
226 |
} |
227 |
/**
|
228 |
* DOCUMENT ME!
|
229 |
*
|
230 |
* @return Nombre de la capa que aparece en el TOC.
|
231 |
*/
|
232 |
public String getLayerName() { |
233 |
return jTxtNomTabla.getText();
|
234 |
} |
235 |
public String getUser() { |
236 |
return jTxtUser.getText();
|
237 |
} |
238 |
public String getPassword() { |
239 |
return jTxtPassword.getText();
|
240 |
} |
241 |
public String getPort() |
242 |
{ |
243 |
return jTxtPort.getText();
|
244 |
} |
245 |
public String getSqlWhere() |
246 |
{ |
247 |
return jTxtSqlWhere.getText();
|
248 |
} |
249 |
|
250 |
/**
|
251 |
* This method initializes jPanel
|
252 |
*
|
253 |
* @return JPanel
|
254 |
*/
|
255 |
private JPanel getJPanel() { |
256 |
if (jPanel == null) { |
257 |
jPanel = new JPanel(); |
258 |
jLabel = new JLabel(); |
259 |
jLabel1 = new JLabel(); |
260 |
jLabel2 = new JLabel(); |
261 |
jLabel4 = new JLabel(); |
262 |
jPanel.setLayout(null);
|
263 |
jLabel.setText("Usuario:");
|
264 |
jLabel.setName("jLabel");
|
265 |
jLabel.setSize(80, 19); |
266 |
jLabel.setLocation(151, 12); |
267 |
jLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
268 |
jLabel1.setBounds(149, 41, 82, 19); |
269 |
jLabel1.setText("Contrase?a:");
|
270 |
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
271 |
jLabel2.setBounds(122, 98, 110, 20); |
272 |
jLabel2.setText("Nombre de la tabla:");
|
273 |
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
274 |
jLabel4.setBounds(125, 130, 106, 22); |
275 |
jLabel4.setText("Cl?usula Where:");
|
276 |
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
277 |
jPanel.add(jLabel, null);
|
278 |
jPanel.add(getJTxtUser(), null);
|
279 |
jPanel.add(jLabel1, null);
|
280 |
jPanel.add(getJTxtPassword(), null);
|
281 |
jPanel.add(getJTxtEsquema(), null);
|
282 |
jPanel.add(jLabel2, null);
|
283 |
jPanel.add(getJTxtNomTabla(), null);
|
284 |
jPanel.add(jLabel4, null);
|
285 |
jPanel.add(getJTxtSqlWhere(), null);
|
286 |
} |
287 |
return jPanel;
|
288 |
} |
289 |
/**
|
290 |
* This method initializes jTextField
|
291 |
*
|
292 |
* @return javax.swing.JTextField
|
293 |
*/
|
294 |
private JTextField getJTxtUser() { |
295 |
if (jTxtUser == null) { |
296 |
jTxtUser = new JTextField(); |
297 |
jTxtUser.setName("jTextField");
|
298 |
jTxtUser.setColumns(0);
|
299 |
jTxtUser.setBounds(241, 12, 169, 19); |
300 |
jTxtUser.setText("sde");
|
301 |
jTxtUser.addFocusListener(new java.awt.event.FocusListener() {
|
302 |
public void focusLost(java.awt.event.FocusEvent e) { |
303 |
listenerSupport.callStateChanged(true);
|
304 |
System.out.println("focusLost()"); // TODO Auto-generated Event stub focusLost() |
305 |
} |
306 |
public void focusGained(java.awt.event.FocusEvent e) {} |
307 |
}); |
308 |
} |
309 |
return jTxtUser;
|
310 |
} |
311 |
/**
|
312 |
* This method initializes jPasswordField
|
313 |
*
|
314 |
* @return javax.swing.JPasswordField
|
315 |
*/
|
316 |
private JPasswordField getJTxtPassword() { |
317 |
if (jTxtPassword == null) { |
318 |
jTxtPassword = new JPasswordField(); |
319 |
jTxtPassword.setBounds(241, 39, 169, 20); |
320 |
jTxtPassword.addFocusListener(new java.awt.event.FocusListener() {
|
321 |
public void focusLost(java.awt.event.FocusEvent e) { |
322 |
listenerSupport.callStateChanged(true);
|
323 |
System.out.println("focusLost()"); // TODO Auto-generated Event stub focusLost() |
324 |
} |
325 |
public void focusGained(java.awt.event.FocusEvent e) {} |
326 |
}); |
327 |
} |
328 |
return jTxtPassword;
|
329 |
} |
330 |
/**
|
331 |
* This method initializes jTextField
|
332 |
*
|
333 |
* @return javax.swing.JTextField
|
334 |
*/
|
335 |
private JTextField getJTxtNomTabla() { |
336 |
if (jTxtNomTabla == null) { |
337 |
jTxtNomTabla = new JTextField(); |
338 |
jTxtNomTabla.setBounds(241, 99, 169, 20); |
339 |
jTxtNomTabla.setText("provin");
|
340 |
} |
341 |
return jTxtNomTabla;
|
342 |
} |
343 |
/**
|
344 |
* This method initializes jTextField
|
345 |
*
|
346 |
* @return javax.swing.JTextField
|
347 |
*/
|
348 |
private JTextField getJTxtSqlWhere() { |
349 |
if (jTxtSqlWhere == null) { |
350 |
jTxtSqlWhere = new JTextField(); |
351 |
jTxtSqlWhere.setBounds(241, 129, 169, 24); |
352 |
} |
353 |
return jTxtSqlWhere;
|
354 |
} |
355 |
|
356 |
/**
|
357 |
* This method initializes jTextField
|
358 |
*
|
359 |
* @return javax.swing.JTextField
|
360 |
*/
|
361 |
private JTextField getJTxtHost() { |
362 |
if (jTxtHost == null) { |
363 |
jTxtHost = new JTextField(); |
364 |
jTxtHost.setText("Alvaro");
|
365 |
jTxtHost.setPreferredSize(new java.awt.Dimension(143,20)); |
366 |
} |
367 |
return jTxtHost;
|
368 |
} |
369 |
|
370 |
/**
|
371 |
* This method initializes jTextField
|
372 |
*
|
373 |
* @return javax.swing.JTextField
|
374 |
*/
|
375 |
private JTextField getJTxtPort() { |
376 |
if (jTxtPort == null) { |
377 |
jTxtPort = new JTextField(); |
378 |
jTxtPort.setText("5151");
|
379 |
} |
380 |
return jTxtPort;
|
381 |
} |
382 |
|
383 |
/**
|
384 |
* This method initializes jTextField
|
385 |
*
|
386 |
* @return javax.swing.JTextField
|
387 |
*/
|
388 |
private JTextField getJTxtEsquema() { |
389 |
if (jTxtEsquema == null) { |
390 |
jTxtEsquema = new JTextField(); |
391 |
jTxtEsquema.setBounds(241, 69, 168, 20); |
392 |
jTxtEsquema.setText("Sigespa");
|
393 |
} |
394 |
return jTxtEsquema;
|
395 |
} |
396 |
|
397 |
public void initWizard() { |
398 |
} |
399 |
|
400 |
/* (non-Javadoc)
|
401 |
* @see com.iver.cit.gvsig.gui.WizardPanel#execute()
|
402 |
*/
|
403 |
public void execute() { |
404 |
} |
405 |
|
406 |
/* (non-Javadoc)
|
407 |
* @see com.iver.cit.gvsig.gui.WizardPanel#getLayer()
|
408 |
*/
|
409 |
public FLayer getLayer() {
|
410 |
WizardSDE arcsde_wizard = this;
|
411 |
String dbHost = arcsde_wizard.getHost();
|
412 |
String port = arcsde_wizard.getPort();
|
413 |
String user = arcsde_wizard.getUser();
|
414 |
String pwd = arcsde_wizard.getPassword();
|
415 |
// String layerName = arcsde_wizard.getLayerName();
|
416 |
// String fields = StringUtilities.getComaSeparated(wiz.getFields());
|
417 |
String tableName = arcsde_wizard.getLayerName();
|
418 |
String schema = arcsde_wizard.getSchema();
|
419 |
String whereClause = ""; |
420 |
String [] fields = null; |
421 |
|
422 |
// VectorialDatabaseDriver driver;
|
423 |
// try {
|
424 |
// driver = (VectorialDatabaseDriver) LayerFactory.getDM().getDriver("ArcSDE driver");
|
425 |
ArcSdeDriver driver = new ArcSdeDriver();
|
426 |
// ArcSdeDriver drv = (ArcSdeDriver) driver;
|
427 |
driver.setData(dbHost, Integer.parseInt(port), schema, user, pwd, tableName, fields, whereClause);
|
428 |
|
429 |
return LayerFactory.createDBLayer(driver, tableName, null); |
430 |
/* } catch (DriverLoadException e) {
|
431 |
// TODO Auto-generated catch block
|
432 |
e.printStackTrace();
|
433 |
return null;
|
434 |
} */
|
435 |
|
436 |
} |
437 |
} |
438 |
|
439 |
// @jve:decl-index=0:visual-constraint="10,10"
|
440 |
// @jve:visual-info decl-index=0 visual-constraint="16,10"
|
441 |
// @jve:visual-info decl-index=0 visual-constraint="10,10"
|
442 |
// @jve:visual-info decl-index=0 visual-constraint="10,10"
|
443 |
// @jve:visual-info decl-index=0 visual-constraint="10,10"
|