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:
Steffen Schaefer committed 2015-07-20 17:37:24 +02:00
1 parent 70b954ee13
commit d74aa3a82f
1 file changed
+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);
}
}