List of usage examples for com.vaadin.server VaadinSession getLockInstance
public Lock getLockInstance()
From source file:com.garyclayburg.vconsole.TargetWindows.java
License:Open Source License
void populateTarget(User selectedUser, String entitledTarget) { Window window = targetWindows.get(entitledTarget); if (window != null) { UI ui = window.getUI();//w w w. j av a 2 s .c o m if (ui != null) { VaadinSession session = ui.getSession(); if (session != null) { session.getLockInstance().lock(); try { VerticalLayout windowContent = populateTargetWindowData(selectedUser, entitledTarget); window.setContent(windowContent); } finally { session.getLockInstance().unlock(); } } } } }
From source file:com.garyclayburg.vconsole.VConsole.java
License:Open Source License
private void updateRightClickItems() { UI ui = userTable.getUI();// w w w . j a va 2 s . c o m if (ui != null) { VaadinSession session = ui.getSession(); if (session != null) { session.getLockInstance().lock(); try { userTable.refreshRowCache(); // force right-click menu item update for possible change to valid menu items based on policy } finally { session.getLockInstance().unlock(); } } } }
From source file:com.garyclayburg.vconsole.VConsole.java
License:Open Source License
private void populateExceptionMessage(String message, boolean visible) { VerticalLayout windowContent = new VerticalLayout(); windowContent.setMargin(true);/*from ww w. ja v a2s . c o m*/ Label messageLabel = new Label(message, ContentMode.PREFORMATTED); messageLabel.setStyleName(Runo.LABEL_SMALL); // messageLabel.setWidth("120em"); windowContent.addComponent(messageLabel); Button closeButton = new Button("Close"); closeButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { exceptionWindow.setVisible(false); } }); windowContent.addComponent(closeButton); UI ui = exceptionWindow.getUI(); if (ui != null) { VaadinSession session = ui.getSession(); if (session != null) { session.getLockInstance().lock(); try { exceptionWindow.setContent(windowContent); exceptionWindow.setVisible(visible); } finally { session.getLockInstance().unlock(); } } else { exceptionWindow.setContent(windowContent); exceptionWindow.setVisible(visible); } } else { exceptionWindow.setContent(windowContent); exceptionWindow.setVisible(visible); } }
From source file:com.garyclayburg.vconsole.VConsole.java
License:Open Source License
@Override public void userChanged(User user) { log.info("user is changing: " + user.getFirstname()); BeanContainer beanContainer = (BeanContainer) userTable.getContainerDataSource(); BeanItem item = beanContainer.getItem(user.getId()); if (item != null) { log.info("updating user"); UI ui = userTable.getUI();//from w ww.java 2 s.c o m if (ui != null) { VaadinSession session = ui.getSession(); if (session != null) { session.getLockInstance().lock(); try { item.getItemProperty("firstname").setValue(user.getFirstname()); item.getItemProperty("lastname").setValue(user.getLastname()); } finally { session.getLockInstance().unlock(); } } } } if (userTable.isSelected(user.getId())) { refreshUserValues(user); populatePolicyExceptionList(); } }
From source file:com.garyclayburg.vconsole.VConsole.java
License:Open Source License
private void populateItems(User firstUser, BeanContainer<String, GeneratedAttributesBean> generatedAttributesBeanContainer) { // if (firstUser !=null) { List<GeneratedAttributesBean> generatedAttributes = attributeService.getGeneratedAttributesBean(firstUser); UI ui = attributeTable.getUI();// ww w . j av a 2 s.c o m if (ui != null) { VaadinSession session = ui.getSession(); if (session != null) { session.getLockInstance().lock(); try { generatedAttributesBeanContainer.removeAllItems(); for (GeneratedAttributesBean generatedAttribute : generatedAttributes) { generatedAttributesBeanContainer.addBean(generatedAttribute); } } finally { session.getLockInstance().unlock(); } } } // } }
From source file:org.lucidj.vaadinui.SmartPush.java
License:Apache License
private synchronized void timer_poll() { if (!ui.isAttached()) { // We never update a detached UI return;//from w w w .j ava 2 s . c o m } if (ui.isClosing()) { // UI.close() issues a final push(), so we can stop right now stop(); return; } if (!ui.getConnectorTracker().hasDirtyConnectors()) { // Nothing to send, reset and keep waiting prepare_push = 0; } else { long now = System.currentTimeMillis(); // We have data to sync if (prepare_push == 0) { // Start the timer to prepare push prepare_push = now; } else if (now - prepare_push > (PUSH_INTERVAL - CHECK_INTERVAL - 1)) { VaadinSession session = ui.getSession(); Lock lock = session.getLockInstance(); try { lock.lock(); ui.push(); } finally { prepare_push = 0; lock.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 ww w. ja v a2 s. c o m*/ 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(); } }