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