Unterschiede
Hier werden die Unterschiede zwischen der gewählten und der aktuellen Version gezeigt.
eclipse-rcp:binding 2016/02/11 09:54 | eclipse-rcp:binding 2020/09/25 09:41 aktuell | ||
---|---|---|---|
Zeile 44: | Zeile 44: | ||
m_bindingContext.bindValue(SWTObservables.observeText(m_firstnameTxt, | m_bindingContext.bindValue(SWTObservables.observeText(m_firstnameTxt, | ||
SWT.Modify), BeansObservables.observeValue(model, MyModel.PROP_FIRSTNAME), null, null); | SWT.Modify), BeansObservables.observeValue(model, MyModel.PROP_FIRSTNAME), null, null); | ||
- | |||
- | initUpdateStrategy(); | ||
+ | // Das Textfeld "m_birthdateTxt" für den Nachnamen an das Model-Attribut "m_birthday" binden: | ||
m_bindingContext.bindValue(SWTObservables.observeText(m_birthdateTxt, | m_bindingContext.bindValue(SWTObservables.observeText(m_birthdateTxt, | ||
SWT.Modify), BeansObservables.observeValue(model, MyModel.PROP_BIRTHDAY), | SWT.Modify), BeansObservables.observeValue(model, MyModel.PROP_BIRTHDAY), | ||
m_targetToModelStrategy, m_modelToTargetStrategy); | m_targetToModelStrategy, m_modelToTargetStrategy); | ||
+ | |||
+ | // UpdateStrategy initialisieren (Konverter und Validatoren festlegen): | ||
+ | initUpdateStrategy(); | ||
} | } | ||
</code> | </code> | ||
Zeile 230: | Zeile 232: | ||
} | } | ||
} | } | ||
+ | </code> | ||
+ | \\ | ||
+ | \\ | ||
+ | \\ | ||
+ | ===== Button-Enablement an Validationstatus binden ===== | ||
+ | <code java> | ||
+ | public void bindButtonEnablementToValidationStatus(final Button button) { | ||
+ | |||
+ | final IObservableValue buttonEnable = SWTObservables.observeEnabled(button); | ||
+ | final IObservableValue validationStatus = | ||
+ | new AggregateValidationStatus(myBindingContext.getValidationRealm(), myBindingContext.getBindings(), AggregateValidationStatus.MAX_SEVERITY); | ||
+ | myBindingContext.bindValue(buttonEnable, | ||
+ | validationStatus, | ||
+ | new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER), | ||
+ | new UpdateValueStrategy().setConverter(new Converter(IStatus.class, Boolean.TYPE) { | ||
+ | @Override | ||
+ | public Object convert(final Object fromObject) { | ||
+ | return new Boolean(((IStatus) fromObject).isOK()); | ||
+ | } | ||
+ | })); | ||
+ | } | ||
</code> | </code> | ||
\\ | \\ |