mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-03 10:53:49 +00:00
Added refresh interval to the settings of the TimePanel
This commit is contained in:
1 parent
647380484f
commit
1ca82c010a
9 files changed
+77
-27
No files matched your search
+17
@@ -10,6 +10,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.Button;
|
||||
import com.google.gwt.user.client.ui.CheckBox;
|
||||
import com.google.gwt.user.client.ui.DialogBox;
|
||||
import com.google.gwt.user.client.ui.DoubleBox;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.IntegerBox;
|
||||
import com.google.gwt.user.client.ui.Label;
|
||||
@@ -175,6 +176,22 @@ public abstract class DataEntryDialog<T> {
|
||||
return longBox;
|
||||
}
|
||||
|
||||
public DoubleBox createDoubleBox(double initialValue, int visibleLength) {
|
||||
DoubleBox doubleBox = new DoubleBox();
|
||||
doubleBox.setVisibleLength(visibleLength);
|
||||
doubleBox.setValue(initialValue);
|
||||
AbstractEntryPoint.addFocusUponKeyUpToggler(doubleBox);
|
||||
doubleBox.addChangeHandler(new ChangeHandler() {
|
||||
@Override
|
||||
public void onChange(ChangeEvent event) {
|
||||
validate();
|
||||
}
|
||||
});
|
||||
AbstractEntryPoint.linkEnterToButton(getOkButton(), doubleBox);
|
||||
AbstractEntryPoint.linkEscapeToButton(getCancelButton(), doubleBox);
|
||||
return doubleBox;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a box for a integer value with a key-up listener attached which ensures the value is updated after each
|
||||
* key-up event and the entire dialog is {@link #validate() validated} in this case.
|
||||
|
||||
+2
@@ -252,4 +252,6 @@ public interface StringMessages extends Messages {
|
||||
String noLeaderboardGroupToLoad();
|
||||
String bearing();
|
||||
String zoom();
|
||||
String refreshInterval();
|
||||
String refreshIntervalMustBeGreaterThanXSeconds(String seconds);
|
||||
}
|
||||
+3
-1
@@ -246,4 +246,6 @@ autoZoomTails=Tails
|
||||
autoZoomSelectedCompetitors=Zoom only to selected competitors
|
||||
noLeaderboardGroupToLoad=No leaderboard group name was given
|
||||
bearing=Bearing
|
||||
zoom=Zoom
|
||||
zoom=Zoom
|
||||
refreshInterval=Refresh interval
|
||||
refreshIntervalMustBeGreaterThanXSeconds=Refresh interval must be greater than {0} seconds
|
||||
+3
-1
@@ -247,4 +247,6 @@ autoZoomTails=Schweife
|
||||
autoZoomSelectedCompetitors=Nur zu ausgewählten Seglern zoomen
|
||||
noLeaderboardGroupToLoad=Es wurde kein Ranglisten-Gruppenname übergeben
|
||||
bearing=Kurs über Grund
|
||||
zoom=Zoom
|
||||
zoom=Zoom
|
||||
refreshInterval=Aktualisierungs-Interval
|
||||
refreshIntervalMustBeGreaterThanXSeconds=Aktualisierungs-Interval muss größer als {0} Sekunden sein
|
||||
@@ -363,6 +363,8 @@ public class TimePanel extends FormPanel implements Component<TimePanelSettings>
|
||||
timeDelayLabel.setText(String.valueOf(newSettings.getDelayToLivePlayInSeconds()) + " s");
|
||||
delayChanged();
|
||||
}
|
||||
getSettings().setRefreshInterval(newSettings.getRefreshInterval());
|
||||
timer.setRefreshInterval(getSettings().getRefreshInterval());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+10
@@ -2,9 +2,11 @@ package com.sap.sailing.gwt.ui.client;
|
||||
|
||||
public class TimePanelSettings {
|
||||
private int delayToLivePlayInSeconds;
|
||||
private long refreshInterval;
|
||||
|
||||
public TimePanelSettings() {
|
||||
delayToLivePlayInSeconds = 0;
|
||||
refreshInterval = 1000;
|
||||
}
|
||||
|
||||
public int getDelayToLivePlayInSeconds() {
|
||||
@@ -15,4 +17,12 @@ public class TimePanelSettings {
|
||||
this.delayToLivePlayInSeconds = delayToLivePlayInSeconds;
|
||||
}
|
||||
|
||||
public long getRefreshInterval() {
|
||||
return refreshInterval;
|
||||
}
|
||||
|
||||
public void setRefreshInterval(long refreshInterval) {
|
||||
this.refreshInterval = refreshInterval;
|
||||
}
|
||||
|
||||
}
|
||||
+18
-4
@@ -1,5 +1,6 @@
|
||||
package com.sap.sailing.gwt.ui.client;
|
||||
|
||||
import com.google.gwt.user.client.ui.DoubleBox;
|
||||
import com.google.gwt.user.client.ui.FocusWidget;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.IntegerBox;
|
||||
@@ -11,6 +12,7 @@ import com.sap.sailing.gwt.ui.shared.components.SettingsDialogComponent;
|
||||
|
||||
public class TimePanelSettingsDialogComponent implements SettingsDialogComponent<TimePanelSettings> {
|
||||
private IntegerBox timeDelayBox;
|
||||
private DoubleBox refreshIntervalBox;
|
||||
private final StringMessages stringMessages;
|
||||
private final TimePanelSettings initialSettings;
|
||||
|
||||
@@ -22,11 +24,19 @@ public class TimePanelSettingsDialogComponent implements SettingsDialogComponent
|
||||
@Override
|
||||
public Widget getAdditionalWidget(DataEntryDialog<TimePanelSettings> dialog) {
|
||||
VerticalPanel vp = new VerticalPanel();
|
||||
HorizontalPanel labelAndTailLengthBoxPanel = new HorizontalPanel();
|
||||
labelAndTailLengthBoxPanel.add(new Label(stringMessages.timeDelay()));
|
||||
|
||||
HorizontalPanel labelAndTimeDelayBoxPanel = new HorizontalPanel();
|
||||
labelAndTimeDelayBoxPanel.add(new Label(stringMessages.timeDelay()));
|
||||
timeDelayBox = dialog.createIntegerBox((int) initialSettings.getDelayToLivePlayInSeconds(), 4);
|
||||
labelAndTailLengthBoxPanel.add(timeDelayBox);
|
||||
vp.add(labelAndTailLengthBoxPanel);
|
||||
labelAndTimeDelayBoxPanel.add(timeDelayBox);
|
||||
vp.add(labelAndTimeDelayBoxPanel);
|
||||
|
||||
HorizontalPanel labelAndRefreshIntervalBoxPanel = new HorizontalPanel();
|
||||
labelAndRefreshIntervalBoxPanel.add(new Label(stringMessages.refreshInterval()));
|
||||
refreshIntervalBox = dialog.createDoubleBox(((double) initialSettings.getRefreshInterval()) / 1000, 4);
|
||||
labelAndRefreshIntervalBoxPanel.add(refreshIntervalBox);
|
||||
vp.add(labelAndRefreshIntervalBoxPanel);
|
||||
|
||||
return vp;
|
||||
}
|
||||
|
||||
@@ -34,6 +44,7 @@ public class TimePanelSettingsDialogComponent implements SettingsDialogComponent
|
||||
public TimePanelSettings getResult() {
|
||||
TimePanelSettings result = new TimePanelSettings();
|
||||
result.setDelayToLivePlayInSeconds(timeDelayBox.getValue() == null ? -1 : timeDelayBox.getValue());
|
||||
result.setRefreshInterval(refreshIntervalBox.getValue() == null ? -1 : (long) (refreshIntervalBox.getValue() * 1000));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -46,6 +57,9 @@ public class TimePanelSettingsDialogComponent implements SettingsDialogComponent
|
||||
if (valueToValidate.getDelayToLivePlayInSeconds() < 0) {
|
||||
errorMessage = stringMessages.tailLengthMustBeNonNegative();
|
||||
}
|
||||
if (valueToValidate.getRefreshInterval() < 500) {
|
||||
errorMessage = stringMessages.refreshIntervalMustBeGreaterThanXSeconds("0.5");
|
||||
}
|
||||
return errorMessage;
|
||||
}
|
||||
};
|
||||
|
||||
+20
-19
@@ -37,7 +37,7 @@ public class Timer {
|
||||
private final Set<PlayStateListener> playStateListeners;
|
||||
|
||||
/**
|
||||
* If <code>Playing</code>, an auto-refreshing command is running with {@link #delayBetweenAutoAdvancesInMilliseconds}
|
||||
* If <code>Playing</code>, an auto-refreshing command is running with {@link #refreshInterval}
|
||||
* as its refresh interval.
|
||||
*/
|
||||
private PlayStates playState;
|
||||
@@ -48,15 +48,15 @@ public class Timer {
|
||||
private PlayModes playMode;
|
||||
|
||||
/**
|
||||
* The refresh interval for auto-updating this timer
|
||||
* The refresh interval in milliseconds for auto-updating this timer
|
||||
*/
|
||||
private long delayBetweenAutoAdvancesInMilliseconds;
|
||||
private long refreshInterval;
|
||||
|
||||
/**
|
||||
* Set to <code>true</code> if the delay changed while {@link #playing}. This forces the auto-refreshing command
|
||||
* to re-schedule itself with the new delay, then terminate.
|
||||
* Set to <code>true</code> if the refreshInterval changed while {@link #playing}. This forces the auto-refreshing command
|
||||
* to re-schedule itself with the new interval, then terminate.
|
||||
*/
|
||||
private boolean delayBetweenAutoAdvancesChanged;
|
||||
private boolean refreshIntervalChanged;
|
||||
|
||||
/**
|
||||
* Factor by which the timer runs faster than real time. 1.0 means real-time, 2.0 means twice as fast as real time, and so on.
|
||||
@@ -69,7 +69,7 @@ public class Timer {
|
||||
|
||||
/**
|
||||
* The timer is created in stopped state, using "now" as its current time, 1.0 as its {@link #playSpeedFactor play speed factor} and
|
||||
* 1 second (1000ms) as the {@link #delayBetweenAutoAdvancesInMilliseconds delay between automatic updates} should the timer be
|
||||
* 1 second (1000ms) as the {@link #refreshInterval delay between automatic updates} should the timer be
|
||||
* {@link #resume() started}.
|
||||
*/
|
||||
public Timer(PlayModes playMode) {
|
||||
@@ -79,11 +79,11 @@ public class Timer {
|
||||
/**
|
||||
* The timer is created in stopped state, using "now" as its current time, 1.0 as its {@link #playSpeedFactor
|
||||
* acceleration factor} and <code>delayBetweenAutoAdvancesInMilliseconds</code> as the
|
||||
* {@link #delayBetweenAutoAdvancesInMilliseconds delay between automatic updates} should the timer be
|
||||
* {@link #refreshInterval delay between automatic updates} should the timer be
|
||||
* {@link #resume() started}.
|
||||
*/
|
||||
public Timer(PlayModes playMode, long delayBetweenAutoAdvancesInMilliseconds) {
|
||||
this.delayBetweenAutoAdvancesInMilliseconds = delayBetweenAutoAdvancesInMilliseconds;
|
||||
public Timer(PlayModes playMode, long refreshInterval) {
|
||||
this.refreshInterval = refreshInterval;
|
||||
this.playMode = playMode;
|
||||
time = new Date();
|
||||
timeListeners = new HashSet<TimeListener>();
|
||||
@@ -125,15 +125,15 @@ public class Timer {
|
||||
this.playSpeedFactor = playSpeedFactor;
|
||||
}
|
||||
|
||||
public void setDelayBetweenAutoAdvancesInMilliseconds(long delayBetweenAutoAdvancesInMilliseconds) {
|
||||
this.delayBetweenAutoAdvancesInMilliseconds = delayBetweenAutoAdvancesInMilliseconds;
|
||||
public void setRefreshInterval(long refreshInterval) {
|
||||
this.refreshInterval = refreshInterval;
|
||||
if (playState == PlayStates.Playing) {
|
||||
delayBetweenAutoAdvancesChanged = true;
|
||||
refreshIntervalChanged = true;
|
||||
}
|
||||
}
|
||||
|
||||
public long getDelayBetweenAutoAdvancesInMilliseconds() {
|
||||
return delayBetweenAutoAdvancesInMilliseconds;
|
||||
public long getRefreshInterval() {
|
||||
return refreshInterval;
|
||||
}
|
||||
|
||||
public Date getTime() {
|
||||
@@ -207,10 +207,10 @@ public class Timer {
|
||||
@Override
|
||||
public boolean execute() {
|
||||
if (time != null) {
|
||||
setTime(time.getTime() + (long) (playSpeedFactor * delayBetweenAutoAdvancesInMilliseconds));
|
||||
setTime(time.getTime() + (long) (playSpeedFactor * refreshInterval));
|
||||
}
|
||||
if (delayBetweenAutoAdvancesChanged) {
|
||||
delayBetweenAutoAdvancesChanged = false;
|
||||
if (refreshIntervalChanged) {
|
||||
refreshIntervalChanged = false;
|
||||
scheduleAdvancerCommand(this);
|
||||
return false; // stop this command; use the newly-scheduled one instead that uses the new frequency
|
||||
} else {
|
||||
@@ -222,7 +222,7 @@ public class Timer {
|
||||
}
|
||||
|
||||
private void scheduleAdvancerCommand(RepeatingCommand command) {
|
||||
Scheduler.get().scheduleFixedPeriod(command, (int) delayBetweenAutoAdvancesInMilliseconds);
|
||||
Scheduler.get().scheduleFixedPeriod(command, (int) refreshInterval);
|
||||
}
|
||||
|
||||
public void setDelay(long delayInMilliseconds) {
|
||||
@@ -247,4 +247,5 @@ public class Timer {
|
||||
public PlayModes getPlayMode() {
|
||||
return playMode;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -250,7 +250,7 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
|
||||
updateLeaderboard(leaderboard);
|
||||
setAutoExpandFirstRace(newSettings.isAutoExpandFirstRace());
|
||||
|
||||
timer.setDelayBetweenAutoAdvancesInMilliseconds(newSettings.getDelayBetweenAutoAdvancesInMilliseconds());
|
||||
timer.setRefreshInterval(newSettings.getDelayBetweenAutoAdvancesInMilliseconds());
|
||||
setDelayInMilliseconds(newSettings.getDelayInMilliseconds());
|
||||
for (ExpandableSortableColumn<?> expandableSortableColumn : columnsToExpandAgain) {
|
||||
expandableSortableColumn.toggleExpansion();
|
||||
@@ -1534,7 +1534,7 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
|
||||
Collections.unmodifiableList(selectedLegDetails),
|
||||
Collections.unmodifiableList(selectedRaceDetails), /* All races to select */
|
||||
leaderboard.getRaceList(), selectedRaceColumns,
|
||||
autoExpandFirstRace, timer.getDelayBetweenAutoAdvancesInMilliseconds(), delayInMilliseconds, stringMessages);
|
||||
autoExpandFirstRace, timer.getRefreshInterval(), delayInMilliseconds, stringMessages);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user