diff options
author | Adam Wagner <wbadam@users.noreply.github.com> | 2017-05-03 12:08:19 +0300 |
---|---|---|
committer | Pekka Hyvönen <pekka@vaadin.com> | 2017-05-03 12:08:19 +0300 |
commit | ac00b616f4522b69dfcaf324be16b1880470392b (patch) | |
tree | b0039fdec14ee834009da32cf1fcbd2f1df9a5c5 | |
parent | ff52c42738a96c3fde01c40d33075376bcae1339 (diff) | |
download | vaadin-framework-ac00b616f4522b69dfcaf324be16b1880470392b.tar.gz vaadin-framework-ac00b616f4522b69dfcaf324be16b1880470392b.zip |
Use style name for drag source according to convention (#9091)
-rw-r--r-- | client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java b/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java index 8a26694bde..165e0ca9df 100644 --- a/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java +++ b/client/src/main/java/com/vaadin/client/extensions/DragSourceExtensionConnector.java @@ -44,7 +44,12 @@ import elemental.events.EventTarget; @Connect(DragSourceExtension.class) public class DragSourceExtensionConnector extends AbstractExtensionConnector { - private static final String CLASS_DRAGGABLE = "v-draggable"; + /** + * Style suffix for indicating that the element is a drag source. + */ + protected static final String STYLE_SUFFIX_DRAGSOURCE = "-dragsource"; + + private static final String STYLE_NAME_DRAGGABLE = "v-draggable"; // Create event listeners private final EventListener dragStartListener = this::onDragStart; @@ -76,7 +81,10 @@ public class DragSourceExtensionConnector extends AbstractExtensionConnector { */ protected void setDraggable(Element element) { element.setDraggable(Element.DRAGGABLE_TRUE); - element.addClassName(CLASS_DRAGGABLE); + element.addClassName( + getStylePrimaryName(element) + STYLE_SUFFIX_DRAGSOURCE); + element.addClassName(STYLE_NAME_DRAGGABLE); + } /** @@ -87,7 +95,9 @@ public class DragSourceExtensionConnector extends AbstractExtensionConnector { */ protected void removeDraggable(Element element) { element.setDraggable(Element.DRAGGABLE_FALSE); - element.removeClassName(CLASS_DRAGGABLE); + element.removeClassName( + getStylePrimaryName(element) + STYLE_SUFFIX_DRAGSOURCE); + element.removeClassName(STYLE_NAME_DRAGGABLE); } /** @@ -271,4 +281,8 @@ public class DragSourceExtensionConnector extends AbstractExtensionConnector { public DragSourceState getState() { return (DragSourceState) super.getState(); } + + private native boolean getStylePrimaryName(Element element)/*-{ + return @com.google.gwt.user.client.ui.UIObject::getStylePrimaryName(Lcom/google/gwt/dom/client/Element;)(element); + }-*/; } |