svn-gvsig-desktop / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSOptionsPanel.java @ 17593
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 17593 2007-12-18 13:08:46Z jpiera $
|
64 |
* $Log$
|
65 |
* Revision 1.12 2007-02-22 12:25:39 ppiqueras
|
66 |
* A?adidas tool tip text y etiqueta para de milisegundos.
|
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 |
* @author Pablo Piqueras Bartolom?
|
109 |
*/
|
110 |
public class WFSOptionsPanel extends DefaultWFSDialogPanel{ |
111 |
|
112 |
private JPanel credentialsPanel = null; |
113 |
private JLabel usernameLabel = null; |
114 |
private JTextField usernameText = null; |
115 |
private JLabel passwordLabel = null; |
116 |
private JPasswordField passwordText = null; |
117 |
private JPanel connectionParamsPanel = null; |
118 |
private JLabel timeoutLabel = null; |
119 |
private JFormattedTextField bufferText = null; |
120 |
private JLabel bufferLabel = null; |
121 |
private JFormattedTextField timeOutText = null; |
122 |
private JPanel formatPanel = null; |
123 |
private JLabel srsLabel = null; |
124 |
private JTextField srsText = null; |
125 |
private JLabel jLabelMiliSeconds = null; |
126 |
|
127 |
public WFSOptionsPanel() {
|
128 |
super();
|
129 |
initialize(); |
130 |
} |
131 |
|
132 |
/**
|
133 |
* This method initializes usernameText
|
134 |
*
|
135 |
* @return javax.swing.JTextField
|
136 |
*/
|
137 |
private JTextField getUsernameText() { |
138 |
if (usernameText == null) { |
139 |
usernameText = new JTextField(); |
140 |
usernameText.setBounds(new java.awt.Rectangle(100,25,200,20)); |
141 |
usernameText.addKeyListener(new java.awt.event.KeyAdapter() {
|
142 |
public void keyTyped(java.awt.event.KeyEvent e) { |
143 |
getParamsPanelData().isApplicable(true);
|
144 |
} |
145 |
}); |
146 |
} |
147 |
return usernameText;
|
148 |
} |
149 |
|
150 |
/**
|
151 |
* This method initializes passwordText
|
152 |
*
|
153 |
* @return javax.swing.JTextField
|
154 |
*/
|
155 |
private JPasswordField getPasswordText() { |
156 |
if (passwordText == null) { |
157 |
passwordText = new JPasswordField(); |
158 |
passwordText.setBounds(new java.awt.Rectangle(100,50,200,20)); |
159 |
passwordText.addKeyListener(new java.awt.event.KeyAdapter() {
|
160 |
public void keyTyped(java.awt.event.KeyEvent e) { |
161 |
getParamsPanelData().isApplicable(true);
|
162 |
} |
163 |
}); |
164 |
} |
165 |
return passwordText;
|
166 |
} |
167 |
|
168 |
/**
|
169 |
* This method initializes jPanel
|
170 |
*
|
171 |
* @return javax.swing.JPanel
|
172 |
*/
|
173 |
private JPanel getConnectionParamsPanel() { |
174 |
if (connectionParamsPanel == null) { |
175 |
bufferLabel = new JLabel(); |
176 |
bufferLabel.setBounds(new Rectangle(10, 25, 85, 16)); |
177 |
bufferLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING); |
178 |
bufferLabel.setText(PluginServices.getText(this, "max_features")); |
179 |
bufferLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP); |
180 |
bufferLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
181 |
timeoutLabel = new JLabel(); |
182 |
timeoutLabel.setBounds(new Rectangle(10, 50, 85, 16)); |
183 |
timeoutLabel.setText(PluginServices.getText(this, "timeout")); |
184 |
timeoutLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
185 |
connectionParamsPanel = new JPanel(); |
186 |
connectionParamsPanel.setLayout(null);
|
187 |
connectionParamsPanel.setBounds(new java.awt.Rectangle(7,65,485,80)); |
188 |
connectionParamsPanel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "conection"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
189 |
connectionParamsPanel.add(timeoutLabel, null);
|
190 |
connectionParamsPanel.add(getBufferText(), null);
|
191 |
connectionParamsPanel.add(bufferLabel, null);
|
192 |
connectionParamsPanel.add(getTimeOutText(), null);
|
193 |
connectionParamsPanel.add(getJLabelMiliSeconds(), null);
|
194 |
} |
195 |
return connectionParamsPanel;
|
196 |
} |
197 |
|
198 |
/**
|
199 |
* This method initializes jTextField
|
200 |
*
|
201 |
* @return javax.swing.JTextField
|
202 |
*/
|
203 |
private JFormattedTextField getBufferText() { |
204 |
if (bufferText == null) { |
205 |
bufferText = new JFormattedTextField(NumberFormat.getIntegerInstance()); |
206 |
bufferText.setValue(new Integer(1000)); |
207 |
bufferText.setBounds(new Rectangle(100, 25, 70, 20)); |
208 |
bufferText.setToolTipText(PluginServices.getText(bufferText, "set_Max_Number_Of_Features_Will_Be_Loaded"));
|
209 |
bufferText.addKeyListener(new java.awt.event.KeyAdapter() {
|
210 |
public void keyTyped(java.awt.event.KeyEvent e) { |
211 |
getParamsPanelData().isApplicable(true);
|
212 |
} |
213 |
}); |
214 |
} |
215 |
return bufferText;
|
216 |
} |
217 |
|
218 |
/**
|
219 |
* This method initializes jTextField1
|
220 |
*
|
221 |
* @return javax.swing.JTextField
|
222 |
*/
|
223 |
private JFormattedTextField getTimeOutText() { |
224 |
if (timeOutText == null) { |
225 |
timeOutText = new JFormattedTextField(NumberFormat.getIntegerInstance()); |
226 |
timeOutText.setValue(new Integer(10000)); |
227 |
timeOutText.setBounds(new Rectangle(100, 50, 70, 20)); |
228 |
timeOutText.setToolTipText(PluginServices.getText(timeOutText, "set_TimeOut_Explanation"));
|
229 |
timeOutText.addKeyListener(new java.awt.event.KeyAdapter() {
|
230 |
public void keyTyped(java.awt.event.KeyEvent e) { |
231 |
getParamsPanelData().isApplicable(true);
|
232 |
} |
233 |
}); |
234 |
} |
235 |
return timeOutText;
|
236 |
} |
237 |
|
238 |
/**
|
239 |
/**
|
240 |
*
|
241 |
* @return the username
|
242 |
*/
|
243 |
public String getUserName(){ |
244 |
return getUsernameText().getText();
|
245 |
} |
246 |
|
247 |
/**
|
248 |
*
|
249 |
* @return the password
|
250 |
*/
|
251 |
public String getPassword(){ |
252 |
return getPasswordText().getText();
|
253 |
} |
254 |
|
255 |
/**
|
256 |
*
|
257 |
* @return the buffer
|
258 |
*/
|
259 |
public int getBuffer(){ |
260 |
try{
|
261 |
String buffer = StringUtilities.replace(getBufferText().getText(),".",""); |
262 |
buffer = StringUtilities.replace(buffer,",",""); |
263 |
return Integer.parseInt(buffer); |
264 |
}catch(NumberFormatException e){ |
265 |
return 10000; |
266 |
} |
267 |
} |
268 |
|
269 |
/**
|
270 |
*
|
271 |
* @return the timeout
|
272 |
*/
|
273 |
public int getTimeout(){ |
274 |
try{
|
275 |
String timeOut = StringUtilities.replace(getTimeOutText().getText(),".",""); |
276 |
timeOut = StringUtilities.replace(timeOut,",",""); |
277 |
return Integer.parseInt(timeOut); |
278 |
}catch(NumberFormatException e){ |
279 |
return 10000; |
280 |
} |
281 |
} |
282 |
|
283 |
/**
|
284 |
* Gets the SRS
|
285 |
* @return
|
286 |
*/
|
287 |
public String getSRS(){ |
288 |
return getSrsText().getText();
|
289 |
} |
290 |
|
291 |
/**
|
292 |
* This method initializes formatPanel
|
293 |
*
|
294 |
* @return javax.swing.JPanel
|
295 |
*/
|
296 |
private JPanel getFormatPanel() { |
297 |
if (formatPanel == null) { |
298 |
srsLabel = new JLabel(); |
299 |
srsLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING); |
300 |
srsLabel.setText(PluginServices.getText(this, "srs")); |
301 |
srsLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP); |
302 |
srsLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
303 |
srsLabel.setBounds(new java.awt.Rectangle(10, 25, 85, 16)); |
304 |
formatPanel = new JPanel(); |
305 |
formatPanel.setLayout(null);
|
306 |
formatPanel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "srs"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
307 |
formatPanel.setBounds(new java.awt.Rectangle(7,5,485,55)); |
308 |
formatPanel.add(srsLabel, null);
|
309 |
formatPanel.add(getSrsText(), null);
|
310 |
} |
311 |
return formatPanel;
|
312 |
} |
313 |
|
314 |
/**
|
315 |
* This method initializes srsText
|
316 |
*
|
317 |
* @return javax.swing.JTextField
|
318 |
*/
|
319 |
private JTextField getSrsText() { |
320 |
if (srsText == null) { |
321 |
srsText = new JTextField(); |
322 |
srsText.setBounds(new java.awt.Rectangle(100, 25, 70, 20)); |
323 |
srsText.setEnabled(false);
|
324 |
srsText.setEditable(false);
|
325 |
srsText.setToolTipText(PluginServices.getText(srsText, "select_Feature_Reference_System"));
|
326 |
} |
327 |
return srsText;
|
328 |
} |
329 |
|
330 |
/**
|
331 |
* Refresh the panel
|
332 |
* @param feature
|
333 |
*/
|
334 |
public void refresh(WFSLayerNode layer) { |
335 |
Vector srs = layer.getSrs();
|
336 |
if (srs.size() > 0){ |
337 |
getSrsText().setText((String)srs.get(0)); |
338 |
} |
339 |
} |
340 |
|
341 |
public void setStatus(WFSStatus status) { |
342 |
getBufferText().setText(String.valueOf(status.getBuffer()));
|
343 |
getTimeOutText().setText(String.valueOf(status.getTimeout()));
|
344 |
getUsernameText().setText(status.getUserName()); |
345 |
getPasswordText().setText(status.getPassword()); |
346 |
} |
347 |
|
348 |
public JLabel getJLabelMiliSeconds() { |
349 |
if (jLabelMiliSeconds == null) { |
350 |
jLabelMiliSeconds = new JLabel(); |
351 |
jLabelMiliSeconds.setText(PluginServices.getText(jLabelMiliSeconds, "miliSeconds"));
|
352 |
jLabelMiliSeconds.setBounds(new Rectangle(175, 50, 40, 16)); |
353 |
} |
354 |
|
355 |
return jLabelMiliSeconds;
|
356 |
} |
357 |
|
358 |
@Override
|
359 |
protected void initialize() { |
360 |
setLabel(PluginServices.getText(this, "options")); |
361 |
setLabelGroup(PluginServices.getText(this, "wfs")); |
362 |
this.setLayout(null); |
363 |
this.setBounds(10, 5, 481, 427); |
364 |
this.add(getConnectionParamsPanel(), null); |
365 |
this.add(getFormatPanel(), null); |
366 |
} |
367 |
} |