Java Code Examples for com.vaadin.navigator.Navigator

The following are top voted examples for showing how to use com.vaadin.navigator.Navigator. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: svgexamples   File: MyUI.java   View source code 6 votes vote down vote up
@Override
protected void init(VaadinRequest vaadinRequest) {
    setNavigator(new Navigator(this, (View view) -> {
        tabs.setSelectedTab((Component) view);
    }));

    registerExample(SvgInVaadin.class);
    registerExample(SimplyAsAnImageOrIcon.class);
    registerExample(FileExample.class);
    registerExample(AnimationExample.class);
    registerExample(Java2DExample.class);
    registerExample(JungExample.class);

    getNavigator().setErrorView(SvgInVaadin.class);
    tabs.addSelectedTabChangeListener(e -> {
        if (e.isUserOriginated()) {
            getNavigator().navigateTo(e.getTabSheet().getSelectedTab().getClass().getSimpleName());
        }
    });
    String state = getNavigator().getState();
    getNavigator().navigateTo(state);

    tabs.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR);
    setContent(tabs);
}
 
Example 2
Project: esup-ecandidat   File: SubMenuBar.java   View source code 6 votes vote down vote up
/** Selection d'un element du sous menu
 * @param menu
 * @param vue
 */
public void selectSubMenuSheet(Menu menu, String vue,Navigator navigator, Boolean cleanListener){
	if (cleanListener){
		/*Suppression des listeners du tabSheet-->Sinon lorsqu'on ajoute un élément, il navigue donc boucle*/
		cleanTabSheetListener();
	}
	/*Suppression des listeners du tabSheet-->Sinon lorsqu'on ajoute un élément, il navigue donc boucle*/
	cleanTabSheetListener();
	menu.getSubMenu().forEach(s -> {
		if (s.getVue().equals(vue)){
			this.setSelectedTab(s.getLabel());
		}
	});
	/*Ajout du listener*/
	if (cleanListener){
		addTabSheetListener(navigator);
	}
}
 
Example 3
Project: vaadin-javaee-jaas-example   File: JaasExampleUI.java   View source code 6 votes vote down vote up
@Override
protected void init(VaadinRequest vaadinRequest) {
    final VerticalLayout contentArea = new VerticalLayout();
    contentArea.setMargin(false);
    setContent(contentArea);

    final Navigator navigator = new Navigator(this, contentArea);
    navigator.addProvider(viewProvider);
    navigator.setErrorView(InaccessibleErrorView.class);

    String defaultView = Page.getCurrent().getUriFragment();
    if (defaultView == null || defaultView.trim().isEmpty()) {
        defaultView = SecureView.VIEW_NAME;
    }

    if (isUserAuthenticated(vaadinRequest)) {
        navigator.navigateTo(defaultView);
    } else {
        navigator.navigateTo(LoginView.VIEW_NAME + "/" + defaultView);
    }
}
 
Example 4
Project: garantia   File: LoginUI.java   View source code 6 votes vote down vote up
@Override
protected void init(VaadinRequest request) {
	log.info("Levanto la pagina UI");
	
	final VerticalLayout root = new VerticalLayout();
       root.setSizeFull();
       root.setMargin(true);
       root.setSpacing(true);
       setContent(root);
	
       final Panel viewContainer = new Panel();
       viewContainer.setSizeFull();
       root.addComponent(viewContainer);
       root.setExpandRatio(viewContainer, 1.0f);
       
       Navigator navigator = new Navigator(this, viewContainer);
       //Navigator navigator = new Navigator(this, this);
       navigator.addProvider(viewProvider);
       
       log.info("Termina de levantar la pagina UI");

}
 
Example 5
Project: VaadinSpringShiroMongoDB   File: MainScreen.java   View source code 6 votes vote down vote up
public MainScreen(MyUI ui) {

        setStyleName("main-screen");

        CssLayout viewContainer = new CssLayout();
        viewContainer.addStyleName("valo-content");
        viewContainer.setSizeFull();

        //final Navigator navigator = new Navigator(ui, viewContainer);
        final Navigator navigator = new DiscoveryNavigator(ui, viewContainer);

        navigator.setErrorView(ErrorView.class);
        menu = new Menu(navigator);
        menu.addView(new SampleCrudView(), SampleCrudView.VIEW_NAME,
                SampleCrudView.VIEW_NAME, FontAwesome.EDIT);
        menu.addView(new AboutView(), AboutView.VIEW_NAME, AboutView.VIEW_NAME,
                FontAwesome.INFO_CIRCLE);

        navigator.addViewChangeListener(viewChangeListener);

        addComponent(menu);
        addComponent(viewContainer);
        setExpandRatio(viewContainer, 1);
        setSizeFull();
    }
 
Example 6
Project: MetricsToGo   File: MetricsToGoUI.java   View source code 6 votes vote down vote up
private void present() {
	context = new ClassPathXmlApplicationContext(new String[] { "./applicationContext.xml" });
	Set<Class<?>> pages = getAllPages();
	System.out.println("Pages found: " + pages.size());
	ArrayList<PageController> annotations = getAnnotations(pages);

	MetricsToGoVaadinUIController controler = new MetricsToGoVaadinUIController(context, pages);

	setContent(contentPane);
	Navigator navigator = new Navigator(this, centerContent);
	System.out.println("Annotations size:" + annotations.size());
	pages.forEach(System.out::println);
	annotations.forEach(System.out::println);
	annotations.stream()//
			.peek(System.out::println).forEach(page -> navigator.addView(page.id(), controler));

	initSidebar(navigator, annotations);
	contentPane.addComponent(centerContent);
	contentPane.setComponentAlignment(centerContent, Alignment.MIDDLE_CENTER);

	navigator.addView("main", controler);
	navigator.addView("", controler);
}
 
Example 7
Project: MetricsToGo   File: MetricsToGoUI.java   View source code 6 votes vote down vote up
private void initSidebar(Navigator navigator, ArrayList<PageController> pages) {
	Sidebar sidebar = context.getBean(Sidebar.class);

	ArrayList<Controller> controller = new ArrayList<>();
	pages.stream().map(page -> new Controller(page.id(), page.name())).forEach(controller::add);
	sidebar.setNavigator(navigator::navigateTo, controller);

	contentPane.addComponent((Component) sidebar);
	contentPane.setComponentAlignment((Component) sidebar, Alignment.TOP_LEFT);

	Label spacing = new Label();
	spacing.setWidth(2, Unit.REM);

	contentPane.addComponent(spacing);
	contentPane.setComponentAlignment(spacing, Alignment.TOP_LEFT);
}
 
Example 8
Project: KrishnasSpace   File: VaadinUI.java   View source code 6 votes vote down vote up
@Override
protected void init(VaadinRequest request) {
	final VerticalLayout mainLayout = new VerticalLayout();
	HorizontalLayout horizontalLayout = new HorizontalLayout();
	CssLayout viewLayout = new CssLayout();
	Page.getCurrent().setTitle("Vaadin Demo");
	mainLayout.setSizeFull();
	viewLayout.setSizeFull();
	mainLayout.setMargin(true);
	setContent(mainLayout);
	mainLayout.addComponent(horizontalLayout);
	mainLayout.addComponent(viewLayout);
	mainLayout.setExpandRatio(viewLayout, 1f);
	Navigator navigator = new Navigator(this, viewLayout);
	setNavigator(navigator);
	setupHeader(horizontalLayout);
	Map<String, Class<? extends MyView>> myViews = getViewProvider();
	navigator.addView("", new HomeView(myViews.keySet()));
	navigator.addProvider(new CachedViewProvider(myViews));
}
 
Example 9
Project: designer-tutorials   File: MainLayout.java   View source code 6 votes vote down vote up
public MainLayout() {
    Navigator navigator = new Navigator(UI.getCurrent(), contentPanel);
    navigator.addView(StatsView.VIEW_NAME, StatsView.class);
    navigator.addView(PluginsView.VIEW_NAME, PluginsView.class);
    navigator.addView(PermissionsView.VIEW_NAME, PermissionsView.class);

    menuButton1.addClickListener(event -> doNavigate(StatsView.VIEW_NAME));
    menuButton2
            .addClickListener(event -> doNavigate(PluginsView.VIEW_NAME));
    menuButton3.addClickListener(
            event -> doNavigate(PermissionsView.VIEW_NAME));

    if (navigator.getState().isEmpty()) {
        navigator.navigateTo(StatsView.VIEW_NAME);
    } else {
        navigator.navigateTo(navigator.getState());
    }
}
 
Example 10
Project: flightservice   File: FlightServiceUI.java   View source code 6 votes vote down vote up
@Override
protected void init(VaadinRequest request) {

	Panel panel = new Panel();
	panel.setSizeFull();

	Navigator navigator = new Navigator(this, panel);
	navigator.addView(NavigationState.HOME, HomeView.class);
	navigator.addView(NavigationState.AIRPORT_LIST, AirportListView.class);
	navigator.addView(NavigationState.FLIGHT_MAINTENANCE, FlightMaintenanceView.class);
	navigator.addView(NavigationState.FLIGHT_BOOKING, FlightBookingView.class);
	navigator.addView(NavigationState.BOOKING_CANCELLATION, BookingCancellationView.class);
	navigator.navigateTo(NavigationState.HOME);

	VerticalLayout verticalLayout = new VerticalLayout();
	verticalLayout.setSizeFull();
	verticalLayout.addComponent(createMenu());
	verticalLayout.addComponent(panel);
	verticalLayout.setExpandRatio(panel, 1);
	setContent(verticalLayout);
}
 
Example 11
Project: archetype-application-example   File: MainScreen.java   View source code 6 votes vote down vote up
public MainScreen(MockAppUI ui) {

        setStyleName("main-screen");

        CssLayout viewContainer = new CssLayout();
        viewContainer.addStyleName("valo-content");
        viewContainer.setSizeFull();

        final Navigator navigator = new Navigator(ui, viewContainer);
        navigator.setErrorView(ErrorView.class);
        menu = new Menu(navigator);
        menu.addView(new SampleCrudView(), SampleCrudView.VIEW_NAME,
                SampleCrudView.VIEW_NAME, FontAwesome.EDIT);
        menu.addView(new AboutView(), AboutView.VIEW_NAME, AboutView.VIEW_NAME,
                FontAwesome.INFO_CIRCLE);

        navigator.addViewChangeListener(viewChangeListener);

        addComponent(menu);
        addComponent(viewContainer);
        setExpandRatio(viewContainer, 1);
        setSizeFull();
    }
 
Example 12
Project: vaadin4spring   File: AbstractSideBarUI.java   View source code 6 votes vote down vote up
@Override
protected void init(VaadinRequest vaadinRequest) {
    getPage().setTitle("Vaadin4Spring Side Bar Sample");
    final HorizontalLayout rootLayout = new HorizontalLayout();
    rootLayout.setSizeFull();
    setContent(rootLayout);

    final VerticalLayout viewContainer = new VerticalLayout();
    viewContainer.setSizeFull();

    final Navigator navigator = new Navigator(this, viewContainer);
    navigator.setErrorView(new ErrorView());
    navigator.addProvider(viewProvider);
    setNavigator(navigator);

    rootLayout.addComponent(getSideBar());
    rootLayout.addComponent(viewContainer);
    rootLayout.setExpandRatio(viewContainer, 1.0f);
}
 
Example 13
Project: vaadin4spring   File: MainScreen.java   View source code 6 votes vote down vote up
@Autowired
public MainScreen(final VaadinSecurity vaadinSecurity, SpringViewProvider springViewProvider, ValoSideBar sideBar) {
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();
    setCompositionRoot(layout);
    setSizeFull();

    // By adding a security item filter, only views that are accessible to the user will show up in the side bar.
    sideBar.setItemFilter(new VaadinSecurityItemFilter(vaadinSecurity));
    layout.addComponent(sideBar);

    CssLayout viewContainer = new CssLayout();
    viewContainer.setSizeFull();
    layout.addComponent(viewContainer);
    layout.setExpandRatio(viewContainer, 1f);

    Navigator navigator = new Navigator(UI.getCurrent(), viewContainer);
    // Without an AccessDeniedView, the view provider would act like the restricted views did not exist at all.
    springViewProvider.setAccessDeniedViewClass(AccessDeniedView.class);
    navigator.addProvider(springViewProvider);
    navigator.setErrorView(ErrorView.class);
    navigator.navigateTo(navigator.getState());
}
 
Example 14
Project: gazpachoquest   File: QuestionnairesUI.java   View source code 6 votes vote down vote up
@Override
public void init(VaadinRequest request) {
    logger.info("New Vaadin UI created");
    String invitation = request.getParameter("invitation");
    logger.info("Invitation: {} of sessions : {}", invitation);
    setSizeFull();
    GazpachoViewDisplay viewDisplay = new GazpachoViewDisplay();
    setContent(viewDisplay);

    navigator = new Navigator(this, (ViewDisplay) viewDisplay);
    navigator.addProvider(viewProvider);
    navigator.setErrorProvider(new GazpachoErrorViewProvider());

    if (isUserSignedIn()) {
        navigator.navigateTo(QuestionnaireView.NAME);
    } else {
        navigator.navigateTo(LoginView.NAME);
    }
}
 
Example 15
Project: jdal   File: SimpleApplicationUI.java   View source code 6 votes vote down vote up
/**
 * Build application main window
 */
protected void buildMain() {
	this.root.removeAllComponents();
	this.top.setWidth(100, Unit.PERCENTAGE);
	this.top.setSpacing(false);
	this.top.setMargin(false);
	this.top.addComponent(buttonBar);
	this.root.addComponent(top);
	this.root.addComponent(mainView);
	this.root.setSpacing(false);
	this.root.setMargin(false);
	this.root.setExpandRatio(top, 0);
	this.root.setExpandRatio(mainView, 1);
	Navigator navigator = new Navigator(this, mainView);
	navigator.addProvider(viewProvider);
}
 
Example 16
Project: vaadin-mockapp   File: MainScreen.java   View source code 6 votes vote down vote up
public MainScreen(UI ui) {
    setSizeFull();
    createHeader();
    createMenuBar();
    final Panel viewContainer = new Panel();
    viewContainer.setSizeFull();
    viewContainer.addStyleName(Reindeer.PANEL_LIGHT);
    addComponent(viewContainer);
    setExpandRatio(viewContainer, 1);

    final Navigator navigator = new Navigator(ui, viewContainer);
    navigator.setErrorView(ErrorView.class);

    navigator.addView(SampleTableView.VIEW_NAME, new SampleTableView());
    navigator.addView(SampleFormView.VIEW_NAME, SampleFormView.class);
    navigator.addView(SampleChartView.VIEW_NAME, SampleChartView.class);

    navigator.navigateTo(navigator.getState());
}
 
Example 17
Project: holon-vaadin7   File: ViewNavigationUtils.java   View source code 5 votes vote down vote up
/**
 * Try to obtain ViewNavigator from current thread-bound {@link UI}
 * @return If current {@link UI} is available and has a ViewNavigator setted, this one is retuned. Null otherwise.
 */
public static ViewNavigator getCurrentUIViewNavigator() {
	UI ui = UI.getCurrent();
	if (ui != null) {
		Navigator navigator = ui.getNavigator();
		if (navigator instanceof ViewNavigator) {
			return (ViewNavigator) navigator;
		}
	}
	return null;
}
 
Example 18
Project: esup-ecandidat   File: SubMenuBar.java   View source code 5 votes vote down vote up
/** Construit la bar de sous menu
 * @param menu
 * @param navigator
 * @param vue
 */
public void constructMenuBar(Menu menu, Navigator navigator, String vue){
	/*Suppression des listeners du tabSheet-->Sinon lorsqu'on ajoute un élément, il navigue donc boucle*/
	cleanTabSheetListener();
	/*Suppression puis ajout des composant du menu*/
	this.removeAllComponents();
	menu.getSubMenu().forEach(s -> {
		this.addTab(s.getLabel(), applicationContext.getMessage(s.getVue() + ".title", null, UI.getCurrent().getLocale()),s.getIcon());
	});
	/*On selectionne l'onglet qui va bien, utile lors du back navigateur ou clavier*/
	selectSubMenuSheet(menu, vue, navigator,false);
	/*Ajout du listener*/
	addTabSheetListener(navigator);
}
 
Example 19
Project: esup-ecandidat   File: SubMenuBar.java   View source code 5 votes vote down vote up
/**
 * Ajout du listener du sous menu
 */
private void addTabSheetListener(Navigator navigator){
	this.addSelectedTabChangeListener(e -> {
		if (e.getTabSheet().getSelectedTab()!=null){
			navigator.navigateTo((String) ((Label)e.getTabSheet().getSelectedTab()).getData());
		}
	});
}
 
Example 20
Project: holon-vaadin   File: ViewNavigationUtils.java   View source code 5 votes vote down vote up
/**
 * Try to obtain ViewNavigator from current thread-bound {@link UI}
 * @return If current {@link UI} is available and has a ViewNavigator setted, this one is retuned. Null otherwise.
 */
public static ViewNavigator getCurrentUIViewNavigator() {
	UI ui = UI.getCurrent();
	if (ui != null) {
		Navigator navigator = ui.getNavigator();
		if (navigator instanceof ViewNavigator) {
			return (ViewNavigator) navigator;
		}
	}
	return null;
}
 
Example 21
Project: history-api-navigation   File: HistoryApiNavigationStateManager.java   View source code 5 votes vote down vote up
@Override
public void setNavigator(final Navigator navigator)
{
    if (this.navigator == null && navigator != null)
    {
        popStateListenerRegistration = page.addPopStateListener(event -> navigator.navigateTo(getState()));
    }
    else if (this.navigator != null && navigator == null)
    {
        popStateListenerRegistration.remove();
    }
    this.navigator = navigator;
}
 
Example 22
Project: incubator-tamaya-sandbox   File: ApplicationLayout.java   View source code 5 votes vote down vote up
private void setupNavigator(UI ui) {
        navigator = new Navigator(ui, content);
        navigator.setErrorView(ErrorView.class);
        // Add view change listeners so we can do things like select the correct menu item and update the page title
        navigator.addViewChangeListener(navBar);
//        navigator.addViewChangeListener(new PageTitleUpdater());
        addView("/home", HomeView.class, getViewName(HomeView.class));
        addView("/system", SystemView.class, getViewName(SystemView.class));
        addView("/config", ConfigView.class, getViewName(ConfigView.class));
        navigator.navigateTo("/home");
    }
 
Example 23
Project: dungeonstory-java   File: MainScreen.java   View source code 5 votes vote down vote up
private void setupNavigator() {
    navigator = new Navigator(DungeonStoryUI.getCurrent(), viewContainer);

    registerViews();

    // Add view change listeners so we can do things like select the correct
    // menu item and update the page title
    navigator.addViewChangeListener(navBar);
    navigator.addViewChangeListener(new PageTitleUpdater());
    navigator.addViewChangeListener(new MessageViewUpdater());

    navigator.setErrorView(ErrorView.class);
    navigator.navigateTo(navigator.getState());
}
 
Example 24
Project: limbr   File: VaadinUI.java   View source code 5 votes vote down vote up
@Override
protected void init(VaadinRequest request) {

    final VerticalLayout root = new VerticalLayout();
    root.setSizeFull();
    root.setMargin(new MarginInfo(false, false, false, true));
    root.setSpacing(true);
    setContent(root);

    HorizontalLayout topBar = new HorizontalLayout();
    topBar.setSpacing(true);

    Image logo = new Image(null, new ExternalResource("images/logo1.png"));
    logo.setHeight(31f, Unit.PIXELS);
    logo.setWidthUndefined();
    topBar.addComponent(logo);

    CssLayout navBar = new CssLayout();
    navBar.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    navBar.addComponent(createNavButton(messages.get("usersNavigationLabel"), UsersViewImpl.VIEW_NAME));
    navBar.addComponent(createNavButton(messages.get("projectsNavigationLabel"), ProjectsViewImpl.VIEW_NAME));
    navBar.addComponent(createNavButton(messages.get("rolesNavigationLabel"), RolesViewImpl.VIEW_NAME));
    topBar.addComponent(navBar);

    root.addComponent(topBar);

    final Panel viewContainer = new Panel();
    viewContainer.setSizeFull();
    root.addComponent(viewContainer);
    root.setExpandRatio(viewContainer, 1.0f);

    Navigator navigator = new Navigator(this, viewContainer);
    navigator.addProvider(viewProvider);
    navigator.setErrorProvider(viewProvider);
    navigator.setErrorView(ErrorView.class);
}
 
Example 25
Project: hawkbit-examples   File: SimulatorUI.java   View source code 5 votes vote down vote up
@Override
protected void init(final VaadinRequest request) {

    rootLayout.setSizeFull();

    final Panel viewContainer = new Panel();
    viewContainer.setSizeFull();
    rootLayout.addComponent(viewContainer);
    rootLayout.setExpandRatio(viewContainer, 1.0F);

    final Navigator navigator = new Navigator(this, viewContainer);
    navigator.addProvider(viewProvider);

    setContent(rootLayout);
}
 
Example 26
Project: Iris   File: IrisUi.java   View source code 5 votes vote down vote up
@Override
protected void init(VaadinRequest request) {

    final CssLayout root = new CssLayout();
    root.setSizeFull();
    setContent(root);

    Navigator navigator = new Navigator(this, root);
    navigator.addProvider(viewProvider);
}
 
Example 27
Project: bookery   File: AppHeader.java   View source code 5 votes vote down vote up
private MHorizontalLayout createSearchBar() {
    Label header = new Label("Bookery");
    header.addStyleName(ValoTheme.LABEL_BOLD);
    header.setSizeUndefined();
    header.addStyleName(ValoTheme.LABEL_H3);
    
    searchText = new TextField();
    searchText.setIcon(FontAwesome.SEARCH);
    searchText.addStyleName(ValoTheme.TEXTFIELD_LARGE);
    searchText.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    searchText.setWidth(100, Unit.PERCENTAGE);
    searchText.setInputPrompt("hier einfach suchen..");
    Button searchButton = new Button("such!", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Navigator navigator = ((App)UI.getCurrent()).getNavigator();
            if (navigator.getState().contains("search")) {
                navigator.navigateTo(navigator.getState());
            }
            else {
                navigator.navigateTo(SearchView.id);
            }
            
        }
    });
    searchButton.addStyleName(ValoTheme.BUTTON_LARGE);
    searchText.addShortcutListener(new Button.ClickShortcut(searchButton, ShortcutAction.KeyCode.ENTER));

    MHorizontalLayout layout = new MHorizontalLayout(header,searchText,searchButton);
    layout.setWidth(100, Unit.PERCENTAGE);
    layout.setExpandRatio(searchText, 1.0f);
    return layout;
}
 
Example 28
Project: vaadin-bug-demos   File: MainUI.java   View source code 5 votes vote down vote up
@Override
protected void init(VaadinRequest vaadinRequest) {
    Navigator navigator = new Navigator(this, this);
    navigator.addProvider(viewProvider);
    setNavigator(navigator);
    navigator.addViewChangeListener(this);
}
 
Example 29
Project: GridStack   File: DemoUI.java   View source code 5 votes vote down vote up
@Override
protected void init(VaadinRequest request) {

    navigator = new Navigator(this, this);
    navigator.addView(MenuView.VIEW_NAME, MenuView.class);
    navigator.addView(TestView.VIEW_NAME, TestView.class);
    navigator.addView(SplitView.VIEW_NAME, SplitView.class);
    navigator.addView(SimpleView.VIEW_NAME, SimpleView.class);
}
 
Example 30
Project: designer-tutorials   File: MainLayout.java   View source code 5 votes vote down vote up
public MainLayout() {
    navigator = new Navigator(UI.getCurrent(), (ViewDisplay) this);
    addNavigatorView(DashboardView.VIEW_NAME, DashboardView.class,
            menuButton1);
    addNavigatorView(OrderView.VIEW_NAME, OrderView.class, menuButton2);
    addNavigatorView(AboutView.VIEW_NAME, AboutView.class, menuButton3);
    if (navigator.getState().isEmpty()) {
        navigator.navigateTo(DashboardView.VIEW_NAME);
    }
}
 
Example 31
Project: mondo-collab-framework   File: SessionSelectionPage.java   View source code 5 votes vote down vote up
public SessionSelectionPage(final Navigator navigator, Application application) {
	System.out.println("Construct SessionSelectionPage");
	this.application = application;
	this.sessions = new ArrayList<CollaborationSession>();
	this.navigator = navigator;
	setSizeFull();
	initSessionsView();
}
 
Example 32
Project: mondo-collab-framework   File: LoginPage.java   View source code 5 votes vote down vote up
public LoginPage(final Navigator navigator, Application application) {
	System.out.println("Construct LoginPage");
	this.navigator = navigator;

	Panel panel = new Panel("Login");
	panel.setSizeUndefined();
	addComponent(panel, "left: 20px; top: 20px;");

	CustomLayout custom = new CustomLayout("loginPage");

	panel.setContent(custom);
	
	TextField username = new TextField();
	custom.addComponent(username, "username");
	TextField password = new TextField();
	custom.addComponent(password, "password");

	boolean isAuthorized = this.authenticate();
	
	Button buttonLogin = new Button("Login");
	buttonLogin.addClickListener(new Button.ClickListener() {
		@Override
		public void buttonClick(ClickEvent event) {
			if(isAuthorized) {
				application.bindUser(
					username.getValue(), 
					password.getValue()
				);
				navigator.navigateTo(SessionSelectionPage.NAME);
			}
		}
	});
	this.application = application;
	custom.addComponent(buttonLogin, "buttonLogin");
}
 
Example 33
Project: metl   File: ViewManager.java   View source code 5 votes vote down vote up
public void init(AppUI ui, ComponentContainer container) {
    navigator = new Navigator(ui, container);
    navigator.setErrorView(new PageNotFoundView(this));
    if (views != null) {
        for (View view : views) {
            TopBarLink menu = (TopBarLink) view.getClass().getAnnotation(TopBarLink.class);
            if (menu != null && menu.uiClass().equals(AppUI.class)) {
                navigator.addView(menu.id(), view);
            }
        }
    }
}
 
Example 34
Project: cdi-tutorial   File: NavigationServiceImpl.java   View source code 5 votes vote down vote up
@PostConstruct
public void initialize() {
    if (ui.getNavigator() == null) {
        Navigator navigator = new Navigator(ui, ui);
        navigator.addProvider(viewProvider);
        navigator.setErrorView(errorView);
    }
}
 
Example 35
Project: vaadin4spring   File: NavigationUI.java   View source code 5 votes vote down vote up
@Override
protected void init(VaadinRequest request) {
    final VerticalLayout root = new VerticalLayout();
    root.setSizeFull();
    root.setMargin(true);
    root.setSpacing(true);
    setContent(root);

    final CssLayout navigationBar = new CssLayout();
    navigationBar.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    navigationBar.addComponent(createNavigationButton("Prototype Scoped View", PrototypeScopedView.VIEW_NAME));
    navigationBar.addComponent(createNavigationButton("UI Scoped View", UIScopedView.VIEW_NAME));
    navigationBar.addComponent(createNavigationButton("View Scoped View", ViewScopedView.VIEW_NAME));
    navigationBar.addComponent(createNavigationButton("Access Control", AccessControlView.VIEW_NAME));
    root.addComponent(navigationBar);

    final Panel viewContainer = new Panel();
    viewContainer.setSizeFull();
    root.addComponent(viewContainer);
    root.setExpandRatio(viewContainer, 1.0f);

    viewProvider.setAccessDeniedViewClass(AccessDeniedView.class);

    Navigator navigator = new Navigator(this, viewContainer);
    navigator.setErrorView(new ErrorView()); // You can still create the error view yourself if you want to.
    navigator.addProvider(viewProvider);
}
 
Example 36
Project: vaadin4spring   File: MainUI.java   View source code 5 votes vote down vote up
@Override
protected void init(VaadinRequest request) {
    getPage().setTitle("Vaadin Shared Security Demo");
    // Let's register a custom error handler to make the 'access denied' messages a bit friendlier.
    setErrorHandler(new DefaultErrorHandler() {
        @Override
        public void error(com.vaadin.server.ErrorEvent event) {
            if (SecurityExceptionUtils.isAccessDeniedException(event.getThrowable())) {
                Notification.show("Sorry, you don't have access to do that.");
            } else {
                super.error(event);
            }
        }
    });
    HorizontalLayout layout = new HorizontalLayout();
    layout.setSizeFull();

    // By adding a security item filter, only views that are accessible to the user will show up in the side bar.
    sideBar.setItemFilter(new VaadinSecurityItemFilter(vaadinSecurity));
    layout.addComponent(sideBar);

    CssLayout viewContainer = new CssLayout();
    viewContainer.setSizeFull();
    layout.addComponent(viewContainer);
    layout.setExpandRatio(viewContainer, 1f);

    Navigator navigator = new Navigator(this, viewContainer);
    // Without an AccessDeniedView, the view provider would act like the restricted views did not exist at all.
    springViewProvider.setAccessDeniedViewClass(AccessDeniedView.class);
    navigator.addProvider(springViewProvider);
    navigator.setErrorView(ErrorView.class);
    navigator.navigateTo(navigator.getState());

    setContent(layout); // Call this here because the Navigator must have been configured before the Side Bar can be attached to a UI.
}
 
Example 37
Project: LazyLayouts   File: DemoUI.java   View source code 5 votes vote down vote up
@Override
protected void init(VaadinRequest request) {

    Navigator navigator = new Navigator(this, this);
    setNavigator(navigator);

    navigator.setErrorView(ErrorView.class);

    navigator.addView(MenuView.VIEW_ID, MenuView.class);
    navigator.addView(LazyVLView.VIEW_ID, LazyVLView.class);
    navigator.addView(LazyWindowView.VIEW_ID, LazyWindowView.class);
    navigator.addView(TabSheetView.VIEW_ID, TabSheetView.class);
    navigator.addView(Issue7View.VIEW_ID, Issue7View.class);
}
 
Example 38
Project: Vaadin4Spring-MVP-Sample-SpringSecuritySocial   File: MainUI.java   View source code 5 votes vote down vote up
@Override
protected void init(VaadinRequest request) {
	setLocale(new Locale.Builder().setLanguage("sr").setScript("Latn").setRegion("RS").build());
	
    Navigator navigator = new Navigator(MainUI.this, (ViewDisplay)mainLayout);
    navigator.addProvider(springViewProvider);
    navigator.addViewChangeListener(mainLayout);
    
    setContent(mainLayout);
    
    /*
     * Handling redirections
     */        
    RequestAttributes attrs = RequestContextHolder.getRequestAttributes();        
    if (sessionStrategy.getAttribute(attrs, VaadinRedirectObject.REDIRECT_OBJECT_SESSION_ATTRIBUTE) != null) {        	
    	VaadinRedirectObject redirectObject = (VaadinRedirectObject) sessionStrategy.getAttribute(attrs, VaadinRedirectObject.REDIRECT_OBJECT_SESSION_ATTRIBUTE);
    	sessionStrategy.removeAttribute(attrs, VaadinRedirectObject.REDIRECT_OBJECT_SESSION_ATTRIBUTE);
    	 
    	navigator.navigateTo(redirectObject.getRedirectViewToken());
    	
    	if (redirectObject.getErrorMessage() != null) {
    		Notification.show("Error", redirectObject.getErrorMessage(), Type.ERROR_MESSAGE);
    	}
    	
    }
           
}
 
Example 39
Project: fns-projects   File: Application.java   View source code 5 votes vote down vote up
@Override
protected void init(VaadinRequest vaadinRequest) {
	Navigator navigator = new Navigator(this, this);
	navigator.setErrorView(errorView);
	navigator.addProvider(viewProvider);
	setNavigator(navigator);
}
 
Example 40
Project: Vaadin4Spring-MVP-Sample   File: MyVaadinUI.java   View source code 5 votes vote down vote up
@Override
protected void init(VaadinRequest request) {
	setLocale(new Locale.Builder().setLanguage("sr").setScript("Latn").setRegion("RS").build());
	
    Navigator navigator = new Navigator(MyVaadinUI.this, (ViewDisplay)mainLayout);
    navigator.addProvider(springViewProvider);
    
    navigator.addViewChangeListener(mainLayout);
    setContent(mainLayout);
}