diff options
Diffstat (limited to 'server/src/com/vaadin')
-rw-r--r-- | server/src/com/vaadin/ui/DragAndDropWrapper.java | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/server/src/com/vaadin/ui/DragAndDropWrapper.java b/server/src/com/vaadin/ui/DragAndDropWrapper.java index 6e4ec903d2..b813973861 100644 --- a/server/src/com/vaadin/ui/DragAndDropWrapper.java +++ b/server/src/com/vaadin/ui/DragAndDropWrapper.java @@ -24,6 +24,8 @@ import java.util.Map; import java.util.Map.Entry; import java.util.Set; +import org.jsoup.nodes.Element; + import com.vaadin.event.Transferable; import com.vaadin.event.TransferableImpl; import com.vaadin.event.dd.DragSource; @@ -38,6 +40,7 @@ import com.vaadin.shared.MouseEventDetails; import com.vaadin.shared.ui.dd.HorizontalDropLocation; import com.vaadin.shared.ui.dd.VerticalDropLocation; import com.vaadin.shared.ui.draganddropwrapper.DragAndDropWrapperConstants; +import com.vaadin.ui.declarative.DesignContext; @SuppressWarnings("serial") public class DragAndDropWrapper extends CustomComponent implements DropTarget, @@ -185,7 +188,12 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, private Set<String> sentIds = new HashSet<String>(); - private DragAndDropWrapper() { + /** + * This is an internal constructor. Use + * {@link DragAndDropWrapper#DragAndDropWrapper(Component)} instead. + */ + @Deprecated + public DragAndDropWrapper() { super(); } @@ -458,4 +466,31 @@ public class DragAndDropWrapper extends CustomComponent implements DropTarget, } + @Override + public void readDesign(Element design, DesignContext designContext) { + super.readDesign(design, designContext); + + for (Element child : design.children()) { + Component component = designContext.readDesign(child); + if (getDragStartMode() == DragStartMode.COMPONENT_OTHER + && child.hasAttr(":drag-image")) { + setDragImageComponent(component); + } else if (getCompositionRoot() == null) { + setCompositionRoot(component); + } + } + } + + @Override + public void writeDesign(Element design, DesignContext designContext) { + super.writeDesign(design, designContext); + + design.appendChild(designContext.createElement(getCompositionRoot())); + if (getDragStartMode() == DragStartMode.COMPONENT_OTHER) { + Element child = designContext + .createElement(getDragImageComponent()); + child.attr(":drag-image", ""); + design.appendChild(child); + } + } } |