mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-27 14:27:15 +00:00
Correctly reusing the place rerouting for old places to new ones on
mobile form factor
This commit is contained in:
1 parent
32977d28da
commit
b4bf7d95fd
5 files changed
+129
-110
No files matched your search
+4
-107
@@ -14,27 +14,9 @@ import com.sap.sailing.gwt.home.client.place.error.ErrorActivityProxy;
|
||||
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.EventActivityProxy;
|
||||
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.legacy.EventPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.legacy.RegattaPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.legacy.SeriesPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.multiregatta.tabs.MultiregattaMediaPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.multiregatta.tabs.MultiregattaOverviewPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.multiregatta.tabs.MultiregattaRegattasPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.regatta.tabs.RegattaCompetitorAnalyticsPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.regatta.tabs.RegattaLeaderboardPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.regatta.tabs.RegattaMediaPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.regatta.tabs.RegattaOverviewPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.regatta.tabs.RegattaRacesPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.events.EventsActivityProxy;
|
||||
import com.sap.sailing.gwt.home.client.place.events.EventsPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.fakeseries.AbstractSeriesPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.fakeseries.SeriesContext;
|
||||
import com.sap.sailing.gwt.home.client.place.fakeseries.SeriesDefaultPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.fakeseries.tabs.EventSeriesCompetitorAnalyticsPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.fakeseries.tabs.EventSeriesLeaderboardsPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.fakeseries.tabs.EventSeriesOverallLeaderboardPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.searchresult.SearchResultActivityProxy;
|
||||
import com.sap.sailing.gwt.home.client.place.searchresult.SearchResultPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.solutions.SolutionsActivityProxy;
|
||||
@@ -46,10 +28,12 @@ import com.sap.sailing.gwt.home.client.place.start.StartPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.whatsnew.WhatsNewActivityProxy;
|
||||
import com.sap.sailing.gwt.home.client.place.whatsnew.WhatsNewPlace;
|
||||
import com.sap.sailing.gwt.home.shared.SwitchingEntryPoint;
|
||||
import com.sap.sailing.gwt.home.shared.app.ApplicationPlaceUpdater;
|
||||
import com.sap.sailing.gwt.home.shared.app.HasMobileVersion;
|
||||
|
||||
public class ApplicationActivityMapper implements ActivityMapper {
|
||||
private final ApplicationClientFactory clientFactory;
|
||||
private final ApplicationPlaceUpdater placeUpdater = new ApplicationPlaceUpdater();
|
||||
|
||||
public ApplicationActivityMapper(ApplicationClientFactory clientFactory) {
|
||||
super();
|
||||
@@ -57,7 +41,8 @@ public class ApplicationActivityMapper implements ActivityMapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Activity getActivity(Place place) {
|
||||
public Activity getActivity(Place rawPlace) {
|
||||
Place place = placeUpdater.getRealPlace(rawPlace);
|
||||
if (place instanceof HasMobileVersion && !SwitchingEntryPoint.isForcedDesktop()) {
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
@Override
|
||||
@@ -73,10 +58,6 @@ public class ApplicationActivityMapper implements ActivityMapper {
|
||||
return new ErrorActivityProxy((ErrorPlace) place, clientFactory);
|
||||
} else if (place instanceof ContactPlace) {
|
||||
return new ContactActivityProxy((ContactPlace) place, clientFactory);
|
||||
} else if (place instanceof EventPlace) {
|
||||
// return new EventActivityProxy((EventPlace) place, clientFactory);
|
||||
// rerouting old place to new place to make bookmarked URLs to work with the new interface.
|
||||
return getActivity(getRealEventPlace((EventPlace) place));
|
||||
} else if (place instanceof AbstractEventPlace) {
|
||||
AbstractEventPlace eventPlace = (AbstractEventPlace) place;
|
||||
return new EventActivityProxy(eventPlace, clientFactory, clientFactory.getHomePlacesNavigator());
|
||||
@@ -92,94 +73,10 @@ public class ApplicationActivityMapper implements ActivityMapper {
|
||||
return new SolutionsActivityProxy((SolutionsPlace) place, clientFactory);
|
||||
} else if (place instanceof WhatsNewPlace) {
|
||||
return new WhatsNewActivityProxy((WhatsNewPlace) place, clientFactory);
|
||||
} else if (place instanceof RegattaPlace) {
|
||||
// return new RegattaActivityProxy((RegattaPlace) place, clientFactory);
|
||||
// rerouting old place to new place to make bookmarked URLs to work with the new interface.
|
||||
return getActivity(getRealRegattaPlace((RegattaPlace) place));
|
||||
} else if (place instanceof SeriesPlace) {
|
||||
// return new SeriesActivityProxy((SeriesPlace) place, clientFactory);
|
||||
// rerouting old place to new place to make bookmarked URLs to work with the new interface.
|
||||
return getActivity(getRealSeriesPlace((SeriesPlace) place));
|
||||
} else if (place instanceof SearchResultPlace) {
|
||||
return new SearchResultActivityProxy((SearchResultPlace) place, clientFactory);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Place getRealRegattaPlace(RegattaPlace place) {
|
||||
String eventId = place.getEventUuidAsString();
|
||||
if(eventId == null || eventId.isEmpty()) {
|
||||
return new EventsPlace();
|
||||
}
|
||||
EventContext eventContext = new EventContext().withId(eventId);
|
||||
String regattaId = place.getLeaderboardIdAsNameString();
|
||||
boolean hasRegattaId = (regattaId != null && !regattaId.isEmpty());
|
||||
|
||||
// TODO evaluate additional parameters
|
||||
|
||||
if(hasRegattaId) {
|
||||
switch (place.getNavigationTab()) {
|
||||
case CompetitorAnalytics:
|
||||
return new RegattaCompetitorAnalyticsPlace(eventContext);
|
||||
case Leaderboard:
|
||||
return new RegattaLeaderboardPlace(eventContext);
|
||||
}
|
||||
}
|
||||
return new EventDefaultPlace(eventContext);
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
private Place getRealEventPlace(EventPlace place) {
|
||||
String eventId = place.getEventUuidAsString();
|
||||
if(eventId == null || eventId.isEmpty()) {
|
||||
return new EventsPlace();
|
||||
}
|
||||
EventContext eventContext = new EventContext().withId(eventId);
|
||||
String regattaId = place.getLeaderboardIdAsNameString();
|
||||
boolean hasRegattaId = (regattaId != null && !regattaId.isEmpty());
|
||||
if(hasRegattaId) {
|
||||
eventContext.withRegattaId(regattaId);
|
||||
|
||||
switch (place.getNavigationTab()) {
|
||||
case Media:
|
||||
return new RegattaMediaPlace(eventContext);
|
||||
case Overview:
|
||||
return new RegattaOverviewPlace(eventContext);
|
||||
case Regatta:
|
||||
return new RegattaRacesPlace(eventContext);
|
||||
}
|
||||
} else {
|
||||
switch (place.getNavigationTab()) {
|
||||
// TODO some places aren't implemented yet
|
||||
case Media:
|
||||
return new MultiregattaMediaPlace(eventContext);
|
||||
case Overview:
|
||||
return new MultiregattaOverviewPlace(eventContext);
|
||||
case Schedule:
|
||||
// Schedule not implemented yet -> using race list
|
||||
case Regattas:
|
||||
return new MultiregattaRegattasPlace(eventContext);
|
||||
}
|
||||
}
|
||||
|
||||
return new EventDefaultPlace(eventContext);
|
||||
}
|
||||
|
||||
private Place getRealSeriesPlace(SeriesPlace place) {
|
||||
String seriesId = place.getEventUuidAsString();
|
||||
SeriesContext context = new SeriesContext().withId(seriesId);
|
||||
|
||||
// TODO evaluate additional parameters
|
||||
|
||||
switch (place.getNavigationTab()) {
|
||||
case OverallLeaderboard:
|
||||
return new EventSeriesOverallLeaderboardPlace(context);
|
||||
case RegattaLeaderboards:
|
||||
return new EventSeriesLeaderboardsPlace(context);
|
||||
case CompetitorAnalytics:
|
||||
return new EventSeriesCompetitorAnalyticsPlace(context);
|
||||
}
|
||||
return new SeriesDefaultPlace(context);
|
||||
}
|
||||
}
|
||||
+4
-1
@@ -15,11 +15,13 @@ import com.sap.sailing.gwt.home.mobile.places.events.EventsActivityProxy;
|
||||
import com.sap.sailing.gwt.home.mobile.places.latestnews.LatestNewsActivityProxy;
|
||||
import com.sap.sailing.gwt.home.mobile.places.latestnews.LatestNewsPlace;
|
||||
import com.sap.sailing.gwt.home.mobile.places.minileaderboard.MiniLeaderboardActivityProxy;
|
||||
import com.sap.sailing.gwt.home.shared.app.ApplicationPlaceUpdater;
|
||||
import com.sap.sailing.gwt.home.shared.app.HasMobileVersion;
|
||||
|
||||
|
||||
public class MobileActivityMapper implements ActivityMapper {
|
||||
private final MobileApplicationClientFactory clientFactory;
|
||||
private final ApplicationPlaceUpdater placeUpdater = new ApplicationPlaceUpdater();
|
||||
|
||||
public MobileActivityMapper(MobileApplicationClientFactory clientFactory) {
|
||||
super();
|
||||
@@ -27,7 +29,8 @@ public class MobileActivityMapper implements ActivityMapper {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Activity getActivity(Place place) {
|
||||
public Activity getActivity(Place rawPlace) {
|
||||
Place place = placeUpdater.getRealPlace(rawPlace);
|
||||
if (!(place instanceof HasMobileVersion)) {
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
@Override
|
||||
|
||||
+1
@@ -70,6 +70,7 @@ public class Header extends Composite {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
GWT.debugger();
|
||||
if(LinkUtil.handleLinkClick(event.getNativeEvent().<Event>cast())) {
|
||||
event.preventDefault();
|
||||
placeNavigation.goToPlace();
|
||||
|
||||
+4
-2
@@ -20,6 +20,7 @@ import com.google.gwt.user.client.ui.RootPanel;
|
||||
import com.sap.sailing.gwt.home.desktop.DesktopEntryPoint;
|
||||
import com.sap.sailing.gwt.home.mobile.MobileEntryPoint;
|
||||
import com.sap.sailing.gwt.home.shared.app.ApplicationHistoryMapper;
|
||||
import com.sap.sailing.gwt.home.shared.app.ApplicationPlaceUpdater;
|
||||
import com.sap.sailing.gwt.home.shared.app.HasMobileVersion;
|
||||
|
||||
public class SwitchingEntryPoint implements EntryPoint {
|
||||
@@ -27,7 +28,8 @@ public class SwitchingEntryPoint implements EntryPoint {
|
||||
private static final String SAPSAILING_MOBILE = "sapsailing_mobile";
|
||||
private static final RegExp isMobileRegExp = RegExp.compile(
|
||||
"Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini", "i");
|
||||
private PlaceHistoryMapper hisMap = GWT.create(ApplicationHistoryMapper.class);
|
||||
private final PlaceHistoryMapper hisMap = GWT.create(ApplicationHistoryMapper.class);
|
||||
private final ApplicationPlaceUpdater placeUpdater = new ApplicationPlaceUpdater();
|
||||
|
||||
@Override
|
||||
public void onModuleLoad() {
|
||||
@@ -36,7 +38,7 @@ public class SwitchingEntryPoint implements EntryPoint {
|
||||
if (hash != null && hash.startsWith("#")) {
|
||||
hash = hash.substring(1);
|
||||
}
|
||||
Place place = hisMap.getPlace(hash);
|
||||
Place place = placeUpdater.getRealPlace(hisMap.getPlace(hash));
|
||||
GWT.log("Hash: " + hash);
|
||||
if (place != null && !(place instanceof HasMobileVersion)) {
|
||||
startDesktop();
|
||||
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
package com.sap.sailing.gwt.home.shared.app;
|
||||
|
||||
import com.google.gwt.place.shared.Place;
|
||||
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.legacy.EventPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.legacy.RegattaPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.legacy.SeriesPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.multiregatta.tabs.MultiregattaMediaPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.multiregatta.tabs.MultiregattaOverviewPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.multiregatta.tabs.MultiregattaRegattasPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.regatta.tabs.RegattaCompetitorAnalyticsPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.regatta.tabs.RegattaLeaderboardPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.regatta.tabs.RegattaMediaPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.regatta.tabs.RegattaOverviewPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event.regatta.tabs.RegattaRacesPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.events.EventsPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.fakeseries.SeriesContext;
|
||||
import com.sap.sailing.gwt.home.client.place.fakeseries.SeriesDefaultPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.fakeseries.tabs.EventSeriesCompetitorAnalyticsPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.fakeseries.tabs.EventSeriesLeaderboardsPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.fakeseries.tabs.EventSeriesOverallLeaderboardPlace;
|
||||
|
||||
/**
|
||||
* Helper class to support converting old places to new ones.
|
||||
*
|
||||
*/
|
||||
public class ApplicationPlaceUpdater {
|
||||
|
||||
public Place getRealPlace(Place place) {
|
||||
if (place instanceof EventPlace) {
|
||||
return getRealEventPlace((EventPlace) place);
|
||||
} else if (place instanceof RegattaPlace) {
|
||||
return getRealRegattaPlace((RegattaPlace) place);
|
||||
} else if (place instanceof SeriesPlace) {
|
||||
return getRealSeriesPlace((SeriesPlace) place);
|
||||
}
|
||||
return place;
|
||||
}
|
||||
|
||||
private Place getRealRegattaPlace(RegattaPlace place) {
|
||||
String eventId = place.getEventUuidAsString();
|
||||
if (eventId == null || eventId.isEmpty()) {
|
||||
return new EventsPlace();
|
||||
}
|
||||
EventContext eventContext = new EventContext().withId(eventId);
|
||||
String regattaId = place.getLeaderboardIdAsNameString();
|
||||
boolean hasRegattaId = (regattaId != null && !regattaId.isEmpty());
|
||||
|
||||
// TODO evaluate additional parameters
|
||||
|
||||
if (hasRegattaId) {
|
||||
switch (place.getNavigationTab()) {
|
||||
case CompetitorAnalytics:
|
||||
return new RegattaCompetitorAnalyticsPlace(eventContext);
|
||||
case Leaderboard:
|
||||
return new RegattaLeaderboardPlace(eventContext);
|
||||
}
|
||||
}
|
||||
return new EventDefaultPlace(eventContext);
|
||||
}
|
||||
|
||||
@SuppressWarnings("incomplete-switch")
|
||||
private Place getRealEventPlace(EventPlace place) {
|
||||
String eventId = place.getEventUuidAsString();
|
||||
if (eventId == null || eventId.isEmpty()) {
|
||||
return new EventsPlace();
|
||||
}
|
||||
EventContext eventContext = new EventContext().withId(eventId);
|
||||
String regattaId = place.getLeaderboardIdAsNameString();
|
||||
boolean hasRegattaId = (regattaId != null && !regattaId.isEmpty());
|
||||
if (hasRegattaId) {
|
||||
eventContext.withRegattaId(regattaId);
|
||||
|
||||
switch (place.getNavigationTab()) {
|
||||
case Media:
|
||||
return new RegattaMediaPlace(eventContext);
|
||||
case Overview:
|
||||
return new RegattaOverviewPlace(eventContext);
|
||||
case Regatta:
|
||||
return new RegattaRacesPlace(eventContext);
|
||||
}
|
||||
} else {
|
||||
switch (place.getNavigationTab()) {
|
||||
// TODO some places aren't implemented yet
|
||||
case Media:
|
||||
return new MultiregattaMediaPlace(eventContext);
|
||||
case Overview:
|
||||
return new MultiregattaOverviewPlace(eventContext);
|
||||
case Schedule:
|
||||
// Schedule not implemented yet -> using race list
|
||||
case Regattas:
|
||||
return new MultiregattaRegattasPlace(eventContext);
|
||||
}
|
||||
}
|
||||
|
||||
return new EventDefaultPlace(eventContext);
|
||||
}
|
||||
|
||||
private Place getRealSeriesPlace(SeriesPlace place) {
|
||||
String seriesId = place.getEventUuidAsString();
|
||||
SeriesContext context = new SeriesContext().withId(seriesId);
|
||||
|
||||
// TODO evaluate additional parameters
|
||||
|
||||
switch (place.getNavigationTab()) {
|
||||
case OverallLeaderboard:
|
||||
return new EventSeriesOverallLeaderboardPlace(context);
|
||||
case RegattaLeaderboards:
|
||||
return new EventSeriesLeaderboardsPlace(context);
|
||||
case CompetitorAnalytics:
|
||||
return new EventSeriesCompetitorAnalyticsPlace(context);
|
||||
}
|
||||
return new SeriesDefaultPlace(context);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user