Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » NatTable » Painter for custom editor component.(How can we apply painter for a complex editor component.)
Painter for custom editor component. [message #1066604] Wed, 03 July 2013 08:14 Go to next message
Courtney Jines is currently offline Courtney Jines
Messages: 13
Registered: September 2012
Junior Member
Hello Dirk,

I have to apply painter for a editor component which has three labels and four text components. Predefined painters are not suitable for that so I am thinking to create an image by custom drawing same as editor component? Please suggest if there is any good approach than what i am thinking.

Thanks in advance.

Re: Painter for custom editor component. [message #1066639 is a reply to message #1066604] Wed, 03 July 2013 10:17 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1248
Registered: July 2012
Senior Member
Hi,

I'm not sure what you mean. First you need to differentiate between editor and painter. The editor is Control based, while the painter is simply drawing on the GC. If your editor is complex, I assume it is handled in a subdialog? Otherwise I'm not sure if NatTable supports a complex editor control inline. Never tried it before, so to be honest I'm not sure.

Implementing a custom painter is straight forward. You simply need to draw on a GC whatever you want to draw. Labels, Images or whatever. The TextPainter does nothing else.

Greez,
Dirk
Re: Painter for custom editor component. [message #1066973 is a reply to message #1066639] Fri, 05 July 2013 06:09 Go to previous messageGo to next message
Courtney Jines is currently offline Courtney Jines
Messages: 13
Registered: September 2012
Junior Member
Thanks for reply Dirk.

As in NatTable, odd row and even row have different background colors so according to that i want to set the background color in my image. but don't know how can i get that color to set in my image.

setWrappedPainter(new BeveledBorderDecorator(new ImagePainter() {
      @Override
      protected Image getImage(ILayerCell cell, IConfigRegistry configRegistry) {
     
      //how to get color......  


      return _image;
        }
      }));


Please suggest any appropriate approach to get the color according to odd or even rows.
Thanks in advance.
Re: Painter for custom editor component. [message #1066979 is a reply to message #1066973] Fri, 05 July 2013 06:34 Go to previous messageGo to next message
Dirk Fauth is currently offline Dirk Fauth
Messages: 1248
Registered: July 2012
Senior Member
Not sure if it works because of possible time related issues (when is which style applied?), but technically this should work:
IStyle cellStyle = CellStyleUtil.getCellStyle(cell, configRegistry);
Color bg = cellStyle.getAttributeValue(CellStyleAttributes.BACKGROUND_COLOR);
Re: Painter for custom editor component. [message #1067001 is a reply to message #1066979] Fri, 05 July 2013 07:53 Go to previous message
Courtney Jines is currently offline Courtney Jines
Messages: 13
Registered: September 2012
Junior Member
Thanks Dirk it is working fine. Smile

[Updated on: Fri, 05 July 2013 07:56]

Report message to a moderator

Previous Topic:Table with no row header
Next Topic:Support for color selection in a cell ?
Goto Forum:
  


Current Time: Wed Aug 20 01:02:01 EDT 2014

Powered by FUDForum. Page generated in 0.03990 seconds