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