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

Last change on this file since 8465 was 6380, checked in by Don-vip, 10 years ago

update license/copyright information

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