@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); }
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 createRTAComponents() { rta = new CRichTextArea(); rta.setWidth("100%"); rta.addKeyDownHandler(this); formatter = new VRichTextToolbar(rta); // Add blur handlers for (Entry<BlurHandler, HandlerRegistration> handler : blurHandlers .entrySet()) { // Remove old registration handler.getValue().removeHandler(); // Add blur handlers addBlurHandler(handler.getKey()); } }
@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(""); }
@Override public HandlerRegistration addBlurHandler(BlurHandler handler) { return iText.addBlurHandler(handler); }
/** * 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 ); } } }); }
public HandlerRegistration addConstraintMatchBlurHandler(final BlurHandler blurHandler) { HandlerRegistration registration = constraintMatchTextBox.addBlurHandler(blurHandler); DomEvent.fireNativeEvent(Document.get().createBlurEvent(), constraintMatchTextBox); return registration; }
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()); }
/** * Removes a blur handler. * * @param blurHandler the handler to remove */ public void removeBlurHandler(BlurHandler blurHandler) { HandlerRegistration registration = blurHandlers.remove(blurHandler); if (registration != null) { registration.removeHandler(); } }
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 addEventListeners() { // we create these to map the event names to their events. see // DomEvent.Type for details. new Type<FocusHandler>("focusin", new FocusInEvent()); new Type<BlurHandler>("focusout", new FocusOutEvent()); addEventListeners_(); }
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(); } }); } }
protected HandlerRegistration setupBlurValidation() { return inputWidget.addDomHandler(new BlurHandler() { @Override public void onBlur(BlurEvent event) { validate(validateOnBlur); } }, BlurEvent.getType()); }
@Test public void checkDOMElementCreationChecksListBoxIsMultipleSelect() { factory.createDomElement(gridLayer, gridWidget, cellRenderContext); verify(listBox).addMouseDownHandler(any(MouseDownHandler.class)); verify(listBox).addKeyDownHandler(any(KeyDownHandler.class)); verify(listBox).addBlurHandler(any(BlurHandler.class)); verify(listBox).isMultipleSelect(); }
@Test @SuppressWarnings("unchecked") public void checkDOMElementCreationBlurHandler() { final InOrder order = inOrder(factory); final GridBodyCellRenderContext context = mock(GridBodyCellRenderContext.class); final Callback<ListBoxDOMElement<String, ListBox>> onCreation = mock(Callback.class); final Callback<ListBoxDOMElement<String, ListBox>> onDisplay = mock(Callback.class); when(context.getTransform()).thenReturn(mock(Transform.class)); factory.attachDomElement(context, onCreation, onDisplay); final ArgumentCaptor<BlurHandler> blurHandlerCaptor = ArgumentCaptor.forClass(BlurHandler.class); verify(listBox).addBlurHandler(blurHandlerCaptor.capture()); final BlurEvent e = mock(BlurEvent.class); final BlurHandler blurHandler = blurHandlerCaptor.getValue(); blurHandler.onBlur(e); order.verify(factory).flush(); order.verify(factory).destroyResources(); verify(gridLayer).batch(); verify(gridLienzoPanel).setFocus(eq(true)); }
@Before public void init() { GwtMockito.initMocks(this); textBox = GWT.create(VariableNameTextBox.class); doCallRealMethod().when(textBox).setRegExp(anyString(), anyString(), anyString()); doCallRealMethod().when(textBox).setInvalidValues(anySet(), anyBoolean(), anyString()); doCallRealMethod().when(textBox).isValidValue(anyString(), anyBoolean()); doCallRealMethod().when(textBox).setText(anyString()); doCallRealMethod().when(textBox).testForInvalidValue(anyString()); doCallRealMethod().when(textBox).makeValidValue(anyString()); doCallRealMethod().when(textBox).getInvalidCharsInName(anyString()); doCallRealMethod().when(textBox).isValidChar(anyChar()); doCallRealMethod().when(textBox).setup(); doCallRealMethod().when(textBox).addBlurHandler(any(BlurHandler.class)); doCallRealMethod().when(textBox).addKeyPressHandler(any(KeyPressHandler.class)); textBox.setRegExp(ALPHA_NUM_REGEXP, ERROR_REMOVED, ERROR_TYPED); INVALID_VALUES.clear(); INVALID_VALUES.add("abc"); INVALID_VALUES.add("CdE"); INVALID_VALUES.add("a#$%1"); textBox.setInvalidValues(INVALID_VALUES, caseSensitive, ERROR_MESSAGE); }
@Override public HandlerRegistration addBlurHandler(BlurHandler handler) { return addHandler(handler, BlurEvent.getType()); }
@Override public HandlerRegistration addBlurHandler(BlurHandler handler) { return addDomHandler(handler, BlurEvent.getType()); }
@Override public HandlerRegistration addBlurHandler(BlurHandler handler) { return iFilter.addBlurHandler(handler); }
@Override public HandlerRegistration addBlurHandler(BlurHandler handler) { return iFilter.getWidget().addBlurHandler(handler); }
@Override public HandlerRegistration addBlurHandler(final BlurHandler handler) { return this.addDomHandler(handler, BlurEvent.getType()); }