TableViewer scrollbar problem [message #492670] |
Wed, 21 October 2009 10:12 |
Michal 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 |
Grant Gayed 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 |
Michal 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
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03820 seconds