mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-27 06:17:27 +00:00
Races list - Race stats columns are now sortable, prefered DESC
This commit is contained in:
1 parent
acb37841be
commit
6163565b24
2 files changed
+30
-7
No files matched your search
+25
-6
@@ -21,6 +21,7 @@ import com.google.gwt.safehtml.shared.SafeUri;
|
||||
import com.google.gwt.safehtml.shared.UriUtils;
|
||||
import com.google.gwt.user.cellview.client.SafeHtmlHeader;
|
||||
import com.sap.sailing.domain.common.InvertibleComparator;
|
||||
import com.sap.sailing.domain.common.SortingOrder;
|
||||
import com.sap.sailing.domain.common.impl.NaturalComparator;
|
||||
import com.sap.sailing.gwt.common.client.SharedResources;
|
||||
import com.sap.sailing.gwt.common.client.SharedResources.MainCss;
|
||||
@@ -380,7 +381,13 @@ public class RaceListColumnFactory {
|
||||
}
|
||||
|
||||
public static <T extends RaceListRaceDTO> SortableRaceListColumn<T, Number> getWindFixesCountColumn() {
|
||||
return new DataCountColumn<T>(DataCountColumn.ICON_WIND) {
|
||||
InvertibleComparator<T> comparator = new InvertibleComparatorWrapper<T, Integer>(new NullSafeComparableComparator<Integer>(false)) {
|
||||
@Override
|
||||
protected Integer getComparisonValue(T object) {
|
||||
return object.getWindSourcesCount();
|
||||
}
|
||||
};
|
||||
return new DataCountColumn<T>(DataCountColumn.ICON_WIND, comparator) {
|
||||
@Override
|
||||
public Number getValue(T object) {
|
||||
return object.getWindSourcesCount();
|
||||
@@ -389,7 +396,13 @@ public class RaceListColumnFactory {
|
||||
}
|
||||
|
||||
public static <T extends RaceListRaceDTO> SortableRaceListColumn<T, Number> getVideoCountColumn() {
|
||||
return new DataCountColumn<T>(DataCountColumn.ICON_VIDEO) {
|
||||
InvertibleComparator<T> comparator = new InvertibleComparatorWrapper<T, Integer>(new NullSafeComparableComparator<Integer>(false)) {
|
||||
@Override
|
||||
protected Integer getComparisonValue(T object) {
|
||||
return object.getVideoCount();
|
||||
}
|
||||
};
|
||||
return new DataCountColumn<T>(DataCountColumn.ICON_VIDEO, comparator) {
|
||||
@Override
|
||||
public Number getValue(T object) {
|
||||
return object.getVideoCount();
|
||||
@@ -398,7 +411,13 @@ public class RaceListColumnFactory {
|
||||
}
|
||||
|
||||
public static <T extends RaceListRaceDTO> SortableRaceListColumn<T, Number> getAudioCountColumn() {
|
||||
return new DataCountColumn<T>(DataCountColumn.ICON_AUDIO) {
|
||||
InvertibleComparator<T> comparator = new InvertibleComparatorWrapper<T, Integer>(new NullSafeComparableComparator<Integer>(false)) {
|
||||
@Override
|
||||
protected Integer getComparisonValue(T object) {
|
||||
return object.getAudioCount();
|
||||
}
|
||||
};
|
||||
return new DataCountColumn<T>(DataCountColumn.ICON_AUDIO, comparator) {
|
||||
@Override
|
||||
public Number getValue(T object) {
|
||||
return object.getAudioCount();
|
||||
@@ -531,7 +550,7 @@ public class RaceListColumnFactory {
|
||||
private static final SafeUri ICON_VIDEO = UriUtils.fromTrustedString("images/home/icon-video.png");
|
||||
private static final SafeUri ICON_AUDIO = UriUtils.fromTrustedString("images/home/icon-audio.png");
|
||||
|
||||
private DataCountColumn(final SafeUri imageUri) {
|
||||
private DataCountColumn(final SafeUri imageUri, InvertibleComparator<T> comparator) {
|
||||
super(new SafeHtmlHeader(TEMPLATE.imageHeader(CSS.raceslist_head_itemflag(), imageUri)), new AbstractCell<Number>() {
|
||||
@Override
|
||||
public void render(Context context, Number value, SafeHtmlBuilder sb) {
|
||||
@@ -541,9 +560,9 @@ public class RaceListColumnFactory {
|
||||
sb.appendHtmlConstant("—");
|
||||
}
|
||||
}
|
||||
}, null);
|
||||
}, comparator, SortingOrder.DESCENDING);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getHeaderStyle() {
|
||||
return getStyleNamesString(CSS.raceslist_head_item(), CSS.raceslist_head_itemcenter(), MEDIA_CSS.showonlarge());
|
||||
|
||||
+5
-1
@@ -20,7 +20,11 @@ public abstract class SortableRaceListColumn<T, C> extends SortableColumn<T, C>
|
||||
}
|
||||
|
||||
protected SortableRaceListColumn(Header<?> header, Cell<C> cell, InvertibleComparator<T> comparator) {
|
||||
super(cell, SortingOrder.ASCENDING);
|
||||
this(header, cell, comparator, SortingOrder.ASCENDING);
|
||||
}
|
||||
|
||||
protected SortableRaceListColumn(Header<?> header, Cell<C> cell, InvertibleComparator<T> comparator, SortingOrder preferredSortingOrder) {
|
||||
super(cell, preferredSortingOrder);
|
||||
this.header = header;
|
||||
this.comparator = comparator;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user