Revision 620
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.111/org.gvsig.catalog.extension/buildNumber.properties | ||
---|---|---|
1 |
#Fri Oct 16 00:07:52 CEST 2020 |
|
2 |
buildNumber=2171 |
|
0 | 3 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.111/org.gvsig.catalog.extension/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
</files> |
|
17 |
|
|
18 |
<fileSets> |
|
19 |
<fileSet> |
|
20 |
<directory>src/main/resources-plugin</directory> |
|
21 |
<outputDirectory>.</outputDirectory> |
|
22 |
</fileSet> |
|
23 |
</fileSets> |
|
24 |
|
|
25 |
<dependencySets> |
|
26 |
<dependencySet> |
|
27 |
<useProjectArtifact>false</useProjectArtifact> |
|
28 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
29 |
<outputDirectory>lib</outputDirectory> |
|
30 |
<includes> |
|
31 |
<!-- <include>org.gvsig:org.gvsig.raster.wcs.io</include> --> |
|
32 |
<!-- <include>org.gvsig:org.gvsig.raster.wcs.app.wcsclient</include> --> |
|
33 |
<include>org.gvsig:org.gvsig.catalog.lib</include> |
|
34 |
<!-- |
|
35 |
<include>org.gvsig:org.gvsig.remoteclient</include> |
|
36 |
--> |
|
37 |
<include>org.jzkit:a2j-runtime</include> |
|
38 |
<include>org.jzkit:a2j</include> |
|
39 |
<include>commons-beanutils:commons-beanutils</include> |
|
40 |
<include>commons-httpclient:commons-httpclient</include> |
|
41 |
<include>commons-logging:commons-logging</include> |
|
42 |
<include>org.dspace:cql-java</include> |
|
43 |
<include>jdom:jdom</include> |
|
44 |
<include>org.jzkit:jzkit2-core</include> |
|
45 |
<include>org.jzkit:jzkit2-z3950</include> |
|
46 |
<include>org.jzkit:jzkit2-origin</include> |
|
47 |
<include>soap:soap</include> |
|
48 |
<include>net.swing:amic-util</include> |
|
49 |
<include>org.springframework:spring</include> |
|
50 |
|
|
51 |
</includes> |
|
52 |
</dependencySet> |
|
53 |
</dependencySets> |
|
54 |
|
|
55 |
</assembly> |
|
0 | 56 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.111/org.gvsig.catalog.extension/src/main/java/org/gvsig/catalog/CatalogClientExtension.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; |
|
42 |
|
|
43 |
import java.io.File; |
|
44 |
import java.io.FileInputStream; |
|
45 |
import java.io.FileNotFoundException; |
|
46 |
import java.io.IOException; |
|
47 |
import java.util.HashMap; |
|
48 |
import java.util.Map; |
|
49 |
import java.util.Properties; |
|
50 |
|
|
51 |
import org.apache.commons.io.IOUtils; |
|
52 |
import org.gvsig.andami.IconThemeHelper; |
|
53 |
import org.gvsig.andami.PluginServices; |
|
54 |
import org.gvsig.andami.PluginsLocator; |
|
55 |
import org.gvsig.andami.plugins.Extension; |
|
56 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
57 |
import org.gvsig.catalog.gui.ConnectDialog; |
|
58 |
import org.gvsig.catalog.loaders.ARCIMSLayerLoader; |
|
59 |
import org.gvsig.catalog.loaders.LinkLoader; |
|
60 |
import org.gvsig.catalog.loaders.PostgisLayerLoader; |
|
61 |
import org.gvsig.catalog.loaders.WCSLayerLoader; |
|
62 |
import org.gvsig.catalog.loaders.WFSLayerLoader; |
|
63 |
import org.gvsig.catalog.loaders.WMSLayerLoader; |
|
64 |
import org.gvsig.catalog.schemas.Resource; |
|
65 |
import org.gvsig.tools.ToolsLocator; |
|
66 |
import org.gvsig.tools.dynobject.DynObject; |
|
67 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
68 |
import org.gvsig.utils.swing.jcomboServer.ServerData; |
|
69 |
import org.slf4j.Logger; |
|
70 |
import org.slf4j.LoggerFactory; |
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
/** |
|
76 |
* DOCUMENT ME! |
|
77 |
* |
|
78 |
* @author Luis W. Sevilla |
|
79 |
*/ |
|
80 |
public class CatalogClientExtension extends Extension { |
|
81 |
private static final Logger LOG = LoggerFactory.getLogger(CatalogClientExtension.class); |
|
82 |
private static final String CATALOGLAYERS = "CatalogLayers"; |
|
83 |
private static final String serversPropsFilename = "servers.properties"; |
|
84 |
|
|
85 |
public void initialize() { |
|
86 |
ExtensionPointManager extensionPointManager = ToolsLocator |
|
87 |
.getExtensionPointManager(); |
|
88 |
extensionPointManager.add(CATALOGLAYERS, "List of possible layers that can be loaded from a catalog"); |
|
89 |
registerIcons(); |
|
90 |
setPersistence(); |
|
91 |
} |
|
92 |
|
|
93 |
private void registerIcons(){ |
|
94 |
IconThemeHelper.registerIcon("catalog", "catalog-move-down", this); |
|
95 |
IconThemeHelper.registerIcon("catalog", "catalog-move-up", this); |
|
96 |
IconThemeHelper.registerIcon("catalog", "catalog-server-properties", this); |
|
97 |
IconThemeHelper.registerIcon("catalog", "catalog-search", this); |
|
98 |
} |
|
99 |
|
|
100 |
public void postInitialize(){ |
|
101 |
//Initialazing the layer loaders |
|
102 |
CatalogManager catalogManager = CatalogLocator.getCatalogManager(); |
|
103 |
catalogManager.addLayerLoader(Resource.WMS, WMSLayerLoader.class); |
|
104 |
catalogManager.addLayerLoader(Resource.POSTGIS, PostgisLayerLoader.class); |
|
105 |
catalogManager.addLayerLoader(Resource.WCS, WCSLayerLoader.class); |
|
106 |
catalogManager.addLayerLoader(Resource.WEBSITE, LinkLoader.class); |
|
107 |
catalogManager.addLayerLoader(Resource.DOWNLOAD, LinkLoader.class); |
|
108 |
catalogManager.addLayerLoader(Resource.WFS, WFSLayerLoader.class); |
|
109 |
catalogManager.addLayerLoader(Resource.ARCIMS_IMAGE, ARCIMSLayerLoader.class); |
|
110 |
catalogManager.addLayerLoader(Resource.ARCIMS_VECTORIAL, ARCIMSLayerLoader.class); |
|
111 |
} |
|
112 |
|
|
113 |
public void execute(String actionCommand) { |
|
114 |
actionConnectDialogStart(); |
|
115 |
} |
|
116 |
|
|
117 |
/** |
|
118 |
* DOCUMENT ME! |
|
119 |
*/ |
|
120 |
private void actionConnectDialogStart() { |
|
121 |
System.out.println("Bot?n Cliente de metadatos pulsado"); |
|
122 |
ConnectDialog connectDialog = new ConnectDialog(); |
|
123 |
PluginServices.getMDIManager().addWindow(connectDialog); |
|
124 |
} |
|
125 |
|
|
126 |
/** |
|
127 |
* It restores a server list. If this list does't exist it create a server |
|
128 |
* list by default. |
|
129 |
*/ |
|
130 |
private void setPersistence() { |
|
131 |
PluginServices plugin=PluginsLocator.getManager().getPlugin(this.getClass()); |
|
132 |
DynObject preferences = plugin.getPluginProperties(); |
|
133 |
Map serversMapPersistence = (Map) preferences.getDynValue("servers"); |
|
134 |
|
|
135 |
if (serversMapPersistence == null) { |
|
136 |
serversMapPersistence = new HashMap(); |
|
137 |
preferences.setDynValue("servers", serversMapPersistence); |
|
138 |
} |
|
139 |
addDefaultServers(serversMapPersistence); |
|
140 |
|
|
141 |
CatalogManager cm= CatalogLocator.getCatalogManager(); |
|
142 |
cm.setServersPersistence(serversMapPersistence); |
|
143 |
} |
|
144 |
|
|
145 |
/** |
|
146 |
* Loads servers from a properties file |
|
147 |
* @param serversMapPersistence |
|
148 |
*/ |
|
149 |
private void addDefaultServers(Map serversMapPersistence) { |
|
150 |
PluginServices plugin=PluginsLocator.getManager().getPlugin(this.getClass()); |
|
151 |
//Lee los servidores del properties y los mezcla con los que hay en la persistencia |
|
152 |
Properties prop = new Properties(); |
|
153 |
File propFile = new File(plugin.getPluginDirectory(), serversPropsFilename); |
|
154 |
FileInputStream fis = null; |
|
155 |
try { |
|
156 |
fis = new FileInputStream(propFile); |
|
157 |
prop.load(fis); |
|
158 |
} catch (FileNotFoundException e) { |
|
159 |
LOG.info("Properties file '" + propFile.getAbsolutePath() + "' not found", e); |
|
160 |
} catch (IOException e) { |
|
161 |
LOG.info("Error reading properties file '" + propFile.getAbsolutePath() + "'.", e); |
|
162 |
} finally { |
|
163 |
IOUtils.closeQuietly(fis); |
|
164 |
} |
|
165 |
for (int i = 0; i < prop.size(); i++) { |
|
166 |
String serverKey="server[" + i + "]"; |
|
167 |
String subtypeKey="subtype[" + i + "]"; |
|
168 |
if (prop.containsKey(serverKey) && prop.containsKey(subtypeKey)){ |
|
169 |
Object value = prop.get(serverKey); |
|
170 |
String host=value.toString(); |
|
171 |
if (!serversMapPersistence.containsKey(host)){ |
|
172 |
Object subType=prop.get(subtypeKey); |
|
173 |
if (subType!=null){ |
|
174 |
ServerData server = new ServerData(host, ServerData.SERVER_TYPE_CATALOG, subType.toString()); |
|
175 |
serversMapPersistence.put(host, server); |
|
176 |
} |
|
177 |
} |
|
178 |
} |
|
179 |
} |
|
180 |
} |
|
181 |
|
|
182 |
public boolean isEnabled() { |
|
183 |
return true; |
|
184 |
} |
|
185 |
|
|
186 |
public boolean isVisible() { |
|
187 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
|
188 |
.getActiveWindow(); |
|
189 |
|
|
190 |
if (f == null) { |
|
191 |
return false; |
|
192 |
} |
|
193 |
|
|
194 |
return (f instanceof AbstractViewPanel); |
|
195 |
} |
|
196 |
} |
|
0 | 197 |
org.gvsig.catalog/tags/org.gvsig.catalog-2.0.111/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.111/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.111/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.111/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.111/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.111/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.111/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.111/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 |
|
|
23 |
public class LoaderWizardPanel implements WizardListener, ListSelectionListener{ |
|
24 |
|
|
25 |
private Logger logger = LoggerFactory.getLogger(LoaderWizardPanel.class); |
|
26 |
|
|
27 |
private WizardPanel wizardPanel; |
|
28 |
private JButton OKButton; |
|
29 |
private JButton CancelButton; |
|
30 |
private DataStoreParameters dataStoreParameters; |
|
31 |
|
|
32 |
public LoaderWizardPanel(WizardPanel panel){ |
|
33 |
this(panel, null); |
|
34 |
} |
|
35 |
|
|
36 |
public LoaderWizardPanel(WizardPanel panel, DataStoreParameters dataStoreParameters){ |
|
37 |
this.dataStoreParameters = dataStoreParameters; |
|
38 |
|
|
39 |
this.wizardPanel = panel; |
|
40 |
this.wizardPanel.setVisible(true); |
|
41 |
this.wizardPanel.setPreferredSize(new Dimension(510, 427)); |
|
42 |
|
|
43 |
this.wizardPanel.addWizardListener(this); |
|
44 |
((WCSParamsPanel)this.wizardPanel).getFormatsPanel().getLstCRSs().addListSelectionListener(this); |
|
45 |
((WCSParamsPanel)this.wizardPanel).getFormatsPanel().getLstFormats().addListSelectionListener(this); |
|
46 |
|
|
47 |
// if(this.dataStoreParameters != null && |
|
48 |
// this.wizardPanel instanceof WCSParamsPanel){ |
|
49 |
// //((WCSParamsPanel)this.wizardPanel).refreshData((WCSDataParametersImpl) this.dataStoreParameters); |
|
50 |
// } |
|
51 |
|
|
52 |
this.OKButton = new JButton(Messages.getText("Connect")); |
|
53 |
this.OKButton.addActionListener(new ActionListener() { |
|
54 |
public void actionPerformed(ActionEvent e) { |
|
55 |
JOptionPane pane = getOptionPane((JComponent)e.getSource()); |
|
56 |
pane.setValue(OKButton); |
|
57 |
} |
|
58 |
}); |
|
59 |
this.OKButton.setEnabled(false); |
|
60 |
|
|
61 |
this.CancelButton = new JButton(Messages.getText("Cancel")); |
|
62 |
this.CancelButton.addActionListener(new ActionListener() { |
|
63 |
public void actionPerformed(ActionEvent e) { |
|
64 |
JOptionPane pane = getOptionPane((JComponent)e.getSource()); |
|
65 |
pane.setValue(CancelButton); |
|
66 |
} |
|
67 |
}); |
|
68 |
} |
|
69 |
|
|
70 |
|
|
71 |
protected JOptionPane getOptionPane(JComponent parent) { |
|
72 |
JOptionPane pane = null; |
|
73 |
if (!(parent instanceof JOptionPane)) { |
|
74 |
pane = getOptionPane((JComponent)parent.getParent()); |
|
75 |
} else { |
|
76 |
pane = (JOptionPane) parent; |
|
77 |
} |
|
78 |
return pane; |
|
79 |
} |
|
80 |
|
|
81 |
public void wizardStateChanged(boolean finishable) { |
|
82 |
logger.debug("Thing happened!"); |
Also available in: Unified diff