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