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