[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: SWT.setData event handlers not called if the table has zero items ?



I solved my problem with this (hack?):

My content provider implements the ILazyContentProvider updateElement method, and it also implements filters of elements something that doesn't work by default in virtual tables. When updateElement is called from the VirtualManager the number of items to be shown in the table is calculated again, I need to do this because if the filter configuration changed then amount of items could change even if the model didn't report any update to the content provider. When the user changes the filter configuration I call viewer.refresh() but it doesn't help because being a virtual table it only clears the content.
In updateElement after calculating the item count with the filters applied, I check if it is 0, it means that the table will be empty and updateElement wont be called again so to avoid it I add an empty item
to the table viewer, solving the problem:




public void updateElement(int index)

public void updateElement(int index) {
	if (viewer != null && input != null) {
		int inputSize = inputSize();
		if (inputSize == 0) {
			viewer.setItemCount(1);
			return;
		}
		viewer.setItemCount(inputSize);
		if (index < inputSize) {
			viewer.replace(getElement(index), index);
		}
	}
}

I would like to know if it is a bug and also if someone else implemeted filters and sorting in virtual tables.


thank you, bye.