svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extWFS2 / src / org / gvsig / wfs / gui / panels / WFSOptionsPanel.java @ 34026
History | View | Annotate | Download (15.4 KB)
1 |
package org.gvsig.wfs.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.JCheckBox; |
9 |
import javax.swing.JFormattedTextField; |
10 |
import javax.swing.JLabel; |
11 |
import javax.swing.JPanel; |
12 |
import javax.swing.JPasswordField; |
13 |
import javax.swing.JTextField; |
14 |
import javax.swing.border.TitledBorder; |
15 |
|
16 |
import org.gvsig.andami.PluginServices; |
17 |
import org.gvsig.gui.beans.panelGroup.IPanelGroup; |
18 |
import org.gvsig.remoteclient.wfs.WFSStatus; |
19 |
import org.gvsig.utils.StringUtilities; |
20 |
import org.gvsig.wfs.gui.panels.model.WFSSelectedFeature; |
21 |
|
22 |
|
23 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
24 |
*
|
25 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
26 |
*
|
27 |
* This program is free software; you can redistribute it and/or
|
28 |
* modify it under the terms of the GNU General Public License
|
29 |
* as published by the Free Software Foundation; either version 2
|
30 |
* of the License, or (at your option) any later version.
|
31 |
*
|
32 |
* This program is distributed in the hope that it will be useful,
|
33 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
34 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
35 |
* GNU General Public License for more details.
|
36 |
*
|
37 |
* You should have received a copy of the GNU General Public License
|
38 |
* along with this program; if not, write to the Free Software
|
39 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
40 |
*
|
41 |
* For more information, contact:
|
42 |
*
|
43 |
* Generalitat Valenciana
|
44 |
* Conselleria d'Infraestructures i Transport
|
45 |
* Av. Blasco Ib??ez, 50
|
46 |
* 46010 VALENCIA
|
47 |
* SPAIN
|
48 |
*
|
49 |
* +34 963862235
|
50 |
* gvsig@gva.es
|
51 |
* www.gvsig.gva.es
|
52 |
*
|
53 |
* or
|
54 |
*
|
55 |
* IVER T.I. S.A
|
56 |
* Salamanca 50
|
57 |
* 46005 Valencia
|
58 |
* Spain
|
59 |
*
|
60 |
* +34 963163400
|
61 |
* dac@iver.es
|
62 |
*/
|
63 |
/* CVS MESSAGES:
|
64 |
*
|
65 |
* $Id: WFSOptionsPanel.java 17736 2008-01-02 16:53:48Z ppiqueras $
|
66 |
* $Log$
|
67 |
* Revision 1.12 2007-02-22 12:25:39 ppiqueras
|
68 |
* A?adidas tool tip text y etiqueta para de milisegundos.
|
69 |
*
|
70 |
* Revision 1.11 2006/10/05 12:49:57 jorpiell
|
71 |
* Cambiada la cadena buffer por max_features
|
72 |
*
|
73 |
* Revision 1.10 2006/10/02 09:09:45 jorpiell
|
74 |
* Cambios del 10 copiados al head
|
75 |
*
|
76 |
* Revision 1.9.2.1 2006/09/26 07:36:24 jorpiell
|
77 |
* El WFS no reproyectaba porque no se le asignaba a la capa un sistema de referencia. Ahora ya se hace.
|
78 |
*
|
79 |
* Revision 1.9 2006/09/05 14:25:05 jorpiell
|
80 |
* Eliminado el nombre de usuario y la contrase?a del panel de opciones
|
81 |
*
|
82 |
* Revision 1.8 2006/07/21 11:50:31 jaume
|
83 |
* improved appearance
|
84 |
*
|
85 |
* Revision 1.7 2006/06/22 06:54:14 jorpiell
|
86 |
* Se ha desabilitado el cuadro de di?logo del sistema de referencia
|
87 |
*
|
88 |
* Revision 1.6 2006/06/21 12:35:45 jorpiell
|
89 |
* 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
|
90 |
*
|
91 |
* Revision 1.5 2006/06/15 07:50:58 jorpiell
|
92 |
* A?adida la funcionalidad de reproyectar y hechos algunos cambios en la interfaz
|
93 |
*
|
94 |
* Revision 1.4 2006/06/01 15:40:50 jorpiell
|
95 |
* 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 ".").
|
96 |
*
|
97 |
* Revision 1.3 2006/05/23 08:09:39 jorpiell
|
98 |
* 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
|
99 |
*
|
100 |
* Revision 1.2 2006/05/19 12:57:08 jorpiell
|
101 |
* Modificados algunos paneles
|
102 |
*
|
103 |
* Revision 1.1 2006/04/20 16:38:24 jorpiell
|
104 |
* 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().
|
105 |
*
|
106 |
*
|
107 |
*/
|
108 |
|
109 |
/**
|
110 |
* <p>Panel with options about the timeout, maximum number of features, the projection reference system, and
|
111 |
* if it's implemented, user and password.</p>
|
112 |
*
|
113 |
* @author Jorge Piera Llodr? (piera_jor@gva.es)
|
114 |
* @author Pablo Piqueras Bartolom?
|
115 |
*/
|
116 |
public class WFSOptionsPanel extends AbstractWFSPanel { |
117 |
private static final long serialVersionUID = -769956995699452173L; |
118 |
|
119 |
private JPanel credentialsPanel = null; |
120 |
private JLabel usernameLabel = null; |
121 |
private JTextField usernameText = null; |
122 |
private JLabel passwordLabel = null; |
123 |
private JPasswordField passwordText = null; |
124 |
private JPanel connectionParamsPanel = null; |
125 |
private JLabel timeoutLabel = null; |
126 |
private JFormattedTextField bufferText = null; |
127 |
private JLabel bufferLabel = null; |
128 |
private JFormattedTextField timeOutText = null; |
129 |
private JPanel formatPanel = null; |
130 |
private JLabel srsLabel = null; |
131 |
private JTextField srsText = null; |
132 |
private JLabel jLabelMiliSeconds = null; |
133 |
private JPanel bufferPanel = null; |
134 |
private JPanel timeOutPanel = null; |
135 |
private JPanel northPanel = null; |
136 |
//Cache panel
|
137 |
private JPanel cachePanel = null; |
138 |
private JCheckBox enableCacheCheckBox = null; |
139 |
|
140 |
/**
|
141 |
* Creates a new WFS options panel.
|
142 |
*/
|
143 |
public WFSOptionsPanel() {
|
144 |
super();
|
145 |
initialize(); |
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 |
IPanelGroup panelGroup = getPanelGroup(); |
160 |
|
161 |
if (panelGroup == null) |
162 |
return;
|
163 |
|
164 |
((WFSParamsPanel)panelGroup).setApplicable(true);
|
165 |
} |
166 |
}); |
167 |
} |
168 |
return usernameText;
|
169 |
} |
170 |
|
171 |
/**
|
172 |
* This method initializes passwordText
|
173 |
*
|
174 |
* @return javax.swing.JTextField
|
175 |
*/
|
176 |
private JPasswordField getPasswordText() { |
177 |
if (passwordText == null) { |
178 |
passwordText = new JPasswordField(); |
179 |
passwordText.setBounds(new java.awt.Rectangle(100,50,200,20)); |
180 |
passwordText.addKeyListener(new java.awt.event.KeyAdapter() {
|
181 |
public void keyTyped(java.awt.event.KeyEvent e) { |
182 |
IPanelGroup panelGroup = getPanelGroup(); |
183 |
|
184 |
if (panelGroup == null) |
185 |
return;
|
186 |
|
187 |
((WFSParamsPanel)panelGroup).setApplicable(true);
|
188 |
} |
189 |
}); |
190 |
} |
191 |
return passwordText;
|
192 |
} |
193 |
|
194 |
/**
|
195 |
* This method initializes jPanel
|
196 |
*
|
197 |
* @return javax.swing.JPanel
|
198 |
*/
|
199 |
private JPanel getConnectionParamsPanel() { |
200 |
if (connectionParamsPanel == null) { |
201 |
java.awt.GridBagConstraints gridBagConstraints; |
202 |
|
203 |
bufferPanel = new JPanel(); |
204 |
bufferLabel = new JLabel(); |
205 |
bufferLabel.setText(PluginServices.getText(this, "max_features")); |
206 |
bufferPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
|
207 |
bufferPanel.add(bufferLabel); |
208 |
bufferPanel.add(getBufferText()); |
209 |
|
210 |
timeOutPanel = new JPanel(); |
211 |
timeoutLabel = new JLabel(); |
212 |
timeoutLabel.setText(PluginServices.getText(this, "timeout")); |
213 |
timeOutPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
|
214 |
timeOutPanel.add(timeoutLabel); |
215 |
timeOutPanel.add(getTimeOutText()); |
216 |
timeOutPanel.add(getJLabelMiliSeconds()); |
217 |
|
218 |
connectionParamsPanel = new JPanel(); |
219 |
connectionParamsPanel.setLayout(new java.awt.GridBagLayout());
|
220 |
connectionParamsPanel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "conection"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
221 |
|
222 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
223 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
224 |
gridBagConstraints.weightx = 1.0;
|
225 |
connectionParamsPanel.add(bufferPanel, gridBagConstraints); |
226 |
|
227 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
228 |
gridBagConstraints.gridx = 0;
|
229 |
gridBagConstraints.gridy = 1;
|
230 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
231 |
gridBagConstraints.weightx = 1.0;
|
232 |
connectionParamsPanel.add(timeOutPanel, gridBagConstraints); |
233 |
} |
234 |
|
235 |
return connectionParamsPanel;
|
236 |
} |
237 |
|
238 |
/**
|
239 |
* This method initializes jTextField
|
240 |
*
|
241 |
* @return javax.swing.JTextField
|
242 |
*/
|
243 |
private JFormattedTextField getBufferText() { |
244 |
if (bufferText == null) { |
245 |
bufferText = new JFormattedTextField(NumberFormat.getIntegerInstance()); |
246 |
bufferText.setValue(new Integer(1000)); |
247 |
bufferText.setBounds(new Rectangle(100, 25, 70, 20)); |
248 |
bufferText.setToolTipText(PluginServices.getText(bufferText, "set_Max_Number_Of_Features_Will_Be_Loaded"));
|
249 |
bufferText.addKeyListener(new java.awt.event.KeyAdapter() {
|
250 |
public void keyTyped(java.awt.event.KeyEvent e) { |
251 |
IPanelGroup panelGroup = getPanelGroup(); |
252 |
|
253 |
if (panelGroup == null) |
254 |
return;
|
255 |
|
256 |
((WFSParamsPanel)panelGroup).setApplicable(true);
|
257 |
} |
258 |
}); |
259 |
} |
260 |
|
261 |
return bufferText;
|
262 |
} |
263 |
|
264 |
/**
|
265 |
* This method initializes jTextField1
|
266 |
*
|
267 |
* @return javax.swing.JTextField
|
268 |
*/
|
269 |
private JFormattedTextField getTimeOutText() { |
270 |
if (timeOutText == null) { |
271 |
timeOutText = new JFormattedTextField(NumberFormat.getIntegerInstance()); |
272 |
timeOutText.setValue(new Integer(10000)); |
273 |
timeOutText.setBounds(new Rectangle(100, 50, 70, 20)); |
274 |
timeOutText.setToolTipText(PluginServices.getText(timeOutText, "set_TimeOut_Explanation"));
|
275 |
timeOutText.addKeyListener(new java.awt.event.KeyAdapter() {
|
276 |
public void keyTyped(java.awt.event.KeyEvent e) { |
277 |
IPanelGroup panelGroup = getPanelGroup(); |
278 |
|
279 |
if (panelGroup == null) |
280 |
return;
|
281 |
|
282 |
((WFSParamsPanel)panelGroup).setApplicable(true);
|
283 |
} |
284 |
}); |
285 |
} |
286 |
|
287 |
return timeOutText;
|
288 |
} |
289 |
|
290 |
/**
|
291 |
* Gets the name of the user.
|
292 |
*
|
293 |
* @return name of the user
|
294 |
*/
|
295 |
public String getUserName(){ |
296 |
return getUsernameText().getText();
|
297 |
} |
298 |
|
299 |
/**
|
300 |
* Gets the password of the user.
|
301 |
*
|
302 |
* @return password of the user
|
303 |
*/
|
304 |
public String getPassword(){ |
305 |
return getPasswordText().getText();
|
306 |
} |
307 |
|
308 |
/**
|
309 |
* Gets the maximum number of values that can load.
|
310 |
*
|
311 |
* @return the maximum number of values that can load
|
312 |
*/
|
313 |
public int getBuffer(){ |
314 |
try {
|
315 |
String buffer = StringUtilities.replace(getBufferText().getText(),".",""); |
316 |
buffer = StringUtilities.replace(buffer,",",""); |
317 |
return Integer.parseInt(buffer); |
318 |
} catch (NumberFormatException e) { |
319 |
return 10000; |
320 |
} |
321 |
} |
322 |
|
323 |
/**
|
324 |
* Gets the timeout used during the loading process.
|
325 |
*
|
326 |
* @return the timeout used during the loading process
|
327 |
*/
|
328 |
public int getTimeout(){ |
329 |
try {
|
330 |
String timeOut = StringUtilities.replace(getTimeOutText().getText(),".",""); |
331 |
timeOut = StringUtilities.replace(timeOut,",",""); |
332 |
return Integer.parseInt(timeOut); |
333 |
} catch (NumberFormatException e) { |
334 |
return 10000; |
335 |
} |
336 |
} |
337 |
|
338 |
/**
|
339 |
* Gets the reference system of the layer.
|
340 |
*
|
341 |
* @return the reference system of the layer
|
342 |
*/
|
343 |
public String getSRS(){ |
344 |
return getSrsText().getText();
|
345 |
} |
346 |
|
347 |
/**
|
348 |
* This method initializes formatPanel
|
349 |
*
|
350 |
* @return javax.swing.JPanel
|
351 |
*/
|
352 |
private JPanel getFormatPanel() { |
353 |
if (formatPanel == null) { |
354 |
formatPanel = new JPanel(); |
355 |
formatPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
|
356 |
formatPanel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "srs"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
357 |
formatPanel.add(getSRSLabel()); |
358 |
formatPanel.add(getSrsText()); |
359 |
} |
360 |
return formatPanel;
|
361 |
} |
362 |
|
363 |
/**
|
364 |
* This method initializes srsLabel
|
365 |
*
|
366 |
* @return javax.swing.JLabel
|
367 |
*/
|
368 |
private JLabel getSRSLabel() { |
369 |
if (srsLabel == null) { |
370 |
srsLabel = new JLabel(); |
371 |
srsLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING); |
372 |
srsLabel.setText(PluginServices.getText(this, "srs")); |
373 |
srsLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP); |
374 |
srsLabel.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); |
375 |
srsLabel.setBounds(new java.awt.Rectangle(10, 25, 85, 16)); |
376 |
} |
377 |
|
378 |
return srsLabel;
|
379 |
} |
380 |
|
381 |
/**
|
382 |
* This method initializes srsText
|
383 |
*
|
384 |
* @return javax.swing.JTextField
|
385 |
*/
|
386 |
private JTextField getSrsText() { |
387 |
if (srsText == null) { |
388 |
srsText = new JTextField(); |
389 |
srsText.setBounds(new java.awt.Rectangle(98, 25, 100, 20)); |
390 |
srsText.setEnabled(false);
|
391 |
srsText.setEditable(false);
|
392 |
srsText.setToolTipText(PluginServices.getText(srsText, "select_Feature_Reference_System"));
|
393 |
} |
394 |
return srsText;
|
395 |
} |
396 |
|
397 |
/**
|
398 |
* Refresh the panel
|
399 |
*
|
400 |
* @param feature
|
401 |
*/
|
402 |
public void refresh(WFSSelectedFeature layer) { |
403 |
Vector srs = layer.getSrs();
|
404 |
|
405 |
if (srs.size() > 0) { |
406 |
getSrsText().setText((String)srs.get(0)); |
407 |
} |
408 |
} |
409 |
|
410 |
/**
|
411 |
* Updates the status of this panel.
|
412 |
*
|
413 |
* @param status status of the WFS graphical interface.
|
414 |
*/
|
415 |
public void setStatus(WFSStatus status) { |
416 |
getBufferText().setText(String.valueOf(status.getMaxFeatures()));
|
417 |
getTimeOutText().setText(String.valueOf(status.getTimeout()));
|
418 |
getUsernameText().setText(status.getUserName()); |
419 |
getPasswordText().setText(status.getPassword()); |
420 |
} |
421 |
|
422 |
/**
|
423 |
* This method initializes jLabelMiliSeconds
|
424 |
*
|
425 |
* @return javax.swing.JLabel
|
426 |
*/
|
427 |
public JLabel getJLabelMiliSeconds() { |
428 |
if (jLabelMiliSeconds == null) { |
429 |
jLabelMiliSeconds = new JLabel(); |
430 |
jLabelMiliSeconds.setText(PluginServices.getText(jLabelMiliSeconds, "miliSeconds"));
|
431 |
jLabelMiliSeconds.setBounds(new Rectangle(175, 50, 40, 16)); |
432 |
} |
433 |
|
434 |
return jLabelMiliSeconds;
|
435 |
} |
436 |
|
437 |
private JPanel getCachePanel() { |
438 |
if (cachePanel == null) { |
439 |
cachePanel = new JPanel(); |
440 |
cachePanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
|
441 |
cachePanel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "vectorial_cache"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
442 |
cachePanel.add(getEnableCacheCheckBox()); |
443 |
} |
444 |
return formatPanel;
|
445 |
} |
446 |
|
447 |
public JLabel getEnableCacheCheckBox() { |
448 |
if (enableCacheCheckBox == null) { |
449 |
enableCacheCheckBox = new JCheckBox(); |
450 |
enableCacheCheckBox.setText(PluginServices.getText(null, "enable_cache")); |
451 |
enableCacheCheckBox.setBounds(new Rectangle(175, 50, 40, 16)); |
452 |
} |
453 |
|
454 |
return jLabelMiliSeconds;
|
455 |
} |
456 |
|
457 |
/*
|
458 |
* (non-Javadoc)
|
459 |
* @see com.iver.cit.gvsig.gui.panels.AbstractWFSPanel#initialize()
|
460 |
*/
|
461 |
protected void initialize() { |
462 |
setLabel(PluginServices.getText(this, "options")); |
463 |
setLabelGroup(PluginServices.getText(this, "wfs")); |
464 |
this.setLayout(new java.awt.BorderLayout()); |
465 |
java.awt.GridBagConstraints gridBagConstraints; |
466 |
|
467 |
northPanel = new JPanel(); |
468 |
northPanel.setLayout(new java.awt.GridBagLayout());
|
469 |
|
470 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
471 |
gridBagConstraints.gridx = 0;
|
472 |
gridBagConstraints.gridy = 0;
|
473 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
474 |
gridBagConstraints.weightx = 1.0;
|
475 |
northPanel.add(getConnectionParamsPanel(), gridBagConstraints); |
476 |
|
477 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
478 |
gridBagConstraints.gridx = 0;
|
479 |
gridBagConstraints.gridy = 1;
|
480 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
481 |
gridBagConstraints.weightx = 1.0;
|
482 |
northPanel.add(getFormatPanel(), gridBagConstraints); |
483 |
|
484 |
gridBagConstraints = new java.awt.GridBagConstraints();
|
485 |
gridBagConstraints.gridx = 0;
|
486 |
gridBagConstraints.gridy = 2;
|
487 |
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; |
488 |
gridBagConstraints.weightx = 1.0;
|
489 |
northPanel.add(getCachePanel(), gridBagConstraints); |
490 |
|
491 |
add(northPanel, java.awt.BorderLayout.NORTH); |
492 |
} |
493 |
} |