Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » TableComboViewer and changing the Background color of a row item
TableComboViewer and changing the Background color of a row item [message #1793732] Tue, 14 August 2018 20:42 Go to next message
Douglas Carter is currently offline Douglas CarterFriend
Messages: 2
Registered: July 2018
Junior Member
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";
	}
}
Re: TableComboViewer and changing the Background color of a row item [message #1793759 is a reply to message #1793732] Wed, 15 August 2018 10:37 Go to previous message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 493
Registered: July 2009
Senior Member

Hi Douglas,

Indeed, this does not seem to work. I have tested with the viewer snippet from [1] but I could not get any background action. It is strange because I do see calls to getBackgroundColor but I only see it during the buildup of the combo. Even there, the color returned is ignored.

Please file an issue in Github and please chip in and see if you can find and repair the cause of this.

Cheers,

Wim


[1] https://github.com/eclipse/nebula/tree/master/examples/org.eclipse.nebula.snippets/src/org/eclipse/nebula/snippets/tablecombo/viewer
Previous Topic:Nebula Project Webpage Missing
Next Topic:FORUM DISCONTINUED
Goto Forum:
  


Current Time: Fri Apr 19 21:02:52 GMT 2024

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

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

Back to the top