Sunday, November 12, 2006

Project renaming and removal of provisional API

On Friday the concurrency branch, Bug116920_investigation, was merged into HEAD and the projects have also been renamed. This means that Realms are now in HEAD and most provisional API has been removed. What that means is that with HEAD your code probably doesn't compile.

Project Renaming

  • org.eclipse.jface.databinding -> org.eclipse.core.databinding

  • org.eclipse.jface.databinding.beans -> org.eclipse.core.databinding.beans

  • org.eclipse.jface.databinding.ui -> org.eclipse.jface.databinding

  • org.eclipse.jface.examples.databinding

  • org.eclipse.jface.tests.databinding


Realms deserve more than a blog post so I'm going to leave this until later; there will be documentation on the subject. To see what has led us down this path see bug 116920. Take a look at the examples and tests projects for usage. There's also a ThreadRealm and LockRealm implementation in the tests projects.

Provisonal API Removal

The majority of the consumer code that could be broken is the result of the removal of the provisional API. The majority of that API existed to allow for the binding of viewers to a model. Previously the only API that the consumer had for this was a builder that then took care of creating the label and content providers. We don't yet have replacements for the builders but we have API for content providers and label providers which can be used to bind viewers without a builder. By exposing these classes this allows for flexibility that we didn't previously have. Consumers now have access to the label provider and can create a decorator to provide colors, fonts, images, etc. as well as the text. Below is a quick example of the creation of the label and content providers for a ComboViewer.

    1 //Create the observable for the domain list.
2 IObservableList lodgings = BeansObservables.observeList(Realm
3 .getDefault(), catalog, "lodgings");
4 //Create the content provider that corresponds to the observable list.
5 ObservableListContentProvider contentProvider = new ObservableListContentProvider();
7 //Create a mapping for the attribute to display.
8 IObservableMap[] attributeMaps = BeansObservables.observeMaps(
9 contentProvider.getKnownElements(), Lodging.class,
10 new String[] { "name" });
12 cviewer.setContentProvider(contentProvider);
13 cviewer.setLabelProvider(new ObservableMapLabelProvider(attributeMaps));
14 cviewer.setInput(lodgings);

The key to this is the creation of the attributeMaps (line 8). In this case we're only specifying one attribute, name (line 10), because it's a Combo. In the map returned the key will be the element and the value will be the display value of the name attribute of the element.

Stay tuned, it's going to be a busy next couple of months.

No comments: