Statistics
| Revision:

root / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / table / gui / DataBaseOpenDialog.java @ 22477

History | View | Annotate | Download (7.21 KB)

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