Statistics
| Revision:

root / branches / CatalogYNomenclator_v1_1_0_1005 / extensions / extCatalogYNomenclator / src / es / gva / cit / gvsig / catalogClient / CatalogClientModule.java @ 12464

History | View | Annotate | Download (6.03 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.catalogClient;
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.About;
51
import com.iver.cit.gvsig.gui.panels.FPanelAbout;
52
import com.iver.cit.gvsig.project.documents.view.gui.BaseView;
53
import com.iver.utiles.extensionPoints.ExtensionPoint;
54
import com.iver.utiles.extensionPoints.ExtensionPoints;
55
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton;
56
import com.iver.utiles.swing.jcomboServer.ServerData;
57

    
58
import es.gva.cit.gvsig.catalogClient.gui.ConnectDialog;
59

    
60

    
61
/**
62
 * DOCUMENT ME!
63
 *
64
 * @author Luis W. Sevilla
65
 */
66
public class CatalogClientModule extends Extension {
67
    /* (non-Javadoc)
68
     * @see com.iver.andami.plugins.Extension#inicializar()
69
     */
70
    public void initialize() {
71
        System.out.println("A?ado CatalogClientModule");
72
        ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance();
73
        ExtensionPoint extensionPoint = new ExtensionPoint("CatalogLayers","Lista de capas que se pueden cargar desde el catalogo.");
74
        extensionPoints.put(extensionPoint);
75
        
76
        
77
    }
78

    
79
        public void postInitialize() {
80
                super.postInitialize();
81
                About about = (About) PluginServices.getExtension(About.class);
82
                FPanelAbout panelAbout = about.getAboutPanel();
83
                java.net.URL aboutURL = this.getClass().getResource("/about.htm");
84
                panelAbout.addAboutUrl(PluginServices.getText(this, "Catalog"),
85
                                aboutURL);
86

    
87
        }
88
    /* (non-Javadoc)
89
     * @see com.iver.andami.plugins.Extension#execute(java.lang.String)
90
     */
91
    public void execute(String actionCommand) {
92
        actionConnectDialogStart();
93
    }
94

    
95
    /**
96
     * DOCUMENT ME!
97
     */
98
    private void actionConnectDialogStart() {
99
        System.out.println("Bot?n Cliente de metadatos pulsado");
100
        restoreServerList();
101

    
102
        ConnectDialog connectDialog = new ConnectDialog();
103
        PluginServices.getMDIManager().addWindow(connectDialog);
104
    }
105

    
106
    /**
107
     * It restores a server list. If this list does't exist it create  a server
108
     * list by default.
109
     */
110
    private void restoreServerList() {
111
        ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_CATALOG);
112
        
113
        ServerData[] servers = persistence.getArrayOfServerData();
114
        
115
        boolean found = false;
116
        for (int i=0 ; i<servers.length ; i++){
117
            if (servers[i].getServiceType().equals(ServerData.SERVER_TYPE_CATALOG)){
118
                found = true;
119
            }
120
        }       
121
        
122
        if (!found){
123
             if (servers.length == 0){
124
                servers = getDefaultServers();
125
            }else{
126
                ServerData[] newServers = new ServerData[servers.length + getDefaultServers().length ];
127
                System.arraycopy(servers, 0, newServers, 0, servers.length);
128
                System.arraycopy(getDefaultServers(), 0, newServers, servers.length, getDefaultServers().length);
129
                servers = newServers;
130
            }
131
            persistence.setArrayOfServerData(servers);
132
        }
133
         
134
        
135
        for (int i = 0; i < servers.length; i++) {
136
            if (servers[i].getServiceType().equals(ServerData.SERVER_TYPE_CATALOG)){
137
                ConnectDialog.addServer(servers[i]);
138
            }
139
        }
140
        
141
        
142
    }
143

    
144
    /**
145
     * It creates a server list by default
146
     *
147
     * @return
148
     */
149
    private ServerData[] getDefaultServers() {
150
        ServerData[] servers = new ServerData[4];
151
        Calendar cal = new GregorianCalendar();
152
        Date date = cal.getTime();
153

    
154
        
155
        servers[0] = new ServerData("http://delta.icc.es/indicio/csw", date, date, ServerData.SERVER_TYPE_CATALOG, ServerData.SERVER_SUBTYPE_CATALOG_CSW);
156
        servers[1] = new ServerData("mapas.euitto.upm.es:2100", date, date, ServerData.SERVER_TYPE_CATALOG, ServerData.SERVER_SUBTYPE_CATALOG_Z3950);
157
        servers[2] = new ServerData("193.43.36.137:2100", date, date, ServerData.SERVER_TYPE_CATALOG, ServerData.SERVER_SUBTYPE_CATALOG_Z3950);
158
        servers[3] = new ServerData("http://idee.unizar.es/SRW/servlet/search/ExplainSOAP",date,date,ServerData.SERVER_TYPE_CATALOG,ServerData.SERVER_SUBTYPE_CATALOG_SRW);
159
        return servers;
160
    }
161

    
162
    /* (non-Javadoc)
163
     * @see com.iver.andami.plugins.Extension#isEnabled()
164
     */
165
    public boolean isEnabled() {
166
        return true;
167
    }
168

    
169
    /* (non-Javadoc)
170
     * @see com.iver.andami.plugins.Extension#isVisible()
171
     */
172
    public boolean isVisible() {
173
        com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
174
                                                             .getActiveWindow();
175

    
176
        if (f == null) {
177
            return false;
178
        }
179

    
180
        return (f instanceof BaseView);
181
    }
182
}