Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Registering an ImagePainter for a certain cell
Registering an ImagePainter for a certain cell [message #1261604] Sun, 02 March 2014 20:30 Go to next message
Ralf Heydenreich is currently offline Ralf HeydenreichFriend
Messages: 235
Registered: July 2009
Senior Member
Hi all,
I've a table with a derived column which contains boolean values. Now I
want to render the cells which contains a "true" value with a certain
icon, the cells with "false" value could left blank. I've registered an
ImagePainter (DefaultCheckmarkPainter) to the cells with the label
"DEFAULT_CELL_LABEL":

configRegistry.registerConfigAttribute(
CellConfigAttributes.CELL_PAINTER,
new DefaultCheckmarkPainter(),
DisplayMode.NORMAL, DEFAULT_CELL_LABEL);

But now I don't know how to label the "true" cell values with
"DEFAULT_CELL_LABEL" (or if my solution is too complicated).

I've labeled a certain column with "DEFAULT_CELL_LABEL":

ColumnOverrideLabelAccumulator columnLabelAccumulator = new
ColumnOverrideLabelAccumulator(gridLayer.getBodyLayerStack());
columnLabelAccumulator.registerColumnOverrides(DEFAULT_COLUMN_POSITION,
DEFAULT_CELL_LABEL);

My DefaultCheckmarkPainter returns an image if the cell value is "true":

protected Image getImage(ILayerCell cell, IConfigRegistry configRegistry) {
return (boolean) cell.getDataValue() ? myImage : null;
}

Now I wonder if this is the correct solution or if there's a simpler one?

Regards,
Ralf.
Re: Registering an ImagePainter for a certain cell [message #1262215 is a reply to message #1261604] Mon, 03 March 2014 11:32 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Quote:
But now I don't know how to label the "true" cell values with "DEFAULT_CELL_LABEL"


http://eclipse.org/nattable/documentation.php?page=styling
Check the section about "Conditional Styling". You could create a custom IConfigLabelAccumulator. I also showed this in my articles that are also linked at our website.

Quote:
Now I wonder if this is the correct solution or if there's a simpler one?


You can only label the cell with a custom IConfigLabelAccumulator and register a custom painter, or register an ImagePainter without setting the image but specify the image via style, or use a CheckboxPainter with custom icons, where one icon is null. There are several ways to achieve your goal. You way is not wrong, but I prefer the custom IConfigLabelAccumulator. But how you solve it is up to you!
Previous Topic:Migrate ILayerCell from underlying layer to top-level
Next Topic:Summary layer with group by layer
Goto Forum:
  


Current Time: Thu Apr 25 22:49:31 GMT 2024

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

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

Back to the top