public void setValueChanged(JavaScriptObject aValue) { if (valueChanged != aValue) { if (valueChangedReg != null) { valueChangedReg.removeHandler(); valueChangedReg = null; } valueChanged = aValue; if (component instanceof HasValueChangeHandlers<?>) { valueChangedReg = ((HasValueChangeHandlers<Object>) component).addValueChangeHandler(new ValueChangeHandler<Object>() { @Override public void onValueChange(ValueChangeEvent<Object> event) { JavaScriptObject published = ((HasPublished) event.getSource()).getPublished(); executeEvent(valueChanged, EventsPublisher.publishSourcedEvent(published)); } }); } } }
private static void addChangeListenerForWindowModified(final ComponentGVO vo, UIObject ui, final String uuid) { if (ui != null) { if (ui instanceof HasValueChangeHandlers) { HasValueChangeHandlers hasValueChangeHandlers = (HasValueChangeHandlers) ui; hasValueChangeHandlers.addValueChangeHandler(new ValueChangeHandler() { public void onValueChange(ValueChangeEvent event) { WindowPanel window = ClientApplicationContext.getInstance().getWindow(vo.getWindow(), uuid); if (window != null && window instanceof QWindowPanel) { ((QWindowPanel) window).setModified(true); } } }); } } }
private static void addChangeListenerForWindowModified(final ComponentGVO vo, UIObject ui, final String uuid) { if (ui != null) { if (ui instanceof HasValueChangeHandlers) { HasValueChangeHandlers hasValueChangeHandlers = (HasValueChangeHandlers) ui; hasValueChangeHandlers.addValueChangeHandler(new ValueChangeHandler() { public void onValueChange(ValueChangeEvent event) { // WindowPanel window = ClientApplicationContext.getInstance().getWindow(vo.getWindow(), uuid); // if (window != null && window instanceof QWindowPanel) { // ((QWindowPanel) window).setModified(true); // } } }); } } }
/** * initialize one editor. * * @param editor editor to initialize */ @SuppressWarnings({"rawtypes", "unchecked"}) public void initializeEditors(final Object editor) { if (editor instanceof HasValueChangeHandlers && this.valueChangeHandler != null) { ((HasValueChangeHandlers) editor).addValueChangeHandler(this.valueChangeHandler); // if widget has a value change handler, validate on change if (this.validateOnVueChangeHandler != null) { ((HasValueChangeHandlers) editor).addValueChangeHandler(this.validateOnVueChangeHandler); } } // if widget has a key up handler, validate on key up if (editor instanceof HasKeyUpHandlers && this.validateOnKeyUpHandler != null) { ((HasKeyUpHandlers) editor).addKeyUpHandler(this.validateOnKeyUpHandler); } // try to submit form on return if (editor instanceof HasKeyPressHandlers && this.commitOnReturnHandler != null) { ((HasKeyPressHandlers) editor).addKeyPressHandler(this.commitOnReturnHandler); } }
public static <H extends HasValueChangeHandlers & HasValue & HasEnabled & HasAttachHandlers> void checkValueChangeEvent( H widget, Object value, Object secondValue) { assertNotSame(value, secondValue); // Widget must be enabled before firing the event widget.setEnabled(true); assertTrue(widget.isEnabled()); // Ensure the widget is attached to the root panel assertTrue(widget.isAttached()); // Register value change handler that listens when the widget // set the value final boolean[] isValueChanged = {false}; widget.addValueChangeHandler(event -> isValueChanged[0] = true); // By default setValue(boolean) will not fire the value change event. widget.setValue(value); assertEquals(value, widget.getValue()); // Expected result : false assertFalse(isValueChanged[0]); // Calling setValue(value, fireEvents) with fireEvents set to false widget.setValue(secondValue, false); // Expected result : secondValue assertEquals(secondValue, widget.getValue()); // Expected result : false assertFalse(isValueChanged[0]); // Calling setValue(value, fireEvents) with fireEvents set to true widget.setValue(value, true); // Expected result : true assertTrue(isValueChanged[0]); // Expected result : value assertEquals(value, widget.getValue()); }
/** * Sets the ValueChange() event handler in many widgets * @param handler the handler * @param widgets the widgets */ public static <T> void addValueChangeHandler(final ValueChangeHandler<T> handler,final HasValueChangeHandlers<T>... widgets) { if (handler != null && widgets != null && widgets.length > 0) { for (HasValueChangeHandlers<T> w : widgets) { if (w != null) w.addValueChangeHandler(handler); } } }
public void registerItemValueChangeHandler(final Widget item) { if (item instanceof HasValueChangeHandlers) { HasValueChangeHandlers<Boolean> hasValueChangeHandlers = (HasValueChangeHandlers<Boolean>)item; hasValueChangeHandlers.addValueChangeHandler(new ValueChangeHandler<Boolean>() { public void onValueChange(ValueChangeEvent<Boolean> event) { doItemValueChange(event); } }); } }
@SuppressWarnings("unchecked") @Override public final HandlerRegistration addValueChangeHandler(final ValueChangeHandler<T> phandler) { if (this.contents.getWidget() instanceof HasValueChangeHandlers<?>) { return ((HasValueChangeHandlers<T>) this.contents.getWidget()) .addValueChangeHandler(phandler); } else { return null; } }
private ClickHandler cellClickHandler(final int row, final int column) { final HasValueChangeHandlers<Pair<Component, Attribute>> self = this; return new ClickHandler() { @Override public void onClick(ClickEvent event) { cellClicked(row, column); } }; }
public static <T> Observable<ValueChangeEvent<T>> valueChange(HasValueChangeHandlers<T> source) { return Observable.create(s -> register(s, source.addValueChangeHandler(s::onNext))); }
public HandlerRegistration addValueChangeHandler(ValueChangeHandler handler) { if (uiObject instanceof HasValueChangeHandlers) { return ((HasValueChangeHandlers)uiObject).addValueChangeHandler(handler); } return null; }
public HandlerRegistration addValueChangeHandler(ValueChangeHandler handler) { if (textbox instanceof HasValueChangeHandlers) { return ((HasValueChangeHandlers)textbox).addValueChangeHandler(handler); } return null; }
/** * add a change handler to clear error state on value change. * * @param pwidget widget to set the handler to */ protected void addValueChangeHandler(final HasValueChangeHandlers<T> pwidget) { pwidget.addValueChangeHandler(event -> AbstractDecorator.this.clearErrors()); }
/** * Fires a {@link ValueChangeEvent} to a given handler * * @param value The value that is changing * @param handler The handler that will receive the event */ private <T> void fireValueChangeEvent(T value, ValueChangeHandler<T> handler) { HasValueChangeHandlers<T> mock = new MockHasValueChangeHandlers<T>(); mock.addValueChangeHandler(handler); ValueChangeEvent.fire(mock, value); }