Statistics
| Revision:

svn-gvsig-desktop / trunk / extensions / extGPE-gvSIG / src / org / gvsig / gpe / GPEReaderExtension.java @ 27067

History | View | Annotate | Download (4.81 KB)

1
package org.gvsig.gpe;
2

    
3
import java.io.File;
4
import java.io.FileInputStream;
5
import java.io.FileNotFoundException;
6
import java.net.URL;
7

    
8
import org.gvsig.fmap.drivers.gpe.addlayer.GPEFileOpen;
9
import org.gvsig.fmap.drivers.gpe.reader.GMLVectorialDriver;
10
import org.gvsig.fmap.drivers.gpe.reader.KMLVectorialDriver;
11
import org.gvsig.gpe.xml.parser.GPEXmlParserFactory;
12
import org.gvsig.gpe.xml.stream.XmlStreamException;
13

    
14
import com.hardcode.driverManager.DriverManager;
15
import com.iver.andami.PluginServices;
16
import com.iver.andami.messages.NotificationManager;
17
import com.iver.andami.plugins.Extension;
18
import com.iver.cit.gvsig.fmap.layers.LayerFactory;
19
import com.iver.utiles.extensionPoints.ExtensionPoints;
20
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton;
21

    
22
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
23
 *
24
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
25
 *
26
 * This program is free software; you can redistribute it and/or
27
 * modify it under the terms of the GNU General Public License
28
 * as published by the Free Software Foundation; either version 2
29
 * of the License, or (at your option) any later version.
30
 *
31
 * This program is distributed in the hope that it will be useful,
32
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
33
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
34
 * GNU General Public License for more details.
35
 *
36
 * You should have received a copy of the GNU General Public License
37
 * along with this program; if not, write to the Free Software
38
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
39
 *
40
 * For more information, contact:
41
 *
42
 *  Generalitat Valenciana
43
 *   Conselleria d'Infraestructures i Transport
44
 *   Av. Blasco Ib??ez, 50
45
 *   46010 VALENCIA
46
 *   SPAIN
47
 *
48
 *      +34 963862235
49
 *   gvsig@gva.es
50
 *      www.gvsig.gva.es
51
 *
52
 *    or
53
 *
54
 *   IVER T.I. S.A
55
 *   Salamanca 50
56
 *   46005 Valencia
57
 *   Spain
58
 *
59
 *   +34 963163400
60
 *   dac@iver.es
61
 */
62
/* CVS MESSAGES:
63
 *
64
 * $Id$
65
 * $Log$
66
 *
67
 */
68
/**
69
 * @author Jorge Piera LLodr? (jorge.piera@iver.es)
70
 */
71
public class GPEReaderExtension extends Extension{
72
        private String parsersFile = "gvSIG" + File.separatorChar + "extensiones" + File.separatorChar + 
73
        "org.gvsig.gpe" + File.separatorChar + "parser.properties";
74
        private String driversDir = "gvSIG" + File.separatorChar + "extensiones" + File.separatorChar + 
75
        "org.gvsig.gpe" + File.separatorChar + "lib";
76
        
77
        /*
78
         * (non-Javadoc)
79
         * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
80
         */        
81
        public void execute(String actionCommand) {
82
                // TODO Auto-generated method stub
83

    
84
        }
85

    
86
        /*
87
         * (non-Javadoc)
88
         * @see com.iver.andami.plugins.IExtension#initialize()
89
         */
90
        public void initialize() {
91
                loadParsers();
92
                ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance();
93
                extensionPoints.add("FileExtendingOpenDialog", "FileOpenGPE", new GPEFileOpen());
94
                //Register the GML driver
95
                DriverManager driverManager = LayerFactory.getDM();
96
                driverManager.addDriver(new File(driversDir), GMLVectorialDriver.DRIVERNAME, GMLVectorialDriver.class);
97
                driverManager.addDriver(new File(driversDir), KMLVectorialDriver.DRIVERNAME, KMLVectorialDriver.class);
98
                //Register the GML driver in the WFS Driver
99
                extensionPoints.add("FMAPWFSDriver","FMAPWFSDriver", GMLVectorialDriver.class);
100
                
101
                //PluginServices pluginServices = PluginServices.getPluginServices(GPEXmlParserFactory.class);
102
                PluginServices pluginServices = PluginServices.getPluginServices("com.iver.cit.gvsig");
103
                URL[] urls = pluginServices.getClassLoader().getURLs();
104
                for (int i=0 ; i<urls.length ; i++){
105
                        System.out.println(urls[i]);
106
                }                
107
                try {
108
                        pluginServices.getClassLoader().loadClass("org.gvsig.gpe.xml.stream.stax.StaxXmlStreamWriter");
109
                        pluginServices.getClassLoader().loadClass("org.gvsig.gpe.gml.GmlProperties");
110
                        GPEXmlParserFactory.setClassLoader(pluginServices.getClassLoader());
111
                        GPEXmlParserFactory.getParser("text/xml; subtype=gml/2.1.0", new FileInputStream("/home/jpiera/output.gml"));
112
                } catch (XmlStreamException e) {
113
                        e.printStackTrace();
114
                } catch (FileNotFoundException e) {
115
                        e.printStackTrace();
116
                } catch (ClassNotFoundException e) {
117
                        // TODO Auto-generated catch block
118
                        e.printStackTrace();
119
                }
120
        }
121
        
122
        private void loadParsers(){
123
                File file = new File(parsersFile);
124
                if (!file.exists()){
125
                        NotificationManager.addWarning("File not found",
126
                                        new FileNotFoundException());
127
                        return;
128
                }
129
                try {
130
                        GPERegister.addParsersFile(file);
131
                } catch (Exception e) {
132
                        NotificationManager.addWarning("GPE parsers file not found",
133
                                        new FileNotFoundException());
134
                }
135
        }        
136

    
137
        /*
138
         * (non-Javadoc)
139
         * @see com.iver.andami.plugins.IExtension#isEnabled()
140
         */
141
        public boolean isEnabled() {
142
                return false;
143
        }
144

    
145
        /*
146
         * (non-Javadoc)
147
         * @see com.iver.andami.plugins.IExtension#isVisible()
148
         */
149
        public boolean isVisible() {
150
                return false;
151
        }
152

    
153
}