本文整理汇总了Java中org.jboss.errai.databinding.client.api.StateSync类的典型用法代码示例。如果您正苦于以下问题:Java StateSync类的具体用法?Java StateSync怎么用?Java StateSync使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StateSync类属于org.jboss.errai.databinding.client.api包,在下文中一共展示了StateSync类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: sortContactsByName
import org.jboss.errai.databinding.client.api.StateSync; //导入依赖的package包/类
private void sortContactsByName() {
binder.pause();
final Function<Contact, String> nickGetter = c -> (c.getNickname() == null ? "" : c.getNickname());
Collections.sort(binder.getModel(), (a,b) -> {
return nickGetter.apply(a).compareTo(nickGetter.apply(b));
});
binder.resume(StateSync.FROM_MODEL);
}
示例2: registerInput
import org.jboss.errai.databinding.client.api.StateSync; //导入依赖的package包/类
@Override
public void registerInput(FormField formField, Converter valueConverter) {
Assert.notNull("FormHandler isn't correctly initialized, please run any of the setUp methods before use", binder);
Assert.notNull("FormField cannot be null!", formField);
String fieldName = formField.getFieldName();
IsWidget widget = formField.getWidget();
formFields.add(formField);
if (handlerHelper.supportsInputBinding() && formField.isBindable()) {
BindableProxy proxy = (BindableProxy) binder.getModel();
Object modelValue = readPropertyValue(proxy, formField.getFieldBinding());
StateSync stateSync = Optional.ofNullable(modelValue).isPresent() ? StateSync.FROM_MODEL : StateSync.FROM_UI;
binder.bind(widget, formField.getFieldBinding(), valueConverter, stateSync);
}
fieldChangeManager.registerField(formField.getFieldName(), formField.isValidateOnChange());
formField.getChangeListeners().forEach(listener -> fieldChangeManager.addFieldChangeHandler(listener.getFieldToListen(), listener.getChangeHandler()));
/**
* if field isn't bindable we cannot listen to field value changes.
*/
if (!formField.isBindable()) {
return;
}
if (widget instanceof IsNestedModel) {
IsNestedModel nestedModelWidget = (IsNestedModel) widget;
nestedModelWidget.addFieldChangeHandler((childFieldName, newValue) -> fieldChangeManager.notifyFieldChange(fieldName + "." + childFieldName, newValue));
} else {
PropertyChangeUnsubscribeHandle unsubscribeHandle = binder.addPropertyChangeHandler(formField.getFieldBinding(), event -> fieldChangeManager.processFieldChange(fieldName, event.getNewValue(), binder.getModel()));
unsubscribeHandlers.add(unsubscribeHandle);
}
}
示例3: setValuePaused
import org.jboss.errai.databinding.client.api.StateSync; //导入依赖的package包/类
/**
* Sets the given model as the model for this component but pauses data-binding. Any changes made to the UI or model
* will not be synchronized until {@link #syncStateFromUI()} is called.
*/
public void setValuePaused(final Contact model) {
binder.setModel(model, StateSync.FROM_MODEL);
binder.pause();
}
示例4: syncStateFromUI
import org.jboss.errai.databinding.client.api.StateSync; //导入依赖的package包/类
/**
* If binding is paused, overwrite the state of the model with the state from the UI.
*/
public void syncStateFromUI() {
// Does nothing if already resumed.
binder.resume(StateSync.FROM_UI);
}
示例5: setValuePaused
import org.jboss.errai.databinding.client.api.StateSync; //导入依赖的package包/类
/**
* Sets the given model as the model for this component but pauses data binding. Any changes made to the UI or model
* will not be synchronized until {@link #syncStateFromUI()} is called.
*/
public void setValuePaused(final Contact model) {
binder.setModel(model, StateSync.FROM_MODEL);
binder.pause();
}
示例6: sortContactsByName
import org.jboss.errai.databinding.client.api.StateSync; //导入依赖的package包/类
private void sortContactsByName() {
binder.pause();
binder.getModel().sort(Comparator.comparing(Contact::getNickname));
binder.resume(StateSync.FROM_MODEL);
}
示例7: forceModelSynchronization
import org.jboss.errai.databinding.client.api.StateSync; //导入依赖的package包/类
@Override
public void forceModelSynchronization() {
formFields.stream().filter(formField -> formField.getWidget() instanceof IsNestedModel).map(formField1 -> (IsNestedModel) formField1.getWidget()).forEach(IsNestedModel::forceModelSynchronization);
binder.setModel(getModel(), StateSync.FROM_UI);
}