Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 304128

Summary: [Viewers] Unnecessary horizontal scrollbar shown for TableViewer+TableColumnLayout
Product: [Eclipse Project] Platform Reporter: Ralf Ebert <ralf>
Component: UIAssignee: Platform UI Triaged <platform-ui-triaged>
Status: CLOSED WONTFIX QA Contact:
Severity: normal    
Priority: P3 CC: gouessej, remy.suen
Version: 3.5.2Keywords: helpwanted
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard: stalebug
Attachments:
Description Flags
Snippet demonstrating the problem none

Description Ralf Ebert CLA 2010-02-26 22:45:34 EST
Build Identifier: 

- given a TableViewer with TableColumnLayout and percentual widths,
- given the backing Table is already visible without scrollbars,
- when a new input object is set to the TableViewer which forces a vertical scrollbar (more items, table need to scroll now)
- this problem occurs: A horizontal scrollbar is displayed without reason
- It seems that the width of the vertical scrollbar is causing the problem. On the next layout() the horizontal scrollbar disappears again.
- Happens at least on cocoa/macosx and gtk/linux in 3.5.1 and 3.6M5

Reproducible: Always

Steps to Reproduce:
Execute attached snippet, you will see a horizontal + vertical scrollbar, should be only vertical.
Comment 1 Ralf Ebert CLA 2010-02-26 22:46:50 EST
Created attachment 160390 [details]
Snippet demonstrating the problem
Comment 2 Eric Moffatt CLA 2010-03-29 16:03:24 EDT
Ralf, thanks for the snippet, shows the problem nicely. If you just run it, notice that resizing the window so that is has *less* width makes the horizontal scroll bar disappear..
Comment 3 Szymon Brandys CLA 2010-03-30 04:50:59 EDT
Removing myself from the cc. I guess this is a problem with the triage script. The same that Remy mentioned in Bug 304530.
Comment 4 Ralf Ebert CLA 2010-06-17 08:12:55 EDT
Still happening for 3.6RC4

Calling layout() on the table's parent composite after setting the input object works around this problem, f.e.:

http://github.com/ralfebert/addressbook/blob/d94b0f14/plugins/com.example.addressbook/src/com/example/addressbook/internal/ui/AddressListViewPart.java#L60
Comment 5 Julien Gouesse CLA 2012-07-18 06:44:43 EDT
Hi

Just do that to work around your problem:
final TableViewer viewer = new TableViewer(shell, SWT.FULL_SELECTION | SWT.MULTI
                | SWT.V_SCROLL | SWT.NO_SCROLL);

I use Eclipse 3.7 under Cent OS Linux 5.3 and it works fine now. However, using SWT.NO_SCROLL should not be necessary, there is clearly a bug.
Comment 6 Julien Gouesse CLA 2012-07-18 06:48:34 EDT
Table.checkStyle(int style) adds scrollbars except if you use NO_SCROLL as you can see here:
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);
}
Comment 7 Lars Vogel CLA 2019-11-27 07:42:04 EST
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.

If you have further information on the current state of the bug, please add it.
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.

If the bug is still relevant, please remove the stalebug whiteboard tag.