使用 JFace 的查看器是否会妨碍良好的 MVC 分离?

发布于 2024-08-16 11:40:54 字数 221 浏览 3 评论 0原文

我正在编写一个 GUI 应用程序,我想使用 Swing 和 SWT。最终用户将以某种方式指定应该使用哪个(它不会同时使用两者!)。 SWT 是我通常比较喜欢的,并且我一直在关注 JFace,但似乎如果我使用它最强大的功能,我会增加 GUI 和模型之间的耦合,并使抽象 GUI 变得更加困难,因此 Swing 可以也用过。

是这样吗?是否可以在不将 GUI 详细信息绑定到模型中的情况下使用 JFace,反之亦然?

I'm writing a GUI app that I want to use Swing and SWT. The end-user will specify somehow which should be used (it won't use both at the same time!). SWT is what I prefer generally and I have been looking at JFace, but it seems like if I use its most powerful features I will increase the coupling between the GUI and the model, and make it far harder to abstract the GUI so Swing can be used as well.

Is this the case? Can one use JFace without tying GUI details into the model or vice-versa?

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

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

发布评论

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

评论(2

我不是你的备胎 2024-08-23 11:40:54

据我所知,使用 JFace 查看器可以很好地分离视图和模型。

这里唯一的紧密耦合是实际查看器实现的选择(例如,使用 TableViewer 与 TreeViewer 将模型分别绑定到表或树小部件)。

至于问题的第一部分,表明您出于某种原因想要将应用程序与 GUI 框架的选择分离,我建议您看一下 UFace 项目

UFace 项目 旨在准确地提供您想要的东西——一个可以在许多 GUI 后端上运行的单一 UI 实现(它调用Providers):

在撰写本文时,UFace 项目页面列出了对以下提供程序的支持:

  • JFace/SWT
  • Swing
  • GWT

(我还听说有传言称正在开展一些支持 Qt Jambi 提供程序的工作)出色地)

For what I know, using JFace viewers ioffers quite good separation of view and model.

The only tight coupling here is the choice of the actual viewer implementation (e.g. using TableViewer versus TreeViewer to bind your model to either a Table or a Tree widget respectfully).

As to your first part of the question tat indicates you want for some reason to decouple your application from a choice of GUI framework, I would suggest you take a look at UFace project

UFace project aims to provide exactly what you seem to be aiming for -- a single UI implementation that can run against many GUI backends (it calls Providers):

UFace project page at the moment of this writing lists support for following providers:

  • JFace/SWT
  • Swing
  • GWT

(I have also heard rumors of some work being done on supporting Qt Jambi provider as well)

醉殇 2024-08-23 11:40:54

您无法动态切换。 JFace 调用 SWT。不能要求它改为调用 AWT。

至于 JFace 是否将模型耦合到 GUI,嗯,没有。它有一组模型接口,但您可以将任何您喜欢的模型粘合到它们上。如果您的客户有一天想要放弃 JFace,那么您就需要彻底地完成此操作。

You can't switch dynamically. JFace calls SWT. It cannot be asked to call AWT instead.

As for whether JFace couples the model to the GUI, well, no. It has a set of model interfaces, but you can glue whatever model you like to them. It is up to you to do this cleanly if your customer wants the option of ripping out JFace some day.

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