Added warning messages in the TracTrac Management console when you start tracking races with a dangerous regatta selection

This commit is contained in:
fmittag committed 2012-06-19 13:40:19 +02:00
1 parent fe128232d1
commit acdd791f9f
4 files changed
+62 -3

No files matched your search

@@ -20,6 +20,7 @@ import com.google.gwt.user.cellview.client.ColumnSortEvent;
import com.google.gwt.user.cellview.client.ColumnSortEvent.Handler;
import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler;
import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.CaptionPanel;
@@ -36,6 +37,7 @@ import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.MultiSelectionModel;
import com.sap.sailing.domain.common.RegattaIdentifier;
import com.sap.sailing.domain.common.RegattaName;
import com.sap.sailing.domain.common.impl.Util;
import com.sap.sailing.domain.common.impl.Util.Pair;
import com.sap.sailing.gwt.ui.client.ErrorReporter;
import com.sap.sailing.gwt.ui.client.RaceSelectionModel;
@@ -495,6 +497,26 @@ public class TracTracEventManagementPanel extends AbstractEventManagementPanel {
});
}
private boolean checkBoatClassMatch(TracTracRaceRecordDTO tracTracRecord, RegattaDTO selectedRegatta) {
Iterable<String> boatClassNames = tracTracRecord.boatClassNames;
if(boatClassNames != null && Util.size(boatClassNames) > 0) {
String tracTracBoatClass = boatClassNames.iterator().next();
if(selectedRegatta == null) {
// in case no regatta has been selected we check if there would be a matching regatta
for(RegattaDTO regatta: allRegattas) {
if(tracTracBoatClass.equalsIgnoreCase(regatta.boatClass.name)) {
return false;
}
}
} else {
if(!tracTracBoatClass.equalsIgnoreCase(selectedRegatta.boatClass.name)) {
return false;
}
}
}
return true;
}
private void trackSelectedRaces(boolean trackWind, boolean correctWindByDeclination, final boolean simulateWithStartTimeNow) {
String liveURI = liveURIBox.getValue();
String storedURI = storedURIBox.getValue();
@@ -503,6 +525,33 @@ public class TracTracEventManagementPanel extends AbstractEventManagementPanel {
if (selectedRegatta != null) {
regattaIdentifier = new RegattaName(selectedRegatta.name);
}
// Check if the assigned regatta makes sense
List<TracTracRaceRecordDTO> racesWithNotMatchingBoatClasses = new ArrayList<TracTracRaceRecordDTO>();
for (TracTracRaceRecordDTO rr : raceList.getList()) {
if (raceTable.getSelectionModel().isSelected(rr)) {
if(!checkBoatClassMatch(rr, selectedRegatta))
racesWithNotMatchingBoatClasses.add(rr);
}
}
if(racesWithNotMatchingBoatClasses.size() > 0) {
String warningText = "WARNING\n";
if(selectedRegatta != null) {
warningText += stringConstants.boatClassDoesNotMatchSelectedRegatta(selectedRegatta.boatClass.name, selectedRegatta.name);
} else {
warningText += stringConstants.regattaExistForSelectedBoatClass();
}
warningText += "\n\n";
warningText += stringConstants.races() + "\n";
for(TracTracRaceRecordDTO record: racesWithNotMatchingBoatClasses) {
warningText += record.name + "\n";
}
if(!Window.confirm(warningText)) {
return;
}
}
for (final TracTracRaceRecordDTO rr : raceList.getList()) {
if (raceTable.getSelectionModel().isSelected(rr)) {
sailingService.trackWithTracTrac(regattaIdentifier, rr, liveURI, storedURI, trackWind,
@@ -335,4 +335,6 @@ public interface StringMessages extends Messages {
String errorUpdatingScoresForLeaderboard(String leaderboardName, String message);
String maneuverTypesToShowWhenCompetitorIsClicked();
String simulateWithStartTimeNow();
String boatClassDoesNotMatchSelectedRegatta(String boatClass, String regattaName);
String regattaExistForSelectedBoatClass();
}
@@ -331,4 +331,8 @@ apply=Apply
successfullyUpdatedScores=Successfully updated scores
errorUpdatingScoresForLeaderboard=Error updating scores for leaderboard {0}: {1}
maneuverTypesToShowWhenCompetitorIsClicked=Maneuver types to show when competitor is clicked
simulateWithStartTimeNow=Simulate with "now" as start time
simulateWithStartTimeNow=Simulate with "now" as start time
boatClassDoesNotMatchSelectedRegatta=The selected races contain boat classes which are not the same as the boat class ''{0}'' of the selected regatta.\n\
Do you really want to use the regatta ''{1}''?
regattaExistForSelectedBoatClass=There is at least one regatta for the selected boat classes.\n\
Do you really want to use the ''no regatta'' selection?
@@ -1,4 +1,4 @@
=Hello World
helloWorld=Hello World
kielWeel2011=Kiel Week 2011
stgAccount=STG Account
tracTracEvents=TracTrac Events
@@ -332,4 +332,8 @@ apply=Übernehmen
successfullyUpdatedScores=Ergebnisse erfolgreich aktualisiert
errorUpdatingScoresForLeaderboard=Fehler beim Aktualisieren der Ergebnisse für {0}: {1}
maneuverTypesToShowWhenCompetitorIsClicked=Anzuzeigende Manövertypen für angeklickte Segler
simulateWithStartTimeNow=Simulieren mit "jetzt" als Startzeit
simulateWithStartTimeNow=Simulieren mit "jetzt" als Startzeit
boatClassDoesNotMatchSelectedRegatta=Die ausgewählten Rennen enthalten eine Bootsklasse, die nicht der Bootsklasse der ausgewählten Regatta '{0}' entspricht.\n\
Willst du wirklich diese Regatta benutzen '{1}'?
regattaExistForSelectedBoatClass=Es gibt mindestens eine Regatta zu den ausgewählten Bootsklassen.\n\
Willst du wirklich die Auswahl 'keine Regatta' benutzen?