root / branches / v2_0_0_prep / extensions / extCatalog / src / org / gvsig / catalog / CatalogClientExtension.java @ 37871
History | View | Annotate | Download (6.93 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.catalog; |
42 |
|
43 |
import java.util.Calendar; |
44 |
import java.util.Date; |
45 |
import java.util.GregorianCalendar; |
46 |
|
47 |
import org.slf4j.Logger; |
48 |
import org.slf4j.LoggerFactory; |
49 |
|
50 |
import org.gvsig.andami.PluginServices; |
51 |
import org.gvsig.andami.persistence.serverData.ServerDataPersistence; |
52 |
import org.gvsig.andami.plugins.Extension; |
53 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
54 |
import org.gvsig.catalog.gui.ConnectDialog; |
55 |
import org.gvsig.catalog.loaders.ARCIMSLayerLoader; |
56 |
import org.gvsig.catalog.loaders.LinkLoader; |
57 |
import org.gvsig.catalog.loaders.PostgisLayerLoader; |
58 |
import org.gvsig.catalog.loaders.WCSLayerLoader; |
59 |
import org.gvsig.catalog.loaders.WFSLayerLoader; |
60 |
import org.gvsig.catalog.loaders.WMSLayerLoader; |
61 |
import org.gvsig.catalog.schemas.Resource; |
62 |
import org.gvsig.tools.ToolsLocator; |
63 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
64 |
import org.gvsig.utils.swing.jcomboServer.ServerData; |
65 |
|
66 |
|
67 |
|
68 |
|
69 |
/**
|
70 |
* DOCUMENT ME!
|
71 |
*
|
72 |
* @author Luis W. Sevilla
|
73 |
*/
|
74 |
public class CatalogClientExtension extends Extension { |
75 |
private static final Logger LOG = LoggerFactory.getLogger(CatalogClientExtension.class); |
76 |
private static final String CATALOGLAYERS = "CatalogLayers"; |
77 |
|
78 |
public void initialize() { |
79 |
ExtensionPointManager extensionPointManager = ToolsLocator |
80 |
.getExtensionPointManager(); |
81 |
extensionPointManager.add(CATALOGLAYERS, "List of possible layers that can be loaded from a catalog");
|
82 |
registerIcons(); |
83 |
} |
84 |
|
85 |
private void registerIcons(){ |
86 |
PluginServices.getIconTheme().registerDefault( |
87 |
"catalog-search",
|
88 |
this.getClass().getClassLoader().getResource("images/SearchButton.png") |
89 |
); |
90 |
PluginServices.getIconTheme().registerDefault( |
91 |
"catalog-up",
|
92 |
this.getClass().getClassLoader().getResource("images/up.png") |
93 |
); |
94 |
PluginServices.getIconTheme().registerDefault( |
95 |
"catalog-down",
|
96 |
this.getClass().getClassLoader().getResource("images/down.png") |
97 |
); |
98 |
PluginServices.getIconTheme().registerDefault( |
99 |
"catalog-record",
|
100 |
this.getClass().getClassLoader().getResource("images/IcoRecord.png") |
101 |
); |
102 |
PluginServices.getIconTheme().registerDefault( |
103 |
"catalog-no-image",
|
104 |
this.getClass().getClassLoader().getResource("images/no_image.png") |
105 |
); |
106 |
PluginServices.getIconTheme().registerDefault( |
107 |
"catalog-properties",
|
108 |
this.getClass().getClassLoader().getResource("images/serverProperties.png") |
109 |
); |
110 |
} |
111 |
|
112 |
public void postInitialize(){ |
113 |
//Initialazing the layer loaders
|
114 |
CatalogManager catalogManager = CatalogLocator.getCatalogManager(); |
115 |
catalogManager.addLayerLoader(Resource.WMS, WMSLayerLoader.class); |
116 |
catalogManager.addLayerLoader(Resource.POSTGIS, PostgisLayerLoader.class); |
117 |
catalogManager.addLayerLoader(Resource.WCS, WCSLayerLoader.class); |
118 |
catalogManager.addLayerLoader(Resource.WEBSITE, LinkLoader.class); |
119 |
catalogManager.addLayerLoader(Resource.DOWNLOAD, LinkLoader.class); |
120 |
catalogManager.addLayerLoader(Resource.WFS, WFSLayerLoader.class); |
121 |
catalogManager.addLayerLoader(Resource.ARCIMS_IMAGE, ARCIMSLayerLoader.class); |
122 |
catalogManager.addLayerLoader(Resource.ARCIMS_VECTORIAL, ARCIMSLayerLoader.class); |
123 |
} |
124 |
|
125 |
public void execute(String actionCommand) { |
126 |
actionConnectDialogStart(); |
127 |
} |
128 |
|
129 |
/**
|
130 |
* DOCUMENT ME!
|
131 |
*/
|
132 |
private void actionConnectDialogStart() { |
133 |
System.out.println("Bot?n Cliente de metadatos pulsado"); |
134 |
restoreServerList(); |
135 |
|
136 |
ConnectDialog connectDialog = new ConnectDialog();
|
137 |
PluginServices.getMDIManager().addWindow(connectDialog); |
138 |
} |
139 |
|
140 |
/**
|
141 |
* It restores a server list. If this list does't exist it create a server
|
142 |
* list by default.
|
143 |
*/
|
144 |
private void restoreServerList() { |
145 |
ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_CATALOG); |
146 |
|
147 |
ServerData[] servers = persistence.getArrayOfServerData();
|
148 |
|
149 |
boolean found = false; |
150 |
for (int i=0 ; i<servers.length ; i++){ |
151 |
if (servers[i].getServiceType().equals(ServerData.SERVER_TYPE_CATALOG)){
|
152 |
found = true;
|
153 |
} |
154 |
} |
155 |
|
156 |
if (!found){
|
157 |
if (servers.length == 0){ |
158 |
servers = getDefaultServers(); |
159 |
}else{
|
160 |
ServerData[] newServers = new ServerData[servers.length + getDefaultServers().length ]; |
161 |
System.arraycopy(servers, 0, newServers, 0, servers.length); |
162 |
System.arraycopy(getDefaultServers(), 0, newServers, servers.length, getDefaultServers().length); |
163 |
servers = newServers; |
164 |
} |
165 |
persistence.setArrayOfServerData(servers); |
166 |
} |
167 |
|
168 |
|
169 |
for (int i = 0; i < servers.length; i++) { |
170 |
if (servers[i].getServiceType().equals(ServerData.SERVER_TYPE_CATALOG)){
|
171 |
ConnectDialog.addServer(servers[i]); |
172 |
} |
173 |
} |
174 |
|
175 |
|
176 |
} |
177 |
|
178 |
/**
|
179 |
* It creates a server list by default
|
180 |
*
|
181 |
* @return
|
182 |
*/
|
183 |
private ServerData[] getDefaultServers() { |
184 |
ServerData[] servers = new ServerData[0]; |
185 |
Calendar cal = new GregorianCalendar(); |
186 |
Date date = cal.getTime();
|
187 |
|
188 |
//servers[0] = new ServerData("http://delta.icc.es/indicio/csw", date, date, ServerData.SERVER_TYPE_CATALOG, ServerData.SERVER_SUBTYPE_CATALOG_CSW);
|
189 |
//servers[1] = new ServerData("mapas.euitto.upm.es:2100", date, date, ServerData.SERVER_TYPE_CATALOG, ServerData.SERVER_SUBTYPE_CATALOG_Z3950);
|
190 |
//servers[2] = new ServerData("193.43.36.137:2100", date, date, ServerData.SERVER_TYPE_CATALOG, ServerData.SERVER_SUBTYPE_CATALOG_Z3950);
|
191 |
//servers[3] = new ServerData("http://idee.unizar.es/SRW/servlet/search/ExplainSOAP",date,date,ServerData.SERVER_TYPE_CATALOG,ServerData.SERVER_SUBTYPE_CATALOG_SRW);
|
192 |
return servers;
|
193 |
} |
194 |
|
195 |
public boolean isEnabled() { |
196 |
return true; |
197 |
} |
198 |
|
199 |
public boolean isVisible() { |
200 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
201 |
.getActiveWindow(); |
202 |
|
203 |
if (f == null) { |
204 |
return false; |
205 |
} |
206 |
|
207 |
return (f instanceof AbstractViewPanel); |
208 |
} |
209 |
} |