fredsa / gwt-dnd

Library providing easy to use mouse or touch based drag-and-drop capabilities to GWT
42 stars 41 forks source link

Code enhancement issue: Allow to create custom DragContext/MouseHandlers in AbstractDragController in future versions #146

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am implementing a little-bit different drag-and-drop system on top of your 
library (for GWT implementation of Canvas, though) and the only thing I am 
currently in need is to have a possibility to customize DragContext and 
MouseHandler, but to keep almost all existing code in AbstractDragController. 

But these fields in DragController are private for creation and I see no 
possibility to extend these classes and use in AbstractDragController without 
copying almost all of its code. (AbstractDragController constructor is a place 
where this happens)

Could you please add a factory methods, factory, generics or something you 
think is right there to allow custom DragContext/MouseHandler instances 
creation in a future versions?

Original issue reported on code.google.com by shaman.sir on 7 Sep 2011 at 1:17

GoogleCodeExporter commented 9 years ago
Also, MouseDragHandler is a package-protected one, so there is no way to extend 
it

Original comment by shaman.sir on 7 Sep 2011 at 1:24

GoogleCodeExporter commented 9 years ago
...and DragContext constructor is not visible :(

Original comment by shaman.sir on 7 Sep 2011 at 1:32

GoogleCodeExporter commented 9 years ago
Implementations are kept as closed as possible, in order to enable free 
refactoring and optimization, without worrying about dependencies. Sorry, but 
experience has taught me that this is much better for the overall stability and 
health of the library.

Original comment by fredsa@google.com on 15 Sep 2011 at 4:53

GoogleCodeExporter commented 9 years ago
I agree that it is a bad idea to open up for inheritance that is not needed. A 
better solution would be to move all the functionality that could be reused out 
in independent classes, in that way the dependencies would be the same for the 
current implementation. Other developers would then be able to make their own 
DragController without copy paste all the source, but instead using the 
functionality from the new classes. They will add new dependencies to the 
classes but that does not have any impact on your implementation.

Another nice thing would be to move the dependency to the MouseDragHandler away 
from the AbstractDragController (maybe to the PickupDragController). In that 
way it would be possible to inherit AbstractDragController without being forced 
to be triggered on a mouse down event for starting the drag functionality.

This was just some thoughts on how the framework could be improved for 
developers.
Appreciate your work!

Original comment by mw.johnd...@gmail.com on 24 Oct 2011 at 12:12

GoogleCodeExporter commented 9 years ago
Yes, through time, I will may be agree with that. I can extend a DragController 
and store the information I need there, though one DragController has one 
DragContext... 

But that'd be ok, if I'd need just to store information. But I need to change a 
little on how MouseDragContext works (allow it to create Canvas instances in 
some cases, wrapping them with widgets. Or just projecting a draggable with 
putImageData : the logic stays same, but implementation changes. However, it is 
enough complicated "extension" to make it a separate twin project like 
gwt-dnd-on-canvas and may be it is ok to copy/modify code for it?

Original comment by shaman.sir on 24 Oct 2011 at 1:23

GoogleCodeExporter commented 9 years ago

Original comment by fredsa on 31 Jan 2012 at 6:15