Search in sources :

Example 21 with BlurHandler

use of com.google.gwt.event.dom.client.BlurHandler in project drools-wb by kiegroup.

the class ListBoxSingletonDOMElementFactoryTest method checkDOMElementCreationBlurHandler.

@Test
@SuppressWarnings("unchecked")
public void checkDOMElementCreationBlurHandler() {
    final GridBodyCellRenderContext context = mock(GridBodyCellRenderContext.class);
    final Consumer<ListBoxDOMElement<String, ListBox>> onCreation = mock(Consumer.class);
    final Consumer<ListBoxDOMElement<String, ListBox>> onDisplay = mock(Consumer.class);
    when(context.getTransform()).thenReturn(mock(Transform.class));
    factory.attachDomElement(context, onCreation, onDisplay);
    final ArgumentCaptor<EventHandler> handlerCaptor = ArgumentCaptor.forClass(EventHandler.class);
    verify(listBox, times(4)).addDomHandler(handlerCaptor.capture(), any(DomEvent.Type.class));
    // KeyDownHandlerCommon
    Assertions.assertThat(handlerCaptor.getAllValues().get(0)).isInstanceOf(KeyDownHandlerCommon.class);
    // KeyDownHandler - stopPropagation
    final KeyDownEvent keyDownEventMock = mock(KeyDownEvent.class);
    Assertions.assertThat(handlerCaptor.getAllValues().get(1)).isInstanceOf(KeyDownHandler.class);
    ((KeyDownHandler) handlerCaptor.getAllValues().get(1)).onKeyDown(keyDownEventMock);
    verify(keyDownEventMock).stopPropagation();
    // MouseDownHandler - stopPropagation
    final MouseDownEvent mouseDownEventMock = mock(MouseDownEvent.class);
    Assertions.assertThat(handlerCaptor.getAllValues().get(2)).isInstanceOf(MouseDownHandler.class);
    ((MouseDownHandler) handlerCaptor.getAllValues().get(2)).onMouseDown(mouseDownEventMock);
    verify(mouseDownEventMock).stopPropagation();
    // BlurHandler
    final BlurEvent blurEventMock = mock(BlurEvent.class);
    Assertions.assertThat(handlerCaptor.getAllValues().get(3)).isInstanceOf(BlurHandler.class);
    ((BlurHandler) handlerCaptor.getAllValues().get(3)).onBlur(blurEventMock);
    verify(factory).flush();
    verify(gridLayer).batch();
    verify(gridLienzoPanel).setFocus(true);
}
Also used : BlurHandler(com.google.gwt.event.dom.client.BlurHandler) KeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler) EventHandler(com.google.gwt.event.shared.EventHandler) MouseDownEvent(com.google.gwt.event.dom.client.MouseDownEvent) GridBodyCellRenderContext(org.uberfire.ext.wires.core.grids.client.widget.context.GridBodyCellRenderContext) KeyDownEvent(com.google.gwt.event.dom.client.KeyDownEvent) BlurEvent(com.google.gwt.event.dom.client.BlurEvent) Transform(com.ait.lienzo.client.core.types.Transform) MouseDownHandler(com.google.gwt.event.dom.client.MouseDownHandler) Test(org.junit.Test)

Example 22 with BlurHandler

use of com.google.gwt.event.dom.client.BlurHandler in project drools-wb by kiegroup.

the class FactPatternConstraintsPageViewImpl method initialiseValueList.

private void initialiseValueList() {
    // Copy value back to model
    txtValueList.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(final ValueChangeEvent<String> event) {
            final String valueList = txtValueList.getText();
            chosenConditionsSelection.setValueList(valueList);
        // ValueList is optional, no need to advise of state change
        }
    });
    // Update Default Value widget if necessary
    txtValueList.addBlurHandler(new BlurHandler() {

        @Override
        public void onBlur(final BlurEvent event) {
            presenter.assertDefaultValue(availablePatternsSelection, chosenConditionsSelection);
            makeDefaultValueWidget();
        }
    });
}
Also used : BlurHandler(com.google.gwt.event.dom.client.BlurHandler) BlurEvent(com.google.gwt.event.dom.client.BlurEvent)

Example 23 with BlurHandler

use of com.google.gwt.event.dom.client.BlurHandler in project drools-wb by kiegroup.

the class ActionInsertFactFieldsPageViewImpl method initialiseValueList.

private void initialiseValueList() {
    // Copy value back to model
    txtValueList.addValueChangeHandler(new ValueChangeHandler<String>() {

        @Override
        public void onValueChange(final ValueChangeEvent<String> event) {
            final String valueList = txtValueList.getText();
            chosenFieldsSelection.setValueList(valueList);
        // ValueList is optional, no need to advise of state change
        }
    });
    // Update Default Value widget if necessary
    txtValueList.addBlurHandler(new BlurHandler() {

        @Override
        public void onBlur(final BlurEvent event) {
            presenter.assertDefaultValue(chosenFieldsSelection);
            makeDefaultValueWidget();
        }
    });
}
Also used : BlurHandler(com.google.gwt.event.dom.client.BlurHandler) BlurEvent(com.google.gwt.event.dom.client.BlurEvent)

Example 24 with BlurHandler

use of com.google.gwt.event.dom.client.BlurHandler in project che by eclipse.

the class TextEditorPartViewImpl method setEditorWidget.

@Override
public void setEditorWidget(final EditorWidget editorWidget) {
    if (this.editorPanel.getWidget() != null) {
        throw new RuntimeException("Editor already set");
    }
    this.editorPanel.setWidget(editorWidget);
    editorWidget.addCursorActivityHandler(new CursorActivityHandler() {

        @Override
        public void onCursorActivity(final CursorActivityEvent event) {
            delegate.editorCursorPositionChanged();
        }
    });
    editorWidget.addBlurHandler(new BlurHandler() {

        @Override
        public void onBlur(final BlurEvent event) {
            delegate.editorLostFocus();
        }
    });
    editorWidget.addFocusHandler(new FocusHandler() {

        @Override
        public void onFocus(final FocusEvent event) {
            delegate.editorGotFocus();
        }
    });
}
Also used : CursorActivityEvent(org.eclipse.che.ide.api.editor.events.CursorActivityEvent) BlurHandler(com.google.gwt.event.dom.client.BlurHandler) FocusHandler(com.google.gwt.event.dom.client.FocusHandler) BlurEvent(com.google.gwt.event.dom.client.BlurEvent) CursorActivityHandler(org.eclipse.che.ide.api.editor.events.CursorActivityHandler) FocusEvent(com.google.gwt.event.dom.client.FocusEvent)

Example 25 with BlurHandler

use of com.google.gwt.event.dom.client.BlurHandler in project rstudio by rstudio.

the class MenuBar method init.

private void init(boolean vertical, AbstractImagePrototype subMenuIcon) {
    this.subMenuIcon = subMenuIcon;
    Element table = DOM.createTable();
    body = DOM.createTBody();
    DOM.appendChild(table, body);
    if (!vertical) {
        Element tr = DOM.createTR();
        DOM.appendChild(body, tr);
    }
    this.vertical = vertical;
    com.google.gwt.dom.client.Element outer = FocusPanel.impl.createFocusable();
    DOM.appendChild(outer, table);
    setElement(outer);
    Accessibility.setRole(getElement(), Accessibility.ROLE_MENUBAR);
    sinkEvents(Event.ONCLICK | Event.ONMOUSEOVER | Event.ONMOUSEOUT | Event.ONFOCUS | Event.ONKEYDOWN);
    setStyleName(STYLENAME_DEFAULT);
    if (vertical) {
        addStyleDependentName("vertical");
    } else {
        addStyleDependentName("horizontal");
    }
    // Hide focus outline in Mozilla/Webkit/Opera
    DOM.setStyleAttribute(getElement(), "outline", "0px");
    // Hide focus outline in IE 6/7
    DOM.setElementAttribute(getElement(), "hideFocus", "true");
    // Deselect items when blurring without a child menu.
    addDomHandler(new BlurHandler() {

        public void onBlur(BlurEvent event) {
            if (shownChildMenu == null) {
                selectItem(null);
            }
        }
    }, BlurEvent.getType());
}
Also used : BlurHandler(com.google.gwt.event.dom.client.BlurHandler) Element(com.google.gwt.user.client.Element) BlurEvent(com.google.gwt.event.dom.client.BlurEvent)

Aggregations

BlurHandler (com.google.gwt.event.dom.client.BlurHandler)34 BlurEvent (com.google.gwt.event.dom.client.BlurEvent)28 KeyPressEvent (com.google.gwt.event.dom.client.KeyPressEvent)10 KeyPressHandler (com.google.gwt.event.dom.client.KeyPressHandler)10 Test (org.junit.Test)9 KeyUpEvent (com.google.gwt.event.dom.client.KeyUpEvent)6 KeyUpHandler (com.google.gwt.event.dom.client.KeyUpHandler)6 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)5 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)5 Element (com.google.gwt.dom.client.Element)4 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)4 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)4 FocusEvent (com.google.gwt.event.dom.client.FocusEvent)3 FocusHandler (com.google.gwt.event.dom.client.FocusHandler)3 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)2 SpanElement (com.google.gwt.dom.client.SpanElement)2 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)2 KeyDownHandler (com.google.gwt.event.dom.client.KeyDownHandler)2 MouseOutEvent (com.google.gwt.event.dom.client.MouseOutEvent)2