Statistics
| Revision:

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

History | View | Annotate | Download (14.6 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.XMLElement;
10
import org.gvsig.remoteClient.gml.types.IXMLType;
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 9461 2006-12-26 10:25:37Z ppiqueras $
60
 * $Log$
61
 * Revision 1.16  2006-12-26 10:25:37  ppiqueras
62
 * Corregidas las dependencias con las nuevas ubicaciones de clases: IXMLType, XMLElement, IXMLComplexType, etc. (en libRemoteServices)
63
 *
64
 * Revision 1.15  2006/12/26 09:23:23  ppiqueras
65
 * 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).
66
 *
67
 * Revision 1.13  2006/10/10 12:55:06  jorpiell
68
 * Se ha a?adido el soporte de features complejas
69
 *
70
 * Revision 1.12  2006/10/05 12:49:57  jorpiell
71
 * Cambiada la cadena buffer por max_features
72
 *
73
 * Revision 1.11  2006/10/02 09:09:45  jorpiell
74
 * Cambios del 10 copiados al head
75
 *
76
 * Revision 1.9.2.1  2006/09/19 12:28:11  jorpiell
77
 * Ya no se depende de geotools
78
 *
79
 * Revision 1.10  2006/09/18 12:07:31  jorpiell
80
 * Se ha sustituido geotools por el driver de remoteservices
81
 *
82
 * Revision 1.9  2006/07/24 07:30:33  jorpiell
83
 * Se han eliminado las partes duplicadas y se est? usando el parser de GML de FMAP.
84
 *
85
 * Revision 1.8  2006/07/21 11:50:31  jaume
86
 * improved appearance
87
 *
88
 * Revision 1.7  2006/06/21 12:35:45  jorpiell
89
 * 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
90
 *
91
 * Revision 1.6  2006/06/15 07:50:58  jorpiell
92
 * A?adida la funcionalidad de reproyectar y hechos algunos cambios en la interfaz
93
 *
94
 * Revision 1.5  2006/05/25 16:22:23  jorpiell
95
 * Cambio para eliminar el namespace de los atributos
96
 *
97
 * Revision 1.4  2006/05/25 16:01:43  jorpiell
98
 * Se ha a?adido la funcionalidad para eliminar el namespace de los tipos de atributos
99
 *
100
 * Revision 1.3  2006/05/25 10:31:06  jorpiell
101
 * Como ha cambiado la forma de mostrar las capas (una tabla, en lugar de una lista), los paneles han tenido que ser modificados
102
 *
103
 * Revision 1.2  2006/05/23 08:09:39  jorpiell
104
 * 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
105
 *
106
 * Revision 1.1  2006/04/20 16:38:24  jorpiell
107
 * 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().
108
 *
109
 * Revision 1.1  2006/04/19 12:50:16  jorpiell
110
 * Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
111
 *
112
 *
113
 */
114
/**
115
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
116
 */
117
public class WFSInfoPanel extends JPanel {
118
         private final String bgColor0 = "\"#FEEDD6\""; // light salmon
119
            private final String bgColor1 = "\"#EAEAEA\""; // light grey
120
            private final String bgColor2 = "\"#F2FEFF\""; // light blue
121
            private final String bgColor3 = "\"#FBFFE1\""; // light yellow
122

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

    
140

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

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

    
167

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

    
176
            public void refresh(WFSWizardData dataSource,WFSLayerNode layer) {
177

    
178
                       String server_text = dataSource.getHost();
179
                String server_type_text = dataSource.getServerType();
180
                String server_title_text = dataSource.getTitle();
181
                String server_abstract_text = dataSource.getAbstract();
182
                String font = "Arial";
183

    
184
                if (server_text == null)
185
                    server_text = "-";
186
                if (server_type_text == null)
187
                    server_type_text = "-";
188
                if (server_title_text == null)
189
                    server_title_text = "-";
190
                if (server_abstract_text == null)
191
                    server_abstract_text = "-";
192

    
193
                String layers_html = "";
194
                if (layer!=null) {
195
                    String layer_name_text = layer.getName();
196
                    String layer_abstract_text = layer.getAbstract();
197
                    String layer_title_text = layer.getTitle();
198
                    String layer_fields_text = "-";
199
                    String layer_geometry_text = "-";
200
                    String layer_srs_text = "-";
201

    
202
                    Vector fields = layer.getSelectedFields();
203
                    layer_fields_text = "";
204

    
205
                    for (int i=0 ; i<fields.size() ; i++){
206
                            XMLElement field = (XMLElement)fields.get(i);
207
                            if (!((field.getEntityType() != null) && (field.getEntityType().getType() == IXMLType.GML_GEOMETRY))){
208
                                     layer_fields_text = layer_fields_text + field.getName() +
209
                                            " (" +
210
                                            PluginServices.getText(this,WFSUtils.getFieldType(field.getEntityType())) + ")";
211
                            }else{
212
                                    layer_fields_text = layer_fields_text + field.getName();
213
                            }
214
                            if (i < fields.size() -1){
215
                                    layer_fields_text = layer_fields_text + ", ";
216
                            }
217
                    }
218

    
219
                    layer_geometry_text = PluginServices.getText(this,WFSUtils.getGeometry(layer));
220
                    if (layer_geometry_text.equals("")){
221
                                    layer_geometry_text = "-";
222
                    }
223

    
224
                    if (layer.getSrs().size() > 0){
225
                            layer_srs_text = (String)layer.getSrs().get(0);
226
                    }
227

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

    
269
                String buffer_text = String.valueOf(dataSource.getBuffer());
270
                String timeout_text = String.valueOf(dataSource.getTimeOut());
271

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

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

    
309
                    "  <tr>" +
310
                    "  </tr>" +
311
                    layers_html +
312
                    options_html +
313
                    "</table>" +
314
                    "</body>" +
315
                    "</html>";
316

    
317
                getEditor().setContentType("text/html");
318
                getEditor().setText(html);
319
            }
320
}