List of usage examples for com.vaadin.navigator Navigator navigateTo
public void navigateTo(String navigationState)
From source file:at.jku.ce.adaptivetesting.vaadin.ui.QuestionManager.java
License:LGPL
@Override public void resultFired(ResultFiredArgs args) throws EngineException { IResultView result;/*from www.j a v a 2s .co m*/ if (resultViewClass == null) { String msg = "You forget to set the result view"; LogHelper.logError(msg); throw new NullPointerException(msg); } Constructor<? extends IResultView> resultConstructor; try { resultConstructor = resultViewClass.getConstructor(ResultFiredArgs.class, String.class); result = resultConstructor.newInstance(args, title.getValue()); } catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NullPointerException e) { LogHelper.logInfo(resultViewClass.getName() + " does not implement the constructors of " + IResultView.class.getName()); throw new EngineException(e); } // Add it to the navigator Navigator navigator = getUI().getNavigator(); assert navigator != null; // Cast cannot fail, as the setResultView takes care, that it is a View // as well navigator.addView(Views.RESULT.toString(), (View) result); navigator.navigateTo(Views.RESULT.toString()); }
From source file:at.reisisoft.jku.ce.adaptivelearning.vaadin.ui.MainUI.java
License:LGPL
public MainUI() { // Make the web-app large setSizeFull();/*from w ww .ja v a2s .c om*/ // Set the layout for the bottom // Create a 3rd party licence button with a click listener final Button licences = new Button("Show 3rd party licences"); licences.addClickListener(new ClickListener() { private static final long serialVersionUID = 32642854872179636L; @Override public void buttonClick(ClickEvent event) { LogHelper.logInfo("Opened LicenceWindow"); LicenceWindow licenceWindow = new LicenceWindow(); licenceWindow.addCloseListener(new CloseListener() { private static final long serialVersionUID = 7874342882437355680L; @Override public void windowClose(CloseEvent e) { event.getButton().setEnabled(true); } }); getUI().addWindow(licenceWindow); // Disable sender event.getButton().setEnabled(false); } }); Label copyright = new HtmlLabel( "<i> Reisisoft 2014 - " + new GregorianCalendar().get(Calendar.YEAR) + "</i>"); Button openLog = new Button("Open Log", (ClickListener) event -> { Navigator navigator = getUI().getNavigator(); assert navigator != null; navigator.navigateTo(Views.Log.toString()); }); // Add the flowLayout at position 1 (second element) -> centered // Add everthing to flowlayout GridLayout southLayout = new GridLayout(3, 1); southLayout.setWidth("100%"); southLayout.addComponent(licences, 0, 0); southLayout.addComponent(openLog, 1, 0); southLayout.addComponent(copyright, 2, 0); // Add southlayout to the main Layout addComponent(southLayout); setComponentAlignment(southLayout, Alignment.BOTTOM_CENTER); }
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/*from w ww . j a v a2 s .co 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.ti.soed.hs16.srs.black.view.reservationView.ReservationController.java
License:Open Source License
public ReservationController(DataModel dataModel, ReservationView reservationView, Navigator navigator) { this.dataModel = dataModel; this.reservationView = reservationView; this.navigator = navigator; reservationView.getLogoutButton().addClickListener(clickEvent -> { // Logout the user / end the session VaadinSession.getCurrent().setAttribute("user", null); // Refresh this view, the navigator should redirect to login view$ navigator.navigateTo(LoginView.NAME); });/*from ww w . ja v a 2s . c om*/ reservationView.getRoomSelect() .addValueChangeListener(e -> roomNumber = Integer.parseInt(e.getProperty().getValue().toString())); for (int i = 1; i < dataModel.getRooms().size() + 1; i++) { reservationView.getRoomSelect().addItem(i); reservationView.getRoomSelect().setItemCaption(i, "Room " + i); } reservationView.getMakeReservationButton().addClickListener(clickEvent -> { Date begin = reservationView.getFromField().getValue(); Date end = reservationView.getToField().getValue(); SimpleDateFormat df = new SimpleDateFormat("dd.MM.yyyy HH:mm"); Notification notification = new Notification(""); notification.setDelayMsec(2000); String username = String.valueOf(VaadinSession.getCurrent().getAttribute("user")); try { Customer customer = dataModel.getCustomer(username); Room room = dataModel.getRoom(roomNumber); dataModel.addReservation(customer, room, begin, end); notification.setCaption("Success"); notification.setDescription("Added reservation for: " + username + ", Room Nr.: " + roomNumber + ", From: " + df.format(begin) + " until " + df.format(end)); notification.show(Page.getCurrent()); try { createList(username); } catch (Exception e) { e.printStackTrace(); } } catch (IllegalArgumentException iae) { notification.setCaption("Error!"); notification.setDescription("Please check the entries you made for your reservation."); notification.show(Page.getCurrent()); } catch (RuntimeException re) { notification.setCaption("Error!"); notification.setDescription("Room couldn't be found.\nCurrently available rooms: " + dataModel.getRooms().stream().map(Object::toString).collect(Collectors.joining(", ")) .replaceAll("[^\\d , ][^\\@]*\\@", "")); notification.show(Page.getCurrent()); } catch (Exception e) { notification.setCaption("Error!"); notification.setDescription("There already exists a reservation for the chosen time range."); notification.show(Page.getCurrent()); } }); reservationView.getLogoutButton().addClickListener(clickEvent -> { reservationView.getFromField().clear(); reservationView.getToField().clear(); reservationView.getRoomSelect().clear(); }); }
From source file:ch.bfh.ti.soed.hs16.srs.view.views.LoginView.java
License:Open Source License
public LoginView(Navigator nav) { /* init objects */ this.layout = new VerticalLayout(); this.btn = new Button("Login"); this.loginFld = new TextField("username"); this.pwFld = new PasswordField("password"); this.header = new Header(); this.footer = new Footer("BFH", "Biel-Bienne", "Schweiz"); /* add to css */ this.layout.setPrimaryStyleName("rootLogin"); this.btn.setStyleName("buttonLogin"); /* add components to layout */ this.layout.addComponent(this.header.getHeaderLayout()); this.layout.addComponents(this.loginFld, this.pwFld, this.btn); this.layout.addComponent(this.footer.getFooterLayout()); setCompositionRoot(layout);/* w w w . j a v a 2s. c om*/ /* event handling */ this.btn.addClickListener((Button.ClickListener) clickEvent -> { // handle userlogin nav.navigateTo("RoomView"); }); }
From source file:com.cerebro.provevaadin.Secure.java
public Secure() { HorizontalLayout top = new HorizontalLayout(); this.addComponent(top); top.addComponent(new Label("Area sicura")); VerticalLayout content = new VerticalLayout(); this.addComponent(content); Navigator nav = new Navigator(UI.getCurrent(), content); nav.setErrorView(new ErrorView()); nav.addView("", new HomeView()); nav.navigateTo(""); Button logout = new Button("Logout"); logout.addClickListener((Button.ClickEvent event) -> { System.out.println("Esco dalla sessione"); SecurityUtils.getSubject().logout(); UI.getCurrent().getSession().close(); UI.getCurrent().getPage().setLocation(""); });// ww w.ja v a 2 s . co m top.addComponent(logout); }
From source file:com.github.djabry.platform.vaadin.ui.MainUI.java
License:Open Source License
@Override protected void init(VaadinRequest request) { VerticalLayout rootLayout = new VerticalLayout(); rootLayout.setSizeFull();// w w w . ja va 2 s.c om setContent(rootLayout); BannerView banner = bannerPresenter.getView(); rootLayout.addComponent(banner); HorizontalLayout mainLayout = new HorizontalLayout(); mainLayout.setSizeFull(); body = new VerticalLayout(); body.setSizeFull(); Navigator navigator = new Navigator(this, body); navigator.addProvider(vP); this.setNavigator(navigator); SideBarView sidebarView = sideBarPresenter.getView(); mainLayout.addComponent(sidebarView); mainLayout.addComponent(body); rootLayout.addComponent(mainLayout); rootLayout.setExpandRatio(mainLayout, 10); sidebarView.setWidth(150, Unit.PIXELS); mainLayout.setExpandRatio(body, 10); //rootLayout.setSplitPosition(150, Unit.PIXELS); navigator.navigateTo(LoginView.VIEW_NAME); eventBus.publish(EventScope.SESSION, this, Action.START); }
From source file:com.github.peholmst.i18n4vaadin.cdi.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { VerticalLayout content = new VerticalLayout(); content.setMargin(true);/*from w ww .j a va2 s . c o m*/ content.setSpacing(true); content.setSizeFull(); setContent(content); languageChanger = new ComboBox(); languageChanger.setContainerDataSource( new BeanItemContainer<java.util.Locale>(java.util.Locale.class, i18n.getSupportedLocales())); languageChanger.setImmediate(true); languageChanger.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (languageChanger.getValue() != null) { i18n.setLocale((java.util.Locale) languageChanger.getValue()); } } }); content.addComponent(languageChanger); Panel viewContent = new Panel(); viewContent.setSizeFull(); content.addComponent(viewContent); content.setExpandRatio(viewContent, 1); Navigator navigator = new Navigator(this, viewContent); navigator.addProvider(viewProvider); navigator.navigateTo("demo"); setNavigator(navigator); updateStrings(); }
From source file:com.github.peholmst.i18n4vaadin.simple.demo.DemoUI.java
License:Apache License
@Override protected void init(VaadinRequest request) { VerticalLayout content = new VerticalLayout(); content.setMargin(true);/*from w w w . j a v a 2 s . c o m*/ content.setSpacing(true); content.setSizeFull(); setContent(content); languageChanger = new ComboBox(); languageChanger.setContainerDataSource( new BeanItemContainer<java.util.Locale>(java.util.Locale.class, i18n.getSupportedLocales())); languageChanger.setImmediate(true); languageChanger.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (languageChanger.getValue() != null) { i18n.setLocale((java.util.Locale) languageChanger.getValue()); } } }); content.addComponent(languageChanger); Panel viewContent = new Panel(); viewContent.setSizeFull(); content.addComponent(viewContent); content.setExpandRatio(viewContent, 1); Navigator navigator = new Navigator(this, viewContent); navigator.addView("demo", DemoView.class); navigator.navigateTo("demo"); setNavigator(navigator); updateStrings(); }
From source file:com.kpg.diary.ui.MenuLayout.java
License:Apache License
/** * Builds the menu./*from ww w. j a va 2 s .c o m*/ * * @param navigator * the navigator * @return the css layout */ private CssLayout buildMenu(Navigator navigator) { // Add items menuItemsMap(); HorizontalLayout top = new HorizontalLayout(); top.setWidth("100%"); top.addStyleName(ValoTheme.MENU_TITLE); top.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT); top.addStyleName(ValoTheme.MENU_TITLE); menu.addComponent(top); // menu.addComponent(createThemeSelect()); menu.addComponent(top); Button showMenu = new Button("Menu", new ClickListener() { @Override public void buttonClick(ClickEvent event) { if (menu.getStyleName().contains("valo-menu-visible")) { menu.removeStyleName("valo-menu-visible"); } else { menu.addStyleName("valo-menu-visible"); } } }); showMenu.addStyleName(ValoTheme.BUTTON_PRIMARY); showMenu.addStyleName(ValoTheme.BUTTON_SMALL); showMenu.addStyleName("valo-menu-toggle"); showMenu.setIcon(FontAwesome.LIST); menu.addComponent(showMenu); Label title = new Label("<h2>Diary</h2>", ContentMode.HTML); title.setSizeUndefined(); top.addComponent(title); top.setExpandRatio(title, 1); menuItemsLayout.setPrimaryStyleName("valo-menuitems"); menu.addComponent(menuItemsLayout); for (final Entry<String, String> item : menuItems.entrySet()) { Button b = new Button(item.getValue(), new ClickListener() { @Override public void buttonClick(ClickEvent event) { navigator.navigateTo(item.getKey()); } }); b.setHtmlContentAllowed(true); b.setPrimaryStyleName(ValoTheme.MENU_ITEM); if (IConstants.NavigationMenu.ADDRESS.getKey().equals(item.getKey())) { b.setIcon(FontAwesome.BOOK); } else if (IConstants.NavigationMenu.PERSON.getKey().equals(item.getKey())) { b.setIcon(FontAwesome.USER); } else { b.setIcon(FontAwesome.APPLE); } menuItemsLayout.addComponent(b); } return menu; }