Statistics
| Revision:

root / branches / v10 / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSInfoPanel.java @ 9154

History | View | Annotate | Download (14.4 KB)

1
package com.iver.cit.gvsig.gui.panels;
2

    
3
import java.util.Vector;
4

    
5
import javax.swing.JEditorPane;
6
import javax.swing.JPanel;
7
import javax.swing.JScrollPane;
8

    
9
import org.gvsig.remoteClient.gml.schemas.IXMLType;
10
import org.gvsig.remoteClient.gml.schemas.XMLElement;
11

    
12
import com.iver.andami.PluginServices;
13
import com.iver.cit.gvsig.fmap.drivers.wfs.WFSUtils;
14
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode;
15
import com.iver.cit.gvsig.gui.wizards.WFSWizardData;
16

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

    
120
            private final String service_title       = PluginServices.getText(this, "service_info");
121
            private final String server              = PluginServices.getText(this, "server");
122
            private final String server_type         = PluginServices.getText(this, "server_type");
123
            private final String server_abstract     = PluginServices.getText(this, "server_abstract");
124
            private final String server_title        = PluginServices.getText(this, "server_title");
125
            private final String layers_title        = PluginServices.getText(this, "selected_layer");
126
            private final String layer_title         = PluginServices.getText(this, "layer_title");
127
            private final String layer_abstract      = PluginServices.getText(this, "layer_abstract");
128
            private final String options                         = PluginServices.getText(this, "properties");
129
            private final String layer_attributes          = PluginServices.getText(this, "attributes");
130
            private final String layer_name                         = PluginServices.getText(this, "name");
131
            private final String timeout                          = PluginServices.getText(this, "timeout");
132
            private final String buffer                                 = PluginServices.getText(this, "max_features");
133
            private final String layer_geometry                 = PluginServices.getText(this, "geometry");
134
            private final String layer_srs                         = PluginServices.getText(this, "srs");
135
            private JEditorPane editor = null;
136

    
137

    
138
            /**
139
             * Creates a new instance of InfoPanel with double buffer and null layout
140
             *
141
             */
142
                public WFSInfoPanel() {
143
                        super();
144
                setLayout(null);
145
                JScrollPane src = new JScrollPane();
146
                src.setBounds(5, 5, 485, 375);
147
                add(src, null);
148
                src.setViewportView(getEditor());
149
                }
150

    
151
            /**
152
             * This method initializes tblInfo
153
             *
154
             * @return javax.swing.JTable
155
             */
156
            private JEditorPane getEditor() {
157
                if (editor == null) {
158
                    editor = new JEditorPane();
159
                    editor.setEditable(false);
160
                }
161
                return editor;
162
            }
163

    
164

    
165
            /**
166
             * Fills the text pane with a data table describing the
167
             * service and the selected settings.
168
             *
169
             * @param WFSWizardData dataSource: connection info
170
             * @param WFSLayer layer: the selected layer
171
             */
172

    
173
            public void refresh(WFSWizardData dataSource,WFSLayerNode layer) {
174

    
175
                       String server_text = dataSource.getHost();
176
                String server_type_text = dataSource.getServerType();
177
                String server_title_text = dataSource.getTitle();
178
                String server_abstract_text = dataSource.getAbstract();
179
                String font = "Arial";
180

    
181
                if (server_text == null)
182
                    server_text = "-";
183
                if (server_type_text == null)
184
                    server_type_text = "-";
185
                if (server_title_text == null)
186
                    server_title_text = "-";
187
                if (server_abstract_text == null)
188
                    server_abstract_text = "-";
189

    
190
                String layers_html = "";
191
                if (layer!=null) {
192
                    String layer_name_text = layer.getName();
193
                    String layer_abstract_text = layer.getAbstract();
194
                    String layer_title_text = layer.getTitle();
195
                    String layer_attributes_text = "-";
196
                    String layer_geometry_text = "-";
197
                    String layer_srs_text = "-";
198

    
199
                    Vector attributes = layer.getSelectedFields();
200
                    layer_attributes_text = "";
201

    
202
                    for (int i=0 ; i<attributes.size() ; i++){
203
                            XMLElement attribute = (XMLElement)attributes.get(i);
204
                            if (!((attribute.getEntityType() != null) && (attribute.getEntityType().getType() == IXMLType.GML_GEOMETRY))){
205
                                     layer_attributes_text = layer_attributes_text + attribute.getName() +
206
                                            " (" +
207
                                            PluginServices.getText(this,WFSUtils.getAttributeType(attribute.getEntityType())) + ")";
208
                            }else{
209
                                    layer_attributes_text = layer_attributes_text + attribute.getName();
210
                            }
211
                            if (i < attributes.size() -1){
212
                                    layer_attributes_text = layer_attributes_text + ", ";
213
                            }
214
                    }
215

    
216
                    layer_geometry_text = PluginServices.getText(this,WFSUtils.getGeometry(layer));
217
                    if (layer_geometry_text.equals("")){
218
                                    layer_geometry_text = "-";
219
                    }
220

    
221
                    if (layer.getSrs().size() > 0){
222
                            layer_srs_text = (String)layer.getSrs().get(0);
223
                    }
224

    
225
                    if (layer_name_text ==null)
226
                            layer_name_text = "-";
227
                    if (layer_abstract_text==null)
228
                            layer_abstract_text = "-";
229
                    if (layer_title_text == null)
230
                            layer_title_text = "-";
231
                    String layer_html =
232
                            "  <tr valign=\"top\">" +
233
                        "     <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+layer_name+"</b></font></td>" +
234
                        "     <td bgcolor="+bgColor0+"><font face=\"Arial\" size=\"3\">"+layer_name_text+"</font></td>" +
235
                        "  </tr>" +
236
                        "  <tr valign=\"top\">" +
237
                        "     <td width=\"119\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\"><b>"+layer_title+"</b></font></td>" +
238
                        "     <td width=\"322\" height=\"18\" bgcolor="+bgColor1+"><font face=\"Arial\" size=\"3\">"+layer_title_text+"</font></td>" +
239
                        "  </tr>" +
240
                        "  <tr valign=\"top\">" +
241
                        "     <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+layer_abstract+"</b></font></td>" +
242
                        "     <td bgcolor="+bgColor0+"><font face=\"Arial\" size=\"3\">"+layer_abstract_text+"</font></td>" +
243
                        "  </tr>" +
244
                        "  <tr valign=\"top\">" +
245
                        "     <td width=\"119\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\"><b>"+layer_geometry+"</b></font></td>" +
246
                        "     <td width=\"322\" height=\"18\" bgcolor="+bgColor1+"><font face=\"Arial\" size=\"3\">"+layer_geometry_text+"</font></td>" +
247
                        "  </tr>" +
248
                        "  <tr valign=\"top\">" +
249
                        "     <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+layer_attributes+"</b></font></td>" +
250
                        "     <td bgcolor="+bgColor0+"><font face=\"Arial\" size=\"3\">"+layer_attributes_text+"</font></td>" +
251
                        "  </tr>" +
252
                        "  <tr valign=\"top\">" +
253
                        "     <td width=\"119\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\"><b>"+layer_srs+"</b></font></td>" +
254
                        "     <td width=\"322\" height=\"18\" bgcolor="+bgColor1+"><font face=\"Arial\" size=\"3\">"+layer_srs_text+"</font></td>" +
255
                        "  </tr>" +
256
                        "  <tr>" +
257
                        "  </tr>";
258
                    layers_html += layer_html;
259
                }
260
                if (!layers_html.equals(""))
261
                    layers_html =
262
                        "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
263
                        "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+layers_title+"</font></b></td>" +
264
                        "  </tr>" + layers_html;
265

    
266
                String buffer_text = String.valueOf(dataSource.getBuffer());
267
                String timeout_text = String.valueOf(dataSource.getTimeOut());
268

    
269
                String options_html =
270
                        "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
271
                    "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+options+"</font></b></td>" +
272
                    "  </tr>" +
273
                    "  <tr valign=\"top\" bgcolor="+bgColor0+">" +
274
                    "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+timeout+"</b></font></td>" +
275
                    "    <td><font face=\""+font+"\" size=\"3\"><font face=\""+font+"\" size=\"3\">"+timeout_text+"</font></td>" +
276
                    "  </tr>" +
277
                    "  <tr valign=\"top\" bgcolor="+bgColor1+">" +
278
                    "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+buffer+"</font></b></td>" +
279
                    "    <td><font face=\""+font+"\" size=\"3\">"+buffer_text+"</font></td>" +
280
                    "  </tr>";
281

    
282
                String html =
283
                    "<html>" +
284
                    "<body>" +
285
                    "<table align=\"center\" width=\"437\" height=\"156\" border=\"0\" cellpadding=\"4\" cellspacing=\"4\">" +
286
                    "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
287
                    "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+service_title+"</font></b></td>" +
288
                    "  </tr>" +
289
                    "  <tr valign=\"top\" bgcolor="+bgColor0+">" +
290
                    "    <td width=\"92\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server+"</font></b></td>" +
291
                    "    <td width=\"268\"><font face=\""+font+"\" size=\"3\">"+server_text+"</font></td>" +
292
                    "  </tr>" +
293
                    "  <tr valign=\"top\" bgcolor="+bgColor1+">" +
294
                    "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_type+"</b></font></td>" +
295
                    "    <td><font face=\""+font+"\" size=\"3\">"+server_type_text+"</font></td>" +
296
                    "  </tr>" +
297
                    "  <tr valign=\"top\" bgcolor="+bgColor0+">" +
298
                    "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_title+"</b></font></td>" +
299
                    "    <td><font face=\""+font+"\" size=\"3\"><font face=\""+font+"\" size=\"3\">"+server_title_text+"</font></td>" +
300
                    "  </tr>" +
301
                    "  <tr valign=\"top\" bgcolor="+bgColor1+">" +
302
                    "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_abstract+"</font></b></td>" +
303
                    "    <td><font face=\""+font+"\" size=\"3\">"+server_abstract_text+"</font></td>" +
304
                    "  </tr>" +
305

    
306
                    "  <tr>" +
307
                    "  </tr>" +
308
                    layers_html +
309
                    options_html +
310
                    "</table>" +
311
                    "</body>" +
312
                    "</html>";
313

    
314
                getEditor().setContentType("text/html");
315
                getEditor().setText(html);
316
            }
317
}