com.holonplatform.vaadin7.navigator.internal

## Class DefaultViewNavigator

- java.lang.Object
- - com.vaadin.navigator.Navigator
  - - com.holonplatform.vaadin7.navigator.internal.DefaultViewNavigator

- All Implemented Interfaces:
    ViewConfiguration.ViewConfigurationProvider, ViewNavigatorAdapter, ViewNavigator, Serializable

      public class DefaultViewNavigator
      extends com.vaadin.navigator.Navigator
      implements ViewNavigatorAdapter

  Default `ViewNavigator` implementation extending Vaadin default `Navigator`
  Since:
    5.0.0
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `DefaultViewNavigator.ViewNavigatorBuilder` `Builder` implementation for fluent-style `ViewNavigator` creation

    - ### Nested classes/interfaces inherited from class com.vaadin.navigator.Navigator

      `com.vaadin.navigator.Navigator.ClassBasedViewProvider, com.vaadin.navigator.Navigator.ComponentContainerViewDisplay, com.vaadin.navigator.Navigator.EmptyView, com.vaadin.navigator.Navigator.SingleComponentContainerViewDisplay, com.vaadin.navigator.Navigator.StaticViewProvider, com.vaadin.navigator.Navigator.UriFragmentManager`

    - ### Nested classes/interfaces inherited from interface com.holonplatform.vaadin7.navigator.ViewNavigator

      `ViewNavigator.Builder, ViewNavigator.NavigationBuilder, ViewNavigator.NavigatorBuilder<B extends ViewNavigator.NavigatorBuilder<B>>, ViewNavigator.ViewNavigationException, ViewNavigator.ViewNavigatorChangeEvent`

  - ### Field Summary

    - ### Fields inherited from interface com.holonplatform.vaadin7.navigator.ViewNavigator

      `CONTEXT_KEY, VIEW_URI_SCHEME`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `DefaultViewNavigator()` Default construtor.
    `DefaultViewNavigator(com.vaadin.ui.UI ui, com.vaadin.ui.ComponentContainer container)` Creates a navigator that is tracking the active view using URI fragments of the `Page` containing the given UI and replacing the contents of a `ComponentContainer` with the active view.
    `DefaultViewNavigator(com.vaadin.ui.UI ui, com.vaadin.navigator.NavigationStateManager stateManager, com.vaadin.navigator.ViewDisplay display)` Creates a navigator.
    `DefaultViewNavigator(com.vaadin.ui.UI ui, com.vaadin.ui.SingleComponentContainer container)` Creates a navigator that is tracking the active view using URI fragments of the `Page` containing the given UI and replacing the contents of a `SingleComponentContainer` with the active view.
    `DefaultViewNavigator(com.vaadin.ui.UI ui, com.vaadin.navigator.ViewDisplay display)` Creates a navigator that is tracking the active view using URI fragments of the `Page` containing the given UI.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addProvider(com.vaadin.navigator.ViewProvider provider)`
    `NavigatorActuator<?>` | `getActuator()` Get the NavigatorActuator associated to this adapter
    `String` | `getCurrentViewName()` Get current (active) view name in navigator
    `String` | `getDefaultViewName()` Get default view name
    `ViewConfiguration` | `getViewConfiguration(Class<? extends com.vaadin.navigator.View> viewClass)` Get `ViewConfiguration` associated to given view class This method is intended for internal use only.
    `boolean` | `navigateBack()` Navigates back to previous `View`, if any.
    `com.vaadin.ui.Window` | `navigateInWindow(String viewName, Consumer<ViewWindowConfigurator> windowConfiguration, Map<String,Object> parameters)` Navigate to the `View` identified by given `viewName` using the same behaviour of `ViewNavigator.navigateTo(String, Map)` but rendering the View contents in an application Window, using optional `windowConfiguration` to setup Window features.
    `void` | `navigateTo(String navigationState)` Navigates to the `View` identified by given `viewName`.
    `void` | `navigateTo(String viewName, Map<String,Object> parameters)` Navigates to the `View` identified by given `viewName` using given `parameters`, if any, and linking them to View fields using `ViewParameter` annotated view class fields.
    `void` | `navigateToDefault()` Navigates to the default View
    `void` | `navigateToState(String navigationState)` Navigates to a view and initialize the view with given parameters.
    `void` | `navigateToView(com.vaadin.navigator.View view, String viewName, String parameters)` Navigate to given View
    `void` | `removeProvider(com.vaadin.navigator.ViewProvider provider)`
    `void` | `setDefaultViewName(String defaultViewName)` Set the default view name.
    `void` | `setup(com.vaadin.ui.UI ui, com.vaadin.navigator.NavigationStateManager stateManager, com.vaadin.navigator.ViewDisplay display)` Init navigator
    `void` | `setViewClassProvider(com.vaadin.navigator.ViewProvider provider, ViewClassProvider viewClassProvider)` Set the `ViewClassProvider` bound to given `ViewProvider`.
    `void` | `updateCurrentNavigationState(com.vaadin.navigator.ViewChangeListener.ViewChangeEvent event)` Update current navigation state relying in given View change event

    - ### Methods inherited from class com.vaadin.navigator.Navigator

      `addView, addView, addViewChangeListener, destroy, getCurrentView, getDisplay, getState, getUI, removeView, removeViewChangeListener, setErrorProvider, setErrorView, setErrorView`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.holonplatform.vaadin7.navigator.ViewNavigator

      `addViewChangeListener, builder, getCurrent, getCurrentView, getViewContent, navigateInWindow, navigateInWindow, navigateInWindow, removeViewChangeListener, require, toView`

- - ### Constructor Detail

    - #### DefaultViewNavigator

          public DefaultViewNavigator(com.vaadin.ui.UI ui,
                                      com.vaadin.ui.ComponentContainer container)

      Creates a navigator that is tracking the active view using URI fragments of the `Page` containing the given UI and replacing the contents of a `ComponentContainer` with the active view.

      All components of the container are removed each time before adding the active `View`.

      Parameters:
        `ui` - The UI to which this Navigator is attached.
        `container` - The ComponentContainer whose contents should be replaced with the active view on view change

    - #### DefaultViewNavigator

          public DefaultViewNavigator(com.vaadin.ui.UI ui,
                                      com.vaadin.ui.SingleComponentContainer container)

      Creates a navigator that is tracking the active view using URI fragments of the `Page` containing the given UI and replacing the contents of a `SingleComponentContainer` with the active view.
      Parameters:
        `ui` - The UI to which this Navigator is attached.
        `container` - The SingleComponentContainer whose contents should be replaced with the active view on view change

    - #### DefaultViewNavigator

          public DefaultViewNavigator(com.vaadin.ui.UI ui,
                                      com.vaadin.navigator.ViewDisplay display)

      Creates a navigator that is tracking the active view using URI fragments of the `Page` containing the given UI.
      Parameters:
        `ui` - The UI to which this Navigator is attached.
        `display` - The ViewDisplay used to display the views.

    - #### DefaultViewNavigator

          public DefaultViewNavigator(com.vaadin.ui.UI ui,
                                      com.vaadin.navigator.NavigationStateManager stateManager,
                                      com.vaadin.navigator.ViewDisplay display)

      Creates a navigator.

      When a custom navigation state manager is not needed, use one of the other constructors which use a URI fragment based state manager.

      Parameters:
        `ui` - The UI to which this Navigator is attached.
        `stateManager` - The NavigationStateManager keeping track of the active view and enabling bookmarking and direct navigation or null to use the default implementation
        `display` - The ViewDisplay used to display the views handled by this navigator

    - #### DefaultViewNavigator

          public DefaultViewNavigator()

      Default construtor.

      With this constructor, `init(UI, NavigationStateManager, ViewDisplay)` method is not called, since navigator initialization is delegated to subclasses.

  - ### Method Detail

    - #### getActuator

          public NavigatorActuator<?> getActuator()

      Description copied from interface: `ViewNavigatorAdapter`
      Get the NavigatorActuator associated to this adapter
      Specified by:
        `getActuator` in interface `ViewNavigatorAdapter`
      Returns:
        NavigatorActuator

    - #### setup

          public void setup(com.vaadin.ui.UI ui,
                            com.vaadin.navigator.NavigationStateManager stateManager,
                            com.vaadin.navigator.ViewDisplay display)

      Description copied from interface: `ViewNavigatorAdapter`
      Init navigator
      Specified by:
        `setup` in interface `ViewNavigatorAdapter`
      Parameters:
        `ui` - UI
        `stateManager` - NavigationStateManager
        `display` - View display

    - #### updateCurrentNavigationState

          public void updateCurrentNavigationState(com.vaadin.navigator.ViewChangeListener.ViewChangeEvent event)

      Description copied from interface: `ViewNavigatorAdapter`
      Update current navigation state relying in given View change event
      Specified by:
        `updateCurrentNavigationState` in interface `ViewNavigatorAdapter`
      Parameters:
        `event` - View change event

    - #### navigateToState

          public void navigateToState(String navigationState)

      Description copied from interface: `ViewNavigator`
      Navigates to a view and initialize the view with given parameters.

      The `navigationState` string consists of a view name optionally followed by a slash and a parameters part that is passed as-is to the view. ViewProviders are used to find and create the correct type of view.

      If multiple providers return a matching view, the view with the longest name is selected. This way, e.g. hierarchies of subviews can be registered like "admin/", "admin/users", "admin/settings" and the longest match is used.

      If the view being deactivated indicates it wants a confirmation for the navigation operation, the user is asked for the confirmation.

      Registered `ViewChangeListener`s are called upon successful view change.

      Specified by:
        `navigateToState` in interface `ViewNavigator`
      Parameters:
        `navigationState` - View name and parameters

    - #### navigateToView

          public void navigateToView(com.vaadin.navigator.View view,
                                     String viewName,
                                     String parameters)

      Description copied from interface: `ViewNavigatorAdapter`
      Navigate to given View
      Specified by:
        `navigateToView` in interface `ViewNavigatorAdapter`
      Parameters:
        `view` - View instance
        `viewName` - View name
        `parameters` - View parameters

    - #### addProvider

          public void addProvider(com.vaadin.navigator.ViewProvider provider)

      Overrides:
        `addProvider` in class `com.vaadin.navigator.Navigator`

    - #### removeProvider

          public void removeProvider(com.vaadin.navigator.ViewProvider provider)

      Overrides:
        `removeProvider` in class `com.vaadin.navigator.Navigator`

    - #### navigateTo

          public void navigateTo(String navigationState)

      Description copied from interface: `ViewNavigator`
      Navigates to the `View` identified by given `viewName`.

      If the view being deactivated indicates it wants a confirmation for the navigation operation, the user is asked for the confirmation.

      Registered `ViewChangeListener`s are called upon successful view change.

      Specified by:
        `navigateTo` in interface `ViewNavigator`
      Overrides:
        `navigateTo` in class `com.vaadin.navigator.Navigator`
      Parameters:
        `navigationState` - View name

    - #### navigateTo

          public void navigateTo(String viewName,
                                 Map<String,Object> parameters)
                          throws ViewNavigator.ViewNavigationException

      Description copied from interface: `ViewNavigator`
      Navigates to the `View` identified by given `viewName` using given `parameters`, if any, and linking them to View fields using `ViewParameter` annotated view class fields.

      If the view being deactivated indicates it wants a confirmation for the navigation operation, the user is asked for the confirmation.

      Registered `ViewChangeListener`s are called upon successful view change.

      Specified by:
        `navigateTo` in interface `ViewNavigator`
      Parameters:
        `viewName` - View name
        `parameters` - Optional view parameters
      Throws:
        `ViewNavigator.ViewNavigationException` - View with given name cannot be found or other view handling error

    - #### navigateInWindow

          public com.vaadin.ui.Window navigateInWindow(String viewName,
                                                       Consumer<ViewWindowConfigurator> windowConfiguration,
                                                       Map<String,Object> parameters)
                                                throws ViewNavigator.ViewNavigationException

      Description copied from interface: `ViewNavigator`
      Navigate to the `View` identified by given `viewName` using the same behaviour of `ViewNavigator.navigateTo(String, Map)` but rendering the View contents in an application Window, using optional `windowConfiguration` to setup Window features.
      Specified by:
        `navigateInWindow` in interface `ViewNavigator`
      Parameters:
        `viewName` - View name
        `windowConfiguration` - View Window configurator
        `parameters` - Optional view parameters
      Returns:
        The UI Window in which the View is displayed
      Throws:
        `ViewNavigator.ViewNavigationException` - View with given name cannot be found or other view handling error

    - #### navigateBack

          public boolean navigateBack()
                               throws ViewNavigator.ViewNavigationException

      Description copied from interface: `ViewNavigator`
      Navigates back to previous `View`, if any. In no previous View is available and a default view is defined, navigator will navigate to the default view.
      Specified by:
        `navigateBack` in interface `ViewNavigator`
      Returns:
        `true` if a previous view in navigation history, or the default view, was available and back navigation succeeded
      Throws:
        `ViewNavigator.ViewNavigationException` - View handling error

    - #### navigateToDefault

          public void navigateToDefault()
                                 throws ViewNavigator.ViewNavigationException

      Description copied from interface: `ViewNavigator`
      Navigates to the default View
      Specified by:
        `navigateToDefault` in interface `ViewNavigator`
      Throws:
        `ViewNavigator.ViewNavigationException` - If no default View is available or other view handling error

    - #### getDefaultViewName

          public String getDefaultViewName()

      Description copied from interface: `ViewNavigator`
      Get default view name
      Specified by:
        `getDefaultViewName` in interface `ViewNavigator`
      Returns:
        Default view name, or `null` if not defined

    - #### setDefaultViewName

          public void setDefaultViewName(String defaultViewName)

      Set the default view name. If a `View` with given `defaultViewName` is valid and provided by registered ViewProviders, it is used as target of `ViewNavigator.navigateToDefault()` method and as a fallback by `ViewNavigator.navigateBack()` method if no other View is available in history.
      Parameters:
        `defaultViewName` - the default view name to set

    - #### setViewClassProvider

          public void setViewClassProvider(com.vaadin.navigator.ViewProvider provider,
                                           ViewClassProvider viewClassProvider)

      Description copied from interface: `ViewNavigatorAdapter`
      Set the `ViewClassProvider` bound to given `ViewProvider`.
      Specified by:
        `setViewClassProvider` in interface `ViewNavigatorAdapter`
      Parameters:
        `provider` - View provider (not null)
        `viewClassProvider` - View class provider

    - #### getCurrentViewName

          public String getCurrentViewName()

      Description copied from interface: `ViewNavigator`
      Get current (active) view name in navigator
      Specified by:
        `getCurrentViewName` in interface `ViewNavigator`
      Returns:
        Current view name, or `null` if no view is currently active in navigator

    - #### getViewConfiguration

          public ViewConfiguration getViewConfiguration(Class<? extends com.vaadin.navigator.View> viewClass)

      Description copied from interface: `ViewConfiguration.ViewConfigurationProvider`
      Get `ViewConfiguration` associated to given view class

      This method is intended for internal use only.

      Specified by:
        `getViewConfiguration` in interface `ViewConfiguration.ViewConfigurationProvider`
      Parameters:
        `viewClass` - View class
      Returns:
        Associated ViewConfiguration, or `null` if not available

Copyright © 2019 The Holon Platform. All rights reserved.