PDA

View Full Version : Bugs of dragsource and droptarget



the_matrix22c
19 Aug 2009, 12:11 AM
Hi,

I found two bugs in dragsource and droptarget

Detailed description of the problem
1/The DragSource cannot be drag in firefox if the droptarget's layoutcontainer is set with RowLayout. It just only works for FitLayout and FlowLayout in FireFox. This bug is not found in IE.In my sample code, when I drag the drag source from container3 to container, the dragsource simply drop back into container3, ondrapdrop code of container doesn't be called.(screen shot is captured and mentioned at the end of this post)
2/another bug is when the layout of container3 in the sample code is set to new RowLayout(Style.Orientation.HORIZONTAL)and add with layoutdata everytime it was added to a layoutcontainer, it seems still using the layoutdata before but not the given one.


- GXT version - gxt-2.0.1
- both Host mode & web mode
- Browser and version - Firefox/3.0.13
- Operating System - Windows XP
- Sample code
public class BasicDNDExample extends LayoutContainer {
private LayoutContainer master = new LayoutContainer();
private LayoutContainer container3 = new LayoutContainer();
private HorizontalPanel hp = new HorizontalPanel();
private LayoutContainer container = new LayoutContainer();

public BasicDNDExample() {
master.setLayoutOnChange(true);
master.setBorders(true);
master.setSize(200, 500);
master.setLayout(new FlowLayout());

hp.setLayout(new FlowLayout());
hp.setSpacing(10);
hp.setId("helloHP");
hp.setLayoutOnChange(true);

container.setLayoutOnChange(true);
container.setBorders(true);
container.setSize(200, 200);
container.setLayout(new FlowLayout());

container3.setLayoutOnChange(true);
container3.setBorders(true);
container3.setSize(200, 200);
container3.setLayout(new RowLayout(Style.Orientation.HORIZONTAL));


DropTarget target = new DropTarget(container) {
@Override
protected void onDragDrop(DNDEvent event) {
super.onDragDrop(event);
Html html = event.getData();
container.add(html, new FlowData(3));
}
};
target.setGroup("test");
target.setOverStyle("drag-ok");

DropTarget target2 = new DropTarget(container3) {
@Override
protected void onDragDrop(DNDEvent event) {
super.onDragDrop(event);
Html html = event.getData();
container3.add(html, new RowData(0.3, 1, new Margins(0, 0, 0, 0)));
}
};
target2.setGroup("test");
target2.setOverStyle("drag-ok");


final LayoutContainer sourceContainer = new LayoutContainer();
sourceContainer.setLayoutOnChange(true);
sourceContainer.setWidth(100);

addSources(sourceContainer);



this.setLayout(new FitLayout());
hp.add(master);
hp.add(sourceContainer);
master.add(container);
master.add(container3);

add(hp);
}

private void addSources(LayoutContainer container) {
for (int i = 0; i < 5; i++) {
final Html html = new Html("Drag Me " + i);
html.setStyleAttribute("padding", "5px");
html.setStyleAttribute("border", "1px solid red");
html.setStyleAttribute("cursor", "default");
html.setStyleName("text");
container.add(html, new FlowData(3));

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));
}
};
// group is optional
source.setGroup("test");
}


}

}

Screen shot for bug one:
For the firefox issue, let me show you by screen shot below:
1/ I drag three dragsource into container3, then drag "Drag Me 4" to container
http://farm4.static.flickr.com/3559/3822708072_d178ed010d.jpg
2/ "Drag Me 4" just add back into container3, appended after "Drag Me 3"
http://farm3.static.flickr.com/2444/3822708092_b2c9c7aee0.jpg

The behavior of the dragsource and droptarget is different from hosted mode
For IE, and chrome, the behavior is as same as the hosted mode.

screen shot for bug two:

1/ I drag three dragsource into container3
http://farm3.static.flickr.com/2491/3821887489_e8a52c4c52_o.jpg

2/then drag "Drage Me 2" to container
http://farm4.static.flickr.com/3462/3821887505_d57b87e5e7_o.jpg

it seems still using the layoutdata before, do I need to clear the layoutdata?



Thank you for your help.

sven
19 Aug 2009, 12:48 AM
Moved to the help forum again. There is no bug.

the_matrix22c
19 Aug 2009, 4:47 AM
Hi sven,

This is not the same case as before, code caused error last time is corrected. Can you kindly give me some advice?

Thank you.

Matrix

sven
19 Aug 2009, 4:58 AM
Try to inspect what you are actually doing here with firebug for example:


it seems still using the layoutdata before, do I need to clear the layoutdata?

The panel is positioned absolutly. You need to revert this. As already explained in the other thread, i have updated the layoutcode so gxt takes care of it in the next release.

the_matrix22c
19 Aug 2009, 5:21 AM
Hi sven,

Thanks for your opinions, so do the issue 1 occurs in firefox caused by the same thing?
Btw, may I know when will the next release be released?