mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-06 12:23:55 +00:00
Added a button in the TrackedRacesManagementPanel to set the
startTimeReceived of the selected race
This commit is contained in:
1 parent
2dec6f7aa0
commit
1ff1b741a4
8 files changed
+133
-3
No files matched your search
+63
@@ -0,0 +1,63 @@
|
||||
package com.sap.sailing.gwt.ui.adminconsole;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||
import com.google.gwt.user.client.ui.Grid;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.shared.BetterDateTimeBox;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog;
|
||||
|
||||
public class SetStartTimeReceivedDialog extends DataEntryDialog<Date> {
|
||||
|
||||
private final StringMessages stringMessages;
|
||||
|
||||
private BetterDateTimeBox timeBox;
|
||||
|
||||
public SetStartTimeReceivedDialog(StringMessages stringMessages, DataEntryDialog.DialogCallback<Date> callback) {
|
||||
super(stringMessages.setStartTimeReceived(), stringMessages.setStartTimeReceivedDescription(), stringMessages.ok(), stringMessages.cancel(), new ReceivedStartTimeDialog(stringMessages), callback);
|
||||
this.stringMessages = stringMessages;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Widget getAdditionalWidget() {
|
||||
Grid content = new Grid(1, 2);
|
||||
|
||||
Label timeBoxLabel = new Label(stringMessages.startTime() + ":");
|
||||
content.setWidget(0, 0, timeBoxLabel);
|
||||
timeBox = new BetterDateTimeBox();
|
||||
timeBox.addValueChangeHandler(new ValueChangeHandler<Date>() {
|
||||
@Override
|
||||
public void onValueChange(ValueChangeEvent<Date> event) {
|
||||
validate();
|
||||
}
|
||||
});
|
||||
content.setWidget(0, 1, timeBox);
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Date getResult() {
|
||||
return timeBox.getValue();
|
||||
}
|
||||
|
||||
private static class ReceivedStartTimeDialog implements Validator<Date> {
|
||||
|
||||
private StringMessages stringMessages;
|
||||
|
||||
public ReceivedStartTimeDialog(StringMessages stringMessages) {
|
||||
this.stringMessages = stringMessages;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getErrorMessage(Date valueToValidate) {
|
||||
return valueToValidate == null ? stringMessages.pleaseEnterAValue() : null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+38
@@ -2,15 +2,22 @@ package com.sap.sailing.gwt.ui.adminconsole;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
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.i18n.client.TimeZone;
|
||||
import com.google.gwt.text.client.DateTimeFormatRenderer;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.Grid;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.sap.sailing.domain.common.dto.RaceDTO;
|
||||
import com.sap.sailing.gwt.ui.client.ErrorReporter;
|
||||
import com.sap.sailing.gwt.ui.client.RegattaRefresher;
|
||||
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog.DialogCallback;
|
||||
|
||||
public class TrackedRacesManagementPanel extends AbstractRaceManagementPanel {
|
||||
private final DateTimeFormatRenderer dateFormatter = new DateTimeFormatRenderer(
|
||||
@@ -25,6 +32,37 @@ public class TrackedRacesManagementPanel extends AbstractRaceManagementPanel {
|
||||
public TrackedRacesManagementPanel(final SailingServiceAsync sailingService, ErrorReporter errorReporter,
|
||||
RegattaRefresher regattaRefresher, StringMessages stringConstants) {
|
||||
super(sailingService, errorReporter, regattaRefresher, stringConstants);
|
||||
|
||||
HorizontalPanel controlsPanel = new HorizontalPanel();
|
||||
Button setStartTimeButton = new Button(stringMessages.setStartTimeReceived(), new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
new SetStartTimeReceivedDialog(stringMessages, new DialogCallback<Date>() {
|
||||
@Override
|
||||
public void ok(Date newStartTimeReceived) {
|
||||
sailingService.setStartTimeReceivedForRace(selectedRaceDTO.getRaceIdentifier(), newStartTimeReceived, new AsyncCallback<RaceDTO>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
TrackedRacesManagementPanel.this.errorReporter.reportError("Error setting the received start time: " + caught.getMessage());
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(RaceDTO result) {
|
||||
if (result != null) {
|
||||
selectedRaceDTO = result;
|
||||
refreshSelectedRaceData();
|
||||
|
||||
TrackedRacesManagementPanel.this.regattaRefresher.fillRegattas();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@Override
|
||||
public void cancel() { }
|
||||
}).show();
|
||||
}
|
||||
});
|
||||
controlsPanel.add(setStartTimeButton);
|
||||
selectedRaceContentPanel.add(controlsPanel);
|
||||
|
||||
raceDataGrid = new Grid(6,2);
|
||||
this.selectedRaceContentPanel.add(raceDataGrid);
|
||||
|
||||
+7
-1
@@ -19,6 +19,7 @@ import com.sap.sailing.domain.common.NoWindException;
|
||||
import com.sap.sailing.domain.common.PassingInstruction;
|
||||
import com.sap.sailing.domain.common.PolarSheetGenerationResponse;
|
||||
import com.sap.sailing.domain.common.PolarSheetGenerationSettings;
|
||||
import com.sap.sailing.domain.common.RaceIdentifier;
|
||||
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
|
||||
import com.sap.sailing.domain.common.RegattaIdentifier;
|
||||
import com.sap.sailing.domain.common.ScoringSchemeType;
|
||||
@@ -511,5 +512,10 @@ public interface SailingService extends RemoteService {
|
||||
* by {@link #getSearchServerNames()} which corresponds to a name of a
|
||||
* {@link RemoteSailingServerReference}, to search a remote server.
|
||||
*/
|
||||
Iterable<LeaderboardSearchResultDTO> search(String serverNameOrNullForMain, KeywordQuery query) throws Exception;
|
||||
Iterable<LeaderboardSearchResultDTO> search(String serverNameOrNullForMain, KeywordQuery query) throws Exception;
|
||||
|
||||
/**
|
||||
* @return The RaceDTO of the modified race or <code>null</code>, if the given newStartTimeReceived was null.
|
||||
*/
|
||||
RaceDTO setStartTimeReceivedForRace(RaceIdentifier raceIdentifier, Date newStartTimeReceived);
|
||||
}
|
||||
+2
@@ -630,4 +630,6 @@ public interface SailingServiceAsync {
|
||||
*/
|
||||
void search(String serverNameOrNullForMain, KeywordQuery query,
|
||||
AsyncCallback<Iterable<LeaderboardSearchResultDTO>> callback);
|
||||
|
||||
void setStartTimeReceivedForRace(RaceIdentifier raceIdentifier, Date newStartTimeReceived, AsyncCallback<RaceDTO> callback);
|
||||
}
|
||||
+2
@@ -1047,4 +1047,6 @@ public interface StringMessages extends Messages {
|
||||
String showNumberOfRacesScored();
|
||||
String racesScored();
|
||||
String racesScoredTooltip();
|
||||
String setStartTimeReceived();
|
||||
String setStartTimeReceivedDescription();
|
||||
}
|
||||
+3
-1
@@ -1032,4 +1032,6 @@ showPingMarkMappings=Show Mappings for pinged Marks
|
||||
regattaNameMustNotContainSlashes=Regatta name must not contain slashes
|
||||
showNumberOfRacesScored=Number of races scored
|
||||
racesScored=Races scored
|
||||
racesScoredTooltip=Number of races the competitor has completed or gotten a score for in this leaderboard.
|
||||
racesScoredTooltip=Number of races the competitor has completed or gotten a score for in this leaderboard.
|
||||
setStartTimeReceived=Set start time received
|
||||
setStartTimeReceivedDescription=This sets the startTimeReceived of the selected TrackedRace that isn''t persistent. This means that the new value will be forgotten after the server has been restarted.
|
||||
+4
-1
@@ -1026,4 +1026,7 @@ showPingMarkMappings=Mappings für gepingte Marks zeigen
|
||||
regattaNameMustNotContainSlashes=Regattaname darf keine Schrägstriche enthalten
|
||||
showNumberOfRacesScored=Anzahl bepunkteter Rennen
|
||||
racesScored=Bepunktete Rennen
|
||||
racesScoredTooltip=Anzahl von Rennen, die der Segler vollendet oder für die er Punkte bekommen hat
|
||||
racesScoredTooltip=Anzahl von Rennen, die der Segler vollendet oder für die er Punkte bekommen hat
|
||||
setStartTimeReceived=Setze die erhaltene Startzeit
|
||||
setStartTimeReceivedDescription=This sets the startTimeReceived of the selected TrackedRace, that isn''t persistent. This means, that the new value will be forgotten after the server has been restarted.
|
||||
setStartTimeReceivedDescription=Dies setzt die startTimeReceived des selektierten TrackedRaces, welches nicht persistent ist. Das beudeutet, dass der neue Wert vergessen wird, sobald der Server neu gestartet wurde.
|
||||
+14
@@ -118,6 +118,7 @@ import com.sap.sailing.domain.common.PolarSheetGenerationSettings;
|
||||
import com.sap.sailing.domain.common.PolarSheetsData;
|
||||
import com.sap.sailing.domain.common.Position;
|
||||
import com.sap.sailing.domain.common.RaceFetcher;
|
||||
import com.sap.sailing.domain.common.RaceIdentifier;
|
||||
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
|
||||
import com.sap.sailing.domain.common.RegattaFetcher;
|
||||
import com.sap.sailing.domain.common.RegattaIdentifier;
|
||||
@@ -4691,4 +4692,17 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
leaderboardSearchResult.getBoatClassName(), convertToEventDTO(leaderboardSearchResult.getEvent()),
|
||||
leaderboardGroups);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RaceDTO setStartTimeReceivedForRace(RaceIdentifier raceIdentifier, Date newStartTimeReceived) {
|
||||
if (newStartTimeReceived != null) {
|
||||
RegattaNameAndRaceName regattaAndRaceIdentifier = new RegattaNameAndRaceName(
|
||||
raceIdentifier.getRegattaName(), raceIdentifier.getRaceName());
|
||||
DynamicTrackedRace trackedRace = getService().getTrackedRace(regattaAndRaceIdentifier);
|
||||
trackedRace.setStartTimeReceived(new MillisecondsTimePoint(newStartTimeReceived));
|
||||
|
||||
return baseDomainFactory.createRaceDTO(getService(), false, regattaAndRaceIdentifier, trackedRace);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user