Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[nebula-dev] New topic in forum Nebula, called TableComboViewer and changing the Background color of a row item, by Douglas Carter

Title: Eclipse Community Forums
Subject: TableComboViewer and changing the Background color of a row item Author: Douglas Carter Date: Tue, 14 August 2018 20:42
I'm trying to create a dropdown box in which I can change the background color of individual rows based on what that row contains. I had hoped that the TableComboViewer as it can be given a LabelProvider that implements ITableColorProvider, therefore allowing you to what I had assumed was set the background color per row. No matter what I try though nothing appears to apply the changes to the background color of the TableCombo, in the Text area or in the drop down.

Label Provider Below

public class ViewGroupLabelProvider extends LabelProvider implements ITableLabelProvider, ITableColorProvider, ITableFontProvider  {

	public String getText(Object element) {
		if (element instanceof String) {
			return (String) element;
		}
		return "Unk";
	}
	
	@Override
	public Font getFont(Object element, int columnIndex) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Color getForeground(Object element, int columnIndex) {
		return Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
	}

	@Override
	public Color getBackground(Object element, int columnIndex) {
		if (element instanceof String) {
			String item = (String) element;
			switch (item) {
				case "Brand":
					return Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED);
				case "Make":
					return Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN);
				case "Requested Part Number":
					return Display.getCurrent().getSystemColor(SWT.COLOR_DARK_BLUE);
			}
		}
		return new Color(new Shell().getDisplay(), 255,0,0);
	}

	@Override
	public Image getColumnImage(Object element, int columnIndex) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public String getColumnText(Object element, int columnIndex) {
		if (element instanceof String) {
			return (String) element;
		}
		return "Unk";
	}
}
[ Reply ][ Quote ][ View Topic/Message ][ Unsubscribe from this forum ]

Back to the top