0
我在使用DataBinding进行验证时必须实现更改背景行为,我该如何执行此操作? 我有两个DateChooserCombo(星云),我想防止重叠,并改变颜色为红色,例如当dateBegin> dateEnd,这是我迄今为止所做的。 谢谢SWT/JFace数据绑定更改背景
IObservableValue textObservable = new DateChooserComboObservableValue(
dateChooser, SWT.Modify);
UpdateValueStrategy strategy = new UpdateValueStrategy();
strategy.setBeforeSetValidator(new IValidator() {
@Override
public IStatus validate(Object value) {
//for testing purpose make it fail
return ValidationStatus.error("this is not permitted");
}
});
Realm realm = SWTObservables.getRealm(dateChooser.getDisplay());
DataBindingContext context = new DataBindingContext(realm);
org.eclipse.core.databinding.Binding binding = context.bindValue(
textObservable, PojoProperties.value(Model.class, "dateEnd")
.observe(realm, model.dateEnd), strategy,
strategy);
//didn't show the control decoration as expected
ControlDecorationSupport.create(binding, SWT.TOP | SWT.LEFT);
如果您创建了一个新的'颜色'对象,您必须**安排在完成它时处理它。 – 2014-09-24 07:22:55
是的你是对的,这只是一个解决方案的例子,如何改变颜色,但是每个swt资源都需要处理或需要使用像ColorRegistry o这样的资源注册表。 – 2014-09-24 07:33:39