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