mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-10 22:30:56 +00:00
fix for bug 1958: whether or not a LeaderboardDTO has overall details is now rememberd; leaderboard is fetched again with progress indication if required
This commit is contained in:
1 parent
8ee612349e
commit
2a38f8eb86
5 files changed
+85
-45
No files matched your search
+17
-1
@@ -49,18 +49,26 @@ public class LeaderboardDTO extends AbstractLeaderboardDTO implements Serializab
|
||||
*/
|
||||
private boolean higherScoresIsBetter;
|
||||
|
||||
/**
|
||||
* Tells whether this leaderboard has data about overall details. This corresponds with the <code>addOverallDetails</code> request parameter
|
||||
* for a leaderboard DTO computation.
|
||||
*/
|
||||
private boolean hasOverallDetails;
|
||||
|
||||
LeaderboardDTO() {} // for serialization
|
||||
|
||||
/**
|
||||
* @param uuidGenerator used to provide the {@link #id ID} for this object (see also {@link #getId()}) and for any clones produced
|
||||
* from it by the {@link #clone()} operation.
|
||||
* @param hasOverallDetails TODO
|
||||
*/
|
||||
public LeaderboardDTO(Date timePointOfLastCorrectionsValidity, String comment, boolean higherScoreIsBetter, UUIDGenerator uuidGenerator) {
|
||||
public LeaderboardDTO(Date timePointOfLastCorrectionsValidity, String comment, boolean higherScoreIsBetter, UUIDGenerator uuidGenerator, boolean hasOverallDetails) {
|
||||
initCollections();
|
||||
id = uuidGenerator.generateRandomUUID();
|
||||
this.timePointOfLastCorrectionsValidity = timePointOfLastCorrectionsValidity;
|
||||
this.comment = comment;
|
||||
this.higherScoresIsBetter = higherScoreIsBetter;
|
||||
this.hasOverallDetails = hasOverallDetails;
|
||||
}
|
||||
|
||||
private void initCollections() {
|
||||
@@ -165,4 +173,12 @@ public class LeaderboardDTO extends AbstractLeaderboardDTO implements Serializab
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether this leaderboard has data about overall details. This corresponds with the <code>addOverallDetails</code> request parameter
|
||||
* for a leaderboard DTO computation.
|
||||
*/
|
||||
public boolean hasOverallDetails() {
|
||||
return hasOverallDetails;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1109,7 +1109,7 @@ public abstract class AbstractSimpleLeaderboardImpl implements Leaderboard, Race
|
||||
final LeaderboardDTO result = new LeaderboardDTO(this.getScoreCorrection().getTimePointOfLastCorrectionsValidity() == null ? null
|
||||
: this.getScoreCorrection().getTimePointOfLastCorrectionsValidity().asDate(),
|
||||
this.getScoreCorrection() == null ? null : this.getScoreCorrection().getComment(), this
|
||||
.getScoringScheme().isHigherBetter(), new UUIDGenerator());
|
||||
.getScoringScheme().isHigherBetter(), new UUIDGenerator(), addOverallDetails);
|
||||
result.competitors = new ArrayList<CompetitorDTO>();
|
||||
result.name = this.getName();
|
||||
result.competitorDisplayNames = new HashMap<CompetitorDTO, String>();
|
||||
|
||||
+2
-2
@@ -60,7 +60,7 @@ public class TestColumnSwapping {
|
||||
public String generateRandomUUID() {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
});
|
||||
}, /* hasOverallDetails */ false);
|
||||
leaderboardOriginalDTO.addRace("Race1", /* explicitFactor */ null, 2., DEFAULT_FLEET, true, null, null);
|
||||
leaderboardOriginalDTO.addRace("Race3", /* explicitFactor */ null, 2., DEFAULT_FLEET, true, null, null);
|
||||
leaderboardOriginalDTO.addRace("Race2", /* explicitFactor */ null, 2., DEFAULT_FLEET, true, null, null);
|
||||
@@ -123,7 +123,7 @@ public class TestColumnSwapping {
|
||||
public String generateRandomUUID() {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
});
|
||||
}, /* hasOverallDetails */ false);
|
||||
assertNotNull("Leaderboard != NULL", lb);
|
||||
lb.addRace("1", /* explicitFactor */ null, 1., DEFAULT_FLEET, false, null, null);
|
||||
lb.addRace("2", /* explicitFactor */ null, 1., DEFAULT_FLEET, false, null, null);
|
||||
|
||||
+2
-1
@@ -148,6 +148,7 @@ public abstract class ExpandableSortableColumn<C> extends SortableColumn<Leaderb
|
||||
*/
|
||||
public void toggleExpansion() {
|
||||
if (isExpansionEnabled()) {
|
||||
final boolean oldBusyState = getLeaderboardPanel().getBusyIndicator().isBusy();
|
||||
getLeaderboardPanel().getBusyIndicator().setBusy(true);
|
||||
setTogglingInProcess(true);
|
||||
final CellTable<LeaderboardRowDTO> table = getLeaderboardPanel().getLeaderboardTable();
|
||||
@@ -175,7 +176,7 @@ public abstract class ExpandableSortableColumn<C> extends SortableColumn<Leaderb
|
||||
}
|
||||
getLeaderboardPanel().getLeaderboardTable().redraw();
|
||||
}
|
||||
getLeaderboardPanel().getBusyIndicator().setBusy(false);
|
||||
getLeaderboardPanel().getBusyIndicator().setBusy(oldBusyState);
|
||||
setTogglingInProcess(false);
|
||||
}
|
||||
});
|
||||
|
||||
+63
-40
@@ -335,12 +335,17 @@ public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayS
|
||||
return resources.settingsIcon();
|
||||
}
|
||||
|
||||
public void updateSettings(LeaderboardSettings newSettings) {
|
||||
public void updateSettings(final LeaderboardSettings newSettings) {
|
||||
boolean oldShallAddOverallDetails = shallAddOverallDetails();
|
||||
if (newSettings.getOverallDetailsToShow() != null) {
|
||||
selectedOverallDetailColumns.clear();
|
||||
selectedOverallDetailColumns.addAll(newSettings.getOverallDetailsToShow());
|
||||
}
|
||||
if (!newSettings.isUpdateUponPlayStateChange() || !currentlyHandlingPlayStateChange) {
|
||||
settingsUpdatedExplicitly = true;
|
||||
}
|
||||
setShowAddedScores(newSettings.isShowAddedScores());
|
||||
List<ExpandableSortableColumn<?>> columnsToExpandAgain = new ArrayList<ExpandableSortableColumn<?>>();
|
||||
final List<ExpandableSortableColumn<?>> columnsToExpandAgain = new ArrayList<ExpandableSortableColumn<?>>();
|
||||
for (int i = 0; i < getLeaderboardTable().getColumnCount(); i++) {
|
||||
Column<LeaderboardRowDTO, ?> c = getLeaderboardTable().getColumn(i);
|
||||
if (c instanceof ExpandableSortableColumn<?>) {
|
||||
@@ -366,10 +371,6 @@ public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayS
|
||||
selectedRaceDetails.clear();
|
||||
selectedRaceDetails.addAll(newSettings.getRaceDetailsToShow());
|
||||
}
|
||||
if (newSettings.getOverallDetailsToShow() != null) {
|
||||
selectedOverallDetailColumns.clear();
|
||||
selectedOverallDetailColumns.addAll(newSettings.getOverallDetailsToShow());
|
||||
}
|
||||
// update strategy for determining the race columns to show; if settings' race columns to show is null, use the
|
||||
// previously selected race columns / number of race columns for the new configuration
|
||||
Iterable<String> oldNamesOfRaceColumnsToShow = null;
|
||||
@@ -414,26 +415,66 @@ public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayS
|
||||
setRaceColumnSelectionToLastNStrategy(newSettings.getNumberOfLastRacesToShow());
|
||||
break;
|
||||
}
|
||||
setAutoExpandPreSelectedRace(false); // avoid expansion during updateLeaderboard(...); will expand later if it
|
||||
// was expanded before
|
||||
// update leaderboard after settings panel column selection change
|
||||
updateLeaderboard(leaderboard);
|
||||
setAutoExpandPreSelectedRace(newSettings.isAutoExpandPreSelectedRace());
|
||||
|
||||
final boolean oldBusyState = getBusyIndicator().isBusy();
|
||||
getBusyIndicator().setBusy(true);
|
||||
Runnable doWhenNecessaryDetailHasBeenLoaded = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setAutoExpandPreSelectedRace(false); // avoid expansion during updateLeaderboard(...); will expand later
|
||||
// if it was expanded before
|
||||
// update leaderboard after settings panel column selection change
|
||||
updateLeaderboard(leaderboard);
|
||||
setAutoExpandPreSelectedRace(newSettings.isAutoExpandPreSelectedRace());
|
||||
|
||||
if (newSettings.getDelayBetweenAutoAdvancesInMilliseconds() != null) {
|
||||
timer.setRefreshInterval(newSettings.getDelayBetweenAutoAdvancesInMilliseconds());
|
||||
}
|
||||
for (ExpandableSortableColumn<?> expandableSortableColumn : columnsToExpandAgain) {
|
||||
expandableSortableColumn.toggleExpansion();
|
||||
}
|
||||
if (newSettings.getNameOfRaceToSort() != null) {
|
||||
final RaceColumn<?> raceColumnByRaceName = getRaceColumnByRaceName(newSettings.getNameOfRaceToSort());
|
||||
if (raceColumnByRaceName != null) {
|
||||
getLeaderboardTable().sortColumn(raceColumnByRaceName, /* ascending */true);
|
||||
if (newSettings.getDelayBetweenAutoAdvancesInMilliseconds() != null) {
|
||||
timer.setRefreshInterval(newSettings.getDelayBetweenAutoAdvancesInMilliseconds());
|
||||
}
|
||||
for (ExpandableSortableColumn<?> expandableSortableColumn : columnsToExpandAgain) {
|
||||
expandableSortableColumn.toggleExpansion();
|
||||
}
|
||||
if (newSettings.getNameOfRaceToSort() != null) {
|
||||
final RaceColumn<?> raceColumnByRaceName = getRaceColumnByRaceName(newSettings
|
||||
.getNameOfRaceToSort());
|
||||
if (raceColumnByRaceName != null) {
|
||||
getLeaderboardTable().sortColumn(raceColumnByRaceName, /* ascending */true);
|
||||
}
|
||||
}
|
||||
getBusyIndicator().setBusy(oldBusyState);
|
||||
}
|
||||
};
|
||||
if (oldShallAddOverallDetails == shallAddOverallDetails() || oldShallAddOverallDetails || getLeaderboard().hasOverallDetails()) {
|
||||
doWhenNecessaryDetailHasBeenLoaded.run();
|
||||
} else { // meaning that now the details need to be loaded from the server
|
||||
updateLeaderboardAndRun(doWhenNecessaryDetailHasBeenLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param callWhenExpansionDataIsLoaded
|
||||
*/
|
||||
private void updateLeaderboardAndRun(final Runnable callWhenExpansionDataIsLoaded) {
|
||||
final LeaderboardDTO previousLeaderboard = getLeaderboard();
|
||||
getSailingService().getLeaderboardByName(getLeaderboardName(),
|
||||
timer.getPlayMode() == PlayModes.Live ? null : getLeaderboardDisplayDate(),
|
||||
/* namesOfRacesForWhichToLoadLegDetails */getNamesOfExpandedRaces(),
|
||||
shallAddOverallDetails(), previousLeaderboard.getId(), new MarkedAsyncCallback<IncrementalOrFullLeaderboardDTO>(
|
||||
new AsyncCallback<IncrementalOrFullLeaderboardDTO>() {
|
||||
@Override
|
||||
public void onSuccess(IncrementalOrFullLeaderboardDTO result) {
|
||||
updateLeaderboard(result.getLeaderboardDTO(previousLeaderboard));
|
||||
callWhenExpansionDataIsLoaded.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
getErrorReporter().reportError(
|
||||
stringMessages.errorTryingToObtainLeaderboardContents(caught.getMessage()),
|
||||
true /* silentMode */);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
private void setRaceColumnSelectionToLastNStrategy(final Integer numberOfLastRacesToShow) {
|
||||
raceColumnSelection = new LastNRacesColumnSelection(numberOfLastRacesToShow, getRaceTimesInfoProvider());
|
||||
if (timer.getPlayState() != Timer.PlayStates.Playing) {
|
||||
@@ -788,25 +829,7 @@ public class LeaderboardPanel extends SimplePanel implements TimeListener, PlayS
|
||||
if (getLeaderboard().getLegCount(getRaceColumnName()) != -1) {
|
||||
callWhenExpansionDataIsLoaded.run();
|
||||
} else {
|
||||
final LeaderboardDTO previousLeaderboard = getLeaderboard();
|
||||
getSailingService().getLeaderboardByName(getLeaderboardName(),
|
||||
timer.getPlayMode() == PlayModes.Live ? null : getLeaderboardDisplayDate(),
|
||||
/* namesOfRacesForWhichToLoadLegDetails */getNamesOfExpandedRaces(),
|
||||
shallAddOverallDetails(), previousLeaderboard.getId(), new MarkedAsyncCallback<IncrementalOrFullLeaderboardDTO>(
|
||||
new AsyncCallback<IncrementalOrFullLeaderboardDTO>() {
|
||||
@Override
|
||||
public void onSuccess(IncrementalOrFullLeaderboardDTO result) {
|
||||
updateLeaderboard(result.getLeaderboardDTO(previousLeaderboard));
|
||||
callWhenExpansionDataIsLoaded.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
getErrorReporter().reportError(
|
||||
stringMessages.errorTryingToObtainLeaderboardContents(caught.getMessage()),
|
||||
true /* silentMode */);
|
||||
}
|
||||
}));
|
||||
updateLeaderboardAndRun(callWhenExpansionDataIsLoaded);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user