Added setting to auto expand the first column and implemented it in LeaderboardPanel

This commit is contained in:
Lennart Hensler committed 2012-02-07 13:51:33 +01:00
1 parent eb2a6befaa
commit 7736ac3542
3 files changed
+33 -4

No files matched your search

@@ -148,6 +148,8 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
* The delay with which the timer shall work. Before the timer is resumed, the delay is set to this value.
*/
private long delayInMilliseconds;
private boolean autoExpandFirstRace;
/**
* This anchor's HTML holds the image tag for the play/pause button that needs to be updated when the {@link #timer}
@@ -240,6 +242,7 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
selectedRaceDetails.addAll(newSettings.getRaceDetailsToShow());
selectedRaceColumns.clear();
selectedRaceColumns.addAll(newSettings.getRaceColumnsToShow());
setAutoExpandFirstRace(newSettings.isAutoExpandFirstRace());
// update leaderboard after settings panel column selection change
updateLeaderboard(leaderboard);
@@ -819,6 +822,7 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
selectedManeuverDetails.add(DetailType.JIBE);
selectedManeuverDetails.add(DetailType.PENALTY_CIRCLE);
delayInMilliseconds = 0l;
autoExpandFirstRace = false;
this.timer = timer;
timer.addPlayStateListener(this);
timer.addTimeListener(this);
@@ -936,6 +940,14 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
private void setDelayInMilliseconds(long delayInMilliseconds) {
this.delayInMilliseconds = delayInMilliseconds;
}
public boolean isAutoExpandFirstRace() {
return autoExpandFirstRace;
}
private void setAutoExpandFirstRace(boolean autoExpandFirstRace) {
this.autoExpandFirstRace = autoExpandFirstRace;
}
/**
* The time point for which the leaderboard currently shows results
@@ -1057,10 +1069,19 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
adjustColumnLayout(leaderboard);
getData().getList().clear();
if (leaderboard != null) {
boolean firstRace = true;
getData().getList().addAll(leaderboard.rows.values());
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<?>) {
ExpandableSortableColumn<?> expandableSortableColumn = (ExpandableSortableColumn<?>) c;
if (!expandableSortableColumn.isExpanded()) {
expandableSortableColumn.toggleExpansion();
}
firstRace = false;
}
}
Comparator<LeaderboardRowDTO> comparator = getComparatorForSelectedSorting();
if (comparator != null) {
@@ -1503,7 +1524,7 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
Collections.unmodifiableList(selectedLegDetails),
Collections.unmodifiableList(selectedRaceDetails), /* All races to select */
leaderboard.getRaceList(), selectedRaceColumns,
timer.getDelayBetweenAutoAdvancesInMilliseconds(), delayInMilliseconds, stringConstants);
autoExpandFirstRace, timer.getDelayBetweenAutoAdvancesInMilliseconds(), delayInMilliseconds, stringConstants);
}
@Override
@@ -10,15 +10,17 @@ public class LeaderboardSettings {
private final List<DetailType> maneuverDetailsToShow;
private final List<DetailType> legDetailsToShow;
private final List<DetailType> raceDetailsToShow;
private final boolean autoExpandFirstRace;
private final long delayBetweenAutoAdvancesInMilliseconds;
private final long delayInMilliseconds;
public LeaderboardSettings(List<DetailType> meneuverDetailsToShow, List<DetailType> legDetailsToShow,
List<DetailType> raceDetailsToShow, List<RaceInLeaderboardDTO> raceColumnsToShow,
List<DetailType> raceDetailsToShow, List<RaceInLeaderboardDTO> raceColumnsToShow, boolean autoExpandFirstRace,
long delayBetweenAutoAdvancesInMilliseconds, long delayInMilliseconds) {
this.legDetailsToShow = legDetailsToShow;
this.raceDetailsToShow = raceDetailsToShow;
this.raceColumnsToShow = raceColumnsToShow;
this.autoExpandFirstRace = autoExpandFirstRace;
this.delayBetweenAutoAdvancesInMilliseconds = delayBetweenAutoAdvancesInMilliseconds;
this.delayInMilliseconds = delayInMilliseconds;
this.maneuverDetailsToShow = meneuverDetailsToShow;
@@ -40,6 +42,10 @@ public class LeaderboardSettings {
return raceColumnsToShow;
}
public boolean isAutoExpandFirstRace() {
return autoExpandFirstRace;
}
public long getDelayBetweenAutoAdvancesInMilliseconds() {
return delayBetweenAutoAdvancesInMilliseconds;
}
@@ -33,12 +33,13 @@ public class LeaderboardSettingsDialogComponent implements SettingsDialogCompone
private final StringMessages stringConstants;
private LongBox delayBetweenAutoAdvancesInSecondsBox;
private LongBox delayInSecondsBox;
private final boolean autoExpandFirstRace;
private final long delayBetweenAutoAdvancesInMilliseconds;
private final long delayInMilliseconds;
public LeaderboardSettingsDialogComponent(List<DetailType> maneuverDetailSelection,
List<DetailType> legDetailSelection, List<DetailType> raceDetailSelection, List<RaceInLeaderboardDTO> raceAllRaceColumns,
List<RaceInLeaderboardDTO> raceColumnSelection, long delayBetweenAutoAdvancesInMilliseconds, long delayInMilliseconds,
List<RaceInLeaderboardDTO> raceColumnSelection, boolean autoExpandFirstRace, long delayBetweenAutoAdvancesInMilliseconds, long delayInMilliseconds,
StringMessages stringConstants) {
this.maneuverDetailSelection = maneuverDetailSelection;
this.raceColumnSelection = raceColumnSelection;
@@ -50,6 +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.delayBetweenAutoAdvancesInMilliseconds = delayBetweenAutoAdvancesInMilliseconds;
this.delayInMilliseconds = delayInMilliseconds;
}
@@ -139,7 +141,7 @@ public class LeaderboardSettingsDialogComponent implements SettingsDialogCompone
}
Long delayBetweenAutoAdvancesValue = delayBetweenAutoAdvancesInSecondsBox.getValue();
Long delayInSecondsValue = delayInSecondsBox.getValue();
return new LeaderboardSettings(maneuverDetailsToShow, legDetailsToShow, raceDetailsToShow, raceColumnsToShow,
return new LeaderboardSettings(maneuverDetailsToShow, legDetailsToShow, raceDetailsToShow, raceColumnsToShow, autoExpandFirstRace,
1000l * (delayBetweenAutoAdvancesValue == null ? 0l : delayBetweenAutoAdvancesValue.longValue()),
1000 * (delayInSecondsValue==null?0:delayInSecondsValue.longValue()));
}