@Test public void testOnBlurEventNotVisible() { doAnswer(i -> false).when(tested).isVisible(); when(event.getTypeInt()).thenReturn(Event.ONBLUR); tested.onChangeName(event); verify(presenter, never()).onClose(); }
@EventHandler("nameField") @SinkNative(Event.ONKEYDOWN | Event.ONBLUR) void onChangeName(Event e) { if (isVisible()) { if (e.getTypeInt() == Event.ONBLUR) { saveChanges(); } else if (e.getTypeInt() == Event.ONKEYDOWN) { if (e.getKeyCode() == KeyCodes.KEY_ENTER && !e.getShiftKey()) { e.stopPropagation(); e.preventDefault(); saveChanges(); } else if ((!isMultiline && e.getKeyCode() == KeyCodes.KEY_ENTER && e.getShiftKey()) || e.getKeyCode() == KeyCodes.KEY_TAB) { e.stopPropagation(); e.preventDefault(); } else if (e.getKeyCode() == KeyCodes.KEY_ESCAPE) { rollback(); } } } }
InlineTextEditorBoxViewImpl extends AbstractInlineTextEditorBoxView implements InlineEditorBoxView,
                   IsElement { @EventHandler("nameField") @SinkNative(Event.ONKEYDOWN | Event.ONBLUR) void onChangeName(Event e) { if (isVisible()) { if (e.getTypeInt() == Event.ONBLUR) { saveChanges(); } else if (e.getTypeInt() == Event.ONKEYDOWN) { if (e.getKeyCode() == KeyCodes.KEY_ENTER && !e.getShiftKey()) { e.stopPropagation(); e.preventDefault(); saveChanges(); } else if ((!isMultiline && e.getKeyCode() == KeyCodes.KEY_ENTER && e.getShiftKey()) || e.getKeyCode() == KeyCodes.KEY_TAB) { e.stopPropagation(); e.preventDefault(); } else if (e.getKeyCode() == KeyCodes.KEY_ESCAPE) { rollback(); } } } } }
InlineTextEditorBoxViewImpl extends AbstractInlineTextEditorBoxView implements InlineEditorBoxView,
                   IsElement { @EventHandler("nameField") @SinkNative(Event.ONKEYDOWN | Event.ONBLUR) void onChangeName(Event e) { if (isVisible()) { if (e.getTypeInt() == Event.ONBLUR) { saveChanges(); } else if (e.getTypeInt() == Event.ONKEYDOWN) { if (e.getKeyCode() == KeyCodes.KEY_ENTER && !e.getShiftKey()) { e.stopPropagation(); e.preventDefault(); saveChanges(); } else if ((!isMultiline && e.getKeyCode() == KeyCodes.KEY_ENTER && e.getShiftKey()) || e.getKeyCode() == KeyCodes.KEY_TAB) { e.stopPropagation(); e.preventDefault(); } else if (e.getKeyCode() == KeyCodes.KEY_ESCAPE) { rollback(); } } } } @Inject  InlineTextEditorBoxViewImpl(final TranslationService translationService);  InlineTextEditorBoxViewImpl(final TranslationService translationService,
                                       final Div editNameBox,
                                       final Div nameField,
                                       final Command showCommand,
                                       final Command hideCommand); }
InlineTextEditorBoxViewImpl extends AbstractInlineTextEditorBoxView implements InlineEditorBoxView,
                   IsElement { @EventHandler("nameField") @SinkNative(Event.ONKEYDOWN | Event.ONBLUR) void onChangeName(Event e) { if (isVisible()) { if (e.getTypeInt() == Event.ONBLUR) { saveChanges(); } else if (e.getTypeInt() == Event.ONKEYDOWN) { if (e.getKeyCode() == KeyCodes.KEY_ENTER && !e.getShiftKey()) { e.stopPropagation(); e.preventDefault(); saveChanges(); } else if ((!isMultiline && e.getKeyCode() == KeyCodes.KEY_ENTER && e.getShiftKey()) || e.getKeyCode() == KeyCodes.KEY_TAB) { e.stopPropagation(); e.preventDefault(); } else if (e.getKeyCode() == KeyCodes.KEY_ESCAPE) { rollback(); } } } } @Inject  InlineTextEditorBoxViewImpl(final TranslationService translationService);  InlineTextEditorBoxViewImpl(final TranslationService translationService,
                                       final Div editNameBox,
                                       final Div nameField,
                                       final Command showCommand,
                                       final Command hideCommand); @PostConstruct @Override void initialize(); @Override void init(Presenter presenter); @Override void setTextBoxInternalAlignment(final String alignment); @Override void setMultiline(final boolean isMultiline); @Override void setPlaceholder(final String placeholder); @Override void setFontSize(final double size); @Override void setFontFamily(final String fontFamily); @Override void show(final String name, final double width, final double height); @Override void rollback(); }
InlineTextEditorBoxViewImpl extends AbstractInlineTextEditorBoxView implements InlineEditorBoxView,
                   IsElement { @EventHandler("nameField") @SinkNative(Event.ONKEYDOWN | Event.ONBLUR) void onChangeName(Event e) { if (isVisible()) { if (e.getTypeInt() == Event.ONBLUR) { saveChanges(); } else if (e.getTypeInt() == Event.ONKEYDOWN) { if (e.getKeyCode() == KeyCodes.KEY_ENTER && !e.getShiftKey()) { e.stopPropagation(); e.preventDefault(); saveChanges(); } else if ((!isMultiline && e.getKeyCode() == KeyCodes.KEY_ENTER && e.getShiftKey()) || e.getKeyCode() == KeyCodes.KEY_TAB) { e.stopPropagation(); e.preventDefault(); } else if (e.getKeyCode() == KeyCodes.KEY_ESCAPE) { rollback(); } } } } @Inject  InlineTextEditorBoxViewImpl(final TranslationService translationService);  InlineTextEditorBoxViewImpl(final TranslationService translationService,
                                       final Div editNameBox,
                                       final Div nameField,
                                       final Command showCommand,
                                       final Command hideCommand); @PostConstruct @Override void initialize(); @Override void init(Presenter presenter); @Override void setTextBoxInternalAlignment(final String alignment); @Override void setMultiline(final boolean isMultiline); @Override void setPlaceholder(final String placeholder); @Override void setFontSize(final double size); @Override void setFontFamily(final String fontFamily); @Override void show(final String name, final double width, final double height); @Override void rollback(); static final String CARET_RETURN; static final String TEXT_ALIGN_CENTER; static final String TEXT_ALIGN_LEFT; static final String ALIGN_MIDDLE_STYLE; static final String ALIGN_LEFT_STYLE; static final String ALIGN_MIDDLE; static final String ALIGN_LEFT; static final String ALIGN_TOP; static final String DEFAULT_FONT_FAMILY; static final double DEFAULT_FONT_SIZE; }