private void addContainerComponents(SingleComponentContainer container, List<Element> elements, SlideContainerPresenter presenter) { elements.stream().map(m -> createComponentFromElement(m, presenter)).filter(Objects::nonNull).forEach(e -> { Component component = e.getComponent(); if (elements.size() == 1 && component instanceof Layout) { container.setContent((Layout) component); } else { GridLayout gridLayout = new GridLayout(1, 1); gridLayout.setSizeFull(); container.setContent(gridLayout); gridLayout.addComponent(component); gridLayout.setComponentAlignment(component, e.getAlignment()); } }); }
@Override public void init(UI ui, SingleComponentContainer container) { init(ui, new UriFragmentManager(ui.getPage()), new SingleContainerViewDisplay(container)); }
@Override public Builder viewDisplay(SingleComponentContainer container) { this.viewDisplay = new SingleContainerViewDisplay(container); return builder(); }
/** * Constructor * @param container SingleComponentContainer which content has to be replaced by the view content */ public SingleContainerViewDisplay(SingleComponentContainer container) { super(); this.container = container; }
@Override public void init(UI ui, SingleComponentContainer container) { init(ui, new UriFragmentManager(ui.getPage()), new SingleComponentContainerViewDisplay(container)); }
@Override public Builder viewDisplay(SingleComponentContainer container) { this.viewDisplay = new SingleComponentContainerViewDisplay(container); return builder(); }
public CustomViewDisplay(final SingleComponentContainer contentNode) { this.contentNode = contentNode; }
public SiteNavigator(UI ui, SingleComponentContainer container) { super(ui, container); }
public MVPDiscoveryNavigator(UI ui, SingleComponentContainer container) { super(ui, container); viewPresenterMap.clear(); views.clear(); }
/** * Initializes an injected navigator and registers {@link SpringViewProvider} for it. * <p> * The default navigation state manager (based on URI fragments) is used. * </p> * <p> * Navigation is automatically initiated after {@code UI.init()} if a navigator was created. If at a later point * changes are made to the navigator, {@code navigator.navigateTo(navigator.getState())} may need to be explicitly * called to ensure the current view matches the navigation state. * </p> * @param ui The UI to which this Navigator is attached * @param container The single component container used to display the views handled by this navigator */ void init(UI ui, SingleComponentContainer container);
/** * Creates a navigator that is tracking the active view using URI fragments of the {@link Page} containing the given * UI and replacing the contents of a {@link SingleComponentContainer} with the active view. * @param ui The UI to which this Navigator is attached. * @param container The SingleComponentContainer whose contents should be replaced with the active view on view * change */ public DefaultViewNavigator(UI ui, SingleComponentContainer container) { this(ui, new SingleComponentContainerViewDisplay(container)); }
/** * Set the {@link SingleComponentContainer} which has to used to display {@link View} instances using * {@link SingleComponentContainer#setContent(com.vaadin.ui.Component)}. * @param container The {@link SingleComponentContainer} which has to used to display {@link View} instances * @return this */ Builder viewDisplay(SingleComponentContainer container);
/** * Creates a navigator that is tracking the active view using the HTML5 History API * of the {@link Page} containing the given UI and replacing the contents of * a {@link SingleComponentContainer} with the active view. * <p> * Views must implement {@link Component} when using this constructor. * <p> * Navigation is automatically initiated after {@code UI.init()} if a * navigator was created. If at a later point changes are made to the * navigator, {@code navigator.navigateTo(navigator.getState())} may need to * be explicitly called to ensure the current view matches the navigation * state. * * @param ui * The UI to which this Navigator is attached. * @param container * The SingleComponentContainer whose contents should be replaced * with the active view on view change */ public static Navigator createHistoryApiNavigator(final UI ui, final SingleComponentContainer container){ return createHistoryApiNavigator( ui, new Navigator.SingleComponentContainerViewDisplay(container)); }
/** * Sets the content of this container. The content is a component that * serves as the outermost item of the visual contents. * * The content should always be set, either as a constructor parameter or by * calling this method. * * @param content * a component (typically a layout) to use as content * @return this (for method chaining) * @see SingleComponentContainer#setContent(Component) */ @SuppressWarnings("unchecked") public default THIS withContent(Component content) { ((SingleComponentContainer) this).setContent(content); return (THIS) this; }
/** * Creates a navigator that is tracking the active view using URI fragments * of the {@link com.vaadin.server.Page} containing the given UI and * replacing the contents of a * {@link com.vaadin.ui.SingleComponentContainer} with the active view. * * <p> * This constructor is exactly similar to * {@link com.vaadin.navigator.Navigator#Navigator(com.vaadin.ui.UI, com.vaadin.ui.SingleComponentContainer)} * * @param ui the UI for which the Navigator is to be created * @param container the component in which the views are to be displayed * @see com.vaadin.navigator.Navigator#Navigator(com.vaadin.ui.UI, * com.vaadin.ui.SingleComponentContainer) */ public MNavigator(UI ui, SingleComponentContainer container) { super(ui, container); }
/** * Sets the content of this container. The content is a component that * serves as the outermost item of the visual contents. * * The content should always be set, either as a constructor parameter or by * calling this method. * * @param content * a component (typically a layout) to use as content * @return this (for method chaining) * @see SingleComponentContainer#setContent(Component) */ public default S withContent(Component content) { ((SingleComponentContainer) this).setContent(content); return (S) this; }