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