|
|
|
Re: Problem sorting on XViewer [message #1767393 is a reply to message #1766975] |
Wed, 05 July 2017 15:16 |
Jim 20100 Messages: 69 Registered: June 2016 |
Member |
|
|
In fact I know the reason of the problem. It comes from org.eclipse.nebula.widgets.xviewer.XViewerSorter class.
Example:
I have my unitWeight column to sort. I use of course SortDataType.Float for the column.
in my EMF provider classes, I implemented the 2 methods
public Object getBackingData(Object object, XViewerColumn xCol,
int columnIndex) throws Exception
public String getColumnText(Object object, XViewerColumn xCol,
int columnIndex) throws Exception {
in the columnText method, I format the unit weight with this:
return new DecimalFormat("#,##0.000");
If I remove the DecimalFormat("#,##0.000"), it works.
The getBackingData is not used for sorting.
I debugged and I see this amazing code in XViewer sorter class:
String o1Str = treeViewer.getColumnText(o1, columnNum);
Object obj1 = null;
String o2Str = treeViewer.getColumnText(o2, columnNum);
Object obj2 = null;
IBaseLabelProvider labelProvider = treeViewer.getLabelProvider();
if (labelProvider instanceof IXViewerLabelProvider) {
obj1 = ((IXViewerLabelProvider) labelProvider).getBackingData(o1, sortXCol, columnNum);
obj2 = ((IXViewerLabelProvider) labelProvider).getBackingData(o2, sortXCol, columnNum);
}
// System.out.println("sortForward.get(columnNum) *" +
// sortXCol.isSortForward() + "*");
int compareInt = 0;
if (o1Str == null) {
compareInt = -1;
} else if (o2Str == null) {
compareInt = 1;
} else if (sortXCol.getSortDataType() == SortDataType.Date) {
compareInt = getCompareForDate(o1Str, obj1, o2Str, obj2);
} else if (sortXCol.getSortDataType() == SortDataType.Percent) {
compareInt = getCompareForPercent(o1Str, o2Str);
} else if (sortXCol.getSortDataType() == SortDataType.Float) {
compareInt = getCompareForFloat(o1Str, o2Str);
} else if (sortXCol.getSortDataType() == SortDataType.Integer) {
compareInt = getCompareForInteger(o1Str, o2Str);
} else if (sortXCol.getSortDataType() == SortDataType.Long) {
compareInt = getCompareForLong(o1Str, o2Str);
} else if (sortXCol.getSortDataType() == SortDataType.Paragraph_Number) {
compareInt = paragraphNumberCompare(o1Str, o2Str);
} else {
compareInt = getComparator().compare(o1Str, o2Str);
}
Why the getBackingData is not used????
|
|
|
Powered by
FUDForum. Page generated in 0.04215 seconds