Java – Does using JFace’s Viewers preclude good MVC separation

javajfacemodel-view-controlleruser-interface

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?

Best Solution

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)