Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Styling based on combination of labels(How to apply style based on more than one label)
icon3.gif  Styling based on combination of labels [message #1171394] Tue, 05 November 2013 07:47 Go to next message
Artyom Karalov is currently offline Artyom KaralovFriend
Messages: 15
Registered: August 2013
Location: Israel
Junior Member
Hi.
I have grid representing database table and want to mark PK fields with icon.
I defined cell painter decorator and it works great.

configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, new BeveledBorderDecorator(new CellPainterDecorator(new TextPainter(), CellEdgeEnum.LEFT, new ImagePainter(getImage("key.png")))), DisplayMode.NORMAL, LABEL_PK);


The problem is that when I sort by this column the image disappears since sort header has it's own cell painter (SortableHeaderTextPainter). So what I need is to decide on painter based on combination of labels: not pk and not sorted - TextPainter, pk and not sorted - ImagePainter, not pk and sorted - SortablePainter, pk and sorted - SortablePainter decorated with ImagePainter.
Is it doable or there is other way to achieve functionality I need?
Re: Styling based on combination of labels [message #1171418 is a reply to message #1171394] Tue, 05 November 2013 08:09 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2702
Registered: July 2012
Senior Member
You could register a different SortableHeaderTextPainter that does not use a TextPainter but your decorator as interior painter.
And you would need to use an ImagePainter with no initial image set, but configure a style that contains an image.

ICellPainter myDecorator = new CellPainterDecorator(new TextPainter(), CellEdgeEnum.LEFT, new ImagePainter());
SortableHeaderTextPainter sortPainter = new SortableHeaderTextPainter(myDecorator);

configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, sortPainter , DisplayMode.NORMAL, SORT_DOWN_CONFIG_TYPE);
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_PAINTER, sortPainter , DisplayMode.NORMAL, SORT_UP_CONFIG_TYPE);

//set the image style for the label
Style imageStyle = new Style();
mageStyle .setAttributeValue(CellStyleAttributes.IMAGE, getImage("key.png"));
configRegistry.registerConfigAttribute(CellConfigAttributes.CELL_STYLE, imageStyle, DisplayMode.NORMAL, LABEL_PK);
Re: Styling based on combination of labels [message #1171521 is a reply to message #1171418] Tue, 05 November 2013 09:38 Go to previous message
Artyom Karalov is currently offline Artyom KaralovFriend
Messages: 15
Registered: August 2013
Location: Israel
Junior Member
Works like a charm.
Thanks a lot for prompt response.
Previous Topic:disable editing and context menu in nattable
Next Topic:How to convert data beans to strings within cells
Goto Forum:
  


Current Time: Mon Aug 19 03:57:45 GMT 2019

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

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

Back to the top