Changeset 1169 in josm for trunk/src/org/openstreetmap/josm/plugins/Plugin.java
- Timestamp:
- 2008-12-23T15:07:05+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/Plugin.java
r873 r1169 24 24 * 25 25 * The actual implementation of this class is optional, as all functions will be called 26 * via reflection. This is to be able to change this interface without the need of 26 * via reflection. This is to be able to change this interface without the need of 27 27 * recompiling or even breaking the plugins. If your class does not provide a 28 28 * function here (or does provide a function with a mismatching signature), it will not … … 32 32 * are provided (you can register yourself to more callbacks in your plugin class 33 33 * constructor). 34 * 34 * 35 35 * Subclassing Plugin and overriding some functions makes it easy for you to keep sync 36 36 * with the correct actual plugin architecture of JOSM. … … 40 40 public abstract class Plugin { 41 41 42 43 44 45 46 47 48 49 42 /** 43 * This is the info available for this plugin. You can access this from your 44 * constructor. 45 * 46 * (The actual implementation to request the info from a static variable 47 * is a bit hacky, but it works). 48 */ 49 public final PluginInformation info = PluginInformation.currentPluginInitialization; 50 50 51 52 53 54 55 56 51 /** 52 * @return The directory for the plugin to store all kind of stuff. 53 */ 54 public final String getPluginDir() { 55 return new File(Main.pref.getPluginsDirFile(), info.name).getPath(); 56 } 57 57 58 59 60 61 62 63 58 /** 59 * Called after Main.mapFrame is initalized. (After the first data is loaded). 60 * You can use this callback to tweak the newFrame to your needs, as example install 61 * an alternative Painter. 62 */ 63 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {} 64 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 65 /** 66 * Called in the preferences dialog to create a preferences page for the plugin, 67 * if any available. 68 */ 69 public PreferenceSetting getPreferenceSetting() { return null; } 70 71 /** 72 * Called in the download dialog to give the plugin a chance to modify the list 73 * of bounding box selectors. 74 */ 75 public void addDownloadSelection(List<DownloadSelection> list) {} 76 77 /** 78 * Copies the ressource 'from' to the file in the plugin directory named 'to'. 79 */ 80 public void copy(String from, String to) throws FileNotFoundException, IOException { 81 String pluginDirName = Main.pref.getPreferencesDir()+"plugins/"+info.name+"/"; 82 82 File pluginDir = new File(pluginDirName); 83 83 if (!pluginDir.exists()) 84 84 pluginDir.mkdirs(); 85 85 FileOutputStream out = new FileOutputStream(pluginDirName+to); 86 86 InputStream in = getClass().getResourceAsStream(from); 87 87 byte[] buffer = new byte[8192]; 88 88 for(int len = in.read(buffer); len > 0; len = in.read(buffer)) 89 89 out.write(buffer, 0, len); 90 90 in.close(); 91 91 out.close();
Note:
See TracChangeset
for help on using the changeset viewer.