root / branches / v2_0_0_prep / extensions / extGeocoding / src / org / gvsig / geocoding / extension / GeocodingExtension.java @ 31249
History | View | Annotate | Download (4.23 KB)
1 | 26843 | vsanjaime | /* 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 | 31078 | vsanjaime | |
31 | 27905 | vsanjaime | import org.gvsig.geocoding.GeocodingLibrary; |
32 | 28322 | vsanjaime | import org.gvsig.geocoding.impl.DefaultGeocodingLibrary; |
33 | 27791 | vsanjaime | import org.gvsig.geocoding.preferences.GeocodingPreferences; |
34 | 31249 | vsanjaime | import org.gvsig.geocoding.utils.GeocodingExtTags; |
35 | 31078 | vsanjaime | import org.gvsig.tools.library.Library; |
36 | 27140 | csanchez | import org.slf4j.Logger; |
37 | import org.slf4j.LoggerFactory; |
||
38 | 26843 | vsanjaime | |
39 | 31078 | vsanjaime | 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 | 26843 | vsanjaime | |
48 | 31078 | vsanjaime | |
49 | |||
50 | 26843 | vsanjaime | /**
|
51 | 27905 | vsanjaime | * Geocoding Extension. This extension geoposition in the map a postal address.
|
52 | 26843 | vsanjaime | *
|
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 | 27338 | vsanjaime | public class GeocodingExtension extends Extension implements |
58 | IPreferenceExtension { |
||
59 | 26843 | vsanjaime | |
60 | 28296 | vsanjaime | @SuppressWarnings("unused") |
61 | 27317 | vsanjaime | private static final Logger log = LoggerFactory |
62 | .getLogger(GeocodingExtension.class); |
||
63 | 27338 | vsanjaime | |
64 | 27791 | vsanjaime | private static final IPreference preferencePage = new GeocodingPreferences(); |
65 | private GeocodingController control = null; |
||
66 | 26843 | vsanjaime | |
67 | /**
|
||
68 | 27756 | vsanjaime | * Execute extension
|
69 | 26843 | vsanjaime | */
|
70 | public void execute(String actionCommand) { |
||
71 | |||
72 | 31249 | vsanjaime | if (actionCommand.equalsIgnoreCase(GeocodingExtTags.GEOCODING)) {
|
73 | 27905 | vsanjaime | control = GeocodingController.getInstance(); |
74 | 27791 | vsanjaime | PluginServices.getMDIManager().addWindow(control.getGPanel()); |
75 | control.getGPanel().setVisible(true);
|
||
76 | 28486 | vsanjaime | control.getGmodel().setSimple(true);
|
77 | 26843 | vsanjaime | } |
78 | } |
||
79 | |||
80 | /**
|
||
81 | * This method initializes some parameters of the extension
|
||
82 | */
|
||
83 | public void initialize() { |
||
84 | |||
85 | 28322 | vsanjaime | Library lib = new DefaultGeocodingLibrary();
|
86 | lib.initialize(); |
||
87 | 27905 | vsanjaime | |
88 | 26843 | vsanjaime | 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 | 26851 | vsanjaime | panelAbout.addAboutUrl(PluginServices.getText(this, "geocoding"), |
93 | aboutURL); |
||
94 | 26843 | vsanjaime | } |
95 | |||
96 | /**
|
||
97 | * This method puts available the extension
|
||
98 | 27355 | vsanjaime | *
|
99 | * @return true or false
|
||
100 | 26843 | vsanjaime | */
|
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 | 27355 | vsanjaime | *
|
113 | * @return true or false
|
||
114 | 26843 | vsanjaime | */
|
115 | public boolean isVisible() { |
||
116 | IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
||
117 | 27355 | vsanjaime | // Visible when there are views in the window
|
118 | 26843 | vsanjaime | if (window instanceof View) { |
119 | return true; |
||
120 | } |
||
121 | return false; |
||
122 | } |
||
123 | |||
124 | 27355 | vsanjaime | /**
|
125 | * Get array of extension preferences pages
|
||
126 | *
|
||
127 | * @return
|
||
128 | */
|
||
129 | 26893 | vsanjaime | public IPreference[] getPreferencesPages() { |
130 | 27338 | vsanjaime | IPreference[] preferences = new IPreference[1]; |
131 | preferences[0] = preferencePage;
|
||
132 | 26893 | vsanjaime | return preferences;
|
133 | 26843 | vsanjaime | } |
134 | |||
135 | 27756 | vsanjaime | /**
|
136 | * get the control of the main extension
|
||
137 | 27905 | vsanjaime | *
|
138 | 27756 | vsanjaime | * @return
|
139 | */
|
||
140 | 27791 | vsanjaime | public GeocodingController getControl() {
|
141 | 27730 | vsanjaime | return control;
|
142 | } |
||
143 | |||
144 | 27905 | vsanjaime | /**
|
145 | *
|
||
146 | */
|
||
147 | 28296 | vsanjaime | public void postInitialize() { |
148 | 27905 | vsanjaime | Library api = new GeocodingLibrary();
|
149 | api.postInitialize(); |
||
150 | } |
||
151 | |||
152 | 26843 | vsanjaime | } |