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";
        }
}

To participate in the discussion, go here: 
https://www.eclipse.org/forums/index.php?t=rview&frm_id=64
_______________________________________________
nebula-dev mailing list
[email protected]
To change your delivery options, retrieve your password, or unsubscribe from 
this list, visit
https://dev.eclipse.org/mailman/listinfo/nebula-dev

Reply via email to