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

Last change on this file since 2683 was 1326, checked in by stoecker, 15 years ago

reworked plugin handling a lot, more to come

  • 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 public final PluginInformation info;
22
23 public PluginProxy(Object plugin, PluginInformation info) {
24 this.plugin = plugin;
25 this.info = info;
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 } catch (Exception e) {
33 BugReportExceptionHandler.handleException(new PluginException(this, info.name, e));
34 }
35 }
36
37 @Override public PreferenceSetting getPreferenceSetting() {
38 try {
39 return (PreferenceSetting)plugin.getClass().getMethod("getPreferenceSetting").invoke(plugin);
40 } catch (NoSuchMethodException e) {
41 return null;
42 } catch (Exception e) {
43 BugReportExceptionHandler.handleException(new PluginException(this, info.name, e));
44 }
45 return null;
46 }
47
48 @Override public void addDownloadSelection(List<DownloadSelection> list) {
49 try {
50 plugin.getClass().getMethod("addDownloadSelection", List.class).invoke(plugin, list);
51 } catch (NoSuchMethodException e) {
52 // ignore
53 } catch (Exception e) {
54 BugReportExceptionHandler.handleException(new PluginException(this, info.name, e));
55 }
56 }
57}
Note: See TracBrowser for help on using the repository browser.