Unterschiede
Hier werden die Unterschiede zwischen der gewählten und der aktuellen Version gezeigt.
| eclipse-rcp:binding 2009/11/03 16:41 | eclipse-rcp:binding 2020/09/25 09:41 aktuell | ||
|---|---|---|---|
| Zeile 37: | Zeile 37: | ||
| m_bindingContext = new DataBindingContext(); | m_bindingContext = new DataBindingContext(); | ||
| - | Binding binding; | + | // Das Textfeld "m_lastnameTxt" für den Nachnamen an das Model-Attribut "m_lastname" binden: |
| - | + | m_bindingContext.bindValue(SWTObservables.observeText(m_lastnameTxt, | |
| - | binding = m_bindingContext.bindValue(SWTObservables.observeText(m_lastnameTxt, | + | SWT.Modify), BeansObservables.observeValue(model, MyModel.PROP_LASTNAME), null, null); |
| - | SWT.Modify), BeansObservables.observeValue(model, MyModel.PROP_LASTNAME), null, null); | + | |
| - | binding = m_bindingContext.bindValue(SWTObservables.observeText(m_firstnameTxt, | + | // Das Textfeld "m_firstnameTxt" für den Nachnamen an das Model-Attribut "m_firstname" binden: |
| - | SWT.Modify), BeansObservables.observeValue(model, MyModel.PROP_FIRSTNAME), null, null); | + | m_bindingContext.bindValue(SWTObservables.observeText(m_firstnameTxt, |
| + | SWT.Modify), BeansObservables.observeValue(model, MyModel.PROP_FIRSTNAME), null, null); | ||
| + | |||
| + | // Das Textfeld "m_birthdateTxt" für den Nachnamen an das Model-Attribut "m_birthday" binden: | ||
| + | m_bindingContext.bindValue(SWTObservables.observeText(m_birthdateTxt, | ||
| + | SWT.Modify), BeansObservables.observeValue(model, MyModel.PROP_BIRTHDAY), | ||
| + | m_targetToModelStrategy, m_modelToTargetStrategy); | ||
| + | // UpdateStrategy initialisieren (Konverter und Validatoren festlegen): | ||
| initUpdateStrategy(); | initUpdateStrategy(); | ||
| - | binding = m_bindingContext.bindValue(SWTObservables.observeText(m_birthdateTxt, | ||
| - | SWT.Modify), BeansObservables.observeValue(model, MyModel.PROP_BIRTHDAY), | ||
| - | m_targetToModelStrategy, m_modelToTargetStrategy); | ||
| } | } | ||
| </code> | </code> | ||
| Zeile 229: | 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> | ||
| \\ | \\ | ||