root / trunk / extensions / extCatalogYNomenclator / src / es / gva / cit / gvsig / catalogClient / gui / ChooseResourceDialog.java @ 3036
History | View | Annotate | Download (5.64 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 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 es.gva.cit.gvsig.catalogClient.gui; |
42 |
|
43 |
import java.io.IOException; |
44 |
|
45 |
import javax.swing.JOptionPane; |
46 |
|
47 |
import com.Ostermiller.util.Browser; |
48 |
import com.iver.andami.PluginServices; |
49 |
import com.iver.andami.ui.mdiManager.View; |
50 |
import com.iver.andami.ui.mdiManager.ViewInfo; |
51 |
|
52 |
import es.gva.cit.catalogClient.parsers.Resource; |
53 |
import es.gva.cit.catalogClient.ui.ChooseResourceDialogPanel; |
54 |
import es.gva.cit.gvsig.catalogClient.loaders.PostgisLoader; |
55 |
import es.gva.cit.gvsig.catalogClient.loaders.WCSLoader; |
56 |
import es.gva.cit.gvsig.catalogClient.loaders.WFSLoader; |
57 |
import es.gva.cit.gvsig.catalogClient.loaders.WMSLoader; |
58 |
|
59 |
/**
|
60 |
* This class implements the resources list view.
|
61 |
*
|
62 |
* @author Jorge Piera Llodra (piera_jor@gva.es)
|
63 |
*/
|
64 |
public class ChooseResourceDialog extends ChooseResourceDialogPanel |
65 |
implements View { |
66 |
|
67 |
/**
|
68 |
* @param resources
|
69 |
* Found resources array
|
70 |
*/
|
71 |
public ChooseResourceDialog(Resource[] resources) { |
72 |
super(resources);
|
73 |
} |
74 |
|
75 |
public ViewInfo getViewInfo() {
|
76 |
ViewInfo m_viewinfo = new ViewInfo(ViewInfo.MODALDIALOG);
|
77 |
m_viewinfo.setTitle(getName()); |
78 |
return m_viewinfo;
|
79 |
} |
80 |
|
81 |
public void closeButtonActionPerformed() { |
82 |
closeJDialog(); |
83 |
} |
84 |
|
85 |
public void closeJDialog() { |
86 |
setVisible(true);
|
87 |
PluginServices.getMDIManager().closeView(ChooseResourceDialog.this); |
88 |
} |
89 |
|
90 |
/**
|
91 |
* This method is invocated when a resource button is clicked
|
92 |
*/
|
93 |
public void resourceButtonActionPerformed(Resource resource){ |
94 |
if (resource.getProtocol().toLowerCase().indexOf("ogc:wcs") >= 0){ |
95 |
loadWCS(resource); |
96 |
}else if (resource.getProtocol().toLowerCase().indexOf("ogc:wms") >= 0){ |
97 |
loadWMS(resource); |
98 |
}else if (resource.getProtocol().toLowerCase().indexOf("ogc:wfs") >= 0){ |
99 |
loadWFS(resource); |
100 |
}else if (resource.getProtocol().toLowerCase().indexOf("postgis") >= 0){ |
101 |
loadPostgis(resource); |
102 |
}else if ((resource.getProtocol().toLowerCase().indexOf("www:link") >= 0) || |
103 |
(resource.getProtocol().toLowerCase().indexOf("www:download") >= 0)){ |
104 |
loadLink(resource); |
105 |
} |
106 |
closeJDialog(); |
107 |
|
108 |
} |
109 |
|
110 |
/**
|
111 |
* It Loads a WCS resource in gvSIG
|
112 |
* @param resource
|
113 |
* Resource to load
|
114 |
*/
|
115 |
public void loadWCS(Resource resource){ |
116 |
if (!(new WCSLoader().load(resource.getLinkage()))){ |
117 |
JOptionPane.showMessageDialog(this, |
118 |
"Ha ocurrido un error al cargar la cobertura:\n" +
|
119 |
"Link: " + resource.getLinkage() + "\n", |
120 |
"Carga de WCS",
|
121 |
JOptionPane.ERROR_MESSAGE);
|
122 |
} |
123 |
} |
124 |
|
125 |
/**
|
126 |
* It Loads a WMS resource in gvSIG
|
127 |
* @param resource
|
128 |
* Resource to load
|
129 |
*/
|
130 |
public void loadWMS(Resource resource){ |
131 |
if (!(new WMSLoader().load(resource.getLinkage(),resource.getName()))){ |
132 |
JOptionPane.showMessageDialog(this, |
133 |
"Ha ocurrido un error al cargar el mapa:\n" +
|
134 |
"Servidor: " + resource.getLinkage() + "\n" + |
135 |
"Capa: " + resource.getName(), "Carga de WMS", |
136 |
JOptionPane.ERROR_MESSAGE);
|
137 |
} |
138 |
} |
139 |
|
140 |
/**
|
141 |
* It Loads a WFS resource in gvSIG
|
142 |
* @param resource
|
143 |
* Resource to load
|
144 |
*/
|
145 |
public void loadWFS(Resource resource){ |
146 |
if (!(new WFSLoader().load(resource.getLinkage(),resource.getName()))){ |
147 |
JOptionPane.showMessageDialog(this, |
148 |
"Ha ocurrido un error al cargar el mapa:\n" +
|
149 |
"Servidor: " + resource.getLinkage() + "\n" + |
150 |
"Capa: " + resource.getName(), "Carga de WFS", |
151 |
JOptionPane.ERROR_MESSAGE);
|
152 |
} |
153 |
} |
154 |
|
155 |
/**
|
156 |
* It Loads a Postgis resource in gvSIG
|
157 |
* @param resource
|
158 |
* Resource to load
|
159 |
*/
|
160 |
public void loadPostgis(Resource resource){ |
161 |
if (!(new PostgisLoader().load(resource.getLinkage(),resource.getName()))){ |
162 |
JOptionPane.showMessageDialog(this, |
163 |
"Ha ocurrido un error al cargar el mapa:\n" +
|
164 |
"Servidor: " + resource.getLinkage() + "\n" + |
165 |
"Par?metros: " + resource.getName(), "Carga de Postgis", |
166 |
JOptionPane.ERROR_MESSAGE);
|
167 |
} |
168 |
} |
169 |
|
170 |
/**
|
171 |
* It Loads a web resource or a web page into a web browser
|
172 |
* @param resource
|
173 |
* Web resource or web page.
|
174 |
*/
|
175 |
public void loadLink(Resource resource){ |
176 |
Browser.init(); |
177 |
try {
|
178 |
Browser.displayURL(resource.getLinkage()); |
179 |
} catch (IOException e1) { |
180 |
e1.printStackTrace(); |
181 |
} |
182 |
} |
183 |
|
184 |
} |
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|