Statistics
| Revision:

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
/* 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.gui.View;
51
import com.iver.utiles.extensionPoints.ExtensionPoint;
52
import com.iver.utiles.extensionPoints.ExtensionPoints;
53
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton;
54
import com.iver.utiles.swing.jcomboServer.ServerData;
55

    
56
import es.gva.cit.gvsig.catalogClient.gui.ConnectDialog;
57

    
58

    
59
/**
60
 * DOCUMENT ME!
61
 *
62
 * @author Luis W. Sevilla
63
 */
64
public class CatalogClientModule extends Extension {
65
    /* (non-Javadoc)
66
     * @see com.iver.andami.plugins.Extension#inicializar()
67
     */
68
    public void initialize() {
69
        System.out.println("A?ado CatalogClientModule");
70
        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
    }
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
        PluginServices.getMDIManager().addWindow(connectDialog);
91
    }
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
        ServerDataPersistence persistence = new ServerDataPersistence(this,ServerData.SERVER_TYPE_CATALOG);
99
        
100
        ServerData[] servers = persistence.getArrayOfServerData();
101
        
102
        boolean found = false;
103
        for (int i=0 ; i<servers.length ; i++){
104
            if (servers[i].getServiceType().equals(ServerData.SERVER_TYPE_CATALOG)){
105
                found = true;
106
            }
107
        }       
108
        
109
        if (!found){
110
             if (servers.length == 0){
111
                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
            persistence.setArrayOfServerData(servers);
119
        }
120
         
121
        
122
        for (int i = 0; i < servers.length; i++) {
123
            if (servers[i].getServiceType().equals(ServerData.SERVER_TYPE_CATALOG)){
124
                ConnectDialog.addServer(servers[i]);
125
            }
126
        }
127
        
128
        
129
    }
130

    
131
    /**
132
     * It creates a server list by default
133
     *
134
     * @return
135
     */
136
    private ServerData[] getDefaultServers() {
137
        ServerData[] servers = new ServerData[4];
138
        Calendar cal = new GregorianCalendar();
139
        Date date = cal.getTime();
140

    
141
        
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
        servers[3] = new ServerData("http://idee.unizar.es/SRW/servlet/search/ExplainSOAP",date,date,ServerData.SERVER_TYPE_CATALOG,ServerData.SERVER_SUBTYPE_CATALOG_SRW);
146
        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
        com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
161
                                                             .getActiveWindow();
162

    
163
        if (f == null) {
164
            return false;
165
        }
166

    
167
        return (f instanceof View);
168
    }
169
}