Column Provider

Introduction

The column provider extension point allows you to contribute new columns that will be automatically added to the existing ones.

The interface associated to this extension point is IMAColumnProvider, but you should avoid implementing this interface directly and instead extend the AbstractMAColumnProvider class.

The only method you need to implement is the getColumns method, which takes a collection of PossibleFeatures (containing all the common structural features for the initial data objects, already computed for your use) and a collection of EObject elements (the current data objects for which the columns should be provided), and returns a collection of IMAColumns.

Note that this method is called every time new elements are added into the existing table (since the table configuration might change) in order to obtain the new column configuration (some elements that do not share a column with the existing ones might be added, and so this column should be removed). It is your responsibility to ensure that this method call is optimized, avoid recreating new columns if the existing ones did not change.

For the next concepts that we will introduce regarding the IMAColumn, we will always have the following naming convention:

The column abstraction

Represents a column abstraction that corresponds to a displayed column. Its main role is to manage the column data (obtaining the current value of this column for a particular table row and modifying it accordingly).

It is advised that you do not implement this interface directly, and instead inherit of either link AbstractMAColumn or MAPrimitiveColumn.

The IMAColumn is in charge among other things, of providing for each row object the current value for this column and also to update the existing value when the user has selected a new one. Note that if your column is not mapped to a feature, you need to use an internal data structure to manage the column content. You should typically use a hash-map having as many entries as row objects, but the choice belongs to you.

The Cell Editor

The cell editor is a NatTable concept, that wraps SWT controls to be cell editors. We provide two abstract implementations AbstractMACellEditor and AbstractMAPrimitiveCellEditor, where we take care of most of the dirty work and internal plumbing.

When the user click on an editable cell, the createEditorControl method is invoked and the newly created control is displayed in a dialog. The cell editor delegates all the display and editing behavior to this cell control.

The Cell Control

We provide two abstract implementations AbstractMACellControl and AbstractMAPrimitiveCellControl. For both implementations you can use the selectedRowObjects field in order to have access to the row objects that the user selected when emitting an edit command.

First of all please note that the control is a Composite, meaning that when the associated editor is invoked, a dialog containing this composite will be opened. By customizing this control you customize the way your users will select a new value for the cells they are currently editing. This can be as simple as a text field or as complex as a multi-grid dialog with plenty of buttons and sparkly colors.

Second of all the control provides access to both the editor value (the representation displayed in the cell editor) and the canonical value (the normal data representation).

For example, the canonical representation might be a Date object, whereas the editor representation could be a formatted String. Note that in NatTable a new cell control is created whenever a user invokes an edit command.

The Data Validator

The data validator provides a validation mechanism for the newly selected values by the users. If the validation is not successful, an error dialog is displayed and the user must either cancel or select a new value.

You can extends the MADataValidator in order to add your own behavior.

The Display Converter

The display converter converts between the actual object representation to the textual representation. The textual value is the one displayed in the column cell. For example, the canonical representation might be a Date object, whereas the target representation could be a formatted String.

You can extends the MADisplayConverter in order to add your own behavior.