日期时间的 SWT 数据绑定

发布于 2024-11-18 17:27:08 字数 969 浏览 1 评论 0原文

我想使用两个 DateTime 控件显示一个 java.util.Date - 一个显示日期,一个显示时间。

我尝试在此处使用数据绑定来设置在控件中输入的值。我尝试将控件绑定到日期,如下所示:

IObservableValue getPostponeDateDayObserveValue = SWTObservables.observeSelection(getPostponeDate());
IObservableValue getPostponeTargetDateDateObserveValue = PojoObservables.observeValue(this, "postponeTargetDate");
bindingContext.bindValue(getPostponeDateDayObserveValue, getPostponeTargetDateDateObserveValue, null, null);
    //
IObservableValue getPostponeTimeSecondsObserveValue = SWTObservables.observeSelection(getPostponeTime());
IObservableValue postponeTargetDateSecondsObserveValue = PojoObservables.observeValue(this, "postponeTargetDate");
bindingContext.bindValue(getPostponeTimeSecondsObserveValue, postponeTargetDateSecondsObserveValue, null, null);

这里发生的情况是,日期与正确的日期或正确的时间相关,具体取决于稍后更改的控件。是否可以将两个日期时间控件(一个用于日期,一个用于时间)绑定到同一日期。

感谢您的支持。

I want to display a java.util.Date using two DateTime controls - one displaying the date and one the time.

I try to use databinding here to set the values entered in the controls. I try to bind the controls to the date as follows:

IObservableValue getPostponeDateDayObserveValue = SWTObservables.observeSelection(getPostponeDate());
IObservableValue getPostponeTargetDateDateObserveValue = PojoObservables.observeValue(this, "postponeTargetDate");
bindingContext.bindValue(getPostponeDateDayObserveValue, getPostponeTargetDateDateObserveValue, null, null);
    //
IObservableValue getPostponeTimeSecondsObserveValue = SWTObservables.observeSelection(getPostponeTime());
IObservableValue postponeTargetDateSecondsObserveValue = PojoObservables.observeValue(this, "postponeTargetDate");
bindingContext.bindValue(getPostponeTimeSecondsObserveValue, postponeTargetDateSecondsObserveValue, null, null);

What happens here is that the date corries the correct date or the correct time depending on which control was changed later. Is there a possibility to bind two datetime controls (one for date one for time) to the same date.

Thanks for your support.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

谢绝鈎搭 2024-11-25 17:27:08

只是忽略了这里有帮助的课程:
相对于="nofollow">日期和时间ObservableValue

just overlooked the class that helps here:
DateAndTimeObservableValue

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文