SWT List cell renderer - swt

How to set a cell renderer for SWT list? I want to have a list with text, and every line must have a different foreground.

Sorry, but that cannot be done for list, only for a Table. See Table example snippet: draw different foreground colors for text in a TableItem.

Related

AG-grid : Changing the font color of parent row when child row cell is edited

I need to change the font-color of the parent row to red when any cell of the child row is edited.
Also the cellStyle for various cells of the child row is displayed in red color when the data is not correct.
I think you can try using redraw API provided by ag grid. Just call the API after the cell value is changed.

Label segmented cells with different colors

I am working with Matlab to extract cells from pathology images.
My codes successfully done the job and I can outline the cells by using 'bwperim'.
To outline the cell, my codes are:
perim=bwperim(selected_img);
r=img(:,:,1);
g=img(:,:,2);
b=img(:,:,3);
r(perim)=255;
g(perim)=0;
b(perim)=0;
img(:,:,1)=r;
img(:,:,2)=g;
img(:,:,3)=b;
And labeled the cells are:
But now I want to make the whole cell labeled with red, rather than just outline, what should I do?
It seems like you are looking for imfill:
mask = imfill(permi, 'holes');

Nattable Cell with Multiple combination of images

We have a requirement to visualize a state of the cell.
Each cell represents user's DB CRUD access so each cell has four boolean flags for create, read, update and delete. To visualize, each cell should show four images with each image showing state of that flag.
We defined 8 labels (CREATE, NO_CREATE, READ, NO_READ etc) and adding these labels based on underlying model. So at any time, each cell will have 4 labels. We want to show 4 images in each cell with each image showing the state of corresponding flag.
Based on the research and from Dirk's suggestion, CellDecoratorPainter is the preferred approach. But each cell with a label is associated with one cell painter (in this case CellDecoratorPainter) so how do we use that to render combination of these images?
One approach I could think of is, instead of creating individual labels for READ, NO_READ etc., create 4x4x2 labels like READ_CREATE_UPDATE_DELETE, NO_READ_CREATE_UPDATE_DELETE and associate each of these labels with one cell painter decorator to paint series of images accordingly.
Not sure if that is the only possible approach. If any of you come across this type of situation, can you please share some thoughts?
PS: This is posted at Eclipse forums at https://www.eclipse.org/forums/index.php/m/1782700/#msg_1782700
It is suggested that we use custom image painter to achieve this as explained at https://www.eclipse.org/forums/index.php/m/1782739/#msg_1782739.
Snippet of response is
You could implement a custom ImagePainter that inspects the cell
labels and draws images based on the labels in the label stack. Or
stack CellPainterDecorators so that every decorator has an image as
decoration that is only painted in case of the cell label, and has
another decorator as base painter.
But honestly, writing a custom ImagePainter that inspects the labels and draws the images on occurence of a label seems to be more
intuitive.
We implemented CombinationImagePainter to achieve this and is available at https://gist.github.com/brsanthu/cd2f91da7777aa994e011f7acedd900a if you are interested.
We had a similar requirement wherein an image was to be displayed at the start and at the end. Almost the way you showed however we extended the AbstractTextPainter class and wrote the implementation according.

Word Styles to get two elements to share same background/border

Within MS Word 2013 I am trying to create a text element plus a list underneath it, all wrapped inside a coloured border with background shading (see image). The attached image shows the text in plain form.
I would like to place a blue border around both the title and the list. I can achieve this by placing both objects within a 1x1 table and applying colouring rules to the cell, but semantically this seems bad (I'm from an HTML development background where it is very wrong!)
When I edit a Style rule to create the border/background, it works well until I create the list, then it goes badly wrong. Is it possible to achieve the output of the table cell approach by only using a style rule and no table?
After a day of experimentation, the closest I can get is by doing the following:
Create a style rule called Tips Heading based on Normal, then set it to be Bold with a blue background.
Create another style rule called Tips List based on List Paragraph, and set it to have a blue background.
Unfortunately the List cannot be indented because the background colour also indents. The border is also affected in this manner, so I ignored the border and indentation. It works really well and is semantically well structured.

change background of multiple text in JFace TextViewer

Is it possible to programatically change the background of multiple text in a TextViewer? For example, I have a word in my TextViewer document that is repeated several times. I would like to change the background colour of that.
I have tried adding LineBackgroundListener. But this changes the background of the whole line. I require only the chosen text to have a different background colour.
Is this possible?
Yes: Create a StyleRange with the background you want and then apply it with setStyleRanges(int[] ranges, StyleRange[] styles) where ranges is a list of int-pairs (start and end of each range in the styles argument) and styles is an array with the length ranges.length/2. Just repeat the same style range N times.