List of usage examples for com.vaadin.server VaadinSession getCurrent
public static VaadinSession getCurrent()
From source file:org.jumpmind.vaadin.ui.sqlexplorer.TableInfoPanel.java
License:Open Source License
protected void refreshData(final org.jumpmind.db.model.Table table, final String user, final IDb db, final Settings settings, boolean isInit) { if (!isInit) { tabSheet.removeTab(tabSheet.getTab(1)); }//w w w .j a va2s. c om IDatabasePlatform platform = db.getPlatform(); DmlStatement dml = platform.createDmlStatement(DmlType.SELECT_ALL, table, null); final HorizontalLayout executingLayout = new HorizontalLayout(); executingLayout.setSizeFull(); final ProgressBar p = new ProgressBar(); p.setIndeterminate(true); final int oldPollInterval = UI.getCurrent().getPollInterval(); UI.getCurrent().setPollInterval(100); executingLayout.addComponent(p); executingLayout.setData(isInit); tabSheet.addTab(executingLayout, "Data", isInit ? null : FontAwesome.SPINNER, 1); if (!isInit) { tabSheet.setSelectedTab(executingLayout); } SqlRunner runner = new SqlRunner(dml.getSql(), false, user, db, settings, explorer, new ISqlRunnerListener() { private static final long serialVersionUID = 1L; @Override public void writeSql(String sql) { explorer.openQueryWindow(db).appendSql(sql); } @Override public void reExecute(String sql) { refreshData(table, user, db, settings, false); } @Override public void finished(final FontAwesome icon, final List<Component> results, long executionTimeInMs, boolean transactionStarted, boolean transactionEnded) { VaadinSession.getCurrent().access(new Runnable() { @Override public void run() { tabSheet.removeComponent(executingLayout); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSizeFull(); if (results.size() > 0) { layout.addComponent(results.get(0)); } tabSheet.addTab(layout, "Data", null, 1); UI.getCurrent().setPollInterval(oldPollInterval); tabSheet.setSelectedTab(layout); } }); } }); runner.setShowSqlOnResults(false); runner.setLogAtDebug(true); if (!isInit) { runner.start(); } }
From source file:org.lucidj.navigatormanager.ProxyViewProvider.java
License:Apache License
private void clear_view(Object departing_view) { String current_state = navigator.getState(); View current_view = navigator.getCurrentView(); Iterator<Map.Entry<String, View>> it_view = view_name_to_view.entrySet().iterator(); while (it_view.hasNext()) { Map.Entry<String, View> entry = it_view.next(); if (entry.getValue() == departing_view) { it_view.remove();// www . ja v a 2 s . c o m if (entry.getKey().equals(current_state) || entry.getValue().equals(current_view)) { // We are running from system land, no sessions at all, so // we need to set Vaadin session from navigator UI session VaadinSession current = VaadinSession.getCurrent(); VaadinSession.setCurrent(navigator.getUI().getSession()); // We always have a dedicated home view navigator.navigateTo(NavigatorManager.HOME); // Back to system land defaults VaadinSession.setCurrent(current); } } } }
From source file:org.lucidj.shiro.Shiro.java
License:Apache License
@Override // SecurityEngine public SecuritySubject getStoredSubject(boolean create_as_system) { SecuritySubject current_subject = VaadinSession.getCurrent().getAttribute(SecuritySubject.class); if (current_subject == null || create_as_system) { Subject shiro_subject;/* w ww .j a v a 2s.c om*/ // The subject is always rebuilt when configured as system if (create_as_system) { shiro_subject = new Subject.Builder(ini_security_manager).authenticated(true) .principals(new SimplePrincipalCollection("system", "")).buildSubject(); log.info("Create system subject: {}", shiro_subject); log.info("{}: authenticated={}", shiro_subject, shiro_subject.isAuthenticated()); } else { shiro_subject = SecurityUtils.getSecurityManager().createSubject(null); } // TODO: CONFIGURABLE shiro_subject.getSession().setTimeout(24L * 60 * 60 * 1000); // 24h current_subject = new ShiroSubject(shiro_subject); // TODO: MAKE SECURITY IDENPENDENT FROM VAADIN/SESSIONS FROM WEB try { // Store current user into VaadinSession VaadinSession.getCurrent().getLockInstance().lock(); VaadinSession.getCurrent().setAttribute(SecuritySubject.class, current_subject); } finally { VaadinSession.getCurrent().getLockInstance().unlock(); } } // Reset doomsday counter.... current_subject.touchSession(); return (current_subject); }
From source file:org.opencms.ui.login.CmsLoginUI.java
License:Open Source License
/** * @see com.vaadin.ui.UI#init(com.vaadin.server.VaadinRequest) */// ww w.ja v a 2 s .co m @Override protected void init(VaadinRequest request) { addStyleName("login-dialog"); LoginParameters params = (LoginParameters) (request.getWrappedSession() .getAttribute(INIT_DATA_SESSION_ATTR)); if (params == null) { params = CmsLoginHelper.getLoginParameters(getCmsObject(), (HttpServletRequest) request, true); request.getWrappedSession().setAttribute(CmsLoginUI.INIT_DATA_SESSION_ATTR, params); } VaadinSession.getCurrent().setErrorHandler(new CmsVaadinErrorHandler()); m_controller = new CmsLoginController(m_adminCms, params); m_controller.setUi(this); setLocale(params.getLocale()); m_loginForm = new CmsLoginForm(m_controller, params.getLocale()); m_controller.onInit(); getPage().setTitle(CmsAppWorkplaceUi.WINDOW_TITLE_PREFIX + CmsVaadinUtils.getMessageText(org.opencms.workplace.Messages.GUI_LOGIN_HEADLINE_0)); }
From source file:org.opennms.features.vaadin.dashboard.ui.wallboard.WallboardBody.java
License:Open Source License
public WallboardBody() { addStyleName("wallboard-board"); setSizeFull();//from ww w . jav a 2s . c om contentLayout = new CssLayout(); contentLayout.setSizeFull(); contentLayout.addComponent(new Label("Nothing to display")); if (debugEnabled) { addComponent(debugLabel); } addComponent(contentLayout); setExpandRatio(contentLayout, 1.0f); progressIndicator = new ProgressIndicator(); progressIndicator.setWidth("100%"); progressIndicator.setPollingInterval(250); progressIndicator.setVisible(false); addComponent(progressIndicator); timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { VaadinSession.getCurrent().lock(); try { advanceTimer(); } finally { VaadinSession.getCurrent().unlock(); } } }, 250, 250); addDetachListener(new DetachListener() { @Override public void detach(DetachEvent detachEvent) { timer.cancel(); } }); }
From source file:org.opennms.features.vaadin.dashboard.ui.wallboard.WallboardBody.java
License:Open Source License
public void setDashletSpecs(List<DashletSpec> dashletSpecs) { this.dashletSpecs = dashletSpecs; this.dashlets = new HashMap<Integer, Dashlet>(); this.priorityMap = new HashMap<Integer, Integer>(); this.durationMap = new HashMap<Integer, Integer>(); this.oldDurationMap = new HashMap<Integer, Integer>(); this.oldPriorityMap = new HashMap<Integer, Integer>(); waitFor = 0;//from ww w. j a va 2 s . c o m iteration = 1; index = -1; VaadinSession.getCurrent().lock(); try { progressIndicator.setVisible(true); } finally { VaadinSession.getCurrent().unlock(); } }
From source file:org.rapidpm.jumpstart.vaadin.ui.screens.LoginScreen.java
License:Apache License
@PostConstruct public void postconstruct() { usernameField.setCaption(propertyService.resolve("login.username")); passwordField.setCaption(propertyService.resolve("login.password")); loginButton.setCaption(propertyService.resolve("login.name")); loginButton.setClickShortcut(KeyCode.ENTER); loginLayout.setCaption(propertyService.resolve("login.info")); loginButton.addClickListener(clickEvent -> { final String username = usernameField.getValue(); final String password = passwordField.getValue(); VaadinSession.getCurrent().setAttribute(LANGUAGE_SESSION_ATTRIBUTE, languageBox.getValue()); final boolean allowed = loginService.isAllowed(username, password); if (allowed) { getSession().setAttribute(User.class, loginService.loadUser(username, password)); UI.getCurrent().setContent(null); //setting working Area UI.getCurrent().setContent(mainWindow); } else {/*from ww w . j a v a 2s . c o m*/ Notification.show(propertyService.resolve("login.failed"), propertyService.resolve("login.failed.description"), Type.WARNING_MESSAGE); } }); }
From source file:org.ripla.web.controllers.AbstractController.java
License:Open Source License
/** * Allows access to the current user object. * //from w ww .j ava 2 s . c om * @return {@link User} */ protected final User getUser() { try { VaadinSession.getCurrent().getLockInstance().lock(); return VaadinSession.getCurrent().getAttribute(User.class); } finally { VaadinSession.getCurrent().getLockInstance().unlock(); } }
From source file:org.ripla.web.controllers.AbstractController.java
License:Open Source License
/** * @return {@link Locale} the actual session's locale. *//* w w w .j ava 2 s . c om*/ protected final Locale getAppLocale() { try { VaadinSession.getCurrent().getLockInstance().lock(); return VaadinSession.getCurrent().getAttribute(Locale.class); } finally { VaadinSession.getCurrent().getLockInstance().unlock(); } }
From source file:org.ripla.web.controllers.AbstractController.java
License:Open Source License
/** * Set generic parameters.<br/>//w w w. j a v a2s . co m * Use e.g.: * * <pre> * ParameterObject lParameters = new ParameterObject(); * lParameters.set(Constants.KEY_PARAMETER_MEMBER, lMemberID); * setParameters(lParameters); * </pre> * * @param inParameters * {@link ParameterObject} the parameters to set or * <code>null</code> to clear the parameter settings */ protected final void setParameters(final ParameterObject inParameters) { try { VaadinSession.getCurrent().getLockInstance().lock(); VaadinSession.getCurrent().setAttribute(ParameterObject.class, inParameters); } finally { VaadinSession.getCurrent().getLockInstance().unlock(); } }