Open GoogleCodeExporter opened 8 years ago
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import gwtquery.plugins.draggable.client.gwt.DraggableWidget;
import gwtquery.plugins.droppable.client.gwt.DroppableWidget;
public class Main implements EntryPoint {
public void onModuleLoad() {
DraggableWidget<DroppableWidget> draggableNo1 = createDraggable("1");
DraggableWidget<DroppableWidget> draggableNo2 = createDraggable("2");
DraggableWidget<DroppableWidget> draggableNo3 = createDraggable("3");
((HorizontalPanel) draggableNo2.getOriginalWidget().getOriginalWidget()).add(draggableNo3);
((HorizontalPanel) draggableNo1.getOriginalWidget().getOriginalWidget()).add(draggableNo2);
RootPanel.get().add(draggableNo1);
}
private DraggableWidget<DroppableWidget> createDraggable(String id) {
HorizontalPanel simplePanel = new HorizontalPanel();
simplePanel.setBorderWidth(2);
simplePanel.setPixelSize(200, 100);
Label label = new Label(id);
label.setSize("100%", "100%");
label.getElement().setId(id);
simplePanel.add(label);
simplePanel.addStyleName("normalWidget");
DroppableWidget<HorizontalPanel> droppableWidget = new DroppableWidget<HorizontalPanel>(simplePanel);
droppableWidget.setDroppableHoverClass("droppableHoverClassParallel");
droppableWidget.setGreedy(true);
DraggableWidget<DroppableWidget> draggableWidget = new DraggableWidget<DroppableWidget>(droppableWidget);
draggableWidget.setHandle("#" + id);
return draggableWidget;
}
}
css:
.normalWidget {
background-color: #81adff;
font-weight: bold;
font-size: 15px;
width: 80px;
height: 30px;
padding: 10px;
text-align: center;
z-index: 300;
}
.droppableHoverClassParallel {
background-color: #00ffbc;
}
Running this code: dragging Widget id 3 and drop on widget id 2 causes that I
can't drag Widget 2 and drop on widget 1.
Original comment by gento...@gmail.com
on 15 Jan 2013 at 10:10
I have tried to fix drag function from DroppableHandler, for me it works now as
I expect. Please look at it and compare to orginal. Let me now if this method
is ok and if so please include these fix in next release:
public void drag(Element droppable, Element draggable, GqEvent e) {
if (options.isDisabled() || greedyChild || !visible) {
return;
}
boolean isIntersect = intersect(draggable);
PositionStatus c = null;
if (!isIntersect && isOver) {
c = PositionStatus.IS_OUT;
} else if (isIntersect && !isOver) {
c = PositionStatus.IS_OVER;
}
if (c == null) {
return;
}
DroppableHandler parentDroppableHandler = null;
GQuery droppableParents = $(droppable).parents(
"." + Droppable.CssClassNames.GWTQUERY_DROPPABLE);
if (options.isGreedy()) {
// TODO maybe filter the parent with droppable data instead of test on css
// class name
for (int i = 0; i < droppableParents.length(); i++) {
parentDroppableHandler = DroppableHandler.getInstance(droppableParents.get(i));
parentDroppableHandler.greedyChild = (c == PositionStatus.IS_OVER);
}
}
for (int i = 0; i < droppableParents.length(); i++) {
parentDroppableHandler = DroppableHandler.getInstance(droppableParents.get(i));
if (parentDroppableHandler != null && c == PositionStatus.IS_OVER) {
parentDroppableHandler.isOver = false;
parentDroppableHandler.isOut = true;
parentDroppableHandler.out(droppableParents.get(i), draggable, e);
}
}
if (c == PositionStatus.IS_OUT) {
isOut = true;
isOver = false;
out(droppable, draggable, e);
} else {
isOver = true;
isOut = false;
over(droppable, draggable, e);
}
// This should be deleted:
// if (droppableParents.length() > 0) {
// parentDroppableHandler =
DroppableHandler.getInstance(droppableParents.get(0));
// if (parentDroppableHandler != null && c == PositionStatus.IS_OUT)
{
// parentDroppableHandler.isOut = false;
// parentDroppableHandler.isOver = true;
// parentDroppableHandler.over(droppableParents.get(0),
draggable, e);
// }
// }
}
Original comment by gento...@gmail.com
on 17 Jan 2013 at 4:10
Original issue reported on code.google.com by
gento...@gmail.com
on 15 Jan 2013 at 7:04Attachments: