Statistics
| Revision:

root / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / gui / DataBaseOpenDialog.java @ 6877

History | View | Annotate | Download (7.12 KB)

1 1103 fjp
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. 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
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41 428 fernando
package com.iver.cit.gvsig.gui;
42
43
import javax.swing.DefaultComboBoxModel;
44
import javax.swing.JComboBox;
45
import javax.swing.JLabel;
46
import javax.swing.JPanel;
47
import javax.swing.JPasswordField;
48
import javax.swing.JTextField;
49
50
import com.hardcode.driverManager.DriverLoadException;
51 6229 jmvivo
import com.iver.andami.PluginServices;
52 596 fernando
import com.iver.andami.messages.NotificationManager;
53 428 fernando
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
54
/**
55
 * DOCUMENT ME!
56
 *
57
 * @author Fernando Gonz?lez Cort?s
58
 */
59 432 fernando
public class DataBaseOpenDialog extends JPanel{
60 428 fernando
    private JLabel jLabel = null;
61
    private JTextField txtHost = null;
62
    private JLabel jLabel1 = null;
63
    private JTextField txtUser = null;
64
    private JComboBox cmbDriver = null;
65
    private JLabel jLabel2 = null;
66
67
        private JLabel jLabel3 = null;
68
        private JTextField txtTable = null;
69
        private JLabel jLabel4 = null;
70
        private JTextField txtPort = null;
71
        private JLabel jLabel5 = null;
72
        private JPasswordField txtPassword = null;
73
        private JLabel jLabel6 = null;
74
        private JTextField txtDB = null;
75
    /**
76
     * This is the default constructor
77
     */
78
    public DataBaseOpenDialog() {
79
        super();
80
        initialize();
81
    }
82
83
    /**
84
     * This method initializes this
85
     */
86
    private void initialize() {
87
        jLabel6 = new JLabel();
88
        jLabel5 = new JLabel();
89
        jLabel4 = new JLabel();
90
        jLabel3 = new JLabel();
91
        jLabel2 = new JLabel();
92
        jLabel1 = new JLabel();
93
        jLabel = new JLabel();
94
        this.setLayout(null);
95 437 fernando
        this.setSize(348, 243);
96 6229 jmvivo
        jLabel.setBounds(5, 12, 99, 23);
97
        jLabel.setText(PluginServices.getText(this,"Servidor")+":");
98
        jLabel1.setBounds(5, 140, 99, 23);
99
        jLabel1.setText(PluginServices.getText(this,"usuario")+":");
100
        jLabel2.setBounds(5, 204, 99, 23);
101
        jLabel2.setText(PluginServices.getText(this,"driver")+":");
102
        jLabel3.setBounds(5, 108, 99, 23);
103
        jLabel3.setText(PluginServices.getText(this,"Tabla")+":");
104
        jLabel4.setBounds(5, 44, 99, 23);
105
        jLabel4.setText(PluginServices.getText(this,"puerto")+":");
106
        jLabel5.setBounds(5, 172, 99, 23);
107
        jLabel5.setText(PluginServices.getText(this,"clave")+":");
108
        jLabel6.setBounds(5, 76, 99, 23);
109
        jLabel6.setText(PluginServices.getText(this,"base_datos")+":");
110 428 fernando
        this.add(jLabel, null);
111
        this.add(getTxtHost(), null);
112
        this.add(jLabel1, null);
113
        this.add(getTxtUser(), null);
114
        this.add(getCmbDriver(), null);
115
        this.add(jLabel2, null);
116
        this.add(jLabel3, null);
117
        this.add(getTxtTable(), null);
118
        this.add(jLabel4, null);
119
        this.add(getTxtPort(), null);
120
        this.add(jLabel5, null);
121
        this.add(getTxtPassword(), null);
122
        this.add(jLabel6, null);
123
        this.add(getTxtDB(), null);
124
    }
125
126
    /**
127
     * This method initializes txtHost
128
     *
129
     * @return javax.swing.JTextField
130
     */
131
    private JTextField getTxtHost() {
132
        if (txtHost == null) {
133
            txtHost = new JTextField();
134 6233 jmvivo
            txtHost.setBounds(118, 12, 200, 23);
135 428 fernando
        }
136
137
        return txtHost;
138
    }
139
140
    /**
141
     * This method initializes txtUser
142
     *
143
     * @return javax.swing.JTextField
144
     */
145
    private JTextField getTxtUser() {
146
        if (txtUser == null) {
147
            txtUser = new JTextField();
148 6233 jmvivo
            txtUser.setBounds(118, 140, 130, 23);
149 428 fernando
        }
150
151
        return txtUser;
152
    }
153
154
    /**
155
     * This method initializes cmbDriver
156
     *
157
     * @return javax.swing.JComboBox
158
     */
159
    private JComboBox getCmbDriver() {
160
        if (cmbDriver == null) {
161
            cmbDriver = new JComboBox();
162 6233 jmvivo
            cmbDriver.setBounds(118, 204, 200, 23);
163 428 fernando
        }
164
165
        return cmbDriver;
166
    }
167
168
    /**
169 1171 fjp
     * @see com.iver.cit.gvsig.gui.OpenLayerPanel#getDriverNames()
170 428 fernando
     */
171
    public String getDriverName() {
172
        return cmbDriver.getSelectedItem().toString();
173
    }
174
175 644 fernando
    public void setClasses(Class[] classes){
176
                DefaultComboBoxModel model = new DefaultComboBoxModel();
177
                        String[] driverNames = LayerFactory.getDM().getDriverNames();
178
                        for (int i = 0; i < driverNames.length; i++) {
179
                                boolean is = false;
180
                                for (int j = 0; j < classes.length; j++) {
181
                                        if (LayerFactory.getDM().isA(driverNames[i], classes[j])){
182
                                                model.addElement(driverNames[i]);
183
                                        }
184 428 fernando
                                }
185
                        }
186 644 fernando
                        cmbDriver.setModel(model);
187 428 fernando
    }
188
189
    public String getHost(){
190
            return txtHost.getText();
191
    }
192
193
    public String getUser(){
194
            return txtUser.getText();
195
    }
196
197
    public String getPassword(){
198
            char[] buffer = txtPassword.getPassword();
199
200
            String str = new String(buffer);
201
202
            for (int i = 0; i < buffer.length; i++) {
203
                    buffer[i] = '\0';
204
            }
205
206
            return str;
207
    }
208
209
    public String getTable(){
210
            return txtTable.getText();
211
    }
212
213
    public String getDataBase(){
214
            return txtDB.getText();
215
    }
216
217
    public String getPort(){
218
            return txtPort.getText();
219
    }
220
221
    /**
222
         * This method initializes txtTable
223
         *
224
         * @return javax.swing.JTextField
225
         */
226
        private JTextField getTxtTable() {
227
                if (txtTable == null) {
228
                        txtTable = new JTextField();
229 6233 jmvivo
                        txtTable.setBounds(118, 108, 200, 23);
230 428 fernando
                }
231
                return txtTable;
232
        }
233
        /**
234
         * This method initializes txtPort
235
         *
236
         * @return javax.swing.JTextField
237
         */
238
        private JTextField getTxtPort() {
239
                if (txtPort == null) {
240
                        txtPort = new JTextField();
241 6233 jmvivo
                        txtPort.setBounds(118, 44, 46, 23);
242 428 fernando
                }
243
                return txtPort;
244
        }
245
        /**
246
         * This method initializes txtPassword
247
         *
248
         * @return javax.swing.JPasswordField
249
         */
250
        private JPasswordField getTxtPassword() {
251
                if (txtPassword == null) {
252
                        txtPassword = new JPasswordField();
253 6233 jmvivo
                        txtPassword.setBounds(118, 172, 130, 23);
254 428 fernando
                }
255
                return txtPassword;
256
        }
257
        /**
258
         * This method initializes txtDB
259
         *
260
         * @return javax.swing.JTextField
261
         */
262
        private JTextField getTxtDB() {
263
                if (txtDB == null) {
264
                        txtDB = new JTextField();
265 6233 jmvivo
                        txtDB.setBounds(118, 76, 200, 23);
266 428 fernando
                }
267
                return txtDB;
268
        }
269 437 fernando
} //  @jve:decl-index=0:visual-constraint="10,10"