Search in sources :

Example 26 with Event

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;
    };
}
Also used : ErrorCallback(org.jboss.errai.common.client.api.ErrorCallback) FileReader(elemental2.dom.FileReader) DocumentUploadChunk(org.kie.workbench.common.forms.jbpm.service.shared.documents.DocumentUploadChunk) RemoteCallback(org.jboss.errai.common.client.api.RemoteCallback)

Example 27 with Event

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();
    }
}
Also used : DragEvent(elemental2.dom.DragEvent) Node(elemental2.dom.Node) EventTarget(elemental2.dom.EventTarget)

Example 28 with Event

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();
}
Also used : HTMLElement(elemental2.dom.HTMLElement) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) DataType(org.kie.workbench.common.dmn.client.editors.types.common.DataType) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 29 with Event

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();
}
Also used : KeyboardEvent(elemental2.dom.KeyboardEvent) Event(org.jboss.errai.common.client.dom.Event) Test(org.junit.Test)

Example 30 with Event

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();
}
Also used : KeyboardEvent(elemental2.dom.KeyboardEvent) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)50 HTMLElement (elemental2.dom.HTMLElement)27 Event (elemental2.dom.Event)26 KeyboardEvent (elemental2.dom.KeyboardEvent)19 Element (elemental2.dom.Element)18 MouseEvent (elemental2.dom.MouseEvent)16 HTMLDivElement (elemental2.dom.HTMLDivElement)15 HTMLInputElement (elemental2.dom.HTMLInputElement)13 HTMLButtonElement (elemental2.dom.HTMLButtonElement)12 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)10 BlurEvent (com.google.gwt.event.dom.client.BlurEvent)7 CSSStyleDeclaration (elemental2.dom.CSSStyleDeclaration)7 JQuery (org.uberfire.client.views.pfly.selectpicker.JQuery)7 DOMRect (elemental2.dom.DOMRect)5 DOMTokenList (elemental2.dom.DOMTokenList)5 DomGlobal (elemental2.dom.DomGlobal)5 LazyReverseView (com.github.mvp4g.mvp4g2.core.ui.LazyReverseView)4 AbstractCell (com.google.gwt.cell.client.AbstractCell)4 Elements.button (org.jboss.gwt.elemento.core.Elements.button)4 Elements.div (org.jboss.gwt.elemento.core.Elements.div)4