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