Statistics
| Revision:

root / org.gvsig.wfs.app / trunk / org.gvsig.wfs.app / org.gvsig.wfs.app.mainplugin / src / main / java / org / gvsig / wfs / gui / panels / WFSInfoPanel.java @ 10

History | View | Annotate | Download (11 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.remoteclient.wfs.WFSFeatureField;
12
import org.gvsig.wfs.gui.panels.model.WFSSelectedFeature;
13

    
14

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

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

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

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

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

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

    
196
                        for (int i=0 ; i<fields.size() ; i++){
197
                                WFSFeatureField field = (WFSFeatureField)fields.get(i);
198
                                if (field.isGeometry()){
199
                                        layer_fields_text = layer_fields_text + field.getName() +
200
                                        " (" +
201
                                        PluginServices.getText(this, field.getType()) + ")";
202
                                }else{
203
                                        layer_fields_text = layer_fields_text + field.getName();
204
                                }
205
                                if (i < fields.size() -1){
206
                                        layer_fields_text = layer_fields_text + ", ";
207
                                }
208
                        }
209

    
210
                        layer_geometry_text = PluginServices.getText(this, layer.getGeometryField().getType());
211
                        if (layer_geometry_text.equals("")){
212
                                layer_geometry_text = "-";
213
                        }
214

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

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

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

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

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

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

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

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