Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extGeoDB / src / org / gvsig / geodb / vectorialdb / wizard / VectorialDBConnectionParamsDialog.java @ 33662

History | View | Annotate | Download (20.5 KB)

1 11971 caballero
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2006 Prodevelop and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *   Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *   +34 963862235
28
 *   gvsig@gva.es
29
 *   www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   Prodevelop Integraci?n de Tecnolog?as SL
34
 *   Conde Salvatierra de ?lava , 34-10
35
 *   46004 Valencia
36
 *   Spain
37
 *
38
 *   +34 963 510 612
39
 *   +34 963 510 968
40
 *   gis@prodevelop.es
41
 *   http://www.prodevelop.es
42
 */
43 29628 jpiera
package org.gvsig.geodb.vectorialdb.wizard;
44 11971 caballero
45
import java.awt.Color;
46
import java.awt.event.ActionEvent;
47
import java.awt.event.ActionListener;
48
import java.awt.event.KeyEvent;
49
import java.awt.event.KeyListener;
50 29199 jmvivo
import java.util.ArrayList;
51 27909 jmvivo
import java.util.Iterator;
52 24759 jmvivo
import java.util.List;
53 11971 caballero
54
import javax.swing.JButton;
55
import javax.swing.JCheckBox;
56
import javax.swing.JComboBox;
57
import javax.swing.JLabel;
58
import javax.swing.JPanel;
59
import javax.swing.JPasswordField;
60
import javax.swing.JTextField;
61
62 12826 jaume
import org.apache.log4j.Logger;
63 33662 cordinyana
64 29628 jpiera
import org.gvsig.andami.PluginServices;
65
import org.gvsig.andami.messages.NotificationManager;
66
import org.gvsig.andami.ui.mdiManager.IWindow;
67
import org.gvsig.andami.ui.mdiManager.WindowInfo;
68 24759 jmvivo
import org.gvsig.fmap.dal.DALLocator;
69 24964 vcaballero
import org.gvsig.fmap.dal.DataManager;
70 24878 jmvivo
import org.gvsig.fmap.dal.DataServerExplorerParameters;
71 27909 jmvivo
import org.gvsig.fmap.dal.exception.DataException;
72
import org.gvsig.fmap.dal.exception.ValidateDataParametersException;
73 27723 jmvivo
import org.gvsig.fmap.dal.serverexplorer.db.DBServerExplorerParameters;
74 29199 jmvivo
import org.gvsig.fmap.dal.serverexplorer.filesystem.swing.DynObjectEditor;
75 33662 cordinyana
import org.gvsig.tools.service.ServiceException;
76 11971 caballero
77 12826 jaume
78
79 11971 caballero
/**
80
 * Lets the user input the connection parameters.
81
 *
82
 * @author jldominguez
83
 *
84
 */
85
public class VectorialDBConnectionParamsDialog extends JPanel implements IWindow,
86
    ActionListener, KeyListener {
87 33662 cordinyana
88
    private static final long serialVersionUID = -5493563028200403559L;
89
    private static Logger LOG = Logger
90
        .getLogger(VectorialDBConnectionParamsDialog.class);
91
92 11971 caballero
    private WindowInfo winfo = new WindowInfo(8); // MODAL only
93
    private JButton cancelButton = null;
94
    private JButton okButton = null;
95 29199 jmvivo
    private JButton advancedButton = null;
96 11971 caballero
    private JPanel paramsPanel = null;
97
    private JComboBox driverComboBox = null;
98
    private JTextField portTextField = null;
99
    private JTextField dbTextField = null;
100
    private JTextField userTextField = null;
101
    private JPasswordField passwordField = null;
102
    private JLabel driverLabel = null;
103
    private JLabel portLabel = null;
104
    private JLabel dbLabel = null;
105 14543 jmvivo
    private JLabel dbLabelWarning = null;
106 11971 caballero
    private JLabel userLabel = null;
107
    private JLabel pwLabel = null;
108
    private boolean okPressed = false;
109
    private JTextField urlTextField = null;
110
    private JLabel urlLabel = null;
111
    private JCheckBox connectedCheckBox = null;
112
    private JLabel connectedLabel = null;
113
    private JLabel connNameLabel = null;
114
    private JTextField connNameTextField = null;
115
116 29199 jmvivo
    private DBServerExplorerParameters params = null;
117
118 11971 caballero
    /**
119
     * This method initializes
120
     *
121
     */
122
    public VectorialDBConnectionParamsDialog() {
123
        super();
124
        initialize();
125
    }
126
127
    public void showDialog() {
128
        PluginServices.getMDIManager().addWindow(this);
129
    }
130
131
    /**
132
     * This method initializes this
133
     *
134
     */
135
    private void initialize() {
136
        winfo.setWidth(370);
137 14543 jmvivo
        winfo.setHeight(317 - 25);
138 11971 caballero
        winfo.setTitle(PluginServices.getText(this, "connection_parameters"));
139
140 14543 jmvivo
        this.setSize(new java.awt.Dimension(360, 329));
141 11971 caballero
        this.setLayout(null);
142
        this.add(getCancelButton(), null);
143
        this.add(getOkButton(), null);
144 29199 jmvivo
        this.add(getAdvancedButton(), null);
145 11971 caballero
        this.add(getParamsPanel(), null);
146
    }
147
148
    public WindowInfo getWindowInfo() {
149
        return winfo;
150
    }
151
152
    /**
153
     * This method initializes cancelButton
154
     *
155
     * @return javax.swing.JButton
156
     */
157
    private JButton getCancelButton() {
158
        if (cancelButton == null) {
159
            cancelButton = new JButton();
160
            cancelButton.setText(PluginServices.getText(this, "cancel"));
161
            cancelButton.addActionListener(this);
162 29199 jmvivo
            cancelButton.setBounds(new java.awt.Rectangle(124, 292, 90, 26));
163 11971 caballero
        }
164
165
        return cancelButton;
166
    }
167
168
    /**
169
     * This method initializes okButton
170
     *
171
     * @return javax.swing.JButton
172
     */
173
    private JButton getOkButton() {
174
        if (okButton == null) {
175
            okButton = new JButton();
176
            okButton.setText(PluginServices.getText(this, "ok"));
177
            okButton.addActionListener(this);
178 29199 jmvivo
            okButton.setBounds(new java.awt.Rectangle(30, 292, 90, 26));
179 11971 caballero
        }
180
181
        return okButton;
182
    }
183
184 29199 jmvivo
        /**
185
         * This method initializes okButton
186
         *
187
         * @return javax.swing.JButton
188
         */
189
        private JButton getAdvancedButton() {
190
                if (advancedButton == null) {
191
                        advancedButton = new JButton();
192
                        advancedButton.setText(PluginServices.getText(this, "advanced"));
193
                        advancedButton.addActionListener(this);
194
                        advancedButton.setBounds(new java.awt.Rectangle(218, 292, 90, 26));
195
                }
196
197
                return advancedButton;
198
        }
199
200
        /**
201
         * This method initializes paramsPanel
202
         *
203
         * @return javax.swing.JPanel
204
         */
205 11971 caballero
    private JPanel getParamsPanel() {
206
        if (paramsPanel == null) {
207
            connNameLabel = new JLabel();
208
            connNameLabel.setBounds(new java.awt.Rectangle(10, 30, 141, 21));
209
            connNameLabel.setText(PluginServices.getText(this, "connection_name") +
210
                ":");
211
            connectedLabel = new JLabel();
212 14543 jmvivo
            connectedLabel.setBounds(new java.awt.Rectangle(10, 247, 141, 21));
213 11971 caballero
            connectedLabel.setText(PluginServices.getText(this, "connected") +
214
                ":");
215
            urlLabel = new JLabel();
216
            urlLabel.setBounds(new java.awt.Rectangle(10, 80, 141, 21));
217
            urlLabel.setText(PluginServices.getText(this, "server_url") + ":");
218
            pwLabel = new JLabel();
219 14543 jmvivo
            pwLabel.setBounds(new java.awt.Rectangle(10, 222, 141, 21));
220 11971 caballero
            pwLabel.setText(PluginServices.getText(this, "password") + ":");
221
            userLabel = new JLabel();
222 14543 jmvivo
            userLabel.setBounds(new java.awt.Rectangle(10, 197, 141, 21));
223 11971 caballero
            userLabel.setText(PluginServices.getText(this, "user") + ":");
224
            dbLabel = new JLabel();
225
            dbLabel.setBounds(new java.awt.Rectangle(10, 130, 141, 21));
226
            dbLabel.setText(PluginServices.getText(this, "database_name") +
227
                ":");
228 14543 jmvivo
            dbLabelWarning = new JLabel();
229
            dbLabelWarning.setBounds(new java.awt.Rectangle(10, 155, 310, 41));
230
            dbLabelWarning.setText(PluginServices.getText(this, "warning_you_must_input_the_exact_name_this_difference_between_capital_letters_and_small_letters")
231
                );
232
233 11971 caballero
            portLabel = new JLabel();
234
            portLabel.setBounds(new java.awt.Rectangle(10, 105, 141, 21));
235
            portLabel.setText(PluginServices.getText(this, "port") + ":");
236
            driverLabel = new JLabel();
237
            driverLabel.setBounds(new java.awt.Rectangle(10, 55, 141, 21));
238
            driverLabel.setText(PluginServices.getText(this, "driver") + ":");
239
            paramsPanel = new JPanel();
240 14543 jmvivo
            paramsPanel.setBounds(new java.awt.Rectangle(10, 10, 336, 273));
241 11971 caballero
            paramsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(
242
                    null, PluginServices.getText(this, "connection_params"),
243
                    javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
244
                    javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
245
            paramsPanel.setLayout(null);
246
            paramsPanel.add(getPortTextField(), null);
247
            paramsPanel.add(getDriverComboBox(), null);
248
            paramsPanel.add(getDbTextField(), null);
249
            paramsPanel.add(getUserTextField(), null);
250
            paramsPanel.add(getPasswordField(), null);
251
            paramsPanel.add(driverLabel, null);
252
            paramsPanel.add(portLabel, null);
253
            paramsPanel.add(dbLabel, null);
254 14543 jmvivo
            paramsPanel.add(dbLabelWarning, null);
255 11971 caballero
            paramsPanel.add(userLabel, null);
256
            paramsPanel.add(pwLabel, null);
257
            paramsPanel.add(getUrlTextArea(), null);
258
            paramsPanel.add(urlLabel, null);
259
            paramsPanel.add(getConnectedCheckBox(), null);
260
            paramsPanel.add(connectedLabel, null);
261
            paramsPanel.add(connNameLabel, null);
262
            paramsPanel.add(getConnNameTextField(), null);
263
        }
264
265
        return paramsPanel;
266
    }
267
268
    /**
269
     * This method initializes driverComboBox
270
     *
271
     * @return javax.swing.JComboBox
272
     */
273
    private JComboBox getDriverComboBox() {
274
        if (driverComboBox == null) {
275
            driverComboBox = new JComboBox();
276
            driverComboBox.addActionListener(this);
277 24759 jmvivo
            DataManager dm = DALLocator.getDataManager();
278 27909 jmvivo
            List<String> explorers = dm.getExplorerProviders();
279
            Iterator<String> iter = explorers.iterator();
280
            String expName;
281
282 24878 jmvivo
            DataServerExplorerParameters params;
283 27909 jmvivo
            while (iter.hasNext()) {
284
                    expName = iter.next();
285
                                try {
286
                                        params = dm.createServerExplorerParameters(expName);
287
                                } catch (DataException e) {
288 22185 jmvivo
                                        NotificationManager.addWarning(PluginServices.getText(null,
289
                                                        "DataExplorer_parameters_error")
290 27909 jmvivo
                                                        + ": " + expName, e);
291 22185 jmvivo
                                        continue;
292
                                }
293 27909 jmvivo
                                if (params instanceof DBServerExplorerParameters) {
294
                                        DBServerExplorerParameters dbParams = (DBServerExplorerParameters) params;
295
                                        driverComboBox.addItem(new DriverComboBoxItem(
296
                                                        dbParams));
297 22185 jmvivo
                                }
298 11971 caballero
299 22035 vcaballero
            }
300 11971 caballero
301
            driverComboBox.setBounds(new java.awt.Rectangle(155, 55, 166, 21));
302 22185 jmvivo
303 11971 caballero
        }
304
305
        return driverComboBox;
306
    }
307
308 22185 jmvivo
    private class DriverComboBoxItem {
309 27723 jmvivo
            private DBServerExplorerParameters params;
310 22185 jmvivo
311 27723 jmvivo
            public DriverComboBoxItem(DBServerExplorerParameters dbParams) {
312 22185 jmvivo
                        this.params = dbParams;
313
                }
314
315
                public String toString() {
316 27723 jmvivo
                        // FIXME
317
                    return params.getExplorerName();
318 22185 jmvivo
            }
319
    }
320
321 11971 caballero
    /**
322
     * This method initializes portTextField
323
     *
324
     * @return javax.swing.JTextField
325
     */
326
    private JTextField getPortTextField() {
327
        if (portTextField == null) {
328
            portTextField = new JTextField();
329
            portTextField.addKeyListener(this);
330
            portTextField.setBounds(new java.awt.Rectangle(155, 105, 166, 21));
331
        }
332
333
        return portTextField;
334
    }
335
336
    /**
337
     * This method initializes dbTextField
338
     *
339
     * @return javax.swing.JTextField
340
     */
341
    private JTextField getDbTextField() {
342
        if (dbTextField == null) {
343
            dbTextField = new JTextField();
344
            dbTextField.addKeyListener(this);
345
            dbTextField.setBounds(new java.awt.Rectangle(155, 130, 166, 21));
346
        }
347
348
        return dbTextField;
349
    }
350
351
    /**
352
     * This method initializes userTextField
353
     *
354
     * @return javax.swing.JTextField
355
     */
356
    private JTextField getUserTextField() {
357
        if (userTextField == null) {
358
            userTextField = new JTextField();
359
            userTextField.addKeyListener(this);
360 14543 jmvivo
            userTextField.setBounds(new java.awt.Rectangle(155, 197, 166, 21));
361 11971 caballero
        }
362
363
        return userTextField;
364
    }
365
366
    /**
367
     * This method initializes passwordField
368
     *
369
     * @return javax.swing.JPasswordField
370
     */
371
    private JPasswordField getPasswordField() {
372
        if (passwordField == null) {
373
            passwordField = new JPasswordField();
374
            passwordField.addKeyListener(this);
375 14543 jmvivo
            passwordField.setBounds(new java.awt.Rectangle(155, 222, 166, 21));
376 11971 caballero
        }
377
378
        return passwordField;
379
    }
380
381 21910 vcaballero
//    private String[] getDriverNames() {
382
//        Class[] classes = new Class[] { IVectorialDatabaseDriver.class };
383
//
384
//        ArrayList ret = new ArrayList();
385
//        String[] driverNames = LayerFactory.getDM().getDriverNames();
386
//
387
//        for (int i = 0; i < driverNames.length; i++) {
388
//            for (int j = 0; j < classes.length; j++) {
389
//                if (LayerFactory.getDM().isA(driverNames[i], classes[j])) {
390
//                    ret.add(driverNames[i]);
391
//                }
392
//            }
393
//        }
394
//
395
//        return (String[]) ret.toArray(new String[0]);
396
//    }
397 11971 caballero
398
    public void actionPerformed(ActionEvent arg0) {
399
        Object src = arg0.getSource();
400
401
        if (src == connectedCheckBox) {
402
            if (connectedCheckBox.isSelected()) {
403
                passwordField.setEnabled(true);
404
                passwordField.setBackground(Color.WHITE);
405
            }
406
            else {
407
                passwordField.setText("");
408
                passwordField.setEnabled(false);
409
                passwordField.setBackground(Color.LIGHT_GRAY);
410
            }
411
        }
412
413
        if (src == okButton) {
414
            okPressed = true;
415
            PluginServices.getMDIManager().closeWindow(this);
416
417
            return;
418
        }
419
420
        if (src == cancelButton) {
421
            okPressed = false;
422
            PluginServices.getMDIManager().closeWindow(this);
423
424
            return;
425
        }
426
427 29199 jmvivo
        if (src == advancedButton) {
428
                List<String> toHide = new ArrayList<String>();
429 32880 jjdelcerro
                toHide.add(DBServerExplorerParameters.PASSWORD_PARAMTER_NAME);
430
                toHide.add(DBServerExplorerParameters.HOST_PARAMTER_NAME);
431
                        toHide.add(DBServerExplorerParameters.PORT_PARAMTER_NAME);
432
                        toHide.add(DBServerExplorerParameters.USER_PARAMTER_NAME);
433
                        toHide.add(DBServerExplorerParameters.DBNAME_PARAMTER_NAME);
434 29199 jmvivo
                        DBServerExplorerParameters myParams = getParameters();
435
                        try {
436
                                myParams.validate();
437
                        } catch (Exception e) {
438
                                // ignore... only for fill default values
439
                        }
440 33662 cordinyana
            try {
441
                DynObjectEditor editor = new DynObjectEditor(myParams);
442
                editor.editObject(true);
443
            } catch (ServiceException ex) {
444
                LOG.error(
445
                    "Error creating a Swing component for the DynObject: "
446
                        + myParams, ex);
447
            }
448 29199 jmvivo
449
                        return;
450
                }
451
452 11971 caballero
        if (src == driverComboBox) {
453 27909 jmvivo
                DBServerExplorerParameters params = ((DriverComboBoxItem) driverComboBox
454 22185 jmvivo
                                        .getSelectedItem()).params;
455 27909 jmvivo
                        try {
456
                                params.validate();
457
                        } catch (ValidateDataParametersException e) {
458
                        }
459 11971 caballero
460 21910 vcaballero
//            try {
461
//                    DataManager dm=DataManager.getManager();
462
//                featureStore = (FeatureStore) dm.createDataStore()LayerFactory.getDM()
463
//                                                           .getDriver(driverName);
464 27953 jmvivo
                        if (params.getPort() != null) {
465
                                portTextField.setText(params.getPort() + "");
466
                        } else {
467
                                portTextField.setText("");
468
                        }
469 21910 vcaballero
//            }
470
//            catch (DriverLoadException e1) {
471
//                portTextField.setText("");
472
//            }
473 11971 caballero
474
            return;
475
        }
476
    }
477
478
    public boolean isOkPressed() {
479
        return okPressed;
480
    }
481
482
    public boolean hasToBeConnected() {
483
        return connectedCheckBox.isSelected();
484
    }
485
486
    public String getConnectionDriverName() {
487 22207 jmvivo
        return ((DriverComboBoxItem) driverComboBox.getSelectedItem()).params
488 27909 jmvivo
                                .getExplorerName();
489 11971 caballero
    }
490
491
    public String getConnectionServerUrl() {
492
        return urlTextField.getText();
493
    }
494
495
    public String getConnectionPort() {
496
        return portTextField.getText();
497
    }
498
499
    public String getConnectionDBName() {
500
        return dbTextField.getText();
501
    }
502
503
    public String getConnectionUser() {
504
        return userTextField.getText();
505
    }
506
507
    public String getConnectionPassword() {
508
        String resp = new String(passwordField.getPassword());
509
510
        return resp;
511
    }
512
513
    private JTextField getUrlTextArea() {
514
        if (urlTextField == null) {
515
            urlTextField = new JTextField();
516
            urlTextField.addKeyListener(this);
517
            urlTextField.setBounds(new java.awt.Rectangle(155, 80, 166, 21));
518
        }
519
520
        return urlTextField;
521
    }
522
523
    /**
524
     * This method initializes connectedCheckBox
525
     *
526
     * @return javax.swing.JCheckBox
527
     */
528
    private JCheckBox getConnectedCheckBox() {
529
        if (connectedCheckBox == null) {
530
            connectedCheckBox = new JCheckBox();
531
            connectedCheckBox.setSelected(true);
532
            connectedCheckBox.addActionListener(this);
533 14543 jmvivo
            connectedCheckBox.setBounds(new java.awt.Rectangle(155, 247, 26, 21));
534 11971 caballero
        }
535
536
        return connectedCheckBox;
537
    }
538
539
    public String getConnectionName() {
540
        return getConnNameTextField().getText();
541
    }
542
543
    /**
544
     * This method initializes connNameTextField
545
     *
546
     * @return javax.swing.JTextField
547
     */
548
    private JTextField getConnNameTextField() {
549
        if (connNameTextField == null) {
550
            connNameTextField = new JTextField();
551
            connNameTextField.addKeyListener(this);
552
            connNameTextField.setBounds(new java.awt.Rectangle(155, 30, 166, 21));
553
        }
554
555
        return connNameTextField;
556
    }
557
558
    public void keyPressed(KeyEvent e) {
559
    }
560
561
    public void keyReleased(KeyEvent e) {
562
        if (e.getKeyChar() != '\n') {
563
            return;
564
        }
565
566
        Object src = e.getSource();
567
568
        if (src == passwordField) {
569
            ActionEvent aevt = new ActionEvent(okButton,
570
                    ActionEvent.ACTION_PERFORMED, "");
571
            actionPerformed(aevt);
572
        }
573
        else {
574
            if (src instanceof JTextField) {
575
                ((JTextField) src).transferFocus();
576
            }
577
        }
578
    }
579
580
    public void keyTyped(KeyEvent e) {
581 22185 jmvivo
        }
582 11971 caballero
583 27723 jmvivo
    public void loadValues(DBServerExplorerParameters cwp) {
584 27953 jmvivo
            if (cwp.getPort() != null){
585
                    getPortTextField().setText(cwp.getPort().toString());
586
            } else{
587
                    getPortTextField().setText("");
588
            }
589 27723 jmvivo
        selectThisInDriverCombo(cwp.getExplorerName());
590 27909 jmvivo
        getDbTextField().setText(cwp.getDBName());
591 11971 caballero
        getUserTextField().setText(cwp.getUser());
592
593 27909 jmvivo
        if (cwp.getPassword() == null) {
594 11971 caballero
            getPasswordField().setText("");
595
        }
596
        else {
597 27909 jmvivo
            getPasswordField().setText(cwp.getPassword());
598 11971 caballero
        }
599
600
        getUrlTextArea().setText(cwp.getHost());
601
602 33662 cordinyana
        // boolean connected = false;
603
        //
604 21910 vcaballero
//        try {
605
//            connected = (cwp.getConnection() != null) &&
606
//                (!cwp.getConnection().isClosed());
607
//        }
608
//        catch (DBException e) {
609
//            logger.error("While checking connection: " + e.getMessage());
610
//            connected = false;
611
//        }
612 11971 caballero
613 21910 vcaballero
//        getConnectedCheckBox().setSelected(connected);
614 27723 jmvivo
                getConnNameTextField().setText(cwp.getExplorerName());
615 11971 caballero
    }
616
617
    private void selectThisInDriverCombo(String drvName) {
618
        int size = getDriverComboBox().getItemCount();
619 29199 jmvivo
        int curSel = getDriverComboBox().getSelectedIndex();
620 11971 caballero
621
        for (int i = 0; i < size; i++) {
622 22207 jmvivo
            DriverComboBoxItem item = (DriverComboBoxItem) getDriverComboBox()
623
                                        .getItemAt(i);
624 11971 caballero
625 27723 jmvivo
            if (item.params.getExplorerName().compareToIgnoreCase(drvName) == 0) {
626 11971 caballero
                getDriverComboBox().setSelectedIndex(i);
627 29199 jmvivo
                if (curSel != i) {
628
                                        this.params = null;
629
                                }
630 11971 caballero
631
                return;
632
            }
633
        }
634
    }
635 26449 jmvivo
636
        public Object getWindowProfile() {
637
                return WindowInfo.DIALOG_PROFILE;
638
        }
639
640 29199 jmvivo
        public DBServerExplorerParameters getParameters(){
641
                if (params == null) {
642
                        DriverComboBoxItem item = (DriverComboBoxItem) getDriverComboBox()
643
                                        .getItemAt(getDriverComboBox().getSelectedIndex());
644
                        params = (DBServerExplorerParameters) item.params.getCopy();
645
646
647 29241 jmvivo
                }
648
                String _host = getConnectionServerUrl();
649
                String _port = getConnectionPort();
650
                String _dbname = getConnectionDBName();
651
                String _user = getConnectionUser();
652
                String _pw = getConnectionPassword();
653 29199 jmvivo
654 29241 jmvivo
                params.setHost(_host);
655
                if (_port.trim().length() != 0) {
656
                        try {
657
                                params.setPort(Integer.parseInt(_port));
658
                        } catch (NumberFormatException e) {
659
                                NotificationManager.addError("Invalid port", e);
660
                        }
661 29199 jmvivo
                }
662 29241 jmvivo
                params.setDBName(_dbname);
663
                params.setUser(_user);
664
                params.setPassword(_pw);
665
666 29199 jmvivo
                return params;
667
        }
668
669 11971 caballero
} //  @jve:decl-index=0:visual-constraint="10,10"