@Override public void dragOver(VDragEvent drag) { // Remove any emphasis getLayout().emphasis(null, null); Slot slot = getSlot(drag.getElementOver(), drag.getCurrentGwtEvent()); if (slot != null) { getLayout().updateDragDetails(slot, drag); } else { getLayout().updateDragDetails(getLayout(), drag); } getLayout().postOverHook(drag); // Validate the drop validate( new VAcceptCallback() { public void accepted(VDragEvent event) { Slot slot = getSlot(event.getElementOver(), event.getCurrentGwtEvent()); if (slot != null) { getLayout().emphasis(slot, event); } else { getLayout().emphasis(getLayout(), event); } } }, drag); }
static VDragEvent createMockedVDragEvent(String dragSourceId, Widget widget, String theme) { VDragEvent dragEvent = createMockedVDragEvent(dragSourceId, widget); ApplicationConnection connection = Mockito.mock(ApplicationConnection.class); when(dragEvent.getTransferable().getDragSource().getConnection()).thenReturn(connection); UIConnector uiConnector = Mockito.mock(UIConnector.class); when(connection.getUIConnector()).thenReturn(uiConnector); when(uiConnector.getActiveTheme()).thenReturn(theme); return dragEvent; }
@Override public boolean drop(VDragEvent drag) { // Un-emphasis any selections getLayout().emphasis(null, null); // Update the details Widget slot = getSlot(drag.getElementOver(), drag.getCurrentGwtEvent()); getLayout().updateDragDetails(slot, drag); return getLayout().postDropHook(drag) && super.drop(drag); }
@Override public void dragEnter(VDragEvent drag) { super.dragEnter(drag); Slot slot = getSlot(drag.getElementOver(), drag.getCurrentGwtEvent()); if (slot != null) { getLayout().updateDragDetails(slot, drag); } else { getLayout().updateDragDetails(getLayout(), drag); } getLayout().postEnterHook(drag); }
static VDragEvent createMockedVDragEvent(String dragSourceId, Widget widget) { com.google.gwt.user.client.Element element = Mockito.mock(com.google.gwt.user.client.Element.class); when(element.getId()).thenReturn(dragSourceId); when(widget.getElement()).thenReturn(element); ComponentConnector dragSource = Mockito.mock(ComponentConnector.class); when(dragSource.getWidget()).thenReturn(widget); VTransferable transferable = Mockito.mock(VTransferable.class); when(transferable.getDragSource()).thenReturn(dragSource); VDragEvent dragEvent = Mockito.mock(VDragEvent.class); when(dragEvent.getTransferable()).thenReturn(transferable); return dragEvent; }
@Override public void accept(final VDragEvent drag, UIDL configuration, final VAcceptCallback callback) { if (lastDragEvent == null || lastDragEvent != drag) { loaded = false; lastDragEvent = drag; } if (loaded) { Object object = drag.getDropDetails().get("itemIdOver"); if (hashSet.contains(object)) { callback.accepted(drag); } } else { VDragEventServerCallback acceptCallback = new VDragEventServerCallback() { @Override public void handleResponse(boolean accepted, UIDL response) { hashSet = new HashSet<String>(); String[] stringArrayAttribute = response.getStringArrayAttribute("allowedIds"); for (int i = 0; i < stringArrayAttribute.length; i++) { hashSet.add(stringArrayAttribute[i]); } loaded = true; if (accepted) { callback.accepted(drag); } } }; VDragAndDropManager.get().visitServer(acceptCallback); } }