"Your time is limited, so don't waste it living someone else's life"

Bug when using DefferedContentProvider in TableViewer eclipse

When create an eclipse RCP application, times you use TableViewer need a content provider. There are many type of provider you can use for your table such as:
an implementation of ILazyContentProvider
My favorite type is the last one, DefferedContentProvider.:D. But, at the first time I used it, it did work. And, i got stuck in this runtime bug:

org.eclipse.core.runtime.AssertionFailedException: assertion failed: 
	at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110)
	at org.eclipse.core.runtime.Assert.isTrue(Assert.java:96)
	at org.eclipse.jface.viewers.deferred.DeferredContentProvider.inputChanged(DeferredContentProvider.java:140)
	at org.eclipse.jface.viewers.ContentViewer.setInput(ContentViewer.java:276)
	at org.eclipse.jface.viewers.StructuredViewer.setInput(StructuredViewer.java:1690)
	at com.gcs.rcp.app.ViewTableViewer.createViewer(ViewTableViewer.java:310)
	at com.gcs.rcp.app.ViewTableViewer.createPartControl(ViewTableViewer.java:239)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.createPartControl(CompatibilityPart.java:142)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityView.createPartControl(CompatibilityView.java:174)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:323)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)

the error occurs while using DefferedContentProvider for TableViewer.
(this class allow us to implement a class to provide data to a TableViewer with sorting, filtering executed by a new thread under the main UI thread, this executes the functions on the content provider)
Why do I use this class instead of ArrayProvider or an implementation of ILazyContentProvider?
Because: this DefferedContentProvider is an implementation of ILazyContentProvider itself. Otherwise, it supports the method to limit the maximum number of item in the TableView via setLimit(int) method.
The bug is not fixed, finding shows using plugin Coffee Bytes.
I done it (setup the plugin and configure), but nothing better.
At the time i wrote this report, I found the solution.
I will update it the next day.
The root cause is I set the input of the table with a list of element.
The alternative input is SetModel. You create a new SetModel and pour the list of element in it.

this.comparator = new MyComparator();
this.contentProvider = new DeferredContentProvider(this.comparator);
this.setModel = new SetModel();
this.lstPerson = ModelProvider.INSTANCE.getPersonList();

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: