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