svn-gvsig-desktop / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSOptionsPanel.java @ 6501
History | View | Annotate | Download (11.2 KB)
1 |
package com.iver.cit.gvsig.gui.panels; |
---|---|
2 |
|
3 |
import java.awt.Rectangle; |
4 |
import java.text.NumberFormat; |
5 |
import java.util.Vector; |
6 |
|
7 |
import javax.swing.BorderFactory; |
8 |
import javax.swing.JFormattedTextField; |
9 |
import javax.swing.JLabel; |
10 |
import javax.swing.JPanel; |
11 |
import javax.swing.JPasswordField; |
12 |
import javax.swing.JTextField; |
13 |
import javax.swing.border.TitledBorder; |
14 |
|
15 |
import org.gvsig.remoteClient.wfs.WFSStatus; |
16 |
|
17 |
import com.iver.andami.PluginServices; |
18 |
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode; |
19 |
import com.iver.utiles.StringUtilities; |
20 |
|
21 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
22 |
*
|
23 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
24 |
*
|
25 |
* This program is free software; you can redistribute it and/or
|
26 |
* modify it under the terms of the GNU General Public License
|
27 |
* as published by the Free Software Foundation; either version 2
|
28 |
* of the License, or (at your option) any later version.
|
29 |
*
|
30 |
* This program is distributed in the hope that it will be useful,
|
31 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
32 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
33 |
* GNU General Public License for more details.
|
34 |
*
|
35 |
* You should have received a copy of the GNU General Public License
|
36 |
* along with this program; if not, write to the Free Software
|
37 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
38 |
*
|
39 |
* For more information, contact:
|
40 |
*
|
41 |
* Generalitat Valenciana
|
42 |
* Conselleria d'Infraestructures i Transport
|
43 |
* Av. Blasco Ib??ez, 50
|
44 |
* 46010 VALENCIA
|
45 |
* SPAIN
|
46 |
*
|
47 |
* +34 963862235
|
48 |
* gvsig@gva.es
|
49 |
* www.gvsig.gva.es
|
50 |
*
|
51 |
* or
|
52 |
*
|
53 |
* IVER T.I. S.A
|
54 |
* Salamanca 50
|
55 |
* 46005 Valencia
|
56 |
* Spain
|
57 |
*
|
58 |
* +34 963163400
|
59 |
* dac@iver.es
|
60 |
*/
|
61 |
/* CVS MESSAGES:
|
62 |
*
|
63 |
* $Id: WFSOptionsPanel.java 6501 2006-07-21 11:51:55Z jaume $
|
64 |
* $Log$
|
65 |
* Revision 1.8 2006-07-21 11:50:31 jaume
|
66 |
* improved appearance
|
67 |
*
|
68 |
* Revision 1.7 2006/06/22 06:54:14 jorpiell
|
69 |
* Se ha desabilitado el cuadro de di?logo del sistema de referencia
|
70 |
*
|
71 |
* Revision 1.6 2006/06/21 12:35:45 jorpiell
|
72 |
* Se ha a?adido la ventana de propiedades. Esto implica a?adir listeners por todos los paneles. Adem?s no se muestra la geomatr?a en la lista de atributos y se muestran ?nicamnete los que se van a descargar
|
73 |
*
|
74 |
* Revision 1.5 2006/06/15 07:50:58 jorpiell
|
75 |
* A?adida la funcionalidad de reproyectar y hechos algunos cambios en la interfaz
|
76 |
*
|
77 |
* Revision 1.4 2006/06/01 15:40:50 jorpiell
|
78 |
* Se ha capturado una excepci?n que saltaba al ejecutar la extensi?n en igl?s provocada por el signo "," que aparece en lo n?meros (en castellano ".").
|
79 |
*
|
80 |
* Revision 1.3 2006/05/23 08:09:39 jorpiell
|
81 |
* Se ha cambiado la forma en la que se leian los valores seleccionados en los paneles y se ha cambiado el comportamiento de los botones
|
82 |
*
|
83 |
* Revision 1.2 2006/05/19 12:57:08 jorpiell
|
84 |
* Modificados algunos paneles
|
85 |
*
|
86 |
* Revision 1.1 2006/04/20 16:38:24 jorpiell
|
87 |
* Ahora mismo ya se puede hacer un getCapabilities y un getDescribeType de la capa seleccionada para ver los atributos a dibujar. Queda implementar el panel de opciones y hacer el getFeature().
|
88 |
*
|
89 |
*
|
90 |
*/
|
91 |
/**
|
92 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
93 |
*/
|
94 |
public class WFSOptionsPanel extends JPanel{ |
95 |
|
96 |
private JPanel credentialsPanel = null; |
97 |
private JLabel usernameLabel = null; |
98 |
private JTextField usernameText = null; |
99 |
private JLabel passwordLabel = null; |
100 |
private JPasswordField passwordText = null; |
101 |
private JPanel connectionParamsPanel = null; |
102 |
private JLabel timeoutLabel = null; |
103 |
private JFormattedTextField bufferText = null; |
104 |
private JLabel bufferLabel = null; |
105 |
private JFormattedTextField timeOutText = null; |
106 |
private JPanel formatPanel = null; |
107 |
private JLabel srsLabel = null; |
108 |
private JTextField srsText = null; |
109 |
private WFSParamsPanel parent = null; |
110 |
/**
|
111 |
* This method initializes
|
112 |
*
|
113 |
*/
|
114 |
public WFSOptionsPanel(WFSParamsPanel parent) {
|
115 |
super();
|
116 |
this.parent = parent;
|
117 |
initialize(); |
118 |
} |
119 |
|
120 |
/**
|
121 |
* This method initializes this
|
122 |
*
|
123 |
*/
|
124 |
private void initialize() { |
125 |
this.setLayout(null); |
126 |
this.setBounds(10, 5, 481, 427); |
127 |
this.add(getCredentialsPanel(), null); |
128 |
this.add(getConnectionParamsPanel(), null); |
129 |
this.add(getFormatPanel(), null); |
130 |
|
131 |
} |
132 |
|
133 |
/**
|
134 |
* This method initializes credentialsPanel
|
135 |
*
|
136 |
* @return javax.swing.JPanel
|
137 |
*/
|
138 |
private JPanel getCredentialsPanel() { |
139 |
if (credentialsPanel == null) { |
140 |
passwordLabel = new JLabel(); |
141 |
passwordLabel.setBounds(new java.awt.Rectangle(10,25,85,16)); |
142 |
passwordLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
143 |
passwordLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING); |
144 |
passwordLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP); |
145 |
passwordLabel.setText(PluginServices.getText(this, "username")); |
146 |
usernameLabel = new JLabel(); |
147 |
usernameLabel.setBounds(new java.awt.Rectangle(10,50,85,16)); |
148 |
usernameLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
149 |
usernameLabel.setText(PluginServices.getText(this, "pwd")); |
150 |
credentialsPanel = new JPanel(); |
151 |
credentialsPanel.setLayout(null);
|
152 |
credentialsPanel.setBorder(javax.swing.BorderFactory.createTitledBorder( |
153 |
null, PluginServices.getText(this, "credentials"), |
154 |
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, |
155 |
javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null)); |
156 |
credentialsPanel.setBounds(new java.awt.Rectangle(7,65,485,80)); |
157 |
credentialsPanel.add(usernameLabel, null);
|
158 |
credentialsPanel.add(getUsernameText(), null);
|
159 |
credentialsPanel.add(passwordLabel, null);
|
160 |
credentialsPanel.add(getPasswordText(), null);
|
161 |
|
162 |
} |
163 |
return credentialsPanel;
|
164 |
} |
165 |
|
166 |
/**
|
167 |
* This method initializes usernameText
|
168 |
*
|
169 |
* @return javax.swing.JTextField
|
170 |
*/
|
171 |
private JTextField getUsernameText() { |
172 |
if (usernameText == null) { |
173 |
usernameText = new JTextField(); |
174 |
usernameText.setBounds(new java.awt.Rectangle(100,25,200,20)); |
175 |
usernameText.addKeyListener(new java.awt.event.KeyAdapter() {
|
176 |
public void keyTyped(java.awt.event.KeyEvent e) { |
177 |
parent.isApplicable(true);
|
178 |
} |
179 |
}); |
180 |
} |
181 |
return usernameText;
|
182 |
} |
183 |
|
184 |
/**
|
185 |
* This method initializes passwordText
|
186 |
*
|
187 |
* @return javax.swing.JTextField
|
188 |
*/
|
189 |
private JPasswordField getPasswordText() { |
190 |
if (passwordText == null) { |
191 |
passwordText = new JPasswordField(); |
192 |
passwordText.setBounds(new java.awt.Rectangle(100,50,200,20)); |
193 |
passwordText.addKeyListener(new java.awt.event.KeyAdapter() {
|
194 |
public void keyTyped(java.awt.event.KeyEvent e) { |
195 |
parent.isApplicable(true);
|
196 |
} |
197 |
}); |
198 |
} |
199 |
return passwordText;
|
200 |
} |
201 |
|
202 |
/**
|
203 |
* This method initializes jPanel
|
204 |
*
|
205 |
* @return javax.swing.JPanel
|
206 |
*/
|
207 |
private JPanel getConnectionParamsPanel() { |
208 |
if (connectionParamsPanel == null) { |
209 |
bufferLabel = new JLabel(); |
210 |
bufferLabel.setBounds(new Rectangle(10, 25, 85, 16)); |
211 |
bufferLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING); |
212 |
bufferLabel.setText(PluginServices.getText(this, "buffer")); |
213 |
bufferLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP); |
214 |
bufferLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
215 |
timeoutLabel = new JLabel(); |
216 |
timeoutLabel.setBounds(new Rectangle(10, 50, 85, 16)); |
217 |
timeoutLabel.setText(PluginServices.getText(this, "timeout")); |
218 |
timeoutLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
219 |
connectionParamsPanel = new JPanel(); |
220 |
connectionParamsPanel.setLayout(null);
|
221 |
connectionParamsPanel.setBounds(new java.awt.Rectangle(7,150,485,80)); |
222 |
connectionParamsPanel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "conection"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
223 |
connectionParamsPanel.add(timeoutLabel, null);
|
224 |
connectionParamsPanel.add(getBufferText(), null);
|
225 |
connectionParamsPanel.add(bufferLabel, null);
|
226 |
connectionParamsPanel.add(getTimeOutText(), null);
|
227 |
} |
228 |
return connectionParamsPanel;
|
229 |
} |
230 |
|
231 |
/**
|
232 |
* This method initializes jTextField
|
233 |
*
|
234 |
* @return javax.swing.JTextField
|
235 |
*/
|
236 |
private JFormattedTextField getBufferText() { |
237 |
if (bufferText == null) { |
238 |
bufferText = new JFormattedTextField(NumberFormat.getIntegerInstance()); |
239 |
bufferText.setValue(new Integer(1000)); |
240 |
bufferText.setBounds(new Rectangle(100, 25, 70, 20)); |
241 |
bufferText.addKeyListener(new java.awt.event.KeyAdapter() {
|
242 |
public void keyTyped(java.awt.event.KeyEvent e) { |
243 |
parent.isApplicable(true);
|
244 |
} |
245 |
}); |
246 |
} |
247 |
return bufferText;
|
248 |
} |
249 |
|
250 |
/**
|
251 |
* This method initializes jTextField1
|
252 |
*
|
253 |
* @return javax.swing.JTextField
|
254 |
*/
|
255 |
private JFormattedTextField getTimeOutText() { |
256 |
if (timeOutText == null) { |
257 |
timeOutText = new JFormattedTextField(NumberFormat.getIntegerInstance()); |
258 |
timeOutText.setValue(new Integer(10000)); |
259 |
timeOutText.setBounds(new Rectangle(100, 50, 70, 20)); |
260 |
timeOutText.addKeyListener(new java.awt.event.KeyAdapter() {
|
261 |
public void keyTyped(java.awt.event.KeyEvent e) { |
262 |
parent.isApplicable(true);
|
263 |
} |
264 |
}); |
265 |
} |
266 |
return timeOutText;
|
267 |
} |
268 |
|
269 |
/**
|
270 |
/**
|
271 |
*
|
272 |
* @return the username
|
273 |
*/
|
274 |
public String getUserName(){ |
275 |
return getUsernameText().getText();
|
276 |
} |
277 |
|
278 |
/**
|
279 |
*
|
280 |
* @return the password
|
281 |
*/
|
282 |
public String getPassword(){ |
283 |
return getPasswordText().getText();
|
284 |
} |
285 |
|
286 |
/**
|
287 |
*
|
288 |
* @return the buffer
|
289 |
*/
|
290 |
public int getBuffer(){ |
291 |
try{
|
292 |
String buffer = StringUtilities.replace(getBufferText().getText(),".",""); |
293 |
buffer = StringUtilities.replace(buffer,",",""); |
294 |
return Integer.parseInt(buffer); |
295 |
}catch(NumberFormatException e){ |
296 |
return 10000; |
297 |
} |
298 |
} |
299 |
|
300 |
/**
|
301 |
*
|
302 |
* @return the timeout
|
303 |
*/
|
304 |
public int getTimeout(){ |
305 |
try{
|
306 |
String timeOut = StringUtilities.replace(getTimeOutText().getText(),".",""); |
307 |
timeOut = StringUtilities.replace(timeOut,",",""); |
308 |
return Integer.parseInt(timeOut); |
309 |
}catch(NumberFormatException e){ |
310 |
return 10000; |
311 |
} |
312 |
} |
313 |
|
314 |
/**
|
315 |
* This method initializes formatPanel
|
316 |
*
|
317 |
* @return javax.swing.JPanel
|
318 |
*/
|
319 |
private JPanel getFormatPanel() { |
320 |
if (formatPanel == null) { |
321 |
srsLabel = new JLabel(); |
322 |
srsLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING); |
323 |
srsLabel.setText(PluginServices.getText(this, "srs")); |
324 |
srsLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP); |
325 |
srsLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
326 |
srsLabel.setBounds(new java.awt.Rectangle(10, 25, 85, 16)); |
327 |
formatPanel = new JPanel(); |
328 |
formatPanel.setLayout(null);
|
329 |
formatPanel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "srs"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
330 |
formatPanel.setBounds(new java.awt.Rectangle(7,5,485,55)); |
331 |
formatPanel.add(srsLabel, null);
|
332 |
formatPanel.add(getSrsText(), null);
|
333 |
} |
334 |
return formatPanel;
|
335 |
} |
336 |
|
337 |
/**
|
338 |
* This method initializes srsText
|
339 |
*
|
340 |
* @return javax.swing.JTextField
|
341 |
*/
|
342 |
private JTextField getSrsText() { |
343 |
if (srsText == null) { |
344 |
srsText = new JTextField(); |
345 |
srsText.setBounds(new java.awt.Rectangle(100, 25, 70, 20)); |
346 |
srsText.setEnabled(false);
|
347 |
srsText.setEditable(false);
|
348 |
} |
349 |
return srsText;
|
350 |
} |
351 |
|
352 |
/**
|
353 |
* Refresh the panel
|
354 |
* @param feature
|
355 |
*/
|
356 |
public void refresh(WFSLayerNode feature) { |
357 |
Vector srs = feature.getSrs();
|
358 |
if (srs.size() > 0){ |
359 |
getSrsText().setText((String)srs.get(0)); |
360 |
} |
361 |
} |
362 |
|
363 |
public void setStatus(WFSStatus status) { |
364 |
getBufferText().setText(String.valueOf(status.getBuffer()));
|
365 |
getTimeOutText().setText(String.valueOf(status.getTimeout()));
|
366 |
getUsernameText().setText(status.getUserName()); |
367 |
getPasswordText().setText(status.getPassword()); |
368 |
} |
369 |
} |