Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » JFace » Synchronizing Multiple TableViewers
Synchronizing Multiple TableViewers [message #633713] Tue, 19 October 2010 04:35 Go to next message
Jon Svede is currently offline Jon SvedeFriend
Messages: 83
Registered: July 2009
Member
I have 4 TableViewers on one Composite in an Editor and I need to synchronize all four to scroll when one is scrolled. I was able to make it so
that when I scroll 1 table, the scroll bar of a second will move. However, the table itself does not move. Here is the code:

        final Table right = rightTableViewer.getTable() ;
        final Table left = leftTableViewer.getTable() ;
        
        ((Scrollable) left).getHorizontalBar().addSelectionListener(new
            SelectionAdapter() {
              public void widgetSelected(SelectionEvent event) {
                ((Scrollable) right).getHorizontalBar().setSelection(
                  ((Scrollable) left).getHorizontalBar().getSelection());
                netFuelConsumptionTableViewer.refresh() ;
              }
            }
          );

        ((Scrollable) right).getHorizontalBar().addSelectionListener(new
            SelectionAdapter() {
              public void widgetSelected(SelectionEvent event) {
                ((Scrollable) left).getHorizontalBar().setSelection(
                  ((Scrollable) right).getHorizontalBar().getSelection());
               netStockTableViewer.refresh() ;
              }
            }
          );


This is only using two of the four tables. Is this incorrect? Is there some other way to make these scroll in unison and have the actual table scroll and not just the scroll bar?

Any pointers will be greatly appreciated!

Jon
Re: Synchronizing Multiple TableViewers [message #633844 is a reply to message #633713] Tue, 19 October 2010 14:48 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Tables don't react to programmatic changes to their scrollbars. You need to
use Table API like: right.setTopIndex(left.getTopIndex()).

If you want finer-grained scrolling control than this then you can wrap them
in ScrolledComposites, but this is more work (Tree snippet that shows this:
http://dev.eclipse.org/viewcvs/index.cgi/%7Echeckout%7E/org. eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet296 .java )
..

Grant


"Jon Svede" <jsvede@yahoo.com> wrote in message
news:i9j761$hqh$1@news.eclipse.org...
>I have 4 TableViewers on one Composite in an Editor and I need to
>synchronize all four to scroll when one is scrolled. I was able to make it
>so that when I scroll 1 table, the scroll bar of a second will move.
>However, the table itself does not move. Here is the code:
>
>
> final Table right = rightTableViewer.getTable() ;
> final Table left = leftTableViewer.getTable() ;
> ((Scrollable) left).getHorizontalBar().addSelectionListener(new
> SelectionAdapter() {
> public void widgetSelected(SelectionEvent event) {
> ((Scrollable) right).getHorizontalBar().setSelection(
> ((Scrollable) left).getHorizontalBar().getSelection());
> netFuelConsumptionTableViewer.refresh() ;
> }
> }
> );
>
> ((Scrollable) right).getHorizontalBar().addSelectionListener(new
> SelectionAdapter() {
> public void widgetSelected(SelectionEvent event) {
> ((Scrollable) left).getHorizontalBar().setSelection(
> ((Scrollable) right).getHorizontalBar().getSelection());
> netStockTableViewer.refresh() ;
> }
> }
> );
>
>
> This is only using two of the four tables. Is this incorrect? Is there
> some other way to make these scroll in unison and have the actual table
> scroll and not just the scroll bar?
> Any pointers will be greatly appreciated!
>
> Jon
>
Previous Topic:Drag and drop to outside of Eclipse
Next Topic:TitleAreaDialog in a XWT file
Goto Forum:
  


Current Time: Fri Apr 26 21:18:32 GMT 2024

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

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

Back to the top