use of org.eclipse.jface.examples.databinding.model.Cart in project eclipse.platform.ui by eclipse-platform.
the class PropertyScenarios method testScenario03.
@Test
public void testScenario03() {
// Binding of a read-only property of an Adventure object to the
// contents of Text controls, no conversion, no validation. Text control
// is not editable as a side effect of binding to a read-only property..
Cart cart = SampleData.CART;
cart.setAdventureDays(42);
// bind to the lodgingDays feature, which is read-only and always one
// less than the number of adventure days.
Text text = new Text(getComposite(), SWT.BORDER);
System.out.println("Expecting message about not being able to attach a listener");
getDbc().bindValue(SWTObservables.observeText(text, SWT.Modify), BeansObservables.observeValue(cart, "lodgingDays"));
assertEquals(Integer.valueOf(cart.getLodgingDays()).toString(), text.getText());
}