Revision 940
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.174/org.gvsig.catalog.extension/src/main/java/org/gvsig/catalog/loaders/PostgisLayerLoader.java | ||
---|---|---|
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 org.gvsig.catalog.loaders; |
|
42 |
|
|
43 |
import java.awt.Dimension; |
|
44 |
import java.net.MalformedURLException; |
|
45 |
import java.net.URL; |
|
46 |
import java.util.StringTokenizer; |
|
47 |
import java.util.TreeMap; |
|
48 |
|
|
49 |
import javax.swing.JLabel; |
|
50 |
import javax.swing.JOptionPane; |
|
51 |
import javax.swing.JPanel; |
|
52 |
import javax.swing.JPasswordField; |
|
53 |
|
|
54 |
import org.apache.commons.dbcp.SQLNestedException; |
|
55 |
import org.apache.commons.lang3.StringUtils; |
|
56 |
import org.gvsig.catalog.schemas.Resource; |
|
57 |
import org.gvsig.catalog.utils.Strings; |
|
58 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
59 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
60 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
61 |
import org.gvsig.fmap.dal.resource.db.DBParameters; |
|
62 |
import org.gvsig.fmap.dal.store.jdbc.JDBCConnectionParameters; |
|
63 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
64 |
import org.gvsig.i18n.Messages; |
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
/** |
|
69 |
* This class is used to load a POSTGIS resource in gvSIG |
|
70 |
* |
|
71 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
72 |
*/ |
|
73 |
|
|
74 |
public class PostgisLayerLoader extends GvSigLayerLoader{ |
|
75 |
|
|
76 |
public PostgisLayerLoader(Resource resource) { |
|
77 |
super(resource); |
|
78 |
} |
|
79 |
|
|
80 |
protected boolean hasSpecificLayer() { |
|
81 |
return false; |
|
82 |
} |
|
83 |
|
|
84 |
protected String getLayerName() { |
|
85 |
return getResource().getName(); |
|
86 |
} |
|
87 |
|
|
88 |
protected DataStoreParameters createDataStoreParameters() |
|
89 |
throws InitializeException, ProviderNotRegisteredException { |
|
90 |
String jdbcUrl = getResource().getLinkage(); |
|
91 |
String table = getResource().getName(); |
|
92 |
|
|
93 |
DataStoreParameters dataStoreParameters = DATA_MANAGER.createStoreParameters("PostgreSQL"); |
|
94 |
parseParams(dataStoreParameters, jdbcUrl, table); |
|
95 |
|
|
96 |
return dataStoreParameters; |
|
97 |
} |
|
98 |
|
|
99 |
private void parseParams(DataStoreParameters dataStoreParameters, String jdbcUrl, String table){ |
|
100 |
StringTokenizer sti = new StringTokenizer(jdbcUrl,"?"); |
|
101 |
String dbURL = sti.nextToken(); |
|
102 |
String user = ""; |
|
103 |
String pwd = ""; |
|
104 |
if(sti.hasMoreTokens()){ |
|
105 |
String p = sti.nextToken(); |
|
106 |
|
|
107 |
TreeMap map = separateParams(p); |
|
108 |
user = (String) map.get((String) "USER"); |
|
109 |
pwd = (String) map.get((String) "PASSWORD"); |
|
110 |
map = Strings.separateParams(table); |
|
111 |
dataStoreParameters.setDynValue("USER", user); |
|
112 |
dataStoreParameters.setDynValue("PASSWORD",pwd); |
|
113 |
dataStoreParameters.setDynValue("WHERECLAUSE",""); |
|
114 |
dataStoreParameters.setDynValue("DBURL",dbURL); |
|
115 |
}else{ |
|
116 |
if(dbURL.startsWith("jdbc:postgresql://")){ |
|
117 |
//jdbc:postgresql://test.gvsig.net:7432/gvsig:****@test |
|
118 |
try { |
|
119 |
URL url = new URL(dbURL.replace("jdbc:postgresql://", "http://")); |
|
120 |
if(url != null) { |
|
121 |
dataStoreParameters.setDynValue(JDBCConnectionParameters.HOST_PARAMTER_NAME, url.getHost()); |
|
122 |
dataStoreParameters.setDynValue(JDBCConnectionParameters.PORT_PARAMTER_NAME, url.getPort()+""); |
|
123 |
// /gvsig:****@test |
|
124 |
String path = url.getPath(); |
|
125 |
user = path.substring(1, path.indexOf(":")); |
|
126 |
pwd = getCredentials(user); |
|
127 |
|
|
128 |
String db = path.substring(path.indexOf("@")+1); |
|
129 |
|
|
130 |
dataStoreParameters.setDynValue(DBParameters.USER_PARAMTER_NAME, user); |
|
131 |
dataStoreParameters.setDynValue(DBParameters.PASSWORD_PARAMTER_NAME, pwd); |
|
132 |
dataStoreParameters.setDynValue(JDBCConnectionParameters.DBNAME_PARAMTER_NAME, db); |
|
133 |
} |
|
134 |
} catch (MalformedURLException e) { |
|
135 |
// TODO Auto-generated catch block |
|
136 |
e.printStackTrace(); |
|
137 |
} |
|
138 |
|
|
139 |
} |
|
140 |
} |
|
141 |
|
|
142 |
dataStoreParameters.setDynValue("Table", table); |
|
143 |
} |
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
148 |
private String getCredentials(String user) { |
|
149 |
JPanel panel = new JPanel(); |
|
150 |
JLabel label = new JLabel(Messages.getText("password_needed")+" ("+user+"):"); |
|
151 |
JPasswordField pass = new JPasswordField(); |
|
152 |
pass.setPreferredSize(new Dimension(150, 25)); |
|
153 |
panel.add(label); |
|
154 |
panel.add(pass); |
|
155 |
String[] options = new String[]{Messages.getText("connectButton"), Messages.getText("cancelSearchButton")}; |
|
156 |
int option = JOptionPane.showOptionDialog(null, panel, Messages.getText("password_needed_title"), |
|
157 |
JOptionPane.NO_OPTION, JOptionPane.PLAIN_MESSAGE, |
|
158 |
null, options, options[1]); |
|
159 |
if(option == 0){ |
|
160 |
return new String(pass.getPassword()); |
|
161 |
} |
|
162 |
return ""; |
|
163 |
} |
|
164 |
|
|
165 |
// public void loadLayer() throws LayerLoaderException { |
|
166 |
// FLayer layer; |
|
167 |
// try{ |
|
168 |
// if (hasSpecificLayer()){ |
|
169 |
// layer = createLayerFromExtensionPoint(); |
|
170 |
// }else{ |
|
171 |
// layer = createLayerFromParameters(); |
|
172 |
// } |
|
173 |
// if (layer != null){ |
|
174 |
// addLayerToView(layer); |
|
175 |
// } |
|
176 |
// } catch (Exception e) { |
|
177 |
// if(e. instanceof SQLNestedException){ |
|
178 |
// JPanel panel = new JPanel(); |
|
179 |
// JLabel label = new JLabel("Enter a password:"); |
|
180 |
// JPasswordField pass = new JPasswordField(); |
|
181 |
// panel.add(label); |
|
182 |
// panel.add(pass); |
|
183 |
// String[] options = new String[]{"OK", "Cancel"}; |
|
184 |
// int option = JOptionPane.showOptionDialog(null, panel, "The title", |
|
185 |
// JOptionPane.NO_OPTION, JOptionPane.PLAIN_MESSAGE, |
|
186 |
// null, options, options[1]); |
|
187 |
// if(option == 0 && !StringUtils.isBlank(new String(pass.getPassword()))){ |
|
188 |
// String pwd = new String(pass.getPassword()); |
|
189 |
// try{ |
|
190 |
// DataStoreParameters dataStoreParameters = createDataStoreParameters(); |
|
191 |
// dataStoreParameters.setDynValue(DBParameters.PASSWORD_PARAMTER_NAME, pwd); |
|
192 |
// MAP_CONTEXT_MANAGER.createLayer(getLayerName(), dataStoreParameters); |
|
193 |
// }catch (Exception ex) { |
|
194 |
// throw new LayerLoaderException(ex.getMessage(), ex, getWindowMessage()); |
|
195 |
// } |
|
196 |
// }else{ |
|
197 |
// throw new LayerLoaderException(e.getMessage(), e, getWindowMessage()); |
|
198 |
// } |
|
199 |
// }else{ |
|
200 |
// e.printStackTrace(); |
|
201 |
// throw new LayerLoaderException(e.getMessage(), e, getWindowMessage()); |
|
202 |
// } |
|
203 |
// } |
|
204 |
// |
|
205 |
// } |
|
206 |
|
|
207 |
private TreeMap separateParams(String pairValues){ |
|
208 |
TreeMap map = new TreeMap(); |
|
209 |
String[] params = pairValues.split("&"); |
|
210 |
for (int i = 0; i < params.length; i++) { |
|
211 |
String[] nameValue = params[i].split("="); |
|
212 |
map.put(nameValue[0].toUpperCase(), nameValue[1]); |
|
213 |
} |
|
214 |
return map; |
|
215 |
} |
|
216 |
|
|
217 |
/* |
|
218 |
* (non-Javadoc) |
|
219 |
* @see es.gva.cit.gvsig.catalogClient.loaders.LayerLoader#getErrorMessage() |
|
220 |
*/ |
|
221 |
protected String getErrorMessage() { |
|
222 |
return Messages.getText("postgisError") + ".\n" + |
|
223 |
Messages.getText("server") + ": " + |
|
224 |
getResource().getLinkage() + "\n" + |
|
225 |
Messages.getText("parameters") + ": " + |
|
226 |
getResource().getName(); |
|
227 |
} |
|
228 |
|
|
229 |
/* |
|
230 |
* (non-Javadoc) |
|
231 |
* @see es.gva.cit.gvsig.catalogClient.loaders.LayerLoader#getWindowMessage() |
|
232 |
*/ |
|
233 |
protected String getWindowMessage() { |
|
234 |
return Messages.getText("postgisLoad"); |
|
235 |
} |
|
236 |
|
|
237 |
|
|
238 |
} |
|
0 | 239 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.174/org.gvsig.catalog.extension/src/main/java/org/gvsig/catalog/loaders/WCSLayerLoader.java | ||
---|---|---|
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 org.gvsig.catalog.loaders; |
|
42 |
|
|
43 |
import java.util.HashMap; |
|
44 |
import java.util.HashSet; |
|
45 |
import java.util.List; |
|
46 |
import java.util.Map; |
|
47 |
|
|
48 |
import org.gvsig.app.gui.wizards.WizardListener; |
|
49 |
import org.gvsig.app.gui.wizards.WizardListenerSupport; |
|
50 |
import org.gvsig.catalog.gui.LoaderWizardPanel; |
|
51 |
import org.gvsig.catalog.schemas.Resource; |
|
52 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
53 |
import org.gvsig.fmap.dal.coverage.exception.ConnectException; |
|
54 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
55 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
56 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
57 |
import org.gvsig.i18n.Messages; |
|
58 |
import org.gvsig.raster.wcs.app.wcsclient.gui.panel.WCSParamsPanel; |
|
59 |
import org.gvsig.raster.wcs.io.WCSLayerNode; |
|
60 |
import org.gvsig.raster.wcs.io.WCSProvider; |
|
61 |
import org.gvsig.raster.wcs.io.WCSServerExplorer; |
|
62 |
import org.gvsig.raster.wcs.io.WCSServerExplorerParameters; |
|
63 |
import org.slf4j.Logger; |
|
64 |
import org.slf4j.LoggerFactory; |
|
65 |
|
|
66 |
|
|
67 |
/** |
|
68 |
* This class is used to load a WCS layer in gvSIG |
|
69 |
* |
|
70 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
71 |
*/ |
|
72 |
public class WCSLayerLoader extends GvSigLayerLoader{ |
|
73 |
|
|
74 |
private Logger logger = LoggerFactory.getLogger(WCSLayerLoader.class); |
|
75 |
|
|
76 |
private WCSServerExplorer explorer; |
|
77 |
|
|
78 |
private WCSParamsPanel wcsParamsPanel; |
|
79 |
|
|
80 |
public static final String FIELD_FORMAT = "format"; |
|
81 |
public static final String FIELD_NAME = "name"; |
|
82 |
public static final String FIELD_SRSSTR = "srsstr"; |
|
83 |
public static final String FIELD_URI = "uri"; |
|
84 |
public static final String FIELD_ONLINERESOURC = "onlineresources"; |
|
85 |
public static final String FIELD_WIDTH = "width"; |
|
86 |
public static final String FIELD_HEIGHT = "height"; |
|
87 |
public static final String FIELD_PARAM = "parameter"; |
|
88 |
|
|
89 |
public WCSLayerLoader(Resource resource) { |
|
90 |
super(resource); |
|
91 |
} |
|
92 |
|
|
93 |
protected boolean hasSpecificLayer() { |
|
94 |
return true; |
|
95 |
} |
|
96 |
|
|
97 |
protected String getLayerName() { |
|
98 |
return getResource().getName(); |
|
99 |
} |
|
100 |
|
|
101 |
protected DataStoreParameters createDataStoreParameters() |
|
102 |
throws InitializeException, ProviderNotRegisteredException { |
|
103 |
DataStoreParameters dataStoreParameters = DATA_MANAGER.createStoreParameters("Wcs Store"); |
|
104 |
|
|
105 |
if(getResource() != null){ |
|
106 |
dataStoreParameters.setDynValue(FIELD_NAME, getLayerName()); |
|
107 |
dataStoreParameters.setDynValue(FIELD_ONLINERESOURC, createOnlineResources()); |
|
108 |
} |
|
109 |
|
|
110 |
if(parseQuery(dataStoreParameters, getResource().getLinkage())){ |
|
111 |
return dataStoreParameters; |
|
112 |
} |
|
113 |
|
|
114 |
return null; |
|
115 |
} |
|
116 |
|
|
117 |
protected Map createOnlineResources() { |
|
118 |
Map args = new HashMap(); |
|
119 |
args.put("GepCoverage", getResource().getLinkage()); |
|
120 |
return args; |
|
121 |
} |
|
122 |
|
|
123 |
protected String extensionPointName() { |
|
124 |
return "OGC:WCS"; |
|
125 |
} |
|
126 |
|
|
127 |
/** |
|
128 |
* Builds a coverage starting from a full GetCoverage URL. |
|
129 |
* (Using this is not a regular function) |
|
130 |
*/ |
|
131 |
private boolean parseQuery(DataStoreParameters dataStoreParameters, String link){ |
|
132 |
|
|
133 |
String host = null; |
|
134 |
String queryString = null; |
|
135 |
int index = link.indexOf("?"); |
|
136 |
if (index > 0){ |
|
137 |
host = link.substring(0, index); |
|
138 |
queryString = link.substring(index+1); |
|
139 |
}else{ |
|
140 |
host = link; |
|
141 |
queryString = ""; |
|
142 |
} |
|
143 |
|
|
144 |
if(link.indexOf('?') > -1){ |
|
145 |
queryString = link.substring(link.indexOf('?')+1); |
|
146 |
dataStoreParameters.setDynValue(FIELD_URI, link.substring(0,link.indexOf('?'))); |
|
147 |
|
|
148 |
String[] params = queryString.split("&"); |
|
149 |
for (int i = 0; i < params.length; i++) { |
|
150 |
if (params[i]!= null){ |
|
151 |
String[] nameValue = params[i].split("="); |
|
152 |
if(nameValue.length == 2){ |
|
153 |
String param = nameValue[0].toUpperCase(); |
|
154 |
if (param.equals("CRS")){ |
|
155 |
dataStoreParameters.setDynValue(FIELD_SRSSTR, nameValue[1]); |
|
156 |
}else if (param.equals("FORMAT")){ |
|
157 |
dataStoreParameters.setDynValue(FIELD_FORMAT, nameValue[1]); |
|
158 |
}else if (param.equals("WIDTH")){ |
|
159 |
dataStoreParameters.setDynValue(FIELD_WIDTH, nameValue[1]); |
|
160 |
}else if (param.equals("HEIGHT")){ |
|
161 |
dataStoreParameters.setDynValue(FIELD_HEIGHT, nameValue[1]); |
|
162 |
}else if (param.equals("BANDS")){ |
|
163 |
dataStoreParameters.setDynValue(FIELD_PARAM, nameValue[1]); |
|
164 |
} |
|
165 |
} |
|
166 |
} |
|
167 |
} |
|
168 |
|
|
169 |
}else{ |
|
170 |
dataStoreParameters.setDynValue(FIELD_URI, link); |
|
171 |
|
|
172 |
|
|
173 |
try { |
|
174 |
WCSServerExplorerParameters explorerParams; |
|
175 |
explorerParams = (WCSServerExplorerParameters) DATA_MANAGER.createServerExplorerParameters(WCSProvider.NAME); |
|
176 |
explorerParams.setHost(host); |
|
177 |
explorer = (WCSServerExplorer) DATA_MANAGER.createServerExplorer(explorerParams); |
|
178 |
explorer.connect(null); |
|
179 |
|
|
180 |
deleteRepitedValues(); |
|
181 |
|
|
182 |
if(!getParams(dataStoreParameters, link)){ |
|
183 |
return false; |
|
184 |
} |
|
185 |
} catch (ValidateDataParametersException e) { |
|
186 |
// TODO Auto-generated catch block |
|
187 |
e.printStackTrace(); |
|
188 |
return false; |
|
189 |
} catch (InitializeException e) { |
|
190 |
// TODO Auto-generated catch block |
|
191 |
e.printStackTrace(); |
|
192 |
return false; |
|
193 |
} catch (ProviderNotRegisteredException e) { |
|
194 |
// TODO Auto-generated catch block |
|
195 |
e.printStackTrace(); |
|
196 |
return false; |
|
197 |
} catch (ConnectException e) { |
|
198 |
// TODO Auto-generated catch block |
|
199 |
e.printStackTrace(); |
|
200 |
} |
|
201 |
|
|
202 |
|
|
203 |
} |
|
204 |
|
|
205 |
return true; |
|
206 |
} |
|
207 |
|
|
208 |
private void deleteRepitedValues() { |
|
209 |
for(int i=0; i<explorer.getCoverageList().length; i++){ |
|
210 |
WCSLayerNode layer = explorer.getCoverageList()[i]; |
|
211 |
deleteDuplicatedStringsFromList(layer.getFormats()); |
|
212 |
deleteDuplicatedStringsFromList(layer.getInterpolationMethods()); |
|
213 |
deleteDuplicatedStringsFromList(layer.getSRSs()); |
|
214 |
} |
|
215 |
} |
|
216 |
|
|
217 |
private void deleteDuplicatedStringsFromList(List list){ |
|
218 |
HashSet hs = new HashSet(); |
|
219 |
hs.addAll(list); |
|
220 |
list.clear(); |
|
221 |
list.addAll(hs); |
|
222 |
} |
|
223 |
|
|
224 |
private boolean getParams(DataStoreParameters dataStoreParameters, String link) { |
|
225 |
try{ |
|
226 |
wcsParamsPanel = new WCSParamsPanel(); |
|
227 |
wcsParamsPanel.setListenerSupport(new WizardListenerSupport()); |
|
228 |
wcsParamsPanel.setWizardData(explorer); |
|
229 |
|
|
230 |
LoaderWizardPanel panel = new LoaderWizardPanel(wcsParamsPanel, dataStoreParameters); |
|
231 |
return panel.showWizardOnDialog(); |
|
232 |
|
|
233 |
}catch(NoClassDefFoundError e1){ |
|
234 |
logger.info("No est? instalada la extensi?n de raster"); |
|
235 |
return false; |
|
236 |
} |
|
237 |
} |
|
238 |
|
|
239 |
protected String getErrorMessage() { |
|
240 |
return Messages.getText("wcsError") + ".\n" + |
|
241 |
Messages.getText("link") + ": " + |
|
242 |
getResource().getLinkage(); |
|
243 |
} |
|
244 |
|
|
245 |
protected String getWindowMessage() { |
|
246 |
return Messages.getText("wcsLoad"); |
|
247 |
} |
|
248 |
} |
|
0 | 249 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.174/org.gvsig.catalog.extension/src/main/java/org/gvsig/catalog/loaders/ARCIMSLayerLoader.java | ||
---|---|---|
1 |
package org.gvsig.catalog.loaders; |
|
2 |
|
|
3 |
import java.util.HashMap; |
|
4 |
import java.util.Map; |
|
5 |
|
|
6 |
import org.gvsig.andami.PluginServices; |
|
7 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
8 |
import org.gvsig.catalog.schemas.Resource; |
|
9 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
10 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
11 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
12 |
import org.gvsig.i18n.Messages; |
|
13 |
|
|
14 |
|
|
15 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
16 |
* |
|
17 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
18 |
* |
|
19 |
* This program is free software; you can redistribute it and/or |
|
20 |
* modify it under the terms of the GNU General Public License |
|
21 |
* as published by the Free Software Foundation; either version 2 |
|
22 |
* of the License, or (at your option) any later version. |
|
23 |
* |
|
24 |
* This program is distributed in the hope that it will be useful, |
|
25 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
26 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
27 |
* GNU General Public License for more details. |
|
28 |
* |
|
29 |
* You should have received a copy of the GNU General Public License |
|
30 |
* along with this program; if not, write to the Free Software |
|
31 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
32 |
* |
|
33 |
* For more information, contact: |
|
34 |
* |
|
35 |
* Generalitat Valenciana |
|
36 |
* Conselleria d'Infraestructures i Transport |
|
37 |
* Av. Blasco Ib??ez, 50 |
|
38 |
* 46010 VALENCIA |
|
39 |
* SPAIN |
|
40 |
* |
|
41 |
* +34 963862235 |
|
42 |
* gvsig@gva.es |
|
43 |
* www.gvsig.gva.es |
|
44 |
* |
|
45 |
* or |
|
46 |
* |
|
47 |
* IVER T.I. S.A |
|
48 |
* Salamanca 50 |
|
49 |
* 46005 Valencia |
|
50 |
* Spain |
|
51 |
* |
|
52 |
* +34 963163400 |
|
53 |
* dac@iver.es |
|
54 |
*/ |
|
55 |
|
|
56 |
/** |
|
57 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
58 |
*/ |
|
59 |
public class ARCIMSLayerLoader extends GvSigLayerLoader { |
|
60 |
|
|
61 |
public ARCIMSLayerLoader(Resource resource) { |
|
62 |
super(resource); |
|
63 |
} |
|
64 |
|
|
65 |
protected boolean hasSpecificLayer() { |
|
66 |
return false; |
|
67 |
} |
|
68 |
|
|
69 |
protected String getLayerName() { |
|
70 |
return getResource().getName(); |
|
71 |
} |
|
72 |
|
|
73 |
protected DataStoreParameters createDataStoreParameters() |
|
74 |
throws InitializeException, ProviderNotRegisteredException { |
|
75 |
//TODO provider for ArcIMS |
|
76 |
return null; |
|
77 |
} |
|
78 |
|
|
79 |
protected Map createArgs() { |
|
80 |
String host = getResource().getLinkage(); |
|
81 |
String sLayer = getResource().getName(); |
|
82 |
String protocol = getResource().getProtocol(); |
|
83 |
AbstractViewPanel activeView = |
|
84 |
(AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
85 |
String srs = activeView.getProjection().getAbrev(); |
|
86 |
|
|
87 |
Map args = new HashMap(); |
|
88 |
args.put("host", host); |
|
89 |
args.put("service_name", sLayer); |
|
90 |
args.put("layer_name", sLayer); |
|
91 |
args.put("srs", srs); |
|
92 |
return args; |
|
93 |
} |
|
94 |
|
|
95 |
protected String extensionPointName() { |
|
96 |
String protocol = getResource().getProtocol(); |
|
97 |
if (protocol.toUpperCase().indexOf(Resource.ARCIMS_IMAGE) >= 0){ |
|
98 |
return "arcims_raster"; |
|
99 |
}else if (protocol.toUpperCase().indexOf(Resource.ARCIMS_VECTORIAL) >= 0){ |
|
100 |
return "arcims_vectorial"; |
|
101 |
} |
|
102 |
return null; |
|
103 |
} |
|
104 |
|
|
105 |
protected String getErrorMessage() { |
|
106 |
return Messages.getText("arcims_server_error") + ".\n" + |
|
107 |
Messages.getText("server") + ": " + |
|
108 |
getResource().getLinkage() + "\n" + |
|
109 |
Messages.getText("layer") + ": " + |
|
110 |
getResource().getName(); |
|
111 |
} |
|
112 |
|
|
113 |
protected String getWindowMessage() { |
|
114 |
return Messages.getText("arcims_load"); |
|
115 |
} |
|
116 |
} |
|
117 |
|
|
0 | 118 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.174/org.gvsig.catalog.extension/src/main/java/org/gvsig/catalog/loaders/GvSigLayerLoader.java | ||
---|---|---|
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 org.gvsig.catalog.loaders; |
|
42 |
|
|
43 |
import java.util.Map; |
|
44 |
|
|
45 |
import org.gvsig.andami.PluginServices; |
|
46 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
47 |
import org.gvsig.catalog.schemas.Resource; |
|
48 |
import org.gvsig.fmap.dal.DALLocator; |
|
49 |
import org.gvsig.fmap.dal.DataManager; |
|
50 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
51 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
52 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
53 |
import org.gvsig.fmap.mapcontext.MapContextLocator; |
|
54 |
import org.gvsig.fmap.mapcontext.MapContextManager; |
|
55 |
import org.gvsig.fmap.mapcontext.exceptions.LoadLayerException; |
|
56 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
57 |
import org.gvsig.tools.ToolsLocator; |
|
58 |
import org.gvsig.tools.extensionpoint.ExtensionPoint; |
|
59 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
60 |
|
|
61 |
|
|
62 |
/** |
|
63 |
* This class has to be inherited by all the classes |
|
64 |
* that have to load a layer in the current view |
|
65 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
66 |
*/ |
|
67 |
public abstract class GvSigLayerLoader extends LayerLoader{ |
|
68 |
protected static final MapContextManager MAP_CONTEXT_MANAGER = |
|
69 |
MapContextLocator.getMapContextManager(); |
|
70 |
protected static final DataManager DATA_MANAGER = |
|
71 |
DALLocator.getDataManager(); |
|
72 |
private static final ExtensionPointManager EXTENSION_POINT_MANAGER = |
|
73 |
ToolsLocator.getExtensionPointManager(); |
|
74 |
|
|
75 |
/** |
|
76 |
* @param resource |
|
77 |
*/ |
|
78 |
public GvSigLayerLoader(Resource resource) { |
|
79 |
super(resource); |
|
80 |
} |
|
81 |
|
|
82 |
public void loadLayer() throws LayerLoaderException { |
|
83 |
FLayer layer; |
|
84 |
try{ |
|
85 |
if (hasSpecificLayer()){ |
|
86 |
layer = createLayerFromExtensionPoint(); |
|
87 |
}else{ |
|
88 |
layer = createLayerFromParameters(); |
|
89 |
} |
|
90 |
} catch (Exception e) { |
|
91 |
e.printStackTrace(); |
|
92 |
throw new LayerLoaderException(e.getMessage(), e, getWindowMessage()); |
|
93 |
} |
|
94 |
if (layer != null){ |
|
95 |
addLayerToView(layer); |
|
96 |
} |
|
97 |
} |
|
98 |
|
|
99 |
protected FLayer createLayerFromParameters() throws InitializeException, ProviderNotRegisteredException, LoadLayerException{ |
|
100 |
DataStoreParameters dataStoreParameters = createDataStoreParameters(); |
|
101 |
return MAP_CONTEXT_MANAGER.createLayer(getLayerName(), dataStoreParameters); |
|
102 |
} |
|
103 |
|
|
104 |
protected FLayer createLayerFromExtensionPoint() throws Exception{ |
|
105 |
DataStoreParameters dataStoreParameters = createDataStoreParameters(); |
|
106 |
ExtensionPoint extensionPoint = EXTENSION_POINT_MANAGER.get("CatalogLayers"); |
|
107 |
return (FLayer)extensionPoint.create(extensionPointName(), new Object[]{dataStoreParameters}); |
|
108 |
} |
|
109 |
|
|
110 |
/** |
|
111 |
* It adds a new layer to the current view |
|
112 |
* @param lyr |
|
113 |
* Layer lo load |
|
114 |
*/ |
|
115 |
protected void addLayerToView(FLayer lyr) { |
|
116 |
AbstractViewPanel theView = |
|
117 |
(AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
118 |
theView.getMapControl().getMapContext().getLayers().addLayer(lyr); |
|
119 |
} |
|
120 |
|
|
121 |
protected abstract boolean hasSpecificLayer(); |
|
122 |
|
|
123 |
protected String extensionPointName(){ |
|
124 |
return null; |
|
125 |
} |
|
126 |
|
|
127 |
protected abstract DataStoreParameters createDataStoreParameters() throws InitializeException, ProviderNotRegisteredException; |
|
128 |
|
|
129 |
protected abstract String getLayerName(); |
|
130 |
} |
|
0 | 131 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.174/org.gvsig.catalog.extension/src/main/java/org/gvsig/catalog/loaders/WFSLayerLoader.java | ||
---|---|---|
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 org.gvsig.catalog.loaders; |
|
42 |
|
|
43 |
import org.gvsig.catalog.schemas.Resource; |
|
44 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
45 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
46 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
47 |
import org.gvsig.i18n.Messages; |
|
48 |
|
|
49 |
|
|
50 |
|
|
51 |
/** |
|
52 |
* This class is used to load a WFS layer in gvSIG |
|
53 |
* |
|
54 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
55 |
*/ |
|
56 |
public class WFSLayerLoader extends GvSigLayerLoader{ |
|
57 |
public static final String DYNFIELDNAME_URL = "url"; |
|
58 |
public static final String DYNFIELDNAME_VERSION = "version"; |
|
59 |
public static final String DYNFIELDNAME_TYPENAME = "typeName"; |
|
60 |
public static final String DYNFIELDNAME_NAMESPACE = "namespace"; |
|
61 |
public static final String DYNFIELDNAME_NAMESPACEPREFIX = "namespacePrefix"; |
|
62 |
public static final String DYNFIELDNAME_FIELDS = "fields"; |
|
63 |
public static final String DYNFIELDNAME_FILTERENCODING = "filterEncoding"; |
|
64 |
public static final String DYNFIELDNAME_MAXFEATURES = "maxFeatures"; |
|
65 |
public static final String DYNFIELDNAME_TIMEOUT = "timeOut"; |
|
66 |
public static final String DYNFIELDNAME_USER = "user"; |
|
67 |
public static final String DYNFIELDNAME_PASSWORD = "password"; |
|
68 |
|
|
69 |
public WFSLayerLoader(Resource resource) { |
|
70 |
super(resource); |
|
71 |
} |
|
72 |
|
|
73 |
protected boolean hasSpecificLayer() { |
|
74 |
return false; |
|
75 |
} |
|
76 |
|
|
77 |
protected String getLayerName() { |
|
78 |
return getResource().getName(); |
|
79 |
} |
|
80 |
|
|
81 |
protected DataStoreParameters createDataStoreParameters() |
|
82 |
throws InitializeException, ProviderNotRegisteredException { |
|
83 |
String host = getResource().getLinkage(); |
|
84 |
String featureType = getResource().getName(); |
|
85 |
|
|
86 |
DataStoreParameters dataStoreParameters = DATA_MANAGER.createStoreParameters("WFSStore"); |
|
87 |
dataStoreParameters.setDynValue(DYNFIELDNAME_URL, host); |
|
88 |
int index = featureType.indexOf(":"); |
|
89 |
if (index > 0){ |
|
90 |
dataStoreParameters.setDynValue(DYNFIELDNAME_NAMESPACEPREFIX, featureType.substring(0, index)); |
|
91 |
} |
|
92 |
dataStoreParameters.setDynValue(DYNFIELDNAME_TYPENAME, featureType); |
|
93 |
dataStoreParameters.setDynValue(DYNFIELDNAME_USER, ""); |
|
94 |
dataStoreParameters.setDynValue(DYNFIELDNAME_PASSWORD, ""); |
|
95 |
return dataStoreParameters; |
|
96 |
} |
|
97 |
|
|
98 |
protected String getErrorMessage() { |
|
99 |
return Messages.getText("wfsError") + ".\n" + |
|
100 |
Messages.getText("server") + ": " + |
|
101 |
getResource().getLinkage() + "\n" + |
|
102 |
Messages.getText("layer") + ": " + |
|
103 |
getResource().getName(); |
|
104 |
} |
|
105 |
|
|
106 |
protected String getWindowMessage() { |
|
107 |
return Messages.getText("wfsLoad"); |
|
108 |
} |
|
109 |
} |
|
0 | 110 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.174/org.gvsig.catalog.extension/src/main/java/org/gvsig/catalog/loaders/LinkLoader.java | ||
---|---|---|
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 org.gvsig.catalog.loaders; |
|
42 |
|
|
43 |
import java.io.IOException; |
|
44 |
|
|
45 |
import com.Ostermiller.util.Browser; |
|
46 |
|
|
47 |
import org.gvsig.catalog.schemas.Resource; |
|
48 |
import org.gvsig.i18n.Messages; |
|
49 |
|
|
50 |
public class LinkLoader extends LayerLoader{ |
|
51 |
|
|
52 |
public LinkLoader(Resource resource) { |
|
53 |
super(resource); |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* It loads the resource to the gvSIG view |
|
58 |
* @throws LayerLoaderException |
|
59 |
*/ |
|
60 |
public void loadLayer() throws LayerLoaderException { |
|
61 |
String link = getResource().getLinkage(); |
|
62 |
Browser.init(); |
|
63 |
try { |
|
64 |
Browser.displayURL(link); |
|
65 |
} catch (IOException e) { |
|
66 |
throw new LayerLoaderException(e.getMessage(),getWindowMessage()); |
|
67 |
} |
|
68 |
} |
|
69 |
|
|
70 |
/* |
|
71 |
* (non-Javadoc) |
|
72 |
* @see es.gva.cit.gvsig.catalogClient.loaders.LayerLoader#getErrorMessage() |
|
73 |
*/ |
|
74 |
protected String getErrorMessage() { |
|
75 |
return Messages.getText("linkError") + ".\n" + |
|
76 |
Messages.getText("link") + ": " + |
|
77 |
getResource().getLinkage(); |
|
78 |
} |
|
79 |
|
|
80 |
/* |
|
81 |
* (non-Javadoc) |
|
82 |
* @see es.gva.cit.gvsig.catalogClient.loaders.LayerLoader#getWindowMessage() |
|
83 |
*/ |
|
84 |
protected String getWindowMessage() { |
|
85 |
return Messages.getText("linkLoad"); |
|
86 |
} |
|
87 |
|
|
88 |
} |
|
0 | 89 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.174/org.gvsig.catalog.extension/src/main/java/org/gvsig/catalog/loaders/WMSLayerLoader.java | ||
---|---|---|
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 org.gvsig.catalog.loaders; |
|
42 |
|
|
43 |
|
|
44 |
import java.util.HashMap; |
|
45 |
import java.util.Map; |
|
46 |
|
|
47 |
import org.gvsig.andami.PluginServices; |
|
48 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
49 |
import org.gvsig.catalog.schemas.Resource; |
|
50 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
51 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
52 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
53 |
import org.gvsig.i18n.Messages; |
|
54 |
|
|
55 |
|
|
56 |
/** |
|
57 |
* This class is used to load a WMS layer in gvSIG |
|
58 |
* |
|
59 |
* @author Jorge Piera Llodra (piera_jor@gva.es) |
|
60 |
*/ |
|
61 |
public class WMSLayerLoader extends GvSigLayerLoader{ |
|
62 |
private static final String FIELD_NAME = "name"; |
|
63 |
private static final String FIELD_SRSSTR = "srsstr"; |
|
64 |
private static final String FIELD_FORMAT = "format"; |
|
65 |
private static final String FIELD_TRANSPARENCY = "transparency"; |
|
66 |
private static final String FIELD_LAYERQUERY = "layer_query"; |
|
67 |
private static final String FIELD_URI = "uri"; |
|
68 |
private static final String FIELD_ONLINERESOURC = "onlineresources"; |
|
69 |
private static final String FIELD_DELETECACHE = "deletecache"; |
|
70 |
|
|
71 |
public WMSLayerLoader(Resource resource) { |
|
72 |
super(resource); |
|
73 |
} |
|
74 |
|
|
75 |
protected boolean hasSpecificLayer() { |
|
76 |
return true; |
|
77 |
} |
|
78 |
|
|
79 |
protected String getLayerName() { |
|
80 |
return getResource().getName(); |
|
81 |
} |
|
82 |
|
|
83 |
protected DataStoreParameters createDataStoreParameters() |
|
84 |
throws InitializeException, ProviderNotRegisteredException { |
|
85 |
DataStoreParameters dataStoreParameters = DATA_MANAGER.createStoreParameters("Wms Store"); |
|
86 |
dataStoreParameters.setDynValue(FIELD_URI, getResource().getLinkage()); |
|
87 |
dataStoreParameters.setDynValue(FIELD_FORMAT, "image/png"); |
|
88 |
dataStoreParameters.setDynValue(FIELD_LAYERQUERY, getResource().getName()); |
|
89 |
AbstractViewPanel activeView = |
|
90 |
(AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
91 |
dataStoreParameters.setDynValue(FIELD_SRSSTR, activeView.getProjection().getAbrev()); |
|
92 |
dataStoreParameters.setDynValue(FIELD_TRANSPARENCY, Boolean.TRUE); |
|
93 |
dataStoreParameters.setDynValue(FIELD_NAME, getLayerName()); |
|
94 |
dataStoreParameters.setDynValue(FIELD_ONLINERESOURC, createOnlineResources()); |
|
95 |
dataStoreParameters.setDynValue(FIELD_DELETECACHE, new Boolean(true)); |
|
96 |
return dataStoreParameters; |
|
97 |
} |
|
98 |
|
|
99 |
protected Map createOnlineResources() { |
|
100 |
Map args = new HashMap(); |
|
101 |
args.put("GepMap", getResource().getLinkage()); |
|
102 |
return args; |
|
103 |
} |
|
104 |
|
|
105 |
protected String extensionPointName() { |
|
106 |
return "OGC:WMS"; |
|
107 |
} |
|
108 |
|
|
109 |
protected String getErrorMessage() { |
|
110 |
return Messages.getText("wmsError") + ".\n" + |
|
111 |
Messages.getText("server") + ": " + |
|
112 |
getResource().getLinkage() + "\n" + |
|
113 |
Messages.getText("layer") + ": " + |
|
114 |
getResource().getName(); |
|
115 |
} |
|
116 |
|
|
117 |
protected String getWindowMessage() { |
|
118 |
return Messages.getText("loadWMS"); |
|
119 |
} |
|
120 |
} |
|
0 | 121 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.174/org.gvsig.catalog.extension/src/main/java/org/gvsig/catalog/gui/ServerPropertiesDialog.java | ||
---|---|---|
1 |
package org.gvsig.catalog.gui; |
|
2 |
|
|
3 |
import org.gvsig.andami.PluginServices; |
|
4 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
5 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
6 |
import org.gvsig.catalog.CatalogClient; |
|
7 |
import org.gvsig.catalog.drivers.profiles.IProfile; |
|
8 |
import org.gvsig.catalog.ui.serverproperties.ServerPropertiesDialogPanel; |
|
9 |
import org.gvsig.i18n.Messages; |
|
10 |
import org.gvsig.utils.swing.jcomboServer.ServerData; |
|
11 |
|
|
12 |
|
|
13 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
14 |
* |
|
15 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
16 |
* |
|
17 |
* This program is free software; you can redistribute it and/or |
|
18 |
* modify it under the terms of the GNU General Public License |
|
19 |
* as published by the Free Software Foundation; either version 2 |
|
20 |
* of the License, or (at your option) any later version. |
|
21 |
* |
|
22 |
* This program is distributed in the hope that it will be useful, |
|
23 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
24 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
25 |
* GNU General Public License for more details. |
|
26 |
* |
|
27 |
* You should have received a copy of the GNU General Public License |
|
28 |
* along with this program; if not, write to the Free Software |
|
29 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
30 |
* |
|
31 |
* For more information, contact: |
|
32 |
* |
|
33 |
* Generalitat Valenciana |
|
34 |
* Conselleria d'Infraestructures i Transport |
|
35 |
* Av. Blasco Ib??ez, 50 |
|
36 |
* 46010 VALENCIA |
|
37 |
* SPAIN |
|
38 |
* |
|
39 |
* +34 963862235 |
|
40 |
* gvsig@gva.es |
|
41 |
* www.gvsig.gva.es |
|
42 |
* |
|
43 |
* or |
|
44 |
* |
|
45 |
* IVER T.I. S.A |
|
46 |
* Salamanca 50 |
|
47 |
* 46005 Valencia |
|
48 |
* Spain |
|
49 |
* |
|
50 |
* +34 963163400 |
|
51 |
* dac@iver.es |
|
52 |
*/ |
|
53 |
/* CVS MESSAGES: |
|
54 |
* |
|
55 |
* $Id$ |
|
56 |
* $Log$ |
|
57 |
* |
|
58 |
*/ |
|
59 |
/** |
|
60 |
* @author Jorge Piera LLodr? (jorge.piera@iver.es) |
|
61 |
*/ |
|
62 |
public class ServerPropertiesDialog extends ServerPropertiesDialogPanel implements IWindow { |
|
63 |
private WindowInfo m_windowinfo = null; |
|
64 |
|
|
65 |
public ServerPropertiesDialog(ServerData serverData, CatalogClient client, |
|
66 |
IProfile profile, Object parentFrame) { |
|
67 |
super(serverData, client, profile, parentFrame); |
|
68 |
} |
|
69 |
|
|
70 |
/* |
|
71 |
* (non-Javadoc) |
|
72 |
* @see es.gva.cit.catalog.ui.serverproperties.ServerPropertiesDialogPanel#closeButtonActionPerformed() |
|
73 |
*/ |
|
74 |
protected void closeButtonActionPerformed() { |
|
75 |
client.setServerData(updateServerData()); |
|
76 |
PluginServices.getMDIManager().closeWindow(this); |
|
77 |
} |
|
78 |
|
|
79 |
/* |
|
80 |
* (non-Javadoc) |
|
81 |
* @see es.gva.cit.catalog.ui.serverproperties.ServerPropertiesDialogPanel#cancelButtonActionPerformed() |
|
82 |
*/ |
|
83 |
protected void cancelButtonActionPerformed() { |
|
84 |
PluginServices.getMDIManager().closeWindow(this); |
|
85 |
} |
|
86 |
|
|
87 |
|
|
88 |
/* |
|
89 |
* (non-Javadoc) |
|
90 |
* @see com.iver.andami.ui.mdiManager.IWindow#getWindowInfo() |
|
91 |
*/ |
|
92 |
public WindowInfo getWindowInfo() { |
|
93 |
if (m_windowinfo == null){ |
|
94 |
m_windowinfo = new WindowInfo(WindowInfo.MODALDIALOG); |
|
95 |
m_windowinfo.setTitle(Messages.getText("propertiesNameWindow")); |
|
96 |
m_windowinfo.setWidth(500); |
|
97 |
m_windowinfo.setHeight(280); |
|
98 |
} |
|
99 |
return m_windowinfo; |
|
100 |
} |
|
101 |
public Object getWindowProfile(){ |
|
102 |
return WindowInfo.DIALOG_PROFILE; |
|
103 |
} |
|
104 |
|
|
105 |
} |
|
0 | 106 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.174/org.gvsig.catalog.extension/src/main/java/org/gvsig/catalog/gui/SearchDialog.java | ||
---|---|---|
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 org.gvsig.catalog.gui; |
|
42 |
|
|
43 |
import java.awt.Frame; |
|
44 |
import java.awt.geom.Rectangle2D; |
|
45 |
|
|
46 |
import javax.swing.Icon; |
|
47 |
import javax.swing.JDialog; |
|
48 |
|
|
49 |
import org.gvsig.andami.IconThemeHelper; |
|
50 |
import org.gvsig.andami.PluginServices; |
|
51 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
52 |
import org.gvsig.andami.ui.mdiManager.WindowInfo; |
|
53 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
54 |
import org.gvsig.catalog.CatalogClient; |
|
55 |
import org.gvsig.catalog.drivers.GetRecordsReply; |
|
56 |
import org.gvsig.catalog.querys.Coordinates; |
|
57 |
import org.gvsig.catalog.ui.search.SearchDialogPanel; |
|
58 |
import org.gvsig.catalog.utils.Frames; |
|
59 |
import org.gvsig.fmap.mapcontext.events.ColorEvent; |
|
60 |
import org.gvsig.fmap.mapcontext.events.ExtentEvent; |
|
61 |
import org.gvsig.fmap.mapcontext.events.ProjectionEvent; |
|
62 |
import org.gvsig.fmap.mapcontext.events.listeners.ViewPortListener; |
|
63 |
import org.gvsig.i18n.Messages; |
|
64 |
|
|
65 |
|
|
66 |
/** |
|
67 |
* This class is used to search a record using the catalog client |
|
68 |
* @author luisw |
|
69 |
* @modified by Jorge Piera |
|
70 |
*/ |
|
71 |
public class SearchDialog extends SearchDialogPanel implements |
|
72 |
IWindow,ViewPortListener { |
|
73 |
public WindowInfo m_windowInfo = null; |
|
74 |
public ConnectDialog parentDialog = null; |
|
75 |
public JDialog frame = null; |
|
76 |
|
|
77 |
public SearchDialog(CatalogClient client, Object serverConnectFrame) { |
|
78 |
super(client,serverConnectFrame); |
|
79 |
parentDialog = (ConnectDialog)serverConnectFrame; |
|
80 |
setViewChangeListener(); |
|
81 |
loadViewPortCoordinates(); |
|
82 |
} |
|
83 |
|
|
84 |
/* (non-Javadoc) |
|
85 |
* @see com.iver.andami.ui.mdiManager.View#getViewInfo() |
|
86 |
*/ |
|
87 |
public WindowInfo getWindowInfo() { |
|
88 |
if (m_windowInfo == null){ |
|
89 |
m_windowInfo = new WindowInfo(WindowInfo.PALETTE); |
|
90 |
m_windowInfo.setTitle(Messages.getText("gazetteer_search") + " [" + |
|
91 |
getCurrentServer() + "]"); |
|
92 |
m_windowInfo.setHeight(80); |
|
93 |
m_windowInfo.setWidth(525); |
|
94 |
} |
|
95 |
return m_windowInfo; |
|
96 |
|
|
97 |
} |
|
98 |
public Object getWindowProfile(){ |
|
99 |
return WindowInfo.TOOL_PROFILE; |
|
100 |
} |
|
101 |
|
|
102 |
protected void showResultsActionPerformed(GetRecordsReply recordsReply) { |
|
103 |
JDialog panel = new JDialog((Frame) PluginServices.getMainFrame(), false); |
|
104 |
Frames.centerFrame(panel,620,420); |
|
105 |
panel.setTitle(Messages.getText( "search_results")); |
|
106 |
panel.setResizable(false); |
|
107 |
ShowResultsDialog dialog = new ShowResultsDialog(panel, |
|
108 |
client, |
|
109 |
recordsReply, |
|
110 |
1); |
|
111 |
panel.getContentPane().add(dialog); |
|
112 |
panel.setVisible(true); |
|
113 |
} |
|
114 |
|
|
115 |
protected void closeButtonActionPerformed() { |
|
116 |
closeJDialog(); |
|
117 |
} |
|
118 |
|
|
119 |
/** |
|
120 |
* Size button action performed |
|
121 |
*/ |
|
122 |
protected void resizeButtonActionPerformed(){ |
|
123 |
if (isMinimized){ |
|
124 |
frame.setSize(frame.getWidth(),495); |
|
125 |
getLowerPanel().setVisible(true); |
|
126 |
getUpperPanel().setUpIcon(); |
|
127 |
}else{ |
|
128 |
frame.setSize(frame.getWidth(),165); |
|
129 |
getLowerPanel().setVisible(false); |
|
130 |
getUpperPanel().setDownIcon(); |
|
131 |
} |
|
132 |
isMinimized = !isMinimized; |
|
133 |
} |
|
134 |
|
|
135 |
/* |
|
136 |
* (non-Javadoc) |
|
137 |
* @see org.gvsig.catalog.ui.search.SearchDialogPanel#getUpIcon() |
|
138 |
*/ |
|
139 |
protected Icon getUpIcon(){ |
|
140 |
// catalog-move-down |
|
141 |
// catalog-move-up |
|
142 |
// catalog-server-properties |
|
143 |
return IconThemeHelper.getImageIcon("catalog-move-up"); |
|
144 |
} |
|
145 |
|
|
146 |
/* |
|
147 |
* (non-Javadoc) |
|
148 |
* @see org.gvsig.catalog.ui.search.SearchDialogPanel#getDownIcon() |
|
149 |
*/ |
|
150 |
protected Icon getDownIcon() { |
|
151 |
// catalog-move-down |
|
152 |
// catalog-move-up |
|
153 |
// catalog-server-properties |
|
154 |
return IconThemeHelper.getImageIcon("catalog-move-down"); |
|
155 |
} |
|
156 |
|
|
157 |
/** |
|
158 |
* Return button action |
|
159 |
*/ |
|
160 |
protected void lastButtonActionPerformed() { |
|
161 |
closeJDialog(); |
|
162 |
ConnectDialog serverConnect = (ConnectDialog)serverConnectFrame; |
|
163 |
serverConnect.setVisible(true); |
|
164 |
serverConnect.getControlsPanel().enableSearchButton(false); |
|
165 |
PluginServices.getMDIManager().addWindow(serverConnect); |
|
166 |
} |
|
167 |
|
|
168 |
public void closeJDialog() { |
|
169 |
frame.setVisible(false); |
|
170 |
} |
|
171 |
|
|
172 |
/** |
|
173 |
* This method loads the view coordinates to the catalog search dialog |
|
174 |
* |
|
175 |
*/ |
|
176 |
private void loadViewPortCoordinates(){ |
|
177 |
AbstractViewPanel activeView = |
|
178 |
(AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
179 |
|
|
180 |
Rectangle2D r2d= activeView.getMapControl().getViewPort().getExtent(); |
|
181 |
|
|
182 |
try{ |
|
183 |
getLowerPanel().setCoordinates(new Coordinates(r2d.getMinX(), |
|
184 |
r2d.getMaxY(), |
|
185 |
r2d.getMaxX(), |
|
186 |
r2d.getMinY())); |
|
187 |
}catch(NullPointerException E){ |
|
188 |
//We cant retrieve the coordinates if it doesn't |
|
189 |
//exist a loaded layer |
|
190 |
} |
|
191 |
} |
|
192 |
/* |
|
193 |
* This method joins the viewPort event to the listener |
|
194 |
*/ |
|
195 |
private void setViewChangeListener(){ |
|
196 |
AbstractViewPanel activeView = |
|
197 |
(AbstractViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
198 |
|
|
199 |
activeView.getMapControl().getViewPort().addViewPortListener(this); |
|
200 |
|
|
201 |
} |
|
202 |
|
|
203 |
public void extentChanged(ExtentEvent e) { |
|
204 |
loadViewPortCoordinates(); |
|
205 |
|
|
206 |
} |
|
207 |
|
|
208 |
public void backColorChanged(ColorEvent e) { |
|
209 |
// TODO Auto-generated method stub |
|
210 |
|
|
211 |
} |
|
212 |
|
|
213 |
public void projectionChanged(ProjectionEvent e) { |
|
214 |
loadViewPortCoordinates(); |
|
215 |
} |
|
216 |
|
|
217 |
public void setFrame(JDialog frame) { |
|
218 |
this.frame = frame; |
|
219 |
} |
|
220 |
} |
|
0 | 221 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.174/org.gvsig.catalog.extension/src/main/java/org/gvsig/catalog/gui/LoaderWizardPanel.java | ||
---|---|---|
1 |
package org.gvsig.catalog.gui; |
|
2 |
|
|
3 |
import java.awt.Dimension; |
|
4 |
import java.awt.event.ActionEvent; |
|
5 |
import java.awt.event.ActionListener; |
|
6 |
|
|
7 |
import javax.swing.JButton; |
|
8 |
import javax.swing.JComponent; |
|
9 |
import javax.swing.JOptionPane; |
|
10 |
import javax.swing.event.ListSelectionEvent; |
|
11 |
import javax.swing.event.ListSelectionListener; |
|
12 |
|
|
13 |
import org.apache.commons.lang3.StringUtils; |
|
14 |
import org.gvsig.app.gui.WizardPanel; |
|
15 |
import org.gvsig.app.gui.wizards.WizardListener; |
|
16 |
import org.gvsig.catalog.loaders.WCSLayerLoader; |
|
17 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
18 |
import org.gvsig.i18n.Messages; |
|
19 |
import org.gvsig.raster.wcs.app.wcsclient.gui.panel.WCSParamsPanel; |
|
20 |
import org.slf4j.Logger; |
|
21 |
import org.slf4j.LoggerFactory; |
|
22 |
|
Also available in: Unified diff