mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-27 22:37:15 +00:00
Refactored EventViewImpl to use mobile event view abstraction
This commit is contained in:
1 parent
d6dd620a79
commit
01b81ba892
4 files changed
+33
-115
No files matched your search
+6
@@ -15,6 +15,7 @@ import com.google.gwt.user.client.ui.AcceptsOneWidget;
|
||||
import com.sap.sailing.gwt.home.client.place.error.ErrorPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.AbstractEventPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.EventContext;
|
||||
import com.sap.sailing.gwt.home.client.place.event.EventDefaultPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.multiregatta.tabs.MultiregattaMediaPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.regatta.tabs.RegattaLeaderboardPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.regatta.tabs.RegattaMediaPlace;
|
||||
@@ -185,4 +186,9 @@ public class EventActivity extends AbstractActivity implements Presenter {
|
||||
EventContext ctx = new EventContext(getCtx()).withRegattaId(regattaId).withRegattaAnalyticsManager(null);
|
||||
return clientFactory.getNavigator().getEventNavigation(new RegattaRacesPlace(ctx), null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlaceNavigation<?> getEventNavigation() {
|
||||
return clientFactory.getNavigator().getEventNavigation(new EventDefaultPlace(getCtx()), null, false);
|
||||
}
|
||||
}
|
||||
+2
-24
@@ -2,38 +2,16 @@ package com.sap.sailing.gwt.home.mobile.places.event;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.gwt.home.client.place.event.EventContext;
|
||||
import com.sap.sailing.gwt.home.mobile.partials.updatesBox.NewsItemLinkProvider;
|
||||
import com.sap.sailing.gwt.home.mobile.places.RegattaLeaderboardNavigationProvider;
|
||||
import com.sap.sailing.gwt.home.mobile.places.RegattaRacesNavigationProvider;
|
||||
import com.sap.sailing.gwt.home.mobile.places.SeriesLeaderboardNavigationProvider;
|
||||
import com.sap.sailing.gwt.home.shared.app.PlaceNavigation;
|
||||
import com.sap.sailing.gwt.home.shared.dispatch.DispatchSystem;
|
||||
import com.sap.sailing.gwt.ui.shared.eventview.RegattaMetadataDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.general.EventReferenceDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.media.SailingImageDTO;
|
||||
|
||||
public interface EventView {
|
||||
|
||||
Widget asWidget();
|
||||
|
||||
void setSailorInfos(String description, String buttonLabel, String url);
|
||||
|
||||
void setSeriesNavigation(String buttonLabel, PlaceNavigation<?> placeNavigation);
|
||||
|
||||
void setQuickFinderValues(Collection<RegattaMetadataDTO> regattaMetadatas);
|
||||
|
||||
void setQuickFinderValues(String seriesName, Collection<EventReferenceDTO> eventsOfSeries);
|
||||
|
||||
void hideQuickfinder();
|
||||
public interface EventView extends EventViewBase {
|
||||
|
||||
void setMediaForImpressions(int nrOfImages, int nrOfVideos, Collection<SailingImageDTO> images);
|
||||
|
||||
public interface Presenter extends NewsItemLinkProvider, RegattaLeaderboardNavigationProvider,
|
||||
RegattaRacesNavigationProvider, SeriesLeaderboardNavigationProvider {
|
||||
EventContext getCtx();
|
||||
DispatchSystem getDispatch();
|
||||
public interface Presenter extends EventViewBase .Presenter, NewsItemLinkProvider, RegattaRacesNavigationProvider {
|
||||
String getRaceViewerURL(String regattaName, String trackedRaceName);
|
||||
PlaceNavigation<?> getMediaPageNavigation();
|
||||
}
|
||||
|
||||
+21
-69
@@ -1,132 +1,84 @@
|
||||
package com.sap.sailing.gwt.home.mobile.places.event;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.dom.client.Style.Display;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
|
||||
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.SimplePanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.gwt.home.client.place.event.regatta.tabs.reload.RefreshManager;
|
||||
import com.sap.sailing.gwt.home.mobile.partials.eventheader.EventHeader;
|
||||
import com.sap.sailing.gwt.home.mobile.partials.impressions.Impressions;
|
||||
import com.sap.sailing.gwt.home.mobile.partials.minileaderboard.MinileaderboardBox;
|
||||
import com.sap.sailing.gwt.home.mobile.partials.quickfinder.Quickfinder;
|
||||
import com.sap.sailing.gwt.home.mobile.partials.regattaStatus.RegattaStatus;
|
||||
import com.sap.sailing.gwt.home.mobile.partials.simpleinfoblock.SimpleInfoBlock;
|
||||
import com.sap.sailing.gwt.home.mobile.partials.statisticsBox.StatisticsBox;
|
||||
import com.sap.sailing.gwt.home.mobile.partials.updatesBox.UpdatesBox;
|
||||
import com.sap.sailing.gwt.home.mobile.places.QuickfinderPresenter;
|
||||
import com.sap.sailing.gwt.home.mobile.places.event.overview.EventOverviewStage;
|
||||
import com.sap.sailing.gwt.home.shared.app.PlaceNavigation;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.GetEventOverviewNewsAction;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.GetEventOverviewStageAction;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.GetEventStatisticsAction;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.GetMiniLeaderbordAction;
|
||||
import com.sap.sailing.gwt.ui.shared.dispatch.event.GetRegattasAndLiveRacesForEventAction;
|
||||
import com.sap.sailing.gwt.ui.shared.eventview.EventViewDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.eventview.EventViewDTO.EventType;
|
||||
import com.sap.sailing.gwt.ui.shared.eventview.RegattaMetadataDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.general.EventReferenceDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.general.EventState;
|
||||
import com.sap.sailing.gwt.ui.shared.media.SailingImageDTO;
|
||||
|
||||
public class EventViewImpl extends Composite implements EventView {
|
||||
public class EventViewImpl extends AbstractEventView<EventView.Presenter> implements EventView {
|
||||
|
||||
private static final StringMessages MSG = StringMessages.INSTANCE;
|
||||
private static StartPageViewUiBinder uiBinder = GWT.create(StartPageViewUiBinder.class);
|
||||
|
||||
interface StartPageViewUiBinder extends UiBinder<Widget, EventViewImpl> {
|
||||
}
|
||||
|
||||
@UiField(provided = true) EventHeader eventHeaderUi;
|
||||
@UiField Quickfinder quickFinderUi;
|
||||
@UiField SimpleInfoBlock simpleInfoUi;
|
||||
@UiField(provided = true) EventOverviewStage overviewStageUi;
|
||||
@UiField SimplePanel listContentUi;
|
||||
@UiField Impressions impressionsUi;
|
||||
@UiField(provided = true) StatisticsBox statisticsBoxUi;
|
||||
@UiField(provided = true) UpdatesBox updatesBoxUi;
|
||||
|
||||
private final Presenter currentPresenter;
|
||||
private final RefreshManager refreshManager;
|
||||
|
||||
public EventViewImpl(Presenter presenter) {
|
||||
this.currentPresenter = presenter;
|
||||
this.refreshManager = new RefreshManager(this, currentPresenter.getDispatch());
|
||||
EventViewDTO event = currentPresenter.getCtx().getEventDTO();
|
||||
eventHeaderUi = new EventHeader(event);
|
||||
this.setupOverviewStage(event.getId());
|
||||
this.setupUpdateBox(event.getId());
|
||||
this.setupStatisticsBox(event);
|
||||
initWidget(uiBinder.createAndBindUi(this));
|
||||
this.setupListContent(event);
|
||||
public EventViewImpl(EventView.Presenter presenter) {
|
||||
super(presenter, false, false);
|
||||
this.setupOverviewStage();
|
||||
this.setupUpdateBox();
|
||||
this.setupStatisticsBox();
|
||||
setViewContent(uiBinder.createAndBindUi(this));
|
||||
this.setupListContent();
|
||||
impressionsUi.getElement().getStyle().setDisplay(Display.NONE);
|
||||
}
|
||||
|
||||
private void setupOverviewStage(UUID eventId) {
|
||||
private void setupOverviewStage() {
|
||||
overviewStageUi = new EventOverviewStage(currentPresenter);
|
||||
refreshManager.add(overviewStageUi, new GetEventOverviewStageAction(eventId));
|
||||
refreshManager.add(overviewStageUi, new GetEventOverviewStageAction(getEventId()));
|
||||
}
|
||||
|
||||
private void setupListContent(EventViewDTO event) {
|
||||
String regattaId = currentPresenter.getCtx().getRegattaId();
|
||||
if (event.getType() == EventType.MULTI_REGATTA) {
|
||||
private void setupListContent() {
|
||||
if (isMultiRegattaEvent()) {
|
||||
RegattaStatus regattaStatus = new RegattaStatus(currentPresenter);
|
||||
listContentUi.add(regattaStatus);
|
||||
refreshManager.add(regattaStatus, new GetRegattasAndLiveRacesForEventAction(event.getId()));
|
||||
refreshManager.add(regattaStatus, new GetRegattasAndLiveRacesForEventAction(getEventId()));
|
||||
} else {
|
||||
MinileaderboardBox miniLeaderboard = new MinileaderboardBox(false);
|
||||
miniLeaderboard.setAction(MSG.showAll(), currentPresenter.getRegattaMiniLeaderboardNavigation(regattaId));
|
||||
miniLeaderboard.setAction(MSG.showAll(), currentPresenter.getRegattaMiniLeaderboardNavigation(getRegattaId()));
|
||||
listContentUi.add(miniLeaderboard);
|
||||
refreshManager.add(miniLeaderboard, new GetMiniLeaderbordAction(event.getId(), regattaId, 3));
|
||||
refreshManager.add(miniLeaderboard, new GetMiniLeaderbordAction(getEventId(), getRegattaId(), 3));
|
||||
}
|
||||
}
|
||||
|
||||
private void setupUpdateBox(UUID eventId) {
|
||||
private void setupUpdateBox() {
|
||||
updatesBoxUi = new UpdatesBox(currentPresenter, refreshManager);
|
||||
if (currentPresenter.getCtx().getEventDTO().getState() == EventState.RUNNING) {
|
||||
refreshManager.add(updatesBoxUi, new GetEventOverviewNewsAction(eventId, 2));
|
||||
refreshManager.add(updatesBoxUi, new GetEventOverviewNewsAction(getEventId(), 2));
|
||||
} else {
|
||||
updatesBoxUi.removeFromParent();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupStatisticsBox(EventViewDTO event) {
|
||||
statisticsBoxUi = new StatisticsBox(event.getType() == EventType.MULTI_REGATTA);
|
||||
refreshManager.add(statisticsBoxUi, new GetEventStatisticsAction(event.getId()));
|
||||
private void setupStatisticsBox() {
|
||||
statisticsBoxUi = new StatisticsBox(isMultiRegattaEvent());
|
||||
refreshManager.add(statisticsBoxUi, new GetEventStatisticsAction(getEventId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSailorInfos(String description, String buttonLabel, String url) {
|
||||
simpleInfoUi.setDescription(SafeHtmlUtils.fromString(description.replace("\n", " ")));
|
||||
simpleInfoUi.setAction(buttonLabel, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSeriesNavigation(String buttonLabel, PlaceNavigation<?> placeNavigation) {
|
||||
simpleInfoUi.setAction(buttonLabel, placeNavigation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQuickFinderValues(Collection<RegattaMetadataDTO> regattaMetadatas) {
|
||||
QuickfinderPresenter.getForRegattaLeaderboards(quickFinderUi, currentPresenter, regattaMetadatas);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setQuickFinderValues(String seriesName, Collection<EventReferenceDTO> eventsOfSeries) {
|
||||
QuickfinderPresenter.getForSeriesLeaderboards(quickFinderUi, seriesName, currentPresenter, eventsOfSeries);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hideQuickfinder() {
|
||||
quickFinderUi.removeFromParent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMediaForImpressions(int nrOfImages, int nrOfVideos, Collection<SailingImageDTO> images) {
|
||||
impressionsUi.getElement().getStyle().setDisplay(Display.BLOCK);
|
||||
|
||||
+4
-22
@@ -1,27 +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:s="urn:import:com.sap.sailing.gwt.home.client.shared"
|
||||
xmlns:mp="urn:import:com.sap.sailing.gwt.home.mobile.partials"
|
||||
xmlns:p="urn:import:com.sap.sailing.gwt.home.mobile.places.event"
|
||||
xmlns:g="urn:import:com.google.gwt.user.client.ui"
|
||||
>
|
||||
<ui:with
|
||||
field="res"
|
||||
type="com.sap.sailing.gwt.home.mobile.resources.SharedResources" />
|
||||
<ui:style>
|
||||
.headerWrapper {
|
||||
background-color: #f2f2f2;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
</ui:style>
|
||||
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" xmlns:g="urn:import:com.google.gwt.user.client.ui"
|
||||
xmlns:mp="urn:import:com.sap.sailing.gwt.home.mobile.partials" xmlns:e="urn:import:com.sap.sailing.gwt.home.mobile.places.event">
|
||||
<ui:with field="res" type="com.sap.sailing.gwt.home.mobile.resources.SharedResources" />
|
||||
<g:HTMLPanel>
|
||||
<div class="{style.headerWrapper}">
|
||||
<mp:eventheader.EventHeader ui:field="eventHeaderUi" />
|
||||
<mp:quickfinder.Quickfinder ui:field="quickFinderUi" />
|
||||
<mp:simpleinfoblock.SimpleInfoBlock ui:field="simpleInfoUi" />
|
||||
</div>
|
||||
<p:overview.EventOverviewStage ui:field="overviewStageUi" />
|
||||
<e:overview.EventOverviewStage ui:field="overviewStageUi" />
|
||||
<g:SimplePanel ui:field="listContentUi"/>
|
||||
<mp:updatesBox.UpdatesBox ui:field="updatesBoxUi" />
|
||||
<mp:impressions.Impressions ui:field="impressionsUi" />
|
||||
|
||||
Reference in new issue
Block a user