Skip to main content



      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 05:20 Go to next message
Eclipse UserFriend
Hi, Dirk,
Can I add an icon into RowHeader like attached image ?
  • Attachment: RowHeader.png
    (Size: 19.26KB, Downloaded 510 times)
Re: Can I add an icon in RowHeader in NatTable ? [message #1727595 is a reply to message #1727594] Thu, 24 March 2016 05:32 Go to previous messageGo to next message
Eclipse UserFriend
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 06:43 Go to previous messageGo to next message
Eclipse UserFriend
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 09:58 Go to previous messageGo to next message
Eclipse UserFriend
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 06:07 Go to previous messageGo to next message
Eclipse UserFriend
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 08:02 Go to previous messageGo to next message
Eclipse UserFriend
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] Mon, 04 April 2016 20:45 Go to previous message
Eclipse UserFriend
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: Sat Jun 14 01:59:20 EDT 2025

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

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

Back to the top