updateDropDetails(drag);
if (!oldDetails.equals(dropDetails)) {
deEmphasis();
+ final TableDDDetails newDetails = dropDetails;
VAcceptCallback cb = new VAcceptCallback() {
public void accepted(VDragEvent event) {
- dragAccepted(event);
+ if (newDetails.equals(dropDetails)) {
+ dragAccepted(event);
+ }
+ /*
+ * Else new target slot already defined, ignore
+ */
}
};
validate(cb, drag);
currentMouseOverKey = findCurrentMouseOverKey(drag.getElementOver());
+ drag.getDropDetails().put("itemIdOver", currentMouseOverKey);
if (currentMouseOverKey != null) {
TreeNode treeNode = keyToNode.get(currentMouseOverKey);
VerticalDropLocation detail = treeNode.getDropDetail(drag
&& detail == VerticalDropLocation.MIDDLE) {
overTreeNode = true;
}
- drag.getDropDetails().put("itemIdOver", currentMouseOverKey);
drag.getDropDetails().put("itemIdOverIsNode", overTreeNode);
drag.getDropDetails().put("detail", detail);
-
+ } else {
+ drag.getDropDetails().put("itemIdOverIsNode", null);
+ drag.getDropDetails().put("detail", null);
}
+
}
private String findCurrentMouseOverKey(Element elementOver) {
// clear old styles
treeNode.emphasis(null);
}
- validate(new VAcceptCallback() {
- public void accepted(VDragEvent event) {
- if (newKey != null) {
- keyToNode.get(newKey).emphasis(detail);
+ if (newKey != null) {
+ validate(new VAcceptCallback() {
+ public void accepted(VDragEvent event) {
+ VerticalDropLocation curDetail = (VerticalDropLocation) event
+ .getDropDetails().get("detail");
+ if (curDetail == detail
+ && newKey
+ .equals(currentMouseOverKey)) {
+ keyToNode.get(newKey).emphasis(detail);
+ }
+ /* Else drag is already on a different
+ * node-detail pair,
+ * new criteria check is going on */
}
- }
- }, currentDrag);
+ }, currentDrag);
+
+ }
}
}
*/
package com.vaadin.terminal.gwt.client.ui.dd;
-import java.util.LinkedList;
-
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.NativeEvent;
import com.google.gwt.dom.client.Node;
}
private void doRequest(DragEventType drop) {
+ if (currentDropHandler == null) {
+ ApplicationConnection.getConsole().log(
+ "DD request ignored, drop handler is null");
+ return;
+ }
Paintable paintable = currentDropHandler.getPaintable();
ApplicationConnection client = currentDropHandler
.getApplicationConnection();
}
private void runDeferredCommands() {
- if (deferredCommands != null && !deferredCommands.isEmpty()) {
- Command command = deferredCommands.poll();
+ if (deferredCommand != null) {
+ Command command = deferredCommand;
+ deferredCommand = null;
command.execute();
if (!isBusy()) {
runDeferredCommands();
}
};
- private LinkedList<Command> deferredCommands;
+ private Command deferredCommand;
private boolean isBusy() {
return serverCallback != null;
* @param command
*/
private void defer(Command command) {
- if (deferredCommands == null) {
- deferredCommands = new LinkedList<Command>();
- }
- deferredCommands.add(command);
+ deferredCommand = command;
}
/**