Regatta list - Wrapped Regatta list in its own widget

This commit is contained in:
Benjamin Barth committed 2015-07-08 14:16:01 +02:00
1 parent 2231b16665
commit d149c2bc4c
4 files changed
+63 -31

No files matched your search

@@ -1,35 +1,28 @@
package com.sap.sailing.gwt.home.client.place.event.multiregatta.tabs;
import java.util.UUID;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
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.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.multiRegattaList.MultiRegattaListItem;
import com.sap.sailing.gwt.home.client.place.event.partials.multiRegattaList.MultiRegattaList;
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.dispatch.ResultWithTTL;
import com.sap.sailing.gwt.ui.shared.dispatch.SortedSetResult;
import com.sap.sailing.gwt.ui.shared.dispatch.event.GetLiveRacesForEventAction;
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(provided = true) RacesListLive racesListLive;
@UiField FlowPanel regattasContainerUi;
@UiField(provided = true) RacesListLive racesListLiveUi;
@UiField(provided = true) MultiRegattaList regattaListUi;
private Presenter currentPresenter;
public MultiregattaRegattasTabView() {
@@ -53,31 +46,17 @@ public class MultiregattaRegattasTabView extends Composite implements Multiregat
@Override
public void start(final MultiregattaRegattasPlace myPlace, final AcceptsOneWidget contentArea) {
racesListLive = new RacesListLive(currentPresenter, true);
racesListLiveUi = new RacesListLive(currentPresenter, true);
regattaListUi = new MultiRegattaList(currentPresenter);
initWidget(ourUiBinder.createAndBindUi(this));
RefreshManager refreshManager = new RefreshManager(this, currentPresenter.getDispatch());
refreshManager.add(racesListLive, new GetLiveRacesForEventAction(currentPresenter.getCtx().getEventDTO().getId()));
refreshManager.add(racesListLiveUi, new GetLiveRacesForEventAction(currentPresenter.getCtx().getEventDTO().getId()));
refreshManager.add(regattaListUi, new GetRegattaListViewAction(currentPresenter.getCtx().getEventDTO().getId()));
contentArea.setWidget(this);
UUID eventId = currentPresenter.getCtx().getEventDTO().getId();
currentPresenter.getDispatch().execute(new GetRegattaListViewAction(eventId), new AsyncCallback<ResultWithTTL<SortedSetResult<RegattaWithProgressDTO>>>() {
@Override
public void onFailure(Throwable caught) {
}
@Override
public void onSuccess(ResultWithTTL<SortedSetResult<RegattaWithProgressDTO>> result) {
regattasContainerUi.clear();
for (RegattaWithProgressDTO regattaWithProgress : result.getDto().getValues()) {
regattasContainerUi.add(new MultiRegattaListItem(regattaWithProgress, currentPresenter));
}
}
});
}
@Override
public void stop() {
}
interface MyBinder extends UiBinder<HTMLPanel, MultiregattaRegattasTabView> {
@@ -1,6 +1,6 @@
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'
xmlns:r="urn:import:com.sap.sailing.gwt.home.client.place.event.partials.raceListLive">
xmlns:p="urn:import:com.sap.sailing.gwt.home.client.place.event.partials">
<ui:with field="res" type="com.sap.sailing.gwt.common.client.SharedResources" />
<ui:style>
.space-top {
@@ -11,8 +11,8 @@
<g:HTMLPanel>
<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"/>
<p:raceListLive.RacesListLive ui:field="racesListLiveUi" addStyleNames="{style.space-top}" />
<p:multiRegattaList.MultiRegattaList ui:field="regattaListUi" />
</div>
</div>
</g:HTMLPanel>
@@ -0,0 +1,44 @@
package com.sap.sailing.gwt.home.client.place.event.partials.multiRegattaList;
import java.util.Collection;
import java.util.Collections;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Widget;
import com.sap.sailing.gwt.home.client.place.event.multiregatta.EventMultiregattaView.Presenter;
import com.sap.sailing.gwt.home.client.place.event.regatta.tabs.reload.RefreshableWidget;
import com.sap.sailing.gwt.ui.shared.dispatch.SortedSetResult;
import com.sap.sailing.gwt.ui.shared.dispatch.regatta.RegattaWithProgressDTO;
public class MultiRegattaList extends Composite implements RefreshableWidget<SortedSetResult<RegattaWithProgressDTO>> {
private static MultiRegattaListUiBinder uiBinder = GWT.create(MultiRegattaListUiBinder.class);
interface MultiRegattaListUiBinder extends UiBinder<Widget, MultiRegattaList> {
}
@UiField FlowPanel regattasContainerUi;
private final Presenter currentPresenter;
public MultiRegattaList(Presenter presenter) {
this.currentPresenter = presenter;
initWidget(uiBinder.createAndBindUi(this));
}
@Override
public void setData(SortedSetResult<RegattaWithProgressDTO> data, long nextUpdate, int updateNo) {
this.setListData(data == null ? Collections.<RegattaWithProgressDTO>emptySet() : data.getValues());
}
public void setListData(Collection<RegattaWithProgressDTO> data) {
regattasContainerUi.clear();
for (RegattaWithProgressDTO regattaWithProgress : data) {
regattasContainerUi.add(new MultiRegattaListItem(regattaWithProgress, currentPresenter));
}
}
}
@@ -0,0 +1,9 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui"
xmlns:s="urn:import:com.sap.sailing.gwt.home.client.shared" xmlns:p="urn:import:com.sap.sailing.gwt.home.client.place.event.partials">
<ui:with field="i18n" type="com.sap.sailing.gwt.ui.client.StringMessages" />
<ui:with field="res" type="com.sap.sailing.gwt.common.client.SharedResources" />
<ui:with field="local_res" type="com.sap.sailing.gwt.home.client.place.event.partials.multiRegattaList.MultiRegattaListResources" />
<g:FlowPanel ui:field="regattasContainerUi">
</g:FlowPanel>
</ui:UiBinder>