root / branches / v2_0_0_prep / extensions / extGeocoding / src / org / gvsig / geocoding / extension / GeocodingExtension.java @ 31249
History | View | Annotate | Download (4.23 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.geocoding.GeocodingLibrary; |
32 |
import org.gvsig.geocoding.impl.DefaultGeocodingLibrary; |
33 |
import org.gvsig.geocoding.preferences.GeocodingPreferences; |
34 |
import org.gvsig.geocoding.utils.GeocodingExtTags; |
35 |
import org.gvsig.tools.library.Library; |
36 |
import org.slf4j.Logger; |
37 |
import org.slf4j.LoggerFactory; |
38 |
|
39 |
import org.gvsig.andami.PluginServices; |
40 |
import org.gvsig.andami.plugins.Extension; |
41 |
import org.gvsig.andami.preferences.IPreference; |
42 |
import org.gvsig.andami.preferences.IPreferenceExtension; |
43 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
44 |
import org.gvsig.app.extension.About; |
45 |
import org.gvsig.app.gui.panels.FPanelAbout; |
46 |
import org.gvsig.app.project.documents.view.gui.View; |
47 |
|
48 |
|
49 |
|
50 |
/**
|
51 |
* Geocoding Extension. This extension geoposition in the map a postal address.
|
52 |
*
|
53 |
* @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a>
|
54 |
* @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a>
|
55 |
*/
|
56 |
|
57 |
public class GeocodingExtension extends Extension implements |
58 |
IPreferenceExtension { |
59 |
|
60 |
@SuppressWarnings("unused") |
61 |
private static final Logger log = LoggerFactory |
62 |
.getLogger(GeocodingExtension.class); |
63 |
|
64 |
private static final IPreference preferencePage = new GeocodingPreferences(); |
65 |
private GeocodingController control = null; |
66 |
|
67 |
/**
|
68 |
* Execute extension
|
69 |
*/
|
70 |
public void execute(String actionCommand) { |
71 |
|
72 |
if (actionCommand.equalsIgnoreCase(GeocodingExtTags.GEOCODING)) {
|
73 |
control = GeocodingController.getInstance(); |
74 |
PluginServices.getMDIManager().addWindow(control.getGPanel()); |
75 |
control.getGPanel().setVisible(true);
|
76 |
control.getGmodel().setSimple(true);
|
77 |
} |
78 |
} |
79 |
|
80 |
/**
|
81 |
* This method initializes some parameters of the extension
|
82 |
*/
|
83 |
public void initialize() { |
84 |
|
85 |
Library lib = new DefaultGeocodingLibrary();
|
86 |
lib.initialize(); |
87 |
|
88 |
About about = (About) PluginServices.getExtension(About.class); |
89 |
FPanelAbout panelAbout = about.getAboutPanel(); |
90 |
java.net.URL aboutURL = getClass().getClassLoader().getResource( |
91 |
"about/extGeocoding-about.html");
|
92 |
panelAbout.addAboutUrl(PluginServices.getText(this, "geocoding"), |
93 |
aboutURL); |
94 |
} |
95 |
|
96 |
/**
|
97 |
* This method puts available the extension
|
98 |
*
|
99 |
* @return true or false
|
100 |
*/
|
101 |
public boolean isEnabled() { |
102 |
|
103 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
104 |
if (window instanceof View) { |
105 |
return true; |
106 |
} |
107 |
return true; |
108 |
} |
109 |
|
110 |
/**
|
111 |
* This method puts visible the extension
|
112 |
*
|
113 |
* @return true or false
|
114 |
*/
|
115 |
public boolean isVisible() { |
116 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
117 |
// Visible when there are views in the window
|
118 |
if (window instanceof View) { |
119 |
return true; |
120 |
} |
121 |
return false; |
122 |
} |
123 |
|
124 |
/**
|
125 |
* Get array of extension preferences pages
|
126 |
*
|
127 |
* @return
|
128 |
*/
|
129 |
public IPreference[] getPreferencesPages() { |
130 |
IPreference[] preferences = new IPreference[1]; |
131 |
preferences[0] = preferencePage;
|
132 |
return preferences;
|
133 |
} |
134 |
|
135 |
/**
|
136 |
* get the control of the main extension
|
137 |
*
|
138 |
* @return
|
139 |
*/
|
140 |
public GeocodingController getControl() {
|
141 |
return control;
|
142 |
} |
143 |
|
144 |
/**
|
145 |
*
|
146 |
*/
|
147 |
public void postInitialize() { |
148 |
Library api = new GeocodingLibrary();
|
149 |
api.postInitialize(); |
150 |
} |
151 |
|
152 |
} |