Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extWFS2 / src / org / gvsig / wfs / gui / panels / WFSInfoPanel.java @ 34026

History | View | Annotate | Download (11.2 KB)

1
package org.gvsig.wfs.gui.panels;
2

    
3
import java.awt.Dimension;
4
import java.awt.Graphics;
5
import java.util.Vector;
6

    
7
import org.gvsig.andami.PluginServices;
8
import org.gvsig.app.project.documents.view.toc.gui.HTMLInfoPanel;
9
import org.gvsig.fmap.dal.serverexplorer.wfs.WFSServerExplorer;
10
import org.gvsig.gui.beans.panelGroup.IPanelGroup;
11
import org.gvsig.wfs.gui.panels.model.WFSSelectedFeature;
12
import org.gvsig.wfs.gui.panels.model.WFSUtils;
13
import org.gvsig.xmlschema.lib.api.som.IXSElementDeclaration;
14

    
15

    
16
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
17
 *
18
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
19
 *
20
 * This program is free software; you can redistribute it and/or
21
 * modify it under the terms of the GNU General Public License
22
 * as published by the Free Software Foundation; either version 2
23
 * of the License, or (at your option) any later version.
24
 *
25
 * This program is distributed in the hope that it will be useful,
26
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
28
 * GNU General Public License for more details.
29
 *
30
 * You should have received a copy of the GNU General Public License
31
 * along with this program; if not, write to the Free Software
32
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
33
 *
34
 * For more information, contact:
35
 *
36
 *  Generalitat Valenciana
37
 *   Conselleria d'Infraestructures i Transport
38
 *   Av. Blasco Ib??ez, 50
39
 *   46010 VALENCIA
40
 *   SPAIN
41
 *
42
 *      +34 963862235
43
 *   gvsig@gva.es
44
 *      www.gvsig.gva.es
45
 *
46
 *    or
47
 *
48
 *   IVER T.I. S.A
49
 *   Salamanca 50
50
 *   46005 Valencia
51
 *   Spain
52
 *
53
 *   +34 963163400
54
 *   dac@iver.es
55
 */
56
/* CVS MESSAGES:
57
 *
58
 * $Id: WFSInfoPanel.java 17736 2008-01-02 16:53:48Z ppiqueras $
59
 * $Log$
60
 * Revision 1.16  2006-12-26 10:25:37  ppiqueras
61
 * Corregidas las dependencias con las nuevas ubicaciones de clases: IXMLType, XMLElement, IXMLComplexType, etc. (en libRemoteServices)
62
 *
63
 * Revision 1.15  2006/12/26 09:23:23  ppiqueras
64
 * Cambiado "atttibutes" en todas las aparaciones en atributos, m?todos, clases, paquetes o comentarios por "fields". (S?lo a aquellas que afectan a clases dentro del proyecto extWFS2).
65
 *
66
 * Revision 1.13  2006/10/10 12:55:06  jorpiell
67
 * Se ha a?adido el soporte de features complejas
68
 *
69
 * Revision 1.12  2006/10/05 12:49:57  jorpiell
70
 * Cambiada la cadena buffer por max_features
71
 *
72
 * Revision 1.11  2006/10/02 09:09:45  jorpiell
73
 * Cambios del 10 copiados al head
74
 *
75
 * Revision 1.9.2.1  2006/09/19 12:28:11  jorpiell
76
 * Ya no se depende de geotools
77
 *
78
 * Revision 1.10  2006/09/18 12:07:31  jorpiell
79
 * Se ha sustituido geotools por el driver de remoteservices
80
 *
81
 * Revision 1.9  2006/07/24 07:30:33  jorpiell
82
 * Se han eliminado las partes duplicadas y se est? usando el parser de GML de FMAP.
83
 *
84
 * Revision 1.8  2006/07/21 11:50:31  jaume
85
 * improved appearance
86
 *
87
 * Revision 1.7  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.6  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.5  2006/05/25 16:22:23  jorpiell
94
 * Cambio para eliminar el namespace de los atributos
95
 *
96
 * Revision 1.4  2006/05/25 16:01:43  jorpiell
97
 * Se ha a?adido la funcionalidad para eliminar el namespace de los tipos de atributos
98
 *
99
 * Revision 1.3  2006/05/25 10:31:06  jorpiell
100
 * Como ha cambiado la forma de mostrar las capas (una tabla, en lugar de una lista), los paneles han tenido que ser modificados
101
 *
102
 * Revision 1.2  2006/05/23 08:09:39  jorpiell
103
 * 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
104
 *
105
 * Revision 1.1  2006/04/20 16:38:24  jorpiell
106
 * 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().
107
 *
108
 * Revision 1.1  2006/04/19 12:50:16  jorpiell
109
 * Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
110
 *
111
 *
112
 */
113

    
114
/**
115
 * <p>Panel that provides information about the service offered by the WFS server connected.</p>
116
 * 
117
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
118
 */
119
public class WFSInfoPanel extends HTMLInfoPanel implements IWFSPanel {
120
        private static final long serialVersionUID = 2605168444543321684L;
121

    
122
        private final String service_title       = PluginServices.getText(this, "service_info");
123
        private final String server              = PluginServices.getText(this, "server");
124
        private final String server_type         = PluginServices.getText(this, "server_type");
125
        private final String server_abstract     = PluginServices.getText(this, "server_abstract");
126
        private final String server_title        = PluginServices.getText(this, "server_title");
127
        private final String layers_title        = PluginServices.getText(this, "selected_layer");
128
        private final String layer_title         = PluginServices.getText(this, "layer_title");
129
        private final String layer_abstract      = PluginServices.getText(this, "layer_abstract");
130
        private final String options                         = PluginServices.getText(this, "properties");
131
        private final String layer_fields                   = PluginServices.getText(this, "fields");
132
        private final String layer_name                         = PluginServices.getText(this, "name");
133
        private final String timeout                          = PluginServices.getText(this, "timeout");
134
        private final String buffer                                 = PluginServices.getText(this, "max_features");
135
        private final String layer_geometry                 = PluginServices.getText(this, "geometry");
136
        private final String layer_srs                         = PluginServices.getText(this, "srs");
137
        
138
        /**
139
         * Creates a new instance of InfoPanel with double buffer and null layout
140
         */
141
        public WFSInfoPanel() {
142
                super();
143
                initialize();
144
                this.setPreferredSize(new Dimension(10,10));
145
        }        
146
        
147
        /*
148
         * (non-Javadoc)
149
         * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
150
         */
151
        protected void paintComponent(Graphics g) {
152
                IPanelGroup panelGroup = getPanelGroup();
153
                
154
                if (panelGroup == null)
155
                        return;
156
                
157
                ((WFSParamsPanel)panelGroup).refreshCapabilitiesInfo();
158
                super.paintComponent(g);
159
        }
160

    
161
        /**
162
         * Fills the text pane with a data table describing the
163
         * service and the selected settings.
164
         *
165
         * @param WFSWizardData dataSource: connection info
166
         * @param WFSLayer layer: the selected layer
167
         */
168
        public void refresh(WFSSelectedFeature layer) {
169
                WFSServerExplorer serverExplorer = getServerExplorer();
170
                
171
                String server_text = serverExplorer.getUrl();
172
                String server_type_text = serverExplorer.getServerType();
173
                String server_title_text = serverExplorer.getTitle();
174
                String server_abstract_text = serverExplorer.getAbstract();
175
                
176
                if (server_text == null)
177
                        server_text = "-";
178
                if (server_type_text == null)
179
                        server_type_text = "-";
180
                if (server_title_text == null)
181
                        server_title_text = "-";
182
                if (server_abstract_text == null)
183
                        server_abstract_text = "-";
184

    
185
                String layers_html = "";
186
                if (layer!=null) {
187
                        String layer_name_text = layer.getName();
188
                        String layer_abstract_text = layer.getAbstract();
189
                        String layer_title_text = layer.getTitle();
190
                        String layer_fields_text = "-";
191
                        String layer_geometry_text = "-";
192
                        String layer_srs_text = "-";
193

    
194
                        Vector<Object> fields = layer.getSelectedFields();
195
                        layer_fields_text = "";
196

    
197
                        for (int i=0 ; i<fields.size() ; i++){
198
                                IXSElementDeclaration field = (IXSElementDeclaration)fields.get(i);
199
                                if (!((field.getTypeDefinition() != null) && (field.getTypeDefinition().isGeometry()))){
200
                                        layer_fields_text = layer_fields_text + field.getNodeName() +
201
                                        " (" +
202
                                        PluginServices.getText(this,WFSUtils.getFieldType(field.getTypeDefinition())) + ")";
203
                                }else{
204
                                        layer_fields_text = layer_fields_text + field.getNodeName();
205
                                }
206
                                if (i < fields.size() -1){
207
                                        layer_fields_text = layer_fields_text + ", ";
208
                                }
209
                        }
210

    
211
                        layer_geometry_text = PluginServices.getText(this,WFSUtils.getGeometry(layer));
212
                        if (layer_geometry_text.equals("")){
213
                                layer_geometry_text = "-";
214
                        }
215

    
216
                        if (layer.getSrs().size() > 0){
217
                                layer_srs_text = (String)layer.getSrs().get(0);
218
                        }
219

    
220
                        if (layer_name_text ==null)
221
                                layer_name_text = "-";
222
                        if (layer_abstract_text==null)
223
                                layer_abstract_text = "-";
224
                        if (layer_title_text == null)
225
                                layer_title_text = "-";
226
                        StringBuffer layer_html = new StringBuffer();
227
                        layer_html.append(setHTMLBasicProperty(layer_name, layer_name_text));
228
                        layer_html.append(setHTMLBasicProperty(layer_title, layer_title_text));
229
                        layer_html.append(setHTMLBasicProperty(layer_abstract, layer_abstract_text));
230
                        layer_html.append(setHTMLBasicProperty(layer_geometry, layer_geometry_text));
231
                        layer_html.append(setHTMLBasicProperty(layer_fields, layer_fields_text));
232
                        layer_html.append(setHTMLBasicProperty(layer_srs, layer_srs_text));
233
                        layers_html += layer_html.toString();
234
                }
235
                if (!layers_html.equals(""))
236
                        layers_html = setHTMLTitleTable(layers_title, 2) + layers_html;
237

    
238
                String buffer_text = String.valueOf(serverExplorer.getMaxFeatures());
239
                String timeout_text = String.valueOf(serverExplorer.getTimeOut());
240

    
241
                StringBuffer options_html = new StringBuffer();
242
                options_html.append(setHTMLTitleTable(options , 2));
243
                options_html.append(setHTMLBasicProperty(timeout, timeout_text));
244
                options_html.append(setHTMLBasicProperty(buffer, buffer_text));
245
                        
246
                StringBuffer service_html = new StringBuffer();
247
                service_html.append(setHTMLTitleTable(service_title, 2));
248
                service_html.append(setHTMLBasicProperty(server, server_text));
249
                service_html.append(setHTMLBasicProperty(server_type, server_type_text));
250
                service_html.append(setHTMLBasicProperty(server_title, server_title_text));
251
                service_html.append(setHTMLBasicProperty(server_abstract, server_abstract_text));
252
                        
253
                StringBuffer html = new StringBuffer();
254
                html.append(setHTMLTable(service_html.toString()));
255
                html.append(setHTMLTable(layers_html.toString()));
256
                html.append(setHTMLTable(options_html.toString()));        
257
                
258
                addHTMLToPanel(setHTMLBody(html.toString()));                
259
        }        
260

    
261
        /* (non-Javadoc)
262
         * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#accept()
263
         */
264
        public void accept() {
265
                // TODO Auto-generated method stub
266
                
267
        }
268

    
269
        /* (non-Javadoc)
270
         * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#apply()
271
         */
272
        public void apply() {
273
                // TODO Auto-generated method stub
274
                
275
        }
276

    
277
        /* (non-Javadoc)
278
         * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#cancel()
279
         */
280
        public void cancel() {
281
                // TODO Auto-generated method stub
282
                
283
        }
284

    
285
        /* (non-Javadoc)
286
         * @see org.gvsig.gui.beans.panelGroup.panels.IPanel#selected()
287
         */
288
        public void selected() {
289
                // TODO Auto-generated method stub
290
                
291
        }
292
        
293
        /**
294
         * <p>Gets the information of the wizard used to add or load panels.</p>
295
         * 
296
         * @return the wizard data
297
         */
298
        public WFSServerExplorer getServerExplorer(){
299
                return (getPanelGroup() == null)? null: ((WFSParamsPanel)getPanelGroup()).getServerExplorer();  
300
        }
301
}