Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Can I add an icon in RowHeader in NatTable ?
Can I add an icon in RowHeader in NatTable ? [message #1727594] Thu, 24 March 2016 09:20 Go to next message
Luke Chen is currently offline Luke ChenFriend
Messages: 10
Registered: March 2016
Junior Member
Hi, Dirk,
Can I add an icon into RowHeader like attached image ?
  • Attachment: RowHeader.png
    (Size: 19.26KB, Downloaded 491 times)
Re: Can I add an icon in RowHeader in NatTable ? [message #1727595 is a reply to message #1727594] Thu, 24 March 2016 09:32 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Yes, it is the same as for body cells. You simply need to register the appropriate cell painter for the row header. Dependen on your use case it can be done via CellPainterDecorator.
Re: Can I add an icon in RowHeader in NatTable ? [message #1728024 is a reply to message #1727595] Wed, 30 March 2016 10:43 Go to previous messageGo to next message
Luke Chen is currently offline Luke ChenFriend
Messages: 10
Registered: March 2016
Junior Member
I had found I can add icon in ThemeConfiguration (extends DefaultNatTableThemeConfiguration), like this
        // row header styling
        this.rHeaderFont = selectedRowFont;
        this.rHeaderCellPainter = new CellPainterDecorator(new TextPainter(),
                CellEdgeEnum.RIGHT,
                new ImagePainter(SWTUtils.getImage(Constants.ICON_ADD)));
        this.rHeaderSelectionCellPainter = new CellPainterDecorator(new TextPainter(),
                CellEdgeEnum.RIGHT,
                new ImagePainter(SWTUtils.getImage(Constants.ICON_ADD)));
        this.rHeaderFullSelectionCellPainter = new CellPainterDecorator(new TextPainter(),
                CellEdgeEnum.RIGHT,
                new ImagePainter(SWTUtils.getImage(Constants.ICON_ADD)));


then all rows header has same icon, while, my questions is can I add different icon in assigned rows and how ?

Thanks,
Luke Chen
Re: Can I add an icon in RowHeader in NatTable ? [message #1728042 is a reply to message #1728024] Wed, 30 March 2016 13:58 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
RTFM

https://www.eclipse.org/nattable/documentation.php?page=styling

IConfigLabelAccumulator is the keyword
Re: Can I add an icon in RowHeader in NatTable ? [message #1728136 is a reply to message #1728042] Thu, 31 March 2016 10:07 Go to previous messageGo to next message
Luke Chen is currently offline Luke ChenFriend
Messages: 10
Registered: March 2016
Junior Member
Hi, Drik,

I had made it in another way by using GC to draw an rectangle, and I can see this rectangle after seted datas asynchronous, and it disappeared then, I think it may covered by something or redrawed ?

I had test it when I add a button and put my GC redraw logic in button's selection event, the rectangle has redrawed on it. So I want to know where is the last refresh UI in NatTable ? I want to add my GC redraw after it.

Thanks,
Luke Chen
Re: Can I add an icon in RowHeader in NatTable ? [message #1728157 is a reply to message #1728136] Thu, 31 March 2016 12:02 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
You can always do something completely different than what is supported out of the box. But I won't spend time explaining how to do wrong things.

You just need to configure an IConfigLabelAccumulator to cells in your row header and configure a cell painter for that label and you will get what you need. If you want to do some custom painting to achieve a default use case in NatTable just because you don't want to read the documentation or don't understand what you need to do, go and find out yourself why it isn't working.

Working directly with the GC in NatTable is only necessary when creating custom painters.
Re: Can I add an icon in RowHeader in NatTable ? [message #1728493 is a reply to message #1728157] Tue, 05 April 2016 00:45 Go to previous message
Luke Chen is currently offline Luke ChenFriend
Messages: 10
Registered: March 2016
Junior Member
I am sorry for reply you now because of Traditional Chinese Holidays.

You are right, I fixed it according to your suggestions and thanks you very much. I used IConfigLabelAccumulator to change config label at any time refresh data. I bind a config label to a cell painter to redraw an icon.

You are so nice.
Previous Topic:Resize one column when selected all rows
Next Topic:Missing tag for 1.3.0 in repository?
Goto Forum:
  


Current Time: Thu Apr 25 23:09:22 GMT 2024

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

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

Back to the top