Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipse-dev] Re: [DataBinding] DOM and Rhino JFace Databinding implementation.


Nobody is interested with DOM and Rhino binding?

I have start to refactor my JFace DOM binding implementation and you can found into the TK-UI SVN.
You have 2 Eclipse project :

org.eclipse.core.databinding.dom which is DOMP binding source.
org.eclipse.core.examples.databinding.dom which is DOM binding samples.

I would like know too if it's possible to add into JFace Databinding Wiki (section Miscelanous), the DOM binding section?
If you are agrre with that, is it possible to give the SVN TK-UI link into JFace Databinding Wiki, because I have not finished the project and I can't send mail with source as bug.

Regards Angelo

2008/7/30 Angelo zerr <angelo.zerr@xxxxxxxxx>

I'm TK-UI developer. TK-UI is Toolkit to describe your UI with any XML markup (XUL, XHTML...)
and render it with Swing or SWT. I'm using JFace databinding to bind DOM Document (Element, Attr, Text...)
with UI widget. So when you update UI it update DOM, whoen you update DOM, the UI is updated.

For instance you can write this XHTML content :

<html xmlns="">
     <input type="text" value="bla bla bla" />

And TK-UI load DOM Document and display SWT Text with "bla bla bla".
When you type some data into input (SWT Text), it update attribute value of the DOM.
So DOM Document are totally bounded with UI.

To manage DOM binding I have created DOMObservables (like BeansObservales, PojoObservables...)
and you use this factory like another JFace databinding implementation. This project is stored into
UFace project.

But I would like know if JFace team is interested with my DOM JFace Databinding implementation?
Indead I would like to improve this project to manage a lot of thing like masterdetail.

Here simple sample with masterdetail which manage three SWT List which display countries, cities and streets.
Each SWT List are bounded with this DOM Document :

    <country name="Country 1" >
            <city name="City 1.1" >
                <street name="Street 1.1.1" />
            <city name="City 1.2" >
                <street name="Street 1.2.1" />
                <street name="Street 1.2.2" />
                <street name="Street 1.2.3" />
            <city name="City 1.3" >
                <street name="Street 1.3.1" />
                <street name="Street 1.3.2" />
    <country name="Country 2" >
            <city name="City 2.1" >
                <street name="Street 2.1.1" />
                <street name="Street 2.1.2" />
            <city name="City 2.2" >
                <street name="Street 2.2.1" />
                <street name="Street 2.2.2" />
                <street name="Street 2.2.3" />

The first SWT list display countries (Country 1 and Country 2 ).
When you select a country the second SWT List display cities (ex : you select
Country 1, SWT List cities display City 1.1, City 1.2, City 1.3).

Here the Java code for this sample :

Display display = new Display();
Shell shell = new Shell(display, SWT.SHELL_TRIM);
FillLayout layout = new FillLayout();

Composite composite = new Composite(shell, SWT.NONE);
composite.setLayout(new FillLayout());

DocumentBuilderFactory factory = new org.apache.xerces.jaxp.DocumentBuilderFactoryImpl();
DocumentBuilder builder = factory.newDocumentBuilder();
Document countriesDOM = builder.parse(DOMComboViewerMasterDetail.class

final Realm realm = SWTObservables.getRealm(display);

// Country
org.eclipse.swt.widgets.List countryList = new org.eclipse.swt.widgets.List(
        composite, SWT.BORDER | SWT.V_SCROLL);
ListViewer countryViewer = new ListViewer(countryList);
ObservableListContentProvider countryViewerContent = new ObservableListContentProvider();

countryViewer.setLabelProvider(new LabelProvider() {
    public String getText(Object element) {
        Element elt = (Element) element;
        return elt.getAttribute("name");

IObservableList countries = DOMObservables.observeElementItems(realm,
        countriesDOM.getDocumentElement(), "country", null, null);

// City
IObservableValue selectedCountry = ViewersObservables

org.eclipse.swt.widgets.List cityList = new org.eclipse.swt.widgets.List(
        composite, SWT.BORDER | SWT.V_SCROLL);
ListViewer cityViewer = new ListViewer(cityList);
ObservableListContentProvider cityViewerContent = new ObservableListContentProvider();

cityViewer.setLabelProvider(new LabelProvider() {
    public String getText(Object element) {
        Element elt = (Element) element;
        return elt.getAttribute("name");

IObservableList cities = DOMObservables.observeDetailList(realm,
        selectedCountry, "city");

// Street
IObservableValue selectedCity = ViewersObservables

org.eclipse.swt.widgets.List streetList = new org.eclipse.swt.widgets.List(
        composite, SWT.BORDER | SWT.V_SCROLL);
ListViewer streetViewer = new ListViewer(streetList);
ObservableListContentProvider streetViewerContent = new ObservableListContentProvider();

streetViewer.setLabelProvider(new LabelProvider() {
    public String getText(Object element) {
        Element elt = (Element) element;
        return elt.getAttribute("name");

IObservableList streets = DOMObservables.observeDetailList(realm,
        selectedCity, "street");


while (!shell.isDisposed()) {
    if (!display.readAndDispatch())


If you are interested with my work, don't hesitate to contact me, I will happy
to contribute to JFace Databinding project.

At end I have too start Rhino JFace Databinding to bind Scriptable _javascript_ Object with another thing (DOM, SWT UI....)
I could tell you more if you are interested.

Regards Angelo

Back to the top