Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Sync Horizontal Scrolling across two tables
Sync Horizontal Scrolling across two tables [message #1050796] Sat, 27 April 2013 19:32 Go to next message
Wojtek  is currently offline Wojtek Friend
Messages: 47
Registered: August 2011
Member
I have the following code:

((Scrollable) baseTable).getHorizontalBar().addSelectionListener( new
SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent event )
{
((Scrollable) totalsTable).getHorizontalBar().setSelection(
((Scrollable) baseTable).getHorizontalBar().getSelection() );
}
} );

This does a nice job in moving the scroll bars in sync, BUT it does not
actually move the contents of the totalsTable.

Is there an event I have to trigger to get the contents to also scroll?

--
Wojtek :-)
Re: Sync Horizontal Scrolling across two tables [message #1053306 is a reply to message #1050796] Fri, 03 May 2013 18:12 Go to previous messageGo to next message
Wojtek  is currently offline Wojtek Friend
Messages: 47
Registered: August 2011
Member
Wojtek wrote :
> I have the following code:
>
> ((Scrollable) baseTable).getHorizontalBar().addSelectionListener( new
> SelectionAdapter()
> {
> @Override
> public void widgetSelected( SelectionEvent event )
> {
> ((Scrollable) totalsTable).getHorizontalBar().setSelection(
> ((Scrollable) baseTable).getHorizontalBar().getSelection() );
> }
> } );
>
> This does a nice job in moving the scroll bars in sync, BUT it does not
> actually move the contents of the totalsTable.
>
> Is there an event I have to trigger to get the contents to also scroll?

I placed the totalsTable inside a composite, then did a:

((Scrollable) composite).getHorizontalBar().setSelection(((Scrollable)
baseTable).getHorizontalBar().getSelection() );

Thinking that I could scroll the composite which would take the table
with it, and thus sync the horizontal movement.

But, alas, no. So it seems that the
getHorizontalBar().setSelection(int) will move the scroll bar, but will
NOT move the contents.

I cannot believe this is a defined behavior. There MUST be a way to
scroll the contents when the bar selection is changed by the program.

Otherwise why does the the method setSelection(int) even exist?

--
Wojtek :-)
Re: Sync Horizontal Scrolling across two tables [message #1053388 is a reply to message #1050796] Sat, 04 May 2013 23:00 Go to previous messageGo to next message
Wojtek  is currently offline Wojtek Friend
Messages: 47
Registered: August 2011
Member
So there is no solution to this? setSelection(int) is a useless method
put only there as a counter to getSelection()?

Should I open a high priority bug for this non-behavior?

BTW a Google search will bring up lots of people who also tried to make
this work, and failed.

--
Wojtek :-)
Re: Sync Horizontal Scrolling across two tables [message #1053396 is a reply to message #1053388] Sun, 05 May 2013 04:00 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1445
Registered: July 2009
Senior Member
On 05/04/2013 06:00 PM, Wojtek wrote:
> So there is no solution to this? setSelection(int) is a useless method
> put only there as a counter to getSelection()?
>
> Should I open a high priority bug for this non-behavior?
>
> BTW a Google search will bring up lots of people who also tried to make
> this work, and failed.
>
Have you tried using the setOrigin method on the Scrollable instead of
setSelection? That method is documented to set point to be displayed in
the top left corner of the Scrollable. This appears to also set the the
scrollbar positions.

Here is an example that might help:

http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/CreatetwoScrolledCompositesthatscrollintandem.htm
Re: Sync Horizontal Scrolling across two tables [message #1053651 is a reply to message #1053396] Tue, 07 May 2013 07:18 Go to previous messageGo to next message
Wojtek  is currently offline Wojtek Friend
Messages: 47
Registered: August 2011
Member
David Wegener wrote :
> On 05/04/2013 06:00 PM, Wojtek wrote:
>> So there is no solution to this? setSelection(int) is a useless method
>> put only there as a counter to getSelection()?
>>
>> Should I open a high priority bug for this non-behavior?
>>
>> BTW a Google search will bring up lots of people who also tried to make
>> this work, and failed.
>>
> Have you tried using the setOrigin method on the Scrollable instead of
> setSelection? That method is documented to set point to be displayed in the
> top left corner of the Scrollable. This appears to also set the the
> scrollbar positions.
>
> Here is an example that might help:
>
> http://www.java2s.com/Code/Java/SWT-JFace-Eclipse/CreatetwoScrolledCompositesthatscrollintandem.htm

Interesting, but it did not work.

I think the problem with using a ScrolledComposite is that it is not
linked to the table columns. When I size a middle column so that the
right column is moved off the window, then a horizontal bar appears. If
I move the horizontal bar then the right column is moved into view and
the left column moves off the window. The table does not move, just its
contents (columns).

The table does not actually grow horizontally. So changing the origin
would create a blank area to the right (or left) of the table, because
I must move the entire table to mimic a bar movement.

Then there are funky issues with making the table show in the first
place as ScrolledComposite does not use FormLayout so the table has
nothing to attach to. It took me a while to figure out why my table was
invisible. It wasn't, it was just sized to 1x1 pixels. Which also means
that I must write code to resize the table whenever the shell is sized.

--
Wojtek :-)
Re: Sync Horizontal Scrolling across two tables [message #1053867 is a reply to message #1050796] Wed, 08 May 2013 01:51 Go to previous message
Wojtek  is currently offline Wojtek Friend
Messages: 47
Registered: August 2011
Member
Sigh...

bug 54785

Created in 2004!

--
Wojtek :-)
Previous Topic:Widget is disposed (newb edition)
Next Topic:MouseDown events on composite causing freezing?
Goto Forum:
  


Current Time: Wed Apr 24 23:53:08 GMT 2024

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

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

Back to the top