mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-15 08:41:01 +00:00
Merge branch 'navigationlinks' into design2015
* navigationlinks: Removed tokenizer from navigation api, using history mapper. Conflicts: java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/client/app/AbstractPlaceNavigator.java java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/client/app/HomePlacesNavigator.java java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/home/client/app/PlaceNavigation.java
This commit is contained in:
commit
4bc20c0f8f
5 files changed
+64
-52
No files matched your search
+19
-12
@@ -1,15 +1,18 @@
|
||||
package com.sap.sailing.gwt.home.client.app;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.place.shared.Place;
|
||||
import com.google.gwt.place.shared.PlaceController;
|
||||
import com.google.gwt.place.shared.PlaceTokenizer;
|
||||
import com.google.gwt.user.client.History;
|
||||
import com.google.gwt.user.client.Window;
|
||||
|
||||
public abstract class AbstractPlaceNavigator implements PlaceNavigator {
|
||||
protected final PlaceController placeController;
|
||||
public final static String DEFAULT_SAPSAILING_SERVER = "www.sapsailing.com";
|
||||
public final static String DEFAULT_SAPSAILING_SERVER_URL = "http://" + DEFAULT_SAPSAILING_SERVER;
|
||||
|
||||
private final ApplicationHistoryMapper mapper = GWT.create(ApplicationHistoryMapper.class);
|
||||
|
||||
public final static String DEFAULT_SAPSAILING_SERVER = "www.sapsailing.com";
|
||||
public final static String DEFAULT_SAPSAILING_SERVER_URL = "http://" + DEFAULT_SAPSAILING_SERVER;
|
||||
|
||||
protected AbstractPlaceNavigator(PlaceController placeController) {
|
||||
this.placeController = placeController;
|
||||
@@ -25,20 +28,24 @@ public abstract class AbstractPlaceNavigator implements PlaceNavigator {
|
||||
}
|
||||
}
|
||||
|
||||
protected <T extends Place> PlaceNavigation<T> createLocalPlaceNavigation(T destinationPlace, PlaceTokenizer<T> tokenizer) {
|
||||
return new PlaceNavigation<T>(null, destinationPlace, tokenizer, false, this);
|
||||
protected <T extends Place> PlaceNavigation<T> createLocalPlaceNavigation(T destinationPlace) {
|
||||
return new PlaceNavigation<T>(null, destinationPlace, false, this);
|
||||
}
|
||||
|
||||
protected <T extends Place> PlaceNavigation<T> createGlobalPlaceNavigation(T destinationPlace, PlaceTokenizer<T> tokenizer) {
|
||||
return new PlaceNavigation<T>(destinationPlace, tokenizer, this);
|
||||
|
||||
protected <T extends Place> PlaceNavigation<T> createGlobalPlaceNavigation(T destinationPlace) {
|
||||
return new PlaceNavigation<T>(destinationPlace, this);
|
||||
}
|
||||
|
||||
protected <T extends Place> PlaceNavigation<T> createPlaceNavigation(String baseUrl, boolean isOnRemoteServer, T destinationPlace, PlaceTokenizer<T> tokenizer) {
|
||||
return new PlaceNavigation<T>(baseUrl, destinationPlace, tokenizer, isOnRemoteServer, this);
|
||||
|
||||
protected <T extends Place> PlaceNavigation<T> createPlaceNavigation(String baseUrl, boolean isOnRemoteServer,
|
||||
T destinationPlace) {
|
||||
return new PlaceNavigation<T>(baseUrl, destinationPlace, isOnRemoteServer, this);
|
||||
}
|
||||
|
||||
public <T extends Place> void pushPlaceToHistoryStack(T destinationPlace, PlaceTokenizer<T> tokenizer) {
|
||||
String placeHistoryToken = destinationPlace.getClass().getSimpleName() + ":" + tokenizer.getToken(destinationPlace);
|
||||
|
||||
|
||||
public <T extends Place> void pushPlaceToHistoryStack(T destinationPlace) {
|
||||
String placeHistoryToken = mapper.getToken(destinationPlace);
|
||||
History.newItem(placeHistoryToken, false);
|
||||
}
|
||||
}
|
||||
+18
-18
@@ -1,7 +1,6 @@
|
||||
package com.sap.sailing.gwt.home.client.app;
|
||||
|
||||
import com.google.gwt.place.shared.PlaceController;
|
||||
import com.google.gwt.place.shared.PlaceTokenizer;
|
||||
import com.sap.sailing.gwt.home.client.place.aboutus.AboutUsPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.contact.ContactPlace;
|
||||
import com.sap.sailing.gwt.home.client.place.event2.AbstractEventPlace;
|
||||
@@ -30,77 +29,78 @@ public class HomePlacesNavigator extends AbstractPlaceNavigator {
|
||||
}
|
||||
|
||||
public PlaceNavigation<StartPlace> getHomeNavigation() {
|
||||
return createGlobalPlaceNavigation(new StartPlace(), new StartPlace.Tokenizer());
|
||||
return createGlobalPlaceNavigation(new StartPlace());
|
||||
}
|
||||
|
||||
public PlaceNavigation<EventsPlace> getEventsNavigation() {
|
||||
return createGlobalPlaceNavigation(new EventsPlace(), new EventsPlace.Tokenizer());
|
||||
return createGlobalPlaceNavigation(new EventsPlace());
|
||||
}
|
||||
|
||||
public PlaceNavigation<SolutionsPlace> getSolutionsNavigation(SolutionsNavigationTabs navigationTab) {
|
||||
return createLocalPlaceNavigation(new SolutionsPlace(navigationTab), new SolutionsPlace.Tokenizer());
|
||||
return createLocalPlaceNavigation(new SolutionsPlace(navigationTab));
|
||||
}
|
||||
|
||||
public PlaceNavigation<WhatsNewPlace> getWhatsNewNavigation(WhatsNewNavigationTabs navigationTab) {
|
||||
return createLocalPlaceNavigation(new WhatsNewPlace(navigationTab), new WhatsNewPlace.Tokenizer());
|
||||
return createLocalPlaceNavigation(new WhatsNewPlace(navigationTab));
|
||||
}
|
||||
|
||||
public PlaceNavigation<SponsoringPlace> getSponsoringNavigation() {
|
||||
return createGlobalPlaceNavigation(new SponsoringPlace(), new SponsoringPlace.Tokenizer());
|
||||
return createGlobalPlaceNavigation(new SponsoringPlace());
|
||||
}
|
||||
|
||||
public PlaceNavigation<AboutUsPlace> getAboutUsNavigation() {
|
||||
return createGlobalPlaceNavigation(new AboutUsPlace(), new AboutUsPlace.Tokenizer());
|
||||
return createGlobalPlaceNavigation(new AboutUsPlace());
|
||||
}
|
||||
|
||||
public PlaceNavigation<ContactPlace> getContactNavigation() {
|
||||
return createGlobalPlaceNavigation(new ContactPlace(), new ContactPlace.Tokenizer());
|
||||
return createGlobalPlaceNavigation(new ContactPlace());
|
||||
}
|
||||
|
||||
public PlaceNavigation<MultiregattaRegattasPlace> getEventRegattasNavigation(String eventUuidAsString, String baseUrl, boolean isOnRemoteServer) {
|
||||
MultiregattaRegattasPlace eventPlace = new MultiregattaRegattasPlace(eventUuidAsString);
|
||||
return createPlaceNavigation(baseUrl, isOnRemoteServer, eventPlace, new MultiregattaRegattasPlace.Tokenizer());
|
||||
return createPlaceNavigation(baseUrl, isOnRemoteServer, eventPlace);
|
||||
}
|
||||
|
||||
public PlaceNavigation<SeriesDefaultPlace> getEventSeriesNavigation(String seriesId, String baseUrl, boolean isOnRemoteServer) {
|
||||
SeriesDefaultPlace place = new SeriesDefaultPlace(seriesId);
|
||||
return createPlaceNavigation(baseUrl, isOnRemoteServer, place, new SeriesDefaultPlace.Tokenizer());
|
||||
return createPlaceNavigation(baseUrl, isOnRemoteServer, place);
|
||||
}
|
||||
|
||||
public PlaceNavigation<EventDefaultPlace> getEventNavigation(String eventUuidAsString, String baseUrl, boolean isOnRemoteServer) {
|
||||
EventDefaultPlace eventPlace = new EventDefaultPlace(eventUuidAsString);
|
||||
return createPlaceNavigation(baseUrl, isOnRemoteServer, eventPlace, new EventDefaultPlace.Tokenizer());
|
||||
return createPlaceNavigation(baseUrl, isOnRemoteServer, eventPlace);
|
||||
}
|
||||
|
||||
public <P extends AbstractEventPlace> PlaceNavigation<P> getEventNavigation(P place, PlaceTokenizer<P> tokenizer, String baseUrl, boolean isOnRemoteServer) {
|
||||
return createPlaceNavigation(baseUrl, isOnRemoteServer, place, tokenizer);
|
||||
public <P extends AbstractEventPlace> PlaceNavigation<P> getEventNavigation(P place, String baseUrl,
|
||||
boolean isOnRemoteServer) {
|
||||
return createPlaceNavigation(baseUrl, isOnRemoteServer, place);
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public PlaceNavigation<AbstractEventRegattaPlace> getRegattaNavigation(String eventUuidAsString, String leaderboardIdAsNameString, String baseUrl, boolean isOnRemoteServer) {
|
||||
// TODO RegattaOverviewPlace not implemented yet
|
||||
RegattaRacesPlace eventPlace = new RegattaRacesPlace(eventUuidAsString, leaderboardIdAsNameString);
|
||||
return createPlaceNavigation(baseUrl, isOnRemoteServer, eventPlace, (PlaceTokenizer)new RegattaRacesPlace.Tokenizer());
|
||||
return (PlaceNavigation) createPlaceNavigation(baseUrl, isOnRemoteServer, eventPlace);
|
||||
}
|
||||
|
||||
public PlaceNavigation<RegattaCompetitorAnalyticsPlace> getCompetitorAnalyticsNavigation(String eventUuidAsString, String regattaId, String baseUrl, boolean isOnRemoteServer) {
|
||||
RegattaCompetitorAnalyticsPlace regattaPlace = new RegattaCompetitorAnalyticsPlace(eventUuidAsString, regattaId);
|
||||
return createPlaceNavigation(baseUrl, isOnRemoteServer, regattaPlace, new RegattaCompetitorAnalyticsPlace.Tokenizer());
|
||||
return createPlaceNavigation(baseUrl, isOnRemoteServer, regattaPlace);
|
||||
}
|
||||
|
||||
public PlaceNavigation<RegattaLeaderboardPlace> getLeaderboardNavigation(String eventUuidAsString, String regattaId, String baseUrl, boolean isOnRemoteServer) {
|
||||
RegattaLeaderboardPlace regattaPlace = new RegattaLeaderboardPlace(eventUuidAsString, regattaId);
|
||||
return createPlaceNavigation(baseUrl, isOnRemoteServer, regattaPlace, new RegattaLeaderboardPlace.Tokenizer());
|
||||
return createPlaceNavigation(baseUrl, isOnRemoteServer, regattaPlace);
|
||||
}
|
||||
|
||||
// TODO replace with the new places / remove when the code that calls this is gone
|
||||
/** this place will be merged into the common series event view as tab later on */
|
||||
public PlaceNavigation<SeriesPlace> getSeriesAnalyticsNavigation(String eventUuidAsString, SeriesNavigationTabs navigationTab, String leaderboardIdAsNameString, String baseUrl, boolean isOnRemoteServer) {
|
||||
SeriesPlace seriesPlace = new SeriesPlace(eventUuidAsString, navigationTab, leaderboardIdAsNameString, true, true);
|
||||
return createPlaceNavigation(baseUrl, isOnRemoteServer, seriesPlace, new SeriesPlace.Tokenizer());
|
||||
return createPlaceNavigation(baseUrl, isOnRemoteServer, seriesPlace);
|
||||
}
|
||||
|
||||
public PlaceNavigation<SearchResultPlace> getSearchResultNavigation(String searchQuery) {
|
||||
return createGlobalPlaceNavigation(new SearchResultPlace(searchQuery), new SearchResultPlace.Tokenizer());
|
||||
return createGlobalPlaceNavigation(new SearchResultPlace(searchQuery));
|
||||
}
|
||||
}
|
||||
+23
-19
@@ -2,31 +2,34 @@ package com.sap.sailing.gwt.home.client.app;
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.place.shared.Place;
|
||||
import com.google.gwt.place.shared.PlaceTokenizer;
|
||||
import com.google.gwt.user.client.Window;
|
||||
|
||||
public class PlaceNavigation<T extends Place> {
|
||||
private final PlaceNavigator placeNavigator;
|
||||
|
||||
private final ApplicationHistoryMapper mapper = GWT.create(ApplicationHistoryMapper.class);
|
||||
|
||||
private final T destinationPlace;
|
||||
private final PlaceTokenizer<T> tokenizer;
|
||||
private final String baseUrl;
|
||||
private final boolean isDestinationOnRemoteServer;
|
||||
private final PlaceNavigator placeNavigator;
|
||||
|
||||
public PlaceNavigation(T destinationPlace, PlaceTokenizer<T> tokenizer, PlaceNavigator placeNavigator) {
|
||||
this.destinationPlace = destinationPlace;
|
||||
this.tokenizer = tokenizer;
|
||||
|
||||
public PlaceNavigation(T destinationPlace, PlaceNavigator placeNavigator) {
|
||||
this.placeNavigator = placeNavigator;
|
||||
this.destinationPlace = destinationPlace;
|
||||
String locationURL = getLocationURL();
|
||||
this.isDestinationOnRemoteServer = !(isLocationOnLocalhost(locationURL) || isLocationOnDefaultSapSailingServer(locationURL));
|
||||
this.baseUrl = isDestinationOnRemoteServer ? AbstractPlaceNavigator.DEFAULT_SAPSAILING_SERVER_URL : locationURL;
|
||||
this.baseUrl = isDestinationOnRemoteServer ? AbstractPlaceNavigator.DEFAULT_SAPSAILING_SERVER_URL : locationURL;
|
||||
}
|
||||
|
||||
public PlaceNavigation(String baseUrl, T destinationPlace, PlaceTokenizer<T> tokenizer, boolean isDestinationOnRemoteServer, PlaceNavigator placeNavigator) {
|
||||
public PlaceNavigation(String baseUrl, T destinationPlace, boolean isDestinationOnRemoteServer,
|
||||
PlaceNavigator placeNavigator) {
|
||||
this.destinationPlace = destinationPlace;
|
||||
this.tokenizer = tokenizer;
|
||||
this.isDestinationOnRemoteServer = isDestinationOnRemoteServer;
|
||||
this.placeNavigator = placeNavigator;
|
||||
this.baseUrl = isDestinationOnRemoteServer ? baseUrl : getLocationURL();
|
||||
this.baseUrl = isDestinationOnRemoteServer ? baseUrl : getLocationURL();
|
||||
}
|
||||
|
||||
public void gotoPlace() {
|
||||
}
|
||||
|
||||
public String getTargetUrl() {
|
||||
@@ -35,7 +38,7 @@ public class PlaceNavigation<T extends Place> {
|
||||
|
||||
public String getHistoryUrl() {
|
||||
String placeUrl = buildPlaceUrl();
|
||||
if(placeUrl.startsWith("#")) {
|
||||
if (placeUrl.startsWith("#")) {
|
||||
placeUrl = placeUrl.substring(1, placeUrl.length());
|
||||
}
|
||||
return placeUrl;
|
||||
@@ -47,10 +50,10 @@ public class PlaceNavigation<T extends Place> {
|
||||
|
||||
private String buildPlaceUrl() {
|
||||
String url = "";
|
||||
if(isRemotePlace()) {
|
||||
if (isRemotePlace()) {
|
||||
url = baseUrl + "/gwt/Home.html";
|
||||
if(!GWT.isProdMode()) {
|
||||
url += "?gwt.codesvr=127.0.0.1:9997";
|
||||
if (!GWT.isProdMode()) {
|
||||
url += "?gwt.codesvr=127.0.0.1:9997";
|
||||
}
|
||||
url += getPlaceToken();
|
||||
} else {
|
||||
@@ -58,13 +61,14 @@ public class PlaceNavigation<T extends Place> {
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
public boolean isRemotePlace() {
|
||||
return isDestinationOnRemoteServer;
|
||||
}
|
||||
|
||||
private String getPlaceToken() {
|
||||
return "#" + destinationPlace.getClass().getSimpleName() + ":" + tokenizer.getToken(destinationPlace);
|
||||
return "#" + mapper.getToken(destinationPlace);
|
||||
|
||||
}
|
||||
|
||||
private boolean isLocationOnDefaultSapSailingServer(String urlToCheck) {
|
||||
@@ -74,11 +78,11 @@ public class PlaceNavigation<T extends Place> {
|
||||
private boolean isLocationOnLocalhost(String urlToCheck) {
|
||||
return urlToCheck.contains("localhost") || urlToCheck.contains("127.0.0.1");
|
||||
}
|
||||
|
||||
|
||||
private String getLocationURL() {
|
||||
return Window.Location.getProtocol() + "//" + Window.Location.getHostName() + ":" + Window.Location.getPort();
|
||||
}
|
||||
|
||||
|
||||
public void goToPlace() {
|
||||
placeNavigator.goToPlace(this);
|
||||
}
|
||||
|
||||
+2
-2
@@ -155,14 +155,14 @@ public abstract class AbstractEventActivity<PLACE extends AbstractEventPlace> ex
|
||||
@Override
|
||||
public PlaceNavigation<RegattaRacesPlace> getRegattaRacesNavigation(String regattaId) {
|
||||
return homePlacesNavigator
|
||||
.getEventNavigation(getPlaceForRegattaRaces(regattaId), new RegattaRacesPlace.Tokenizer(), ctx
|
||||
.getEventNavigation(getPlaceForRegattaRaces(regattaId), ctx
|
||||
.getEventDTO().getBaseURL(), ctx.getEventDTO().isOnRemoteServer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlaceNavigation<RegattaRacesPlace> getRegattaNavigation(String regattaId) {
|
||||
return homePlacesNavigator
|
||||
.getEventNavigation(getPlaceForRegattaRaces(regattaId), new RegattaRacesPlace.Tokenizer(), ctx
|
||||
.getEventNavigation(getPlaceForRegattaRaces(regattaId), ctx
|
||||
.getEventDTO().getBaseURL(), ctx.getEventDTO().isOnRemoteServer());
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -87,7 +87,8 @@ public class EventRegattaActivity extends AbstractEventActivity<AbstractEventReg
|
||||
@Override
|
||||
public PlaceNavigation<RegattaRacesPlace> getCurrentRegattaOverviewNavigation() {
|
||||
// TODO Overview isn't implemented yet
|
||||
return homePlacesNavigator.getEventNavigation(new RegattaRacesPlace(ctx), new RegattaRacesPlace.Tokenizer(), ctx.getEventDTO().getBaseURL(), ctx.getEventDTO().isOnRemoteServer());
|
||||
return homePlacesNavigator.getEventNavigation(new RegattaRacesPlace(ctx), ctx.getEventDTO().getBaseURL(), ctx
|
||||
.getEventDTO().isOnRemoteServer());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user