Elastic Path Commerce Development

Table Viewer

Table Viewer


The EP table viewer abstracts the Eclipse's TableViewer and TableColumn components.

How to use it

An instance of IEpTableViewer can be obtained from the IEpLayoutComposite or EpControlFactory:

IEpTableViewer IEpLayoutComposite.addTableViewer(boolean multiSelection, EpState epState, IEpLayoutData data)
IEpTableViewer EpControlFactory.createTableViewer(final Composite parentComposite, final int style, final EpState epState)

Usually a table has to have at least one column. Columns can be added by calling

IEpTableColumn IEpTableViewer.addTableColumn(String headerText, int initialWidth)

The interface IEpTableColumn represents a column in the table.

There are two modes for an EP table viewer depending on the EpState (EDITABLE, READ_ONLY, DISABLED). If the table is created in read-only mode the label provider can be set directly on the IEpTableViewer instance. The provided label provider will be responsible for checking which column the label should be provided for and return it accordingly . If the table created is in EDITABLE state then each column has to have its own column label provider and editing support implementations. Of course editing support can be omitted in case it is not needed.

The look and feel of the table viewer is predefined and is dependent on the EpState value supplied at creation time.


This example is extracted from AddSkuWizardPage2 class. It shows the way the new SKU wizard handles the attributes values that have to be set to the SKU object model. An IEpTableViewer is created and a few columns added. The editing support is needed so that we have the value column editable when the user clicks over it. The AttributeEditingSupport class extends the org.eclipse.jface.viewers.EditingSupport.

	this.attributesTableViewer = mainComposite.addTableViewer(false, EpState.EDITABLE, tableLayoutData);
	final GridData tableLayoutData2 = (GridData) attributesTableViewer.getSwtTable().getLayoutData();
	tableLayoutData2.heightHint = TABLE_HIGH_HINT;
	tableLayoutData2.widthHint = TABLE_WIDTH_HINT;

	// the name column content of the attribute table
	final IEpTableColumn nameColumn = this.attributesTableViewer
	// The attribute type column content of the attribute table
	final IEpTableColumn typeColumn = this.attributesTableViewer
	// The attribute required column content of the attribute table
	final IEpTableColumn requiredColumn = this.attributesTableViewer
	// The attribute required column content of the attribute table
	final IEpTableColumn multiLanguageColumn = this.attributesTableViewer

	// The attribute value column content of the attribute table
	final IEpTableColumn valueColumn = this.attributesTableViewer
	final AttributesLabelProviderUtil labelProviderUtil = new AttributesLabelProviderUtil(EpState.EDITABLE);

	// add EditSupport to the attribute value column
	valueColumn.setEditingSupport(new AttributeEditingSupport(this.attributesTableViewer, this.getProductSku()));