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