How to work with custom painters in NatTable? [message #1085668] |
Tue, 13 August 2013 03:47  |
Eclipse User |
|
|
|
I have a scenario where in a single column, the cells either have a Null Editor (No editor) or a Combo Box Editor. I did this using a custom Editor.
Now I cant understand how to use a custom painter, so that the one with Null Editor has a Text Box Painter, and the Combo Box Editor has a Combo Box Painter.
I want to use a custom painter, but there is no documentation available on what method does what in the class that implements ICellPainter.
How can i use thi scustom painter?
Or is there any other better way to do so? If so, what?
Regards,
Ali Ahmad Malik
|
|
|
|
Re: How to work with custom painters in NatTable? [message #1091145 is a reply to message #1085694] |
Wed, 21 August 2013 01:14   |
Eclipse User |
|
|
|
Hi Dirk,
What you are trying to say, I assume, is that I have two columns.
But I have only 1 column, and within that column some cells would be using ComboBox Painter, some would be using TextPainter.
I achieved my goal by using a custom painter. In the paintCell method I used the painters as required. Below is a code snippet:
@Override
public void paintCell(ILayerCell arg0, GC arg1, Rectangle arg2,
IConfigRegistry arg3) {
if(arg0.getRowIndex() % 2 == 0 ) {
textPainter.paintCell(arg0, arg1, arg2, arg3);
} else {
comboPainter.paintCell(arg0, arg1, arg2, arg3);
}
}
Where
comboPainter = new ComboBoxPainter();
textPainter = new TextPainter();
So in this snippet, according to the cell index it either paints it as a TextPainter, or a ComboBoxPainter.
Anyways, thanks for your help, Dirk
Regards,
Ali Ahmad Malik
|
|
|
Re: How to work with custom painters in NatTable? [message #1091208 is a reply to message #1091145] |
Wed, 21 August 2013 03:18  |
Eclipse User |
|
|
|
No, for those use cases we have the label mechanism. You need to create a cell label overrider that adds special labels to the cell label stack and configure the painters dependent to that labels. This can be done on a per column, per row or per cell base. I did this before and it works like charm. There is no need to implement custom painters that call the real painters by condition.
From the architectural design aspect of NatTable your solution is not correct. It also works, but there is a much more convenient way without the need to implement custom painters as you only need to configure correctly.
|
|
|
Powered by
FUDForum. Page generated in 0.07660 seconds