You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VDragAndDropWrapper.java 23KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. /*
  2. @VaadinApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.terminal.gwt.client.ui;
  5. import java.util.ArrayList;
  6. import java.util.HashMap;
  7. import java.util.List;
  8. import java.util.Map;
  9. import java.util.Set;
  10. import com.google.gwt.core.client.GWT;
  11. import com.google.gwt.core.client.JsArrayString;
  12. import com.google.gwt.core.client.Scheduler;
  13. import com.google.gwt.dom.client.NativeEvent;
  14. import com.google.gwt.event.dom.client.MouseDownEvent;
  15. import com.google.gwt.event.dom.client.MouseDownHandler;
  16. import com.google.gwt.event.dom.client.TouchStartEvent;
  17. import com.google.gwt.event.dom.client.TouchStartHandler;
  18. import com.google.gwt.user.client.Command;
  19. import com.google.gwt.user.client.Element;
  20. import com.google.gwt.user.client.Event;
  21. import com.google.gwt.user.client.Timer;
  22. import com.google.gwt.user.client.ui.Widget;
  23. import com.google.gwt.xhr.client.ReadyStateChangeHandler;
  24. import com.google.gwt.xhr.client.XMLHttpRequest;
  25. import com.vaadin.terminal.gwt.client.ApplicationConnection;
  26. import com.vaadin.terminal.gwt.client.MouseEventDetails;
  27. import com.vaadin.terminal.gwt.client.RenderInformation;
  28. import com.vaadin.terminal.gwt.client.RenderInformation.Size;
  29. import com.vaadin.terminal.gwt.client.UIDL;
  30. import com.vaadin.terminal.gwt.client.Util;
  31. import com.vaadin.terminal.gwt.client.VConsole;
  32. import com.vaadin.terminal.gwt.client.VPaintable;
  33. import com.vaadin.terminal.gwt.client.VPaintableMap;
  34. import com.vaadin.terminal.gwt.client.VPaintableWidget;
  35. import com.vaadin.terminal.gwt.client.VTooltip;
  36. import com.vaadin.terminal.gwt.client.ValueMap;
  37. import com.vaadin.terminal.gwt.client.ui.dd.DDUtil;
  38. import com.vaadin.terminal.gwt.client.ui.dd.HorizontalDropLocation;
  39. import com.vaadin.terminal.gwt.client.ui.dd.VAbstractDropHandler;
  40. import com.vaadin.terminal.gwt.client.ui.dd.VAcceptCallback;
  41. import com.vaadin.terminal.gwt.client.ui.dd.VDragAndDropManager;
  42. import com.vaadin.terminal.gwt.client.ui.dd.VDragEvent;
  43. import com.vaadin.terminal.gwt.client.ui.dd.VDropHandler;
  44. import com.vaadin.terminal.gwt.client.ui.dd.VHasDropHandler;
  45. import com.vaadin.terminal.gwt.client.ui.dd.VHtml5DragEvent;
  46. import com.vaadin.terminal.gwt.client.ui.dd.VHtml5File;
  47. import com.vaadin.terminal.gwt.client.ui.dd.VTransferable;
  48. import com.vaadin.terminal.gwt.client.ui.dd.VerticalDropLocation;
  49. /**
  50. *
  51. * Must have features pending:
  52. *
  53. * drop details: locations + sizes in document hierarchy up to wrapper
  54. *
  55. */
  56. public class VDragAndDropWrapper extends VCustomComponent implements
  57. VHasDropHandler {
  58. public static final String DRAG_START_MODE = "dragStartMode";
  59. public static final String HTML5_DATA_FLAVORS = "html5-data-flavors";
  60. private static final String CLASSNAME = "v-ddwrapper";
  61. protected static final String DRAGGABLE = "draggable";
  62. public VDragAndDropWrapper() {
  63. super();
  64. sinkEvents(VTooltip.TOOLTIP_EVENTS);
  65. hookHtml5Events(getElement());
  66. setStyleName(CLASSNAME);
  67. addDomHandler(new MouseDownHandler() {
  68. public void onMouseDown(MouseDownEvent event) {
  69. if (startDrag(event.getNativeEvent())) {
  70. event.preventDefault(); // prevent text selection
  71. }
  72. }
  73. }, MouseDownEvent.getType());
  74. addDomHandler(new TouchStartHandler() {
  75. public void onTouchStart(TouchStartEvent event) {
  76. if (startDrag(event.getNativeEvent())) {
  77. /*
  78. * Dont let eg. panel start scrolling.
  79. */
  80. event.stopPropagation();
  81. }
  82. }
  83. }, TouchStartEvent.getType());
  84. sinkEvents(Event.TOUCHEVENTS);
  85. }
  86. @Override
  87. public void onBrowserEvent(Event event) {
  88. super.onBrowserEvent(event);
  89. if (client != null) {
  90. client.handleTooltipEvent(event, this);
  91. }
  92. }
  93. /**
  94. * Starts a drag and drop operation from mousedown or touchstart event if
  95. * required conditions are met.
  96. *
  97. * @param event
  98. * @return true if the event was handled as a drag start event
  99. */
  100. private boolean startDrag(NativeEvent event) {
  101. if (dragStartMode == WRAPPER || dragStartMode == COMPONENT) {
  102. VTransferable transferable = new VTransferable();
  103. transferable.setDragSource(VDragAndDropWrapper.this);
  104. Widget widget = Util.findWidget((Element) event.getEventTarget()
  105. .cast(), null);
  106. VPaintableMap vPaintableMap = VPaintableMap.get(client);
  107. while (widget != null && !vPaintableMap.isPaintable(widget)) {
  108. widget = widget.getParent();
  109. }
  110. VPaintableWidget paintable = vPaintableMap.getPaintable(widget);
  111. transferable.setData("component", paintable);
  112. VDragEvent dragEvent = VDragAndDropManager.get().startDrag(
  113. transferable, event, true);
  114. transferable.setData("mouseDown",
  115. new MouseEventDetails(event).serialize());
  116. if (dragStartMode == WRAPPER) {
  117. dragEvent.createDragImage(getElement(), true);
  118. } else {
  119. dragEvent.createDragImage(widget.getElement(), true);
  120. }
  121. return true;
  122. }
  123. return false;
  124. }
  125. protected final static int NONE = 0;
  126. protected final static int COMPONENT = 1;
  127. protected final static int WRAPPER = 2;
  128. protected final static int HTML5 = 3;
  129. protected int dragStartMode;
  130. private ApplicationConnection client;
  131. private VAbstractDropHandler dropHandler;
  132. private VDragEvent vaadinDragEvent;
  133. private int filecounter = 0;
  134. private Map<String, String> fileIdToReceiver;
  135. private ValueMap html5DataFlavors;
  136. private Element dragStartElement;
  137. @Override
  138. public void updateFromUIDL(UIDL uidl, ApplicationConnection client) {
  139. this.client = client;
  140. super.updateFromUIDL(uidl, client);
  141. if (!uidl.hasAttribute("cached") && !uidl.hasAttribute("hidden")) {
  142. UIDL acceptCrit = uidl.getChildByTagName("-ac");
  143. if (acceptCrit == null) {
  144. dropHandler = null;
  145. } else {
  146. if (dropHandler == null) {
  147. dropHandler = new CustomDropHandler();
  148. }
  149. dropHandler.updateAcceptRules(acceptCrit);
  150. }
  151. Set<String> variableNames = uidl.getVariableNames();
  152. for (String fileId : variableNames) {
  153. if (fileId.startsWith("rec-")) {
  154. String receiverUrl = uidl.getStringVariable(fileId);
  155. fileId = fileId.substring(4);
  156. if (fileIdToReceiver == null) {
  157. fileIdToReceiver = new HashMap<String, String>();
  158. }
  159. if ("".equals(receiverUrl)) {
  160. Integer id = Integer.parseInt(fileId);
  161. int indexOf = fileIds.indexOf(id);
  162. if (indexOf != -1) {
  163. files.remove(indexOf);
  164. fileIds.remove(indexOf);
  165. }
  166. } else {
  167. fileIdToReceiver.put(fileId, receiverUrl);
  168. }
  169. }
  170. }
  171. startNextUpload();
  172. dragStartMode = uidl.getIntAttribute(DRAG_START_MODE);
  173. initDragStartMode();
  174. html5DataFlavors = uidl.getMapAttribute(HTML5_DATA_FLAVORS);
  175. }
  176. }
  177. protected void initDragStartMode() {
  178. Element div = getElement();
  179. if (dragStartMode == HTML5) {
  180. if (dragStartElement == null) {
  181. dragStartElement = getDragStartElement();
  182. dragStartElement.setPropertyBoolean(DRAGGABLE, true);
  183. VConsole.log("draggable = "
  184. + dragStartElement.getPropertyBoolean(DRAGGABLE));
  185. hookHtml5DragStart(dragStartElement);
  186. VConsole.log("drag start listeners hooked.");
  187. }
  188. } else {
  189. dragStartElement = null;
  190. if (div.hasAttribute(DRAGGABLE)) {
  191. div.removeAttribute(DRAGGABLE);
  192. }
  193. }
  194. }
  195. protected Element getDragStartElement() {
  196. return getElement();
  197. }
  198. private boolean uploading;
  199. private ReadyStateChangeHandler readyStateChangeHandler = new ReadyStateChangeHandler() {
  200. public void onReadyStateChange(XMLHttpRequest xhr) {
  201. if (xhr.getReadyState() == XMLHttpRequest.DONE) {
  202. // visit server for possible
  203. // variable changes
  204. client.sendPendingVariableChanges();
  205. uploading = false;
  206. startNextUpload();
  207. xhr.clearOnReadyStateChange();
  208. }
  209. }
  210. };
  211. private Timer dragleavetimer;
  212. private void startNextUpload() {
  213. Scheduler.get().scheduleDeferred(new Command() {
  214. public void execute() {
  215. if (!uploading) {
  216. if (fileIds.size() > 0) {
  217. uploading = true;
  218. final Integer fileId = fileIds.remove(0);
  219. VHtml5File file = files.remove(0);
  220. final String receiverUrl = client
  221. .translateVaadinUri(fileIdToReceiver
  222. .remove(fileId.toString()));
  223. ExtendedXHR extendedXHR = (ExtendedXHR) ExtendedXHR
  224. .create();
  225. extendedXHR
  226. .setOnReadyStateChange(readyStateChangeHandler);
  227. extendedXHR.open("POST", receiverUrl);
  228. extendedXHR.postFile(file);
  229. }
  230. }
  231. }
  232. });
  233. }
  234. public boolean html5DragStart(VHtml5DragEvent event) {
  235. if (dragStartMode == HTML5) {
  236. /*
  237. * Populate html5 payload with dataflavors from the serverside
  238. */
  239. JsArrayString flavors = html5DataFlavors.getKeyArray();
  240. for (int i = 0; i < flavors.length(); i++) {
  241. String flavor = flavors.get(i);
  242. event.setHtml5DataFlavor(flavor,
  243. html5DataFlavors.getString(flavor));
  244. }
  245. event.setEffectAllowed("copy");
  246. return true;
  247. }
  248. return false;
  249. }
  250. public boolean html5DragEnter(VHtml5DragEvent event) {
  251. if (dropHandler == null) {
  252. return true;
  253. }
  254. try {
  255. if (dragleavetimer != null) {
  256. // returned quickly back to wrapper
  257. dragleavetimer.cancel();
  258. dragleavetimer = null;
  259. }
  260. if (VDragAndDropManager.get().getCurrentDropHandler() != getDropHandler()) {
  261. VTransferable transferable = new VTransferable();
  262. transferable.setDragSource(this);
  263. vaadinDragEvent = VDragAndDropManager.get().startDrag(
  264. transferable, event, false);
  265. VDragAndDropManager.get().setCurrentDropHandler(
  266. getDropHandler());
  267. }
  268. try {
  269. event.preventDefault();
  270. event.stopPropagation();
  271. } catch (Exception e) {
  272. // VConsole.log("IE9 fails");
  273. }
  274. return false;
  275. } catch (Exception e) {
  276. GWT.getUncaughtExceptionHandler().onUncaughtException(e);
  277. return true;
  278. }
  279. }
  280. public boolean html5DragLeave(VHtml5DragEvent event) {
  281. if (dropHandler == null) {
  282. return true;
  283. }
  284. try {
  285. dragleavetimer = new Timer() {
  286. @Override
  287. public void run() {
  288. // Yes, dragleave happens before drop. Makes no sense to me.
  289. // IMO shouldn't fire leave at all if drop happens (I guess
  290. // this
  291. // is what IE does).
  292. // In Vaadin we fire it only if drop did not happen.
  293. if (vaadinDragEvent != null
  294. && VDragAndDropManager.get()
  295. .getCurrentDropHandler() == getDropHandler()) {
  296. VDragAndDropManager.get().interruptDrag();
  297. }
  298. }
  299. };
  300. dragleavetimer.schedule(350);
  301. try {
  302. event.preventDefault();
  303. event.stopPropagation();
  304. } catch (Exception e) {
  305. // VConsole.log("IE9 fails");
  306. }
  307. return false;
  308. } catch (Exception e) {
  309. GWT.getUncaughtExceptionHandler().onUncaughtException(e);
  310. return true;
  311. }
  312. }
  313. public boolean html5DragOver(VHtml5DragEvent event) {
  314. if (dropHandler == null) {
  315. return true;
  316. }
  317. if (dragleavetimer != null) {
  318. // returned quickly back to wrapper
  319. dragleavetimer.cancel();
  320. dragleavetimer = null;
  321. }
  322. vaadinDragEvent.setCurrentGwtEvent(event);
  323. getDropHandler().dragOver(vaadinDragEvent);
  324. String s = event.getEffectAllowed();
  325. if ("all".equals(s) || s.contains("opy")) {
  326. event.setDropEffect("copy");
  327. } else {
  328. event.setDropEffect(s);
  329. }
  330. try {
  331. event.preventDefault();
  332. event.stopPropagation();
  333. } catch (Exception e) {
  334. // VConsole.log("IE9 fails");
  335. }
  336. return false;
  337. }
  338. public boolean html5DragDrop(VHtml5DragEvent event) {
  339. if (dropHandler == null || !currentlyValid) {
  340. return true;
  341. }
  342. try {
  343. VTransferable transferable = vaadinDragEvent.getTransferable();
  344. JsArrayString types = event.getTypes();
  345. for (int i = 0; i < types.length(); i++) {
  346. String type = types.get(i);
  347. if (isAcceptedType(type)) {
  348. String data = event.getDataAsText(type);
  349. if (data != null) {
  350. transferable.setData(type, data);
  351. }
  352. }
  353. }
  354. int fileCount = event.getFileCount();
  355. if (fileCount > 0) {
  356. transferable.setData("filecount", fileCount);
  357. for (int i = 0; i < fileCount; i++) {
  358. final int fileId = filecounter++;
  359. final VHtml5File file = event.getFile(i);
  360. transferable.setData("fi" + i, "" + fileId);
  361. transferable.setData("fn" + i, file.getName());
  362. transferable.setData("ft" + i, file.getType());
  363. transferable.setData("fs" + i, file.getSize());
  364. queueFilePost(fileId, file);
  365. }
  366. }
  367. VDragAndDropManager.get().endDrag();
  368. vaadinDragEvent = null;
  369. try {
  370. event.preventDefault();
  371. event.stopPropagation();
  372. } catch (Exception e) {
  373. // VConsole.log("IE9 fails");
  374. }
  375. return false;
  376. } catch (Exception e) {
  377. GWT.getUncaughtExceptionHandler().onUncaughtException(e);
  378. return true;
  379. }
  380. }
  381. protected String[] acceptedTypes = new String[] { "Text", "Url",
  382. "text/html", "text/plain", "text/rtf" };
  383. private boolean isAcceptedType(String type) {
  384. for (String t : acceptedTypes) {
  385. if (t.equals(type)) {
  386. return true;
  387. }
  388. }
  389. return false;
  390. }
  391. static class ExtendedXHR extends XMLHttpRequest {
  392. protected ExtendedXHR() {
  393. }
  394. public final native void postFile(VHtml5File file)
  395. /*-{
  396. this.setRequestHeader('Content-Type', 'multipart/form-data');
  397. this.send(file);
  398. }-*/;
  399. }
  400. /**
  401. * Currently supports only FF36 as no other browser supports natively File
  402. * api.
  403. *
  404. * @param fileId
  405. * @param data
  406. */
  407. private List<Integer> fileIds = new ArrayList<Integer>();
  408. private List<VHtml5File> files = new ArrayList<VHtml5File>();
  409. private void queueFilePost(final int fileId, final VHtml5File file) {
  410. fileIds.add(fileId);
  411. files.add(file);
  412. }
  413. private String getPid() {
  414. return VPaintableMap.get(client).getPid((VPaintable) this);
  415. }
  416. public VDropHandler getDropHandler() {
  417. return dropHandler;
  418. }
  419. protected VerticalDropLocation verticalDropLocation;
  420. protected HorizontalDropLocation horizontalDropLocation;
  421. private VerticalDropLocation emphasizedVDrop;
  422. private HorizontalDropLocation emphasizedHDrop;
  423. /**
  424. * Flag used by html5 dd
  425. */
  426. private boolean currentlyValid;
  427. private static final String OVER_STYLE = "v-ddwrapper-over";
  428. public class CustomDropHandler extends VAbstractDropHandler {
  429. @Override
  430. public void dragEnter(VDragEvent drag) {
  431. updateDropDetails(drag);
  432. currentlyValid = false;
  433. super.dragEnter(drag);
  434. }
  435. @Override
  436. public void dragLeave(VDragEvent drag) {
  437. deEmphasis(true);
  438. dragleavetimer = null;
  439. }
  440. @Override
  441. public void dragOver(final VDragEvent drag) {
  442. boolean detailsChanged = updateDropDetails(drag);
  443. if (detailsChanged) {
  444. currentlyValid = false;
  445. validate(new VAcceptCallback() {
  446. public void accepted(VDragEvent event) {
  447. dragAccepted(drag);
  448. }
  449. }, drag);
  450. }
  451. }
  452. @Override
  453. public boolean drop(VDragEvent drag) {
  454. deEmphasis(true);
  455. Map<String, Object> dd = drag.getDropDetails();
  456. // this is absolute layout based, and we may want to set
  457. // component
  458. // relatively to where the drag ended.
  459. // need to add current location of the drop area
  460. int absoluteLeft = getAbsoluteLeft();
  461. int absoluteTop = getAbsoluteTop();
  462. dd.put("absoluteLeft", absoluteLeft);
  463. dd.put("absoluteTop", absoluteTop);
  464. if (verticalDropLocation != null) {
  465. dd.put("verticalLocation", verticalDropLocation.toString());
  466. dd.put("horizontalLocation", horizontalDropLocation.toString());
  467. }
  468. return super.drop(drag);
  469. }
  470. @Override
  471. protected void dragAccepted(VDragEvent drag) {
  472. currentlyValid = true;
  473. emphasis(drag);
  474. }
  475. @Override
  476. public VPaintableWidget getPaintable() {
  477. return VDragAndDropWrapper.this;
  478. }
  479. public ApplicationConnection getApplicationConnection() {
  480. return client;
  481. }
  482. }
  483. protected native void hookHtml5DragStart(Element el)
  484. /*-{
  485. var me = this;
  486. el.addEventListener("dragstart", function(ev) {
  487. return me.@com.vaadin.terminal.gwt.client.ui.VDragAndDropWrapper::html5DragStart(Lcom/vaadin/terminal/gwt/client/ui/dd/VHtml5DragEvent;)(ev);
  488. }, false);
  489. }-*/;
  490. /**
  491. * Prototype code, memory leak risk.
  492. *
  493. * @param el
  494. */
  495. protected native void hookHtml5Events(Element el)
  496. /*-{
  497. var me = this;
  498. el.addEventListener("dragenter", function(ev) {
  499. return me.@com.vaadin.terminal.gwt.client.ui.VDragAndDropWrapper::html5DragEnter(Lcom/vaadin/terminal/gwt/client/ui/dd/VHtml5DragEvent;)(ev);
  500. }, false);
  501. el.addEventListener("dragleave", function(ev) {
  502. return me.@com.vaadin.terminal.gwt.client.ui.VDragAndDropWrapper::html5DragLeave(Lcom/vaadin/terminal/gwt/client/ui/dd/VHtml5DragEvent;)(ev);
  503. }, false);
  504. el.addEventListener("dragover", function(ev) {
  505. return me.@com.vaadin.terminal.gwt.client.ui.VDragAndDropWrapper::html5DragOver(Lcom/vaadin/terminal/gwt/client/ui/dd/VHtml5DragEvent;)(ev);
  506. }, false);
  507. el.addEventListener("drop", function(ev) {
  508. return me.@com.vaadin.terminal.gwt.client.ui.VDragAndDropWrapper::html5DragDrop(Lcom/vaadin/terminal/gwt/client/ui/dd/VHtml5DragEvent;)(ev);
  509. }, false);
  510. }-*/;
  511. public boolean updateDropDetails(VDragEvent drag) {
  512. VerticalDropLocation oldVL = verticalDropLocation;
  513. verticalDropLocation = DDUtil.getVerticalDropLocation(getElement(),
  514. drag.getCurrentGwtEvent(), 0.2);
  515. drag.getDropDetails().put("verticalLocation",
  516. verticalDropLocation.toString());
  517. HorizontalDropLocation oldHL = horizontalDropLocation;
  518. horizontalDropLocation = DDUtil.getHorizontalDropLocation(getElement(),
  519. drag.getCurrentGwtEvent(), 0.2);
  520. drag.getDropDetails().put("horizontalLocation",
  521. horizontalDropLocation.toString());
  522. if (oldHL != horizontalDropLocation || oldVL != verticalDropLocation) {
  523. return true;
  524. } else {
  525. return false;
  526. }
  527. }
  528. protected void deEmphasis(boolean doLayout) {
  529. Size size = null;
  530. if (doLayout) {
  531. size = new RenderInformation.Size(getOffsetWidth(),
  532. getOffsetHeight());
  533. }
  534. if (emphasizedVDrop != null) {
  535. VDragAndDropWrapper.setStyleName(getElement(), OVER_STYLE, false);
  536. VDragAndDropWrapper.setStyleName(getElement(), OVER_STYLE + "-"
  537. + emphasizedVDrop.toString().toLowerCase(), false);
  538. VDragAndDropWrapper.setStyleName(getElement(), OVER_STYLE + "-"
  539. + emphasizedHDrop.toString().toLowerCase(), false);
  540. }
  541. if (doLayout) {
  542. handleVaadinRelatedSizeChange(size);
  543. }
  544. }
  545. protected void emphasis(VDragEvent drag) {
  546. Size size = new RenderInformation.Size(getOffsetWidth(),
  547. getOffsetHeight());
  548. deEmphasis(false);
  549. VDragAndDropWrapper.setStyleName(getElement(), OVER_STYLE, true);
  550. VDragAndDropWrapper.setStyleName(getElement(), OVER_STYLE + "-"
  551. + verticalDropLocation.toString().toLowerCase(), true);
  552. VDragAndDropWrapper.setStyleName(getElement(), OVER_STYLE + "-"
  553. + horizontalDropLocation.toString().toLowerCase(), true);
  554. emphasizedVDrop = verticalDropLocation;
  555. emphasizedHDrop = horizontalDropLocation;
  556. // TODO build (to be an example) an emphasis mode where drag image
  557. // is fitted before or after the content
  558. handleVaadinRelatedSizeChange(size);
  559. }
  560. protected void handleVaadinRelatedSizeChange(Size originalSize) {
  561. if (isDynamicHeight() || isDynamicWidth()) {
  562. if (!originalSize.equals(new RenderInformation.Size(
  563. getOffsetWidth(), getOffsetHeight()))) {
  564. Util.notifyParentOfSizeChange(VDragAndDropWrapper.this, false);
  565. }
  566. }
  567. client.handleComponentRelativeSize(VDragAndDropWrapper.this);
  568. Util.notifyParentOfSizeChange(this, false);
  569. }
  570. }