PDA

View Full Version : [FIXED] [2.0 Trunk] Bug in DND Manager?



mgoerdes
11 Apr 2009, 5:03 AM
hi dev team,

we try to implement a dataset widget, in which the layout can be modified by a user via drag and drop of a tree-element to the target. Therefore we have TabPanel, containing a TabItem, containing a FormPanel to which a user can drag a fieldset. After dragging a fieldset to the FormPanel the user can drag additional fields to the fieldset. Unfortunately the drag/drop of the field to the fieldset does not work, because the DNDManager.getTarget returns the wrong target.

While defining the form, we define a droptarget and set the group DRAG_GROUP_FIELDSET.
DropTarget target = new DropTarget(form) {...}
target.setGroup(DRAG_GROUP_FIELDSET);

After dragging a fieldset to the form, we define the fieldset dynamically and create an additional DropTarget:

DropTarget target = new DropTarget(fieldSet) {
target.setGroup(DRAG_GROUP_FIELD);

No the user should have the possibilty to drag a field to this target, but unfortunately the DNDManaget.getTarget(Element elem) returns the Form, not the Fieldset, because the DOM.isOrHasChild(...) is true for the form. Therefore the handleDragMove returns without result because of the different groups we defined.

After modifying the getTarget method everything works fine for me. But I think, that this is only a quick and dirty solution.

private DropTarget getTarget(DragSource source, Element elem) {

DropTarget t = null;
for (int i = 0, len = targets.size(); i < len; i++) {
DropTarget target = targets.get(i);
if (DOM.isOrHasChild(target.component.getElement(), elem)) {
if (target.getGroup().equals(source.getGroup()))
t = target;
}
}
return t;
}

Can you help me with this?

Regards, Mark

mgoerdes
21 Apr 2009, 11:25 PM
Hi dev-Team,

as shown on gxt-conference, the bug still exists in the trunk. Any solutions or ideas yet?

Regards,
Mark

sven
22 Apr 2009, 3:12 AM
This will be fixed with one of the next milestones.

sven
23 Apr 2009, 6:35 AM
Fixed in SVN.

Rvanlaak
29 Apr 2009, 6:03 AM
Does this actually mean that it isn't possible to get the DropTarget within the DropSource event handler? I'm using the following code:



DragSource source = new DragSource(html) {
@Override
protected void onDragStart(DNDEvent event) {
// by default drag is allowed
event.setData(html);
event.getStatus().update(
El.fly(html.getElement()).cloneNode(true));
}

@Override
protected void onDragDrop(DNDEvent event) {

super.onDragDrop(event);

System.out.println( "DragSource: " + event.getDragSource() );
System.out.println( "DropTarget: " + event.getDropTarget() );


}
};
source.setGroup("dnd-call");

The first println says null, the second one works fine. The above example is talking about the DNDManager, the difference here is that I'm not using the manager. Can I also use above code example to fix this bug?

darrellmeyer
1 May 2009, 11:27 AM
Does this actually mean that it isn't possible to get the DropTarget within the DropSource event handler?

Fixed in SVN.

Rvanlaak
1 May 2009, 1:23 PM
Hmm,, as I remember SVN is only available for premium members. The GXT2 branch is still in a beta phase, so isn't it possible to get access to SVN?

Else,, how to fix this problem? What did you fix?

darrellmeyer
1 May 2009, 1:37 PM
The fix is in both the 1.0 branch (releases/1.2) and 2.0 (trunk) and will be included in the next release for both 1.2 and 2.0.