root / branches / v2_0_0_prep / extensions / extGeocoding / src / org / gvsig / geocoding / extension / GeocodingExtension.java @ 27905
History | View | Annotate | Download (4.21 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 |
import org.gvsig.geocoding.GeocodingLibrary; |
31 |
import org.gvsig.geocoding.preferences.GeocodingPreferences; |
32 |
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 |
import org.slf4j.Logger; |
37 |
import org.slf4j.LoggerFactory; |
38 |
|
39 |
import sun.security.jca.GetInstance; |
40 |
|
41 |
import com.iver.andami.PluginServices; |
42 |
import com.iver.andami.plugins.Extension; |
43 |
import com.iver.andami.preferences.IPreference; |
44 |
import com.iver.andami.preferences.IPreferenceExtension; |
45 |
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 |
* 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 |
private static final Logger log = LoggerFactory |
61 |
.getLogger(GeocodingExtension.class); |
62 |
|
63 |
private static final IPreference preferencePage = new GeocodingPreferences(); |
64 |
private GeocodingController control = null; |
65 |
|
66 |
/**
|
67 |
* Execute extension
|
68 |
*/
|
69 |
public void execute(String actionCommand) { |
70 |
|
71 |
if (actionCommand.equalsIgnoreCase(GeocodingTags.GEOCODING)) {
|
72 |
control = GeocodingController.getInstance(); |
73 |
PluginServices.getMDIManager().addWindow(control.getGPanel()); |
74 |
control.getGPanel().setVisible(true);
|
75 |
} |
76 |
} |
77 |
|
78 |
/**
|
79 |
* This method initializes some parameters of the extension
|
80 |
*/
|
81 |
public void initialize() { |
82 |
|
83 |
Library api = new GeocodingLibrary();
|
84 |
api.initialize(); |
85 |
|
86 |
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 |
panelAbout.addAboutUrl(PluginServices.getText(this, "geocoding"), |
91 |
aboutURL); |
92 |
} |
93 |
|
94 |
/**
|
95 |
* This method puts available the extension
|
96 |
*
|
97 |
* @return true or false
|
98 |
*/
|
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 |
*
|
111 |
* @return true or false
|
112 |
*/
|
113 |
public boolean isVisible() { |
114 |
IWindow window = PluginServices.getMDIManager().getActiveWindow(); |
115 |
// Visible when there are views in the window
|
116 |
if (window instanceof View) { |
117 |
return true; |
118 |
} |
119 |
return false; |
120 |
} |
121 |
|
122 |
/**
|
123 |
* Get array of extension preferences pages
|
124 |
*
|
125 |
* @return
|
126 |
*/
|
127 |
public IPreference[] getPreferencesPages() { |
128 |
IPreference[] preferences = new IPreference[1]; |
129 |
preferences[0] = preferencePage;
|
130 |
return preferences;
|
131 |
} |
132 |
|
133 |
/**
|
134 |
* get the control of the main extension
|
135 |
*
|
136 |
* @return
|
137 |
*/
|
138 |
public GeocodingController getControl() {
|
139 |
return control;
|
140 |
} |
141 |
|
142 |
/**
|
143 |
*
|
144 |
*/
|
145 |
public void postInitialize() { |
146 |
Library api = new GeocodingLibrary();
|
147 |
api.postInitialize(); |
148 |
} |
149 |
|
150 |
} |