com.vaadin.addon.touchkit.ui
Class NavigationManager

java.lang.Object
  extended by com.vaadin.server.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
          extended by com.vaadin.ui.AbstractComponentContainer
              extended by com.vaadin.addon.touchkit.ui.NavigationManager
All Implemented Interfaces:
com.vaadin.event.MethodEventSource, com.vaadin.server.ClientConnector, com.vaadin.server.Sizeable, com.vaadin.shared.Connector, com.vaadin.ui.Component, com.vaadin.ui.ComponentContainer, com.vaadin.ui.HasComponents, com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier, Serializable, Iterable<com.vaadin.ui.Component>

public class NavigationManager
extends com.vaadin.ui.AbstractComponentContainer

The NavigationManager is a non-visible component container that allows for smooth navigation between components, or views. It support all components, but back buttons are updated automatically only for NavigationViews.

When a component is navigated to, it replaces the currently visible component, which in turn is pushed on to the stack of previous views. One can navigate backwards by calling navigateBack(), in which case the currently visible view is forgotten (still cached in case the user decides to navigate to it again, see getNextComponent()) and the previous view is restored from the stack and made visible.

When used with NavigationViews, NavigationBars and NavigationButtons, navigation is smooth and quite automatic.

Bootstrap the navigation by giving the NavigationManager an initial view, either by using the constructor NavigationManager(Component) or by calling navigateTo(Component).

See Also:
Serialized Form

Nested Class Summary
static class NavigationManager.NavigationEvent
          A NavigationEvent is triggered when the user navigates forward or backward in the NavigationManager.
static interface NavigationManager.NavigationListener
          A NavigationListener is notified whenever a navigation event occurs.
 
Nested classes/interfaces inherited from interface com.vaadin.ui.HasComponents
com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier, com.vaadin.ui.HasComponents.ComponentAttachEvent, com.vaadin.ui.HasComponents.ComponentAttachListener, com.vaadin.ui.HasComponents.ComponentDetachEvent, com.vaadin.ui.HasComponents.ComponentDetachListener
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
com.vaadin.ui.Component.ErrorEvent, com.vaadin.ui.Component.Event, com.vaadin.ui.Component.Focusable, com.vaadin.ui.Component.Listener
 
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
com.vaadin.server.ClientConnector.AttachEvent, com.vaadin.server.ClientConnector.AttachListener, com.vaadin.server.ClientConnector.ConnectorErrorEvent, com.vaadin.server.ClientConnector.DetachEvent, com.vaadin.server.ClientConnector.DetachListener
 
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
com.vaadin.server.Sizeable.Unit
 
Field Summary
 
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
 
Constructor Summary
NavigationManager()
          Constructs a NavigationManager that is 100% wide and high.
NavigationManager(com.vaadin.ui.Component c)
          Constructs a NavigationManager that is 100% wide and high, and initially navigates to (shows) the given component.
 
Method Summary
 void addNavigationListener(NavigationManager.NavigationListener listener)
          Adds a navigation listener that is notified whenever a navigation event occurs.
 int getComponentCount()
           
 Iterator<com.vaadin.ui.Component> getComponentIterator()
           
 com.vaadin.ui.Component getCurrentComponent()
           
 com.vaadin.ui.Component getNextComponent()
           
 com.vaadin.ui.Component getPreviousComponent()
           
 NavigationManagerSharedState getState()
           
 Stack<com.vaadin.ui.Component> getViewStack()
          Gets the view stack.
 boolean isMaintainBreadcrumb()
           
 Iterator<com.vaadin.ui.Component> iterator()
           
 void navigateBack()
          Navigates backwards in history by popping the previous component off of the view stack and making it visible.
 void navigateTo(com.vaadin.ui.Component c)
          Navigates to the given component, effectively making it the new visible component.
 void removeListener(NavigationManager.NavigationListener listener)
          Removes a navigation listener.
 void replaceComponent(com.vaadin.ui.Component oldComponent, com.vaadin.ui.Component newComponent)
          This operation is not supported
 void setCurrentComponent(com.vaadin.ui.Component newCurrentComponent)
          Sets the currently visible component in the NavigationManager.
 void setMaintainBreadcrumb(boolean maintainBreadcrumb)
          Configures whether the NavigationManager maintains a breadcrumb of visited views automatically.
 void setNextComponent(com.vaadin.ui.Component nextComponent)
          If the developer knows the next component where user is going to navigate, it can be set with this method.
 void setPreviousComponent(com.vaadin.ui.Component newPreviousComponent)
          Replaces the topmost component in the history, forgetting the replaced component - i.e modifies the history.
 
Methods inherited from class com.vaadin.ui.AbstractComponentContainer
addComponent, addComponentAttachListener, addComponentDetachListener, addComponents, addListener, addListener, fireComponentAttachEvent, fireComponentDetachEvent, moveComponentsFrom, removeAllComponents, removeComponent, removeComponentAttachListener, removeComponentDetachListener, removeListener, removeListener, setHeight, setWidth
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, focus, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getState, getStyleName, getWidth, getWidthUnits, isConnectorEnabled, isEnabled, isImmediate, isReadOnly, isVisible, removeListener, removeShortcutListener, removeStyleName, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setHeight, setIcon, setId, setImmediate, setLocale, setParent, setPrimaryStyleName, setReadOnly, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth
 
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hasListeners, isAttached, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setReadOnly, setStyleName, setVisible
 
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
 
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
 
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setSizeFull, setSizeUndefined, setWidth
 

Constructor Detail

NavigationManager

public NavigationManager()
Constructs a NavigationManager that is 100% wide and high.


NavigationManager

public NavigationManager(com.vaadin.ui.Component c)
Constructs a NavigationManager that is 100% wide and high, and initially navigates to (shows) the given component.

Method Detail

getState

public NavigationManagerSharedState getState()
Overrides:
getState in class com.vaadin.ui.AbstractComponent

getViewStack

public Stack<com.vaadin.ui.Component> getViewStack()
Gets the view stack. Each time the user navigates forward, the previous view is pushed on top of the view stack and when navigating backwards, views are popped off of the view stack.

Developers can override components in this stack if they want to manually modify the breadcrumb or e.g. release previous views for garbage collection.

Returns:
the navigation view stack.
See Also:
isMaintainBreadcrumb()

navigateTo

public void navigateTo(com.vaadin.ui.Component c)
Navigates to the given component, effectively making it the new visible component. If the given component is actually the previous component in the history, navigateBack() is performed, otherwise the replaced view (previously visible) is pushed onto the view stack.

Parameters:
c - the view to navigate to

navigateBack

public void navigateBack()
Navigates backwards in history by popping the previous component off of the view stack and making it visible. The currently visible view is replaced and cached for a short while (see getNextComponent() in case the user wishes to return to the same view.


setCurrentComponent

public void setCurrentComponent(com.vaadin.ui.Component newCurrentComponent)
Sets the currently visible component in the NavigationManager.

If the current component is already set it is overridden. If the previous component or the next component is of type NavigationView, their next and previous components will be automatically re-assigned.

Parameters:
newCurrentComponent - the component to set as the currently visible component.

getCurrentComponent

public com.vaadin.ui.Component getCurrentComponent()
Returns:
the component that is currently visible

setPreviousComponent

public void setPreviousComponent(com.vaadin.ui.Component newPreviousComponent)
Replaces the topmost component in the history, forgetting the replaced component - i.e modifies the history.

Parameters:
newPreviousComponent - the new previous component

getPreviousComponent

public com.vaadin.ui.Component getPreviousComponent()
Returns:
the previous component, e.g. the top of the view stack, or null if n/a

setNextComponent

public void setNextComponent(com.vaadin.ui.Component nextComponent)
If the developer knows the next component where user is going to navigate, it can be set with this method. This might allow the component to be pre-rendered before the actual navigation (and animation) occurs. Having a null as nextComponent shows a placeholder content until the next view is rendered.

When navigating backwards, this is used to cache the views in case the user decides to return to the same view.


getNextComponent

public com.vaadin.ui.Component getNextComponent()
Returns:
the next component, or null if none set
See Also:
setNextComponent(Component)

replaceComponent

public void replaceComponent(com.vaadin.ui.Component oldComponent,
                             com.vaadin.ui.Component newComponent)
This operation is not supported

Throws:
UnsupportedOperationException

getComponentIterator

public Iterator<com.vaadin.ui.Component> getComponentIterator()
Specified by:
getComponentIterator in interface com.vaadin.ui.ComponentContainer
Overrides:
getComponentIterator in class com.vaadin.ui.AbstractComponentContainer

addNavigationListener

public void addNavigationListener(NavigationManager.NavigationListener listener)
Adds a navigation listener that is notified whenever a navigation event occurs.

Parameters:
listener - the listener to add.

removeListener

public void removeListener(NavigationManager.NavigationListener listener)
Removes a navigation listener.

Parameters:
listener - the listener to remove.

isMaintainBreadcrumb

public boolean isMaintainBreadcrumb()
Returns:
true if NavigationManager should maintain a breadcrumb of visited views. The default is true.
See Also:
setMaintainBreadcrumb(boolean)

setMaintainBreadcrumb

public void setMaintainBreadcrumb(boolean maintainBreadcrumb)
Configures whether the NavigationManager maintains a breadcrumb of visited views automatically. This is handy when using NavigationViews to dive into a deep hierarchy.

Parameters:
maintainBreadcrumb - true if a breadcrumb should be maintained

getComponentCount

public int getComponentCount()

iterator

public Iterator<com.vaadin.ui.Component> iterator()


Copyright © 2014 Vaadin Ltd. All rights reserved.