Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » Nebula ViewerCell with custom image
Nebula ViewerCell with custom image [message #57177] Wed, 06 August 2008 12:28 Go to next message
Eclipse UserFriend
Originally posted by: johnny.hensegard.telia.com

Hi,

I'm trying to print an image to a cell in the nebula grid.
I've tried two ways without success. Or maybe there is another way??

1.
Using the method ViewerCell.setImage(Image)
My problem here is that the image will not cover the whole cell,
the cell always puts a block of white space to the left of the image
(I have tried with bigger width than the cell has with the same result)

Example code:
GridViewerColumn col = new GridViewerColumn(viewer, SWT.NONE);
col.getColumn().setWidth(30);
col.setLabelProvider(new CellLabelProvider() {

@Override
public void update(ViewerCell cell) {
cell.setImage(new Image(Display.getDefault(), imageData));
}
});


2.
Using the GC to instead of setImage in the code below
GC gc = new GC(viewer.getGrid());
gc.setBackground(Display.getDefault().getSystemColor(SWT.COL OR_BLUE));
gc.fillRectangle(cell.getBounds());
gc.dispose();
This will flash the color once and then replace it with the original table

Cheers
/Johnny
Re: Nebula ViewerCell with custom image [message #57205 is a reply to message #57177] Wed, 06 August 2008 12:43 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5487
Registered: July 2009
Senior Member
Hi,

Solution 2 can't work because when ever the table issues a redraw you
image is gone. Solution 1 should use a ColumnLabelProvider and you are
leaking in the example a lot of images because you are always creating a
new one.

If you are not satisfied with the default rendering you'll have to
replace the DefaultCellRenderer directly on the Grid-Widget with your
implementation.

Tom

Johnny schrieb:
> Hi,
>
> I'm trying to print an image to a cell in the nebula grid.
> I've tried two ways without success. Or maybe there is another way??
>
> 1.
> Using the method ViewerCell.setImage(Image)
> My problem here is that the image will not cover the whole cell,
> the cell always puts a block of white space to the left of the image
> (I have tried with bigger width than the cell has with the same result)
>
> Example code:
> GridViewerColumn col = new GridViewerColumn(viewer, SWT.NONE);
> col.getColumn().setWidth(30);
> col.setLabelProvider(new CellLabelProvider() {
>
> @Override
> public void update(ViewerCell cell) {
> cell.setImage(new Image(Display.getDefault(), imageData));
> }
> });
>
>
> 2.
> Using the GC to instead of setImage in the code below
> GC gc = new GC(viewer.getGrid());
> gc.setBackground(Display.getDefault().getSystemColor(SWT.COL OR_BLUE));
> gc.fillRectangle(cell.getBounds());
> gc.dispose();
> This will flash the color once and then replace it with the original table
>
> Cheers
> /Johnny
>
>
>
>
>
>
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Re: Nebula ViewerCell with custom image [message #591514 is a reply to message #57177] Wed, 06 August 2008 12:43 Go to previous message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 5487
Registered: July 2009
Senior Member
Hi,

Solution 2 can't work because when ever the table issues a redraw you
image is gone. Solution 1 should use a ColumnLabelProvider and you are
leaking in the example a lot of images because you are always creating a
new one.

If you are not satisfied with the default rendering you'll have to
replace the DefaultCellRenderer directly on the Grid-Widget with your
implementation.

Tom

Johnny schrieb:
> Hi,
>
> I'm trying to print an image to a cell in the nebula grid.
> I've tried two ways without success. Or maybe there is another way??
>
> 1.
> Using the method ViewerCell.setImage(Image)
> My problem here is that the image will not cover the whole cell,
> the cell always puts a block of white space to the left of the image
> (I have tried with bigger width than the cell has with the same result)
>
> Example code:
> GridViewerColumn col = new GridViewerColumn(viewer, SWT.NONE);
> col.getColumn().setWidth(30);
> col.setLabelProvider(new CellLabelProvider() {
>
> @Override
> public void update(ViewerCell cell) {
> cell.setImage(new Image(Display.getDefault(), imageData));
> }
> });
>
>
> 2.
> Using the GC to instead of setImage in the code below
> GC gc = new GC(viewer.getGrid());
> gc.setBackground(Display.getDefault().getSystemColor(SWT.COL OR_BLUE));
> gc.fillRectangle(cell.getBounds());
> gc.dispose();
> This will flash the color once and then replace it with the original table
>
> Cheers
> /Johnny
>
>
>
>
>
>
>


--
B e s t S o l u t i o n . at
------------------------------------------------------------ --------
Tom Schindl JFace-Committer
------------------------------------------------------------ --------
Previous Topic:Nebula ViewerCell with custom image
Next Topic:How to traverse through PGroup without focusing toggle button
Goto Forum:
  


Current Time: Sat Dec 20 08:41:56 GMT 2014

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

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