30 |
30 |
import org.gvsig.andami.IconThemeHelper;
|
31 |
31 |
import org.gvsig.andami.Launcher;
|
32 |
32 |
import org.gvsig.andami.PluginServices;
|
|
33 |
import org.gvsig.andami.messages.NotificationManager;
|
33 |
34 |
import org.gvsig.andami.plugins.Extension;
|
34 |
35 |
import org.gvsig.andami.plugins.config.generate.Extensions;
|
35 |
36 |
import org.gvsig.andami.plugins.config.generate.PluginConfig;
|
... | ... | |
52 |
53 |
import org.gvsig.tools.ToolsLocator;
|
53 |
54 |
import org.gvsig.tools.extensionpoint.ExtensionPoint;
|
54 |
55 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager;
|
|
56 |
import org.gvsig.tools.i18n.I18nManager;
|
|
57 |
|
55 |
58 |
import org.slf4j.Logger;
|
56 |
59 |
import org.slf4j.LoggerFactory;
|
57 |
60 |
|
... | ... | |
75 |
78 |
*
|
76 |
79 |
*/
|
77 |
80 |
public class PreferencesExtension extends Extension{
|
78 |
|
|
|
81 |
|
79 |
82 |
private static Logger logger = LoggerFactory.getLogger(PreferencesExtension.class);
|
80 |
83 |
private ExtensionPointManager extensionPoints =ToolsLocator.getExtensionPointManager();
|
81 |
84 |
|
... | ... | |
204 |
207 |
private void initializeExtensions() {
|
205 |
208 |
Iterator i = Launcher.getExtensionIterator();
|
206 |
209 |
ExtensionPoint ep = this.extensionPoints.add("AplicationPreferences", "");
|
|
210 |
I18nManager i18nManager = ToolsLocator.getI18nManager();
|
207 |
211 |
|
208 |
212 |
while (i.hasNext()) {
|
209 |
213 |
Object extension = i.next();
|
210 |
214 |
|
211 |
215 |
if (extension instanceof IPreferenceExtension) {
|
212 |
216 |
IPreferenceExtension pe = (IPreferenceExtension) extension;
|
213 |
|
IPreference[] pp = pe.getPreferencesPages();
|
|
217 |
IPreference[] pp = null;
|
|
218 |
try{
|
|
219 |
pp = pe.getPreferencesPages();
|
|
220 |
} catch (Throwable th){
|
|
221 |
//Do nothing
|
|
222 |
}
|
214 |
223 |
|
215 |
224 |
if (pp == null) {
|
216 |
|
logger.info("Preferences page is NULL. Extension "
|
217 |
|
+ extension.getClass().getName()
|
218 |
|
+ " implements IPreferenceExtension but does not provide pref. pages. ");
|
|
225 |
String msg = "Preferences page is NULL. Extension "
|
|
226 |
+ extension.getClass().getName()
|
|
227 |
+ " implements IPreferenceExtension but does not provide pref. pages. ";
|
|
228 |
logger.info(msg);
|
|
229 |
String[] params = {extension.getClass().getName()};
|
|
230 |
NotificationManager.addInfo(i18nManager.getTranslation("extension_does_not_provide_preferences_pages",params));
|
219 |
231 |
} else {
|
220 |
232 |
for (int j = 0; j < pp.length; j++) {
|
221 |
|
ep.append(pp[j].getID(), "", pp[j]);
|
222 |
|
pp[j].initializeValues();
|
|
233 |
try {
|
|
234 |
pp[j].initializeValues();
|
|
235 |
ep.append(pp[j].getID(), "", pp[j]);
|
|
236 |
} catch (Throwable th) {
|
|
237 |
String msg = "cant_initialize_values_for_{0}_page_in_{1}";
|
|
238 |
String[] params = {pp[j].getTitle(), extension.getClass().getName()};
|
|
239 |
NotificationManager.addWarning(i18nManager.getTranslation(msg,params),th);
|
|
240 |
}
|
223 |
241 |
}
|
224 |
242 |
}
|
225 |
243 |
}
|