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

Last change on this file since 504 was 298, checked in by imi, 17 years ago
  • added license description to head of each source file
File size: 1.7 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;
9
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 throw 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 throw new PluginException(this, info.name, e);
44 }
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 throw new PluginException(this, info.name, e);
54 }
55 }
56}
Note: See TracBrowser for help on using the repository browser.