Changes between Initial Version and Version 1 of DevelopersGuide/PluginInstallationWithoutRestart


Ignore:
Timestamp:
2015-02-12T17:05:36+01:00 (11 years ago)
Author:
bastiK
Comment:

initial doc

Legend:

Unmodified
Added
Removed
Modified
  • DevelopersGuide/PluginInstallationWithoutRestart

    v1 v1  
     1= Plugin installation without restart =
     2
     3Since version r8024, JOSM can load plugins at runtime. This means that after [wiki:Help/Preferences/Plugins#Installingplugins installation], there is no need to restart, but the plugins can be used immediately. However, this only works for plugins that support this new feature.
     4
     5== Make plugins ready for installation without restart ==
     6
     7To indicate to JOSM that the plugin has full support for installation without restart, add the following attribute to the plugin Manifest file:
     8{{{
     9Plugin-Canloadatruntime=true
     10}}}
     11If you are using the `build-common.xml` file in your `ant` build script, the corresponding ant-property is:
     12{{{
     13<property name="plugin.canloadatruntime" value="true"/>
     14}}}
     15
     16When this flag is set, JOSM will not prompt the user for restart and will attempt to load the plugin by:
     171. Calling the Plugin Constructor
     182. Calling the `mapFrameInitialized` method in case a `MapFrame` is currently present.
     19
     20== Required code changes ==
     21
     22''So what do you need to change in the plugin source code?'' If you're lucky, nothing at all. The most common ways, a plugin interacts with JOSM work ''without'' adaption:
     23* Adding a menu entry to the main menu in the plugin Constructor
     24* Adding MapModes or ToggleDialogs to the MapFrame in the `mapFrameInitialized` method
     25* Adding a preferences tab to the preferences in the `getPreferenceSetting` method
     26
     27An example, where an adaption ''would'' be necessary, are layer change listeners. Until now, the order was:
     281. Run plugin constructor
     292. Start JOSM GUI
     303. Add MapFrame, run plugin's `mapFrameInitialized` method
     314. Add Layer, run plugin's layer change listeners (if registered)
     32
     33Now it can also be
     341. Start JOSM GUI
     352. Add MapFrame
     363. Add Layer
     374. Install plugin
     385. Run plugin constructor
     396. Run plugin's `mapFrameInitialized` method
     40
     41So basically you may miss a call to the layer change listener because the layers are already there when the plugin is loaded. This can usually be fixed by calling the listener one time explicitly after it has been registered.
     42
     43== How to test ==
     44
     45One problem with testing the installation, is that JOSM will keep downloading the plugin binary from the server, instead of using the locally compiled one copied to the plugin directory. Here are two ways to circumvent this:
     461. You can rename the plugin for the purpose of testing. Then JOSM will not find any information on this plugin and will be forced to load the compiled binary.
     472. Alternatively, make sure the version number of the compiled plugin matches the one of the plugin downloaded from the server. Then JOSM will not download and replace the plugin, but use the "cached" binary.
     48
     49