[josm-dev] JosmPlugin, Catching the DataDelete Event

2015-11-25 Thread Möller , Matthias
Hello,

currently i'am working on a plugin for JOSM and i want to prevent the user from 
deleting special Nodes.
So the Idea is to catch the Delete Event and display a warning(or a userchoise).
I first looked into the Dataset and DatasetListener. But at the pont when I get 
the primitiesRemoved() Event in my DatasetListener, the element has already 
been deleted.
My next idea would be to override the shortcut key DEL and link it to my own 
DeleteAction. With this Action I can either display a warning or delegate the 
Selection to the original DeleteAction.

So my question:
Is there a better way to prevent Nodes from being deleted?
Is it a good solution to replace the shortcut key DEL with my own deleteAction?

Thanks in advance

Regards Matthias Möller
___
josm-dev mailing list
josm-dev@openstreetmap.org
https://lists.openstreetmap.org/listinfo/josm-dev


Re: [josm-dev] JosmPlugin, Catching the DataDelete Event

2015-11-25 Thread Paul Hartmann

On 25.11.2015 13:18, Möller, Matthias wrote:

Hello,

currently i'am working on a plugin for JOSM and i want to prevent the user from 
deleting special Nodes.
So the Idea is to catch the Delete Event and display a warning(or a userchoise).


Could you give a little more context, what the plugin is supposed to do 
and why certain nodes should not be deleted?



[...]
So my question:
Is there a better way to prevent Nodes from being deleted?


The cleanest solution is to patch JOSM core so your plugin can intercept 
the delete action. (Similar to DatasetListener, but the "listener" 
returns a boolean value which tells JOSM to continue or abort the delete 
action.)



Is it a good solution to replace the shortcut key DEL with my own deleteAction?


No, not only will you get shortcut conflict messages on the console, but 
the user can still remove all nodes in delete mode (ctrl+del).


Paul

___
josm-dev mailing list
josm-dev@openstreetmap.org
https://lists.openstreetmap.org/listinfo/josm-dev


Re: [josm-dev] JosmPlugin, Catching the DataDelete Event

2015-11-25 Thread Michael Zangl
Am 25.11.2015 um 13:55 schrieb Paul Hartmann:
>
> The cleanest solution is to patch JOSM core so your plugin can intercept
> the delete action. (Similar to DatasetListener, but the "listener"
> returns a boolean value which tells JOSM to continue or abort the delete
> action.)

An even cleaner way would be to pass an Event-Object with a
cancel()-method on to the listener. This would allow for more additions
- both parameters and return values - in the future without breaking the
API.

Michael

___
josm-dev mailing list
josm-dev@openstreetmap.org
https://lists.openstreetmap.org/listinfo/josm-dev