Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » How to work with custom painters in NatTable?
How to work with custom painters in NatTable? [message #1085668] Tue, 13 August 2013 07:47 Go to next message
Ali Malik is currently offline Ali MalikFriend
Messages: 27
Registered: August 2013
Junior Member
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 #1085694 is a reply to message #1085668] Tue, 13 August 2013 08:33 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
Why do you need a custom painter to achieve that? You need to register labels according to your use case. For the one label you register the TextCellPainter, for the other label the ComboBoxPainter. No need for a custom painter and no magic. Smile
Re: How to work with custom painters in NatTable? [message #1091145 is a reply to message #1085694] Wed, 21 August 2013 05:14 Go to previous messageGo to next message
Ali Malik is currently offline Ali MalikFriend
Messages: 27
Registered: August 2013
Junior Member
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 Smile

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 07:18 Go to previous message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2902
Registered: July 2012
Senior Member
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.
Previous Topic:Multiple Selection is not enforced after setting flag in the selection model.
Next Topic:State saving is buggy...
Goto Forum:
  


Current Time: Thu Apr 18 23:19:11 GMT 2024

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

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

Back to the top