mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-25 06:58:39 +00:00
compare start/end tracking times by Date, not String; code formatting
This commit is contained in:
+8
-9
@@ -5,13 +5,12 @@ import java.util.Date;
|
|||||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||||
|
|
||||||
public class RaceLogSetTrackingTimesDTO implements IsSerializable {
|
public class RaceLogSetTrackingTimesDTO implements IsSerializable {
|
||||||
public String leaderboardName;
|
public String leaderboardName;
|
||||||
public String raceColumnName;
|
public String raceColumnName;
|
||||||
public String fleetName;
|
public String fleetName;
|
||||||
public String authorName;
|
public String authorName;
|
||||||
public Integer authorPriority;
|
public Integer authorPriority;
|
||||||
public Date logicalTimePoint;
|
public Date logicalTimePoint;
|
||||||
public Date startOfTracking;
|
public Date startOfTracking;
|
||||||
public Date endOfTracking;
|
public Date endOfTracking;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+25
-25
@@ -5,6 +5,8 @@ import java.util.Date;
|
|||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||||
|
import com.google.gwt.i18n.client.DateTimeFormat.PredefinedFormat;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.gwt.user.client.ui.CaptionPanel;
|
import com.google.gwt.user.client.ui.CaptionPanel;
|
||||||
import com.google.gwt.user.client.ui.Grid;
|
import com.google.gwt.user.client.ui.Grid;
|
||||||
@@ -36,8 +38,11 @@ public class SetTrackingTimesDialog extends DataEntryDialogWithBootstrap<RaceLog
|
|||||||
private final String fleetName;
|
private final String fleetName;
|
||||||
private final StringMessages stringMessages;
|
private final StringMessages stringMessages;
|
||||||
|
|
||||||
|
private final DateTimeFormat dateTimeFormat = DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_LONG);
|
||||||
private Label currentStartLabel;
|
private Label currentStartLabel;
|
||||||
|
private Date currentStart;
|
||||||
private Label currentEndLabel;
|
private Label currentEndLabel;
|
||||||
|
private Date currentEnd;
|
||||||
|
|
||||||
private BetterDateTimeBox startTimeBox;
|
private BetterDateTimeBox startTimeBox;
|
||||||
private BetterDateTimeBox endTimeBox;
|
private BetterDateTimeBox endTimeBox;
|
||||||
@@ -69,7 +74,6 @@ public class SetTrackingTimesDialog extends DataEntryDialogWithBootstrap<RaceLog
|
|||||||
private void refreshTimes() {
|
private void refreshTimes() {
|
||||||
service.getTrackingTimes(leaderboardName, raceColumnName, fleetName,
|
service.getTrackingTimes(leaderboardName, raceColumnName, fleetName,
|
||||||
new AsyncCallback<Util.Pair<Date, Date>>() {
|
new AsyncCallback<Util.Pair<Date, Date>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
errorReporter.reportError("Error retrieving tracking times: " + caught.getMessage());
|
errorReporter.reportError("Error retrieving tracking times: " + caught.getMessage());
|
||||||
@@ -77,29 +81,25 @@ public class SetTrackingTimesDialog extends DataEntryDialogWithBootstrap<RaceLog
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Pair<Date, Date> result) {
|
public void onSuccess(Pair<Date, Date> result) {
|
||||||
Date start = result.getA();
|
currentStart = result.getA();
|
||||||
Date end = result.getB();
|
currentEnd = result.getB();
|
||||||
if (start == null) {
|
updateDateTimeLabelAndTimeBoxFromDate(currentStart, currentStartLabel, startTimeBox);
|
||||||
currentStartLabel.setText(stringMessages.notAvailable());
|
updateDateTimeLabelAndTimeBoxFromDate(currentEnd, currentEndLabel, endTimeBox);
|
||||||
} else {
|
|
||||||
currentStartLabel.setText(start.toString());
|
|
||||||
startTimeBox.setValue(start);
|
|
||||||
}
|
|
||||||
if (end == null) {
|
|
||||||
currentEndLabel.setText(stringMessages.notAvailable());
|
|
||||||
} else {
|
|
||||||
currentEndLabel.setText(end.toString());
|
|
||||||
endTimeBox.setValue(end);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateDateTimeLabelAndTimeBoxFromDate(final Date date, final Label label, final BetterDateTimeBox dateTimeBox) {
|
||||||
|
if (date == null) {
|
||||||
|
label.setText(stringMessages.notAvailable());
|
||||||
|
} else {
|
||||||
|
label.setText(dateTimeFormat.format(date));
|
||||||
|
dateTimeBox.setValue(date);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Widget createInputPanel() {
|
private Widget createInputPanel() {
|
||||||
Grid content = new Grid(4, 2);
|
Grid content = new Grid(4, 2);
|
||||||
|
|
||||||
|
|
||||||
startTimeBox = createDateTimeBox(null);
|
startTimeBox = createDateTimeBox(null);
|
||||||
startTimeBox.setFormat("dd/mm/yyyy hh:ii:ss");
|
startTimeBox.setFormat("dd/mm/yyyy hh:ii:ss");
|
||||||
content.setWidget(0, 0, createLabel(stringMessages.startOfTracking()));
|
content.setWidget(0, 0, createLabel(stringMessages.startOfTracking()));
|
||||||
@@ -158,17 +158,16 @@ public class SetTrackingTimesDialog extends DataEntryDialogWithBootstrap<RaceLog
|
|||||||
dto.logicalTimePoint = new Date();
|
dto.logicalTimePoint = new Date();
|
||||||
Date newEndTime = endTimeBox.getValue();
|
Date newEndTime = endTimeBox.getValue();
|
||||||
Date newStartTime = startTimeBox.getValue();
|
Date newStartTime = startTimeBox.getValue();
|
||||||
if (newEndTime != null && newEndTime.toString() != currentEndLabel.getText()) {
|
if (!Util.equalsWithNull(newEndTime, currentEnd)) {
|
||||||
dto.endOfTracking = newEndTime;
|
dto.endOfTracking = newEndTime;
|
||||||
}
|
}
|
||||||
if (newStartTime != null && newStartTime.toString() != currentStartLabel.getText()) {
|
if (!Util.equalsWithNull(newEndTime, currentEnd)) {
|
||||||
dto.startOfTracking = newStartTime;
|
dto.startOfTracking = newStartTime;
|
||||||
}
|
}
|
||||||
return dto;
|
return dto;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TrackingTimesValidator implements Validator<RaceLogSetTrackingTimesDTO> {
|
private static class TrackingTimesValidator implements Validator<RaceLogSetTrackingTimesDTO> {
|
||||||
|
|
||||||
private final StringMessages stringMessages;
|
private final StringMessages stringMessages;
|
||||||
|
|
||||||
public TrackingTimesValidator(StringMessages stringMessages) {
|
public TrackingTimesValidator(StringMessages stringMessages) {
|
||||||
@@ -177,13 +176,14 @@ public class SetTrackingTimesDialog extends DataEntryDialogWithBootstrap<RaceLog
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getErrorMessage(RaceLogSetTrackingTimesDTO dto) {
|
public String getErrorMessage(RaceLogSetTrackingTimesDTO dto) {
|
||||||
|
final String result;
|
||||||
if (dto.authorName == null || dto.authorPriority == null
|
if (dto.authorName == null || dto.authorPriority == null
|
||||||
|| (dto.startOfTracking == null && dto.endOfTracking == null)) {
|
|| (dto.startOfTracking == null && dto.endOfTracking == null)) {
|
||||||
return stringMessages.pleaseEnterAValue();
|
result = stringMessages.pleaseEnterAValue();
|
||||||
|
} else {
|
||||||
|
result = null;
|
||||||
}
|
}
|
||||||
return null;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Executable → Regular
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 809 B After Width: | Height: | Size: 199 B |
Reference in New Issue
Block a user