diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2011-11-21 13:38:31 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2011-11-21 13:38:31 +0000 |
commit | fdc8e9a3445612adb21e620ca9822455663e34ba (patch) | |
tree | 51e17ed9913d7cbf374788f5c5e8a651e527494c /src/com/vaadin/ui | |
parent | e8f99a58c30d2813f0ddc60787fe7dc8774dac4e (diff) | |
download | vaadin-framework-fdc8e9a3445612adb21e620ca9822455663e34ba.tar.gz vaadin-framework-fdc8e9a3445612adb21e620ca9822455663e34ba.zip |
dragandropwrapper can now initiate html5 drags, fixes #7833
svn changeset:22081/svn branch:6.8
Diffstat (limited to 'src/com/vaadin/ui')
-rw-r--r-- | src/com/vaadin/ui/DragAndDropWrapper.java | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/src/com/vaadin/ui/DragAndDropWrapper.java b/src/com/vaadin/ui/DragAndDropWrapper.java index 83aa6314c8..9e06382eac 100644 --- a/src/com/vaadin/ui/DragAndDropWrapper.java +++ b/src/com/vaadin/ui/DragAndDropWrapper.java @@ -6,6 +6,7 @@ package com.vaadin.ui; import java.io.OutputStream; import java.util.HashMap; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; @@ -54,7 +55,7 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, /** * The component in wrapper that is being dragged or null if the - * transferrable is not a component (most likely an html5 drag). + * transferable is not a component (most likely an html5 drag). * * @return */ @@ -135,7 +136,8 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, } /** - * @return a detail about the drags horizontal position over the wrapper. + * @return a detail about the drags horizontal position over the + * wrapper. */ public HorizontalDropLocation getHorizontalDropLocation() { return HorizontalDropLocation @@ -172,9 +174,18 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, /** * The whole wrapper is used as a drag image when dragging. */ - WRAPPER + WRAPPER, + /** + * The whole wrapper is used to start an HTML5 drag. + * + * NOTE: In Internet Explorer 6 to 8, this prevents user interactions + * with the wrapper's contents. For example, clicking a button inside + * the wrapper will no longer work. + */ + HTML5, } + private final Map<String, Object> html5DataFlavors = new LinkedHashMap<String, Object>(); private DragStartMode dragStartMode = DragStartMode.NONE; /** @@ -187,10 +198,27 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, super(root); } + /** + * Sets data flavors available in the DragAndDropWrapper is used to start an + * HTML5 style drags. Most commonly the "Text" flavor should be set. + * Multiple data types can be set. + * + * @param type + * the string identifier of the drag "payload". E.g. "Text" or + * "text/html" + * @param value + * the value + */ + public void setHTML5DataFlavor(String type, Object value) { + html5DataFlavors.put(type, value); + requestRepaint(); + } + @Override public void paintContent(PaintTarget target) throws PaintException { super.paintContent(target); - target.addAttribute("dragStartMode", dragStartMode.ordinal()); + target.addAttribute(VDragAndDropWrapper.DRAG_START_MODE, + dragStartMode.ordinal()); if (getDropHandler() != null) { getDropHandler().getAcceptCriterion().paint(target); } @@ -213,6 +241,8 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, } } } + target.addAttribute(VDragAndDropWrapper.HTML5_DATA_FLAVORS, + html5DataFlavors); } private DropHandler dropHandler; |