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.

VHtml5DragEvent.java 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. @ITMillApache2LicenseForJavaFiles@
  3. */
  4. package com.vaadin.terminal.gwt.client.ui.dd;
  5. import com.google.gwt.core.client.JsArrayString;
  6. import com.google.gwt.dom.client.NativeEvent;
  7. /**
  8. * Helper class to access html5 style drag events.
  9. *
  10. */
  11. public class VHtml5DragEvent extends NativeEvent {
  12. protected VHtml5DragEvent() {
  13. }
  14. public final native JsArrayString getTypes()
  15. /*-{
  16. return this.dataTransfer.types;
  17. }-*/;
  18. public final native String getDataAsText(String type)
  19. /*-{
  20. var v = this.dataTransfer.getData(type);
  21. return v;
  22. }-*/;
  23. /**
  24. * Works on FF 3.6 and possibly with gears.
  25. *
  26. * @param index
  27. * @return
  28. */
  29. public final native String getFileAsString(int index)
  30. /*-{
  31. if(this.dataTransfer.files.length > 0 && this.dataTransfer.files[0].getAsText) {
  32. return this.dataTransfer.files[index].getAsText("UTF-8");
  33. }
  34. return null;
  35. }-*/;
  36. public final native void setDragEffect(String effect)
  37. /*-{
  38. try {
  39. this.dataTransfer.dropEffect = effect;
  40. } catch (e){}
  41. }-*/;
  42. public final native String getEffectAllowed()
  43. /*-{
  44. return this.dataTransfer.effectAllowed;
  45. }-*/;
  46. }