List of usage examples for com.vaadin.server VaadinSession getCurrent
public static VaadinSession getCurrent()
From source file:org.ripla.web.controllers.AbstractController.java
License:Open Source License
/** * Returns the generic parameters passed by a task/controller. * /*from ww w . j a v a 2 s . com*/ * @param inClear * boolean if <code>true</code>, the parameter settings are * cleared, if <code>false</code>, they are retained * @return {@link ParameterObject} generich parameters */ protected final ParameterObject getParameters(final boolean inClear) { ParameterObject out = null; try { VaadinSession.getCurrent().getLockInstance().lock(); out = VaadinSession.getCurrent().getAttribute(ParameterObject.class); if (inClear) { VaadinSession.getCurrent().setAttribute(ParameterObject.class, null); } } finally { VaadinSession.getCurrent().getLockInstance().unlock(); } return out; }
From source file:org.ripla.web.controllers.AbstractController.java
License:Open Source License
private IRiplaEventDispatcher getDispatcher() { try {// w ww . j av a 2 s . c om VaadinSession.getCurrent().getLockInstance().lock(); return VaadinSession.getCurrent().getAttribute(IRiplaEventDispatcher.class); } finally { VaadinSession.getCurrent().getLockInstance().unlock(); } }
From source file:org.ripla.web.controllers.AbstractController.java
License:Open Source License
/** * Saves the specified value with the specified key to the application's * preferences.// w w w. j av a 2 s.c o m * * @param inKey * String * @param inValue * String */ protected final void savePreferences(final String inKey, final String inValue) { try { VaadinSession.getCurrent().getLockInstance().lock(); VaadinSession.getCurrent().getAttribute(PreferencesHelper.class).set(inKey, inValue); } finally { VaadinSession.getCurrent().getLockInstance().unlock(); } }
From source file:org.ripla.web.controllers.AbstractController.java
License:Open Source License
/** * Returns the value with the specified key from the application's * preferences.//from www. jav a2 s.c o m * * @param inKey * String * @param inDftValue * String default value * @return String the value retrieved from the application's preferences */ protected final String getPreference(final String inKey, final String inDftValue) { try { VaadinSession.getCurrent().getLockInstance().lock(); return VaadinSession.getCurrent().getAttribute(PreferencesHelper.class).get(inKey, inDftValue); } finally { VaadinSession.getCurrent().getLockInstance().unlock(); } }
From source file:org.ripla.web.controllers.RiplaBody.java
License:Open Source License
private void createMenu(final MenuBar inMenuBar, final Resource inSubMenuIcon) { final MenuBar.Command lCommand = new MenuBar.Command() { @Override//from w w w . jav a 2 s.c o m public void menuSelected(final MenuItem inSelected) { final IMenuCommand lAction = getMenuMap().get(inSelected.getId()); afterMenuClick(); if (lAction != null) { try { setContentView(getContentComponent(lAction.getControllerName())); } catch (final NoControllerFoundException exc) { handleNoTaskFound(exc); } } } }; final Authorization lAuthorization = UseCaseRegistry.INSTANCE.getUserAdmin().getAuthorization(getUser()); final Map<String, MenuItem> lMenuMap = new HashMap<String, MenuBar.MenuItem>(); for (final MenuFactory lFactory : UseCaseRegistry.INSTANCE.getMenus()) { final MenuItem lItem = lFactory.createMenu(inMenuBar, inSubMenuIcon, getMenuMap(), lCommand, lAuthorization); lMenuMap.put(lFactory.getProviderSymbolicName(), lItem); } // we set the menu map to the session to access it later to mark the // active menu try { VaadinSession.getCurrent().getLockInstance().lock(); VaadinSession.getCurrent().setAttribute(Constants.SA_MENU_MAP, lMenuMap); } finally { VaadinSession.getCurrent().getLockInstance().unlock(); } LOG.debug("Menu created for Ripla."); //$NON-NLS-1$ }
From source file:org.ripla.web.controllers.RiplaBody.java
License:Open Source License
private User getUser() { try {// w w w . j a va2 s. c o m VaadinSession.getCurrent().getLockInstance().lock(); return VaadinSession.getCurrent().getAttribute(User.class); } finally { VaadinSession.getCurrent().getLockInstance().unlock(); } }
From source file:org.ripla.web.internal.menu.ContextMenuManager.java
License:Open Source License
private static IRiplaEventDispatcher getDispatcher() { try {/*from www.java 2 s. c om*/ VaadinSession.getCurrent().getLockInstance().lock(); return VaadinSession.getCurrent().getAttribute(IRiplaEventDispatcher.class); } finally { VaadinSession.getCurrent().getLockInstance().unlock(); } }
From source file:org.ripla.web.internal.services.ControllerManager.java
License:Open Source License
@SuppressWarnings("unchecked") private void setActiveMenuItem(final String inBundleName) { final VaadinSession lCurrentSession = VaadinSession.getCurrent(); MenuItem lOldItem = null;//from w w w. ja v a2 s. com try { lCurrentSession.getLockInstance().lock(); lOldItem = (MenuItem) lCurrentSession.getAttribute(Constants.SA_ACTIVE_MENU); } finally { lCurrentSession.getLockInstance().unlock(); } if (lOldItem != null) { lOldItem.setStyleName(""); } Map<String, MenuItem> lMenuMap = null; try { lCurrentSession.getLockInstance().lock(); lMenuMap = (Map<String, MenuItem>) lCurrentSession.getAttribute(Constants.SA_MENU_MAP); } finally { lCurrentSession.getLockInstance().unlock(); } final MenuItem lNewItem = lMenuMap == null ? null : lMenuMap.get(inBundleName); if (lNewItem != null) { lNewItem.setStyleName(Constants.CSS_ACTIVE_MENU); } try { lCurrentSession.getLockInstance().lock(); lCurrentSession.setAttribute(Constants.SA_ACTIVE_MENU, lNewItem); } finally { lCurrentSession.getLockInstance().unlock(); } }
From source file:org.ripla.web.RiplaApplication.java
License:Open Source License
@Override public final void init(final VaadinRequest inRequest) { initialized = true;/* w ww . j av a2s. co m*/ toolbarItemFactory = new ToolbarItemFactory(preferences, configManager, null); // synchronize language settings setSessionLocale(preferences.getLocale(getLocale())); setSessionPreferences(preferences); eventDispatcher = new RiplaEventDispatcher(); try { VaadinSession.getCurrent().getLockInstance().lock(); VaadinSession.getCurrent().setAttribute(IRiplaEventDispatcher.class, eventDispatcher); } finally { VaadinSession.getCurrent().getLockInstance().unlock(); } UseCaseRegistry.INSTANCE.registerContextMenus(); SkinRegistry.INSTANCE.setPreferences(preferences); if (!initializeLayout(getAppConfiguration())) { return; } }
From source file:org.ripla.web.RiplaApplication.java
License:Open Source License
private void setSessionPreferences(final PreferencesHelper inPreferences) { try {/*from www. ja va2 s .c om*/ VaadinSession.getCurrent().getLockInstance().lock(); VaadinSession.getCurrent().setAttribute(PreferencesHelper.class, inPreferences); } finally { VaadinSession.getCurrent().getLockInstance().unlock(); } }