mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-05 11:53:53 +00:00
fixed bug 790: auto-expand of first column shall only expand pre-selected race, and only once
This commit is contained in:
1 parent
3baf4046ac
commit
6a402a35ad
4 files changed
+36
-26
No files matched your search
+23
-13
@@ -154,7 +154,13 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
|
||||
|
||||
private final Timer timer;
|
||||
|
||||
private boolean autoExpandFirstRace;
|
||||
private boolean autoExpandPreSelectedRace;
|
||||
|
||||
/**
|
||||
* Remembers whether the auto-expand of the pre-selected race (see {@link #autoExpandPreSelectedRace}) has been performed
|
||||
* once. It must not be performed another time.
|
||||
*/
|
||||
private boolean autoExpandPerformedOnce;
|
||||
|
||||
/**
|
||||
* This anchor's HTML holds the image tag for the play/pause button that needs to be updated when the {@link #timer}
|
||||
@@ -304,10 +310,10 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
|
||||
}
|
||||
}
|
||||
}
|
||||
setAutoExpandFirstRace(false); // avoid expansion during updateLeaderboard(...); will expand later if it was expanded before
|
||||
setAutoExpandPreSelectedRace(false); // avoid expansion during updateLeaderboard(...); will expand later if it was expanded before
|
||||
// update leaderboard after settings panel column selection change
|
||||
updateLeaderboard(leaderboard);
|
||||
setAutoExpandFirstRace(newSettings.isAutoExpandFirstRace());
|
||||
setAutoExpandPreSelectedRace(newSettings.isAutoExpandPreSelectedRace());
|
||||
|
||||
if (newSettings.getDelayBetweenAutoAdvancesInMilliseconds() != null) {
|
||||
timer.setRefreshInterval(newSettings.getDelayBetweenAutoAdvancesInMilliseconds());
|
||||
@@ -946,7 +952,7 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
|
||||
selectedLegDetails.addAll(settings.getLegDetailsToShow());
|
||||
selectedManeuverDetails.addAll(settings.getManeuverDetailsToShow());
|
||||
selectedRaceDetails.addAll(settings.getRaceDetailsToShow());
|
||||
setAutoExpandFirstRace(settings.isAutoExpandFirstRace());
|
||||
setAutoExpandPreSelectedRace(settings.isAutoExpandPreSelectedRace());
|
||||
|
||||
this.timer = timer;
|
||||
timer.addPlayStateListener(this);
|
||||
@@ -1110,12 +1116,15 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
|
||||
timer.setLivePlayDelayInMillis(delayInMilliseconds);
|
||||
}
|
||||
|
||||
public boolean isAutoExpandFirstRace() {
|
||||
return autoExpandFirstRace;
|
||||
public boolean isAutoExpandPreSelectedRace() {
|
||||
return autoExpandPreSelectedRace;
|
||||
}
|
||||
|
||||
private void setAutoExpandFirstRace(boolean autoExpandFirstRace) {
|
||||
this.autoExpandFirstRace = autoExpandFirstRace;
|
||||
private void setAutoExpandPreSelectedRace(boolean autoExpandPreSelectedRace) {
|
||||
this.autoExpandPreSelectedRace = autoExpandPreSelectedRace;
|
||||
if (autoExpandPreSelectedRace) {
|
||||
autoExpandPerformedOnce = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1250,18 +1259,19 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
|
||||
adjustColumnLayout(leaderboard);
|
||||
getData().getList().clear();
|
||||
if (leaderboard != null) {
|
||||
boolean firstRace = true;
|
||||
getData().getList().addAll(getRowsToDisplay(leaderboard));
|
||||
for (int i = 0; i < getLeaderboardTable().getColumnCount(); i++) {
|
||||
SortableColumn<?, ?> c = (SortableColumn<?, ?>) getLeaderboardTable().getColumn(i);
|
||||
c.updateMinMax(leaderboard);
|
||||
// Toggle the first race, if the setting is set and it isn't open yet
|
||||
if (firstRace && isAutoExpandFirstRace() && c instanceof ExpandableSortableColumn<?>) {
|
||||
// Toggle pre-selected race, if the setting is set and it isn't open yet
|
||||
if (!autoExpandPerformedOnce && isAutoExpandPreSelectedRace()
|
||||
&& c instanceof RaceColumn<?>
|
||||
&& ((RaceColumn<?>) c).getRace().hasTrackedRace(preSelectedRace)) {
|
||||
ExpandableSortableColumn<?> expandableSortableColumn = (ExpandableSortableColumn<?>) c;
|
||||
if (!expandableSortableColumn.isExpanded()) {
|
||||
expandableSortableColumn.toggleExpansion();
|
||||
autoExpandPerformedOnce = true;
|
||||
}
|
||||
firstRace = false;
|
||||
}
|
||||
}
|
||||
Comparator<LeaderboardRowDTO> comparator = getComparatorForSelectedSorting();
|
||||
@@ -1810,7 +1820,7 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
|
||||
Collections.unmodifiableList(selectedLegDetails),
|
||||
Collections.unmodifiableList(selectedRaceDetails), /* All races to select */
|
||||
leaderboard.getRaceList(), selectedRaceColumns,
|
||||
autoExpandFirstRace, timer.getRefreshInterval(), timer.getLivePlayDelayInMillis(), stringMessages);
|
||||
autoExpandPreSelectedRace, timer.getRefreshInterval(), timer.getLivePlayDelayInMillis(), stringMessages);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-6
@@ -17,7 +17,7 @@ public class LeaderboardSettings {
|
||||
private final List<DetailType> maneuverDetailsToShow;
|
||||
private final List<DetailType> legDetailsToShow;
|
||||
private final List<DetailType> raceDetailsToShow;
|
||||
private final boolean autoExpandFirstRace;
|
||||
private final boolean autoExpandPreSelectedRace;
|
||||
private final Long delayBetweenAutoAdvancesInMilliseconds;
|
||||
private final Long delayInMilliseconds;
|
||||
|
||||
@@ -33,7 +33,7 @@ public class LeaderboardSettings {
|
||||
* @param legDetailsToShow
|
||||
* @param raceDetailsToShow
|
||||
* @param namesOfRacesToShow
|
||||
* @param autoExpandFirstRace
|
||||
* @param autoExpandPreSelectedRace
|
||||
* @param delayBetweenAutoAdvancesInMilliseconds
|
||||
* @param delayInMilliseconds
|
||||
* @param nameOfRaceToSort
|
||||
@@ -42,7 +42,7 @@ public class LeaderboardSettings {
|
||||
*/
|
||||
public LeaderboardSettings(List<DetailType> meneuverDetailsToShow, List<DetailType> legDetailsToShow,
|
||||
List<DetailType> raceDetailsToShow, List<String> namesOfRaceColumnsToShow,
|
||||
List<String> namesOfRacesToShow, boolean autoExpandFirstRace, Long delayBetweenAutoAdvancesInMilliseconds,
|
||||
List<String> namesOfRacesToShow, boolean autoExpandPreSelectedRace, Long delayBetweenAutoAdvancesInMilliseconds,
|
||||
Long delayInMilliseconds, String nameOfRaceToSort, boolean sortAscending) {
|
||||
if (namesOfRacesToShow != null && namesOfRaceColumnsToShow != null) {
|
||||
throw new IllegalArgumentException("You can identify races either only by their race or by their column names, not both");
|
||||
@@ -51,7 +51,7 @@ public class LeaderboardSettings {
|
||||
this.raceDetailsToShow = raceDetailsToShow;
|
||||
this.namesOfRacesToShow = namesOfRacesToShow;
|
||||
this.namesOfRaceColumnsToShow = namesOfRaceColumnsToShow;
|
||||
this.autoExpandFirstRace = autoExpandFirstRace;
|
||||
this.autoExpandPreSelectedRace = autoExpandPreSelectedRace;
|
||||
this.delayBetweenAutoAdvancesInMilliseconds = delayBetweenAutoAdvancesInMilliseconds;
|
||||
this.delayInMilliseconds = delayInMilliseconds;
|
||||
this.maneuverDetailsToShow = meneuverDetailsToShow;
|
||||
@@ -87,8 +87,8 @@ public class LeaderboardSettings {
|
||||
return namesOfRacesToShow;
|
||||
}
|
||||
|
||||
public boolean isAutoExpandFirstRace() {
|
||||
return autoExpandFirstRace;
|
||||
public boolean isAutoExpandPreSelectedRace() {
|
||||
return autoExpandPreSelectedRace;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+4
-4
@@ -33,13 +33,13 @@ public class LeaderboardSettingsDialogComponent implements SettingsDialogCompone
|
||||
private final StringMessages stringConstants;
|
||||
private LongBox delayBetweenAutoAdvancesInSecondsBox;
|
||||
private LongBox delayInSecondsBox;
|
||||
private final boolean autoExpandFirstRace;
|
||||
private final boolean autoExpandPreSelectedRace;
|
||||
private final long delayBetweenAutoAdvancesInMilliseconds;
|
||||
private final long delayInMilliseconds;
|
||||
|
||||
public LeaderboardSettingsDialogComponent(List<DetailType> maneuverDetailSelection,
|
||||
List<DetailType> legDetailSelection, List<DetailType> raceDetailSelection, List<RaceColumnDTO> raceAllRaceColumns,
|
||||
List<RaceColumnDTO> raceColumnSelection, boolean autoExpandFirstRace, long delayBetweenAutoAdvancesInMilliseconds, long delayInMilliseconds,
|
||||
List<RaceColumnDTO> raceColumnSelection, boolean autoExpandPreSelectedRace, long delayBetweenAutoAdvancesInMilliseconds, long delayInMilliseconds,
|
||||
StringMessages stringConstants) {
|
||||
this.maneuverDetailSelection = maneuverDetailSelection;
|
||||
this.raceColumnSelection = raceColumnSelection;
|
||||
@@ -51,7 +51,7 @@ public class LeaderboardSettingsDialogComponent implements SettingsDialogCompone
|
||||
maneuverDetailCheckboxes = new LinkedHashMap<DetailType, CheckBox>();
|
||||
legDetailCheckboxes = new LinkedHashMap<DetailType, CheckBox>();
|
||||
raceDetailCheckboxes = new LinkedHashMap<DetailType, CheckBox>();
|
||||
this.autoExpandFirstRace = autoExpandFirstRace;
|
||||
this.autoExpandPreSelectedRace = autoExpandPreSelectedRace;
|
||||
this.delayBetweenAutoAdvancesInMilliseconds = delayBetweenAutoAdvancesInMilliseconds;
|
||||
this.delayInMilliseconds = delayInMilliseconds;
|
||||
}
|
||||
@@ -142,7 +142,7 @@ public class LeaderboardSettingsDialogComponent implements SettingsDialogCompone
|
||||
Long delayBetweenAutoAdvancesValue = delayBetweenAutoAdvancesInSecondsBox.getValue();
|
||||
Long delayInSecondsValue = delayInSecondsBox.getValue();
|
||||
return new LeaderboardSettings(maneuverDetailsToShow, legDetailsToShow, raceDetailsToShow,
|
||||
namesOfRaceColumnsToShow, /* nameOfRacesToShow */null, autoExpandFirstRace,
|
||||
namesOfRaceColumnsToShow, /* nameOfRacesToShow */null, autoExpandPreSelectedRace,
|
||||
1000l * (delayBetweenAutoAdvancesValue == null ? 0l : delayBetweenAutoAdvancesValue.longValue()),
|
||||
1000 * (delayInSecondsValue == null ? 0 : delayInSecondsValue.longValue()), null, true);
|
||||
}
|
||||
|
||||
+3
-3
@@ -61,7 +61,7 @@ public class LeaderboardSettingsFactory {
|
||||
raceDetails.add(DetailType.DISPLAY_LEGS);
|
||||
settings = new LeaderboardSettings(maneuverDetails, legDetails, raceDetails, namesOfRaceColumnsToShow,
|
||||
namesOfRacesToShow,
|
||||
/* set autoExpandFirstRace to true if we look at a single race */ nameOfRaceColumnToShow != null || nameOfRaceToShow != null, /* refresh interval */ null,
|
||||
/* set autoExpandPreSelectedRace to true if we look at a single race */ nameOfRaceColumnToShow != null || nameOfRaceToShow != null, /* refresh interval */ null,
|
||||
/* delay to live */ null, /* name of race to sort */ nameOfRaceToSort, /* ascending */ true);
|
||||
break;
|
||||
case Replay:
|
||||
@@ -83,7 +83,7 @@ public class LeaderboardSettingsFactory {
|
||||
* <code>namesOfRaceColumnsToShow</code> must be <code>null
|
||||
*/
|
||||
public LeaderboardSettings createNewDefaultSettings(List<String> namesOfRaceColumnsToShow,
|
||||
List<String> namesOfRacesToShow, String nameOfRaceToSort, boolean autoExpandFirstRace) {
|
||||
List<String> namesOfRacesToShow, String nameOfRaceToSort, boolean autoExpandPreSelectedRace) {
|
||||
if (namesOfRaceColumnsToShow != null && namesOfRacesToShow != null) {
|
||||
throw new IllegalArgumentException("Can specify race columns either by column or by race name, not both");
|
||||
}
|
||||
@@ -99,7 +99,7 @@ public class LeaderboardSettingsFactory {
|
||||
raceDetails.add(DetailType.DISPLAY_LEGS);
|
||||
return new LeaderboardSettings(maneuverDetails, legDetails, raceDetails, namesOfRaceColumnsToShow,
|
||||
namesOfRacesToShow,
|
||||
autoExpandFirstRace, /* refresh interval */ null,
|
||||
autoExpandPreSelectedRace, /* refresh interval */ null,
|
||||
/* delay to live */ null, /* sort by column */ nameOfRaceToSort, /* ascending */ true);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user