| Summary: | Table: Background color not drawn with empty EraseItem-Listener | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Martin Platter <martin.platter> | ||||
| Component: | SWT | Assignee: | Platform-SWT-Inbox <platform-swt-inbox> | ||||
| Status: | CLOSED WONTFIX | QA Contact: | Felipe Heidrich <eclipse.felipe> | ||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | eclipse.felipe, tom.schindl | ||||
| Version: | 4.0 | Keywords: | triaged | ||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | stalebug | ||||||
| Attachments: |
|
||||||
Created attachment 152375 [details]
Screenshot show how background color of the first line in the table is not painted correctly
I suspect this is a JFace problem. Note: if you hook paintitem/measureitem/eraseitem the table becomes custom draw, it doesn't matter if the listener is empty or not. Not sure what what JFace should do here. We are simply calling TableItem#setBackground(). Maybe it would help if we could get a SWT only snippet which shows the problem. (In reply to comment #3) > Not sure what what JFace should do here. We are simply calling > TableItem#setBackground(). I noticed the label provider has getBackground(), I don't know what that does to the table. > Maybe it would help if we could get a SWT only > snippet which shows the problem. Agree. (In reply to comment #4) > (In reply to comment #3) > > Not sure what what JFace should do here. We are simply calling > > TableItem#setBackground(). > > I noticed the label provider has getBackground(), I don't know what that does > to the table. > Well we have 2 methods here: ---------------------------- LabelProvider#getBackground(Object) ITableColorProvider#getBackground(Object,int) If TableViewer finds a IITableColorProvider it calls ITableColorProvider#getBackground(Object,int) foreach TableItem-Index and calls TableItem#setBackground(Color,int) else it calls LabelProvider#getBackground(Object) and calls TableItem#setBackground(Color,int) for all indices. (In reply to comment #5) > (In reply to comment #4) > > (In reply to comment #3) > > > Not sure what what JFace should do here. We are simply calling > > > TableItem#setBackground(). > > > > I noticed the label provider has getBackground(), I don't know what that does > > to the table. > > > > Well we have 2 methods here: > ---------------------------- > LabelProvider#getBackground(Object) > ITableColorProvider#getBackground(Object,int) > > If TableViewer finds a IITableColorProvider it calls > ITableColorProvider#getBackground(Object,int) foreach TableItem-Index and calls > TableItem#setBackground(Color,int) else it calls > LabelProvider#getBackground(Object) and calls > TableItem#setBackground(Color,int) for all indices. Just to mention the code above leaks resources :-) this is SWT:
public static void main (String[] args) {
final Display display = new Display();
Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
Table table = new Table(shell, SWT.MULTI | SWT.FULL_SELECTION);
TableColumn column = new TableColumn(table, SWT.LEFT, 0);
column.setWidth(800);
for (int i = 0; i < 4; i++) {
TableItem item = new TableItem(table, SWT.NONE);
item.setBackground(display.getSystemColor(SWT.COLOR_YELLOW));
item.setText("Item " + i);
}
table.addListener(SWT.EraseItem, new Listener() {
public void handleEvent(Event event) {
}
});
shell.setBounds(10,10,300,200);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
display.dispose();
}
----
custom draw table when drawing the focus item only fills the cell background to the extent of the content (instead of the column).
(In reply to comment #7) > custom draw table when drawing the focus item only fills the cell background to > the extent of the content (instead of the column). the same problem also happens when the table is not custom draw and not full selection, see bug 295869. This is a one-off bulk update. (The last one in the triage migration). Moving bugs from swt-triaged@eclipse to platform-swt-inbox@eclipse.org and adding "triaged" keyword as per new triage process: https://wiki.eclipse.org/SWT/Devel/Triage See Bug 518478 for details. Tag for notification/mail filters: @TriageBulkUpdate This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug. If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. -- The automated Eclipse Genie. |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5 Build Identifier: 3.5.1.v3555a The correct background color of the TableItem is not drawn if (empty)EraseItem-Listener is added to a table. Reproducible: Always Steps to Reproduce: public static void main(String[] args) { final Display display = new Display(); Shell shell = new Shell(display); shell.setBounds(10,10,200,200); shell.setLayout(new FillLayout()); TableViewer tv = new TableViewer(shell, SWT.MULTI | SWT.FULL_SELECTION); Table table = tv.getTable(); table.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND)); table.setHeaderVisible(false); table.setLinesVisible(true); tv.setContentProvider(new ArrayContentProvider()); class lbp extends LabelProvider implements ITableColorProvider { public Color getBackground(Object element, int columnIndex) { return new Color(display, 255, 255,255); } public Color getForeground(Object element, int columnIndex) { return null; } } tv.setLabelProvider(new lbp()); table.addListener(SWT.EraseItem, new Listener() { private int count = 1; public void handleEvent(Event event) { } }); TableColumn text = new TableColumn(table, SWT.LEFT, 0); text.setWidth(800); // table.setSelection(0); // table.deselect(0); tv.setInput(new String[]{"Hoi!", "Pfiati!"}); shell.layout(true, true); shell.update(); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); }