Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / extensions / org.gvsig.geocoding.extension / src / org / gvsig / geocoding / extension / GeocodingExtension.java @ 32526

History | View | Annotate | Download (4.83 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 2
9
 * of the License, or (at your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 * 
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
21
 */
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 Prodevelop S.L. main development
26
 */
27

    
28
package org.gvsig.geocoding.extension;
29

    
30

    
31
import org.gvsig.fmap.mapcontext.MapContextLibrary;
32
import org.gvsig.fmap.mapcontext.impl.MapContextImplLibrary;
33
import org.gvsig.geocoding.GeocodingLibrary;
34
import org.gvsig.geocoding.impl.DefaultGeocodingLibrary;
35
import org.gvsig.geocoding.preferences.GeocodingPreferences;
36
import org.gvsig.geocoding.utils.GeocodingExtTags;
37
import org.gvsig.symbology.SymbologyLibrary;
38
import org.gvsig.symbology.impl.SymbologyDefaultImplLibrary;
39
import org.gvsig.tools.library.Library;
40
import org.slf4j.Logger;
41
import org.slf4j.LoggerFactory;
42

    
43
import org.gvsig.andami.PluginServices;
44
import org.gvsig.andami.plugins.Extension;
45
import org.gvsig.andami.preferences.IPreference;
46
import org.gvsig.andami.preferences.IPreferenceExtension;
47
import org.gvsig.andami.ui.mdiManager.IWindow;
48
import org.gvsig.app.extension.About;
49
import org.gvsig.app.gui.panels.FPanelAbout;
50
import org.gvsig.app.project.documents.view.gui.IView;
51

    
52

    
53
/**
54
 * Geocoding Extension. This extension geoposition in the map a postal address.
55
 * 
56
 * @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a>
57
 * @author <a href="mailto:vsanjaime@prodevelop.es"> Vicent Sanjaime Calvet</a>
58
 */
59

    
60
public class GeocodingExtension extends Extension implements
61
                IPreferenceExtension {
62

    
63
        @SuppressWarnings("unused")
64
        private static final Logger log = LoggerFactory
65
                        .getLogger(GeocodingExtension.class);
66

    
67
        private static final IPreference preferencePage = new GeocodingPreferences();
68
        private GeocodingController control = null;
69

    
70
        /**
71
         * Execute extension
72
         */
73
        public void execute(String actionCommand) {
74

    
75
                if (actionCommand.equalsIgnoreCase(GeocodingExtTags.GEOCODING)) {
76
                        control = GeocodingController.getInstance();
77
                        PluginServices.getMDIManager().addWindow(control.getGPanel());
78
                        control.getGPanel().setVisible(true);
79
                        control.getGmodel().setSimple(true);
80
                }
81
        }
82

    
83
        /**
84
         * This method initializes some parameters of the extension
85
         */
86
        public void initialize() {
87

    
88
                Library lib = new DefaultGeocodingLibrary();
89
                lib.initialize();
90
                
91
                Library libx = new MapContextImplLibrary();
92
                libx.initialize();        
93
                
94
                Library lib2 = new SymbologyDefaultImplLibrary();
95
                lib2.initialize();
96

    
97
                About about = (About) PluginServices.getExtension(About.class);
98
                FPanelAbout panelAbout = about.getAboutPanel();
99
                java.net.URL aboutURL = getClass().getClassLoader().getResource(
100
                                "about/extGeocoding-about.html");
101
                panelAbout.addAboutUrl(PluginServices.getText(this, "geocoding"),
102
                                aboutURL);
103
                
104
//                // initialize legend GraphicLayer
105
//                control = GeocodingController.getInstance();
106
                
107
        }
108

    
109
        /**
110
         * This method puts available the extension
111
         * 
112
         * @return true or false
113
         */
114
        public boolean isEnabled() {
115

    
116
                IWindow window = PluginServices.getMDIManager().getActiveWindow();
117
                if (window instanceof IView) {
118
                        return true;
119
                }
120
                return true;
121
        }
122

    
123
        /**
124
         * This method puts visible the extension
125
         * 
126
         * @return true or false
127
         */
128
        public boolean isVisible() {
129
                IWindow window = PluginServices.getMDIManager().getActiveWindow();
130
                // Visible when there are views in the window
131
                if (window instanceof IView) {
132
                        return true;
133
                }
134
                return false;
135
        }
136

    
137
        /**
138
         * Get array of extension preferences pages
139
         * 
140
         * @return
141
         */
142
        public IPreference[] getPreferencesPages() {
143
                IPreference[] preferences = new IPreference[1];
144
                preferences[0] = preferencePage;
145
                return preferences;
146
        }
147

    
148
        /**
149
         * get the control of the main extension
150
         * 
151
         * @return
152
         */
153
        public GeocodingController getControl() {
154
                return control;
155
        }
156

    
157
        /**
158
         * 
159
         */
160
        public void postInitialize() {
161
                Library api = new GeocodingLibrary();
162
                api.postInitialize();
163
                
164
                Library lib2 = new SymbologyLibrary();
165
                lib2.postInitialize();
166
                
167
                Library libx = new MapContextLibrary();
168
                libx.postInitialize();
169
        }
170

    
171
}