| 103 | | = Versioning and Dependencies = |
| 104 | | JOSM does not support declarative dependency checking - you have to do it by hand. But don't be scared, it's not that hard. You can request information about other installed plugins via {{{PluginInformation.getLoaded("pluginname")}}}. As example if your plugin is named "secondwaltz" and you depend on the plugin "schostakowitsch" to be loaded, do the following things: |
| 105 | | |
| 106 | | - make sure you get loaded after "schostakowitsch" (by incrementing your Plugin-Stage. See above) |
| 107 | | - check for "schostakowitsch" to be loaded in your plugin's class constructor: |
| 108 | | {{{ |
| 109 | | #!java |
| 110 | | class SecondWaltz { |
| 111 | | |
| 112 | | // constructor called by JOSM to initialize the plugin |
| 113 | | public SecondWaltz() { |
| 114 | | PluginInformation schostakowitsch = PluginInformation.getLoaded("schostakowitsch"); |
| 115 | | if (schostakowitsch == null || !"2".equals(schostakowitsch.version)) { |
| 116 | | JOptionPane.showMessageDialog(Main.parent, tr("Please install plugin 'schostakowitsch' version 2")); |
| 117 | | return; |
| 118 | | } |
| 119 | | |
| 120 | | // initialize the plugin |
| 121 | | ... |
| 122 | | } |
| 123 | | |
| 124 | | } |
| 125 | | }}} |
| 126 | | - Of course, you may initialize the parts of your plugin that don't need "schostakowitsch" to be loaded or react in some other way to the missing plugin (e.g. by using a build-in version of "schostakowitsch"). |
| 127 | | |
| 128 | | |