开发者

Does using JFace's Viewers preclude good MVC separation?

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 c开发者_开发问答ase? Can one use JFace without tying GUI details into the model or vice-versa?


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)


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜