Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » CellPainterDecorator
CellPainterDecorator [message #1181452] Mon, 11 November 2013 16:07 Go to next message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
I have a bean as a model object for a cell. I have registered a converter to get its string representation.

I would like to decorate that cell with a short text. This text is stored in the model bean. How can I add a CellPainterDecorator to paint that short text let's say on the right side of the cell?

The example CellPainterDecorator shows exactly what I'm looking for, but it uses image decorator and the image is not get from the cell model. It's static.
Re: CellPainterDecorator [message #1181717 is a reply to message #1181452] Mon, 11 November 2013 19:57 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2751
Registered: July 2012
Senior Member
The more dynamic it becomes, the more you have to adjust.

If you want to show an dynamic icon, it should be enough to create the decorator without an initial image and register the image within a style against a label.

If you want to decorate with a text that is also retrieved out of the model you have to find a way how the decorator is able to retrieve the data. Haven't done anything similar before.
Re: CellPainterDecorator [message #1182593 is a reply to message #1181717] Tue, 12 November 2013 09:35 Go to previous message
Jan Krakora is currently offline Jan KrakoraFriend
Messages: 477
Registered: December 2009
Location: Prague
Senior Member
Ok, I have done it by overriding its convertDataType(ILayerCell cell, IConfigRegistry configRegistry) method
CellPainterDecorator painterDecorator = new CellPainterDecorator(
     new TextPainter(), 
     CellEdgeEnum.RIGHT, 
     new TextPainter() {
					
	 @Override
	 protected String convertDataType(ILayerCell cell, IConfigRegistry configRegistry) {
	      Object model = cell.getDataValue();
              if (model instanceof MerenyBod) {
                   // return model specific text
                   ...
	      }
	      return StringUtils.EMPTY;
	 }
     }, 
     true
);
Previous Topic:Pop up menu in Editable cells.
Next Topic:How to use ColumnHideShowLayer with ColumnGroupHeaderLayer
Goto Forum:
  


Current Time: Sat Dec 07 12:13:22 GMT 2019

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

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

Back to the top