Example usage for com.vaadin.navigator Navigator Navigator

List of usage examples for com.vaadin.navigator Navigator Navigator

Introduction

In this page you can find the example usage for com.vaadin.navigator Navigator Navigator.

Prototype

public Navigator(UI ui, ViewDisplay display) 

Source Link

Document

Creates a navigator that is tracking the active view using URI fragments of the Page containing the given UI.

Usage

From source file:annis.gui.AnnisUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    super.init(request);
    setErrorHandler(this);

    searchView = new SearchView(AnnisUI.this);
    adminView = new AdminView(AnnisUI.this);
    queryController = new QueryController(searchView, AnnisUI.this);

    toolbar = new MainToolbar();
    toolbar.setQueryController(queryController);

    toolbar.addLoginListener(searchView);
    toolbar.addLoginListener(adminView);

    nav = new Navigator(AnnisUI.this, AnnisUI.this);
    nav.addView(SearchView.NAME, searchView);
    nav.addView(AdminView.NAME, adminView);
    nav.addViewChangeListener(AnnisUI.this);

    addExtension(toolbar.getScreenshotExtension());

    loadInstanceFonts();//from w w  w .ja  v  a2 s.  co m
}

From source file:at.jku.ce.adaptivetesting.vaadin.ui.core.VaadinUI.java

License:LGPL

public VaadinUI() {
    // Set up the Navigator
    navigator = new Navigator(this, this);

    // Create Welcome Screen
    MainUI mainScreen = new MainUI();
    mainScreen.setMargin(true);//from  ww  w. ja  v a 2 s .  c  o m
    Button start = new Button("Start", e -> {
        navigator.navigateTo(Views.TEST.toString());
    });
    start.setWidth("40%");
    start.setHeight("40%");
    //mainScreen.addComponent(new HtmlLabel(HtmlUtils.center("h1", "Willkommen zur " + productData)));
    mainScreen.addComponent(new HtmlLabel(HtmlUtils.center("h2", "Bitte klicke den <b>" + start.getCaption()
            + "</b> Button um mit dem Rechnungswesentest zu beginnen!")));
    mainScreen.addComponent(start);
    mainScreen.setComponentAlignment(start, Alignment.MIDDLE_CENTER);

    navigator.addView(Views.DEFAULT.toString(), mainScreen);
    // Question view
    // Change this to the questionManager you like
    final QuestionManager manager = new AccountingQuestionManager("Rechnungswesentest");
    navigator.addView(Views.TEST.toString(), manager);
    navigator.addView(Views.Log.toString(), new LogView(new File(Servlet.getLogFileName())));
    navigator.addView(Views.Admin.toString(), new AdminView(manager));
    navigator.addView(Views.Results.toString(), new ResultView(manager));
    navigator.setErrorView(mainScreen);
    LogHelper.logInfo("Startup completed");
}

From source file:at.reisisoft.jku.ce.adaptivelearning.vaadin.ui.core.VaadinUI.java

License:LGPL

public VaadinUI() {
    // Set up the Navigator
    navigator = new Navigator(this, this);

    // Create Welcome Screen
    MainUI mainScreen = new MainUI();
    mainScreen.setMargin(true);/*from   ww  w  . ja v  a2s. com*/
    Button start = new Button("Start", e -> {
        navigator.navigateTo(Views.TEST.toString());
    });
    start.setWidth("40%");
    start.setHeight("40%");
    mainScreen.addComponent(new HtmlLabel(HtmlUtils.center("h1", "Welcome to " + productData)));
    mainScreen.addComponent(new HtmlLabel(
            HtmlUtils.center("h2", "Click the <b>" + start.getCaption() + "</b> Button to start!")));
    mainScreen.addComponent(start);
    mainScreen.setComponentAlignment(start, Alignment.MIDDLE_CENTER);

    navigator.addView(Views.DEFAULT.toString(), mainScreen);
    // Question view
    // Change this to the questionManager you like
    final QuestionManager manager = new AccountingQuestionManager("Accounting Quiz");
    navigator.addView(Views.TEST.toString(), manager);
    navigator.addView(Views.Log.toString(), new LogView(new File(Servlet.getLogFileName())));
    navigator.setErrorView(mainScreen);
    LogHelper.logInfo("Startup completed");
}

From source file:by.bigvova.MainUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    EventBus.register(this);
    getPage().setTitle("FoodNote");
    UI.getCurrent().setLocale(Locale.forLanguageTag("ru-RU"));
    // Let's register a custom error handler to make the 'access denied' messages a bit friendlier.
    setErrorHandler(new DefaultErrorHandler() {
        @Override//www  . j  a  v a2s.  c o  m
        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));
    sideBar.setHeader(new CssLayout() {
        {
            Label header = new Label("<span>Food</span>Note", ContentMode.HTML);
            header.setWidth(100, Unit.PERCENTAGE);
            header.setHeightUndefined();
            addComponent(header);
            addComponent(buildUserMenu());
        }
    });
    sideBar.getHeader().setStyleName("branding");
    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.
}

From source file:ch.bfh.blue.UI.MainUI.java

License:Open Source License

@Override
protected void init(VaadinRequest vaadinRequest) {
    final VerticalLayout layout = new VerticalLayout();
    final CssLayout viewLayout = new CssLayout();
    final Navigator navigator;

    getSession().setAttribute("databaseLock", true);
    try {/*from ww  w  .  j  a  v  a2 s .c  o  m*/
        controller = new Controller();
    } catch (InstantiationException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    }

    getSession().setAttribute("user", null);

    // /*
    // * is called upon closing of the UI do cleanup stuff here
    // */
    // addDetachListener(new DetachListener() {
    // @Override
    // public void detach(DetachEvent event) {
    // // during work
    // controller.close();
    //
    // }
    // });

    navigator = new Navigator(this, viewLayout);
    navigator.addView("", new HomeView(controller));
    navigator.addView("home", new HomeView(controller));
    navigator.addView("login", new LoginView(controller));
    navigator.addView("register", new RegisterView(controller));
    navigator.addView("availableSpaces", new AvailableSpacesView(controller));
    navigator.addView("reservationBySelectedRoom", new ReservationBySelectedRoomView(controller));
    navigator.addView("reservationBySelectedTime", new ReservationBySelectedTimeView(controller));

    layout.addComponent(viewLayout);
    layout.setMargin(true);
    setContent(layout);
}

From source file:ch.bfh.due1.srs.MainUI.java

License:Open Source License

@Override
protected void init(VaadinRequest request) {
    ////  w ww .  j ava 2  s  . co  m
    getPage().setTitle("Smart Reservation System");
    this.navigator = new Navigator(this, this);
    this.navigator.addView(RoomListView.VIEWNAME, new RoomListView(navigator, roomController));
    this.navigator.addView(ReservationView.VIEWNAME,
            new ReservationView(navigator, roomController, reservationController));

    //
    this.navigator.navigateTo(ReservationView.VIEWNAME);

}

From source file:ch.bfh.ti.soed.hs16.srs.black.SupervisingController.java

License:Open Source License

@Override
protected void init(VaadinRequest vaadinRequest) {
    // Set the title of the site in the browser
    Page.getCurrent().setTitle("SRS - Smart ReservationEntity System");

    dataModel = JPADataAccess.getInstance();
    loginView = new LoginView();
    reservationView = new ReservationView();
    signUpView = new SignUpView();
    navigator = new Navigator(this, this);

    // Adding the login view to the navigator
    navigator.addView(LoginView.NAME, loginView);

    // Setting the error view of the navigator to the login view
    // This way the navigator will always default to the login view
    navigator.setErrorView(loginView);//w ww .  j a v a  2s  .com

    // Adding the reservation view to the navigator
    navigator.addView(ReservationView.NAME, reservationView);

    // Adding the sign up view to the navigator
    navigator.addView(SignUpView.NAME, signUpView);

    // Instantiating the controllers for the two views
    reservationController = new ReservationController(dataModel, reservationView, navigator);
    new LoginController(dataModel, loginView, navigator);
    new SignUpController(dataModel, signUpView, navigator);

    // We use a view change handler to ensure the user is always redirected
    // to the login view if the user is not logged in
    navigator.addViewChangeListener(new ViewChangeListener() {

        @Override
        public boolean beforeViewChange(ViewChangeEvent event) {
            // Check if a user has logged in
            boolean isLoggedIn = VaadinSession.getCurrent().getAttribute("user") != null;

            boolean isLoginView = event.getNewView() instanceof LoginView;
            boolean isSignUpView = event.getNewView() instanceof SignUpView;
            boolean isReservationView = event.getNewView() instanceof ReservationView;

            if (!isLoggedIn && isReservationView) {
                // Always redirect to login view if a user has not yet logged in
                navigator.navigateTo(LoginView.NAME);
                return false;
            } else if (isLoggedIn && (isLoginView || isSignUpView)) {
                // Access attempt to the login or signup view while already logged in gets cancelled
                return false;
            }
            return true;
        }

        @Override
        public void afterViewChange(ViewChangeEvent event) {
            try {
                reservationController.createList((String) VaadinSession.getCurrent().getAttribute("user"));
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
        }
    });
}

From source file:ch.bfh.ti.soed.hs16.srs.red.ui.MyUI.java

License:Open Source License

@Override
protected void init(VaadinRequest vaadinRequest) {

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

    navigator.addView("", new LoginView(navigator));
    navigator.addView("my Reservation", new MyReservationView(navigator));

}

From source file:ch.bfh.ti.soed.hs16.srs.view.MyUI.java

License:Open Source License

@Override
protected void init(VaadinRequest vaadinRequest) {
    this.navigator = new Navigator(this, this);
    this.navigator.addView("", new LoginView(this.navigator));
    this.navigator.addView("BookerView", new BookerView(this.navigator));
    this.navigator.addView("RoomView", new RoomView(this.navigator));
}

From source file:ch.bfh.ti.soed.hs16.srs.yellow.views.NavigationRoot.java

License:Open Source License

@Override
protected void init(VaadinRequest vaadinRequest) {

    MainView mainView = new MainView();

    LoginView loginView = new LoginView();

    SignUpView signUpView = new SignUpView();

    mainView.setNavigator(this);

    loginView.setNavigator(this);

    signUpView.setNavigator(this);

    navigator = new Navigator(this, this);

    navigator.addView(MAINVIEW, mainView);

    navigator.addView(LOGINVIEW, loginView);

    navigator.addView(SIGNUPVIEW, signUpView);

    navigator.setErrorView(mainView);//from   w  w  w  .  j  av a  2 s . co  m

}