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 Basak
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) {

		setPropertyColumns();
		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() {
	    	@Override
	    	public void accumulateConfigLabels(LabelStack configLabels, int columnPosition, int rowPosition) {
	    		// Some logic to add a label
	    		configLabels.addLabel(Editable.DROPDOWN_EDIT);
	    	}
	    };
		
	    bodyLayer.setConfigLabelAccumulator(cellLabelAccumulator);
	    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());
		natTable.configure();
		
		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?

Thanks,
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 Fauth
Messages: 1339
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:How to efficient upadate the whole data of a NatTable?
Next Topic:Unable to run NatTableExamples-1.1.0.jar
Goto Forum:
  


Current Time: Fri Oct 24 07:47:23 GMT 2014

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

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