== Widgets == Create a facade API to create widgets as simply as possible; delegating as much of the style & configuration to CSS or some CSS-like mechanism inside the factory. Usually the widgets are bound directly to models using the JFace Data Binding. e.g. {{{ Person person = new Person(); // 1. Idea UI ui = UIFactory.getInstance(); UIComposite parent = ..... UIElement f1 = ui.createTextField(parent, person, "givenname", UIEvents.Modify, new UIGridData(200,UIGridData.DEFAULT)); UIElement f2 = ui.createDateField(parent, person, "birthday", "dd.MM.yyyy", UIEvents.Focus, new UIGridData(200,UIGridData.DEFAULT)); UIElement f3 = ui.createTextField(parent, person, "primaryAddress.street", UIEvents.Modify, new UIGridData(200,UIGridData.DEFAULT)); UITable table = ui.createTable(parent, person, "addresses", ...); // 2. Generic idea (different models & allow lifecycle control of model) Form form = new EMFForm(); UIElement f4 = ui.createTextField( form, parent, new EMFAttribute(SamplePackage.Literals.PERSON_GIVENNAME), UIEvents.Modify ); UIElement f5 = ui.createTextField( form, parent, new EMFAttribute(SamplePackage.Literals.PERSON_PRIMARY_ADDRESS,SamplePackage.Literals.ADDRESS_STREET), UIEvents.Modify ); form.bind(new WritableValue(person)); }}} == Issues == * we could add the factory to the UIComposite so it can be looked up from there and used. (So we could customise the factory at different points in the tree - such as to kinda implement CSS like behaviour, changing how the default fields work at different points in the UI tree?). The nice thing is this would avoid the static variable. For example in JFace the root Shell would be a UIComposite we could create passing in the JFaceUIFactory. In GWT the EntryPoint could be a UIComposite created with the GWTUIFactory etc. i.e. all the UI code is always gonna be adding stuff to some parent - let it be the holder of the factory? * we might wanna provide IDs so that we can do nice CSS and so forth; though we could minimise coding by adding an ID to the composite. e.g. in the above code, we could set an ID on the parent to avoid having to pass IDs into each factory call. Also IDs can be optional and generally only used to add custom styling here and there - so maybe make an optional setter on UIElement * parent/child relationship; should we expose that in the UIElement / UIComposite? Most UI frameworks have the idea of parent/child - wonder how often its used. I only tend to do removeFromParent() :) * sometimes we might in GWT-land create a UI using HTML - then just bind widgets to the DOM; I wonder should we expose this kinda thing; or make it a specialised factory (for only in a browser type environment) * should we make data-binding the default UI model? i.e. should we allow content to be get/set on a widget, or force some kinda model to be used on its construction? Forcing a model might simplify the APIs. Should we also have something like the IContentProvider / ILabelProvider APIs? * what is the best way to define the binding-attributes. We need to support different model-types (EMF, UModel (see below), Java-Beans, ...)? = Models = We can start with the EMF model. Also we should create a simple Model (=UModel) that can take any key/value pairs. = Random Ideas = == CSS == It would be nice if we could adopt CSS-like techniques for developing UIs even when working with JFace or Swing. i.e. leave all of your UI code to wire together widgets, models and actions simple and portable to all UI platforms - then customize any magic stuff for a specific platform (e.g. tweaking the Swing settings) in a custom Swing factory. So we might want to be able to specify style classes on widgets (or their parents), or IDs - so we can then tinker with widget configurations in the factory. e.g. some custom UIFactory implementation could contain code something like... {{{ SwingUITable createTable(UIComposite parent, ...) { SwingUITable table = super.createTable(parent, ...); if (parent.getId().equals("orderForm")) { // lets customize the look & feel.... table.setAutoResizeMode(...); } return table; } }}}