Statistics
| Revision:

root / trunk / extensions / extWFS2 / src / com / iver / cit / gvsig / gui / panels / WFSInfoPanel.java @ 6501

History | View | Annotate | Download (13.7 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.wfs.WFSAttribute;
10

    
11
import com.iver.andami.PluginServices;
12
import com.iver.cit.gvsig.fmap.drivers.geotools.WFSFilter;
13
import com.iver.cit.gvsig.fmap.layers.WFSLayerNode;
14
import com.iver.cit.gvsig.gui.wizards.WFSWizardData;
15
import com.iver.utiles.StringUtilities;
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 6501 2006-07-21 11:51:55Z jaume $
60
 * $Log$
61
 * Revision 1.8  2006-07-21 11:50:31  jaume
62
 * improved appearance
63
 *
64
 * Revision 1.7  2006/06/21 12:35:45  jorpiell
65
 * 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
66
 *
67
 * Revision 1.6  2006/06/15 07:50:58  jorpiell
68
 * A?adida la funcionalidad de reproyectar y hechos algunos cambios en la interfaz
69
 *
70
 * Revision 1.5  2006/05/25 16:22:23  jorpiell
71
 * Cambio para eliminar el namespace de los atributos
72
 *
73
 * Revision 1.4  2006/05/25 16:01:43  jorpiell
74
 * Se ha a?adido la funcionalidad para eliminar el namespace de los tipos de atributos
75
 *
76
 * Revision 1.3  2006/05/25 10:31:06  jorpiell
77
 * Como ha cambiado la forma de mostrar las capas (una tabla, en lugar de una lista), los paneles han tenido que ser modificados
78
 *
79
 * Revision 1.2  2006/05/23 08:09:39  jorpiell
80
 * 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
81
 *
82
 * Revision 1.1  2006/04/20 16:38:24  jorpiell
83
 * 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().
84
 *
85
 * Revision 1.1  2006/04/19 12:50:16  jorpiell
86
 * Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
87
 *
88
 *
89
 */
90
/**
91
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
92
 */
93
public class WFSInfoPanel extends JPanel {
94
         private final String bgColor0 = "\"#FEEDD6\""; // light salmon
95
            private final String bgColor1 = "\"#EAEAEA\""; // light grey
96
            private final String bgColor2 = "\"#F2FEFF\""; // light blue
97
            private final String bgColor3 = "\"#FBFFE1\""; // light yellow
98

    
99
            private final String service_title       = PluginServices.getText(this, "service_info");
100
            private final String server              = PluginServices.getText(this, "server");
101
            private final String server_type         = PluginServices.getText(this, "server_type");
102
            private final String server_abstract     = PluginServices.getText(this, "server_abstract");
103
            private final String server_title        = PluginServices.getText(this, "server_title");
104
            private final String layers_title        = PluginServices.getText(this, "selected_layer");
105
            private final String layer_title         = PluginServices.getText(this, "layer_title");
106
            private final String layer_abstract      = PluginServices.getText(this, "layer_abstract");
107
            private final String options                         = PluginServices.getText(this, "properties");
108
            private final String layer_attributes          = PluginServices.getText(this, "attributes");
109
            private final String layer_name                         = PluginServices.getText(this, "name");
110
            private final String timeout                          = PluginServices.getText(this, "timeout");
111
            private final String buffer                                 = PluginServices.getText(this, "buffer");
112
            private final String layer_geometry                 = PluginServices.getText(this, "geometry");
113
            private final String layer_srs                         = PluginServices.getText(this, "srs");
114
            private JEditorPane editor = null;
115

    
116

    
117
            /**
118
             * Creates a new instance of InfoPanel with double buffer and null layout
119
             *
120
             */
121
                public WFSInfoPanel() {
122
                        super();
123
                setLayout(null);
124
                JScrollPane src = new JScrollPane();
125
                src.setBounds(5, 5, 485, 375);
126
                add(src, null);
127
                src.setViewportView(getEditor());
128
                }
129

    
130
            /**
131
             * This method initializes tblInfo
132
             *
133
             * @return javax.swing.JTable
134
             */
135
            private JEditorPane getEditor() {
136
                if (editor == null) {
137
                    editor = new JEditorPane();
138
                    editor.setEditable(false);
139
                }
140
                return editor;
141
            }
142

    
143

    
144
            /**
145
             * Fills the text pane with a data table describing the
146
             * service and the selected settings.
147
             *
148
             * @param WFSWizardData dataSource: connection info
149
             * @param WFSLayer layer: the selected layer
150
             */
151

    
152
            public void refresh(WFSWizardData dataSource,WFSLayerNode layer) {
153

    
154
                       String server_text = dataSource.getHost();
155
                String server_type_text = dataSource.getServerType();
156
                String server_title_text = dataSource.getTitle();
157
                String server_abstract_text = dataSource.getAbstract();
158
                String font = "Arial";
159

    
160
                if (server_text == null)
161
                    server_text = "-";
162
                if (server_type_text == null)
163
                    server_type_text = "-";
164
                if (server_title_text == null)
165
                    server_title_text = "-";
166
                if (server_abstract_text == null)
167
                    server_abstract_text = "-";
168

    
169
                String layers_html = "";
170
                if (layer!=null) {
171
                    String layer_name_text = layer.getName();
172
                    String layer_abstract_text = layer.getAbstract();
173
                    String layer_title_text = layer.getTitle();
174
                    String layer_attributes_text = "-";
175
                    String layer_geometry_text = "-";
176
                    String layer_srs_text = "-";
177

    
178
                    Vector attributes = layer.getSelectedFields();
179
                    layer_attributes_text = "";
180

    
181
                    for (int i=0 ; i<attributes.size() ; i++){
182
                            WFSAttribute attribute = (WFSAttribute)attributes.get(i);
183
                            if (!(WFSFilter.isGeometry(attribute.getType()))){
184
                                     if (attribute.getType() != null){
185
                                            layer_attributes_text = layer_attributes_text + attribute.getName() +
186
                                            " (" +
187
                                            PluginServices.getText(this,WFSFilter.getAttributeType(attribute)) + ")";
188
                                    }else{
189
                                            layer_attributes_text = layer_attributes_text + attribute.getName();
190
                                    }
191
                                    if (i < attributes.size() -1){
192
                                            layer_attributes_text = layer_attributes_text + ", ";
193
                                    }
194
                            }
195
                    }
196

    
197
                    layer_geometry_text = PluginServices.getText(this,WFSFilter.getGeometry(layer));
198
                    if (layer_geometry_text.equals("")){
199
                                    layer_geometry_text = "-";
200
                    }
201

    
202
                    if (layer.getSrs().size() > 0){
203
                            layer_srs_text = (String)layer.getSrs().get(0);
204
                    }
205

    
206
                    if (layer_name_text ==null)
207
                            layer_name_text = "-";
208
                    if (layer_abstract_text==null)
209
                            layer_abstract_text = "-";
210
                    if (layer_title_text == null)
211
                            layer_title_text = "-";
212
                    String layer_html =
213
                            "  <tr valign=\"top\">" +
214
                        "     <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+layer_name+"</b></font></td>" +
215
                        "     <td bgcolor="+bgColor0+"><font face=\"Arial\" size=\"3\">"+layer_name_text+"</font></td>" +
216
                        "  </tr>" +
217
                        "  <tr valign=\"top\">" +
218
                        "     <td width=\"119\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\"><b>"+layer_title+"</b></font></td>" +
219
                        "     <td width=\"322\" height=\"18\" bgcolor="+bgColor1+"><font face=\"Arial\" size=\"3\">"+layer_title_text+"</font></td>" +
220
                        "  </tr>" +
221
                        "  <tr valign=\"top\">" +
222
                        "     <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+layer_abstract+"</b></font></td>" +
223
                        "     <td bgcolor="+bgColor0+"><font face=\"Arial\" size=\"3\">"+layer_abstract_text+"</font></td>" +
224
                        "  </tr>" +
225
                        "  <tr valign=\"top\">" +
226
                        "     <td width=\"119\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\"><b>"+layer_geometry+"</b></font></td>" +
227
                        "     <td width=\"322\" height=\"18\" bgcolor="+bgColor1+"><font face=\"Arial\" size=\"3\">"+layer_geometry_text+"</font></td>" +
228
                        "  </tr>" +
229
                        "  <tr valign=\"top\">" +
230
                        "     <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+layer_attributes+"</b></font></td>" +
231
                        "     <td bgcolor="+bgColor0+"><font face=\"Arial\" size=\"3\">"+layer_attributes_text+"</font></td>" +
232
                        "  </tr>" +
233
                        "  <tr valign=\"top\">" +
234
                        "     <td width=\"119\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\"><b>"+layer_srs+"</b></font></td>" +
235
                        "     <td width=\"322\" height=\"18\" bgcolor="+bgColor1+"><font face=\"Arial\" size=\"3\">"+layer_srs_text+"</font></td>" +
236
                        "  </tr>" +
237
                        "  <tr>" +
238
                        "  </tr>";
239
                    layers_html += layer_html;
240
                }
241
                if (!layers_html.equals(""))
242
                    layers_html =
243
                        "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
244
                        "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+layers_title+"</font></b></td>" +
245
                        "  </tr>" + layers_html;
246

    
247
                String buffer_text = String.valueOf(dataSource.getBuffer());
248
                String timeout_text = String.valueOf(dataSource.getTimeOut());
249

    
250
                String options_html =
251
                        "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
252
                    "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+options+"</font></b></td>" +
253
                    "  </tr>" +
254
                    "  <tr valign=\"top\" bgcolor="+bgColor0+">" +
255
                    "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+timeout+"</b></font></td>" +
256
                    "    <td><font face=\""+font+"\" size=\"3\"><font face=\""+font+"\" size=\"3\">"+timeout_text+"</font></td>" +
257
                    "  </tr>" +
258
                    "  <tr valign=\"top\" bgcolor="+bgColor1+">" +
259
                    "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+buffer+"</font></b></td>" +
260
                    "    <td><font face=\""+font+"\" size=\"3\">"+buffer_text+"</font></td>" +
261
                    "  </tr>";
262

    
263
                String html =
264
                    "<html>" +
265
                    "<body>" +
266
                    "<table align=\"center\" width=\"437\" height=\"156\" border=\"0\" cellpadding=\"4\" cellspacing=\"4\">" +
267
                    "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
268
                    "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+service_title+"</font></b></td>" +
269
                    "  </tr>" +
270
                    "  <tr valign=\"top\" bgcolor="+bgColor0+">" +
271
                    "    <td width=\"92\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server+"</font></b></td>" +
272
                    "    <td width=\"268\"><font face=\""+font+"\" size=\"3\">"+server_text+"</font></td>" +
273
                    "  </tr>" +
274
                    "  <tr valign=\"top\" bgcolor="+bgColor1+">" +
275
                    "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_type+"</b></font></td>" +
276
                    "    <td><font face=\""+font+"\" size=\"3\">"+server_type_text+"</font></td>" +
277
                    "  </tr>" +
278
                    "  <tr valign=\"top\" bgcolor="+bgColor0+">" +
279
                    "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_title+"</b></font></td>" +
280
                    "    <td><font face=\""+font+"\" size=\"3\"><font face=\""+font+"\" size=\"3\">"+server_title_text+"</font></td>" +
281
                    "  </tr>" +
282
                    "  <tr valign=\"top\" bgcolor="+bgColor1+">" +
283
                    "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_abstract+"</font></b></td>" +
284
                    "    <td><font face=\""+font+"\" size=\"3\">"+server_abstract_text+"</font></td>" +
285
                    "  </tr>" +
286

    
287
                    "  <tr>" +
288
                    "  </tr>" +
289
                    layers_html +
290
                    options_html +
291
                    "</table>" +
292
                    "</body>" +
293
                    "</html>";
294

    
295
                getEditor().setContentType("text/html");
296
                getEditor().setText(html);
297
            }
298
}