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

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

update license/copyright information

  • Property svn:eol-style set to native
File size: 2.2 KB
RevLine 
[6380]1// License: GPL. For details, see LICENSE file.
[626]2package org.openstreetmap.josm.plugins;
3
4import java.util.List;
5
[6310]6import org.openstreetmap.josm.Main;
[626]7import org.openstreetmap.josm.gui.MapFrame;
8import org.openstreetmap.josm.gui.download.DownloadSelection;
9import org.openstreetmap.josm.gui.preferences.PreferenceSetting;
[1326]10import org.openstreetmap.josm.tools.BugReportExceptionHandler;
[626]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
[1169]21 public final Object plugin;
[626]22
[1169]23 public PluginProxy(Object plugin, PluginInformation info) {
[2830]24 super(info);
[1169]25 this.plugin = plugin;
[626]26 }
27
[1169]28 @Override public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
29 try {
30 plugin.getClass().getMethod("mapFrameInitialized", MapFrame.class, MapFrame.class).invoke(plugin, oldFrame, newFrame);
[626]31 } catch (NoSuchMethodException e) {
[6310]32 Main.debug("Plugin "+plugin+" does not define mapFrameInitialized");
[626]33 } catch (Exception e) {
[2830]34 BugReportExceptionHandler.handleException(new PluginException(this, getPluginInformation().name, e));
[626]35 }
36 }
37
[1169]38 @Override public PreferenceSetting getPreferenceSetting() {
39 try {
40 return (PreferenceSetting)plugin.getClass().getMethod("getPreferenceSetting").invoke(plugin);
41 } catch (NoSuchMethodException e) {
[6310]42 Main.debug("Plugin "+plugin+" does not define getPreferenceSetting");
[1169]43 return null;
44 } catch (Exception e) {
[2830]45 BugReportExceptionHandler.handleException(new PluginException(this, getPluginInformation().name, e));
[1169]46 }
[1326]47 return null;
[626]48 }
[1169]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) {
[6310]54 Main.debug("Plugin "+plugin+" does not define addDownloadSelection");
[1169]55 } catch (Exception e) {
[2830]56 BugReportExceptionHandler.handleException(new PluginException(this, getPluginInformation().name, e));
[1169]57 }
58 }
[626]59}
Note: See TracBrowser for help on using the repository browser.