svn-gvsig-desktop / tags / v10_RC2c / extensions / extCatalogYNomenclator / src / es / gva / cit / gvsig / catalogClient / CatalogClientModule.java @ 8745
History | View | Annotate | Download (5.58 KB)
1 | 2819 | jorpiell | /* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|---|---|
2 | 3312 | jorpiell | *
|
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 | 1975 | luisw | package es.gva.cit.gvsig.catalogClient; |
42 | |||
43 | 3336 | luisw2 | import java.util.Calendar; |
44 | import java.util.Date; |
||
45 | import java.util.GregorianCalendar; |
||
46 | |||
47 | 1975 | luisw | import com.iver.andami.PluginServices; |
48 | 4302 | jorpiell | import com.iver.andami.persistence.serverData.ServerDataPersistence; |
49 | 1975 | luisw | import com.iver.andami.plugins.Extension; |
50 | import com.iver.cit.gvsig.gui.View; |
||
51 | 4681 | jorpiell | import com.iver.utiles.extensionPoints.ExtensionPoint; |
52 | import com.iver.utiles.extensionPoints.ExtensionPoints; |
||
53 | import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
||
54 | 4302 | jorpiell | import com.iver.utiles.swing.jcomboServer.ServerData; |
55 | 5005 | jorpiell | |
56 | 2026 | luisw | import es.gva.cit.gvsig.catalogClient.gui.ConnectDialog; |
57 | 1975 | luisw | |
58 | 2026 | luisw | |
59 | 1975 | luisw | /**
|
60 | 3312 | jorpiell | * DOCUMENT ME!
|
61 | *
|
||
62 | 1975 | luisw | * @author Luis W. Sevilla
|
63 | */
|
||
64 | 5005 | jorpiell | public class CatalogClientModule extends Extension { |
65 | 3312 | jorpiell | /* (non-Javadoc)
|
66 | * @see com.iver.andami.plugins.Extension#inicializar()
|
||
67 | */
|
||
68 | 5005 | jorpiell | public void initialize() { |
69 | 3312 | jorpiell | System.out.println("A?ado CatalogClientModule"); |
70 | 4681 | jorpiell | ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
71 | ExtensionPoint extensionPoint = new ExtensionPoint("CatalogLayers","Lista de capas que se pueden cargar desde el catalogo."); |
||
72 | extensionPoints.put(extensionPoint); |
||
73 | 3312 | jorpiell | } |
74 | |||
75 | /* (non-Javadoc)
|
||
76 | * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
|
||
77 | */
|
||
78 | public void execute(String actionCommand) { |
||
79 | actionConnectDialogStart(); |
||
80 | } |
||
81 | |||
82 | /**
|
||
83 | * DOCUMENT ME!
|
||
84 | */
|
||
85 | private void actionConnectDialogStart() { |
||
86 | System.out.println("Bot?n Cliente de metadatos pulsado"); |
||
87 | restoreServerList(); |
||
88 | |||
89 | ConnectDialog connectDialog = new ConnectDialog();
|
||
90 | 6880 | cesar | PluginServices.getMDIManager().addWindow(connectDialog); |
91 | 3312 | jorpiell | } |
92 | |||
93 | /**
|
||
94 | * It restores a server list. If this list does't exist it create a server
|
||
95 | * list by default.
|
||
96 | */
|
||
97 | private void restoreServerList() { |
||
98 | 4302 | jorpiell | ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_CATALOG); |
99 | 3224 | jorpiell | |
100 | 3312 | jorpiell | ServerData[] servers = persistence.getArrayOfServerData();
|
101 | |||
102 | 3365 | jorpiell | boolean found = false; |
103 | for (int i=0 ; i<servers.length ; i++){ |
||
104 | 3477 | jorpiell | if (servers[i].getServiceType().equals(ServerData.SERVER_TYPE_CATALOG)){
|
105 | 3365 | jorpiell | found = true;
|
106 | } |
||
107 | } |
||
108 | |||
109 | if (!found){
|
||
110 | 3477 | jorpiell | if (servers.length == 0){ |
111 | 3365 | jorpiell | servers = getDefaultServers(); |
112 | }else{
|
||
113 | ServerData[] newServers = new ServerData[servers.length + getDefaultServers().length ]; |
||
114 | System.arraycopy(servers, 0, newServers, 0, servers.length); |
||
115 | System.arraycopy(getDefaultServers(), 0, newServers, servers.length, getDefaultServers().length); |
||
116 | servers = newServers; |
||
117 | } |
||
118 | 3312 | jorpiell | persistence.setArrayOfServerData(servers); |
119 | } |
||
120 | |||
121 | |||
122 | for (int i = 0; i < servers.length; i++) { |
||
123 | 3477 | jorpiell | if (servers[i].getServiceType().equals(ServerData.SERVER_TYPE_CATALOG)){
|
124 | 3365 | jorpiell | ConnectDialog.addServer(servers[i]); |
125 | } |
||
126 | 3312 | jorpiell | } |
127 | |||
128 | |||
129 | 3224 | jorpiell | } |
130 | 3312 | jorpiell | |
131 | /**
|
||
132 | * It creates a server list by default
|
||
133 | *
|
||
134 | * @return
|
||
135 | */
|
||
136 | private ServerData[] getDefaultServers() { |
||
137 | 4238 | jorpiell | ServerData[] servers = new ServerData[4]; |
138 | 3312 | jorpiell | Calendar cal = new GregorianCalendar(); |
139 | Date date = cal.getTime();
|
||
140 | |||
141 | 3752 | jorpiell | |
142 | servers[0] = new ServerData("http://delta.icc.es/indicio/csw", date, date, ServerData.SERVER_TYPE_CATALOG, ServerData.SERVER_SUBTYPE_CATALOG_CSW); |
||
143 | servers[1] = new ServerData("mapas.euitto.upm.es:2100", date, date, ServerData.SERVER_TYPE_CATALOG, ServerData.SERVER_SUBTYPE_CATALOG_Z3950); |
||
144 | servers[2] = new ServerData("193.43.36.137:2100", date, date, ServerData.SERVER_TYPE_CATALOG, ServerData.SERVER_SUBTYPE_CATALOG_Z3950); |
||
145 | 4238 | jorpiell | servers[3] = new ServerData("http://idee.unizar.es/SRW/servlet/search/ExplainSOAP",date,date,ServerData.SERVER_TYPE_CATALOG,ServerData.SERVER_SUBTYPE_CATALOG_SRW); |
146 | 3312 | jorpiell | return servers;
|
147 | } |
||
148 | |||
149 | /* (non-Javadoc)
|
||
150 | * @see com.iver.andami.plugins.Extension#isEnabled()
|
||
151 | */
|
||
152 | public boolean isEnabled() { |
||
153 | return true; |
||
154 | } |
||
155 | |||
156 | /* (non-Javadoc)
|
||
157 | * @see com.iver.andami.plugins.Extension#isVisible()
|
||
158 | */
|
||
159 | public boolean isVisible() { |
||
160 | 6877 | cesar | com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
161 | 6880 | cesar | .getActiveWindow(); |
162 | 3312 | jorpiell | |
163 | if (f == null) { |
||
164 | return false; |
||
165 | } |
||
166 | |||
167 | 5900 | jorpiell | return (f instanceof View); |
168 | 3312 | jorpiell | } |
169 | 1975 | luisw | } |