JFace Data Bindings

Supported for Eclipse 3.3 and above only

Click the Bindings tab in the editor to created and edit data bindings.

JFace Viewers can bind to a content provider, label provider and input object. The content provider (an ObservableListContentProvider or ObservableSetContentProvider) is calculated automatically based on the input. The label provider (and ObservableMapLabelProvider) is created based on the observed bean and its selected properties.

Viewers

Any viewers defined in the current compilation unit are shown in the widget list. Several properties including the input can be selected in the properties list

Input Types

Several types of inputs are supported:

New JFace Bindings

New bindings are created by selecting a Viewer, an Input and clicking the Bind button. When creating a binding, the Content Provider and Label Provider may be specified.

 

For Eclipse 3.4 and above:

For TreeViewer inputs, the Input Bean Class, IObservableFactory, Tree Structure Advisor, Content Provider and Label Provider may be specified.

In order to simplify this, the tool can generate a number of pre-defined helper classes that implement most of the needed tree behavior.

Existing JFace Bindings

At the top of the page, existing Bound Viewers are listed. The Content Provider and Input are listed for each viewer.

Clicking the Edit button or Edit menu opens the Edit Binding dialog where the providers may be modified.

    

The Delete button or Delete menu is used to delete the selected bound viewer while the Delete All button or Delete All menu is used to delete all of the bound viewers.

The Move Up and Move Down buttons and menus are used to change the order of the bindings while the Goto Definition button and menu are used to jump to the generated code for the binding.

Source

As bindings are created or edited on the Bindings tab, the necessary data binding code is generated which may then be seen in the Source view. An initDataBindings() method is created, if it does not already exist and a call to that method is added to the end of the widget creation process.

Within the initDataBindings() method, any needed observables are created first followed by the creation of the Data Binding Context. Simple SWT data bindings are then created using the new context followed by any JFace content providers, list providers and inputs that are needed.

Warning: do not edit the initDataBinding() method by hand (without carefully matching the code generation pattern used by the tool) as it will be regenerated in its entirety any time the tool needs to add, remove or update a data binding.