package com.vaadin.terminal.gwt.client.ui;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JsArrayString;
import com.vaadin.terminal.gwt.client.MouseEventDetails;
import com.vaadin.terminal.gwt.client.RenderInformation;
import com.vaadin.terminal.gwt.client.RenderInformation.Size;
-import com.vaadin.terminal.gwt.client.UIDL;
import com.vaadin.terminal.gwt.client.Util;
import com.vaadin.terminal.gwt.client.VConsole;
import com.vaadin.terminal.gwt.client.VPaintable;
super.onBrowserEvent(event);
if (client != null) {
- client.handleTooltipEvent(event, this);
+ client.handleWidgetTooltipEvent(event, this);
}
}
private boolean startDrag(NativeEvent event) {
if (dragStartMode == WRAPPER || dragStartMode == COMPONENT) {
VTransferable transferable = new VTransferable();
- transferable.setDragSource(VDragAndDropWrapper.this);
+ transferable.setDragSource(VPaintableMap.get(client).getPaintable(
+ VDragAndDropWrapper.this));
VPaintableWidget paintable = Util.findPaintable(client,
(Element) event.getEventTarget().cast());
protected int dragStartMode;
- private ApplicationConnection client;
- private VAbstractDropHandler dropHandler;
+ ApplicationConnection client;
+ VAbstractDropHandler dropHandler;
private VDragEvent vaadinDragEvent;
- private int filecounter = 0;
- private Map<String, String> fileIdToReceiver;
- private ValueMap html5DataFlavors;
+ int filecounter = 0;
+ Map<String, String> fileIdToReceiver;
+ ValueMap html5DataFlavors;
private Element dragStartElement;
- @Override
- public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
- this.client = client;
- super.updateFromUIDL(uidl, client);
- if (!uidl.hasAttribute("cached") && !uidl.hasAttribute("hidden")) {
- UIDL acceptCrit = uidl.getChildByTagName("-ac");
- if (acceptCrit == null) {
- dropHandler = null;
- } else {
- if (dropHandler == null) {
- dropHandler = new CustomDropHandler();
- }
- dropHandler.updateAcceptRules(acceptCrit);
- }
-
- Set<String> variableNames = uidl.getVariableNames();
- for (String fileId : variableNames) {
- if (fileId.startsWith("rec-")) {
- String receiverUrl = uidl.getStringVariable(fileId);
- fileId = fileId.substring(4);
- if (fileIdToReceiver == null) {
- fileIdToReceiver = new HashMap<String, String>();
- }
- if ("".equals(receiverUrl)) {
- Integer id = Integer.parseInt(fileId);
- int indexOf = fileIds.indexOf(id);
- if (indexOf != -1) {
- files.remove(indexOf);
- fileIds.remove(indexOf);
- }
- } else {
- fileIdToReceiver.put(fileId, receiverUrl);
- }
- }
- }
- startNextUpload();
-
- dragStartMode = uidl.getIntAttribute(DRAG_START_MODE);
- initDragStartMode();
- html5DataFlavors = uidl.getMapAttribute(HTML5_DATA_FLAVORS);
- }
- }
-
protected void initDragStartMode() {
Element div = getElement();
if (dragStartMode == HTML5) {
};
private Timer dragleavetimer;
- private void startNextUpload() {
+ void startNextUpload() {
Scheduler.get().scheduleDeferred(new Command() {
public void execute() {
}
if (VDragAndDropManager.get().getCurrentDropHandler() != getDropHandler()) {
VTransferable transferable = new VTransferable();
- transferable.setDragSource(this);
+ transferable.setDragSource(VPaintableMap.get(client)
+ .getPaintable(this));
vaadinDragEvent = VDragAndDropManager.get().startDrag(
transferable, event, false);
* @param fileId
* @param data
*/
- private List<Integer> fileIds = new ArrayList<Integer>();
- private List<VHtml5File> files = new ArrayList<VHtml5File>();
+ List<Integer> fileIds = new ArrayList<Integer>();
+ List<VHtml5File> files = new ArrayList<VHtml5File>();
private void queueFilePost(final int fileId, final VHtml5File file) {
fileIds.add(fileId);
@Override
public VPaintableWidget getPaintable() {
- return VDragAndDropWrapper.this;
+ return VPaintableMap.get(client).getPaintable(
+ VDragAndDropWrapper.this);
}
public ApplicationConnection getApplicationConnection() {
--- /dev/null
+package com.vaadin.terminal.gwt.client.ui;\r
+\r
+import java.util.HashMap;\r
+import java.util.Set;\r
+\r
+import com.google.gwt.core.client.GWT;\r
+import com.google.gwt.user.client.ui.Widget;\r
+import com.vaadin.terminal.gwt.client.ApplicationConnection;\r
+import com.vaadin.terminal.gwt.client.UIDL;\r
+\r
+public class VDragAndDropWrapperPaintable extends VCustomComponentPaintable {\r
+\r
+ @Override\r
+ public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {\r
+ getWidgetForPaintable().client = client;\r
+ super.updateFromUIDL(uidl, client);\r
+ if (!uidl.hasAttribute("cached") && !uidl.hasAttribute("hidden")) {\r
+ UIDL acceptCrit = uidl.getChildByTagName("-ac");\r
+ if (acceptCrit == null) {\r
+ getWidgetForPaintable().dropHandler = null;\r
+ } else {\r
+ if (getWidgetForPaintable().dropHandler == null) {\r
+ getWidgetForPaintable().dropHandler = getWidgetForPaintable().new CustomDropHandler();\r
+ }\r
+ getWidgetForPaintable().dropHandler\r
+ .updateAcceptRules(acceptCrit);\r
+ }\r
+\r
+ Set<String> variableNames = uidl.getVariableNames();\r
+ for (String fileId : variableNames) {\r
+ if (fileId.startsWith("rec-")) {\r
+ String receiverUrl = uidl.getStringVariable(fileId);\r
+ fileId = fileId.substring(4);\r
+ if (getWidgetForPaintable().fileIdToReceiver == null) {\r
+ getWidgetForPaintable().fileIdToReceiver = new HashMap<String, String>();\r
+ }\r
+ if ("".equals(receiverUrl)) {\r
+ Integer id = Integer.parseInt(fileId);\r
+ int indexOf = getWidgetForPaintable().fileIds\r
+ .indexOf(id);\r
+ if (indexOf != -1) {\r
+ getWidgetForPaintable().files.remove(indexOf);\r
+ getWidgetForPaintable().fileIds.remove(indexOf);\r
+ }\r
+ } else {\r
+ getWidgetForPaintable().fileIdToReceiver.put(fileId,\r
+ receiverUrl);\r
+ }\r
+ }\r
+ }\r
+ getWidgetForPaintable().startNextUpload();\r
+\r
+ getWidgetForPaintable().dragStartMode = uidl\r
+ .getIntAttribute(VDragAndDropWrapper.DRAG_START_MODE);\r
+ getWidgetForPaintable().initDragStartMode();\r
+ getWidgetForPaintable().html5DataFlavors = uidl\r
+ .getMapAttribute(VDragAndDropWrapper.HTML5_DATA_FLAVORS);\r
+ }\r
+ }\r
+\r
+ @Override\r
+ protected Widget createWidget() {\r
+ return GWT.create(VDragAndDropWrapper.class);\r
+ }\r
+\r
+ @Override\r
+ public VDragAndDropWrapper getWidgetForPaintable() {\r
+ return (VDragAndDropWrapper) super.getWidgetForPaintable();\r
+ }\r
+\r
+}\r