Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » TableViewer scrollbar problem(Scroll error)
TableViewer scrollbar problem [message #492670] Wed, 21 October 2009 10:12 Go to next message
Michal  is currently offline Michal Friend
Messages: 4
Registered: October 2009
Junior Member
Hello,

For some time we are struggling with a minor problem in our application. The problem is that when we have large table based on TableViewer (more then 10k rows more less) the scroll bar seems not to work 100% properly. It's not a big deal but we have a signal that it's annoying for our user so that's why we are searching for solution.

The problem is that when we scroll down the large table using the mouse pointer and scroll bar, and we want to see the last table entry- usually we are not able to do it. The scroll bar reaches it's bottom but the table doesn't show the last 4 or more entries. Important thing is that it happens only on the FIRST scroll. After we scroll a bit, release the mouse button and then scroll again to the bottom - last row will be shown. I've done some investigation, tests and also reproduced this bug on some simple table, not connected with our application to make sure that we are not causing the problem.

Results of the investigation:

Bug is dependant on 3 conditions and I haven't been able to reproduce it
without them:
1. TableViewer must have the SWT.VIRTUAL flag set.
2. There needs to be image added to some column, which is a bit bigger then
text.
3. Table must have some header defined.

If the conditions mentioned above are fulfilled, you can reproduce this bug
when scrolling to the very bottom of the table. But you have to remember that:
* It only happens on the first scroll on the table.
* It only happens when scrolling with the mouse button.
* When you release the mouse button and then try to scroll again, the bug won't
appear since it's counted as second scroll.
* When you resize or do anything that causes redrawing of the table before you
scroll the bug won't happen...


You may thing it's not a serious problem - and indeed it's not a blocker but since it's annoying for the users we are trying to fix it somehow.
Anybody else experienced this behaviour?
Any ideas how to fix it?

Use attached plugin if you want to see it yourself. Just throw it into the workspace and run any application which will allow you to see the additional, plugin-provided view with the table.

[[[[ I tried to add the attachment but failed for some reason... if someones intrested, I'll send it by mail]]]


Thanks for all your help,
Michal

[Updated on: Wed, 21 October 2009 10:40]

Report message to a moderator

Re: TableViewer scrollbar problem [message #492720 is a reply to message #492670] Wed, 21 October 2009 14:01 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Michal,

This sounds like it could be an swt problem, but since your attachment did
not work it's difficult to investigate. Which eclipse version and platform
do you see this on? And, are you able to change the swt-level snippet below
to show the problem? I wrote it based on the three conditions you
specified, but it reaches the 10000th item for me. If you can't change the
snippet to show the problem then you can just send me your plugin to try.

public static void main(String[] args) {
final Display display = new Display();
final Image image = new Image(display, 40, 40);
GC gc = new GC(image);
gc.setBackground(display.getSystemColor(SWT.COLOR_RED));
gc.fillOval(0, 0, 40, 40);
gc.dispose();
final Shell shell = new Shell(display);
shell.setBounds(10,10,200,200);
shell.setLayout(new FillLayout());
final Table table = new Table(shell, SWT.VIRTUAL);
table.setHeaderVisible(true);
TableColumn column = new TableColumn(table, SWT.NONE);
column.setWidth(100);
column.setImage(image);
column.setText("text");
table.addListener(SWT.SetData, new Listener() {
public void handleEvent(Event event) {
TableItem item = (TableItem)event.item;
int index = table.indexOf(item);
item.setText("item " + index);
item.setImage(image); // <-- not needed to show problem?
}
});
shell.open();
table.setItemCount(10000);
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
image.dispose();
display.dispose();
}

Grant


"Michal" <michal.morzywolek@gmail.com> wrote in message
news:hbmmpl$r10$1@build.eclipse.org...
> Hello,
>
> For some time we are struggling with a minor problem in our application.
The problem is that when we have large table based on TableViewer (more then
10k rows more less) the scroll bar seems not to work 100% properly. It's not
a big deal but we have a signal that it's annoying for our user so that's
why we are searching for solution.
>
> The problem is that when we scroll down the large table using the mouse
pointer and scroll bar, and we want to see the last table entry- usually we
are not able to do it. The scroll bar reaches it's bottom but the table
doesn't show the last 4 or more entries. Important thing is that it happens
only on the FIRST scroll. After we scroll a bit, release the mouse button
and then scroll again to the bottom - last row will be shown. I've done some
investigation, tests and also reproduced this bug on some simple table, not
connected with our application to make sure that we are not causing the
problem.
>
> Results of the investigation:
>
> Bug is dependant on 3 conditions and I haven't been able to reproduce it
> without them:
> 1. TableViewer must have the SWT.VIRTUAL flag set.
> 2. There needs to be image added to some column, which is a bit bigger
then
> text.
> 3. Table must have some header defined.
>
> If the conditions mentioned above are fulfilled, you can reproduce this
bug
> when scrolling to the very bottom of the table. But you have to remember
that:
> * It only happens on the first scroll on the table.
> * It only happens when scrolling with the mouse button.
> * When you release the mouse button and then try to scroll again, the bug
won't
> appear since it's counted as second scroll.
> * When you resize or do anything that causes redrawing of the table before
you
> scroll the bug won't happen...
>
>
> You may thing it's not a serious problem - and indeed it's not a blocker
but since it's annoying for the users we are trying to fix it somehow.
> Anybody else experienced this behaviour?
> Any ideas how to fix it?
>
> Use attached plugin if you want to see it yourself. Just throw it into the
workspace and run any application which will allow you to see the
additional, plugin-provided view with the table.
>
> Thanks for all your help,
> Michal
Re: TableViewer scrollbar problem [message #492917 is a reply to message #492720] Thu, 22 October 2009 11:27 Go to previous messageGo to next message
Michal  is currently offline Michal Friend
Messages: 4
Registered: October 2009
Junior Member
Hello Grant,

Thanks for being intrested in this issue. To reproduce this bug i used the TableViewer mixed up with jface (Content / Label Providers). I would love to send you this small plugin but still can't add attachments and use private messages. Since your mail is not visible I have no way to deliver the code to you. I may only send post the view code here:

package view;

import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.ui.part.ViewPart;

import bugreproduceplugin.Activator;

public class MyView extends ViewPart implements ITableLabelProvider, IStructuredContentProvider {
    public static final String ID = "BugReproducePlugin.view";

    protected TableViewer viewer;

    public MyView() {
    }

    @Override
    public void createPartControl(Composite parent) {
        viewer = new TableViewer(parent, SWT.VIRTUAL | SWT.FULL_SELECTION | SWT.MULTI |
            SWT.H_SCROLL | SWT.V_SCROLL);

        //viewer.getTable().setLinesVisible(true);        
        final TableColumn col = new TableColumn(viewer.getTable(), SWT.LEFT);
        col.setText("HEADER");
        col.setWidth(300);
        viewer.getTable().setHeaderVisible(true);
        
        viewer.setContentProvider(this);
        viewer.setLabelProvider(this);
        viewer.setInput(new String()); //doesn't matter what we pass - some random object, we don't use it anyway
    }

    @Override
    public void setFocus() {
        viewer.getControl().setFocus();

    }

    @Override
    public Image getColumnImage(Object element, int columnIndex) {
        return Activator.getImageDescriptor("icons/fatal.gif").createImage();
    }

    @Override
    public String getColumnText(Object element, int columnIndex) {
        return (String) element;
    }

    @Override
    public Object[] getElements(Object inputElement) {
        String[] s = new String[15000];
        for (int i = 0; i < 15000; i++) {
            s[i] = "ELEMENT: " + i;
        }
        return s;
    }

    
    //Not important overriden methods, ignore
    
    @Override
    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        // TODO Auto-generated method stub

    }

    @Override
    public void addListener(ILabelProviderListener listener) {
        // TODO Auto-generated method stub

    }

    @Override
    public boolean isLabelProperty(Object element, String property) {
        return false;
    }

    @Override
    public void removeListener(ILabelProviderListener listener) {
        // TODO Auto-generated method stub

    }
}


You can just create a new view in some random application with the code provided above. The chance that the bug will occure is higher when the view placeholder (the view itself) is quite small (like 1/5 of the screen).


Thanks!

Best Regards,
Michal
Re: TableViewer scrollbar problem [message #492920 is a reply to message #492917] Thu, 22 October 2009 11:31 Go to previous messageGo to next message
Michal  is currently offline Michal Friend
Messages: 4
Registered: October 2009
Junior Member
http://rapidshare.com/files/296349136/BugReproducePlugin.rar

Here is the plugin with the view.
Re: TableViewer scrollbar problem [message #492958 is a reply to message #492920] Thu, 22 October 2009 13:53 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
The site would not let me download the plugin because the number of free
user downloads had been exceeded. I was able to use the code from your
other post to create a view though, the only thing missing was the image, so
I changed the view to create an image in memory similar to my previous
snippet. I did not see the problem happen using Windows 2000 with the
latest swt. Which platform and eclipse version are you using? And what are
the dimensions of the image being returned by #getColumnImage()?

Grant


"Michal" <michal.morzywolek@gmail.com> wrote in message
news:hbpfr6$ns6$1@build.eclipse.org...
> http://rapidshare.com/files/296349136/BugReproducePlugin.rar
>
> Here is the plugin with the view.
Re: TableViewer scrollbar problem [message #495532 is a reply to message #492958] Thu, 05 November 2009 09:35 Go to previous message
Michal  is currently offline Michal Friend
Messages: 4
Registered: October 2009
Junior Member
Hello Grant,

I would like to thank you for your try outs and also apologise for my long absence on the forum. I had many different problems and couldn't pay enough attention to this scrollbar thing.

here is the link to the website without any download limits:
http://www.datafilehost.com/download-96677d9e.html

I hope you will have no problems downloading it this time...

I'm using Windows XP and Eclipse 3.5 release.
SWT plugin version:
3.5.0.v3550b

JFace plugin version:
3.5.0.I20090525-2000

The image (which you can find in the plugin) parameters:
Size: 16x16 (pixels)
Resolution 96x96 (dpi)

I'm not the only one seeing the problem - other devs in the project can also reproduce it: both on our real product and this sample view provided in the link (above). You can also see the problem on the printscreen (in the printscreen folder of the plugin) - it has been taken after the scroll. As you can see some rows are not shown ;(

Thank you again for all the help and suggestions!

Best Regards,
Michal
Previous Topic:Views update from application
Next Topic:Project Explorer and Markers
Goto Forum:
  


Current Time: Thu Apr 18 20:48:29 GMT 2024

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

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

Back to the top