Plugins: deprecated API to be removed

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

Plugins: deprecated API to be removed

Paul Hartmann-2
Dear plugin developers,

Recently we have started an effort to make the JOSM source code more
modular. [1] This requires a lot of refactoring and many of the original
methods and classes have been deprecated. The work is not finished by
any means, but we would like to make a cut and remove currently
deprecated API at the end of 2017. [2]

Please update any plugins that you are maintaining! The majority of
fixes should be not more than replacing one method by another, as
indicated in the deprecation JavaDoc comment.

Some notable API changes:
* So far, plugins place all their files in one directory, namely
Plugin.getPluginDir(). Now there are separate directories for plugin
user data, preferences, and cache. (The old directory is the same as the
new plugin user data directory.) Among other things, this allows backup
processes to ignore possibly large amounts of non-essential data
(cache). [3]
* The preference interface has been reworked: The field Main.pref is not
technically deprecated yet, but should be replaced by Config.getPref().
The new interface is more restrictive, but sufficient for getting and
setting preference values.

As most plugin developers are aware, the plugin "Mainversion" needs to
be updated whenever older versions of JOSM will become incompatible with
the updated plugin binary (as is usually the case for deprecation
fixes). [4]

[1] https://josm.openstreetmap.de/ticket/15182 (Standalone JOSM validator),
https://josm.openstreetmap.de/ticket/15229 (modular structure for JOSM core)
[2] https://josm.openstreetmap.de/ticket/15310 (The Great Deprecation
Cleanup)
[3] https://josm.openstreetmap.de/ticket/15436 (Store cache data of
plugins in cache location)
[4]
<https://josm.openstreetmap.de/wiki/DevelopersGuide/DevelopingPlugins#Publishingthenewplugin>

Paul

Reply | Threaded
Open this post in threaded view
|

Re: Plugins: deprecated API to be removed

Holger Mappt
Hi,

Is the sonar the right place to see what is deprecated, i.e. what needs
to be changed? [1]

Can someone who was/is involved in the API update please update the
plugin developers guide to reflect the changes (e.g. "The JOSM API")? [2]

Thanks,
Holger

[1]
https://josm.openstreetmap.de/sonar/project/issues?id=josm-plugins&resolved=false&rules=squid%3ACallToDeprecatedMethod
[2] https://josm.openstreetmap.de/wiki/DevelopersGuide/DevelopingPlugins


On 2017-10-19 at 15:22 +0200 Paul Hartmann wrote:

> Dear plugin developers,
>
> Recently we have started an effort to make the JOSM source code more
> modular. [1] This requires a lot of refactoring and many of the original
> methods and classes have been deprecated. The work is not finished by
> any means, but we would like to make a cut and remove currently
> deprecated API at the end of 2017. [2]
>
> Please update any plugins that you are maintaining! The majority of
> fixes should be not more than replacing one method by another, as
> indicated in the deprecation JavaDoc comment.
>
> Some notable API changes:
> * So far, plugins place all their files in one directory, namely
> Plugin.getPluginDir(). Now there are separate directories for plugin
> user data, preferences, and cache. (The old directory is the same as the
> new plugin user data directory.) Among other things, this allows backup
> processes to ignore possibly large amounts of non-essential data
> (cache). [3]
> * The preference interface has been reworked: The field Main.pref is not
> technically deprecated yet, but should be replaced by Config.getPref().
> The new interface is more restrictive, but sufficient for getting and
> setting preference values.
>
> As most plugin developers are aware, the plugin "Mainversion" needs to
> be updated whenever older versions of JOSM will become incompatible with
> the updated plugin binary (as is usually the case for deprecation
> fixes). [4]
>
> [1] https://josm.openstreetmap.de/ticket/15182 (Standalone JOSM validator),
> https://josm.openstreetmap.de/ticket/15229 (modular structure for JOSM
> core)
> [2] https://josm.openstreetmap.de/ticket/15310 (The Great Deprecation
> Cleanup)
> [3] https://josm.openstreetmap.de/ticket/15436 (Store cache data of
> plugins in cache location)
> [4]
> <https://josm.openstreetmap.de/wiki/DevelopersGuide/DevelopingPlugins#Publishingthenewplugin>
>

Reply | Threaded
Open this post in threaded view
|

Re: Plugins: deprecated API to be removed

Holger Mappt
In reply to this post by Paul Hartmann-2
Hi,

Is there a plugin that is updated already? I need some examples to see
what I should do with the deprecated items. E.g. I have
Main.map.mapView.addMouseListener(mouseAdapter);
in my plugin. Main.map is a deprecated field and should be changed to
MainApplication.getMap(). But the access to
MainApplication.getMap().mapView is discouraged. The documentation [1]
says I should use LayerManager [2] instead. But how do I register a
mouse listener with the LayerManager? Or should I use the MainPanel [3]
for the mouse listener? If so it would be good to have a direct mapping
from Main.map.mapView.addMouseListener() to the corresponding call on
the deprecation page [4]. BTW, do I access MainPanel directly
(MainPanel.addMouseListener()) or what would be the right way to get a
reference to the MainPanel?

Thanks,
Holger

[1]
https://josm.openstreetmap.de/doc/org/openstreetmap/josm/gui/MapFrame.html#mapView
[2]
https://josm.openstreetmap.de/doc/org/openstreetmap/josm/gui/layer/LayerManager.html
[3]
https://josm.openstreetmap.de/doc/org/openstreetmap/josm/gui/MainPanel.html
[4] https://josm.openstreetmap.de/doc/deprecated-list.html


On 2017-10-19 at 15:22 +0200 Paul Hartmann wrote:
> Please update any plugins that you are maintaining! The majority of
> fixes should be not more than replacing one method by another, as
> indicated in the deprecation JavaDoc comment.

Reply | Threaded
Open this post in threaded view
|

Re: Plugins: deprecated API to be removed

Marián Kyral
Hi,
try doc page: https://josm.openstreetmap.de/doc/deprecated-list.html

Some plugins were already updated. E.g. my plugins:

https://github.com/mkyral/josm-tracer/commits/development
https://github.com/mkyral/josm-pointInfo/commits/master

Regards,
Marián

Dne 21.10.2017 v 18:46 Holger Mappt napsal(a):

> Hi,
>
> Is there a plugin that is updated already? I need some examples to see
> what I should do with the deprecated items. E.g. I have
> Main.map.mapView.addMouseListener(mouseAdapter);
> in my plugin. Main.map is a deprecated field and should be changed to
> MainApplication.getMap(). But the access to
> MainApplication.getMap().mapView is discouraged. The documentation [1]
> says I should use LayerManager [2] instead. But how do I register a
> mouse listener with the LayerManager? Or should I use the MainPanel
> [3] for the mouse listener? If so it would be good to have a direct
> mapping from Main.map.mapView.addMouseListener() to the corresponding
> call on the deprecation page [4]. BTW, do I access MainPanel directly
> (MainPanel.addMouseListener()) or what would be the right way to get a
> reference to the MainPanel?
>
> Thanks,
> Holger
>
> [1]
> https://josm.openstreetmap.de/doc/org/openstreetmap/josm/gui/MapFrame.html#mapView
> [2]
> https://josm.openstreetmap.de/doc/org/openstreetmap/josm/gui/layer/LayerManager.html
> [3]
> https://josm.openstreetmap.de/doc/org/openstreetmap/josm/gui/MainPanel.html
> [4] https://josm.openstreetmap.de/doc/deprecated-list.html
>
>
> On 2017-10-19 at 15:22 +0200 Paul Hartmann wrote:
>> Please update any plugins that you are maintaining! The majority of
>> fixes should be not more than replacing one method by another, as
>> indicated in the deprecation JavaDoc comment.
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Plugins: deprecated API to be removed

Paul Hartmann-2
In reply to this post by Holger Mappt
On 21.10.2017 17:49, Holger Mappt wrote:
> Hi,
>
> Is the sonar the right place to see what is deprecated, i.e. what needs
> to be changed? [1]
> [...]
> [1]
> https://josm.openstreetmap.de/sonar/project/issues?id=josm-plugins&resolved=false&rules=squid%3ACallToDeprecatedMethod 

Possible, but the normal way would be to have the java compiler output
deprecation warnings (use compiler option -Xlint:deprecation for javac
to see details).

Paul

Reply | Threaded
Open this post in threaded view
|

Re: Plugins: deprecated API to be removed

Paul Hartmann-2
In reply to this post by Holger Mappt
On 21.10.2017 18:46, Holger Mappt wrote:
> Hi,
>
> Is there a plugin that is updated already? I need some examples to see
> what I should do with the deprecated items. E.g. I have
> Main.map.mapView.addMouseListener(mouseAdapter);
> in my plugin. Main.map is a deprecated field and should be changed to
> MainApplication.getMap(). But the access to
> MainApplication.getMap().mapView is discouraged. The documentation [1]
> says I should use LayerManager [2] instead.

You can replace "Main.map.mapView.addMouseListener(mouseAdapter);" with
"MainApplication.getMap().mapView.addMouseListener(mouseAdapter);".

The comment in MapFrame.java is misleading: use of the field mapView is
only discouraged for accessing methods the have been moved from MapView
to LayerManager.

> But how do I register a
> mouse listener with the LayerManager? Or should I use the MainPanel [3]
> for the mouse listener? If so it would be good to have a direct mapping
> from Main.map.mapView.addMouseListener() to the corresponding call on
> the deprecation page [4]. BTW, do I access MainPanel directly
> (MainPanel.addMouseListener()) or what would be the right way to get a
> reference to the MainPanel?

You don't normally need the MainPanel instance, but it can be accessed
with MainApplication.getMainPanel().

Paul

Reply | Threaded
Open this post in threaded view
|

Re: Plugins: deprecated API to be removed

Holger Mappt
In reply to this post by Paul Hartmann-2
On 2017-10-23 at 00:15 +0200 Paul Hartmann wrote:
> On 21.10.2017 17:49, Holger Mappt wrote:
>> Is the sonar the right place to see what is deprecated, i.e. what
>> needs to be changed? [1]
>> [1]
>> https://josm.openstreetmap.de/sonar/project/issues?id=josm-plugins&resolved=false&rules=squid%3ACallToDeprecatedMethod 
>
> Possible, but the normal way would be to have the java compiler output
> deprecation warnings (use compiler option -Xlint:deprecation for javac
> to see details).

The trick is to call "ant clean" before "ant", otherwise the deprecation
messages are not shown. Option -Xlint:deprecation is on by default if
../build-common.xml is imported from build.xml.

Thanks,
Holger






Reply | Threaded
Open this post in threaded view
|

Re: Plugins: deprecated API to be removed

Vincent Privat
Hi Holger,
Sorry for not responding earlier, but I have already updated a lot of
plugins, see https://github.com/openstreetmap/josm-plugins/commits/master
Still some work to do (around 1100 deprecation warnings)
Cheers,
Vincent

2017-10-30 21:16 GMT+01:00 Holger Mappt <[hidden email]>:

> On 2017-10-23 at 00:15 +0200 Paul Hartmann wrote:
>
>> On 21.10.2017 17:49, Holger Mappt wrote:
>>
>>> Is the sonar the right place to see what is deprecated, i.e. what needs
>>> to be changed? [1]
>>> [1] https://josm.openstreetmap.de/sonar/project/issues?id=josm-p
>>> lugins&resolved=false&rules=squid%3ACallToDeprecatedMethod
>>>
>>
>> Possible, but the normal way would be to have the java compiler output
>> deprecation warnings (use compiler option -Xlint:deprecation for javac to
>> see details).
>>
>
> The trick is to call "ant clean" before "ant", otherwise the deprecation
> messages are not shown. Option -Xlint:deprecation is on by default if
> ../build-common.xml is imported from build.xml.
>
> Thanks,
> Holger
>
>
>
>
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Plugins: deprecated API to be removed

Vincent Privat
Hello,
JOSM 13170 has been released. This is the last stable version before we
remove a lot of deprecated APIs.
Make sure your plugins compile without deprecation warning!
Vincent

2017-10-30 21:20 GMT+01:00 Vincent Privat <[hidden email]>:

> Hi Holger,
> Sorry for not responding earlier, but I have already updated a lot of
> plugins, see https://github.com/openstreetmap/josm-plugins/commits/master
> Still some work to do (around 1100 deprecation warnings)
> Cheers,
> Vincent
>
> 2017-10-30 21:16 GMT+01:00 Holger Mappt <[hidden email]>:
>
>> On 2017-10-23 at 00:15 +0200 Paul Hartmann wrote:
>>
>>> On 21.10.2017 17:49, Holger Mappt wrote:
>>>
>>>> Is the sonar the right place to see what is deprecated, i.e. what needs
>>>> to be changed? [1]
>>>> [1] https://josm.openstreetmap.de/sonar/project/issues?id=josm-p
>>>> lugins&resolved=false&rules=squid%3ACallToDeprecatedMethod
>>>>
>>>
>>> Possible, but the normal way would be to have the java compiler output
>>> deprecation warnings (use compiler option -Xlint:deprecation for javac to
>>> see details).
>>>
>>
>> The trick is to call "ant clean" before "ant", otherwise the deprecation
>> messages are not shown. Option -Xlint:deprecation is on by default if
>> ../build-common.xml is imported from build.xml.
>>
>> Thanks,
>> Holger
>>
>>
>>
>>
>>
>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Plugins: deprecated API to be removed

Vincent Privat
First batch of deprecated APIs removed:
https://josm.openstreetmap.de/changeset/13173/josm
Cheers,
Vincent

2017-11-26 16:42 GMT+01:00 Vincent Privat <[hidden email]>:

> Hello,
> JOSM 13170 has been released. This is the last stable version before we
> remove a lot of deprecated APIs.
> Make sure your plugins compile without deprecation warning!
> Vincent
>
> 2017-10-30 21:20 GMT+01:00 Vincent Privat <[hidden email]>:
>
>> Hi Holger,
>> Sorry for not responding earlier, but I have already updated a lot of
>> plugins, see https://github.com/openstreetmap/josm-plugins/commits/master
>> Still some work to do (around 1100 deprecation warnings)
>> Cheers,
>> Vincent
>>
>> 2017-10-30 21:16 GMT+01:00 Holger Mappt <[hidden email]>:
>>
>>> On 2017-10-23 at 00:15 +0200 Paul Hartmann wrote:
>>>
>>>> On 21.10.2017 17:49, Holger Mappt wrote:
>>>>
>>>>> Is the sonar the right place to see what is deprecated, i.e. what
>>>>> needs to be changed? [1]
>>>>> [1] https://josm.openstreetmap.de/sonar/project/issues?id=josm-p
>>>>> lugins&resolved=false&rules=squid%3ACallToDeprecatedMethod
>>>>>
>>>>
>>>> Possible, but the normal way would be to have the java compiler output
>>>> deprecation warnings (use compiler option -Xlint:deprecation for javac to
>>>> see details).
>>>>
>>>
>>> The trick is to call "ant clean" before "ant", otherwise the deprecation
>>> messages are not shown. Option -Xlint:deprecation is on by default if
>>> ../build-common.xml is imported from build.xml.
>>>
>>> Thanks,
>>> Holger
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Plugins: deprecated API to be removed

Jo-2
Hi Vincent,

Thank you for cleaning up the source code. Of course I run into a problem
when using the scripting plugin.

How can I get all the selected elements?

This is what worked untill a few days ago:

from org.openstreetmap.josm import Main

editLayer = Main.getLayerManager().getEditLayer()
if editLayer and editLayer.data:
    selectedElements = editLayer.data.getSelected()

I tried a few incantations, but no luck.

Cheers,

Polyglot


2017-11-28 1:07 GMT+01:00 Vincent Privat <[hidden email]>:

> First batch of deprecated APIs removed:
> https://josm.openstreetmap.de/changeset/13173/josm
> Cheers,
> Vincent
>
> 2017-11-26 16:42 GMT+01:00 Vincent Privat <[hidden email]>:
>
> > Hello,
> > JOSM 13170 has been released. This is the last stable version before we
> > remove a lot of deprecated APIs.
> > Make sure your plugins compile without deprecation warning!
> > Vincent
> >
> > 2017-10-30 21:20 GMT+01:00 Vincent Privat <[hidden email]>:
> >
> >> Hi Holger,
> >> Sorry for not responding earlier, but I have already updated a lot of
> >> plugins, see https://github.com/openstreetmap/josm-plugins/
> commits/master
> >> Still some work to do (around 1100 deprecation warnings)
> >> Cheers,
> >> Vincent
> >>
> >> 2017-10-30 21:16 GMT+01:00 Holger Mappt <[hidden email]>:
> >>
> >>> On 2017-10-23 at 00:15 +0200 Paul Hartmann wrote:
> >>>
> >>>> On 21.10.2017 17:49, Holger Mappt wrote:
> >>>>
> >>>>> Is the sonar the right place to see what is deprecated, i.e. what
> >>>>> needs to be changed? [1]
> >>>>> [1] https://josm.openstreetmap.de/sonar/project/issues?id=josm-p
> >>>>> lugins&resolved=false&rules=squid%3ACallToDeprecatedMethod
> >>>>>
> >>>>
> >>>> Possible, but the normal way would be to have the java compiler output
> >>>> deprecation warnings (use compiler option -Xlint:deprecation for
> javac to
> >>>> see details).
> >>>>
> >>>
> >>> The trick is to call "ant clean" before "ant", otherwise the
> deprecation
> >>> messages are not shown. Option -Xlint:deprecation is on by default if
> >>> ../build-common.xml is imported from build.xml.
> >>>
> >>> Thanks,
> >>> Holger
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>
> >
>
Reply | Threaded
Open this post in threaded view
|

Re: Plugins: deprecated API to be removed

Vincent Privat
Hi Jo,
This should work:

from org.openstreetmap.josm.gui import MainApplication

editLayer = MainApplication.getLayerManager().getEditLayer()
if editLayer and editLayer.data:
    selectedElements = editLayer.data.getSelected()

If you don't need editLayer you could simplify it to:

editData = MainApplication.getLayerManager().getEditDataSet()
if editData:
    selectedElements = editData.getSelected()

Cheers,
Vincent

2017-12-02 11:00 GMT+01:00 Jo <[hidden email]>:

> Hi Vincent,
>
> Thank you for cleaning up the source code. Of course I run into a problem
> when using the scripting plugin.
>
> How can I get all the selected elements?
>
> This is what worked untill a few days ago:
>
> from org.openstreetmap.josm import Main
>
> editLayer = Main.getLayerManager().getEditLayer()
> if editLayer and editLayer.data:
>     selectedElements = editLayer.data.getSelected()
>
> I tried a few incantations, but no luck.
>
> Cheers,
>
> Polyglot
>
>
> 2017-11-28 1:07 GMT+01:00 Vincent Privat <[hidden email]>:
>
>> First batch of deprecated APIs removed:
>> https://josm.openstreetmap.de/changeset/13173/josm
>> Cheers,
>> Vincent
>>
>> 2017-11-26 16:42 GMT+01:00 Vincent Privat <[hidden email]>:
>>
>> > Hello,
>> > JOSM 13170 has been released. This is the last stable version before we
>> > remove a lot of deprecated APIs.
>> > Make sure your plugins compile without deprecation warning!
>> > Vincent
>> >
>> > 2017-10-30 21:20 GMT+01:00 Vincent Privat <[hidden email]>:
>> >
>> >> Hi Holger,
>> >> Sorry for not responding earlier, but I have already updated a lot of
>> >> plugins, see https://github.com/openstreetm
>> ap/josm-plugins/commits/master
>> >> Still some work to do (around 1100 deprecation warnings)
>> >> Cheers,
>> >> Vincent
>> >>
>> >> 2017-10-30 21:16 GMT+01:00 Holger Mappt <[hidden email]>:
>> >>
>> >>> On 2017-10-23 at 00:15 +0200 Paul Hartmann wrote:
>> >>>
>> >>>> On 21.10.2017 17:49, Holger Mappt wrote:
>> >>>>
>> >>>>> Is the sonar the right place to see what is deprecated, i.e. what
>> >>>>> needs to be changed? [1]
>> >>>>> [1] https://josm.openstreetmap.de/sonar/project/issues?id=josm-p
>> >>>>> lugins&resolved=false&rules=squid%3ACallToDeprecatedMethod
>> >>>>>
>> >>>>
>> >>>> Possible, but the normal way would be to have the java compiler
>> output
>> >>>> deprecation warnings (use compiler option -Xlint:deprecation for
>> javac to
>> >>>> see details).
>> >>>>
>> >>>
>> >>> The trick is to call "ant clean" before "ant", otherwise the
>> deprecation
>> >>> messages are not shown. Option -Xlint:deprecation is on by default if
>> >>> ../build-common.xml is imported from build.xml.
>> >>>
>> >>> Thanks,
>> >>> Holger
>> >>>
>> >>>
>> >>>
>> >>>
>> >>>
>> >>>
>> >>>
>> >>
>> >
>>
>
>