source: josm/trunk/src/org/openstreetmap/josm/plugins/PluginProxy.java@ 5299

Last change on this file since 5299 was 2830, checked in by Gubaer, 14 years ago

fixed an ugly hack in the plugin bootstrap procedure

  • Property svn:eol-style set to native
File size: 2.0 KB
Line 
1// License: GPL. Copyright 2007 by Immanuel Scholz and others
2package org.openstreetmap.josm.plugins;
3
4import java.util.List;
5
6import org.openstreetmap.josm.gui.MapFrame;
7import org.openstreetmap.josm.gui.download.DownloadSelection;
8import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
9import org.openstreetmap.josm.tools.BugReportExceptionHandler;
10
11/**
12 * Helper class for the JOSM system to communicate with the plugin.
13 *
14 * This class should be of no interest for sole plugin writer.
15 *
16 * @author Immanuel.Scholz
17 */
18public class PluginProxy extends Plugin {
19
20 public final Object plugin;
21
22 public PluginProxy(Object plugin, PluginInformation info) {
23 super(info);
24 this.plugin = plugin;
25 }
26
27 @Override public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
28 try {
29 plugin.getClass().getMethod("mapFrameInitialized", MapFrame.class, MapFrame.class).invoke(plugin, oldFrame, newFrame);
30 } catch (NoSuchMethodException e) {
31 } catch (Exception e) {
32 BugReportExceptionHandler.handleException(new PluginException(this, getPluginInformation().name, e));
33 }
34 }
35
36 @Override public PreferenceSetting getPreferenceSetting() {
37 try {
38 return (PreferenceSetting)plugin.getClass().getMethod("getPreferenceSetting").invoke(plugin);
39 } catch (NoSuchMethodException e) {
40 return null;
41 } catch (Exception e) {
42 BugReportExceptionHandler.handleException(new PluginException(this, getPluginInformation().name, e));
43 }
44 return null;
45 }
46
47 @Override public void addDownloadSelection(List<DownloadSelection> list) {
48 try {
49 plugin.getClass().getMethod("addDownloadSelection", List.class).invoke(plugin, list);
50 } catch (NoSuchMethodException e) {
51 // ignore
52 } catch (Exception e) {
53 BugReportExceptionHandler.handleException(new PluginException(this, getPluginInformation().name, e));
54 }
55 }
56}
Note: See TracBrowser for help on using the repository browser.