Thursday, January 2, 2014

TableViewer.refresh(true, false) behaves as TableViewer.refresh(true, true)

The problem I met is that refresh(true, false) method of org.eclipse.jface.viewers.TableViewer class behaves as refresh(true, true) on Linux platforms.

I found an opened bug for this case: https://bugs.eclipse.org/bugs/show_bug.cgi?id=414455 but the current SWT 4.3 stable version doesn't contain the fix.

To overcome this problem temporary (until SWT 4.4 is released) I used "SWT.MULTI" style bit during TableViewer creation.

I played with different styles, but it is the only way to avoid the problem. "SWT.NONE" didn't help as well because of the logic inside org.eclipse.swt.widgets.Tablet constructor which overwrites "style" parameter:


public Table (Composite parent, int style) {
super (parent, checkStyle (style));
}

static int checkStyle (int style) {
/*
* Feature in Windows.  Even when WS_HSCROLL or
* WS_VSCROLL is not specified, Windows creates
* trees and tables with scroll bars.  The fix
* is to set H_SCROLL and V_SCROLL.

* NOTE: This code appears on all platforms so that
* applications have consistent scroll bar behavior.
*/
if ((style & SWT.NO_SCROLL) == 0) {
style |= SWT.H_SCROLL | SWT.V_SCROLL;
}
/* GTK is always FULL_SELECTION */
style |= SWT.FULL_SELECTION;
return checkBits (style, SWT.SINGLE, SWT.MULTI, 0, 0, 0, 0);
}

To summarize the above notes, this code worked for me:

int style = SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION;
TableViewer viewer = new LogTableViewer(parent, style);

No comments:

Post a Comment