private void testValidNumericValueConstraintMatch(final String scoreHolderClass, final String constraintMatchValue) throws Exception { ConstraintMatchInputWidgetBlurHandler handler = new ConstraintMatchInputWidgetBlurHandler(widget, translationService, scoreHolderClass); when(widget.getConstraintMatchValue()).thenReturn(constraintMatchValue); when(translationService.getTranslation(GuidedRuleEditorConstants.ConstraintMatchInputWidgetBlurHandler_IntegerValueParsingError)) .thenReturn("translation"); handler.onBlur(mock(BlurEvent.class)); verify(widget, never()).showError("translation"); verify(widget, times(1)).clearError(); }
@Override public HandlerRegistration addBlurHandler(BlurHandler handler) { if (!blurHandlerAdded) { blurHandlerAdded = true; final OrionTextViewOverlay textView = this.editorOverlay.getTextView(); textView.addEventListener( OrionEventConstants.BLUR_EVENT, new OrionTextViewOverlay.EventHandlerNoParameter() { @Override public void onEvent() { fireBlurEvent(); } }); } return addHandler(handler, BlurEvent.getType()); }
private void addHandlers() { BlurHandler blurHandler = new BlurHandler() { public void onBlur(BlurEvent ev) { checkForChange(true); } }; _textBox.addKeyPressHandler(new KeyHandler()); _textBox.addBlurHandler(blurHandler); }
@Override public void onBlur(BlurEvent p_event) { if( !m_isEditableMode && m_text.getText().isEmpty() ) { return; } if( m_isEditableMode && m_text.getText().equalsIgnoreCase( GameEngine.model().getGame().getMessage() ) ) { // message didn't change: don't send message event return; } if( GameEngine.model().getGame().isRecordingScript() ) { // or we are recording user event GameEngine.model().getGame().setMessage( m_text.getText() ); return; } EbEvtMessage message = new EbEvtMessage(); message.setGame( GameEngine.model().getGame() ); message.setMessage( m_text.getText().trim() ); message.setAccountId( AppMain.instance().getMyAccount().getId() ); GameEngine.model().runSingleAction( message ); }
private void addLostFocusHandler(final PropertyEditorFieldInfo property, final PropertyEditorPasswordTextBox passwordTextBox) { passwordTextBox.addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { if (validate(property, passwordTextBox.getText())) { passwordTextBox.clearOldValidationErrors(); property.setCurrentStringValue(passwordTextBox.getText()); propertyEditorChangeEventEvent.fire(new PropertyEditorChangeEvent(property, passwordTextBox.getText())); } else { passwordTextBox.setValidationError(getValidatorErrorMessage(property, passwordTextBox.getText())); passwordTextBox.setText(property.getCurrentStringValue()); } } }); }
private void addLostFocusHandler(final PropertyEditorFieldInfo property, final PropertyEditorTextBox textBox) { textBox.addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { if (validate(property, textBox.getText())) { textBox.clearOldValidationErrors(); property.setCurrentStringValue(textBox.getText()); propertyEditorChangeEventEvent.fire(new PropertyEditorChangeEvent(property, textBox.getText())); } else { textBox.setValidationError(getValidatorErrorMessage(property, textBox.getText())); textBox.setText(property.getCurrentStringValue()); } } }); }
@Override public ListBoxDOMElement createDomElement(final GridLayer gridLayer, final GridWidget gridWidget, final GridBodyCellRenderContext context) { this.widget = createWidget(); this.e = new ListBoxDOMElement(widget, gridLayer, gridWidget); widget.addBlurHandler(new BlurHandler() { @Override public void onBlur(final BlurEvent event) { destroyResources(); gridLayer.batch(); gridPanel.setFocus(true); } }); return e; }
@Override public TextBoxDOMElement createDomElement(final GridLayer gridLayer, final GridWidget gridWidget, final GridBodyCellRenderContext context) { this.widget = createWidget(); this.e = new TextBoxDOMElement(widget, gridLayer, gridWidget); widget.addBlurHandler(new BlurHandler() { @Override public void onBlur(final BlurEvent event) { destroyResources(); gridLayer.batch(); gridPanel.setFocus(true); } }); return e; }
@Override public TextBoxDOMElement createDomElement(final GridLayer gridLayer, final GridWidget gridWidget, final GridBodyCellRenderContext context) { final TextBox widget = createWidget(); final TextBoxDOMElement e = new TextBoxDOMElement(widget, gridLayer, gridWidget); widget.addBlurHandler(new BlurHandler() { @Override public void onBlur(final BlurEvent event) { e.flush(widget.getValue()); gridLayer.batch(); } }); return e; }
public void setFocusLost(JavaScriptObject aValue) { if (focusLost != aValue) { if (blurReg != null) { blurReg.removeHandler(); blurReg = null; } focusLost = aValue; if (focusLost != null && component instanceof HasBlurHandlers) { blurReg = ((HasBlurHandlers) component).addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { if (focusLost != null) { executeEvent(focusLost, EventsPublisher.publish(event)); } mouseState = MOUSE.NULL; } }); } } }
protected void handleTypeAttribute(UIObject uiObject, final String regExp, final String validationMessage, final String validationTitle) { if (uiObject instanceof TextBox) { TextBox textBox = (TextBox)uiObject; textBox.addBlurHandler(new BlurHandler(){ public void onBlur(BlurEvent event) { String textValue = ((TextBoxBase)event.getSource()).getText(); if ((textValue != null) && (regExp != null)) { if (textValue.replaceFirst(regExp, "").length() > 0) { if (validationTitle != null) { ClientApplicationContext.getInstance().log(validationTitle, validationMessage,true); } else { ClientApplicationContext.getInstance().log("Validation error", validationMessage,true); } } } } }); } }
public Text(Composite parent, int style) { this(new TextArea(), parent, style); textArea = (TextArea) getGwtWidget(); panel = (LayoutPanel) getParent().getGwtWidget().getParent(); panel.add(textArea); textArea.addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { setText(textArea.getText()); textArea.removeFromParent(); sendEvent(SWT.Modify); sendEvent(SWT.FocusOut); } }); }
private void bindHandlers() { if (this.widget == null) { return; } this.registrations.removeHandler(); switch (this.getTrigger()) { case FOCUS: this.registrations.add(this.widget.addDomHandler(this.triggerEventHandler, FocusEvent.getType())); this.registrations.add(this.widget.addDomHandler(this.triggerEventHandler, BlurEvent.getType())); break; case HOVER: this.registrations.add(this.widget.addDomHandler(this.triggerEventHandler, MouseOverEvent.getType())); this.registrations.add(this.widget.addDomHandler(this.triggerEventHandler, MouseOutEvent.getType())); break; case MANUAL: break; default: break; } }
@Override public void onBlur(BlurEvent event) { this.focused = false; if (this.input != null) { T val = this.input.flush(); StyleUtils.toggleStyle(this.container, InputList.STYLE_ERROR, this.hasErrors()); if (val == null && !this.hasErrors()) { InputList.this.removeEditor(this); } else { this.itemValue = val; this.output.edit(val); } } this.resetFocusHandler(); this.redraw(); }
public void onBlur(final BlurEvent event) { final String interval = getText(); if (!interval.matches(regexp)) { // Steal the dateBoxFormatError :) addStyleName("dateBoxFormatError"); event.stopPropagation(); DeferredCommand.addCommand(new Command() { public void execute() { // TODO(tsuna): Understand why this doesn't work as expected, even // though we cancel the onBlur event and we put the focus afterwards // using a deferred command. //setFocus(true); selectAll(); } }); } else { removeStyleName("dateBoxFormatError"); } }
@Test public void testNameBlurHandler() { VariablesEditorWidgetView.Presenter parent = mock(VariablesEditorWidgetView.Presenter.class); when(parent.isDuplicateName(anyString())).thenReturn(true); doReturn("anyName").when(name).getText(); view.setParentWidget(parent); view.init(); verify(name, times(1)).addBlurHandler(blurHandlerCaptor.capture()); BlurHandler handler = blurHandlerCaptor.getValue(); handler.onBlur(mock(BlurEvent.class)); verify(parent, times(1)).isDuplicateName("anyName"); verify(notification, times(1)).fire(new NotificationEvent(null, NotificationEvent.NotificationType.ERROR)); verify(name, times(1)).setValue(""); }
@Test public void testNameBlurHandler() { ActivityDataIOEditorWidget parent = mock(ActivityDataIOEditorWidget.class); when(parent.isDuplicateName(anyString())).thenReturn(true); doReturn("anyName").when(name).getText(); view.setAllowDuplicateNames(false, "ErrorMessage"); view.setParentWidget(parent); view.init(); verify(name, times(1)).addBlurHandler(blurHandlerCaptor.capture()); BlurHandler handler = blurHandlerCaptor.getValue(); handler.onBlur(mock(BlurEvent.class)); verify(parent, times(1)).isDuplicateName("anyName"); verify(notification, times(1)).fire(new NotificationEvent("ErrorMessage", NotificationEvent.NotificationType.ERROR)); verify(name, times(1)).setValue(""); }
@Test public void shouldHandleDropAsOnBlur() { // given DropEvent event = mock(DropEvent.class); // when testObj.bind(droppableObject, presenterHandler); testObj.onDrop(event); // then verify(presenterHandler).onBlur(Matchers.any(BlurEvent.class)); }
@Test public void shouldHandleOnBlurWithPresenter() { // given BlurEvent blurEvent = mock(BlurEvent.class); // when testObj.bind(droppableObject, presenterHandler); testObj.onBlur(blurEvent); // then verify(presenterHandler).onBlur(Matchers.eq(blurEvent)); verifyNoMoreInteractions(presenterHandler); }
@Override public void onBrowserEvent(Event event) { switch (DOM.eventGetType(event)) { case Event.ONBLUR: BlurEvent.fireNativeEvent(event, this); break; case Event.ONFOCUS: FocusEvent.fireNativeEvent(event, this); break; } super.onBrowserEvent(event); }
public SuggestionsContainer(CubaSuggestionFieldWidget suggestionFieldWidget) { this.suggestionFieldWidget = suggestionFieldWidget; container = DOM.createDiv(); final Element outer = FocusImpl.getFocusImplForPanel().createFocusable(); DOM.appendChild(outer, container); setElement(outer); sinkEvents(Event.ONCLICK | Event.ONMOUSEDOWN | Event.ONMOUSEOVER | Event.ONMOUSEOUT | Event.ONFOCUS | Event.ONKEYDOWN); addDomHandler(event -> selectItem(null), BlurEvent.getType()); setStylePrimaryName(STYLENAME); }
@Override public void onBlur(BlurEvent event) { super.onBlur(event); if (!readonly && !"".equals(inputPrompt) && ("".equals(selectedOptionKey) || null == selectedOptionKey)) { setPromptingOn(); } }
/** * Allows to initialize the text box by setting up its listeners and styles. */ private void initialize() { //Set the base values and styles super.setStyleName( CommonResourcesContainer.GWT_TEXT_BOX_STYLE ); this.addStyleName( CommonResourcesContainer.USER_DIALOG_SUGG_TEXT_BOX_STYLE ); this.setText( helperText ); //On gaining the focus addFocusHandler(new FocusHandler(){ public void onFocus(FocusEvent event) { //If the focus is obtained and the text box value is set to empty if //the user text was not set, i.e. he have the helper message there if( TextBoxWithSuggText.super.getText().trim().equals( helperText ) ){ TextBoxWithSuggText.super.setText( "" ); } //Remove the suggestion style making the text be in another color removeStyleName( CommonResourcesContainer.USER_DIALOG_SUGG_TEXT_BOX_STYLE ); } }); //On loosing the focus addBlurHandler(new BlurHandler(){ public void onBlur(BlurEvent e) { //If the text box looses the focus and the text is not set //then we set the helper text and the corresponding style if( TextBoxWithSuggText.super.getText().trim().isEmpty() ){ TextBoxWithSuggText.this.setText( null ); } } }); }
@Test public void nullConstraintMatch() throws Exception { when(widget.getConstraintMatchValue()).thenReturn(null); when(translationService.getTranslation(GuidedRuleEditorConstants.ConstraintMatchInputWidgetBlurHandler_EmptyValuesAreNotAllowedForModifyScore)) .thenReturn("translation"); handler.onBlur(mock(BlurEvent.class)); verify(widget).showError("translation"); verify(widget, never()).clearError(); }
@Test public void emptyConstraintMatch() throws Exception { when(widget.getConstraintMatchValue()).thenReturn(""); when(translationService.getTranslation(GuidedRuleEditorConstants.ConstraintMatchInputWidgetBlurHandler_EmptyValuesAreNotAllowedForModifyScore)) .thenReturn("translation"); handler.onBlur(mock(BlurEvent.class)); verify(widget).showError("translation"); verify(widget, never()).clearError(); }
@Test public void whiteSpaceConstraintMatch() throws Exception { when(widget.getConstraintMatchValue()).thenReturn(" "); when(translationService.getTranslation(GuidedRuleEditorConstants.ConstraintMatchInputWidgetBlurHandler_EmptyValuesAreNotAllowedForModifyScore)) .thenReturn("translation"); handler.onBlur(mock(BlurEvent.class)); verify(widget).showError("translation"); verify(widget, never()).clearError(); }
@Test public void numberConstraintMatch() throws Exception { when(widget.getConstraintMatchValue()).thenReturn("123"); handler.onBlur(mock(BlurEvent.class)); verify(widget, never()).showError(anyString()); verify(widget).clearError(); }
private void testInvalidValueConstraintMatch(final String scoreHolderClass) { ConstraintMatchInputWidgetBlurHandler handler = new ConstraintMatchInputWidgetBlurHandler(widget, translationService, scoreHolderClass); when(widget.getConstraintMatchValue()).thenReturn("123zzz"); when(translationService.getTranslation(anyString())) .thenReturn("translation"); handler.onBlur(mock(BlurEvent.class)); verify(widget, times(1)).showError("translation"); verify(widget, never()).clearError(); }
private void testValidExpressionConstraintMatch(final String scoreHolderClass) throws Exception { ConstraintMatchInputWidgetBlurHandler handler = new ConstraintMatchInputWidgetBlurHandler(widget, translationService, scoreHolderClass); when(widget.getConstraintMatchValue()).thenReturn("$person.getAge()"); handler.onBlur(mock(BlurEvent.class)); verify(widget, never()).showError(anyString()); verify(widget).clearError(); }
private void addHandlers() { BlurHandler blurHandler = new BlurHandler() { public void onBlur(BlurEvent ev) { checkForChange(); } }; _textArea.addKeyPressHandler(new KeyHandler()); _textArea.addBlurHandler(blurHandler); }
public static BlurHandler createOnExitListener(final EventListenerGVO ev, final List<InputVariableGVO> input) { return new BlurHandler() { public void onBlur(BlurEvent event) { CallbackHandler.createCallBack(event.getSource(), QAMLConstants.EVENT_ONEXIT, ev, input); } }; }
private static BlurHandler createBlurHandler(final ComponentGVO componentGVO, final EventListenerGVO eventGVO, final NotifyHandler notifyHandler, final String windowId, final String context, final AbstractActivity activity) { return new BlurHandler() { @Override public void onBlur(BlurEvent event) { UIObject widget = (UIObject)event.getSource(); List<InputVariableGVO> inputVariables = eventGVO.getInputvariablesList(); handleEvent(componentGVO, widget, eventGVO, event, QAMLConstants.EVENT_ONEXIT, inputVariables, notifyHandler, windowId, context, activity); } }; }
@Override public HandlerRegistration addBlurHandler(final BlurHandler handler) { if (!blurHandlerAdded) { blurHandlerAdded = true; this.codeMirror.on(this.editorOverlay, BLUR, new EventHandlers.EventHandlerNoParameters() { @Override public void onEvent() { fireBlurEvent(); } }); } return addHandler(handler, BlurEvent.getType()); }
private void init() { Element table = DOM.createTable(); body = DOM.createTBody(); DOM.appendChild(table, body); Element outer = FocusImpl.getFocusImplForPanel().createFocusable(); DOM.appendChild(outer, table); setElement(outer); Roles.getMenubarRole().set(getElement()); sinkEvents(Event.ONCLICK | Event.ONMOUSEOVER | Event.ONMOUSEOUT | Event.ONFOCUS | Event.ONKEYDOWN); setStyleName(STYLENAME_DEFAULT); addStyleDependentName("vertical"); // Hide focus outline in Mozilla/Webkit/Opera getElement().getStyle().setProperty("outline", "0px"); // Hide focus outline in IE 6/7 getElement().setAttribute("hideFocus", "true"); // Deselect items when blurring without a child menu. addDomHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { selectItem(null); } }, BlurEvent.getType()); }
@Override public void onBlur(BlurEvent event) { if (Utils.isNotBlank(promptText) && Utils.isBlank(super.getText())) { setPrompts(); } else { setText(renderer.render(getValue())); } }
public void popup(Widget container, Widget relativeTo) { this.setVisible(true); StyleUtils.addStyle(this, InputDatePicker.STYLE_POPUP); RootPanel.get().add(this); Element positioningElement = this.getElement(); Element relativeElement = relativeTo.getElement(); int targetHeight = relativeElement.getOffsetHeight(); int targetTop = relativeElement.getAbsoluteTop(); int positioningWidth = positioningElement.getOffsetWidth(); int targetRight = relativeElement.getAbsoluteRight(); Style elementStyle = positioningElement.getStyle(); elementStyle.setPosition(Position.ABSOLUTE); elementStyle.setLeft(targetRight - positioningWidth, Unit.PX); elementStyle.setTop(targetTop + targetHeight, Unit.PX); StyleUtils.addStyle(this, InputDatePicker.STYLE_FADE); StyleUtils.addStyle(this, InputDatePicker.STYLE_SHOW); this.setFocus(true); if (this.popupBlurHandler == null) { this.popupBlurHandler = this.addBlurHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { InputDatePicker.this.hide(); } }); } }
@Override public void onBlur(BlurEvent event) { if (wrappedtb.getValue().length() != 0 || precision == Precision.OOO_HM || precision == Precision.OOO_HMS) { String cval = complete(wrappedtb.getValue()); wrappedtb.setValue(cval); prevValue = cval; } fireEvent(new DateTimeTextBoxEvent()); }