List of usage examples for com.vaadin.server VaadinSession getAttribute
public <T> T getAttribute(Class<T> type)
From source file:com.skysql.manager.ui.components.SystemLayout.java
License:Open Source License
/** * Delete component./*w w w . j av a2 s .c om*/ * * @param button the button */ public void deleteComponent(ComponentButton button) { removeComponent(button); VaadinSession session = getSession(); SystemInfo systemInfo = session.getAttribute(SystemInfo.class); String parentID = systemInfo.getCurrentSystem().getParentID(); systemInfo.setCurrentSystem(parentID); session.setAttribute(SystemInfo.class, systemInfo); ManagerUI.log("new systemID: " + parentID); OverviewPanel overviewPanel = session.getAttribute(OverviewPanel.class); if (button.isSelected()) { overviewPanel.clickLayout(null, false); } overviewPanel.refresh(); }
From source file:com.skysql.manager.ui.OverviewPanel.java
License:Open Source License
/** * Asynch refresh./*from ww w . j a v a 2 s .c o m*/ * * @param updaterThread the updater thread */ private void asynchRefresh(UpdaterThread updaterThread) { VaadinSession session = getSession(); ManagerUI managerUI = session.getAttribute(ManagerUI.class); SystemInfo systemInfo = session.getAttribute(SystemInfo.class); SystemRecord newSystemRecord = systemInfo.updateSystem(systemInfo.getCurrentID()); if (isEditable) { if (newSystemRecord != null && !SystemInfo.SYSTEM_ROOT.equals(newSystemRecord.getID())) { addNodeButton.setVisible(true); addSystemButton.setVisible(false); } else { addSystemButton.setVisible(true); addNodeButton.setVisible(false); } } systemLayout.refresh(updaterThread, newSystemRecord); if (updaterThread.flagged) { return; } nodesLayout.refresh(updaterThread, newSystemRecord); nodesLabel.setValue( newSystemRecord == null || SystemInfo.SYSTEM_ROOT.equals(newSystemRecord.getID()) ? "Systems" : "Components"); if (updaterThread.flagged) { return; } ManagerUI.log("OverviewPanel.refresh() selectedButton: " + selectedButton); if (selectedButton == null) { selectCurrentButton(newSystemRecord); } systemRecord = newSystemRecord; managerUI.access(new Runnable() { @Override public void run() { // Here the UI is locked and can be updated ManagerUI.log("OverviewPanel - TabbedPanel access run()"); TabbedPanel tabbedPanel = getSession().getAttribute(TabbedPanel.class); tabbedPanel.refresh(); } }); }
From source file:de.metas.procurement.webui.util.SwipeHelper.java
License:Open Source License
public static final SwipeHelper getCurrent() { final VaadinSession session = UI.getCurrent().getSession(); SwipeHelper swipe = session.getAttribute(SwipeHelper.class); if (swipe == null) { swipe = new SwipeHelper(); session.setAttribute(SwipeHelper.class, swipe); }//from w ww . ja va 2 s. co m return swipe; }
From source file:de.metas.ui.web.vaadin.session.UserSession.java
License:Open Source License
private static final UserSession getCurrent(final VaadinSession vaadinSession) { UserSession userSession = vaadinSession.getAttribute(UserSession.class); if (userSession == null) { userSession = new UserSession(); vaadinSession.setAttribute(UserSession.class, userSession); }/* www .j ava2 s . c o m*/ return userSession; }
From source file:edu.nps.moves.mmowgli.AppMaster.java
License:Open Source License
public synchronized StringBuilder getLocalNodeReportRaw() { StringBuilder sb = new StringBuilder(); synchronized (sessionsInThisMmowgliNode) { // Synchronized to protect hashset Iterator<VaadinSession> itr = sessionsInThisMmowgliNode.iterator(); while (itr.hasNext()) { VaadinSession sess = itr.next(); MmowgliSessionGlobals sGlobs = sess.getAttribute(MmowgliSessionGlobals.class); // empty first is servername sb.append(SESSION_REPORT_FIELD_DELIMITER); // " User "); String uname = sGlobs.getUserName(); sb.append(uname.length() <= 0 ? "not logged in" : uname); sb.append(SESSION_REPORT_FIELD_DELIMITER); Serializable id = sGlobs.getUserID(); sb.append(id == null ? " " : id); sb.append(SESSION_REPORT_FIELD_DELIMITER); // " at "); sb.append(sGlobs.getUserLoginTimeData()); sb.append(SESSION_REPORT_FIELD_DELIMITER); // " from "); sb.append(sGlobs.getBrowserAddress()); sb.append(SESSION_REPORT_FIELD_DELIMITER); // " using "); sb.append(sGlobs.getBrowserMiniType()); sb.append(SESSION_REPORT_FIELD_DELIMITER); sb.append(sGlobs.getBrowserMajorVersionString()); sb.append(SESSION_REPORT_FIELD_DELIMITER); sb.append(sGlobs.getBrowserOS()); sb.append(SESSION_REPORT_ITEM_DELIMITER); }/*from w w w . j a v a 2 s .c o m*/ } return sb; }
From source file:edu.nps.moves.mmowgli.Mmowgli2UIProvider.java
License:Open Source License
@Override public Class<? extends UI> getUIClass(UIClassSelectionEvent event) { VaadinService serv = event.getService(); VaadinSession vsess; CACData data = (CACData) event.getRequest().getAttribute(CACData.class.getName()); // put in place by Mmowgli2VaadinServlet.sessionInit() if (data != null) // why null sometimes? if (!CACManager.canProceed(data)) { return Mmowgli2CACError.class; }/*w w w.ja v a2s . c om*/ try { vsess = serv.findVaadinSession(event.getRequest()); } catch (SessionExpiredException ex) { return Mmowgli2UILogin.class; } catch (ServiceException sex) { return Mmowgli2UIError.class; } Collection<UI> uis = vsess.getUIs(); int count = uis.size(); if (count == 0) return Mmowgli2UILogin.class; MmowgliSessionGlobals globs = vsess.getAttribute(MmowgliSessionGlobals.class); // if globs != null, just means servlet has been hit, shouldn't be here // if globs ! initted, means Mmowgli2UILogin has not finished init ... send error // if glob ! loggedIn, means Mmowgli2UILogin in the sequence of login screens ... send error // else, send Subsequent UI, which is UI for 2nd and further browser windows/tabs in same user session if (globs != null && globs.initted & globs.isLoggedIn()) { for (UI ui : uis) { if (ui instanceof Mmowgli2UILogin) { // so we've got an initted UI, and the user is logged in return Mmowgli2UISubsequent.class; } } } return Mmowgli2UIError.class; // puts up "incomplete login" verbage }
From source file:io.github.jikuja.vaadin_yamapa.ui.views.PoiMap.java
License:Creative Commons License
private void setupMap() { // sane default zoom VaadinSession session = VaadinSession.getCurrent(); if (session.getAttribute("lat") != null) { map.setCenter(new Point((Double) session.getAttribute("lat"), (Double) session.getAttribute("lon")), 14.0);//from ww w. j av a2 s .c o m } else { map.setCenter(new Point(60.440963, 22.25122), 14.0); } // single click / tapping is used to add POIs // using context meny would be even nicer thing to have. Maybe later map.setDoubleClickZoomEnabled(false); setupClickHandlers(); }
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
/** * actualiza los settings (la parte que muestra la sesin del usuario) * * *///from w w w.java 2s . c o m private void refreshSettings() { VaadinSession s = VaadinSession.getCurrent(); settings.removeItems(); if (s.getAttribute("usuario") == null) { System.out.println("***** NO AUTENTICADO."); if (getApp().isAuthenticationNeeded()) { MenuItem settingsItem = settings.addItem("Login", new MenuBar.Command() { @Override public void menuSelected(MenuItem menuItem) { openLoginDialog(true); } }); } } else { System.out.println("***** AUTENTICADO. USUARIO=" + s.getAttribute("usuario")); MenuItem settingsItem = settings.addItem("", foto = (getApp().getUserData().getPhoto() != null) ? new ExternalResource(getApp().getUserData().getPhoto()) : sinfoto, null); settingsItem.addItem("Edit Profile", new MenuBar.Command() { @Override public void menuSelected(MenuItem menuItem) { editProfile(); } }); settingsItem.addItem("Change password", new MenuBar.Command() { @Override public void menuSelected(MenuItem menuItem) { changePassword(); } }); settingsItem.addItem("Change photo", new MenuBar.Command() { @Override public void menuSelected(MenuItem menuItem) { uploadFoto(); } }); settingsItem.addSeparator(); settingsItem.addItem("Sign Out", new MenuBar.Command() { @Override public void menuSelected(MenuItem menuItem) { VaadinSession.getCurrent().setAttribute("usuario", null); getApp().setUserData(null); getViewDisplay().removeAllComponents(); refreshSettings(); if (MateuUI.getApp().isFavouritesAvailable()) linkFavoritos.setVisible(false); if (MateuUI.getApp().isLastEditedAvailable()) linkUltimosRegistros.setVisible(false); if (MateuUI.getApp().isFavouritesAvailable()) linkNuevoFavorito.setVisible(false); refreshMenu(null, null); addView(MyUI.this, getApp().getPublicHome()); if (!"".equals(navigator.getState())) navigator.navigateTo(""); } }); } }
From source file:io.mateu.ui.vaadin.framework.MyUI.java
License:Apache License
/** * construye el men//from www .j ava 2s.c om */ public void refreshMenu(AbstractArea area, MenuEntry menu) { if (area != null && area.equals(getAreaActual())) { // no cambia el area. Solo puede cambiar el menu if ((menu == null && getMenuActual() == null) || (menu != null && menu.equals(getMenuActual()))) { // no cambia nada. no hacemos nada } else { setMenuActual(menu); } } else { // cambia el area. debemos reconstruir el menu setAreaActual(area); VaadinSession s = VaadinSession.getCurrent(); boolean autentico = s.getAttribute("usuario") != null; List<AbstractArea> areas = new ArrayList<>(); for (AbstractArea a : getApp().getAreas()) { if (autentico) { if (!a.isPublicAccess()) { if (area == null) area = a; areas.add(a); } } else { if (!getApp().isAuthenticationNeeded() || a.isPublicAccess()) { if (area == null) area = a; areas.add(a); } } } menuItemsLayout.removeAllComponents(); /** * area no puede ser null */ if (area != null) { divIndicadorAreaActual = new VerticalLayout(); divIndicadorAreaActual.setSpacing(false); divIndicadorAreaActual.addStyleName("divIndicadorAreaActual"); if (areas.size() > 1) { Button b; AbstractArea finalArea = area; divIndicadorAreaActual .addComponent(b = new Button("You are at " + ((area != null) ? area.getName() : "--"), new ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { navigator.navigateTo(getApp().getAreaId(finalArea) + "/changearea"); } })); b.addStyleName(ValoTheme.BUTTON_LINK); b.addStyleName("linkotrasareas"); menuItemsLayout.addComponent(divIndicadorAreaActual); } buildMenuOptions(area); } setMenuActual(menu); } }
From source file:org.lucidj.navigatormanager.DefaultNavigatorManager.java
License:Apache License
private ViewProvider get_or_create_proxy_view_provider(Navigator navigator) { UI current_ui = UI.getCurrent();//from ww w. ja v a 2s . c o m VaadinSession current_session = (current_ui != null) ? current_ui.getSession() : null; ViewProvider proxy_view_provider = null; if (current_session != null) { // Get or create the ProxyViewProvider, bound into VaadinSession Object view_provider_obj = current_session.getAttribute(ATTR_VIEW_PROVIDER); if (view_provider_obj instanceof ViewProvider) { // TODO: WHAT IF NAVIGATOR CHANGES INSIDE THE SAME UI? CREATE SOME WAY TO UPDATE IT. proxy_view_provider = (ViewProvider) view_provider_obj; } else { proxy_view_provider = serviceContext.wrapObject(ProxyViewProvider.class, new ProxyViewProvider(this, navigator)); current_session.setAttribute(ATTR_VIEW_PROVIDER, proxy_view_provider); } } return (proxy_view_provider); }