Example usage for com.vaadin.server VaadinSession getCurrent

List of usage examples for com.vaadin.server VaadinSession getCurrent

Introduction

In this page you can find the example usage for com.vaadin.server VaadinSession getCurrent.

Prototype

public static VaadinSession getCurrent() 

Source Link

Document

Gets the currently used session.

Usage

From source file:org.hip.vif.web.util.BeanWrapperHelper.java

License:Open Source License

private static Locale getAppLocale() {
    if (VaadinSession.getCurrent() == null) {
        return Locale.ENGLISH;
    }/* w w w . java2  s  . co  m*/
    try {
        VaadinSession.getCurrent().getLockInstance().lock();
        return VaadinSession.getCurrent().getLocale();
    } finally {
        VaadinSession.getCurrent().getLockInstance().unlock();
    }
}

From source file:org.hip.vif.web.util.VIFAppHelper.java

License:Open Source License

/** Set generic parameters.<br/>
 * Use e.g.:/*from   ww w.j av a 2s  .  c o m*/
 *
 * <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 */
public static void setParameters(final ParameterObject inParameters) {
    try {
        VaadinSession.getCurrent().getLockInstance().lock();
        VaadinSession.getCurrent().setAttribute(ParameterObject.class, inParameters);
    } finally {
        VaadinSession.getCurrent().getLockInstance().unlock();
    }
}

From source file:org.hip.vif.web.util.VIFAppHelper.java

License:Open Source License

/** Returns the generic parameters passed by a task/controller.
 *
 * @param inClear boolean if <code>true</code>, the parameter settings are cleared, if <code>false</code>, they are
 *            retained/*ww  w .ja  va2  s. c  om*/
 * @return {@link ParameterObject} generich parameters */
public static 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.hip.vif.web.util.VIFAppHelper.java

License:Open Source License

/** Set's the specified value to the vaadin session.
 *
 * @param inKey String/*from   w  w  w.  j a v  a 2s . c om*/
 * @param inValue Long */
public static void setValueToSession(final String inKey, final Long inValue) {
    try {
        VaadinSession.getCurrent().getLockInstance().lock();
        VaadinSession.getCurrent().setAttribute(inKey, inValue);
    } finally {
        VaadinSession.getCurrent().getLockInstance().unlock();
    }
}

From source file:org.hip.vif.web.util.VIFAppHelper.java

License:Open Source License

/** Get's the value for the specified key from the Vaadin session.
 *
 * @param inKey String//from   ww  w . j av  a2  s .c o  m
 * @return Long If no value is stored for the name, null is returned. */
public static Long getValueFromSession(final String inKey) {
    try {
        VaadinSession.getCurrent().getLockInstance().lock();
        return (Long) VaadinSession.getCurrent().getAttribute(inKey);
    } finally {
        VaadinSession.getCurrent().getLockInstance().unlock();
    }
}

From source file:org.ikasan.dashboard.ui.dashboard.panel.DashboardPanel.java

License:BSD License

@Subscribe
public void receiveAlertEvent(final AlertEvent event) {
    UI.getCurrent().access(new Runnable() {
        @Override//from  ww  w.  j a  v  a  2 s . c o  m
        public void run() {
            VaadinSession.getCurrent().getLockInstance().lock();
            try {
                Item item = container.addItemAt(0, event.getAlert() + this);

                Property<String> alertProperty = item.getItemProperty("Alert");

                alertProperty.setValue(event.getAlert());

                final Property<String> moduleProperty = item.getItemProperty("Module");

                moduleProperty.setValue(event.getModule());

                TextArea notesField = new TextArea("Notes");
                notesField.setWidth("500px");
                notesField.setRequired(false);
                notesField.setHeight("150px");
                notesField.setImmediate(true);
                notesField.setStyleName("coursedetailtext");
                // popup notes view
                final PopupView notesPopupView = new PopupView("Details", notesField);
                notesPopupView.setCaption("Details");
                notesPopupView.setHideOnMouseOut(false);
                notesPopupView.setData(event.getAlert() + this);

                final Property<PopupView> detailsProperty = item.getItemProperty("Details");

                detailsProperty.setValue(notesPopupView);

                System.out.println("container = " + container);
                System.out.println("Item = " + item);
            } finally {
                VaadinSession.getCurrent().getLockInstance().unlock();
            }

            //               UI.getCurrent().push();   
        }
    });
}

From source file:org.ikasan.dashboard.ui.dashboard.panel.DashboardPanel.java

License:BSD License

@Subscribe
public void receiveHealthAlert(final HealthEvent event) {
    UI.getCurrent().access(new Runnable() {
        @Override//from  w  w w.  j a  v  a  2  s . co m
        public void run() {
            VaadinSession.getCurrent().getLockInstance().lock();
            try {
                Item item = healthContainer.addItemAt(0, event.getAlert() + this);

                Property<String> alertProperty = item.getItemProperty("Health Alert");

                alertProperty.setValue(event.getAlert());

                final Property<String> moduleProperty = item.getItemProperty("Module");

                moduleProperty.setValue(event.getModule());

                System.out.println("container = " + container);
                System.out.println("Item = " + item);
            } finally {
                VaadinSession.getCurrent().getLockInstance().unlock();
            }

            //               UI.getCurrent().push();   
        }
    });
}

From source file:org.ikasan.dashboard.ui.framework.action.LogoutAction.java

License:BSD License

@Override
public void exectuteAction() {
    VaadinService.getCurrentRequest().getWrappedSession().setAttribute(DashboardSessionValueConstants.USER,
            null);//from   w  w  w .j  av  a2  s .  c  om
    this.visibilityGroup.setVisible();
    this.editableGroup.setEditable(false);

    layout.removeComponent(this.logOutButton);
    layout.addComponent(this.loginButton, 2, 0);
    layout.addComponent(this.setupButton, 3, 0);
    layout.setComponentAlignment(this.setupButton, Alignment.MIDDLE_RIGHT);
    layout.setComponentAlignment(this.loginButton, Alignment.MIDDLE_RIGHT);
    this.layout.removeComponent(userLabel);

    VaadinSession vSession = VaadinSession.getCurrent();
    WrappedSession httpSession = vSession.getSession();

    this.navigationPanel.reset();

    //Invalidate HttpSession
    httpSession.invalidate();
    vSession.close();
    //Redirect the user to the login/default Page
    Page.getCurrent().setLocation("/ikasan-dashboard");
}

From source file:org.ikasan.dashboard.ui.framework.component.FlowStateTable.java

License:BSD License

@Subscribe
public void receiveAlertEvent(final FlowStateEvent event) {
    logger.info("received event: " + event);
    UI.getCurrent().access(new Runnable() {
        @Override/*  w  w w  .ja v a  2  s .  co  m*/
        public void run() {
            VaadinSession.getCurrent().getLockInstance().lock();
            try {
                populate(event.getFlowStateMap());
            } finally {
                VaadinSession.getCurrent().getLockInstance().unlock();
            }

            UI.getCurrent().push();
        }
    });
}

From source file:org.ikasan.dashboard.ui.IkasanUI.java

License:BSD License

@Override
protected void init(VaadinRequest request) {
    VaadinSession.getCurrent().setAttribute(DashboardSessionValueConstants.TOPOLOGY_STATE_CACHE,
            this.topologyStateCache);

    addStyleName(ValoTheme.UI_WITH_MENU);

    this.mainLayout.setSizeFull();
    this.setContent(this.mainLayout);

    this.imagePanelLayout.removeAllComponents();
    this.imagePanelLayout.setHeight("70px");

    this.mainLayout.removeAllComponents();
    this.mainLayout.addComponent(imagePanelLayout, 0, 0);

    this.imagePanelLayout.setStyleName("v-header");

    this.imagePanelLayout.addComponent(this.bannerImage);
    this.bannerImage.setHeight("150%");
    this.imagePanelLayout.setExpandRatio(this.bannerImage, 0.5f);

    this.bannerLabel.setStyleName("ikasan-maroon");
    this.bannerLabel.setHeight("100%");
    this.imagePanelLayout.addComponent(this.bannerLabel);
    this.imagePanelLayout.setExpandRatio(this.bannerLabel, 0.5f);
    this.imagePanelLayout.setComponentAlignment(this.bannerLabel, Alignment.BOTTOM_LEFT);

    this.mainLayout.addComponent(navigationPanel, 0, 1);

    loadTopLevelNavigator();// w  ww .j  a  va  2  s.  c o m
    buildContent();
    this.menuLayout.addMenu(this.menuContent);
    this.mainLayout.addComponent(this.menuLayout, 0, 2);

    this.mainLayout.setRowExpandRatio(2, 1);

    this.navigationPanel.resetCurrentView();
    this.navigationPanel.setToggleButton(buildToggleButton());

    for (Component component : menu.getMenuComponents().keySet()) {
        component.setVisible(false);
    }

    this.navigationPanel.setMenuComponents(menu.getMenuComponents());

    UI.getCurrent().getNavigator().navigateTo("landingView");
    this.navigationPanel.setVisible(true);
}