mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-14 22:43:57 +00:00
added sequence node for race end case
This commit is contained in:
1 parent
90bbc4bbbe
commit
e916095de4
6 files changed
+93
-88
No files matched your search
+10
-28
@@ -1,41 +1,23 @@
|
||||
package com.sap.sailing.gwt.autoplay.client.nodes;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sap.sailing.gwt.autoplay.client.app.AutoPlayClientFactory;
|
||||
import com.sap.sailing.gwt.autoplay.client.events.AutoPlayHeaderEvent;
|
||||
import com.sap.sailing.gwt.autoplay.client.nodes.base.FiresPlaceNode;
|
||||
import com.sap.sailing.gwt.home.communication.event.minileaderboard.GetMiniLeaderboardDTO;
|
||||
import com.sap.sailing.gwt.home.communication.event.minileaderboard.GetMiniLeaderbordAction;
|
||||
import com.sap.sse.gwt.dispatch.shared.commands.ResultWithTTL;
|
||||
import com.sap.sailing.gwt.autoplay.client.places.screens.preliveraceloop.leaderboard.AbstractPreRaceLeaderBoardWithImagePlace;
|
||||
import com.sap.sailing.gwt.autoplay.client.places.screens.preliveraceloop.leaderboard.PreRaceLeaderBoardWithCompetitorPlace;
|
||||
|
||||
public class PreLeaderBoardWithFlagsNode extends FiresPlaceNode {
|
||||
public class PreLeaderBoardWithCompetitorsNode extends FiresPlaceNode {
|
||||
private final AutoPlayClientFactory cf;
|
||||
|
||||
public PreLeaderBoardWithFlagsNode(AutoPlayClientFactory cf) {
|
||||
public PreLeaderBoardWithCompetitorsNode(AutoPlayClientFactory cf) {
|
||||
this.cf = cf;
|
||||
}
|
||||
|
||||
|
||||
public void onStart() {
|
||||
|
||||
UUID eventId = cf.getAutoPlayCtx().getContextDefinition().getEventId();
|
||||
String leaderBoardName = cf.getAutoPlayCtx().getContextDefinition().getLeaderboardName();
|
||||
cf.getDispatch().execute(new GetMiniLeaderbordAction(eventId, leaderBoardName),
|
||||
new AsyncCallback<ResultWithTTL<GetMiniLeaderboardDTO>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// fireEvent(new DataLoadFailureEvent(MiniLeaderboardLoader.this, caught));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ResultWithTTL<GetMiniLeaderboardDTO> resultTTL) {
|
||||
/*
|
||||
* GetMiniLeaderboardDTO dto = resultTTL.getDto(); AbstractPreRaceLeaderBoardWithImagePlace
|
||||
* place = new AbstractPreRaceLeaderBoardWithImagePlace(); place.setLeaderBoardDTO(dto);
|
||||
* setPlaceToGo(place); firePlaceChangeAndStartTimer();
|
||||
*/
|
||||
}
|
||||
});
|
||||
AbstractPreRaceLeaderBoardWithImagePlace place = new PreRaceLeaderBoardWithCompetitorPlace();
|
||||
setPlaceToGo(place);
|
||||
firePlaceChangeAndStartTimer();
|
||||
getBus().fireEvent(new AutoPlayHeaderEvent(cf.getAutoPlayCtx().getLifeRace().getRegattaName(),
|
||||
cf.getAutoPlayCtx().getLifeRace().getRaceName()));
|
||||
};
|
||||
}
|
||||
-41
@@ -1,41 +0,0 @@
|
||||
package com.sap.sailing.gwt.autoplay.client.nodes;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sap.sailing.gwt.autoplay.client.app.AutoPlayClientFactory;
|
||||
import com.sap.sailing.gwt.autoplay.client.nodes.base.FiresPlaceNode;
|
||||
import com.sap.sailing.gwt.home.communication.event.minileaderboard.GetMiniLeaderboardDTO;
|
||||
import com.sap.sailing.gwt.home.communication.event.minileaderboard.GetMiniLeaderbordAction;
|
||||
import com.sap.sse.gwt.dispatch.shared.commands.ResultWithTTL;
|
||||
|
||||
public class PreLeaderBoardWithFlagsNode extends FiresPlaceNode {
|
||||
private final AutoPlayClientFactory cf;
|
||||
|
||||
public PreLeaderBoardWithFlagsNode(AutoPlayClientFactory cf) {
|
||||
this.cf = cf;
|
||||
}
|
||||
|
||||
|
||||
public void onStart() {
|
||||
|
||||
UUID eventId = cf.getAutoPlayCtx().getContextDefinition().getEventId();
|
||||
String leaderBoardName = cf.getAutoPlayCtx().getContextDefinition().getLeaderboardName();
|
||||
cf.getDispatch().execute(new GetMiniLeaderbordAction(eventId, leaderBoardName),
|
||||
new AsyncCallback<ResultWithTTL<GetMiniLeaderboardDTO>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// fireEvent(new DataLoadFailureEvent(MiniLeaderboardLoader.this, caught));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ResultWithTTL<GetMiniLeaderboardDTO> resultTTL) {
|
||||
/*
|
||||
* GetMiniLeaderboardDTO dto = resultTTL.getDto(); AbstractPreRaceLeaderBoardWithImagePlace
|
||||
* place = new AbstractPreRaceLeaderBoardWithImagePlace(); place.setLeaderBoardDTO(dto);
|
||||
* setPlaceToGo(place); firePlaceChangeAndStartTimer();
|
||||
*/
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
+11
-9
@@ -4,6 +4,7 @@ import com.google.gwt.user.client.Command;
|
||||
import com.sap.sailing.gwt.autoplay.client.app.AutoPlayClientFactory;
|
||||
import com.sap.sailing.gwt.autoplay.client.events.FailureEvent;
|
||||
import com.sap.sailing.gwt.autoplay.client.nodes.base.AutoPlayLoopNode;
|
||||
import com.sap.sailing.gwt.autoplay.client.nodes.base.AutoPlaySequenceNode;
|
||||
import com.sap.sailing.gwt.autoplay.client.nodes.base.RootNodeBase;
|
||||
import com.sap.sailing.gwt.autoplay.client.nodes.base.RootNodeState;
|
||||
|
||||
@@ -12,30 +13,31 @@ public class RootNodeSixtyInch extends RootNodeBase {
|
||||
private final AutoPlayLoopNode idleLoop;
|
||||
private final AutoPlayLoopNode preLiveRaceLoop;
|
||||
private final AutoPlayLoopNode liveRaceLoop;
|
||||
private final AutoPlayLoopNode afterLiveRaceLoop;
|
||||
private final AutoPlaySequenceNode afterLiveRaceLoop;
|
||||
protected boolean afterRaceFinished = true;
|
||||
|
||||
public RootNodeSixtyInch(AutoPlayClientFactory cf) {
|
||||
super(cf);
|
||||
this.idleLoop = new AutoPlayLoopNode(30,new IdleUpNextNode(cf),new IdleOverallLeaderBoardNode(cf));
|
||||
this.preLiveRaceLoop = new AutoPlayLoopNode(90, new PreLeaderBoardWithCompetitorsNode(cf),new PreRaceWithRacemapNode(cf));
|
||||
this.liveRaceLoop = new AutoPlayLoopNode(30, new LiveRaceWithRacemapNode(cf));
|
||||
this.afterLiveRaceLoop = new AutoPlayLoopNode(30, new RaceEndWithCompetitorsBoatsNode(cf),
|
||||
new RaceEndWithCompetitorsFlagsNode(cf), idleLoop);
|
||||
this.afterLiveRaceLoop = new AutoPlaySequenceNode(30, new RaceEndWithCompetitorsBoatsNode(cf),
|
||||
new RaceEndWithCompetitorsFlagsNode(cf));
|
||||
|
||||
afterLiveRaceLoop.setOnLoopEnd(new Command() {
|
||||
afterLiveRaceLoop.setOnSequenceEnd(new Command() {
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
transitionTo(idleLoop);
|
||||
afterRaceFinished = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected boolean processStateTransition(RootNodeState goingTo, RootNodeState comingFrom) {
|
||||
// block transitions, until the afterLiveRaceLoop returns to the idleLoop, to ensure scoreboard is shown at
|
||||
// least 30 seconds
|
||||
if (comingFrom == RootNodeState.AFTER_LIVE && afterLiveRaceLoop.getCurrentNode() != idleLoop) {
|
||||
// block transitions, until the afterLiveRaceLoop is finished
|
||||
if (comingFrom == RootNodeState.AFTER_LIVE && !afterRaceFinished) {
|
||||
return true;
|
||||
}else{
|
||||
afterRaceFinished = false;
|
||||
}
|
||||
switch (goingTo) {
|
||||
case IDLE:
|
||||
|
||||
-9
@@ -4,7 +4,6 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.user.client.Command;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
|
||||
public class AutoPlayLoopNode extends BaseCompositeNode {
|
||||
@@ -12,7 +11,6 @@ public class AutoPlayLoopNode extends BaseCompositeNode {
|
||||
private List<AutoPlayNode> nodes = new ArrayList<>();
|
||||
private int loopTimePerNodeInSeconds;
|
||||
private int currentPos = -1;
|
||||
private Command onLoopEnd;
|
||||
private Timer transitionTimer = new Timer() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -23,9 +21,6 @@ public class AutoPlayLoopNode extends BaseCompositeNode {
|
||||
private void gotoNext() {
|
||||
currentPos++;
|
||||
if (currentPos > nodes.size() - 1) {
|
||||
if (onLoopEnd != null) {
|
||||
onLoopEnd.execute();
|
||||
}
|
||||
currentPos = 0;
|
||||
}
|
||||
transitionTo(nodes.get(currentPos));
|
||||
@@ -44,10 +39,6 @@ public class AutoPlayLoopNode extends BaseCompositeNode {
|
||||
this.nodes.addAll(Arrays.asList(nodes));
|
||||
}
|
||||
|
||||
public void setOnLoopEnd(Command onLoopEnd) {
|
||||
this.onLoopEnd = onLoopEnd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
currentPos = -1;
|
||||
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
package com.sap.sailing.gwt.autoplay.client.nodes.base;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.user.client.Command;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
|
||||
public class AutoPlaySequenceNode extends BaseCompositeNode {
|
||||
|
||||
private List<AutoPlayNode> nodes = new ArrayList<>();
|
||||
private int sequenceTimePerNodeInSeconds;
|
||||
private int currentPos = -1;
|
||||
private Command onLoopEnd;
|
||||
private Timer transitionTimer = new Timer() {
|
||||
@Override
|
||||
public void run() {
|
||||
gotoNext();
|
||||
}
|
||||
};
|
||||
|
||||
private void gotoNext() {
|
||||
currentPos++;
|
||||
if (currentPos > nodes.size() - 1) {
|
||||
if (onLoopEnd != null) {
|
||||
onLoopEnd.execute();
|
||||
}
|
||||
//do nothing we stay at the end position
|
||||
}else{
|
||||
transitionTo(nodes.get(currentPos));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void transitionTo(AutoPlayNode nextNode) {
|
||||
super.transitionTo(nextNode);
|
||||
if (!isStopped()) {
|
||||
transitionTimer.schedule(sequenceTimePerNodeInSeconds * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
public AutoPlaySequenceNode(int sequenceTimePerNodeInSeconds, AutoPlayNode... nodes) {
|
||||
this.sequenceTimePerNodeInSeconds = sequenceTimePerNodeInSeconds;
|
||||
this.nodes.addAll(Arrays.asList(nodes));
|
||||
}
|
||||
|
||||
public void setOnSequenceEnd(Command onLoopEnd) {
|
||||
this.onLoopEnd = onLoopEnd;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
currentPos = -1;
|
||||
gotoNext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
super.onStop();
|
||||
for (AutoPlayNode autoPlayNode : nodes) {
|
||||
autoPlayNode.stop();
|
||||
}
|
||||
transitionTimer.cancel();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+4
-1
@@ -15,6 +15,8 @@ import com.sap.sailing.gwt.ui.leaderboard.SortedCellTable;
|
||||
import com.sap.sse.gwt.client.panels.ResizableFlowPanel;
|
||||
|
||||
public class IdleOverallLeaderBoardViewImpl extends ResizeComposite implements IdleOverallLeaderBoardView {
|
||||
protected static final int TOOLBAR_SIZE = 182;
|
||||
|
||||
private static LifeRaceWithRacemapViewImplUiBinder uiBinder = GWT.create(LifeRaceWithRacemapViewImplUiBinder.class);
|
||||
|
||||
@UiField
|
||||
@@ -44,7 +46,8 @@ public class IdleOverallLeaderBoardViewImpl extends ResizeComposite implements I
|
||||
public void run() {
|
||||
SortedCellTable<LeaderboardRowDTO> tbl = leaderboardPanel.getLeaderboardTable();
|
||||
Widget tb = leaderboardPanel.getToolbarWidget();
|
||||
LeaderBoardScaleHelper.scaleContentWidget(AutoPlayMainViewImpl.SAP_HEADER_IN_PX+tb.getOffsetHeight(), tbl);
|
||||
GWT.log("toolbarsize "+tb.getOffsetHeight());
|
||||
LeaderBoardScaleHelper.scaleContentWidget(AutoPlayMainViewImpl.SAP_HEADER_IN_PX+TOOLBAR_SIZE, tbl);
|
||||
}
|
||||
};
|
||||
resizer.scheduleRepeating(100);
|
||||
|
||||
Reference in new issue
Block a user