mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-30 17:36:40 +00:00
fix some bugs of timepanel/sliderbar
This commit is contained in:
1 parent
045206c607
commit
b436117928
7 files changed
+1231
-1155
No files matched your search
+26
-9
@@ -124,22 +124,36 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
|
|||||||
RaceIdentifier raceIdentifier = selectedRaces.get(selectedRaces.size() - 1);
|
RaceIdentifier raceIdentifier = selectedRaces.get(selectedRaces.size() - 1);
|
||||||
RaceDTO race = raceListBox.getRace(raceIdentifier);
|
RaceDTO race = raceListBox.getRace(raceIdentifier);
|
||||||
competitorSelectionProvider.setCompetitors(race.competitors);
|
competitorSelectionProvider.setCompetitors(race.competitors);
|
||||||
updateSlider(race);
|
|
||||||
if (race.startOfRace != null) {
|
updateTimePanel(race);
|
||||||
timePanel.timeChanged(race.startOfRace);
|
|
||||||
timer.setTime(race.startOfRace.getTime());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
raceMap.onRaceSelectionChange(selectedRaces);
|
raceMap.onRaceSelectionChange(selectedRaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSlider(RaceDTO selectedRace) {
|
private void updateTimePanel(RaceDTO selectedRace) {
|
||||||
|
Date min = null;
|
||||||
|
Date max = null;
|
||||||
|
|
||||||
if (selectedRace.startOfTracking != null) {
|
if (selectedRace.startOfTracking != null) {
|
||||||
timePanel.setMin(selectedRace.startOfTracking);
|
min = selectedRace.startOfTracking;
|
||||||
}
|
}
|
||||||
if (selectedRace.timePointOfNewestEvent != null) {
|
if (selectedRace.endOfRace != null) {
|
||||||
timePanel.setMax(selectedRace.timePointOfNewestEvent);
|
max = selectedRace.endOfRace;
|
||||||
|
} else if (selectedRace.timePointOfNewestEvent != null) {
|
||||||
|
max = selectedRace.timePointOfNewestEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(min != null && max != null)
|
||||||
|
timePanel.setMinMax(min, max);
|
||||||
|
|
||||||
|
// set initial timer position
|
||||||
|
switch(timer.getPlayMode()) {
|
||||||
|
case Live:
|
||||||
|
case Replay:
|
||||||
|
timer.setTime(selectedRace.startOfRace.getTime());
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
timePanel.setLegMarkers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -182,5 +196,8 @@ public class RaceMapPanel extends FormPanel implements EventDisplayer, TimeListe
|
|||||||
if (raceMap.map != null) {
|
if (raceMap.map != null) {
|
||||||
raceMap.map.onResize();
|
raceMap.map.onResize();
|
||||||
}
|
}
|
||||||
|
if (timePanel != null) {
|
||||||
|
timePanel.onResize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-2
@@ -191,7 +191,9 @@ public class RaceMapResources {
|
|||||||
// here it would be better to get the boat length from the boat class -> for now we assume a length of 5m
|
// here it would be better to get the boat length from the boat class -> for now we assume a length of 5m
|
||||||
double boatLengthInMeter = 5.0;
|
double boatLengthInMeter = 5.0;
|
||||||
if (zoomLevel > 5) {
|
if (zoomLevel > 5) {
|
||||||
int boatSizeXInPixel = imageSize.getWidth();
|
int boatLengthInPixel = imageSize.getHeight();
|
||||||
|
if(imageSize.getWidth() > boatLengthInPixel)
|
||||||
|
boatLengthInPixel = imageSize.getWidth();
|
||||||
LatLngBounds bounds = map.getBounds();
|
LatLngBounds bounds = map.getBounds();
|
||||||
if (bounds != null) {
|
if (bounds != null) {
|
||||||
LatLng upperRight = bounds.getNorthEast();
|
LatLng upperRight = bounds.getNorthEast();
|
||||||
@@ -200,7 +202,7 @@ public class RaceMapResources {
|
|||||||
double distXInMeters = upperLeft.distanceFrom(upperRight);
|
double distXInMeters = upperLeft.distanceFrom(upperRight);
|
||||||
int widthInPixel = map.getSize().getWidth();
|
int widthInPixel = map.getSize().getWidth();
|
||||||
double realBoatSizeInPixel = (widthInPixel * boatLengthInMeter) / distXInMeters;
|
double realBoatSizeInPixel = (widthInPixel * boatLengthInMeter) / distXInMeters;
|
||||||
realBoatSizeScaleFactor = realBoatSizeInPixel / (double) boatSizeXInPixel;
|
realBoatSizeScaleFactor = realBoatSizeInPixel / (double) boatLengthInPixel;
|
||||||
if (realBoatSizeScaleFactor < minScaleFactor) {
|
if (realBoatSizeScaleFactor < minScaleFactor) {
|
||||||
realBoatSizeScaleFactor = minScaleFactor;
|
realBoatSizeScaleFactor = minScaleFactor;
|
||||||
}
|
}
|
||||||
|
|||||||
+34
-11
@@ -19,6 +19,7 @@ import com.google.gwt.user.client.ui.HasVerticalAlignment;
|
|||||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||||
import com.google.gwt.user.client.ui.IntegerBox;
|
import com.google.gwt.user.client.ui.IntegerBox;
|
||||||
import com.google.gwt.user.client.ui.Label;
|
import com.google.gwt.user.client.ui.Label;
|
||||||
|
import com.google.gwt.user.client.ui.RequiresResize;
|
||||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||||
import com.google.gwt.user.client.ui.Widget;
|
import com.google.gwt.user.client.ui.Widget;
|
||||||
import com.sap.sailing.gwt.ui.client.Timer.PlayModes;
|
import com.sap.sailing.gwt.ui.client.Timer.PlayModes;
|
||||||
@@ -27,7 +28,7 @@ import com.sap.sailing.gwt.ui.shared.components.SettingsDialog;
|
|||||||
import com.sap.sailing.gwt.ui.shared.components.SettingsDialogComponent;
|
import com.sap.sailing.gwt.ui.shared.components.SettingsDialogComponent;
|
||||||
import com.sap.sailing.gwt.ui.shared.controls.SliderBar;
|
import com.sap.sailing.gwt.ui.shared.controls.SliderBar;
|
||||||
|
|
||||||
public class TimePanel extends FormPanel implements Component<TimePanelSettings>, TimeListener, PlayStateListener {
|
public class TimePanel extends FormPanel implements Component<TimePanelSettings>, TimeListener, PlayStateListener, RequiresResize {
|
||||||
private final Timer timer;
|
private final Timer timer;
|
||||||
private final Button playPauseButton;
|
private final Button playPauseButton;
|
||||||
private final IntegerBox playSpeedBox;
|
private final IntegerBox playSpeedBox;
|
||||||
@@ -67,9 +68,6 @@ public class TimePanel extends FormPanel implements Component<TimePanelSettings>
|
|||||||
|
|
||||||
sliderBar = new SliderBar();
|
sliderBar = new SliderBar();
|
||||||
sliderBar.setEnabled(true);
|
sliderBar.setEnabled(true);
|
||||||
sliderBar.setStepSize(60000);
|
|
||||||
sliderBar.setNumTickLabels(8);
|
|
||||||
sliderBar.setNumTicks(8);
|
|
||||||
sliderBar.setLabelFormatter(new SliderBar.LabelFormatter() {
|
sliderBar.setLabelFormatter(new SliderBar.LabelFormatter() {
|
||||||
final DateTimeFormat formatter = DateTimeFormat.getFormat("HH:mm");
|
final DateTimeFormat formatter = DateTimeFormat.getFormat("HH:mm");
|
||||||
@Override
|
@Override
|
||||||
@@ -224,7 +222,7 @@ public class TimePanel extends FormPanel implements Component<TimePanelSettings>
|
|||||||
switch(timer.getPlayMode()) {
|
switch(timer.getPlayMode()) {
|
||||||
case Live:
|
case Live:
|
||||||
playModeLabel.setText(stringMessages.playModeLive());
|
playModeLabel.setText(stringMessages.playModeLive());
|
||||||
timeDelayLabel.setText(((int) timer.getDelay() / 1000) + " s");
|
timeDelayLabel.setText(((int) timer.getCurrentDelay() / 1000) + " s");
|
||||||
break;
|
break;
|
||||||
case Replay:
|
case Replay:
|
||||||
playModeLabel.setText(stringMessages.playModeReplay());
|
playModeLabel.setText(stringMessages.playModeReplay());
|
||||||
@@ -233,22 +231,34 @@ public class TimePanel extends FormPanel implements Component<TimePanelSettings>
|
|||||||
playModeLabel.setText(timer.getPlayMode().name());
|
playModeLabel.setText(timer.getPlayMode().name());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMin(Date min) {
|
public void setMinMax(Date min, Date max) {
|
||||||
|
int numTicks = 8;
|
||||||
sliderBar.setMinValue(new Double(min.getTime()));
|
sliderBar.setMinValue(new Double(min.getTime()));
|
||||||
if (timer.getTime().before(min)) {
|
sliderBar.setMaxValue(new Double(max.getTime()));
|
||||||
timer.setTime((long) min.getTime());
|
sliderBar.setNumTickLabels(numTicks);
|
||||||
}
|
sliderBar.setNumTicks(numTicks);
|
||||||
|
double stepSize = (max.getTime() - min.getTime()) / numTicks;
|
||||||
|
sliderBar.setStepSize(stepSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMax(Date max) {
|
public void changeMax(Date max) {
|
||||||
sliderBar.setMaxValue(new Double(max.getTime()));
|
sliderBar.setMaxValue(new Double(max.getTime()));
|
||||||
if (timer.getTime().after(max)) {
|
if (timer.getTime().after(max)) {
|
||||||
timer.setTime((long) max.getTime());
|
timer.setTime((long) max.getTime());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void changeMin(Date min) {
|
||||||
|
sliderBar.setMinValue(new Double(min.getTime()));
|
||||||
|
if (timer.getTime().before(min)) {
|
||||||
|
timer.setTime((long) min.getTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setLegMarkers() {
|
public void setLegMarkers() {
|
||||||
if(sliderBar.isMinMaxInitialized()) {
|
if(sliderBar.isMinMaxInitialized()) {
|
||||||
|
sliderBar.clearMarkers();
|
||||||
|
|
||||||
Double minValue = sliderBar.getMinValue();
|
Double minValue = sliderBar.getMinValue();
|
||||||
Double maxValue = sliderBar.getMaxValue();
|
Double maxValue = sliderBar.getMaxValue();
|
||||||
int legCount = 5;
|
int legCount = 5;
|
||||||
@@ -256,7 +266,9 @@ public class TimePanel extends FormPanel implements Component<TimePanelSettings>
|
|||||||
double diff = (maxValue - minValue) / (double) legCount;
|
double diff = (maxValue - minValue) / (double) legCount;
|
||||||
|
|
||||||
for(int i = 0; i < legCount; i++)
|
for(int i = 0; i < legCount; i++)
|
||||||
sliderBar.addMarker("L" + i + 1, minValue + i * diff);
|
sliderBar.addMarker("L" + (i + 1), minValue + i * diff);
|
||||||
|
|
||||||
|
sliderBar.redraw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,4 +317,15 @@ public class TimePanel extends FormPanel implements Component<TimePanelSettings>
|
|||||||
public String getLocalizedShortName() {
|
public String getLocalizedShortName() {
|
||||||
return "Time control";
|
return "Time control";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onResize() {
|
||||||
|
// handle what is required by @link{ProvidesResize}
|
||||||
|
Widget child = getWidget();
|
||||||
|
if (child instanceof RequiresResize) {
|
||||||
|
((RequiresResize) child).onResize();
|
||||||
|
}
|
||||||
|
|
||||||
|
sliderBar.onResize();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+17
-11
@@ -20,6 +20,12 @@ public class Timer {
|
|||||||
*/
|
*/
|
||||||
private Date time;
|
private Date time;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The time delay to the current point in time in millisseconds
|
||||||
|
* will only be used in live play mode
|
||||||
|
*/
|
||||||
|
private long livePlayDelayInMs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Listeners interested in changes of {@link #time}
|
* Listeners interested in changes of {@link #time}
|
||||||
*/
|
*/
|
||||||
@@ -80,6 +86,7 @@ public class Timer {
|
|||||||
playStateListeners = new HashSet<PlayStateListener>();
|
playStateListeners = new HashSet<PlayStateListener>();
|
||||||
playing = false;
|
playing = false;
|
||||||
playSpeedFactor = 1.0;
|
playSpeedFactor = 1.0;
|
||||||
|
livePlayDelayInMs = 0;
|
||||||
this.delayBetweenAutoAdvancesInMilliseconds = delayBetweenAutoAdvancesInMilliseconds;
|
this.delayBetweenAutoAdvancesInMilliseconds = delayBetweenAutoAdvancesInMilliseconds;
|
||||||
this.playMode = playMode;
|
this.playMode = playMode;
|
||||||
}
|
}
|
||||||
@@ -149,6 +156,10 @@ public class Timer {
|
|||||||
public void resume() {
|
public void resume() {
|
||||||
if (!playing) {
|
if (!playing) {
|
||||||
playing = !playing;
|
playing = !playing;
|
||||||
|
|
||||||
|
if(playMode == PlayModes.Live)
|
||||||
|
setTime(System.currentTimeMillis()-livePlayDelayInMs);
|
||||||
|
|
||||||
startAutoAdvance();
|
startAutoAdvance();
|
||||||
for (PlayStateListener playStateListener : playStateListeners) {
|
for (PlayStateListener playStateListener : playStateListeners) {
|
||||||
playStateListener.playStateChanged(playing);
|
playStateListener.playStateChanged(playing);
|
||||||
@@ -179,20 +190,15 @@ public class Timer {
|
|||||||
Scheduler.get().scheduleFixedPeriod(command, (int) delayBetweenAutoAdvancesInMilliseconds);
|
Scheduler.get().scheduleFixedPeriod(command, (int) delayBetweenAutoAdvancesInMilliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Indirect way of setting this timer to a specific point in time, namely to "now" - <code>delayInMilliseconds</code>.
|
|
||||||
*/
|
|
||||||
public void setDelay(long delayInMilliseconds) {
|
public void setDelay(long delayInMilliseconds) {
|
||||||
if(playMode == PlayModes.Replay)
|
this.livePlayDelayInMs = delayInMilliseconds;
|
||||||
return;
|
}
|
||||||
|
|
||||||
setTime(System.currentTimeMillis()-delayInMilliseconds);
|
public long getDelay() {
|
||||||
|
return livePlayDelayInMs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getDelay() {
|
public long getCurrentDelay() {
|
||||||
if(playMode == PlayModes.Replay)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return System.currentTimeMillis() - getTime().getTime();
|
return System.currentTimeMillis() - getTime().getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+83
-55
@@ -4,15 +4,18 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.google.gwt.user.client.Window;
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
|
||||||
import com.google.gwt.user.client.ui.FlowPanel;
|
import com.google.gwt.user.client.ui.FlowPanel;
|
||||||
import com.google.gwt.user.client.ui.RootPanel;
|
import com.google.gwt.user.client.ui.RootPanel;
|
||||||
import com.sap.sailing.domain.common.DefaultLeaderboardName;
|
import com.sap.sailing.domain.common.DefaultLeaderboardName;
|
||||||
import com.sap.sailing.domain.common.RaceIdentifier;
|
import com.sap.sailing.domain.common.RaceIdentifier;
|
||||||
import com.sap.sailing.gwt.ui.client.AbstractEntryPoint;
|
import com.sap.sailing.gwt.ui.client.AbstractEntryPoint;
|
||||||
import com.sap.sailing.gwt.ui.client.LogoAndTitlePanel;
|
import com.sap.sailing.gwt.ui.client.LogoAndTitlePanel;
|
||||||
|
import com.sap.sailing.gwt.ui.client.ParallelExecutionCallback;
|
||||||
|
import com.sap.sailing.gwt.ui.client.ParallelExecutionHolder;
|
||||||
import com.sap.sailing.gwt.ui.client.RaceSelectionModel;
|
import com.sap.sailing.gwt.ui.client.RaceSelectionModel;
|
||||||
import com.sap.sailing.gwt.ui.shared.EventDTO;
|
import com.sap.sailing.gwt.ui.shared.EventDTO;
|
||||||
|
import com.sap.sailing.gwt.ui.shared.LeaderboardDTO;
|
||||||
|
import com.sap.sailing.gwt.ui.shared.LeaderboardGroupDTO;
|
||||||
import com.sap.sailing.gwt.ui.shared.RaceDTO;
|
import com.sap.sailing.gwt.ui.shared.RaceDTO;
|
||||||
import com.sap.sailing.gwt.ui.shared.RegattaDTO;
|
import com.sap.sailing.gwt.ui.shared.RegattaDTO;
|
||||||
|
|
||||||
@@ -20,75 +23,100 @@ public class RaceBoardEntryPoint extends AbstractEntryPoint {
|
|||||||
private RaceDTO selectedRace;
|
private RaceDTO selectedRace;
|
||||||
private RaceBoardPanel raceBoardPanel;
|
private RaceBoardPanel raceBoardPanel;
|
||||||
|
|
||||||
|
private String eventName;
|
||||||
|
private String raceName;
|
||||||
|
private String leaderboardName;
|
||||||
|
private String leaderboardGroupName;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onModuleLoad() {
|
public void onModuleLoad() {
|
||||||
super.onModuleLoad();
|
super.onModuleLoad();
|
||||||
|
|
||||||
final String eventName = Window.Location.getParameter("eventName");
|
eventName = Window.Location.getParameter("eventName");
|
||||||
final String raceName = Window.Location.getParameter("raceName");
|
raceName = Window.Location.getParameter("raceName");
|
||||||
String leaderboardNameParamValue = Window.Location.getParameter("leaderboardName");
|
String leaderboardNameParamValue = Window.Location.getParameter("leaderboardName");
|
||||||
//String leaderboardGroupNameParamValue = Window.Location.getParameter("leaderboardGroupName");
|
String leaderboardGroupNameParamValue = Window.Location.getParameter("leaderboardGroupName");
|
||||||
final String leaderboardName;
|
|
||||||
//final String leaderboardGroupName;
|
|
||||||
if(leaderboardNameParamValue == null || leaderboardNameParamValue.isEmpty()) {
|
if(leaderboardNameParamValue == null || leaderboardNameParamValue.isEmpty()) {
|
||||||
leaderboardName = DefaultLeaderboardName.DEFAULT_LEADERBOARD_NAME;
|
leaderboardName = DefaultLeaderboardName.DEFAULT_LEADERBOARD_NAME;
|
||||||
} else {
|
} else {
|
||||||
leaderboardName = leaderboardNameParamValue;
|
leaderboardName = leaderboardNameParamValue;
|
||||||
sailingService.getLeaderboardNames(new AsyncCallback<List<String>>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(List<String> leaderboardNames) {
|
|
||||||
if (!leaderboardNames.contains(leaderboardName)) {
|
|
||||||
createErrorPage(stringMessages.noSuchLeaderboard());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(Throwable t) {
|
|
||||||
reportError("Error trying to obtain the list of leaderboard names: " + t.getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
/* not used yet.... waiting for the leaderboard group functionality
|
|
||||||
if(leaderboardGroupNameParamValue != null && !leaderboardGroupNameParamValue.isEmpty()))
|
|
||||||
{
|
|
||||||
sailingService.getLeaderboardGroupByName(leaderboardGroupNameParamValue, new AsyncCallback<LeaderboardGroupDTO>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(LeaderboardGroupDTO leaderboardGroup) {
|
|
||||||
for(leaderboardGroup.leaderboards.contains()
|
|
||||||
if (!leaderboardNames.contains(leaderboardName)) {
|
|
||||||
createErrorPage(stringMessages.noSuchLeaderboard());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
if(leaderboardGroupNameParamValue != null && !leaderboardGroupNameParamValue.isEmpty())
|
||||||
public void onFailure(Throwable t) {
|
leaderboardGroupName = leaderboardGroupNameParamValue;
|
||||||
reportError("Error trying to obtain the list of leaderboard names: " + t.getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (eventName != null && !eventName.isEmpty() && raceName != null && !raceName.isEmpty()) {
|
|
||||||
sailingService.listEvents(false, new AsyncCallback<List<EventDTO>>() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(List<EventDTO> events) {
|
|
||||||
selectedRace = findRace(eventName, raceName, events);
|
|
||||||
if(selectedRace != null) {
|
|
||||||
createRaceBoardPanel(selectedRace, events, eventName, leaderboardName);
|
|
||||||
} else {
|
|
||||||
createErrorPage("Could not obtain a race with name " + raceName + " for an event with name " + eventName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
if (eventName == null || eventName.isEmpty() || raceName == null || raceName.isEmpty()) {
|
||||||
public void onFailure(Throwable t) {
|
|
||||||
reportError("Error trying to obtain the list of events: " + t.getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
createErrorPage("This page requires a valid event name and race name.");
|
createErrorPage("This page requires a valid event name and race name.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final ParallelExecutionCallback<List<String>> getLeaderboardNamesCallback = new ParallelExecutionCallback<List<String>>();
|
||||||
|
final ParallelExecutionCallback<List<EventDTO>> listEventsCallback = new ParallelExecutionCallback<List<EventDTO>>();
|
||||||
|
final ParallelExecutionCallback<LeaderboardGroupDTO> getLeaderboardGroupByNameCallback = new ParallelExecutionCallback<LeaderboardGroupDTO>();
|
||||||
|
|
||||||
|
if (leaderboardGroupName != null) {
|
||||||
|
new ParallelExecutionHolder(getLeaderboardNamesCallback, getLeaderboardGroupByNameCallback, listEventsCallback) {
|
||||||
|
@Override
|
||||||
|
public void handleSuccess() {
|
||||||
|
checkUrlParameters(getLeaderboardNamesCallback.getData(),
|
||||||
|
getLeaderboardGroupByNameCallback.getData(), listEventsCallback.getData());
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void handleFailure(Throwable t) {
|
||||||
|
reportError("Error trying to create the raceboard: " + t.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
new ParallelExecutionHolder(getLeaderboardNamesCallback, listEventsCallback) {
|
||||||
|
@Override
|
||||||
|
public void handleSuccess() {
|
||||||
|
checkUrlParameters(getLeaderboardNamesCallback.getData(), null, listEventsCallback.getData());
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void handleFailure(Throwable t) {
|
||||||
|
reportError("Error trying to create the raceboard: " + t.getMessage());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
sailingService.listEvents(false, listEventsCallback);
|
||||||
|
sailingService.getLeaderboardNames(getLeaderboardNamesCallback);
|
||||||
|
if(leaderboardGroupName != null)
|
||||||
|
sailingService.getLeaderboardGroupByName(leaderboardGroupNameParamValue, getLeaderboardGroupByNameCallback);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkUrlParameters(List<String> leaderboardNames, LeaderboardGroupDTO leaderboardGroup, List<EventDTO> events)
|
||||||
|
{
|
||||||
|
if (!leaderboardNames.contains(leaderboardName)) {
|
||||||
|
createErrorPage(stringMessages.noSuchLeaderboard());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (leaderboardGroupName != null && leaderboardGroup != null) {
|
||||||
|
boolean foundLeaderboard = false;
|
||||||
|
for(LeaderboardDTO leaderBoard: leaderboardGroup.leaderboards) {
|
||||||
|
if(leaderBoard.name.equals(leaderboardName)) {
|
||||||
|
foundLeaderboard = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!foundLeaderboard) {
|
||||||
|
createErrorPage("the leaderboard is not contained in this leaderboard group.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedRace = findRace(eventName, raceName, events);
|
||||||
|
if(selectedRace == null) {
|
||||||
|
createErrorPage("Could not obtain a race with name " + raceName + " for an event with name " + eventName);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
createRaceBoardPanel(selectedRace, events, eventName, leaderboardName);
|
||||||
|
}
|
||||||
|
|
||||||
private RaceDTO findRace(String eventName, String raceName, List<EventDTO> events) {
|
private RaceDTO findRace(String eventName, String raceName, List<EventDTO> events) {
|
||||||
for (EventDTO eventDTO : events) {
|
for (EventDTO eventDTO : events) {
|
||||||
if(eventDTO.name.equals(eventName)) {
|
if(eventDTO.name.equals(eventName)) {
|
||||||
|
|||||||
+18
-5
@@ -2,6 +2,7 @@ package com.sap.sailing.gwt.ui.raceboard;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -189,16 +190,28 @@ public class RaceBoardPanel extends FormPanel implements EventDisplayer, RaceSel
|
|||||||
public void onRaceSelectionChange(List<RaceIdentifier> selectedRaces) {
|
public void onRaceSelectionChange(List<RaceIdentifier> selectedRaces) {
|
||||||
if (selectedRaces != null && !selectedRaces.isEmpty()) {
|
if (selectedRaces != null && !selectedRaces.isEmpty()) {
|
||||||
RaceDTO selectedRace = racesByIdentifier.get(selectedRaces.iterator().next());
|
RaceDTO selectedRace = racesByIdentifier.get(selectedRaces.iterator().next());
|
||||||
|
|
||||||
|
Date min = null;
|
||||||
|
Date max = null;
|
||||||
|
|
||||||
if (selectedRace.startOfTracking != null) {
|
if (selectedRace.startOfTracking != null) {
|
||||||
timePanel.setMin(selectedRace.startOfTracking);
|
min = selectedRace.startOfTracking;
|
||||||
}
|
}
|
||||||
if (selectedRace.endOfRace != null) {
|
if (selectedRace.endOfRace != null) {
|
||||||
timePanel.setMax(selectedRace.endOfRace);
|
max = selectedRace.endOfRace;
|
||||||
} else if (selectedRace.timePointOfNewestEvent != null) {
|
} else if (selectedRace.timePointOfNewestEvent != null) {
|
||||||
timePanel.setMax(selectedRace.timePointOfNewestEvent);
|
max = selectedRace.timePointOfNewestEvent;
|
||||||
}
|
}
|
||||||
if (selectedRace.startOfRace != null) {
|
|
||||||
timer.setTime(selectedRace.startOfRace.getTime());
|
if(min != null && max != null)
|
||||||
|
timePanel.setMinMax(min, max);
|
||||||
|
|
||||||
|
// set initial timer position
|
||||||
|
switch(timer.getPlayMode()) {
|
||||||
|
case Live:
|
||||||
|
case Replay:
|
||||||
|
timer.setTime(selectedRace.startOfRace.getTime());
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
timePanel.setLegMarkers();
|
timePanel.setLegMarkers();
|
||||||
}
|
}
|
||||||
|
|||||||
+1049
-1062
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user