@Override public String buildRelativeHistoryToken(int level) { List<PlaceRequest> placeHierarchyCopy = truncatePlaceHierarchy(level); if (placeHierarchyCopy.size() == 0) { return ""; } return tokenFormatter.toHistoryToken(placeHierarchyCopy); }
@Override public String buildHistoryToken(PlaceRequest request) { return tokenFormatter.toPlaceToken(request); }
private void handleTokenChange(final String historyToken) { if (locked) { defferedNavigation = () -> handleTokenChange(historyToken); return; } if (!getLock()) { return; } try { if (historyToken.trim().isEmpty()) { unlock(); revealDefaultPlace(); } else { placeHierarchy = tokenFormatter.toPlaceRequestHierarchy(historyToken); doRevealPlace(getCurrentPlaceRequest(), true); } } catch (TokenFormatException e) { unlock(); error(historyToken); NavigationEvent.fire(this, null); } }
@Override public String buildRelativeHistoryToken(PlaceRequest request, int level) { List<PlaceRequest> placeHierarchyCopy = truncatePlaceHierarchy(level); placeHierarchyCopy.add(request); return tokenFormatter.toHistoryToken(placeHierarchyCopy); }
@Override public void updateHistory(PlaceRequest request, boolean updateBrowserUrl) { try { // Make sure the request match assert request.hasSameNameToken(getCurrentPlaceRequest()) : "Internal error, PlaceRequest passed to" + "updateHistory doesn't match the tail of the place hierarchy."; placeHierarchy.set(placeHierarchy.size() - 1, request); if (updateBrowserUrl) { String historyToken = tokenFormatter.toHistoryToken(placeHierarchy); String browserHistoryToken = getBrowserHistoryToken(); if (browserHistoryToken == null || !browserHistoryToken.equals(historyToken)) { setBrowserHistoryToken(historyToken, false); } saveHistoryToken(historyToken); } } catch (TokenFormatException e) { // Do nothing. } }
/** * Fires the {@link PlaceRequestInternalEvent} for the given {@link PlaceRequest}. Do not call this method directly, * instead call {@link #revealPlace(PlaceRequest)} or a related method. * * @param request The {@link PlaceRequest} to fire. * @param updateBrowserUrl {@code true} If the browser URL should be updated, {@code false} otherwise. */ protected void doRevealPlace(PlaceRequest request, boolean updateBrowserUrl) { PlaceRequestInternalEvent requestEvent = new PlaceRequestInternalEvent(request, updateBrowserUrl); fireEvent(requestEvent); if (!requestEvent.isHandled()) { unlock(); error(tokenFormatter.toHistoryToken(placeHierarchy)); } else if (!requestEvent.isAuthorized()) { unlock(); illegalAccess(tokenFormatter.toHistoryToken(placeHierarchy)); } }