use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class DocumentUploadManager method initFileReader.
public void initFileReader() {
fileReader = new FileReader();
fileReader.onload = event -> {
if (fileReader.readyState == FileReader.DONE) {
String[] split = fileReader.result.asString().split(",");
String content = "";
if (split.length == 2) {
content = split[1];
}
if (activeSession == null) {
return null;
}
DocumentUploadChunk newChunk = new DocumentUploadChunk(activeSession.documentId, activeSession.file.name, activeSession.chunk, activeSession.maxChunks, content);
uploadService.call((RemoteCallback<DocumentUploadResponse>) response -> {
if (response.getState().equals(DocumentUploadResponse.DocumentUploadState.FINISH)) {
activeSession.onUploadEnd.execute(response.isSuccess());
activeSession = null;
startUpload();
} else if (!response.isSuccess()) {
activeSession.onUploadEnd.execute(response.isSuccess());
activeSession = null;
startUpload();
}
}, (ErrorCallback<Message>) (message, throwable) -> {
activeSession.onUploadEnd.execute(false);
activeSession = null;
startUpload();
return false;
}).uploadContent(newChunk);
if (activeSession.nextChunk <= activeSession.file.size) {
upload(activeSession.nextChunk);
}
}
return null;
};
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class DocumentUploadViewImpl method onDragEnd.
private void onDragEnd(Event event) {
if (dropRegion.contains(dropHere)) {
EventTarget relatedTarget = ((DragEvent) event).relatedTarget;
if (relatedTarget.equals(dropHere) || dropHere.contains((Node) relatedTarget)) {
return;
}
restore();
}
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class DataTypeSelectViewTest method testOnTypeTextClickWhenItsBuiltInType.
@Test
public void testOnTypeTextClickWhenItsBuiltInType() {
final ClickEvent event = mock(ClickEvent.class);
final String type = "string";
final DataType dataType = makeDataType(type);
final HTMLElement element = mock(HTMLElement.class);
when(presenter.getDataType()).thenReturn(dataType);
doReturn(element).when(view).getElement();
view.onTypeTextClick(event);
verify(structureTypesTooltip, never()).show(any(), anyString());
verify(event).preventDefault();
verify(event).stopPropagation();
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class ListSelectorViewImplTest method testOnKeyDownWhenEscapeIsNotPressed.
@Test
public void testOnKeyDownWhenEscapeIsNotPressed() {
final Event event = mock(Event.class);
doReturn(false).when(view).isEscape(event);
view.onKeyDown().call(event);
verify(view, never()).hide();
verify(view, never()).returnFocusToPanel();
}
use of elemental2.dom.Event in project kie-wb-common by kiegroup.
the class AbstractPopoverViewImplTest method testKeyDownEventListenerWhenIsNotAHandledKey.
@Test
public void testKeyDownEventListenerWhenIsNotAHandledKey() {
final KeyboardEvent event = mock(KeyboardEvent.class);
doReturn(false).when(view).isEnterKeyPressed(event);
doReturn(false).when(view).isEscapeKeyPressed(event);
view.keyDownEventListener(event);
verify(view, never()).hide();
verify(event, never()).stopPropagation();
verify(view, never()).onClosedByKeyboard();
verify(view, never()).reset();
}
Aggregations