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