Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Is my Styling approach correct.
Is my Styling approach correct. [message #1059086] Thu, 16 May 2013 15:18 Go to next message
Courtney Jines is currently offline Courtney JinesFriend
Messages: 13
Registered: September 2012
Junior Member
What i did for being independent from labeling for styling purpose.

1) Extended TextPainter and overridden painCell() method. as shown below

@Override
public void paintCell(ILayerCell cell, GC gc, Rectangle rectangle, IConfigRegistry configRegistry) {

configureRegistry(cell, configRegistry); //METHOD USED FOR CUSTOM STYLING. ANY ONE CAN EXTEND THIS CLASS AND OVERRIDE THIS METHOD FOR THE CUSTOM STYLING.
super.paintCell(cell, gc, rectangle, configRegistry);
}

protected void configureRegistry(ILayerCell cell, IConfigRegistry configRegistry) {}


2) Applying custom styling to configRegistry.
3) Now anyone can apply custom styling by just extending this class.

Please let me know modification to configRegistry in this way will not cause any problem.


Thanks a lot in advance please must reply.

Re: Is my Styling approach correct. [message #1059169 is a reply to message #1059086] Fri, 17 May 2013 06:19 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2704
Registered: July 2012
Senior Member
Well, I'm not sure why you want to do this. In fact you are removing a lot of flexibility and functionality by doing it like this. You will not be able to have conditional styling anymore for example.

So why do you want to be independent from the labeling mechanism? Why do you prefer coding over configuration?

Additionally, you are calling super.paintCell() which retrieves the styling out of the ConfigRegistry via labels. So in fact you don't win anything.
Re: Is my Styling approach correct. [message #1059548 is a reply to message #1059169] Mon, 20 May 2013 12:04 Go to previous messageGo to next message
Courtney Jines is currently offline Courtney JinesFriend
Messages: 13
Registered: September 2012
Junior Member
Thank you very much Dirk.

I am using concept of labeling for Styling. Only thing which is causing confusion is that I want to show a painter with a color image.
And I am getting the color by converting cell value and setting wrapped painter as shown below.

@Override
public void paintCell(ILayerCell cell, GC gc, Rectangle rectangle,
IConfigRegistry configRegistry) {

Color colorValue = BeansUtilManager.decodeColorFromInteger(new Integer(cell.getDataValue().toString()));

ColorImage colorImage = new ColorImage(PREFERRED_WIDTH,PREFERRED_HEIGHT, colorValue);

if (image != null && !image.isDisposed()) {
image.dispose();
image = null;
}

image = colorImage.getImage();

setWrappedPainter(new BeveledBorderDecorator(new ImagePainter(image)));

super.paintCell(cell, gc, rectangle, configRegistry);
}

Is above changes are valid(Actually it is fulfilling our requirement). Please share your opinion.

Thanks in advance Dirk Sir, I know you will answer me

[Updated on: Tue, 21 May 2013 09:00]

Report message to a moderator

Re: Is my Styling approach correct. [message #1059570 is a reply to message #1059548] Mon, 20 May 2013 14:08 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk FauthFriend
Messages: 2704
Registered: July 2012
Senior Member
First of all, my name is Dirk with a R and not Dick!

I would still use a different approach.

1. Attach a label to determine that a special painter should be used
2. Configure a painter that is in fact a CellPainterDecorator that decorates a TextPainter with a specialized ImagePainter
3. Override the getImage() method of that ImagePainter to perform the action you showed above. I personally use anonymous inner classes to solve such issues

That should it be without modifying working internal code.
Re: Is my Styling approach correct. [message #1059654 is a reply to message #1059570] Tue, 21 May 2013 06:23 Go to previous message
Courtney Jines is currently offline Courtney JinesFriend
Messages: 13
Registered: September 2012
Junior Member
Hello Dirk,

After doing the same as suggested above. My painter which is being display in cell with no text(bcoz i overridden the gettexttodisplay() and returned empty string) but image is only Right or Left aligned but i want it in center. with button like look lifted upward. It is working fine for others painters where image is right aligned and lifted up as button kind look.

CellPainterDecorator cpw = new CellPainterDecorator(new TextPainter(),
CellEdgeEnum.LEFT,
new BeveledBorderDecorator(new ImagePainter(){
@Override
protected Image getImage(ILayerCell cell,
IConfigRegistry configRegistry) {
//RETURNING IMAGE FROM HERE},true));

setWrappedPainter(cpw);

Please suggest some appropriate solution or any other approach to get this output.

Thanks
Amresh

[Updated on: Wed, 22 May 2013 14:24]

Report message to a moderator

Previous Topic:How to add Filter row in Nattable
Next Topic:Detecting changes in a list - without glazedlists
Goto Forum:
  


Current Time: Fri Aug 23 13:19:52 GMT 2019

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

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

Back to the top