/** Toggles {@code property} each time the event is triggered. */ public void toggle(final Property<Boolean> property) { b.add(hookUpEventRunnable(new DomEventRunnable() { public void run(DomEvent<?> event) { property.set(TRUE.equals(property.get()) ? false : true); if (event != null) { event.preventDefault(); } } })); }
public void to(final ListProperty<P> values) { b.add(hookUpRunnable(new Runnable() { public void run() { values.add(value); } })); } }
public void from(final ListProperty<P> values) { b.add(hookUpRunnable(new Runnable() { public void run() { values.remove(value); } })); } }
/** Executes {@code command} when triggered. */ public void execute(final UiCommand command) { b.add(hookUpRunnable(new Runnable() { public void run() { command.execute(); } })); }
public void to(final List<P> values) { b.add(hookUpRunnable(new Runnable() { public void run() { values.add(value); } })); }
public void by(final Comparator<P> comparator) { b.add(hookUpRunnable(new Runnable() { public void run() { list.sort(comparator); } })); } }
/** Focuses on {@code focusable} when triggered. */ public void focus(final Focusable focusable) { b.add(hookUpEventRunnable(new DomEventRunnable() { public void run(DomEvent<?> event) { focusable.setFocus(true); if (event != null) { event.preventDefault(); } } })); }
/** Fires a {@link PlaceRequestEvent} for {@code request} when triggered. */ public void goTo(final EventBus bus, final PlaceRequest request) { b.add(hookUpRunnable(new Runnable() { public void run() { bus.fireEvent(request.asEvent()); } })); }
public void in(final ListProperty<P> values) { b.add(hookUpRunnable(new Runnable() { public void run() { if (up) { values.moveUp(value); } else { values.moveDown(value); } } })); } }
/** Forces a {@link ValueChangeEvent} of each {@code source} on key up, after it's been touched. */ public <P, S extends HasKeyUpHandlers & HasBlurHandlers & HasValue<P>> void fireChangeOnBlurThenKeyUp(S... sources) { for (final S source : sources) { BlurThenKeyUp<P> h = new BlurThenKeyUp<P>(source); add(source.addKeyUpHandler(h)); add(source.addBlurHandler(h)); } }
/** Sets/removes our {@code style} when our property is {@code true}. */ public void on(final HasCss... css) { b.add(property.addPropertyChangedHandler(e -> update(css))); update(css); // set initial value }
/** Sets/removes our {@code attribute} when our property is {@code true}. */ public void onAttribute(final IsElement element, String attribute) { b.add(property.addPropertyChangedHandler(e -> update(element, attribute))); update(element, attribute); // set initial value }
/** Forces a {@link ValueChangeEvent} (and hence touching) of each {@code source} on blur. */ public <P, S extends HasBlurHandlers & HasValue<P>> void fireChangeOnBlur(S... sources) { for (final S source : sources) { add(source.addBlurHandler(e -> ValueChangeEvent.fire(source, source.getValue()))); } }
/** Sets/removes our {@code style} when our property is {@code true}. */ public void on(final HasCss... css) { b.add(property.addPropertyChangedHandler(e -> update(css))); update(css); // set initial value }
public void has(final V value) { b.add(p.addPropertyChangedHandler(e -> update(value))); b.add(values.addPropertyChangedHandler(e -> { p.set(e.getNewValue().contains(value)); })); if (b.canSetInitialValue(p)) { p.setInitialValue(values.get().contains(value)); } else { update(value); // set initial } }
/** Adds/removes our {@code value} when our {@code property} is {@code value}. */ public void to(final List<V> values) { b.add(property.addPropertyChangedHandler(e -> update(values))); if (b.canSetInitialValue(property) && values.contains(newValue)) { condition.setInitialValue(property); } else { update(values); // set initial value } }
/** Adds/removes our {@code value} when our property is {@code true}. */ public void from(final ListProperty<V> values) { b.add(property.addPropertyChangedHandler(e -> update(values))); if (b.canSetInitialValue(property) && !values.get().contains(newValue)) { condition.setInitialValue(property); } else { update(values); // set initial value } }
/** Binds each value in {@code p} to a view created by {@code factory}. */ public void to(final ListLike<IsWidget> panel, final ListViewFactory<P> factory) { if (p.get() != null) { int i = 0; for (P value : p.get()) { panel.add(i++, factory.create(value)); } } b.add(p.addListChangedHandler(e -> e.getDiff().apply(panel, a -> factory.create(a)))); }