public abstract class PlaceManagerImpl extends Object implements PlaceManager, ValueChangeHandler<String>, Window.ClosingHandler
PlaceManager.DefaultPlaceManager| Constructor and Description |
|---|
PlaceManagerImpl(EventBus eventBus,
TokenFormatter tokenFormatter) |
| Modifier and Type | Method and Description |
|---|---|
String |
buildHistoryToken(PlaceRequest request)
Builds a string corresponding to the history token to reveal the specified
PlaceRequest. |
String |
buildRelativeHistoryToken(int level)
Builds a string corresponding to the history token to reveal the specified place from the
current place hierarchy.
|
String |
buildRelativeHistoryToken(PlaceRequest request)
Builds a string corresponding to the history token to reveal the specified
PlaceRequest
as a child of the current place hierarchy. |
String |
buildRelativeHistoryToken(PlaceRequest request,
int level)
Builds a string corresponding to the history token to reveal the specified
PlaceRequest
relative to the other places in the current place hierarchy. |
protected void |
doRevealPlace(PlaceRequest request,
boolean updateBrowserUrl)
Fires the
PlaceRequestInternalEvent for the given
PlaceRequest. |
void |
fireEvent(GwtEvent<?> event) |
List<PlaceRequest> |
getCurrentPlaceHierarchy()
Access the current place hierarchy, with the current
PlaceRequest being the last
element of this list. |
PlaceRequest |
getCurrentPlaceRequest()
Access the current place request, that is, the tail of the place request hierarchy.
|
void |
getCurrentTitle(SetPlaceTitleHandler handler)
Retrieves the title of the currently displayed place, or
null if it doesn't have a
title. |
EventBus |
getEventBus()
Makes it possible to access the
EventBus object associated with that presenter. |
int |
getHierarchyDepth()
Retrieves the number of elements in the place hierarchy.
|
void |
getTitle(int index,
SetPlaceTitleHandler handler)
Retrieves the title of a specific place within the place hierarchy.
|
boolean |
hasPendingNavigation()
Checks if the
PlaceManager has to perform any pending navigation that were not
immediately executed because it was requested while the navigation was locked. |
void |
navigateBack()
Calls
History#back(). |
void |
onValueChange(ValueChangeEvent<String> event)
Handles change events from
History. |
void |
onWindowClosing(Window.ClosingEvent event) |
void |
revealCurrentPlace()
Reveals the place corresponding to the current value of the history token in the URL bar.
|
void |
revealErrorPlace(String invalidHistoryToken)
Reveals the place to display when a user tries to access an invalid place.
|
void |
revealPlace(PlaceRequest request)
Programmatically reveals the specified place, updating the browser URL in the process.
|
void |
revealPlace(PlaceRequest request,
boolean updateBrowserUrl)
Programmatically reveals the specified place.
|
void |
revealPlaceHierarchy(List<PlaceRequest> placeRequestHierarchy)
Programmatically reveals the specified hierarchy of places place, updating the browser URL in
the process.
|
void |
revealRelativePlace(int level)
Programmatically reveals the specified place from the current place hierarchy.
|
void |
revealRelativePlace(PlaceRequest request)
Programmatically reveals the specified place as a child of the current place hierarchy.
|
void |
revealRelativePlace(PlaceRequest request,
int level)
Programmatically reveals the specified place relative to the other places in the current place
hierarchy.
|
void |
revealUnauthorizedPlace(String unauthorizedHistoryToken)
Reveals the place to display when a user has been refused the access to a specific place.
|
void |
setOnLeaveConfirmation(String question)
Sets the question that will be displayed whenever the user tries to navigate away from the
current page.
|
void |
unlock()
Resets the navigation lock if it is currently set.
|
void |
updateHistory(PlaceRequest request,
boolean updateBrowserUrl)
Updates History without firing a
ValueChangeEvent. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitrevealDefaultPlacepublic PlaceManagerImpl(EventBus eventBus, TokenFormatter tokenFormatter)
public String buildHistoryToken(PlaceRequest request)
PlaceManagerPlaceRequest. This can be used with a
Hyperlink.
Invoking this history token will discard all the place hierarchy, effectively revealing the
request as a top-level place. To keep the place hierarchy, see
PlaceManager.buildRelativeHistoryToken(com.gwtplatform.mvp.shared.proxy.PlaceRequest),
PlaceManager.buildRelativeHistoryToken(com.gwtplatform.mvp.shared.proxy.PlaceRequest, int) or
PlaceManager.buildRelativeHistoryToken(int).buildHistoryToken in interface PlaceManagerrequest - The PlaceRequest corresponding to the place for which to
build a history token.PlaceManager.revealPlace(com.gwtplatform.mvp.shared.proxy.PlaceRequest)public String buildRelativeHistoryToken(int level)
PlaceManagerrequestA > requestB > requestC
revealRelativePlace(-1) will make a link to
requestA > requestBrevealRelativePlace(1) will make a link to requestArevealRelativePlace(0) will make a link to
requestA > requestB > requestCrevealRelativePlace(-3) or less will make a link to ""revealRelativePlace(3) or more will make a link to
requestA > requestB > requestCbuildRelativeHistoryToken in interface PlaceManagerlevel - If negative, take back that many elements from the tail of the hierarchy. If
positive, keep only that many elements from the head of the hierarchy. Passing 0
makes a link to the current place.PlaceManager.revealRelativePlace(int)public String buildRelativeHistoryToken(PlaceRequest request)
PlaceManagerPlaceRequest
as a child of the current place hierarchy. Identical to calling
PlaceManager.buildRelativeHistoryToken(PlaceRequest, int) with a level of 0.
To get the history token for revealing as a top-level place, see PlaceManager.buildHistoryToken(com.gwtplatform.mvp.shared.proxy.PlaceRequest). To
navigate back to a specific place in the hierarchy, see
PlaceManager.buildRelativeHistoryToken(int).buildRelativeHistoryToken in interface PlaceManagerrequest - The PlaceRequest corresponding to the place for which to build a history
token.PlaceManager.revealRelativePlace(PlaceRequest)public String buildRelativeHistoryToken(PlaceRequest request, int level)
PlaceManagerPlaceRequest
relative to the other places in the current place hierarchy.
To get the history token for revealing as a top-level place, see PlaceManager.buildHistoryToken(com.gwtplatform.mvp.shared.proxy.PlaceRequest). To
navigate back to a specific place in the hierarchy, see
PlaceManager.buildRelativeHistoryToken(int).
Examples, suppose the current hierarchy is requestA > requestB > requestC
buildRelativeHistoryToken(requestD, 0) will make a link to
requestA > requestB > requestC > requestDbuildRelativeHistoryToken(requestD, -1) will make a link to
requestA > requestB > requestDbuildRelativeHistoryToken(requestD, 1) will make a link to
requestA > requestDbuildRelativeHistoryToken(requestD, -3) will make a link to
requestDbuildRelativeHistoryToken(requestD, 3) will make a link to
requestA > requestB > requestC > requestDbuildRelativeHistoryToken in interface PlaceManagerrequest - The PlaceRequest corresponding to the place for which to build a history
token.level - If 0, then simply appends the request to the current page
hierarchy. If negative, take back that many elements from the tail of the hierarchy before
appending the request. If positive, keep only that many elements from the head of the
hierarchy before appending the request.PlaceManager.revealRelativePlace(PlaceRequest, int)protected void doRevealPlace(PlaceRequest request, boolean updateBrowserUrl)
PlaceRequestInternalEvent for the given
PlaceRequest. Do not call this method directly,
instead call revealPlace(PlaceRequest) or a related method.request - The PlaceRequest to fire.updateBrowserUrl - true If the browser URL should be updated, false
otherwise.public void fireEvent(GwtEvent<?> event)
fireEvent in interface HasHandlerspublic List<PlaceRequest> getCurrentPlaceHierarchy()
PlaceManagerPlaceRequest being the last
element of this list.getCurrentPlaceHierarchy in interface PlaceManagerPlaceRequest.PlaceManager.getCurrentPlaceRequest()public PlaceRequest getCurrentPlaceRequest()
PlaceManagerPlaceRequest.getCurrentPlaceRequest in interface PlaceManagerPlaceRequest, or an empty one if the hierarchy is empty.PlaceManager.getCurrentPlaceHierarchy()public void getCurrentTitle(SetPlaceTitleHandler handler)
PlaceManagernull if it doesn't have a
title. Same as calling PlaceManager.getTitle(int, SetPlaceTitleHandler) with a level of
PlaceManager.getHierarchyDepth()-1.
Instead of returning the title directly, this method accepts a callback and will call
SetPlaceTitleHandler.onSetPlaceTitle(java.lang.String) as soon as the title is available. This makes it
possible for the user to query the title from the server based on the
PlaceRequest parameters, for example.getCurrentTitle in interface PlaceManagerhandler - The SetPlaceTitleHandler to invoke when the place title is available.
This will be invoked with null if the place doesn't have a title.public EventBus getEventBus()
PlaceManagerEventBus object associated with that presenter.getEventBus in interface PlaceManagerpublic int getHierarchyDepth()
PlaceManagerPlaceManager.getTitle(int, SetPlaceTitleHandler).getHierarchyDepth in interface PlaceManagerpublic void getTitle(int index,
SetPlaceTitleHandler handler)
throws IndexOutOfBoundsException
PlaceManagerSetPlaceTitleHandler.onSetPlaceTitle(java.lang.String) as soon as the title is available. This makes it
possible for the user to query the title from the server based on the PlaceRequest
parameters, for example.getTitle in interface PlaceManagerindex - The index of the place for which to get a title, 0 is the top-level class,
PlaceManager.getHierarchyDepth()-1 is the current place.handler - The SetPlaceTitleHandler to invoke when the place title is available.
This will be invoked with null if the place doesn't have a title.IndexOutOfBoundsException - If the index is less than 0 or greater or equal to
PlaceManager.getHierarchyDepth().PlaceManager.getCurrentTitle(SetPlaceTitleHandler)public boolean hasPendingNavigation()
PlaceManagerPlaceManager has to perform any pending navigation that were not
immediately executed because it was requested while the navigation was locked.hasPendingNavigation in interface PlaceManagertrue if there are any pending navigation requests, false otherwise.public void navigateBack()
PlaceManagerHistory#back(). This may cause the user's browser to leave your application, if
case you call this method from the first page visited.navigateBack in interface PlaceManagerpublic void onValueChange(ValueChangeEvent<String> event)
History.onValueChange in interface ValueChangeHandler<String>public void onWindowClosing(Window.ClosingEvent event)
onWindowClosing in interface Window.ClosingHandlerpublic void revealCurrentPlace()
PlaceManagerPlaceRequestInternalEvent being fired.revealCurrentPlace in interface PlaceManagerpublic void revealErrorPlace(String invalidHistoryToken)
PlaceManagerPlaceRequest corresponding to the desired presenter and
call PlaceManager.revealPlace(PlaceRequest, boolean) with it. Consider passing false as the
second parameter of revealPlace, otherwise a new token will be inserted in the
browser's history and hitting the browser's back button will take the user back to the
invalid page he initially tried to access.
The default implementation is simply to call PlaceManager.revealDefaultPlace().
Important! Make sure you build a valid PlaceRequest and that the user has access
to it, otherwise you might create an infinite loop.revealErrorPlace in interface PlaceManagerinvalidHistoryToken - The history token that was not recognised.public void revealPlace(PlaceRequest request)
PlaceManagerPlaceManager.revealPlace(PlaceRequest, boolean).
This discards the current place hierarchy, effectively revealing the request as a top-level
place. To keep the current place hierarchy, see PlaceManager.revealRelativePlace(PlaceRequest),
PlaceManager.revealRelativePlace(PlaceRequest, int) or PlaceManager.revealRelativePlace(int). To reveal
an entire place hierarchy, see PlaceManager.revealPlaceHierarchy(java.util.List<com.gwtplatform.mvp.shared.proxy.PlaceRequest>).revealPlace in interface PlaceManagerrequest - The PlaceRequest corresponding to the place to reveal.PlaceManager.buildHistoryToken(PlaceRequest)public void revealPlace(PlaceRequest request, boolean updateBrowserUrl)
PlaceManagerPlaceManager.revealRelativePlace(PlaceRequest),
PlaceManager.revealRelativePlace(PlaceRequest, int) or PlaceManager.revealRelativePlace(int). To reveal
an entire place hierarchy, see PlaceManager.revealPlaceHierarchy(java.util.List<com.gwtplatform.mvp.shared.proxy.PlaceRequest>).revealPlace in interface PlaceManagerrequest - The PlaceRequest corresponding to the place to reveal.updateBrowserUrl - true If the browser URL should be updated, false
otherwise.PlaceManager.buildHistoryToken(PlaceRequest)public void revealPlaceHierarchy(List<PlaceRequest> placeRequestHierarchy)
PlaceManagerPlaceManager.revealRelativePlace(PlaceRequest),
PlaceManager.revealRelativePlace(PlaceRequest, int) or PlaceManager.revealRelativePlace(int). To reveal
a single Place instead of a hierarchy, see PlaceManager.revealPlace(com.gwtplatform.mvp.shared.proxy.PlaceRequest).revealPlaceHierarchy in interface PlaceManagerpublic void revealRelativePlace(int level)
PlaceManagerrequestA > requestB > requestC:
revealRelativePlace(-1) makes it requestA > requestBrevealRelativePlace(1) makes it requestArevealRelativePlace(0) makes it requestA > requestB > requestCrevealRelativePlace(-3) or less calls PlaceManager.revealDefaultPlace()revealRelativePlace(3) or more makes it
requestA > requestB > requestCrevealRelativePlace in interface PlaceManagerlevel - If negative, take back that many elements from the tail of the hierarchy. If
positive, keep only that many elements from the head of the hierarchy. Passing 0
reveals the current place.PlaceManager.buildRelativeHistoryToken(int)public void revealRelativePlace(PlaceRequest request)
PlaceManagerPlaceManager.revealRelativePlace(PlaceRequest, int) with a level of 0.
This will result in a PlaceRequestInternalEvent being fired.
To reveal as a top-level place, see PlaceManager.revealPlace(com.gwtplatform.mvp.shared.proxy.PlaceRequest). To navigate back to a specific place
in the hierarchy, see PlaceManager.revealRelativePlace(int).revealRelativePlace in interface PlaceManagerrequest - The PlaceRequest corresponding to the place to reveal.PlaceManager.buildRelativeHistoryToken(PlaceRequest)public void revealRelativePlace(PlaceRequest request, int level)
PlaceManagerPlaceRequestInternalEvent being fired.
To reveal as a top-level place, see PlaceManager.revealPlace(com.gwtplatform.mvp.shared.proxy.PlaceRequest). To navigate back to a specific place
in the hierarchy, see PlaceManager.revealRelativePlace(int).
Examples. Suppose the current hierarchy is requestA > requestB > requestC:
revealRelativePlace(requestD, 0) makes it
requestA > requestB > requestC > requestDrevealRelativePlace(requestD, -1) makes it
requestA > requestB > requestDrevealRelativePlace(requestD, 1) makes it requestA > requestDrevealRelativePlace(requestD, -3) or less makes it requestDrevealRelativePlace(requestD, 3) or more makes it
requestA > requestB > requestC > requestDrevealRelativePlace in interface PlaceManagerrequest - The PlaceRequest corresponding to the place to reveal.level - If 0, then simply appends the request to the current page
hierarchy. If negative, take back that many elements from the tail of the hierarchy before
appending the request. If positive, keep only that many elements from the head of the
hierarchy before appending the request.PlaceManager.buildRelativeHistoryToken(PlaceRequest, int)public void revealUnauthorizedPlace(String unauthorizedHistoryToken)
PlaceManagerPlace.canReveal() returned false. Application-specific place managers should
build a PlaceRequest corresponding to the desired presenter and call
PlaceManager.revealPlace(PlaceRequest, boolean) with it. Consider passing true as the
second parameter of revealPlace if you navigate, say, to a login page and want the user
to be able to navigate back to the unauthorized page after login. If you are displaying a page
that simply mentions the error you may want to pass false, otherwise a new token will
be inserted in the browser's history and hitting the browser's back button will take
the user
back to the unauthorized page he initially tried to access.
The default implementation is simply to call PlaceManager.revealErrorPlace(String).
Important! Make sure you build a valid PlaceRequest and that the user has access
to it, otherwise you might create an infinite loop.revealUnauthorizedPlace in interface PlaceManagerunauthorizedHistoryToken - The history token that was not authorized.public void setOnLeaveConfirmation(String question)
PlaceManagerNavigationRefusedEvent will be triggered and the current page will remain.
setOnLeaveConfirmation in interface PlaceManagerquestion - The question to display. Pass null to accept navigation directly,
without asking a question.public void unlock()
PlaceManagerProxyPlace.manualReveal(com.gwtplatform.mvp.client.Presenter) and
ProxyPlace.manualRevealFailed().unlock in interface PlaceManagerPresenter.useManualReveal(),
ProxyPlace.manualReveal(com.gwtplatform.mvp.client.Presenter),
ProxyPlace.manualRevealFailed()public void updateHistory(PlaceRequest request, boolean updateBrowserUrl)
PlaceManagerValueChangeEvent.
Only the last PlaceRequest of the place request hierarchy is modified.
This method will only work if the passed PlaceRequest has the same name token as the
current place request (see PlaceManager.getCurrentPlaceRequest().
If true is passed as a second parameter, then this method causes a new token to be
added to the browser history, affecting the behavior of the browser's back button.updateHistory in interface PlaceManagerrequest - The PlaceRequest to display in the updated history.updateBrowserUrl - true If the browser URL should be updated, false
otherwise.Copyright © 2010–2014 Arcbees. All rights reserved.