Statistics
| Revision:

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

History | View | Annotate | Download (11.2 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 10473 ppiqueras
 * 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 7917 jorpiell
 * Cambiada la cadena buffer por max_features
70
 *
71
 * Revision 1.10  2006/10/02 09:09:45  jorpiell
72 7721 jorpiell
 * 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 7034 jorpiell
 * 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 6501 jaume
 * improved appearance
82
 *
83
 * Revision 1.7  2006/06/22 06:54:14  jorpiell
84 5974 jorpiell
 * 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 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
88
 *
89
 * Revision 1.5  2006/06/15 07:50:58  jorpiell
90 5856 jorpiell
 * 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 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 ".").
94
 *
95
 * Revision 1.3  2006/05/23 08:09:39  jorpiell
96 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
97
 *
98
 * Revision 1.2  2006/05/19 12:57:08  jorpiell
99 5300 jorpiell
 * Modificados algunos paneles
100
 *
101
 * Revision 1.1  2006/04/20 16:38:24  jorpiell
102 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().
103
 *
104
 *
105
 */
106
/**
107
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
108 10473 ppiqueras
 * @author Pablo Piqueras Bartolom?
109 4911 jorpiell
 */
110 17593 jpiera
public class WFSOptionsPanel extends DefaultWFSDialogPanel{
111 4911 jorpiell
112 5300 jorpiell
        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 5856 jorpiell
        private JPanel formatPanel = null;
123
        private JLabel srsLabel = null;
124
        private JTextField srsText = null;
125 10473 ppiqueras
        private JLabel jLabelMiliSeconds = null;
126 17593 jpiera
127
        public WFSOptionsPanel() {
128 5300 jorpiell
                super();
129
                initialize();
130
        }
131
132
        /**
133 6501 jaume
         * This method initializes usernameText
134
         *
135
         * @return javax.swing.JTextField
136 5300 jorpiell
         */
137
        private JTextField getUsernameText() {
138
                if (usernameText == null) {
139
                        usernameText = new JTextField();
140
                        usernameText.setBounds(new java.awt.Rectangle(100,25,200,20));
141 6501 jaume
                        usernameText.addKeyListener(new java.awt.event.KeyAdapter() {
142
                                public void keyTyped(java.awt.event.KeyEvent e) {
143 17593 jpiera
                                        getParamsPanelData().isApplicable(true);
144 5948 jorpiell
                                }
145
                        });
146 5300 jorpiell
                }
147
                return usernameText;
148
        }
149
150
        /**
151 6501 jaume
         * This method initializes passwordText
152
         *
153
         * @return javax.swing.JTextField
154 5300 jorpiell
         */
155
        private JPasswordField getPasswordText() {
156
                if (passwordText == null) {
157
                        passwordText = new JPasswordField();
158
                        passwordText.setBounds(new java.awt.Rectangle(100,50,200,20));
159 6501 jaume
                        passwordText.addKeyListener(new java.awt.event.KeyAdapter() {
160
                                public void keyTyped(java.awt.event.KeyEvent e) {
161 17593 jpiera
                                        getParamsPanelData().isApplicable(true);
162 5948 jorpiell
                                }
163
                        });
164 5300 jorpiell
                }
165
                return passwordText;
166
        }
167
168
        /**
169 6501 jaume
         * This method initializes jPanel
170
         *
171
         * @return javax.swing.JPanel
172 5300 jorpiell
         */
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 7917 jorpiell
                        bufferLabel.setText(PluginServices.getText(this, "max_features"));
179 5300 jorpiell
                        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 7034 jorpiell
                        connectionParamsPanel.setBounds(new java.awt.Rectangle(7,65,485,80));
188 5300 jorpiell
                        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 10473 ppiqueras
                        connectionParamsPanel.add(getJLabelMiliSeconds(), null);
194 5300 jorpiell
                }
195
                return connectionParamsPanel;
196
        }
197
198
        /**
199 6501 jaume
         * This method initializes jTextField
200
         *
201
         * @return javax.swing.JTextField
202 5300 jorpiell
         */
203
        private JFormattedTextField getBufferText() {
204
                if (bufferText == null) {
205
                        bufferText = new JFormattedTextField(NumberFormat.getIntegerInstance());
206 5948 jorpiell
                        bufferText.setValue(new Integer(1000));
207 5300 jorpiell
                        bufferText.setBounds(new Rectangle(100, 25, 70, 20));
208 10473 ppiqueras
                        bufferText.setToolTipText(PluginServices.getText(bufferText, "set_Max_Number_Of_Features_Will_Be_Loaded"));
209 6501 jaume
                        bufferText.addKeyListener(new java.awt.event.KeyAdapter() {
210
                                public void keyTyped(java.awt.event.KeyEvent e) {
211 17593 jpiera
                                        getParamsPanelData().isApplicable(true);
212 5948 jorpiell
                                }
213
                        });
214 5300 jorpiell
                }
215
                return bufferText;
216
        }
217
218
        /**
219 6501 jaume
         * This method initializes jTextField1
220
         *
221
         * @return javax.swing.JTextField
222 5300 jorpiell
         */
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 10473 ppiqueras
                        timeOutText.setToolTipText(PluginServices.getText(timeOutText, "set_TimeOut_Explanation"));
229 6501 jaume
                        timeOutText.addKeyListener(new java.awt.event.KeyAdapter() {
230
                                public void keyTyped(java.awt.event.KeyEvent e) {
231 17593 jpiera
                                        getParamsPanelData().isApplicable(true);
232 5948 jorpiell
                                }
233
                        });
234 5300 jorpiell
                }
235
                return timeOutText;
236
        }
237
238
        /**
239 5948 jorpiell
        /**
240 6501 jaume
         *
241 5300 jorpiell
         * @return the username
242
         */
243
        public String getUserName(){
244
                return getUsernameText().getText();
245
        }
246 6501 jaume
247 5300 jorpiell
        /**
248 6501 jaume
         *
249 5300 jorpiell
         * @return the password
250
         */
251
        public String getPassword(){
252
                return getPasswordText().getText();
253
        }
254 6501 jaume
255 5300 jorpiell
        /**
256 6501 jaume
         *
257 5300 jorpiell
         * @return the buffer
258
         */
259
        public int getBuffer(){
260 5590 jorpiell
                try{
261
                        String buffer = StringUtilities.replace(getBufferText().getText(),".","");
262 5948 jorpiell
                        buffer = StringUtilities.replace(buffer,",","");
263 5590 jorpiell
                        return Integer.parseInt(buffer);
264
                }catch(NumberFormatException e){
265
                        return 10000;
266
                }
267 5300 jorpiell
        }
268 6501 jaume
269 5300 jorpiell
        /**
270 6501 jaume
         *
271 5300 jorpiell
         * @return the timeout
272
         */
273
        public int getTimeout(){
274 5590 jorpiell
                try{
275
                        String timeOut = StringUtilities.replace(getTimeOutText().getText(),".","");
276 5948 jorpiell
                        timeOut = StringUtilities.replace(timeOut,",","");
277 5590 jorpiell
                        return Integer.parseInt(timeOut);
278
                }catch(NumberFormatException e){
279
                        return 10000;
280
                }
281 5300 jorpiell
        }
282 17593 jpiera
283 7721 jorpiell
        /**
284
         * Gets the SRS
285
         * @return
286
         */
287
        public String getSRS(){
288
                return getSrsText().getText();
289
        }
290 5856 jorpiell
291
        /**
292 6501 jaume
         * This method initializes formatPanel
293
         *
294
         * @return javax.swing.JPanel
295 5856 jorpiell
         */
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 5948 jorpiell
                        formatPanel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "srs"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null));
307 6501 jaume
                        formatPanel.setBounds(new java.awt.Rectangle(7,5,485,55));
308 5856 jorpiell
                        formatPanel.add(srsLabel, null);
309
                        formatPanel.add(getSrsText(), null);
310
                }
311
                return formatPanel;
312
        }
313
314
        /**
315 6501 jaume
         * This method initializes srsText
316
         *
317
         * @return javax.swing.JTextField
318 5856 jorpiell
         */
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 5974 jorpiell
                        srsText.setEditable(false);
325 10473 ppiqueras
                        srsText.setToolTipText(PluginServices.getText(srsText, "select_Feature_Reference_System"));
326 5856 jorpiell
                }
327
                return srsText;
328
        }
329 6501 jaume
330 5856 jorpiell
        /**
331
         * Refresh the panel
332
         * @param feature
333
         */
334 17593 jpiera
        public void refresh(WFSLayerNode layer) {
335
                Vector srs = layer.getSrs();
336 5856 jorpiell
                if (srs.size() > 0){
337
                        getSrsText().setText((String)srs.get(0));
338
                }
339
        }
340 5948 jorpiell
341 6501 jaume
        public void setStatus(WFSStatus status) {
342 5948 jorpiell
                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 17593 jpiera
348 10473 ppiqueras
        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 17593 jpiera
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 4911 jorpiell
}