root / branches / v2_0_0_prep / extensions / extGeocoding / src / org / gvsig / geocoding / extension / GeocodingExtension.java @ 27905
History | View | Annotate | Download (4.21 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 | 27905 | vsanjaime | import org.gvsig.geocoding.GeocodingLibrary; |
31 | 27791 | vsanjaime | import org.gvsig.geocoding.preferences.GeocodingPreferences; |
32 | 27905 | vsanjaime | import org.gvsig.geocoding.utils.GeocodingTags; |
33 | import org.gvsig.metadata.MDLibrary; |
||
34 | import org.gvsig.metadata.simple.SimpleMDLibrary; |
||
35 | import org.gvsig.tools.locator.Library; |
||
36 | 27140 | csanchez | import org.slf4j.Logger; |
37 | import org.slf4j.LoggerFactory; |
||
38 | 26843 | vsanjaime | |
39 | 27791 | vsanjaime | import sun.security.jca.GetInstance; |
40 | |||
41 | 26843 | vsanjaime | import com.iver.andami.PluginServices; |
42 | import com.iver.andami.plugins.Extension; |
||
43 | 26893 | vsanjaime | import com.iver.andami.preferences.IPreference; |
44 | import com.iver.andami.preferences.IPreferenceExtension; |
||
45 | 26843 | vsanjaime | import com.iver.andami.ui.mdiManager.IWindow; |
46 | import com.iver.cit.gvsig.About; |
||
47 | import com.iver.cit.gvsig.gui.panels.FPanelAbout; |
||
48 | import com.iver.cit.gvsig.project.documents.view.gui.View; |
||
49 | |||
50 | /**
|
||
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 | 27317 | vsanjaime | private static final Logger log = LoggerFactory |
61 | .getLogger(GeocodingExtension.class); |
||
62 | 27338 | vsanjaime | |
63 | 27791 | vsanjaime | private static final IPreference preferencePage = new GeocodingPreferences(); |
64 | private GeocodingController control = null; |
||
65 | 26843 | vsanjaime | |
66 | /**
|
||
67 | 27756 | vsanjaime | * Execute extension
|
68 | 26843 | vsanjaime | */
|
69 | public void execute(String actionCommand) { |
||
70 | |||
71 | 27905 | vsanjaime | if (actionCommand.equalsIgnoreCase(GeocodingTags.GEOCODING)) {
|
72 | control = GeocodingController.getInstance(); |
||
73 | 27791 | vsanjaime | PluginServices.getMDIManager().addWindow(control.getGPanel()); |
74 | control.getGPanel().setVisible(true);
|
||
75 | 26843 | vsanjaime | } |
76 | } |
||
77 | |||
78 | /**
|
||
79 | * This method initializes some parameters of the extension
|
||
80 | */
|
||
81 | public void initialize() { |
||
82 | |||
83 | 27905 | vsanjaime | Library api = new GeocodingLibrary();
|
84 | api.initialize(); |
||
85 | |||
86 | 26843 | vsanjaime | About about = (About) PluginServices.getExtension(About.class); |
87 | FPanelAbout panelAbout = about.getAboutPanel(); |
||
88 | java.net.URL aboutURL = getClass().getClassLoader().getResource( |
||
89 | "about/extGeocoding-about.html");
|
||
90 | 26851 | vsanjaime | panelAbout.addAboutUrl(PluginServices.getText(this, "geocoding"), |
91 | aboutURL); |
||
92 | 26843 | vsanjaime | } |
93 | |||
94 | /**
|
||
95 | * This method puts available the extension
|
||
96 | 27355 | vsanjaime | *
|
97 | * @return true or false
|
||
98 | 26843 | vsanjaime | */
|
99 | public boolean isEnabled() { |
||
100 | |||
101 | IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
||
102 | if (window instanceof View) { |
||
103 | return true; |
||
104 | } |
||
105 | return true; |
||
106 | } |
||
107 | |||
108 | /**
|
||
109 | * This method puts visible the extension
|
||
110 | 27355 | vsanjaime | *
|
111 | * @return true or false
|
||
112 | 26843 | vsanjaime | */
|
113 | public boolean isVisible() { |
||
114 | IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
||
115 | 27355 | vsanjaime | // Visible when there are views in the window
|
116 | 26843 | vsanjaime | if (window instanceof View) { |
117 | return true; |
||
118 | } |
||
119 | return false; |
||
120 | } |
||
121 | |||
122 | 27355 | vsanjaime | /**
|
123 | * Get array of extension preferences pages
|
||
124 | *
|
||
125 | * @return
|
||
126 | */
|
||
127 | 26893 | vsanjaime | public IPreference[] getPreferencesPages() { |
128 | 27338 | vsanjaime | IPreference[] preferences = new IPreference[1]; |
129 | preferences[0] = preferencePage;
|
||
130 | 26893 | vsanjaime | return preferences;
|
131 | 26843 | vsanjaime | } |
132 | |||
133 | 27756 | vsanjaime | /**
|
134 | * get the control of the main extension
|
||
135 | 27905 | vsanjaime | *
|
136 | 27756 | vsanjaime | * @return
|
137 | */
|
||
138 | 27791 | vsanjaime | public GeocodingController getControl() {
|
139 | 27730 | vsanjaime | return control;
|
140 | } |
||
141 | |||
142 | 27905 | vsanjaime | /**
|
143 | *
|
||
144 | */
|
||
145 | public void postInitialize() { |
||
146 | Library api = new GeocodingLibrary();
|
||
147 | api.postInitialize(); |
||
148 | } |
||
149 | |||
150 | 26843 | vsanjaime | } |