svn-gvsig-desktop / branches / CatalogYNomenclator_v1_1_0_1005 / extensions / extCatalogYNomenclator / src / es / gva / cit / gvsig / gazetteer / GazetteerExtension.java @ 12758
History | View | Annotate | Download (5.99 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 es.gva.cit.gvsig.gazetteer; |
42 |
|
43 |
import java.util.Calendar; |
44 |
import java.util.Date; |
45 |
import java.util.GregorianCalendar; |
46 |
|
47 |
import com.iver.andami.PluginServices; |
48 |
import com.iver.andami.persistence.serverData.ServerDataPersistence; |
49 |
import com.iver.andami.plugins.Extension; |
50 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
51 |
import com.iver.utiles.swing.jcomboServer.ServerData; |
52 |
|
53 |
import es.gva.cit.gazetteer.adl.drivers.ADLGazetteerServiceDriver; |
54 |
import es.gva.cit.gazetteer.idec.drivers.IDECGazetteerServiceDriver; |
55 |
import es.gva.cit.gazetteer.utils.GazetteerDriverRegister; |
56 |
import es.gva.cit.gazetteer.wfs.drivers.WFSServiceDriver; |
57 |
import es.gva.cit.gazetteer.wfsg.drivers.WFSGServiceDriver; |
58 |
import es.gva.cit.gvsig.gazetteer.gui.ConnectDialog; |
59 |
|
60 |
|
61 |
/**
|
62 |
* @author Jorge Piera Llodra (piera_jor@gva.es)
|
63 |
*/
|
64 |
public class GazetteerExtension extends Extension{ |
65 |
|
66 |
public static void main(String[] args) { |
67 |
} |
68 |
|
69 |
/* (non-Javadoc)
|
70 |
* @see com.iver.andami.plugins.Extension#inicializar()
|
71 |
*/
|
72 |
public void initialize() { |
73 |
System.out.println("A?ado GazetteerModule"); |
74 |
} |
75 |
|
76 |
/*
|
77 |
* (non-Javadoc)
|
78 |
* @see com.iver.andami.plugins.Extension#postInitialize()
|
79 |
*/
|
80 |
public void postInitialize(){ |
81 |
GazetteerDriverRegister register = GazetteerDriverRegister.getInstance(); |
82 |
register.register(new ADLGazetteerServiceDriver());
|
83 |
register.register(new WFSServiceDriver());
|
84 |
register.register(new WFSGServiceDriver());
|
85 |
register.register(new IDECGazetteerServiceDriver());
|
86 |
} |
87 |
|
88 |
/* (non-Javadoc)
|
89 |
* @see com.iver.andami.plugins.Extension#execute(java.lang.String)
|
90 |
*/
|
91 |
public void execute(String actionCommand) { |
92 |
// JToolBar toolBar = (JToolBar)PluginServices.getMainFrame().getComponentByName("Catalogo");
|
93 |
// System.out.println("gjkmgbghb");
|
94 |
// for (int i=0 ; i<toolBar.getComponentCount() ; i++){
|
95 |
// System.out.println(((JButton)toolBar.getComponentAtIndex(i)).getName());
|
96 |
// }
|
97 |
actionConnectDialogStart(); |
98 |
} |
99 |
|
100 |
/**
|
101 |
*
|
102 |
*
|
103 |
*/
|
104 |
private void actionConnectDialogStart() { |
105 |
System.out.println("Bot?n de Gazeteer pulsado"); |
106 |
restoreServerList(); |
107 |
ConnectDialog connectDialog = new ConnectDialog();
|
108 |
PluginServices.getMDIManager().addWindow(connectDialog); |
109 |
} |
110 |
|
111 |
private void restoreServerList() { |
112 |
ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_GAZETTEER); |
113 |
|
114 |
ServerData[] servers = persistence.getArrayOfServerData();
|
115 |
|
116 |
boolean found = false; |
117 |
for (int i=0 ; i<servers.length ; i++){ |
118 |
if (servers[i].getServiceType().equals(ServerData.SERVER_TYPE_GAZETTEER)){
|
119 |
found = true;
|
120 |
} |
121 |
} |
122 |
|
123 |
if (!found){
|
124 |
if (servers.length == 0){ |
125 |
servers = getDefaultServers(); |
126 |
}else{
|
127 |
ServerData[] newServers = new ServerData[servers.length + getDefaultServers().length ]; |
128 |
System.arraycopy(servers, 0, newServers, 0, servers.length); |
129 |
System.arraycopy(getDefaultServers(), 0, newServers, servers.length, getDefaultServers().length); |
130 |
servers = newServers; |
131 |
} |
132 |
persistence.setArrayOfServerData(servers); |
133 |
} |
134 |
|
135 |
for (int i = 0; i < servers.length; i++) { |
136 |
if (servers[i].getServiceType().equals(ServerData.SERVER_TYPE_GAZETTEER)){
|
137 |
ConnectDialog.addServer(servers[i]); |
138 |
} |
139 |
} |
140 |
} |
141 |
|
142 |
/**
|
143 |
* It creates a server list by default
|
144 |
* @return
|
145 |
*/
|
146 |
private ServerData[] getDefaultServers(){ |
147 |
ServerData[] servers = new ServerData[3]; |
148 |
Calendar cal = new GregorianCalendar(); |
149 |
Date date = cal.getTime();
|
150 |
|
151 |
servers[0] = new ServerData("http://middleware.alexandria.ucsb.edu:8080/gaz/adlgaz/dispatch",date,date,ServerData.SERVER_TYPE_GAZETTEER,ServerData.SERVER_SUBTYPE_GAZETTEER_ADL); |
152 |
servers[1] = new ServerData("http://demo.deegree.org:8080/gazetteer/wfs-g",date,date,ServerData.SERVER_TYPE_GAZETTEER,ServerData.SERVER_SUBTYPE_GAZETTEER_WFSG); |
153 |
servers[2] = new ServerData("http://193.144.250.29/webservices/services/IDEC_GeoServeisPort",date,date,ServerData.SERVER_TYPE_GAZETTEER,ServerData.SERVER_SUBTYPE_GAZETTEER_IDEC); |
154 |
|
155 |
return servers;
|
156 |
} |
157 |
|
158 |
/* (non-Javadoc)
|
159 |
* @see com.iver.andami.plugins.Extension#isEnabled()
|
160 |
*/
|
161 |
public boolean isEnabled() { |
162 |
return true; |
163 |
} |
164 |
|
165 |
/* (non-Javadoc)
|
166 |
* @see com.iver.andami.plugins.Extension#isVisible()
|
167 |
*/
|
168 |
public boolean isVisible() { |
169 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
170 |
.getActiveWindow(); |
171 |
|
172 |
if (f == null) { |
173 |
return false; |
174 |
} |
175 |
|
176 |
if (f instanceof View){ |
177 |
if (((View)f).getMapControl().getViewPort().getAdjustedExtent() != null){ |
178 |
return true; |
179 |
} |
180 |
} |
181 |
|
182 |
return false; |
183 |
} |
184 |
} |