svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.geodb.app / org.gvsig.geodb.app.mainplugin / src / main / java / org / gvsig / geodb / vectorialdb / ConnectionPanel.java @ 41633
History | View | Annotate | Download (23.7 KB)
1 | 40557 | jjdelcerro | /**
|
---|---|---|---|
2 | * gvSIG. Desktop Geographic Information System.
|
||
3 | *
|
||
4 | * Copyright (C) 2007-2013 gvSIG Association.
|
||
5 | *
|
||
6 | * This program is free software; you can redistribute it and/or
|
||
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 3
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | *
|
||
11 | * This program is distributed in the hope that it will be useful,
|
||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
14 | * GNU General Public License for more details.
|
||
15 | *
|
||
16 | * You should have received a copy of the GNU General Public License
|
||
17 | * along with this program; if not, write to the Free Software
|
||
18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | * For any additional information, do not hesitate to contact us
|
||
22 | * at info AT gvsig.com, or visit our website www.gvsig.com.
|
||
23 | */
|
||
24 | 40435 | jjdelcerro | package org.gvsig.geodb.vectorialdb; |
25 | |||
26 | import java.awt.BorderLayout; |
||
27 | import java.awt.Dimension; |
||
28 | import java.awt.FlowLayout; |
||
29 | import java.awt.Rectangle; |
||
30 | import java.awt.event.ActionEvent; |
||
31 | import java.awt.event.ActionListener; |
||
32 | import java.util.HashMap; |
||
33 | import java.util.Iterator; |
||
34 | |||
35 | import javax.swing.DefaultComboBoxModel; |
||
36 | import javax.swing.JLabel; |
||
37 | import javax.swing.JPanel; |
||
38 | import javax.swing.JPasswordField; |
||
39 | import javax.swing.JTextField; |
||
40 | import javax.swing.SwingConstants; |
||
41 | |||
42 | import org.gvsig.andami.PluginServices; |
||
43 | import org.gvsig.fmap.dal.DALLocator; |
||
44 | import org.gvsig.fmap.dal.DataManager; |
||
45 | import org.gvsig.fmap.dal.exception.InitializeException; |
||
46 | import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
||
47 | import org.gvsig.fmap.dal.resource.db.DBParameters; |
||
48 | import org.gvsig.utils.NotExistInXMLEntity; |
||
49 | import org.gvsig.utils.XMLEntity; |
||
50 | import org.gvsig.utils.swing.JComboBox; |
||
51 | import org.gvsig.utils.swing.wizard.Step; |
||
52 | import org.gvsig.utils.swing.wizard.WizardControl; |
||
53 | |||
54 | |||
55 | |||
56 | /**
|
||
57 | * DOCUMENT ME!
|
||
58 | *
|
||
59 | * @author Fernando Gonz?lez Cort?s
|
||
60 | */
|
||
61 | public class ConnectionPanel extends JPanel implements Step { |
||
62 | private static String passw = null; |
||
63 | |||
64 | private JPanel jPanelLabels = null; |
||
65 | private JLabel jLabel = null; |
||
66 | private JTextField txtHost = null; |
||
67 | private JPanel jPanelTexts = null; |
||
68 | private JTextField txtPort = null; |
||
69 | private JLabel jLabel1 = null; |
||
70 | private JLabel jLabel2 = null; |
||
71 | private JTextField txtUser = null; |
||
72 | private JLabel jLabel3 = null; |
||
73 | private JPasswordField txtPassword = null; |
||
74 | private JLabel jLabel4 = null; |
||
75 | private JTextField txtBD = null; |
||
76 | private JLabel jLabel5 = null; |
||
77 | private JComboBox cmbDriver = null; |
||
78 | private JLabel jLabel6 = null; |
||
79 | private org.gvsig.utils.swing.JComboBox cmbName = null; |
||
80 | private HashMap cs = new HashMap(); |
||
81 | |||
82 | private JPanel jPanel = null; |
||
83 | |||
84 | private JLabel jLabelSchema = null; |
||
85 | |||
86 | private ConnectionPanel XYZ = null; |
||
87 | |||
88 | private JPanel jPanel1 = null; |
||
89 | |||
90 | private JPanel jPanelLabels1 = null; |
||
91 | |||
92 | private JLabel jLabel61 = null; |
||
93 | |||
94 | private JLabel jLabel7 = null; |
||
95 | |||
96 | private JLabel jLabel11 = null; |
||
97 | |||
98 | private JLabel jLabel21 = null; |
||
99 | |||
100 | private JLabel jLabel31 = null; |
||
101 | |||
102 | private JLabel jLabel51 = null; |
||
103 | |||
104 | private JPanel jPanelTexts1 = null; |
||
105 | |||
106 | private JComboBox cmbName1 = null; |
||
107 | |||
108 | private JTextField txtHost1 = null; |
||
109 | |||
110 | private JTextField txtPort1 = null; |
||
111 | |||
112 | private JTextField txtUser1 = null; |
||
113 | |||
114 | private JPasswordField txtPassword1 = null; |
||
115 | |||
116 | private JTextField txtBD1 = null; |
||
117 | |||
118 | private JComboBox cmbDriver1 = null; |
||
119 | |||
120 | private JTextField txtSchema = null; |
||
121 | |||
122 | |||
123 | |||
124 | /**
|
||
125 | * This is the default constructor
|
||
126 | */
|
||
127 | public ConnectionPanel() {
|
||
128 | super();
|
||
129 | initialize(); |
||
130 | } |
||
131 | |||
132 | /**
|
||
133 | * This method initializes this
|
||
134 | */
|
||
135 | private void initialize() { |
||
136 | this.setLayout(null); |
||
137 | this.setSize(335, 240); |
||
138 | this.add(getJPanel(), null); |
||
139 | |||
140 | if (passw != null) { |
||
141 | txtPassword.setText(passw); |
||
142 | } |
||
143 | |||
144 | } |
||
145 | |||
146 | /**
|
||
147 | * This method initializes jPanel
|
||
148 | *
|
||
149 | * @return javax.swing.JPanel
|
||
150 | */
|
||
151 | private JPanel getJPanelLabels() { |
||
152 | if (jPanelLabels == null) { |
||
153 | String string = PluginServices.getText(this, "_Schema") + ":"; |
||
154 | jLabelSchema = new JLabel(); |
||
155 | jLabelSchema.setName("jLabel4");
|
||
156 | jLabelSchema.setHorizontalAlignment(SwingConstants.RIGHT);
|
||
157 | jLabelSchema.setHorizontalTextPosition(SwingConstants.RIGHT);
|
||
158 | jLabelSchema.setText(string); |
||
159 | jLabelSchema.setPreferredSize(new Dimension(140, 19)); |
||
160 | FlowLayout flowLayout3 = new FlowLayout(); |
||
161 | flowLayout3.setVgap(15);
|
||
162 | jLabel5 = new JLabel(); |
||
163 | jLabel4 = new JLabel(); |
||
164 | jLabel3 = new JLabel(); |
||
165 | jLabel2 = new JLabel(); |
||
166 | jLabel1 = new JLabel(); |
||
167 | jLabel = new JLabel(); |
||
168 | jPanelLabels = new JPanel(); |
||
169 | jPanelLabels.setLayout(flowLayout3); |
||
170 | jPanelLabels.setName("jPanelLabels");
|
||
171 | jPanelLabels.setPreferredSize(new java.awt.Dimension(150,400)); |
||
172 | jLabel.setText(PluginServices.getText(this, "_Host") + ":"); |
||
173 | jLabel.setPreferredSize(new java.awt.Dimension(140,19)); |
||
174 | jLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
||
175 | jLabel.setName("jLabel");
|
||
176 | jLabel1.setText(PluginServices.getText(this, "_Port")+":"); |
||
177 | jLabel1.setPreferredSize(new java.awt.Dimension(140,19)); |
||
178 | jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); |
||
179 | jLabel1.setName("jLabel1");
|
||
180 | jLabel2.setText(PluginServices.getText(this, "_User")+":"); |
||
181 | jLabel2.setName("jLabel2");
|
||
182 | jLabel2.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); |
||
183 | jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
||
184 | jLabel2.setPreferredSize(new java.awt.Dimension(140,19)); |
||
185 | jLabel3.setText(PluginServices.getText(this, "_Password")+":"); |
||
186 | jLabel3.setName("jLabel3");
|
||
187 | jLabel3.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); |
||
188 | jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
||
189 | jLabel3.setPreferredSize(new java.awt.Dimension(140,19)); |
||
190 | jLabel4.setText(PluginServices.getText(this, "_Database")+":"); |
||
191 | jLabel4.setName("jLabel4");
|
||
192 | jLabel4.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); |
||
193 | jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
||
194 | jLabel4.setPreferredSize(new java.awt.Dimension(140,19)); |
||
195 | jLabel5.setText(PluginServices.getText(this, "_Driver_type")+":"); |
||
196 | jLabel5.setName("jLabel5");
|
||
197 | jLabel5.setHorizontalTextPosition(javax.swing.SwingConstants.RIGHT); |
||
198 | jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
||
199 | jLabel5.setPreferredSize(new java.awt.Dimension(140,19)); |
||
200 | jPanelLabels.add(getJLabel6(), null);
|
||
201 | jPanelLabels.add(jLabel, null);
|
||
202 | jPanelLabels.add(jLabel1, null);
|
||
203 | jPanelLabels.add(jLabel2, null);
|
||
204 | jPanelLabels.add(jLabel3, null);
|
||
205 | jPanelLabels.add(jLabel4, null);
|
||
206 | jPanelLabels.add(jLabelSchema, null);
|
||
207 | jPanelLabels.add(jLabel5, null);
|
||
208 | |||
209 | } |
||
210 | |||
211 | return jPanelLabels;
|
||
212 | } |
||
213 | |||
214 | /**
|
||
215 | * This method initializes txtHost
|
||
216 | *
|
||
217 | * @return javax.swing.JTextField
|
||
218 | */
|
||
219 | private JTextField getTxtHost() { |
||
220 | if (txtHost == null) { |
||
221 | txtHost = new JTextField(); |
||
222 | txtHost.setPreferredSize(new java.awt.Dimension(170, 19)); |
||
223 | txtHost.setName("txtHost");
|
||
224 | } |
||
225 | |||
226 | return txtHost;
|
||
227 | } |
||
228 | |||
229 | /**
|
||
230 | * This method initializes jPanel1
|
||
231 | *
|
||
232 | * @return javax.swing.JPanel
|
||
233 | */
|
||
234 | private JPanel getJPanelTexts() { |
||
235 | if (jPanelTexts == null) { |
||
236 | FlowLayout flowLayout2 = new FlowLayout(FlowLayout.LEFT); |
||
237 | flowLayout2.setVgap(15);
|
||
238 | jPanelTexts = new JPanel(); |
||
239 | jPanelTexts.setLayout(flowLayout2); |
||
240 | jPanelTexts.setPreferredSize(new Dimension(200, 300)); |
||
241 | |||
242 | jPanelTexts.setName("jPanelText");
|
||
243 | jPanelTexts.add(getCmbName(), null);
|
||
244 | jPanelTexts.add(getTxtHost(), null);
|
||
245 | jPanelTexts.add(getTxtPort(), null);
|
||
246 | jPanelTexts.add(getTxtUser(), null);
|
||
247 | jPanelTexts.add(getTxtPassword(), null);
|
||
248 | jPanelTexts.add(getTxtBD(), null);
|
||
249 | jPanelTexts.add(getTxtSchema(), null);
|
||
250 | jPanelTexts.add(getCmbDriver(), null);
|
||
251 | } |
||
252 | |||
253 | return jPanelTexts;
|
||
254 | } |
||
255 | |||
256 | /**
|
||
257 | * This method initializes txtPort
|
||
258 | *
|
||
259 | * @return javax.swing.JTextField
|
||
260 | */
|
||
261 | private JTextField getTxtPort() { |
||
262 | if (txtPort == null) { |
||
263 | txtPort = new JTextField(); |
||
264 | txtPort.setPreferredSize(new java.awt.Dimension(40, 19)); |
||
265 | txtPort.setName("txtPort");
|
||
266 | txtPort.setText("");
|
||
267 | txtPort.setHorizontalAlignment(javax.swing.JTextField.LEFT); |
||
268 | } |
||
269 | |||
270 | return txtPort;
|
||
271 | } |
||
272 | |||
273 | /**
|
||
274 | * This method initializes txtUser
|
||
275 | *
|
||
276 | * @return javax.swing.JTextField
|
||
277 | */
|
||
278 | private JTextField getTxtUser() { |
||
279 | if (txtUser == null) { |
||
280 | txtUser = new JTextField(); |
||
281 | txtUser.setPreferredSize(new java.awt.Dimension(170, 19)); |
||
282 | txtUser.setName("txtUser");
|
||
283 | } |
||
284 | |||
285 | return txtUser;
|
||
286 | } |
||
287 | |||
288 | /**
|
||
289 | * This method initializes txtPassword
|
||
290 | *
|
||
291 | * @return javax.swing.JTextField
|
||
292 | */
|
||
293 | private JPasswordField getTxtPassword() { |
||
294 | if (txtPassword == null) { |
||
295 | txtPassword = new JPasswordField(); |
||
296 | txtPassword.setPreferredSize(new java.awt.Dimension(170, 19)); |
||
297 | txtPassword.setName("txtPassword");
|
||
298 | } |
||
299 | |||
300 | return txtPassword;
|
||
301 | } |
||
302 | |||
303 | /**
|
||
304 | * This method initializes txtBD
|
||
305 | *
|
||
306 | * @return javax.swing.JTextField
|
||
307 | */
|
||
308 | private JTextField getTxtBD() { |
||
309 | if (txtBD == null) { |
||
310 | txtBD = new JTextField(); |
||
311 | txtBD.setPreferredSize(new java.awt.Dimension(170, 19)); |
||
312 | txtBD.setName("txtBD");
|
||
313 | } |
||
314 | |||
315 | return txtBD;
|
||
316 | } |
||
317 | |||
318 | /**
|
||
319 | * DOCUMENT ME!
|
||
320 | *
|
||
321 | * @return DOCUMENT ME!
|
||
322 | */
|
||
323 | public String getHost() { |
||
324 | return getTxtHost().getText();
|
||
325 | } |
||
326 | |||
327 | /**
|
||
328 | * DOCUMENT ME!
|
||
329 | *
|
||
330 | * @return DOCUMENT ME!
|
||
331 | */
|
||
332 | public String getPort() { |
||
333 | return getTxtPort().getText();
|
||
334 | } |
||
335 | |||
336 | /**
|
||
337 | * DOCUMENT ME!
|
||
338 | *
|
||
339 | * @return DOCUMENT ME!
|
||
340 | */
|
||
341 | public String getUser() { |
||
342 | return getTxtUser().getText();
|
||
343 | } |
||
344 | |||
345 | /**
|
||
346 | * DOCUMENT ME!
|
||
347 | *
|
||
348 | * @return DOCUMENT ME!
|
||
349 | */
|
||
350 | public String getSettingsName() { |
||
351 | if (getCmbName().getSelectedItem() == null){ |
||
352 | return null; |
||
353 | } |
||
354 | return getCmbName().getSelectedItem().toString();
|
||
355 | } |
||
356 | |||
357 | /**
|
||
358 | * DOCUMENT ME!
|
||
359 | *
|
||
360 | * @return DOCUMENT ME!
|
||
361 | */
|
||
362 | public String getPassword() { |
||
363 | passw = String.copyValueOf(getTxtPassword().getPassword());
|
||
364 | return passw;
|
||
365 | } |
||
366 | |||
367 | /**
|
||
368 | * DOCUMENT ME!
|
||
369 | *
|
||
370 | * @return DOCUMENT ME!
|
||
371 | */
|
||
372 | public String getDBName() { |
||
373 | return getTxtBD().getText();
|
||
374 | } |
||
375 | |||
376 | /**
|
||
377 | * DOCUMENT ME!
|
||
378 | *
|
||
379 | * @param drivers DOCUMENT ME!
|
||
380 | */
|
||
381 | public void setDrivers(String[] drivers) { |
||
382 | DefaultComboBoxModel model = new DefaultComboBoxModel(); |
||
383 | |||
384 | for (int i = 0; i < drivers.length; i++) { |
||
385 | model.addElement(drivers[i]); |
||
386 | } |
||
387 | |||
388 | getCmbDriver().setModel(model); |
||
389 | |||
390 | //Para que refresque el textbox del puerto
|
||
391 | if (drivers.length > 0) { |
||
392 | cmbDriver.setSelectedIndex(0);
|
||
393 | } |
||
394 | |||
395 | } |
||
396 | |||
397 | |||
398 | /**
|
||
399 | * @return ConnectionSettings based on values in this panel
|
||
400 | */
|
||
401 | public ConnectionSettings getConnectionSettings()
|
||
402 | { |
||
403 | ConnectionSettings cs = new ConnectionSettings();
|
||
404 | cs.setDb(getDBName()); |
||
405 | cs.setSchema(getSchema()); |
||
406 | cs.setDriver(getDriver()); |
||
407 | cs.setHost(getHost()); |
||
408 | cs.setPort(getPort()); |
||
409 | cs.setUser(getUser()); |
||
410 | cs.setPassw(getPassword()); |
||
411 | cs.setName(getSettingsName()); |
||
412 | return cs;
|
||
413 | } |
||
414 | |||
415 | public String getSchema() { |
||
416 | return txtSchema.getText();
|
||
417 | } |
||
418 | |||
419 | /**
|
||
420 | * Makes persistent the connection settings of this panel.
|
||
421 | */
|
||
422 | public void saveConnectionSettings() |
||
423 | { |
||
424 | ConnectionSettings cs = new ConnectionSettings();
|
||
425 | cs.setDb(getDBName()); |
||
426 | cs.setSchema(getSchema()); |
||
427 | cs.setDriver(getDriver()); |
||
428 | cs.setHost(getHost()); |
||
429 | cs.setPort(getPort()); |
||
430 | cs.setUser(getUser()); |
||
431 | cs.setPassw(getPassword()); |
||
432 | cs.setName(getSettingsName()); |
||
433 | |||
434 | PluginServices ps = PluginServices.getPluginServices(this);
|
||
435 | XMLEntity xml = ps.getPersistentXML(); |
||
436 | |||
437 | try {
|
||
438 | String[] connections = xml.getStringArrayProperty("jdbc-connections"); |
||
439 | String[] newConnections = new String[connections.length + 1]; |
||
440 | System.arraycopy(connections, 0, newConnections, 0, connections.length); |
||
441 | newConnections[connections.length] = cs.toString(); |
||
442 | xml.putProperty("jdbc-connections", newConnections);
|
||
443 | } catch (NotExistInXMLEntity e) {
|
||
444 | xml.putProperty("jdbc-connections", new String[] { cs.toString() }); |
||
445 | } |
||
446 | |||
447 | |||
448 | } |
||
449 | |||
450 | /**
|
||
451 | * DOCUMENT ME!
|
||
452 | *
|
||
453 | * @return DOCUMENT ME!
|
||
454 | */
|
||
455 | public String getDriver() { |
||
456 | return cmbDriver.getSelectedItem().toString();
|
||
457 | } |
||
458 | |||
459 | /**
|
||
460 | * DOCUMENT ME!
|
||
461 | *
|
||
462 | * @param cs DOCUMENT ME!
|
||
463 | */
|
||
464 | public void setSettings(HashMap cs) { |
||
465 | this.cs = cs;
|
||
466 | ((DefaultComboBoxModel) getCmbName().getModel()).removeAllElements();
|
||
467 | |||
468 | Iterator i = cs.keySet().iterator();
|
||
469 | |||
470 | while (i.hasNext()) {
|
||
471 | String item = (String) i.next(); |
||
472 | ((DefaultComboBoxModel) getCmbName().getModel()).addElement(item);
|
||
473 | } |
||
474 | } |
||
475 | |||
476 | /**
|
||
477 | * @see org.gvsig.utils.swing.wizard.Step#init(org.gvsig.utils.swing.wizard.WizardControl)
|
||
478 | */
|
||
479 | public void init(WizardControl w) { |
||
480 | } |
||
481 | |||
482 | /**
|
||
483 | * This method initializes cmbDriver
|
||
484 | *
|
||
485 | * @return com.iver.utiles.swing.JComboBox
|
||
486 | */
|
||
487 | private JComboBox getCmbDriver() { |
||
488 | if (cmbDriver == null) { |
||
489 | cmbDriver = new JComboBox(); |
||
490 | cmbDriver.setPreferredSize(new java.awt.Dimension(170, 19)); |
||
491 | cmbDriver.setName("cmbDriver");
|
||
492 | cmbDriver.addActionListener(new ActionListener() { |
||
493 | public void actionPerformed(ActionEvent e) { |
||
494 | String driverName = cmbDriver.getSelectedItem().toString();
|
||
495 | DataManager dm = DALLocator.getDataManager(); |
||
496 | DBParameters dsp=null;
|
||
497 | try {
|
||
498 | dsp = (DBParameters) dm |
||
499 | .createServerExplorerParameters(driverName); |
||
500 | } catch (InitializeException e1) {
|
||
501 | // TODO Auto-generated catch block
|
||
502 | e1.printStackTrace(); |
||
503 | } catch (ProviderNotRegisteredException e1) {
|
||
504 | // TODO Auto-generated catch block
|
||
505 | e1.printStackTrace(); |
||
506 | } |
||
507 | |||
508 | // String port = dsp.getPort() + "";
|
||
509 | // getTxtPort().setText(port);
|
||
510 | } |
||
511 | }); |
||
512 | } |
||
513 | |||
514 | return cmbDriver;
|
||
515 | } |
||
516 | |||
517 | /**
|
||
518 | * DOCUMENT ME!
|
||
519 | *
|
||
520 | * @return
|
||
521 | */
|
||
522 | public boolean done() { |
||
523 | return (getTxtBD().getText().length() > 0) && |
||
524 | (getTxtHost().getText().length() > 0) &&
|
||
525 | (getCmbName().getSelectedItem() != null) &&
|
||
526 | (getCmbName().getSelectedItem().toString().length() > 0);
|
||
527 | } |
||
528 | |||
529 | /**
|
||
530 | * This method initializes jLabel6
|
||
531 | *
|
||
532 | * @return javax.swing.JLabel
|
||
533 | */
|
||
534 | private JLabel getJLabel6() { |
||
535 | if (jLabel6 == null) { |
||
536 | jLabel6 = new JLabel(); |
||
537 | jLabel6.setText(PluginServices.getText(this, "_Connection_name")+":"); |
||
538 | jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
||
539 | jLabel6.setPreferredSize(new java.awt.Dimension(140,19)); |
||
540 | } |
||
541 | |||
542 | return jLabel6;
|
||
543 | } |
||
544 | |||
545 | /**
|
||
546 | * This method initializes jComboBox
|
||
547 | *
|
||
548 | * @return com.iver.utiles.swing.JComboBox
|
||
549 | */
|
||
550 | private org.gvsig.utils.swing.JComboBox getCmbName() {
|
||
551 | if (cmbName == null) { |
||
552 | cmbName = new org.gvsig.utils.swing.JComboBox();
|
||
553 | cmbName.setEditable(true);
|
||
554 | cmbName.setPreferredSize(new java.awt.Dimension(170, 19)); |
||
555 | cmbName.setModel(new DefaultComboBoxModel()); |
||
556 | cmbName.addActionListener(new ActionListener() { |
||
557 | public void actionPerformed(ActionEvent e) { |
||
558 | Object item = cmbName.getSelectedItem();
|
||
559 | |||
560 | if (item == null) { |
||
561 | return;
|
||
562 | } |
||
563 | |||
564 | ConnectionSettings c = (ConnectionSettings) cs.get(item.toString()); |
||
565 | |||
566 | if (c != null) { |
||
567 | getTxtHost().setText(c.getHost()); |
||
568 | getTxtPort().setText(c.getPort()); |
||
569 | getTxtBD().setText(c.getDb()); |
||
570 | getTxtUser().setText(c.getUser()); |
||
571 | if (c.getPassw() != null) { |
||
572 | getTxtPassword().setText(c.getPassw()); |
||
573 | } |
||
574 | getCmbDriver().setSelectedItem(c.getDriver()); |
||
575 | } |
||
576 | } |
||
577 | }); |
||
578 | } |
||
579 | |||
580 | return cmbName;
|
||
581 | } |
||
582 | |||
583 | /**
|
||
584 | * This method initializes jPanel
|
||
585 | *
|
||
586 | * @return javax.swing.JPanel
|
||
587 | */
|
||
588 | private JPanel getJPanel() { |
||
589 | if (jPanel == null) { |
||
590 | jPanel = new JPanel(); |
||
591 | jPanel.setLayout(new BorderLayout()); |
||
592 | jPanel.setBounds(0, 0, 363, 240); |
||
593 | jPanel.add(getJPanelLabels(), java.awt.BorderLayout.WEST); |
||
594 | jPanel.add(getJPanelTexts(), java.awt.BorderLayout.EAST); |
||
595 | } |
||
596 | return jPanel;
|
||
597 | } |
||
598 | |||
599 | /**
|
||
600 | * This method initializes XYZ
|
||
601 | *
|
||
602 | * @return com.iver.cit.gvsig.jdbc_spatial.gui.jdbcwizard.ConnectionPanel
|
||
603 | */
|
||
604 | private ConnectionPanel getXYZ() {
|
||
605 | if (XYZ == null) { |
||
606 | XYZ = new ConnectionPanel();
|
||
607 | XYZ.setLayout(null);
|
||
608 | XYZ.setSize(new java.awt.Dimension(335,240)); |
||
609 | XYZ.add(getJPanel1(), null);
|
||
610 | } |
||
611 | return XYZ;
|
||
612 | } |
||
613 | |||
614 | /**
|
||
615 | * This method initializes jPanel1
|
||
616 | *
|
||
617 | * @return javax.swing.JPanel
|
||
618 | */
|
||
619 | private JPanel getJPanel1() { |
||
620 | if (jPanel1 == null) { |
||
621 | jPanel1 = new JPanel(); |
||
622 | jPanel1.setLayout(new BorderLayout()); |
||
623 | jPanel1.setBounds(new Rectangle(0, 0, 363, 240)); |
||
624 | jPanel1.add(getJPanelLabels1(), java.awt.BorderLayout.WEST); |
||
625 | jPanel1.add(getJPanelTexts1(), java.awt.BorderLayout.EAST); |
||
626 | } |
||
627 | return jPanel1;
|
||
628 | } |
||
629 | |||
630 | /**
|
||
631 | * This method initializes jPanelLabels1
|
||
632 | *
|
||
633 | * @return javax.swing.JPanel
|
||
634 | */
|
||
635 | private JPanel getJPanelLabels1() { |
||
636 | if (jPanelLabels1 == null) { |
||
637 | jLabel51 = new JLabel(); |
||
638 | jLabel51.setName("jLabel5");
|
||
639 | jLabel51.setHorizontalAlignment(SwingConstants.RIGHT);
|
||
640 | jLabel51.setHorizontalTextPosition(SwingConstants.RIGHT);
|
||
641 | jLabel51.setText(PluginServices.getText(getXYZ(), "_Driver_type") + ":"); |
||
642 | jLabel51.setPreferredSize(new Dimension(140, 19)); |
||
643 | jLabel31 = new JLabel(); |
||
644 | jLabel31.setName("jLabel3");
|
||
645 | jLabel31.setHorizontalAlignment(SwingConstants.RIGHT);
|
||
646 | jLabel31.setHorizontalTextPosition(SwingConstants.RIGHT);
|
||
647 | jLabel31.setText(PluginServices.getText(getXYZ(), "_Password") + ":"); |
||
648 | jLabel31.setPreferredSize(new Dimension(140, 19)); |
||
649 | jLabel21 = new JLabel(); |
||
650 | jLabel21.setName("jLabel2");
|
||
651 | jLabel21.setHorizontalAlignment(SwingConstants.RIGHT);
|
||
652 | jLabel21.setHorizontalTextPosition(SwingConstants.RIGHT);
|
||
653 | jLabel21.setText(PluginServices.getText(getXYZ(), "_User") + ":"); |
||
654 | jLabel21.setPreferredSize(new Dimension(140, 19)); |
||
655 | jLabel11 = new JLabel(); |
||
656 | jLabel11.setName("jLabel1");
|
||
657 | jLabel11.setHorizontalAlignment(SwingConstants.TRAILING);
|
||
658 | jLabel11.setText(PluginServices.getText(getXYZ(), "_Port") + ":"); |
||
659 | jLabel11.setPreferredSize(new Dimension(140, 19)); |
||
660 | jLabel7 = new JLabel(); |
||
661 | jLabel7.setName("jLabel");
|
||
662 | jLabel7.setHorizontalAlignment(SwingConstants.RIGHT);
|
||
663 | jLabel7.setText(PluginServices.getText(getXYZ(), "_Host") + ":"); |
||
664 | jLabel7.setPreferredSize(new Dimension(140, 19)); |
||
665 | jLabel61 = new JLabel(); |
||
666 | jLabel61.setPreferredSize(new Dimension(140, 19)); |
||
667 | jLabel61.setText(PluginServices.getText(getXYZ(), "_Connection_name") + ":"); |
||
668 | jLabel61.setHorizontalAlignment(SwingConstants.RIGHT);
|
||
669 | FlowLayout flowLayout31 = new FlowLayout(); |
||
670 | flowLayout31.setVgap(15);
|
||
671 | jPanelLabels1 = new JPanel(); |
||
672 | jPanelLabels1.setPreferredSize(new Dimension(150, 400)); |
||
673 | jPanelLabels1.setLayout(flowLayout31); |
||
674 | jPanelLabels1.setName("jPanelLabels");
|
||
675 | jPanelLabels1.add(jLabel61, null);
|
||
676 | jPanelLabels1.add(jLabel7, null);
|
||
677 | jPanelLabels1.add(jLabel11, null);
|
||
678 | jPanelLabels1.add(jLabel21, null);
|
||
679 | jPanelLabels1.add(jLabel31, null);
|
||
680 | jPanelLabels1.add(jLabelSchema, jLabelSchema.getName()); |
||
681 | jPanelLabels1.add(jLabel51, null);
|
||
682 | } |
||
683 | return jPanelLabels1;
|
||
684 | } |
||
685 | |||
686 | /**
|
||
687 | * This method initializes jPanelTexts1
|
||
688 | *
|
||
689 | * @return javax.swing.JPanel
|
||
690 | */
|
||
691 | private JPanel getJPanelTexts1() { |
||
692 | if (jPanelTexts1 == null) { |
||
693 | FlowLayout flowLayout21 = new FlowLayout(FlowLayout.LEFT); |
||
694 | flowLayout21.setVgap(15);
|
||
695 | jPanelTexts1 = new JPanel(); |
||
696 | jPanelTexts1.setPreferredSize(new Dimension(200, 300)); |
||
697 | jPanelTexts1.setLayout(flowLayout21); |
||
698 | jPanelTexts1.setName("jPanelText");
|
||
699 | jPanelTexts1.add(getCmbName1(), null);
|
||
700 | jPanelTexts1.add(getTxtHost1(), null);
|
||
701 | jPanelTexts1.add(getTxtPort1(), null);
|
||
702 | jPanelTexts1.add(getTxtUser1(), null);
|
||
703 | jPanelTexts1.add(getTxtPassword1(), null);
|
||
704 | jPanelTexts1.add(getTxtBD1(), null);
|
||
705 | jPanelTexts1.add(getCmbDriver1(), null);
|
||
706 | } |
||
707 | return jPanelTexts1;
|
||
708 | } |
||
709 | |||
710 | /**
|
||
711 | * This method initializes cmbName1
|
||
712 | *
|
||
713 | * @return com.iver.utiles.swing.JComboBox
|
||
714 | */
|
||
715 | private JComboBox getCmbName1() { |
||
716 | if (cmbName1 == null) { |
||
717 | cmbName1 = new JComboBox(); |
||
718 | cmbName1.setPreferredSize(new Dimension(170, 19)); |
||
719 | cmbName1.setModel(new DefaultComboBoxModel()); |
||
720 | cmbName1.setEditable(true);
|
||
721 | } |
||
722 | return cmbName1;
|
||
723 | } |
||
724 | |||
725 | /**
|
||
726 | * This method initializes txtHost1
|
||
727 | *
|
||
728 | * @return javax.swing.JTextField
|
||
729 | */
|
||
730 | private JTextField getTxtHost1() { |
||
731 | if (txtHost1 == null) { |
||
732 | txtHost1 = new JTextField(); |
||
733 | txtHost1.setName("txtHost");
|
||
734 | txtHost1.setPreferredSize(new Dimension(170, 19)); |
||
735 | } |
||
736 | return txtHost1;
|
||
737 | } |
||
738 | |||
739 | /**
|
||
740 | * This method initializes txtPort1
|
||
741 | *
|
||
742 | * @return javax.swing.JTextField
|
||
743 | */
|
||
744 | private JTextField getTxtPort1() { |
||
745 | if (txtPort1 == null) { |
||
746 | txtPort1 = new JTextField(); |
||
747 | txtPort1.setName("txtPort");
|
||
748 | txtPort1.setText("");
|
||
749 | txtPort1.setHorizontalAlignment(JTextField.LEFT);
|
||
750 | txtPort1.setPreferredSize(new Dimension(40, 19)); |
||
751 | } |
||
752 | return txtPort1;
|
||
753 | } |
||
754 | |||
755 | /**
|
||
756 | * This method initializes txtUser1
|
||
757 | *
|
||
758 | * @return javax.swing.JTextField
|
||
759 | */
|
||
760 | private JTextField getTxtUser1() { |
||
761 | if (txtUser1 == null) { |
||
762 | txtUser1 = new JTextField(); |
||
763 | txtUser1.setName("txtUser");
|
||
764 | txtUser1.setPreferredSize(new Dimension(170, 19)); |
||
765 | } |
||
766 | return txtUser1;
|
||
767 | } |
||
768 | |||
769 | /**
|
||
770 | * This method initializes txtPassword1
|
||
771 | *
|
||
772 | * @return javax.swing.JPasswordField
|
||
773 | */
|
||
774 | private JPasswordField getTxtPassword1() { |
||
775 | if (txtPassword1 == null) { |
||
776 | txtPassword1 = new JPasswordField(); |
||
777 | txtPassword1.setName("txtPassword");
|
||
778 | txtPassword1.setPreferredSize(new Dimension(170, 19)); |
||
779 | } |
||
780 | return txtPassword1;
|
||
781 | } |
||
782 | |||
783 | /**
|
||
784 | * This method initializes txtBD1
|
||
785 | *
|
||
786 | * @return javax.swing.JTextField
|
||
787 | */
|
||
788 | private JTextField getTxtBD1() { |
||
789 | if (txtBD1 == null) { |
||
790 | txtBD1 = new JTextField(); |
||
791 | txtBD1.setName("txtBD");
|
||
792 | txtBD1.setPreferredSize(new Dimension(170, 19)); |
||
793 | } |
||
794 | return txtBD1;
|
||
795 | } |
||
796 | |||
797 | /**
|
||
798 | * This method initializes cmbDriver1
|
||
799 | *
|
||
800 | * @return com.iver.utiles.swing.JComboBox
|
||
801 | */
|
||
802 | private JComboBox getCmbDriver1() { |
||
803 | if (cmbDriver1 == null) { |
||
804 | cmbDriver1 = new JComboBox(); |
||
805 | cmbDriver1.setName("cmbDriver");
|
||
806 | cmbDriver1.setPreferredSize(new Dimension(170, 19)); |
||
807 | } |
||
808 | return cmbDriver1;
|
||
809 | } |
||
810 | |||
811 | /**
|
||
812 | * This method initializes txtSchema
|
||
813 | *
|
||
814 | * @return javax.swing.JTextField
|
||
815 | */
|
||
816 | private JTextField getTxtSchema() { |
||
817 | if (txtSchema == null) { |
||
818 | txtSchema = new JTextField(); |
||
819 | txtSchema.setName("txtBD");
|
||
820 | txtSchema.setPreferredSize(new Dimension(170, 19)); |
||
821 | } |
||
822 | return txtSchema;
|
||
823 | } |
||
824 | } // @jve:decl-index=0:visual-constraint="7,3" |