svn-gvsig-desktop / branches / v2_0_0_prep / extensions / extCatalog / src / org / gvsig / catalog / CatalogClientExtension.java @ 28434
History | View | Annotate | Download (7.56 KB)
1 | 15717 | vcaballero | /* 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 | 28387 | jpiera | package org.gvsig.catalog; |
42 | 15717 | vcaballero | |
43 | import java.util.Calendar; |
||
44 | import java.util.Date; |
||
45 | import java.util.GregorianCalendar; |
||
46 | |||
47 | 28387 | jpiera | import org.gvsig.catalog.gui.ConnectDialog; |
48 | 28431 | jpiera | import org.gvsig.catalog.loaders.ARCIMSLayerLoader; |
49 | import org.gvsig.catalog.loaders.LinkLoader; |
||
50 | import org.gvsig.catalog.loaders.PostgisLayerLoader; |
||
51 | import org.gvsig.catalog.loaders.WCSLayerLoader; |
||
52 | import org.gvsig.catalog.loaders.WFSLayerLoader; |
||
53 | import org.gvsig.catalog.loaders.WMSLayerLoader; |
||
54 | import org.gvsig.catalog.schemas.Resource; |
||
55 | import org.gvsig.fmap.dal.store.catalog.CatalogDataStoreLibrary; |
||
56 | 28387 | jpiera | import org.gvsig.tools.ToolsLocator; |
57 | import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
||
58 | import org.slf4j.Logger; |
||
59 | import org.slf4j.LoggerFactory; |
||
60 | 28355 | jpiera | |
61 | 15717 | vcaballero | import com.iver.andami.PluginServices; |
62 | import com.iver.andami.persistence.serverData.ServerDataPersistence; |
||
63 | import com.iver.andami.plugins.Extension; |
||
64 | import com.iver.cit.gvsig.project.documents.view.gui.BaseView; |
||
65 | import com.iver.utiles.swing.jcomboServer.ServerData; |
||
66 | |||
67 | |||
68 | |||
69 | /**
|
||
70 | * DOCUMENT ME!
|
||
71 | *
|
||
72 | * @author Luis W. Sevilla
|
||
73 | */
|
||
74 | public class CatalogClientExtension extends Extension { |
||
75 | 28387 | jpiera | private static final Logger logger = LoggerFactory.getLogger(CatalogClientExtension.class); |
76 | public static final String CATALOGLAYERS = "CatalogLayers"; |
||
77 | 28409 | jpiera | private CatalogLibrary catalogLibrary = null; |
78 | 28434 | jpiera | |
79 | 28387 | jpiera | /* (non-Javadoc)
|
80 | 28434 | jpiera | * @see com.iver.andami.plugins.Extension#inicializar()
|
81 | */
|
||
82 | public void initialize() { |
||
83 | catalogLibrary = new CatalogDataStoreLibrary();
|
||
84 | catalogLibrary.initialize(); |
||
85 | |||
86 | ExtensionPointManager extensionPointManager = ToolsLocator |
||
87 | 28387 | jpiera | .getExtensionPointManager(); |
88 | extensionPointManager.add(CATALOGLAYERS, "List of possible layers that can be loaded from a catalog");
|
||
89 | 28434 | jpiera | registerIcons(); |
90 | } |
||
91 | |||
92 | private void registerIcons(){ |
||
93 | PluginServices.getIconTheme().registerDefault( |
||
94 | 15717 | vcaballero | "catalog-search",
|
95 | this.getClass().getClassLoader().getResource("images/SearchButton.png") |
||
96 | 28434 | jpiera | ); |
97 | PluginServices.getIconTheme().registerDefault( |
||
98 | "catalog-up",
|
||
99 | this.getClass().getClassLoader().getResource("images/up.png") |
||
100 | ); |
||
101 | PluginServices.getIconTheme().registerDefault( |
||
102 | "catalog-down",
|
||
103 | this.getClass().getClassLoader().getResource("images/down.png") |
||
104 | ); |
||
105 | PluginServices.getIconTheme().registerDefault( |
||
106 | "catalog-record",
|
||
107 | this.getClass().getClassLoader().getResource("images/IcoRecord.png") |
||
108 | ); |
||
109 | PluginServices.getIconTheme().registerDefault( |
||
110 | "catalog-no-image",
|
||
111 | this.getClass().getClassLoader().getResource("images/no_image.png") |
||
112 | ); |
||
113 | PluginServices.getIconTheme().registerDefault( |
||
114 | "catalog-properties",
|
||
115 | this.getClass().getClassLoader().getResource("images/serverProperties.png") |
||
116 | ); |
||
117 | } |
||
118 | 15717 | vcaballero | |
119 | 28434 | jpiera | /*
|
120 | * (non-Javadoc)
|
||
121 | * @see com.iver.andami.plugins.Extension#postInitialize()
|
||
122 | */
|
||
123 | public void postInitialize(){ |
||
124 | catalogLibrary.postInitialize(); |
||
125 | 15717 | vcaballero | |
126 | 28434 | jpiera | //Initialazing the layer loaders
|
127 | CatalogManager catalogManager = CatalogLocator.getCatalogManager(); |
||
128 | catalogManager.addLayerLoader(Resource.WMS, WMSLayerLoader.class); |
||
129 | catalogManager.addLayerLoader(Resource.POSTGIS, PostgisLayerLoader.class); |
||
130 | catalogManager.addLayerLoader(Resource.WCS, WCSLayerLoader.class); |
||
131 | catalogManager.addLayerLoader(Resource.WEBSITE, LinkLoader.class); |
||
132 | catalogManager.addLayerLoader(Resource.DOWNLOAD, LinkLoader.class); |
||
133 | catalogManager.addLayerLoader(Resource.WFS, WFSLayerLoader.class); |
||
134 | catalogManager.addLayerLoader(Resource.ARCIMS_IMAGE, ARCIMSLayerLoader.class); |
||
135 | catalogManager.addLayerLoader(Resource.ARCIMS_VECTORIAL, ARCIMSLayerLoader.class); |
||
136 | } |
||
137 | 15717 | vcaballero | |
138 | 28434 | jpiera | /* (non-Javadoc)
|
139 | * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
|
||
140 | */
|
||
141 | public void execute(String actionCommand) { |
||
142 | actionConnectDialogStart(); |
||
143 | } |
||
144 | 15717 | vcaballero | |
145 | 28434 | jpiera | /**
|
146 | * DOCUMENT ME!
|
||
147 | */
|
||
148 | private void actionConnectDialogStart() { |
||
149 | System.out.println("Bot?n Cliente de metadatos pulsado"); |
||
150 | restoreServerList(); |
||
151 | 15717 | vcaballero | |
152 | 28434 | jpiera | ConnectDialog connectDialog = new ConnectDialog();
|
153 | PluginServices.getMDIManager().addWindow(connectDialog); |
||
154 | } |
||
155 | 15717 | vcaballero | |
156 | 28434 | jpiera | /**
|
157 | * It restores a server list. If this list does't exist it create a server
|
||
158 | * list by default.
|
||
159 | */
|
||
160 | private void restoreServerList() { |
||
161 | ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_CATALOG); |
||
162 | 15717 | vcaballero | |
163 | 28434 | jpiera | ServerData[] servers = persistence.getArrayOfServerData();
|
164 | 15717 | vcaballero | |
165 | 28434 | jpiera | boolean found = false; |
166 | for (int i=0 ; i<servers.length ; i++){ |
||
167 | if (servers[i].getServiceType().equals(ServerData.SERVER_TYPE_CATALOG)){
|
||
168 | found = true;
|
||
169 | } |
||
170 | } |
||
171 | 15717 | vcaballero | |
172 | 28434 | jpiera | if (!found){
|
173 | if (servers.length == 0){ |
||
174 | servers = getDefaultServers(); |
||
175 | }else{
|
||
176 | ServerData[] newServers = new ServerData[servers.length + getDefaultServers().length ]; |
||
177 | System.arraycopy(servers, 0, newServers, 0, servers.length); |
||
178 | System.arraycopy(getDefaultServers(), 0, newServers, servers.length, getDefaultServers().length); |
||
179 | servers = newServers; |
||
180 | } |
||
181 | persistence.setArrayOfServerData(servers); |
||
182 | } |
||
183 | 15717 | vcaballero | |
184 | 28434 | jpiera | |
185 | for (int i = 0; i < servers.length; i++) { |
||
186 | if (servers[i].getServiceType().equals(ServerData.SERVER_TYPE_CATALOG)){
|
||
187 | ConnectDialog.addServer(servers[i]); |
||
188 | } |
||
189 | } |
||
190 | |||
191 | |||
192 | } |
||
193 | |||
194 | /**
|
||
195 | * It creates a server list by default
|
||
196 | *
|
||
197 | * @return
|
||
198 | */
|
||
199 | private ServerData[] getDefaultServers() { |
||
200 | ServerData[] servers = new ServerData[4]; |
||
201 | Calendar cal = new GregorianCalendar(); |
||
202 | Date date = cal.getTime();
|
||
203 | |||
204 | |||
205 | servers[0] = new ServerData("http://delta.icc.es/indicio/csw", date, date, ServerData.SERVER_TYPE_CATALOG, ServerData.SERVER_SUBTYPE_CATALOG_CSW); |
||
206 | servers[1] = new ServerData("mapas.euitto.upm.es:2100", date, date, ServerData.SERVER_TYPE_CATALOG, ServerData.SERVER_SUBTYPE_CATALOG_Z3950); |
||
207 | servers[2] = new ServerData("193.43.36.137:2100", date, date, ServerData.SERVER_TYPE_CATALOG, ServerData.SERVER_SUBTYPE_CATALOG_Z3950); |
||
208 | servers[3] = new ServerData("http://idee.unizar.es/SRW/servlet/search/ExplainSOAP",date,date,ServerData.SERVER_TYPE_CATALOG,ServerData.SERVER_SUBTYPE_CATALOG_SRW); |
||
209 | return servers;
|
||
210 | } |
||
211 | |||
212 | /* (non-Javadoc)
|
||
213 | * @see com.iver.andami.plugins.Extension#isEnabled()
|
||
214 | */
|
||
215 | public boolean isEnabled() { |
||
216 | return true; |
||
217 | } |
||
218 | |||
219 | /* (non-Javadoc)
|
||
220 | * @see com.iver.andami.plugins.Extension#isVisible()
|
||
221 | */
|
||
222 | public boolean isVisible() { |
||
223 | com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
||
224 | .getActiveWindow(); |
||
225 | |||
226 | if (f == null) { |
||
227 | return false; |
||
228 | } |
||
229 | |||
230 | return (f instanceof BaseView); |
||
231 | } |
||
232 | 15717 | vcaballero | } |