root / branches / v10 / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSOptionsPanel.java @ 9154
History | View | Annotate | Download (10.5 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 9154 2006-12-04 09:42:57Z ppiqueras $
|
64 |
* $Log$
|
65 |
* Revision 1.9.2.5 2006-12-04 09:42:57 ppiqueras
|
66 |
* 1 Bug corregido. (subo este fichero por si acaso he modificado algo en ?l para corregir el bug)
|
67 |
*
|
68 |
* Revision 1.11 2006/10/05 12:49:57 jorpiell
|
69 |
* Cambiada la cadena buffer por max_features
|
70 |
*
|
71 |
* Revision 1.10 2006/10/02 09:09:45 jorpiell
|
72 |
* Cambios del 10 copiados al head
|
73 |
*
|
74 |
* Revision 1.9.2.1 2006/09/26 07:36:24 jorpiell
|
75 |
* El WFS no reproyectaba porque no se le asignaba a la capa un sistema de referencia. Ahora ya se hace.
|
76 |
*
|
77 |
* Revision 1.9 2006/09/05 14:25:05 jorpiell
|
78 |
* Eliminado el nombre de usuario y la contrase?a del panel de opciones
|
79 |
*
|
80 |
* Revision 1.8 2006/07/21 11:50:31 jaume
|
81 |
* improved appearance
|
82 |
*
|
83 |
* Revision 1.7 2006/06/22 06:54:14 jorpiell
|
84 |
* Se ha desabilitado el cuadro de di?logo del sistema de referencia
|
85 |
*
|
86 |
* Revision 1.6 2006/06/21 12:35:45 jorpiell
|
87 |
* 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
|
88 |
*
|
89 |
* Revision 1.5 2006/06/15 07:50:58 jorpiell
|
90 |
* A?adida la funcionalidad de reproyectar y hechos algunos cambios en la interfaz
|
91 |
*
|
92 |
* Revision 1.4 2006/06/01 15:40:50 jorpiell
|
93 |
* 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 ".").
|
94 |
*
|
95 |
* Revision 1.3 2006/05/23 08:09:39 jorpiell
|
96 |
* 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
|
97 |
*
|
98 |
* Revision 1.2 2006/05/19 12:57:08 jorpiell
|
99 |
* Modificados algunos paneles
|
100 |
*
|
101 |
* Revision 1.1 2006/04/20 16:38:24 jorpiell
|
102 |
* 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().
|
103 |
*
|
104 |
*
|
105 |
*/
|
106 |
/**
|
107 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
108 |
*/
|
109 |
public class WFSOptionsPanel extends JPanel{ |
110 |
|
111 |
private JPanel credentialsPanel = null; |
112 |
private JLabel usernameLabel = null; |
113 |
private JTextField usernameText = null; |
114 |
private JLabel passwordLabel = null; |
115 |
private JPasswordField passwordText = null; |
116 |
private JPanel connectionParamsPanel = null; |
117 |
private JLabel timeoutLabel = null; |
118 |
private JFormattedTextField bufferText = null; |
119 |
private JLabel bufferLabel = null; |
120 |
private JFormattedTextField timeOutText = null; |
121 |
private JPanel formatPanel = null; |
122 |
private JLabel srsLabel = null; |
123 |
private JTextField srsText = null; |
124 |
private WFSParamsPanel parent = null; |
125 |
/**
|
126 |
* This method initializes
|
127 |
*
|
128 |
*/
|
129 |
public WFSOptionsPanel(WFSParamsPanel parent) {
|
130 |
super();
|
131 |
this.parent = parent;
|
132 |
initialize(); |
133 |
} |
134 |
|
135 |
/**
|
136 |
* This method initializes this
|
137 |
*
|
138 |
*/
|
139 |
private void initialize() { |
140 |
this.setLayout(null); |
141 |
this.setBounds(10, 5, 481, 427); |
142 |
this.add(getConnectionParamsPanel(), null); |
143 |
this.add(getFormatPanel(), null); |
144 |
|
145 |
} |
146 |
|
147 |
|
148 |
/**
|
149 |
* This method initializes usernameText
|
150 |
*
|
151 |
* @return javax.swing.JTextField
|
152 |
*/
|
153 |
private JTextField getUsernameText() { |
154 |
if (usernameText == null) { |
155 |
usernameText = new JTextField(); |
156 |
usernameText.setBounds(new java.awt.Rectangle(100,25,200,20)); |
157 |
usernameText.addKeyListener(new java.awt.event.KeyAdapter() {
|
158 |
public void keyTyped(java.awt.event.KeyEvent e) { |
159 |
parent.isApplicable(true);
|
160 |
} |
161 |
}); |
162 |
} |
163 |
return usernameText;
|
164 |
} |
165 |
|
166 |
/**
|
167 |
* This method initializes passwordText
|
168 |
*
|
169 |
* @return javax.swing.JTextField
|
170 |
*/
|
171 |
private JPasswordField getPasswordText() { |
172 |
if (passwordText == null) { |
173 |
passwordText = new JPasswordField(); |
174 |
passwordText.setBounds(new java.awt.Rectangle(100,50,200,20)); |
175 |
passwordText.addKeyListener(new java.awt.event.KeyAdapter() {
|
176 |
public void keyTyped(java.awt.event.KeyEvent e) { |
177 |
parent.isApplicable(true);
|
178 |
} |
179 |
}); |
180 |
} |
181 |
return passwordText;
|
182 |
} |
183 |
|
184 |
/**
|
185 |
* This method initializes jPanel
|
186 |
*
|
187 |
* @return javax.swing.JPanel
|
188 |
*/
|
189 |
private JPanel getConnectionParamsPanel() { |
190 |
if (connectionParamsPanel == null) { |
191 |
bufferLabel = new JLabel(); |
192 |
bufferLabel.setBounds(new Rectangle(10, 25, 85, 16)); |
193 |
bufferLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING); |
194 |
bufferLabel.setText(PluginServices.getText(this, "max_features")); |
195 |
bufferLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP); |
196 |
bufferLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
197 |
timeoutLabel = new JLabel(); |
198 |
timeoutLabel.setBounds(new Rectangle(10, 50, 85, 16)); |
199 |
timeoutLabel.setText(PluginServices.getText(this, "timeout")); |
200 |
timeoutLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
201 |
connectionParamsPanel = new JPanel(); |
202 |
connectionParamsPanel.setLayout(null);
|
203 |
connectionParamsPanel.setBounds(new java.awt.Rectangle(7,65,485,80)); |
204 |
connectionParamsPanel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "conection"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
205 |
connectionParamsPanel.add(timeoutLabel, null);
|
206 |
connectionParamsPanel.add(getBufferText(), null);
|
207 |
connectionParamsPanel.add(bufferLabel, null);
|
208 |
connectionParamsPanel.add(getTimeOutText(), null);
|
209 |
} |
210 |
return connectionParamsPanel;
|
211 |
} |
212 |
|
213 |
/**
|
214 |
* This method initializes jTextField
|
215 |
*
|
216 |
* @return javax.swing.JTextField
|
217 |
*/
|
218 |
private JFormattedTextField getBufferText() { |
219 |
if (bufferText == null) { |
220 |
bufferText = new JFormattedTextField(NumberFormat.getIntegerInstance()); |
221 |
bufferText.setValue(new Integer(1000)); |
222 |
bufferText.setBounds(new Rectangle(100, 25, 70, 20)); |
223 |
bufferText.addKeyListener(new java.awt.event.KeyAdapter() {
|
224 |
public void keyTyped(java.awt.event.KeyEvent e) { |
225 |
parent.isApplicable(true);
|
226 |
} |
227 |
}); |
228 |
} |
229 |
return bufferText;
|
230 |
} |
231 |
|
232 |
/**
|
233 |
* This method initializes jTextField1
|
234 |
*
|
235 |
* @return javax.swing.JTextField
|
236 |
*/
|
237 |
private JFormattedTextField getTimeOutText() { |
238 |
if (timeOutText == null) { |
239 |
timeOutText = new JFormattedTextField(NumberFormat.getIntegerInstance()); |
240 |
timeOutText.setValue(new Integer(10000)); |
241 |
timeOutText.setBounds(new Rectangle(100, 50, 70, 20)); |
242 |
timeOutText.addKeyListener(new java.awt.event.KeyAdapter() {
|
243 |
public void keyTyped(java.awt.event.KeyEvent e) { |
244 |
parent.isApplicable(true);
|
245 |
} |
246 |
}); |
247 |
} |
248 |
return timeOutText;
|
249 |
} |
250 |
|
251 |
/**
|
252 |
/**
|
253 |
*
|
254 |
* @return the username
|
255 |
*/
|
256 |
public String getUserName(){ |
257 |
return getUsernameText().getText();
|
258 |
} |
259 |
|
260 |
/**
|
261 |
*
|
262 |
* @return the password
|
263 |
*/
|
264 |
public String getPassword(){ |
265 |
return getPasswordText().getText();
|
266 |
} |
267 |
|
268 |
/**
|
269 |
*
|
270 |
* @return the buffer
|
271 |
*/
|
272 |
public int getBuffer(){ |
273 |
try{
|
274 |
String buffer = StringUtilities.replace(getBufferText().getText(),".",""); |
275 |
buffer = StringUtilities.replace(buffer,",",""); |
276 |
return Integer.parseInt(buffer); |
277 |
}catch(NumberFormatException e){ |
278 |
return 10000; |
279 |
} |
280 |
} |
281 |
|
282 |
/**
|
283 |
*
|
284 |
* @return the timeout
|
285 |
*/
|
286 |
public int getTimeout(){ |
287 |
try{
|
288 |
String timeOut = StringUtilities.replace(getTimeOutText().getText(),".",""); |
289 |
timeOut = StringUtilities.replace(timeOut,",",""); |
290 |
return Integer.parseInt(timeOut); |
291 |
}catch(NumberFormatException e){ |
292 |
return 10000; |
293 |
} |
294 |
} |
295 |
|
296 |
/**
|
297 |
* Gets the SRS
|
298 |
* @return
|
299 |
*/
|
300 |
public String getSRS(){ |
301 |
return getSrsText().getText();
|
302 |
} |
303 |
|
304 |
/**
|
305 |
* This method initializes formatPanel
|
306 |
*
|
307 |
* @return javax.swing.JPanel
|
308 |
*/
|
309 |
private JPanel getFormatPanel() { |
310 |
if (formatPanel == null) { |
311 |
srsLabel = new JLabel(); |
312 |
srsLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING); |
313 |
srsLabel.setText(PluginServices.getText(this, "srs")); |
314 |
srsLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP); |
315 |
srsLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
316 |
srsLabel.setBounds(new java.awt.Rectangle(10, 25, 85, 16)); |
317 |
formatPanel = new JPanel(); |
318 |
formatPanel.setLayout(null);
|
319 |
formatPanel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "srs"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
320 |
formatPanel.setBounds(new java.awt.Rectangle(7,5,485,55)); |
321 |
formatPanel.add(srsLabel, null);
|
322 |
formatPanel.add(getSrsText(), null);
|
323 |
} |
324 |
return formatPanel;
|
325 |
} |
326 |
|
327 |
/**
|
328 |
* This method initializes srsText
|
329 |
*
|
330 |
* @return javax.swing.JTextField
|
331 |
*/
|
332 |
private JTextField getSrsText() { |
333 |
if (srsText == null) { |
334 |
srsText = new JTextField(); |
335 |
srsText.setBounds(new java.awt.Rectangle(100, 25, 70, 20)); |
336 |
srsText.setEnabled(false);
|
337 |
srsText.setEditable(false);
|
338 |
} |
339 |
return srsText;
|
340 |
} |
341 |
|
342 |
/**
|
343 |
* Refresh the panel
|
344 |
* @param feature
|
345 |
*/
|
346 |
public void refresh(WFSLayerNode feature) { |
347 |
Vector srs = feature.getSrs();
|
348 |
if (srs.size() > 0){ |
349 |
getSrsText().setText((String)srs.get(0)); |
350 |
} |
351 |
} |
352 |
|
353 |
public void setStatus(WFSStatus status) { |
354 |
getBufferText().setText(String.valueOf(status.getBuffer()));
|
355 |
getTimeOutText().setText(String.valueOf(status.getTimeout()));
|
356 |
getUsernameText().setText(status.getUserName()); |
357 |
getPasswordText().setText(status.getPassword()); |
358 |
} |
359 |
} |