Regatta list - First integration of MultiRegattaList partial

This commit is contained in:
Benjamin Barth committed 2015-07-07 18:04:49 +02:00
1 parent 4e696dd688
commit 893c06cb3e
2 files changed
+22 -51

No files matched your search

@@ -1,8 +1,6 @@
package com.sap.sailing.gwt.home.client.place.event.multiregatta.tabs;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
@@ -10,28 +8,28 @@ import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.AcceptsOneWidget;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.SimplePanel;
import com.sap.sailing.gwt.common.client.controls.tabbar.TabView;
import com.sap.sailing.gwt.home.client.place.event.multiregatta.EventMultiregattaView;
import com.sap.sailing.gwt.home.client.place.event.multiregatta.EventMultiregattaView.Presenter;
import com.sap.sailing.gwt.home.client.place.event.multiregatta.MultiregattaTabView;
import com.sap.sailing.gwt.home.client.place.event.partials.eventregatta.EventRegattaList;
import com.sap.sailing.gwt.home.client.place.event.partials.multiRegattaList.MultiRegattaListItem;
import com.sap.sailing.gwt.home.client.place.event.partials.raceListLive.RacesListLive;
import com.sap.sailing.gwt.home.client.place.event.regatta.tabs.reload.RefreshManager;
import com.sap.sailing.gwt.ui.shared.LeaderboardGroupDTO;
import com.sap.sailing.gwt.ui.shared.RaceGroupDTO;
import com.sap.sailing.gwt.ui.shared.StrippedLeaderboardDTO;
import com.sap.sailing.gwt.ui.shared.dispatch.ResultWithTTL;
import com.sap.sailing.gwt.ui.shared.dispatch.SortedSetResult;
import com.sap.sailing.gwt.ui.shared.dispatch.event.GetLiveRacesForEventAction;
import com.sap.sse.common.Util.Triple;
import com.sap.sailing.gwt.ui.shared.dispatch.event.GetRegattaListViewAction;
import com.sap.sailing.gwt.ui.shared.dispatch.regatta.RegattaWithProgressDTO;
/**
* Created by pgtaboada on 25.11.14.
*/
public class MultiregattaRegattasTabView extends Composite implements MultiregattaTabView<MultiregattaRegattasPlace> {
@UiField SimplePanel content;
@UiField(provided = true) RacesListLive racesListLive;
@UiField FlowPanel regattasContainerUi;
private Presenter currentPresenter;
public MultiregattaRegattasTabView() {
@@ -61,47 +59,20 @@ public class MultiregattaRegattasTabView extends Composite implements Multiregat
refreshManager.add(racesListLive, new GetLiveRacesForEventAction(currentPresenter.getCtx().getEventDTO().getId()));
contentArea.setWidget(this);
// TODO: understand, and than move this into appropiate place (probably context)
currentPresenter.ensureRegattaStructure(new AsyncCallback<List<RaceGroupDTO>>() {
@Override
public void onSuccess(List<RaceGroupDTO> raceGroups) {
if (raceGroups.size() > 0) {
initView();
} else {
// createEventWithoutRegattasView(event, panel);
}
}
@Override
public void onFailure(Throwable caught) {
// createErrorView(
// "Error while loading the regatta structure with service getRegattaStructureOfEvent()",
// caught, panel);
}
});
}
protected void initView() {
Map<String, Triple<RaceGroupDTO, StrippedLeaderboardDTO, LeaderboardGroupDTO>> regattaStructure = getRegattaStructure();
EventRegattaList eventRegattaList = new EventRegattaList(regattaStructure, currentPresenter);
content.setWidget(eventRegattaList);
}
private Map<String, Triple<RaceGroupDTO, StrippedLeaderboardDTO, LeaderboardGroupDTO>> getRegattaStructure() {
Map<String, Triple<RaceGroupDTO, StrippedLeaderboardDTO, LeaderboardGroupDTO>> result = new HashMap<>();
Map<String, RaceGroupDTO> raceGroupsMap = new HashMap<>();
for (RaceGroupDTO raceGroup: currentPresenter.getCtx().getRaceGroups()) {
raceGroupsMap.put(raceGroup.getName(), raceGroup);
}
for (LeaderboardGroupDTO leaderboardGroup : currentPresenter.getCtx().getLeaderboardGroups()) {
for(StrippedLeaderboardDTO leaderboard: leaderboardGroup.getLeaderboards()) {
String leaderboardName = leaderboard.name;
result.put(leaderboardName, new Triple<RaceGroupDTO, StrippedLeaderboardDTO, LeaderboardGroupDTO>(raceGroupsMap.get(leaderboardName),
leaderboard, leaderboardGroup));
UUID eventId = currentPresenter.getCtx().getEventDTO().getId();
currentPresenter.getDispatch().execute(new GetRegattaListViewAction(eventId), new AsyncCallback<ResultWithTTL<SortedSetResult<RegattaWithProgressDTO>>>() {
@Override
public void onFailure(Throwable caught) {
}
}
return result;
@Override
public void onSuccess(ResultWithTTL<SortedSetResult<RegattaWithProgressDTO>> result) {
regattasContainerUi.clear();
for (RegattaWithProgressDTO regattaWithProgress : result.getDto().getValues()) {
regattasContainerUi.add(new MultiRegattaListItem(regattaWithProgress, currentPresenter));
}
}
});
}
@Override
@@ -12,8 +12,8 @@
<div class="{res.mediaCss.grid}">
<div class="{res.mediaCss.small12} {res.mediaCss.columns}">
<r:RacesListLive ui:field="racesListLive" addStyleNames="{style.space-top}" />
<g:FlowPanel ui:field="regattasContainerUi"/>
</div>
</div>
<g:SimplePanel ui:field="content" addStyleNames="{style.space-top}" />
</g:HTMLPanel>
</ui:UiBinder>