mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-28 14:57:12 +00:00
Implemented sorting of regatta list by regatta state as primary criteria
to have live regattas on top of the list
This commit is contained in:
1 parent
70b954ee13
commit
d74aa3a82f
1 file changed
+31
+31
@@ -1,6 +1,7 @@
|
||||
package com.sap.sailing.gwt.ui.shared.dispatch.regatta;
|
||||
|
||||
import com.sap.sailing.gwt.ui.shared.eventview.RegattaMetadataDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.eventview.RegattaReferenceDTO;
|
||||
|
||||
public class RegattaWithProgressDTO extends RegattaMetadataDTO {
|
||||
private RegattaProgressDTO progress;
|
||||
@@ -20,4 +21,34 @@ public class RegattaWithProgressDTO extends RegattaMetadataDTO {
|
||||
public void setProgress(RegattaProgressDTO progress) {
|
||||
this.progress = progress;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(RegattaReferenceDTO o) {
|
||||
if(o instanceof RegattaWithProgressDTO) {
|
||||
RegattaWithProgressDTO other = (RegattaWithProgressDTO) o;
|
||||
RegattaState state = getState();
|
||||
RegattaState otherState = other.getState();
|
||||
if(state != otherState) {
|
||||
if(state == RegattaState.RUNNING) {
|
||||
return -1;
|
||||
}
|
||||
if(otherState == RegattaState.RUNNING) {
|
||||
return 1;
|
||||
}
|
||||
if(state == RegattaState.PROGRESS) {
|
||||
return -1;
|
||||
}
|
||||
if(otherState == RegattaState.PROGRESS) {
|
||||
return 1;
|
||||
}
|
||||
if(state == RegattaState.FINISHED) {
|
||||
return -1;
|
||||
}
|
||||
if(otherState == RegattaState.FINISHED) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.compareTo(o);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user