tags:

views:

66

answers:

2

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?

A: 

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.

bmargulies
I said that *I* want to use Swing and SWT, not the end-user. And it's out of the scope of the question, but I have a good reason for the requirement.I'm not trying to get JFace to call Swing or AWT instead, I'm just wondering is it possible to build an MVC app where the GUI is seperated enough from the model that I can make it easy to switch (and the MVC approach is how I was told here to do that), but still gain from JFace's more powerful features?
ZoFreX
You wrote: "The end-user will specify somehow which should be used (it won't use both at the same time!). " Apparently, I don't know what you mean by 'end user'.
bmargulies
I meant that the provision of the option between SWT and Swing is a decision I made. The end user will get to choose which is used at runtime.
ZoFreX
That would imply a giant pile of parallel code for Swing and JFace, no?
bmargulies
Yup. But I want choosable user interfaces and MVC with a dash of programming to an Interface gives me that.
ZoFreX
A: 

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)

Roland Tepp
This sounds perfect! Thank you!
ZoFreX