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