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, wait
revealDefaultPlace
public PlaceManagerImpl(EventBus eventBus, TokenFormatter tokenFormatter)
public String buildHistoryToken(PlaceRequest request)
PlaceManager
PlaceRequest
. 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 PlaceManager
request
- 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)
PlaceManager
requestA > requestB > requestC
revealRelativePlace(-1)
will make a link to
requestA > requestB
revealRelativePlace(1)
will make a link to requestA
revealRelativePlace(0)
will make a link to
requestA > requestB > requestC
revealRelativePlace(-3)
or less will make a link to ""
revealRelativePlace(3)
or more will make a link to
requestA > requestB > requestC
buildRelativeHistoryToken
in interface PlaceManager
level
- 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)
PlaceManager
PlaceRequest
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 PlaceManager
request
- The PlaceRequest
corresponding to the place for which to build a history
token.PlaceManager.revealRelativePlace(PlaceRequest)
public String buildRelativeHistoryToken(PlaceRequest request, int level)
PlaceManager
PlaceRequest
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 > requestD
buildRelativeHistoryToken(requestD, -1)
will make a link to
requestA > requestB > requestD
buildRelativeHistoryToken(requestD, 1)
will make a link to
requestA > requestD
buildRelativeHistoryToken(requestD, -3)
will make a link to
requestD
buildRelativeHistoryToken(requestD, 3)
will make a link to
requestA > requestB > requestC > requestD
buildRelativeHistoryToken
in interface PlaceManager
request
- 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 HasHandlers
public List<PlaceRequest> getCurrentPlaceHierarchy()
PlaceManager
PlaceRequest
being the last
element of this list.getCurrentPlaceHierarchy
in interface PlaceManager
PlaceRequest
.PlaceManager.getCurrentPlaceRequest()
public PlaceRequest getCurrentPlaceRequest()
PlaceManager
PlaceRequest
.getCurrentPlaceRequest
in interface PlaceManager
PlaceRequest
, or an empty one if the hierarchy is empty.PlaceManager.getCurrentPlaceHierarchy()
public void getCurrentTitle(SetPlaceTitleHandler handler)
PlaceManager
null
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 PlaceManager
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.public EventBus getEventBus()
PlaceManager
EventBus
object associated with that presenter.getEventBus
in interface PlaceManager
public int getHierarchyDepth()
PlaceManager
PlaceManager.getTitle(int, SetPlaceTitleHandler)
.getHierarchyDepth
in interface PlaceManager
public void getTitle(int index, SetPlaceTitleHandler handler) throws IndexOutOfBoundsException
PlaceManager
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.getTitle
in interface PlaceManager
index
- 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()
PlaceManager
PlaceManager
has to perform any pending navigation that were not
immediately executed because it was requested while the navigation was locked.hasPendingNavigation
in interface PlaceManager
true
if there are any pending navigation requests, false
otherwise.public void navigateBack()
PlaceManager
History#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 PlaceManager
public void onValueChange(ValueChangeEvent<String> event)
History
.onValueChange
in interface ValueChangeHandler<String>
public void onWindowClosing(Window.ClosingEvent event)
onWindowClosing
in interface Window.ClosingHandler
public void revealCurrentPlace()
PlaceManager
PlaceRequestInternalEvent
being fired.revealCurrentPlace
in interface PlaceManager
public void revealErrorPlace(String invalidHistoryToken)
PlaceManager
PlaceRequest
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 PlaceManager
invalidHistoryToken
- The history token that was not recognised.public void revealPlace(PlaceRequest request)
PlaceManager
PlaceManager.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 PlaceManager
request
- The PlaceRequest
corresponding to the place to reveal.PlaceManager.buildHistoryToken(PlaceRequest)
public void revealPlace(PlaceRequest request, boolean updateBrowserUrl)
PlaceManager
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 PlaceManager
request
- 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)
PlaceManager
PlaceManager.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 PlaceManager
public void revealRelativePlace(int level)
PlaceManager
requestA > requestB > requestC
:
revealRelativePlace(-1)
makes it requestA > requestB
revealRelativePlace(1)
makes it requestA
revealRelativePlace(0)
makes it requestA > requestB > requestC
revealRelativePlace(-3)
or less calls PlaceManager.revealDefaultPlace()
revealRelativePlace(3)
or more makes it
requestA > requestB > requestC
revealRelativePlace
in interface PlaceManager
level
- 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)
PlaceManager
PlaceManager.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 PlaceManager
request
- The PlaceRequest
corresponding to the place to reveal.PlaceManager.buildRelativeHistoryToken(PlaceRequest)
public void revealRelativePlace(PlaceRequest request, int level)
PlaceManager
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)
.
Examples. Suppose the current hierarchy is requestA > requestB > requestC
:
revealRelativePlace(requestD, 0)
makes it
requestA > requestB > requestC > requestD
revealRelativePlace(requestD, -1)
makes it
requestA > requestB > requestD
revealRelativePlace(requestD, 1)
makes it requestA > requestD
revealRelativePlace(requestD, -3)
or less makes it requestD
revealRelativePlace(requestD, 3)
or more makes it
requestA > requestB > requestC > requestD
revealRelativePlace
in interface PlaceManager
request
- 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)
PlaceManager
Place.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 PlaceManager
unauthorizedHistoryToken
- The history token that was not authorized.public void setOnLeaveConfirmation(String question)
PlaceManager
NavigationRefusedEvent
will be triggered and the current page will remain.
setOnLeaveConfirmation
in interface PlaceManager
question
- The question to display. Pass null
to accept navigation directly,
without asking a question.public void unlock()
PlaceManager
ProxyPlace.manualReveal(com.gwtplatform.mvp.client.Presenter)
and
ProxyPlace.manualRevealFailed()
.unlock
in interface PlaceManager
Presenter.useManualReveal()
,
ProxyPlace.manualReveal(com.gwtplatform.mvp.client.Presenter)
,
ProxyPlace.manualRevealFailed()
public void updateHistory(PlaceRequest request, boolean updateBrowserUrl)
PlaceManager
ValueChangeEvent
.
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 PlaceManager
request
- 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.