Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Adding Labels to specific cells(Problem in adding labels to specific cells.)
Adding Labels to specific cells [message #1385094] Wed, 04 June 2014 10:05 Go to next message
Swapnil Basak is currently offline Swapnil BasakFriend
Messages: 12
Registered: June 2014
Junior Member
I have to add labels to specific cells to make them a dropdown field, checkbox etc. This is what I came up with, reading the examples.

public Control createExampleControl(Composite parent) {

		bodyDataProvider = new CustomDataProvider();
		DataLayer bodyDataLayer = new DataLayer(bodyDataProvider);

		final DefaultBodyLayerStack bodyLayer = new DefaultBodyLayerStack(bodyDataLayer);
		SelectionLayer selectionLayer = bodyLayer.getSelectionLayer();
		FreezeLayer freezeLayer = new FreezeLayer(selectionLayer);
		CompositeFreezeLayer compositeFreezeLayer = new CompositeFreezeLayer(freezeLayer, bodyLayer.getViewportLayer(), selectionLayer);
	    // Column header
		IDataProvider columnHeaderDataProvider = new DefaultColumnHeaderDataProvider(propertyColumns);
		ILayer columnHeaderLayer = new ColumnHeaderLayer(new DefaultColumnHeaderDataLayer(columnHeaderDataProvider), compositeFreezeLayer, selectionLayer);
		// Row header
		IDataProvider rowHeaderDataProvider = new DefaultRowHeaderDataProvider(bodyDataProvider);
		ILayer rowHeaderLayer = new RowHeaderLayer(new DefaultRowHeaderDataLayer(rowHeaderDataProvider), compositeFreezeLayer, selectionLayer);
		// Corner
		DefaultCornerDataProvider cornerDataProvider = new DefaultCornerDataProvider(columnHeaderDataProvider, rowHeaderDataProvider);
		CornerLayer cornerLayer = new CornerLayer(new DataLayer(cornerDataProvider), rowHeaderLayer, columnHeaderLayer);
	    // Grid
	    GridLayer gridLayer = new GridLayer(compositeFreezeLayer, columnHeaderLayer, rowHeaderLayer, cornerLayer);
// I assign the labels here
	    IConfigLabelAccumulator cellLabelAccumulator = new IConfigLabelAccumulator() {
	    	public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
	    		// Some logic to add a label
	    bodyLayer.addConfiguration(new EditorConfiguration());

		NatTable natTable = new NatTable(parent, gridLayer, false);

		// Configuration
		natTable.addConfiguration(new DefaultNatTableStyleConfiguration());
		natTable.addConfiguration(new HeaderMenuConfiguration(natTable));
		natTable.addConfiguration(new DefaultFreezeGridBindings());
		// natTable.addConfiguration(new EditorConfiguration());
		return natTable;

EditorConfiguration inherits AbstractRegistryConfiguration and adds a dropdown to the label Editable.DROPDOWN_EDIT.

However, this doesn't work. The accumulateConfigLabels isn't even called. What am I doing wrong?

Appreciate the help
Re: Adding Labels to specific cells [message #1385113 is a reply to message #1385094] Wed, 04 June 2014 12:28 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2751
Registered: July 2012
Senior Member
I think you need to set the cellLabelAccumulator to a lower level layer like the body data layer and not the DefaultBodyLayerStack
Previous Topic:Mouse Event Handling Problem
Next Topic:Unable to run NatTableExamples-1.1.0.jar
Goto Forum:

Current Time: Sat Dec 07 11:10:08 GMT 2019

Powered by FUDForum. Page generated in 0.01868 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top