Statistics
| Revision:

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

History | View | Annotate | Download (12.8 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 5462 2006-05-25 16:22:23Z jorpiell $
60
 * $Log$
61
 * Revision 1.5  2006-05-25 16:22:23  jorpiell
62
 * Cambio para eliminar el namespace de los atributos
63
 *
64
 * Revision 1.4  2006/05/25 16:01:43  jorpiell
65
 * Se ha a?adido la funcionalidad para eliminar el namespace de los tipos de atributos
66
 *
67
 * Revision 1.3  2006/05/25 10:31:06  jorpiell
68
 * Como ha cambiado la forma de mostrar las capas (una tabla, en lugar de una lista), los paneles han tenido que ser modificados
69
 *
70
 * Revision 1.2  2006/05/23 08:09:39  jorpiell
71
 * 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
72
 *
73
 * Revision 1.1  2006/04/20 16:38:24  jorpiell
74
 * 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().
75
 *
76
 * Revision 1.1  2006/04/19 12:50:16  jorpiell
77
 * Primer commit de la aplicaci?n. Se puede hacer un getCapabilities y ver el mensaje de vienvenida del servidor
78
 *
79
 *
80
 */
81
/**
82
 * @author Jorge Piera Llodr? (piera_jor@gva.es)
83
 */
84
public class WFSInfoPanel extends JPanel {
85
         private final String bgColor0 = "\"#FEEDD6\""; // light salmon
86
            private final String bgColor1 = "\"#EAEAEA\""; // light grey
87
            private final String bgColor2 = "\"#F2FEFF\""; // light blue
88
            private final String bgColor3 = "\"#FBFFE1\""; // light yellow
89
            
90
            private final String service_title       = PluginServices.getText(this, "service_info");
91
            private final String server              = PluginServices.getText(this, "server");
92
            private final String server_type         = PluginServices.getText(this, "server_type");
93
            private final String server_abstract     = PluginServices.getText(this, "server_abstract");
94
            private final String server_title        = PluginServices.getText(this, "server_title");
95
            private final String layers_title        = PluginServices.getText(this, "selected_layers");
96
            private final String layer_title         = PluginServices.getText(this, "layer_title");
97
            private final String layer_abstract      = PluginServices.getText(this, "layer_abstract");
98
            private final String options                         = PluginServices.getText(this, "properties");
99
            private final String layer_attributes          = PluginServices.getText(this, "attributes");
100
            private final String layer_name                         = PluginServices.getText(this, "name");
101
            private final String timeout                          = PluginServices.getText(this, "timeout");
102
            private final String buffer                                 = PluginServices.getText(this, "buffer");
103
            private final String layer_geometry                 = PluginServices.getText(this, "geometry");
104
            private JEditorPane editor = null;
105
            
106
            
107
            /**
108
             * Creates a new instance of InfoPanel with double buffer and null layout
109
             *
110
             */
111
                public WFSInfoPanel() {
112
                        super();
113
                setLayout(null);
114
                JScrollPane src = new JScrollPane();
115
                src.setBounds(5, 5, 455, 375);
116
                add(src, null);
117
                src.setViewportView(getEditor());
118
                }
119

    
120
            /**
121
             * This method initializes tblInfo  
122
             *  
123
             * @return javax.swing.JTable   
124
             */    
125
            private JEditorPane getEditor() {
126
                if (editor == null) {
127
                    editor = new JEditorPane();
128
                    editor.setEditable(false);
129
                }
130
                return editor;
131
            }
132

    
133
            
134
            /**
135
             * Fills the text pane with a data table describing the
136
             * service and the selected settings.
137
             * 
138
             * @param WFSWizardData dataSource: connection info
139
             * @param WFSLayer layer: the selected layer
140
             */
141
            
142
            public void refresh(WFSWizardData dataSource,WFSLayerNode layer) {
143
               
144
                       String server_text = dataSource.getHost();
145
                String server_type_text = dataSource.getServerType();
146
                String server_title_text = dataSource.getTitle(); 
147
                String server_abstract_text = dataSource.getAbstract();
148
                String font = "Arial";
149
       
150
                if (server_text == null) 
151
                    server_text = "-";
152
                if (server_type_text == null)
153
                    server_type_text = "-";
154
                if (server_title_text == null)
155
                    server_title_text = "-";
156
                if (server_abstract_text == null)
157
                    server_abstract_text = "-";
158
       
159
                String layers_html = "";
160
                if (layer!=null) {
161
                    String layer_name_text = layer.getName();
162
                    String layer_abstract_text = layer.getAbstract();
163
                    String layer_title_text = layer.getTitle();
164
                    String layer_attributes_text = "-";
165
                    String layer_geometry_text = "-";
166
                    
167
                    Vector attributes = layer.getSelectedFields();
168
                    layer_attributes_text = "";
169
                    
170
                    for (int i=0 ; i<attributes.size() ; i++){
171
                            WFSAttribute attribute = (WFSAttribute)attributes.get(i);
172
                            if (!(WFSFilter.isGeometry(attribute.getType()))){
173
                                     if (attribute.getType() != null){
174
                                            layer_attributes_text = layer_attributes_text + attribute.getName() +
175
                                            " (" + 
176
                                            PluginServices.getText(this,WFSFilter.getAttributeType(attribute)) + ")";
177
                                    }else{
178
                                            layer_attributes_text = layer_attributes_text + attribute.getName();
179
                                    }
180
                                    if (i < attributes.size() -1){
181
                                            layer_attributes_text = layer_attributes_text + ", ";
182
                                    }
183
                            }  
184
                            layer_geometry_text = PluginServices.getText(this,WFSFilter.getGeometry(layer));
185
                            if (layer_geometry_text.equals("")){
186
                                            layer_geometry_text = "-";
187
                            }
188
                    }            
189
                    
190
                    if (layer_name_text ==null)
191
                            layer_name_text = "-";
192
                    if (layer_abstract_text==null)
193
                            layer_abstract_text = "-";
194
                    if (layer_title_text == null)
195
                            layer_title_text = "-";
196
                    String layer_html =
197
                            "  <tr valign=\"top\">" +
198
                        "     <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+layer_name+"</b></font></td>" +
199
                        "     <td bgcolor="+bgColor0+"><font face=\"Arial\" size=\"3\">"+layer_name_text+"</font></td>" +
200
                        "  </tr>" +
201
                        "  <tr valign=\"top\">" +
202
                        "     <td width=\"119\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\"><b>"+layer_title+"</b></font></td>" +
203
                        "     <td width=\"322\" height=\"18\" bgcolor="+bgColor1+"><font face=\"Arial\" size=\"3\">"+layer_title_text+"</font></td>" +
204
                        "  </tr>" +
205
                        "  <tr valign=\"top\">" +
206
                        "     <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+layer_abstract+"</b></font></td>" +
207
                        "     <td bgcolor="+bgColor0+"><font face=\"Arial\" size=\"3\">"+layer_abstract_text+"</font></td>" +
208
                        "  </tr>" +
209
                        "  <tr valign=\"top\">" +
210
                        "     <td width=\"119\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\"><b>"+layer_geometry+"</b></font></td>" +
211
                        "     <td width=\"322\" height=\"18\" bgcolor="+bgColor1+"><font face=\"Arial\" size=\"3\">"+layer_geometry_text+"</font></td>" +
212
                        "  </tr>" +
213
                        "  <tr valign=\"top\">" +
214
                        "     <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+layer_attributes+"</b></font></td>" +
215
                        "     <td bgcolor="+bgColor0+"><font face=\"Arial\" size=\"3\">"+layer_attributes_text+"</font></td>" +
216
                        "  </tr>" +
217
                        "  <tr>" +
218
                        "  </tr>";
219
                    layers_html += layer_html;
220
                }
221
                if (!layers_html.equals(""))
222
                    layers_html =
223
                        "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
224
                        "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+layers_title+"</font></b></td>" +
225
                        "  </tr>" + layers_html;                
226
               
227
                String buffer_text = String.valueOf(dataSource.getBuffer());
228
                String timeout_text = String.valueOf(dataSource.getTimeOut());
229
                
230
                String options_html = 
231
                        "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
232
                    "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+options+"</font></b></td>" +
233
                    "  </tr>" + 
234
                    "  <tr valign=\"top\" bgcolor="+bgColor0+">" +
235
                    "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+timeout+"</b></font></td>" +
236
                    "    <td><font face=\""+font+"\" size=\"3\"><font face=\""+font+"\" size=\"3\">"+timeout_text+"</font></td>" +
237
                    "  </tr>" +
238
                    "  <tr valign=\"top\" bgcolor="+bgColor1+">" +
239
                    "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+buffer+"</font></b></td>" +
240
                    "    <td><font face=\""+font+"\" size=\"3\">"+buffer_text+"</font></td>" +
241
                    "  </tr>";
242
                    
243
                String html = 
244
                    "<html>" +
245
                    "<body>" +
246
                    "<table align=\"center\" width=\"437\" height=\"156\" border=\"0\" cellpadding=\"4\" cellspacing=\"4\">" +
247
                    "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
248
                    "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+service_title+"</font></b></td>" +
249
                    "  </tr>" +
250
                    "  <tr valign=\"top\" bgcolor="+bgColor0+">" +
251
                    "    <td width=\"92\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server+"</font></b></td>" +
252
                    "    <td width=\"268\"><font face=\""+font+"\" size=\"3\">"+server_text+"</font></td>" +
253
                    "  </tr>" +
254
                    "  <tr valign=\"top\" bgcolor="+bgColor1+">" +
255
                    "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_type+"</b></font></td>" +
256
                    "    <td><font face=\""+font+"\" size=\"3\">"+server_type_text+"</font></td>" +
257
                    "  </tr>" +
258
                    "  <tr valign=\"top\" bgcolor="+bgColor0+">" +
259
                    "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_title+"</b></font></td>" +
260
                    "    <td><font face=\""+font+"\" size=\"3\"><font face=\""+font+"\" size=\"3\">"+server_title_text+"</font></td>" +
261
                    "  </tr>" +
262
                    "  <tr valign=\"top\" bgcolor="+bgColor1+">" +
263
                    "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_abstract+"</font></b></td>" +
264
                    "    <td><font face=\""+font+"\" size=\"3\">"+server_abstract_text+"</font></td>" +
265
                    "  </tr>" +
266
                    
267
                    "  <tr>" +
268
                    "  </tr>" +
269
                    layers_html +
270
                    options_html +
271
                    "</table>" +
272
                    "</body>" +
273
                    "</html>";
274
                
275
                getEditor().setContentType("text/html");
276
                getEditor().setText(html);
277
            }
278
}