1.0M2


XWT


ComboViewer

The ComboViewer of JFace can be defined in the same way as ListViewer and TableViewer using the standard JFace class.


Simplified JFace viewers

This milestone has simplified the declaration of JFace viewer. The ILabelProvider and IContentProvider are not needed any more.

Here is the code for TableViewer,

  <TableViewer input="{Binding Path=employees}">
<TableViewer.columns>
<TableViewerColumn width="150" text="Name" displayMemberPath="name"/>
<TableViewerColumn width="150" text="Age" displayMemberPath="age"/>
</TableViewer.columns>
<TableViewer.control.layoutData>
<GridData horizontalAlignment="FILL"
grabExcessHorizontalSpace="true"/>
</TableViewer.control.layoutData>
</TableViewer>

Her is the code for ComboViewer,

  <ComboViewer input="{Binding Path=employees}" displayMemberPath="name">
<ComboViewer.control.layoutData>
<GridData horizontalAlignment="FILL"
grabExcessHorizontalSpace="true"/>
</ComboViewer.control.layoutData>
</ComboViewer>

And the code of ListViewer

  <ListViewer input="{Binding Path=employees}" displayMemberPath="name">
<ListViewer.control.layoutData>
<GridData horizontalAlignment="FILL"
grabExcessHorizontalSpace="true"/>
</ListViewer.control.layoutData>
</ListViewer>

Viewer Filter

A new class ViewerFilter is provided to define a filter in a JFace viewer. This class contains a collection of Condition which is used as predicate to select the elements to display.

  <TableViewer Name="TableViewer" input="{Binding Path=employees}" >
<TableViewer.filters>
<ViewerFilter>
<ViewerFilter.conditions>
<Condition property="age" value="30" operator="GT"/>
<Condition property="name" value="Th*" operator="LIKE"/>
</ViewerFilter.conditions>
</ViewerFilter>
</TableViewer.filters>


<TableViewer.columns>
<TableViewerColumn width="150" text="Name" displayMemberPath="name"/>
<TableViewerColumn width="150" text="Age" displayMemberPath="age"/>
</TableViewer.columns>
</TableViewer>

This TableViewer displays all Employee whose name is started with "Th" and ago is great than 30.


IObservable Management

A new IObservable management is implemented in XWT for each UI resource unit. XWT keeps now all instances of IObservable. It allows developers to get the IObservableValue and then modify observed values with automatically notifications in UI and in behind data. The service is provided in the main class XWT:

IObservableValue XWT.getObservableValue(Object control, Object data, String path);

Master/Detail support

XWT starts to provide a transparent "Declarative Data Binding" solution to hide all complexity of JFace data binding. The master/detail presentation is supported straightforward in the path expression of Data Binding. The expression language is extended to complete the missing type in programming language.

For example, the element type of a collection is always missing in binary class in Java. This information is necessary to build the Data binding chain in Mater/Detail pattern. In the following example, we have a class Company with a property "employees" in a collection or an array. The employees are displayed in a ListViewer, when user select an element, its name will be displayed in the Label below..

  <ListViewer name="master" input="{Binding Path=employees}" displayMemberPath="name">
<ListViewer.control.layoutData>
<GridData horizontalAlignment="FILL"
grabExcessHorizontalSpace="true"/>
</ListViewer.control.layoutData>
</ListViewer> <Label text="{Binding elementName=master,path=singleSelection.(j:Employee.name)}"/>

The property "name" in the binding expression is prefixed by its type Employee and enclosed by a parenthese.

Here is the example Snippet017 of Jface Data binding ported in XWT:



Update Source trigger

This Milestone integrates a new type UpdateSourceTrigger. And a new property "updateSourceTrigger" is added in the class Binding and therefore in Data Binding expression. This class indicates when the modification to Data Binding source model will occur. Most of UI Element has only one possibility like check Button. But Text has two possibilities: when the content gets changed, or when the focus gets loosed.

  <Text text="{Binding path=name,updateSourceTrigger=FocusOut}">

More operators in condition

The following operators are added in Condition and all classes of Trigger to extend the expression capability:

Operator Data type Description
EG Any Equal
NE Any Not equal
LT Number Less then
GT Number Great then
LE Number Less and equal
GE Number Great and equal
LIKE String String matching. * and ? are supported.
IS_A Any Tests if an instance is a type
IS_KIND_OF Type Tests if a type is same or a subclass of another.