Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » strange index update with virtual table
strange index update with virtual table [message #633866] Tue, 19 October 2010 16:13 Go to next message
Luca Ferrari is currently offline Luca FerrariFriend
Messages: 159
Registered: November 2009
Senior Member
Hi all,
I've got an application that uses a virtual table and it was working. Now, after a while, I noted that the virtual table is forcing an update of the 63 row (always the same) without requiring the update of the previous one.
I mean, the following is my update method:

public synchronized void updateElement(int index) {
	
	System.out.println("Updating index "  + index);
	// get the object from the cache
	T nextElement = ((ILazyLoadingDAO<T>) this.getDao()).get( index );
	
	
	// update the UI
	this.tableViewer.replace(nextElement, index);
    }


The above prints only Updating index 63 even if only 10 rows are visible on the screen. Moreover, I don't understand why it is forcing the 63 row instead of rows from 1 to ...n.
Any idea on how to investigate this problem?
Re: strange index update with virtual table [message #633994 is a reply to message #633866] Wed, 20 October 2010 08:33 Go to previous messageGo to next message
Luca Ferrari is currently offline Luca FerrariFriend
Messages: 159
Registered: November 2009
Senior Member
The following is a snippet that demonstrates the problem:

public class View extends ViewPart {
	public static final String ID = "RCPEXAMPLE.view";

	private TableViewer viewer;

	class ViewLabelProvider extends LabelProvider implements
			ITableLabelProvider {
		public String getColumnText(Object obj, int index) {
			return getText(obj);
		}

		public Image getColumnImage(Object obj, int index) {
			return getImage(obj);
		}

		public Image getImage(Object obj) {
			return PlatformUI.getWorkbench().getSharedImages().getImage(
					ISharedImages.IMG_OBJ_ELEMENT);
		}
	}

	public void createPartControl(Composite parent) {



	    
		viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.VIRTUAL
				| SWT.V_SCROLL);
		ViewContentProvider provider = new ViewContentProvider( viewer );
		viewer.setContentProvider( provider );
		viewer.setLabelProvider(new ViewLabelProvider());
		viewer.setInput( null );
		viewer.setItemCount( 100 );



	}


	public void setFocus() {
	    viewer.getControl().setFocus();
	    
	}


class ViewContentProvider implements IStructuredContentProvider, ILazyContentProvider {
    private List<String> content = null;
    private Viewer myView = null;
    
	public void inputChanged(Viewer v, Object oldInput, Object newInput) {
	    System.out.println("Input changed!");
	    if( newInput instanceof List )
		content = (List<String>) newInput;
	    else
		System.out.println("Input changed with " + newInput);
	    
	    this.myView.refresh();
	}

	public void dispose() {
	}

	public Object[] getElements(Object parent) {
		return content.toArray();
	}
	
	public ViewContentProvider( Viewer view){
	    super();
	    this.myView = view;
	}

	@Override
	public void updateElement(int index) {
	    System.out.println("Updating element " + index );
	    TableViewer tableviewer = (TableViewer) myView;
	    tableviewer.replace( new String ("Element " + index), index);
	    
	    
	}
	
}

}



Running the above snippet force a message Updating element 31 as the view becomes visible, after that a list of messages Updating element from 0 to the last row visible is displayed. It seems that the virtual table is forcing the update of a random (?) element that is yet not visible. This can be annoying if the elements are loaded from a database, since it requires more time that that required to display rows on the screen.
Any idea?
Re: strange index update with virtual table [message #634586 is a reply to message #633994] Fri, 22 October 2010 10:55 Go to previous messageGo to next message
Luca Ferrari is currently offline Luca FerrariFriend
Messages: 159
Registered: November 2009
Senior Member
I debugged the application but really don't see why this is happening. Anybody has an idea?
Re: strange index update with virtual table [message #635109 is a reply to message #634586] Mon, 25 October 2010 16:03 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
This looks like a bug, I've logged
https://bugs.eclipse.org/bugs/show_bug.cgi?id=328628 .

Grant


"Luca Ferrari" <fluca1978@infinito.it> wrote in message
news:i9rqd9$ed$1@news.eclipse.org...
>I debugged the application but really don't see why this is happening.
>Anybody has an idea?
Re: strange index update with virtual table [message #635359 is a reply to message #635109] Tue, 26 October 2010 14:53 Go to previous message
Luca Ferrari is currently offline Luca FerrariFriend
Messages: 159
Registered: November 2009
Senior Member
Yes, seems a bug! Thanks.
Previous Topic:How to hook widgets in editor to global cut/copy/paste?
Next Topic:Table & Tableviewer column pack
Goto Forum:
  


Current Time: Sat Nov 16 01:34:27 GMT 2019

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

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

Back to the top