Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSOptionsPanel.java @ 10072

History | View | Annotate | Download (10.4 KB)

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