本文整理匯總了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);
}