Search in sources :

Example 46 with Event

use of elemental2.dom.Event in project kie-wb-common by kiegroup.

the class TimePicker method inputOnBlur.

private Object inputOnBlur(final Event event) {
    final FocusEvent focusEvent = (FocusEvent) event;
    onBlur(focusEvent, view.getElement());
    return this;
}
Also used : FocusEvent(elemental2.dom.FocusEvent)

Example 47 with Event

use of elemental2.dom.Event in project kie-wb-common by kiegroup.

the class ValueAndDataTypePopoverViewImpl method typeSelectorKeyDownEventListener.

void typeSelectorKeyDownEventListener(final Object event) {
    if (event instanceof KeyboardEvent) {
        final KeyboardEvent keyEvent = (KeyboardEvent) event;
        if (isEnterKeyPressed(keyEvent)) {
            hide(true);
            keyEvent.preventDefault();
            onClosedByKeyboard();
        } else if (isEscapeKeyPressed(keyEvent)) {
            reset();
            hide(false);
            onClosedByKeyboard();
        } else if (isTabKeyPressed(keyEvent)) {
            if (keyEvent.shiftKey) {
                final Button manageButton = getManageButton();
                manageButton.focus();
            } else {
                valueEditor.focus();
            }
            keyEvent.preventDefault();
        }
    }
}
Also used : Button(org.jboss.errai.common.client.dom.Button) KeyboardEvent(elemental2.dom.KeyboardEvent)

Example 48 with Event

use of elemental2.dom.Event in project kie-wb-common by kiegroup.

the class MenuInitializerTest method testMoveDropDownToBody.

@Test
public void testMoveDropDownToBody() {
    final HTMLElement modalInElement = mock(HTMLElement.class);
    final HTMLElement target = mock(HTMLElement.class);
    final JQuery jQueryModalIn = mock(JQuery.class);
    final JQuery jQueryTarget = mock(JQuery.class);
    final JQuery jQueryCSS = mock(JQuery.class);
    final JQuery jQueryDetach = mock(JQuery.class);
    final JQueryEvent event = mock(JQueryEvent.class);
    final JSONObject jsonObjectProperties = mock(JSONObject.class);
    final JavaScriptObject javaScriptObjectProperties = mock(JavaScriptObject.class);
    event.target = target;
    doReturn(jsonObjectProperties).when(initializer).bodyDropdownProperties(event);
    doReturn(modalInElement).when(initializer).body();
    when(jsonObjectProperties.getJavaScriptObject()).thenReturn(javaScriptObjectProperties);
    when(jQueryTarget.css(javaScriptObjectProperties)).thenReturn(jQueryCSS);
    when(jQueryCSS.detach()).thenReturn(jQueryDetach);
    when(initializer.jQuery(modalInElement)).thenReturn(jQueryModalIn);
    when(initializer.jQuery(target)).thenReturn(jQueryTarget);
    initializer.moveDropDownToBody().call(event);
    verify(jQueryModalIn).append(jQueryDetach);
}
Also used : HTMLElement(elemental2.dom.HTMLElement) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JQueryEvent(org.uberfire.client.views.pfly.selectpicker.JQueryEvent) JQuery(org.uberfire.client.views.pfly.selectpicker.JQuery) Test(org.junit.Test)

Example 49 with Event

use of elemental2.dom.Event in project kie-wb-common by kiegroup.

the class BaseSelectorViewTest method testSetOnInputChangeCallbackWithKeyUpEvent.

@Test
public void testSetOnInputChangeCallbackWithKeyUpEvent() {
    final Event event = mock(Event.class);
    selectorView.setOnInputChangeCallback(eventConsumer);
    input.onkeyup.onInvoke(event);
    verify(eventConsumer).accept(event);
}
Also used : Event(elemental2.dom.Event) BlurEvent(com.google.gwt.event.dom.client.BlurEvent) Test(org.junit.Test)

Example 50 with Event

use of elemental2.dom.Event in project kie-wb-common by kiegroup.

the class ContextMenuViewTest method testWhenGettingEventPathAndPathIsNull.

@Test
public void testWhenGettingEventPathAndPathIsNull() {
    final Event event = mock(Event.class);
    final Element element = mock(Element.class);
    final JsArray<EventTarget> composedPath = spy(new JsArray<>());
    final List<EventTarget> composedPathAsList = new ArrayList<>();
    final String value = "test-val";
    event.path = null;
    composedPathAsList.add(element);
    doReturn(composedPathAsList).when(composedPath).asList();
    when(event.composedPath()).thenReturn(composedPath);
    when(element.getAttribute(Mockito.<String>any())).thenReturn(value);
    final List<Element> eventPath = contextMenuView.getEventPath(event);
    assertThat(eventPath).isNotNull();
    assertThat(eventPath).isNotEmpty();
    assertThat(eventPath.size()).isEqualTo(1);
    assertThat(eventPath.get(0)).extracting(elem -> elem.getAttribute("test-attr")).isEqualTo(value);
}
Also used : Element(elemental2.dom.Element) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) Event(elemental2.dom.Event) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Mockito.spy(org.mockito.Mockito.spy) ListSelector(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.ListSelector) ArrayList(java.util.ArrayList) EventTarget(elemental2.dom.EventTarget) HTMLDocument(elemental2.dom.HTMLDocument) Mockito.doReturn(org.mockito.Mockito.doReturn) Command(org.uberfire.mvp.Command) Before(org.junit.Before) DomGlobal(elemental2.dom.DomGlobal) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) Field(java.lang.reflect.Field) JsArray(elemental2.core.JsArray) Mockito.verify(org.mockito.Mockito.verify) ListSelectorTextItem(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorTextItem) Mockito(org.mockito.Mockito) List(java.util.List) Modifier(java.lang.reflect.Modifier) ListSelectorItem(org.kie.workbench.common.dmn.client.widgets.grid.controls.list.HasListSelectorControl.ListSelectorItem) Mockito.anyInt(org.mockito.Mockito.anyInt) Collections(java.util.Collections) Mockito.mock(org.mockito.Mockito.mock) Element(elemental2.dom.Element) ArrayList(java.util.ArrayList) Event(elemental2.dom.Event) EventTarget(elemental2.dom.EventTarget) 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