Statistics
| Revision:

gvsig-raster / org.gvsig.raster.wcs / trunk / org.gvsig.raster.wcs / org.gvsig.raster.wcs.app / org.gvsig.raster.wcs.app.wcsclient / src / main / java / org / gvsig / raster / wcs / app / wcsclient / gui / panel / InfoPanel.java @ 418

History | View | Annotate | Download (11.1 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
*
3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4
* of the Valencian Government (CIT)
5
* 
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version.
10
* 
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU General Public License for more details.
15
* 
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
* MA  02110-1301, USA.
20
* 
21
*/
22
 
23
package org.gvsig.raster.wcs.app.wcsclient.gui.panel;
24

    
25
import java.awt.BorderLayout;
26

    
27
import javax.swing.JEditorPane;
28
import javax.swing.JPanel;
29
import javax.swing.JScrollPane;
30

    
31
import org.gvsig.andami.PluginServices;
32
import org.gvsig.fmap.dal.coverage.explorer.WCSServerExplorer;
33
import org.gvsig.fmap.dal.coverage.store.remote.RemoteWCSLayerNode;
34

    
35

    
36
/**
37
 * Service Information Panel
38
 * @author Nacho Brodin (nachobrodin@gmail.com)
39
 */
40
public class InfoPanel extends JPanel {
41
        private static final long serialVersionUID = 1L;
42
        private final String bgColor0 = "\"#FEEDD6\""; // light salmon
43
    private final String bgColor1 = "\"#EAEAEA\""; // light grey
44
    //private final String bgColor2 = "\"#F2FEFF\""; // light blue
45
    private final String bgColor3 = "\"#FBFFE1\""; // light yellow
46

    
47
    private final String service_title       = PluginServices.getText(this, "service_info");
48
    private final String server              = PluginServices.getText(this, "server");
49
    private final String server_type         = PluginServices.getText(this, "server_type");
50
    private final String server_abstract     = PluginServices.getText(this, "server_abstract");
51
    private final String server_title        = PluginServices.getText(this, "server_title");
52
    private final String layers_title        = PluginServices.getText(this, "selected_layers");
53
    private final String layer_title         = PluginServices.getText(this, "layer_title");
54
    private final String layer_abstract      = PluginServices.getText(this, "layer_abstract");
55
    private final String selected_parameters = PluginServices.getText(this, "selected_parameters");
56
    private final String time_title          = PluginServices.getText(this, "time");
57
    private final String format_title        = PluginServices.getText(this, "format");
58
    private final String srs_title           = "CRS";
59
    private final String properties                         = PluginServices.getText(this, "properties");
60
    private final String layer_name                         = PluginServices.getText(this, "name");
61
        private JEditorPane editor = null;
62

    
63

    
64
    /**
65
     * Creates a new instance of InfoPanel with double buffer and null layout
66
     *
67
     */
68
        public InfoPanel() {
69
        setLayout(new BorderLayout());
70
        JScrollPane src = new JScrollPane();
71
        src.setViewportView(getEditor());
72
        add(src, BorderLayout.CENTER);
73
        }
74

    
75
    /**
76
     * This method initializes tblInfo
77
     *
78
     * @return javax.swing.JTable
79
     */
80
    private JEditorPane getEditor() {
81
        if (editor == null) {
82
            editor = new JEditorPane();
83
            editor.setEditable(false);
84
        }
85
        return editor;
86
    }
87

    
88

    
89
    /**
90
     * Fills the text pane with a data table describing the service and the
91
     * selected settings.
92
     *
93
     * @param WCSWizardData dataSource: connection info
94
     * @param WCSLayer layer: the selected layer
95
     * @param String time: the time value.
96
     * @param String format: the format value
97
     * @param String crs: the CRS value
98
     * @param String parameters: comma-separated key-value string containing the values for the parameters
99
     */
100

    
101
    public void refresh(WCSServerExplorer dataSource, RemoteWCSLayerNode layer, String time, String format, String crs, String parameters) {
102

    
103
        String server_text = dataSource.getHost();
104
        String server_type_text = dataSource.getServerType();
105
        String server_title_text = dataSource.getTitle();
106
        String server_abstract_text = dataSource.getAbstract();
107
        String font = "Arial";
108

    
109
        if (server_text == null)
110
            server_text = "-";
111
        if (server_type_text == null)
112
            server_type_text = "-";
113
        if (server_title_text == null)
114
            server_title_text = "-";
115
        if (server_abstract_text == null)
116
            server_abstract_text = "-";
117

    
118
        if (format == null)
119
            format = PluginServices.getText(this, "none_selected");
120
        if (crs == null)
121
            crs = PluginServices.getText(this, "none_selected");
122

    
123
        String layers_html = "";
124
        if (layer!=null) {
125
            String layer_name_text = layer.getName();
126
            String time_text = (time==null) ? PluginServices.getText(this, "not_available") : time;//((FMapWMSStyle) selectedStyles.get(i)).title;
127
            String layer_abstract_text = layer.getDescription();
128
            String layer_title_text = layer.getTitle();
129

    
130
            if (layer_name_text ==null)
131
                    layer_name_text = "-";
132
            if (time_text==null)
133
                    time_text = "-";
134
            if (layer_abstract_text==null)
135
                    layer_abstract_text = "-";
136
            if (layer_title_text == null)
137
                    layer_title_text = "-";
138
            String layer_html =
139
                    "  <tr valign=\"top\">" +
140
                "     <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+layer_name+"</b></font></td>" +
141
                "     <td bgcolor="+bgColor0+"><font face=\"Arial\" size=\"3\">"+layer_name_text+"</font></td>" +
142
                "  </tr>" +
143
                "  <tr valign=\"top\">" +
144
                "     <td width=\"119\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\"><b>"+layer_title+"</b></font></td>" +
145
                "     <td width=\"322\" height=\"18\" bgcolor="+bgColor1+"><font face=\"Arial\" size=\"3\">"+layer_title_text+"</font></td>" +
146
                "  </tr>" +
147
                "  <tr valign=\"top\">" +
148
                "     <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+layer_abstract+"</b></font></td>" +
149
                "     <td bgcolor="+bgColor0+"><font face=\"Arial\" size=\"3\">"+layer_abstract_text+"</font></td>" +
150
                "  </tr>" +
151
                "  <tr valign=\"top\">" +
152
                "     <td bgcolor=\"#D6D6D6\" align=\"right\"><font face=\"Arial\" size=\"3\" align=\"right\"><b>"+time_title+"</b></font></td>" +
153
                "     <td bgcolor="+bgColor1+"><font face=\"Arial\" size=\"3\">"+time_text+"</font></td>" +
154
                "  </tr>" +
155
                "  <tr>" +
156
                "  </tr>";
157
            layers_html += layer_html;
158
        }
159
        if (!layers_html.equals(""))
160
            layers_html =
161
                "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
162
                "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+layers_title+"</font></b></td>" +
163
                "  </tr>" + layers_html;
164
        String parameter_html = "";
165
        if (parameters!=null) {
166
                boolean swap = false;
167
                String[] myParameters = parameters.split("&");
168
                for (int i = 0; i < myParameters.length; i++) {
169
                        String color = swap ? bgColor0 : bgColor1;
170
                        String[] parameter = myParameters[i].split("=");
171
                        parameter_html +=
172
                                "  <tr valign=\"top\" bgcolor="+color+">" +
173
                                "    <td width=\"120\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><b>"+parameter[0]+"</b></td>" +
174
                                "    <td width=\"322\" height=\"18\">"+parameter[1]+"</td>" +
175
                                "  </tr>";
176
                        swap = !swap;
177
                }
178
                parameter_html +=
179
                        "  <tr>" +
180
                        "  </tr>";
181
        }
182
        if (!parameter_html.equals(""))
183
                parameter_html =
184
                        "  <tr valign=\"top\">" +
185
                        "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+selected_parameters+"</font></b></td>" +
186
                        "  </tr>" + parameter_html;
187

    
188
        String format_html =
189
                "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
190
            "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+properties+"</font></b></td>" +
191
            "  </tr>" +
192
            "  <tr valign=\"top\" bgcolor="+bgColor0+">" +
193
            "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+format_title+"</b></font></td>" +
194
            "    <td><font face=\""+font+"\" size=\"3\"><font face=\""+font+"\" size=\"3\">"+format+"</font></td>" +
195
            "  </tr>" +
196
            "  <tr valign=\"top\" bgcolor="+bgColor1+">" +
197
            "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+srs_title+"</font></b></td>" +
198
            "    <td><font face=\""+font+"\" size=\"3\">"+crs+"</font></td>" +
199
            "  </tr>";
200

    
201
        String html =
202

    
203
            "<html>" +
204
            "<body>" +
205
            "<table align=\"center\" width=\"437\" height=\"156\" border=\"0\" cellpadding=\"4\" cellspacing=\"4\">" +
206
            "  <tr valign=\"top\" bgcolor=\"#FFFFFF\">" +
207
            "    <td width=\"92\" height=\"18\" bgcolor="+bgColor3+" colspan=\"2\"><font face=\""+font+"\" size=\"4\"><b>"+service_title+"</font></b></td>" +
208
            "  </tr>" +
209
            "  <tr valign=\"top\" bgcolor="+bgColor0+">" +
210
            "    <td width=\"92\" height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server+"</font></b></td>" +
211
            "    <td width=\"268\"><font face=\""+font+"\" size=\"3\">"+server_text+"</font></td>" +
212
            "  </tr>" +
213
            "  <tr valign=\"top\" bgcolor="+bgColor1+">" +
214
            "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_type+"</b></font></td>" +
215
            "    <td><font face=\""+font+"\" size=\"3\">"+server_type_text+"</font></td>" +
216
            "  </tr>" +
217
            "  <tr valign=\"top\" bgcolor="+bgColor0+">" +
218
            "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_title+"</b></font></td>" +
219
            "    <td><font face=\""+font+"\" size=\"3\"><font face=\""+font+"\" size=\"3\">"+server_title_text+"</font></td>" +
220
            "  </tr>" +
221
            "  <tr valign=\"top\" bgcolor="+bgColor1+">" +
222
            "    <td height=\"18\" bgcolor=\"#D6D6D6\" align=\"right\"><font face=\""+font+"\" size=\"3\"><b>"+server_abstract+"</font></b></td>" +
223
            "    <td><font face=\""+font+"\" size=\"3\">"+server_abstract_text+"</font></td>" +
224
            "  </tr>" +
225

    
226
            "  <tr>" +
227
            "  </tr>" +
228
            layers_html +
229
            parameter_html +
230
            format_html +
231
            "</table>" +
232
            "</body>" +
233
            "</html>";
234

    
235
        getEditor().setContentType("text/html");
236
        getEditor().setText(html);
237
    }
238
}
239