Java 类com.google.gwt.event.dom.client.DropEvent 实例源码

项目:empiria.player    文件:DragDataObjectFromEventExtractorJUnitTest.java   
@Test
public void shouldExtractObjectWhenJsonIsValid() throws Exception {
    DropEvent dropEvent = Mockito.mock(DropEvent.class);

    String json = "some json";
    when(dropEvent.getData("json")).thenReturn(json);

    when(overlayTypesParser.isValidJSON(json)).thenReturn(true);

    NativeDragDataObject nativeDragData = Mockito.mock(NativeDragDataObject.class);
    when(overlayTypesParser.get(json)).thenReturn(nativeDragData);

    Optional<DragDataObject> extracted = dataObjectFromEventExtractor.extractDroppedObjectFromEvent(dropEvent);

    verify(dropEvent).stopPropagation();
    verify(dropEvent).preventDefault();
    assertThat(extracted.get()).isEqualTo(nativeDragData);
}
项目:empiria.player    文件:DragDataObjectFromEventExtractorJUnitTest.java   
@Test
public void shouldReturnAbsentWhenJsonIsNotValid() throws Exception {
    DropEvent dropEvent = Mockito.mock(DropEvent.class);

    String json = "some json";
    when(dropEvent.getData("json")).thenReturn(json);

    when(overlayTypesParser.isValidJSON(json)).thenReturn(false);

    NativeDragDataObject nativeDragData = Mockito.mock(NativeDragDataObject.class);
    when(overlayTypesParser.get(json)).thenReturn(nativeDragData);

    Optional<DragDataObject> extracted = dataObjectFromEventExtractor.extractDroppedObjectFromEvent(dropEvent);

    verify(dropEvent).stopPropagation();
    verify(dropEvent).preventDefault();
    assertThat(extracted.isPresent()).isEqualTo(false);
}
项目:empiria.player    文件:SourceListConnectedDropHandlerTest.java   
@Test
public void shouldExtractDataFromEventAndInformSourcelistManager() throws Exception {
    DropEvent event = Mockito.mock(DropEvent.class);

    DragDataObject dragDataObject = Mockito.mock(DragDataObject.class);
    Optional<DragDataObject> optionalDragData = Optional.fromNullable(dragDataObject);
    when(dragDataObjectFromEventExtractor.extractDroppedObjectFromEvent(event)).thenReturn(optionalDragData);

    String itemId = "itemId";
    when(dragDataObject.getItemId()).thenReturn(itemId);

    String sourceId = "sourceId";
    when(dragDataObject.getSourceId()).thenReturn(sourceId);

    dropHandler.onDrop(event);

    verify(sourceListManagerAdapter).dragEnd(itemId, sourceId);
}
项目:empiria.player    文件:DragDataObjectFromEventExtractor.java   
public Optional<DragDataObject> extractDroppedObjectFromEvent(DropEvent dropEvent) {
    String jsonObject = dropEvent.getData("json");
    Optional<DragDataObject> dragData;
    if (overlayTypesParser.isValidJSON(jsonObject)) {
        NativeDragDataObject nativeDragData = overlayTypesParser.get(jsonObject);
        DragDataObject dragDataObject = nativeDragData;
        dragData = Optional.fromNullable(dragDataObject);
    } else {
        dragData = Optional.absent();
    }
    dropEvent.stopPropagation();
    dropEvent.preventDefault();

    return dragData;
}
项目:empiria.player    文件:SourceListConnectedDropHandler.java   
@Override
public void onDrop(DropEvent event) {
    Optional<DragDataObject> objectFromEvent = dragDataObjectFromEventExtractor.extractDroppedObjectFromEvent(event);
    if (objectFromEvent.isPresent()) {
        informSourceListManagerAboutDrop(objectFromEvent.get());
    }
}
项目:empiria.player    文件:SourceListViewDropHandler.java   
@Override
public void onDrop(DropEvent event) {
    Optional<DragDataObject> objectFromEvent = objectFromEventExtractor.extractDroppedObjectFromEvent(event);
    if (objectFromEvent.isPresent()) {
        DragDataObject dataObject = objectFromEvent.get();
        sourceListPresenter.onDropEvent(dataObject.getItemId(), dataObject.getSourceId());
    }
}
项目:empiria.player    文件:TextEntryGapModulePresenterBase.java   
public void addDomHandlerOnObjectDrop(final GapDropHandler dragGapDropHandler) {
    droppable.addDropHandler(new DropHandler() {
        @Override
        public void onDrop(DropEvent event) {
            Optional<DragDataObject> objectFromEvent = dataObjectFromEventExtractor.extractDroppedObjectFromEvent(event);
            if (objectFromEvent.isPresent()) {
                dragGapDropHandler.onDrop(objectFromEvent.get());
            }
        }
    });
}
项目:empiria.player    文件:TextBoxChangeHandlerJUnitTest.java   
@Test
public void shouldHandleDropAsOnBlur() {
    // given
    DropEvent event = mock(DropEvent.class);

    // when
    testObj.bind(droppableObject, presenterHandler);
    testObj.onDrop(event);

    // then
    verify(presenterHandler).onBlur(Matchers.any(BlurEvent.class));
}
项目:empiria.player    文件:TextBoxChangeHandler.java   
@Override
public void onDrop(DropEvent event) {
    BlurEvent noopBlurEvent = new BlurEvent() {
    };
    callBlurHandler(noopBlurEvent);
}
项目:appinventor-extensions    文件:HandlerPanel.java   
public HandlerRegistration addDropHandler(DropHandler handler) {
  return addBitlessDomHandler(handler, DropEvent.getType());
}
项目:gwthtml5apps    文件:DropDockRootPanel.java   
/**
* 
*/
 @Override
   public HandlerRegistration addDropHandler(DropHandler handler) {
       return addBitlessDomHandler(handler, DropEvent.getType());
   }
项目:putnami-web-toolkit    文件:AbstractInput.java   
@Override
public com.google.gwt.event.shared.HandlerRegistration addDropHandler(DropHandler handler) {
    return this.addBitlessDomHandler(handler, DropEvent.getType());
}
项目:putnami-web-toolkit    文件:ListItem.java   
@Override
public HandlerRegistration addDropHandler(DropHandler handler) {
    return this.addBitlessDomHandler(handler, DropEvent.getType());
}
项目:putnami-web-toolkit    文件:Anchor.java   
@Override
public HandlerRegistration addDropHandler(DropHandler handler) {
    return this.addBitlessDomHandler(handler, DropEvent.getType());
}