mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-27 14:27:15 +00:00
Merge branch 'design2015-races-navi' into tw2015
Conflicts: java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.properties java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages_de.properties java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages_ru.properties java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages_zh.properties
This commit is contained in:
commit
a7eeccc8bc
5 files changed
+61
-15
No files matched your search
+4
-2
@@ -46,6 +46,7 @@ import com.sap.sailing.gwt.ui.shared.race.RaceProgressDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.race.wind.AbstractWindDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.race.wind.WindStatisticsDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.util.NullSafeComparableComparator;
|
||||
import com.sap.sailing.gwt.ui.shared.util.NullSafeComparatorWrapper;
|
||||
import com.sap.sse.common.Duration;
|
||||
import com.sap.sse.common.Util;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
@@ -185,7 +186,7 @@ public class RaceListColumnFactory {
|
||||
}
|
||||
|
||||
public static <T extends RaceMetadataDTO<?>> SortableRaceListStartTimeColumn<T> getStartTimeColumn() {
|
||||
InvertibleComparator<T> comparator = new InvertibleComparatorWrapper<T, Date>(new NullSafeComparableComparator<Date>()) {
|
||||
InvertibleComparator<T> comparator = new InvertibleComparatorWrapper<T, Date>(new NullSafeComparableComparator<Date>(true)) {
|
||||
@Override
|
||||
protected Date getComparisonValue(T object) {
|
||||
return object.getStart();
|
||||
@@ -473,7 +474,8 @@ public class RaceListColumnFactory {
|
||||
}
|
||||
}
|
||||
};
|
||||
InvertibleComparator<T> comparator = new InvertibleComparatorWrapper<T, String>(new NaturalComparator(false)) {
|
||||
InvertibleComparator<T> comparator = new InvertibleComparatorWrapper<T, String>(
|
||||
new NullSafeComparatorWrapper<String>(new NaturalComparator(false), false)) {
|
||||
@Override
|
||||
protected String getComparisonValue(T object) {
|
||||
return object.getWinner() != null ? object.getWinner().getName() : null;
|
||||
|
||||
+6
-1
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.gwt.home.client.place.event.partials.racelist;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.RaceListRaceDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.SimpleCompetitorDTO;
|
||||
@@ -135,7 +136,11 @@ public class RaceListDataUtil {
|
||||
return hasDifferentValues(data, new ValueProvider<T, Long>() {
|
||||
@Override
|
||||
public Long getValue(T object) {
|
||||
return object.getStart().getTime() / DAY_IN_MILLIS;
|
||||
Date start = object.getStart();
|
||||
if(start == null) {
|
||||
return null;
|
||||
}
|
||||
return start.getTime() / DAY_IN_MILLIS;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package com.sap.sailing.gwt.ui.shared.util;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class ComparableComparator<T extends Comparable<T>> implements Comparator<T> {
|
||||
|
||||
@Override
|
||||
public int compare(T left, T right) {
|
||||
if (left == right) {
|
||||
return 0;
|
||||
}
|
||||
return left.compareTo(right);
|
||||
}
|
||||
|
||||
}
|
||||
+3
-12
@@ -4,28 +4,19 @@ import java.util.Comparator;
|
||||
|
||||
public class NullSafeComparableComparator<T extends Comparable<T>> implements Comparator<T> {
|
||||
|
||||
private final boolean sortNullToTop;
|
||||
private final Comparator<T> comparator;
|
||||
|
||||
public NullSafeComparableComparator() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
public NullSafeComparableComparator(boolean sortNullToTop) {
|
||||
this.sortNullToTop = sortNullToTop;
|
||||
comparator = new NullSafeComparatorWrapper<>(new ComparableComparator<T>(), sortNullToTop);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(T left, T right) {
|
||||
if (left == right) {
|
||||
return 0;
|
||||
}
|
||||
if (left == null) {
|
||||
return sortNullToTop ? -1 : 1;
|
||||
}
|
||||
if (right == null) {
|
||||
return sortNullToTop ? 1 : -1;
|
||||
}
|
||||
return left.compareTo(right);
|
||||
return comparator.compare(left, right);
|
||||
}
|
||||
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
package com.sap.sailing.gwt.ui.shared.util;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
public class NullSafeComparatorWrapper<T> implements Comparator<T> {
|
||||
|
||||
private final boolean sortNullToTop;
|
||||
private final Comparator<T> comparator;
|
||||
|
||||
public NullSafeComparatorWrapper(Comparator<T> comparator) {
|
||||
this(comparator, false);
|
||||
}
|
||||
|
||||
public NullSafeComparatorWrapper(Comparator<T> comparator, boolean sortNullToTop) {
|
||||
this.comparator = comparator;
|
||||
this.sortNullToTop = sortNullToTop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(T left, T right) {
|
||||
if (left == right) {
|
||||
return 0;
|
||||
}
|
||||
if (left == null) {
|
||||
return sortNullToTop ? -1 : 1;
|
||||
}
|
||||
if (right == null) {
|
||||
return sortNullToTop ? 1 : -1;
|
||||
}
|
||||
return comparator.compare(left, right);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user