Statistics
| Revision:

svn-gvsig-desktop / tags / v2_0_0_Build_2020 / extensions / extWCS / src / org / gvsig / wcs / gui / WCSWizardData.java @ 33775

History | View | Annotate | Download (5.55 KB)

1 29644 jpiera
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.wcs.gui;
42
43
import java.awt.Component;
44
import java.io.IOException;
45
import java.net.ConnectException;
46
import java.net.URL;
47
import java.util.ArrayList;
48
49
import javax.swing.JOptionPane;
50
51
import org.gvsig.andami.PluginServices;
52
import org.gvsig.app.gui.wizards.WizardData;
53
import org.gvsig.fmap.dal.exception.ReadException;
54
import org.gvsig.wcs.fmap.drivers.wcs.FMapWCSDriver;
55
import org.gvsig.wcs.fmap.drivers.wcs.FMapWCSDriverFactory;
56
import org.gvsig.wcs.fmap.layers.WCSLayer;
57
58
59
60
61
/**
62
 * This class holds the WCSWizard's info
63
 *
64
 * Contiene la informaci?n del asistente WCS
65
 *
66
 * @author jaume - jaume.dominguez@iver.es
67
 *
68
 */
69
70
public class WCSWizardData extends WizardData{
71
    private String title;
72
    private FMapWCSDriver wcs;
73
        private String theAbstract;
74
        private WCSLayer[] coverageList;
75
76
77
    public void setHost(URL host, boolean override) throws ReadException {
78
        try {
79
                wcs = FMapWCSDriverFactory.getFMapDriverForURL(host);
80
81
                        //wcs.createClient(host);
82
83
        // Send getCapabilities and describe coverage request;
84
                if (!wcs.connect(override, null)) {
85
                        throw new ReadException(host.getPath(), null);
86
                }
87
        } catch (ConnectException e) {
88
                JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this,"wcs_server_timeout"));
89
                        return;
90
                } catch (IOException e) {
91
                        JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this, "wcs_cant_connect"));
92
                        return;
93
                }
94
95
                if (wcs.getLabel()!=null) {
96
                        title = wcs.getLabel();
97
                }
98
99
        if (wcs.getDescription()  != null) {
100
                        theAbstract = wcs.getDescription();
101
                }
102
103
        coverageList = wcs.getLayerList();
104
    }
105
106
    /**
107
     * The server description.
108
     *
109
     * La descripci?n del servidor
110
     * @return String
111
     */
112
    public String getAbstract() {
113
            if (theAbstract == null) {
114
                        return "None";
115
                }
116
        return theAbstract;
117
    }
118
119
    /**
120
     * An ArrayList with the coverage formats.
121
     *
122
     * Los formatos de la cobertura
123
     *
124
     * @return
125
     */
126
    public ArrayList getCoverageFormatos(String nomCobertura) {
127
        return getLayer(nomCobertura).getFormats();
128
    }
129
130
    /**
131
     * Finds the coverage within the coverage list
132
     *
133
     * Busca la cobertura en la lista de coberturas
134
     *
135
     * @return CoverageInfo
136
     */
137
    public WCSLayer getLayer(String name) {
138
            for (int i = 0; i < coverageList.length; i++) {
139
                        if (coverageList[i].getName().equals(name)) {
140
                                return coverageList[i];
141
                        }
142
                }
143
            return null;
144
    }
145
146
    /**
147
     * Returns an ArrayList containing the supported SRS of the coverage specified
148
     * by name.
149
     *
150
     * Devuelve una lista de SRSs soportados por la cobertura "name".
151
     *
152
     * @param name
153
     * @return ArrayList
154
     */
155
    public ArrayList getCoverageSRSs(String name){
156
            return getLayer(name).getSRSs();
157
    }
158
    /**
159
     * Server's title (not used in gvSIG)
160
     *
161
     * T?tulo del servidor (no se usa en gvSIG)
162
     *
163
     * @return
164
     */
165
    public String getTitle() {
166
            if (title == null) {
167
                        return "None";
168
                }
169
        return title;
170
    }
171
172
    /**
173
     * Equivalent to the setDescription method
174
     *
175
     * Equivalente a setDescription
176
     *
177
     * @param string
178
     */
179
    public void setAbstract(String string) {
180
        theAbstract = string;
181
    }
182
183
    /**
184
     * Sets the server's title (not used in gvSIG)
185
     *
186
     * Establece el t?tulo del servidor (no se usa en gvSIG)
187
     *
188
     * @param string
189
     */
190
    public void setTitle(String string) {
191
        title = string;
192
    }
193
194
    /**
195
     * Sets the server's description.
196
     *
197
     * Establece la descripci?n del servidor.
198
     * @param String
199
     */
200
    public void setDescription(String s) {
201
            setAbstract(s);
202
    }
203
204
    /**
205
     * Returns the server's descrition
206
     *
207
     * Recupera la descripci?n del servidor
208
     * @return "None" if the server doesn't specify any description
209
     */
210
    public String getDescription(){
211
            if (getAbstract() == null) {
212
                        return "None";
213
                }
214
            return getAbstract();
215
    }
216
217
        public WCSLayer[] getCoverageList() {
218
                if (coverageList == null) {
219
                        coverageList = new WCSLayer[0];
220
                }
221
                return coverageList;
222
        }
223
224
        public FMapWCSDriver getDriver() {
225
                return wcs;
226
        }
227
228
        public String getHost() {
229
                return wcs.getHost();
230
        }
231
232
        public String getServerType() {
233
                if (wcs.getVersion()==null) {
234
                        return "WCS";
235
                }
236
                return "WCS "+wcs.getVersion();
237
        }
238
239
240
}