List of usage examples for com.vaadin.server VaadinSession setAttribute
public <T> void setAttribute(Class<T> type, T value)
From source file:com.haulmont.cuba.web.sys.WebVaadinCompatibleSecurityContextHolder.java
License:Apache License
@Override public void set(SecurityContext securityContext) { VaadinSession vaadinSession = VaadinSession.getCurrent(); if (vaadinSession != null && vaadinSession.hasLock()) { vaadinSession.setAttribute(SecurityContext.class, securityContext); } else {/*from w ww . jav a 2 s. c o m*/ super.set(securityContext); } }
From source file:com.skysql.manager.ManagerUI.java
License:Open Source License
@Override protected void init(VaadinRequest request) { VaadinSession session = getSession(); Logging.setComponent("WebUI"); try {//from www .java2 s . c o m do { session.setAttribute(ManagerUI.class, this); AppData appData = AppData.newInstance(); if (appData == null) { setContent(new ErrorView(Notification.Type.ERROR_MESSAGE, null)); return; } session.setAttribute(AppData.class, appData); log("init session: - " + session + " UI: " + this.toString()); APIrestful api = APIrestful.newInstance(appData.getApiURI(), appData.getAppID(), appData.getApiKey()); if (api == null) { setContent(new ErrorView(Notification.Type.ERROR_MESSAGE, null)); return; } session.setAttribute(APIrestful.class, api); UserInfo userInfo = new UserInfo(null); if (userInfo.getUsersList() == null || userInfo.getUsersList().isEmpty()) { break; } session.setAttribute(UserInfo.class, userInfo); session.setAttribute(CachedData.class, new CachedData()); } while (false); refreshContentBasedOnSessionData(); } catch (RuntimeException e) { ManagerUI.error("RunTime error: " + e.getLocalizedMessage()); close(); } }
From source file:com.skysql.manager.ManagerUI.java
License:Open Source License
/** * Refresh content based on session data. */// www . j a v a 2s . c o m public void refreshContentBasedOnSessionData() { /* * As the UI is regenerated upon browser refresh, we should always check in the init what content to set to our UI. * * To force our application to reuse the same UI instance, we can add the @PreserveOnRefresh-annotation to our UI class */ VaadinSession session = getSession(); AppData appData = session.getAttribute(AppData.class); if (appData == null) { setContent(new ErrorView(Notification.Type.ERROR_MESSAGE, "Cannot find configuration file")); return; } APIrestful api = session.getAttribute(APIrestful.class); if (api == null) { setContent(new ErrorView(Notification.Type.ERROR_MESSAGE, null)); return; } new Versions("gui", "MariaDB-Manager-WebUI", GUI_VERSION + (Debug.ON ? " DEBUG" : ""), GUI_RELEASE, null); SystemInfo systemInfo = new SystemInfo(SystemInfo.SYSTEM_ROOT); session.setAttribute(SystemInfo.class, systemInfo); UserInfo userInfo = session.getAttribute(UserInfo.class); if (userInfo == null || userInfo.getUsersList() == null || userInfo.getUsersList().isEmpty()) { setContent(new ErrorView(Notification.Type.HUMANIZED_MESSAGE, "Initial System Setup - Please provide your configuration information.")); new SetupDialog(); return; } UserObject userObject = session.getAttribute(UserObject.class); if (userObject == null) { setContent(new LoginView()); } else { String adjust = userObject.getProperty(UserObject.PROPERTY_TIME_ADJUST); DateConversion dateConversion = new DateConversion( (adjust == null ? GeneralSettings.DEFAULT_TIME_ADJUST : Boolean.valueOf(adjust)), userObject.getProperty(UserObject.PROPERTY_TIME_FORMAT)); session.setAttribute(DateConversion.class, dateConversion); session.setAttribute("isChartsEditing", false); initLayout(); initExecutor(); } }
From source file:com.skysql.manager.ManagerUI.java
License:Open Source License
/** * Inits the layout./*from ww w . j a va 2 s . c o m*/ */ private void initLayout() { VerticalLayout main = new VerticalLayout(); main.setMargin(new MarginInfo(false, true, false, true)); main.setSpacing(true); main.setSizeFull(); setContent(main); VaadinSession session = getSession(); AnimatorProxy proxy = new AnimatorProxy(); main.addComponent(proxy); session.setAttribute(AnimatorProxy.class, proxy); VerticalLayout topMiddleLayout = new VerticalLayout(); main.addComponent(topMiddleLayout); session.setAttribute(VerticalLayout.class, topMiddleLayout); TopPanel topPanel = new TopPanel(); topMiddleLayout.addComponent(topPanel); session.setAttribute(TopPanel.class, topPanel); overviewPanel = new OverviewPanel(); topMiddleLayout.addComponent(overviewPanel); session.setAttribute(OverviewPanel.class, overviewPanel); tabbedPanel = new TabbedPanel(session); main.addComponent(tabbedPanel.getTabSheet()); main.setExpandRatio(tabbedPanel.getTabSheet(), 1f); session.setAttribute(TabbedPanel.class, tabbedPanel); overviewPanel.refresh(); }
From source file:com.skysql.manager.ui.components.NodesLayout.java
License:Open Source License
/** * Instantiates a new nodes layout./*from w ww.j av a 2s . c o m*/ * * @param systemRecord the system record */ public NodesLayout(SystemRecord systemRecord) { addStyleName("network"); addLayoutClickListener(new LayoutClickListener() { public void layoutClick(LayoutClickEvent event) { Component child; VaadinSession session = getSession(); boolean isDoubleClick = event.isDoubleClick(); ManagerUI.log("is DoubleClick: " + isDoubleClick); if (event.isDoubleClick() && (child = event.getChildComponent()) != null && (child instanceof ComponentButton)) { // Get the child component which was double-clicked ComponentButton button = (ComponentButton) child; ClusterComponent clusterComponent = (ClusterComponent) button.getData(); if (isEditable) { new ComponentDialog(clusterComponent, button); } else { if (clusterComponent.getType() == ClusterComponent.CCType.system) { SystemInfo systemInfo = session.getAttribute(SystemInfo.class); String clusterID = clusterComponent.getID(); systemInfo.setCurrentSystem(clusterID); session.setAttribute(SystemInfo.class, systemInfo); ManagerUI.log("new systemID: " + clusterID); clusterComponent.setButton(button); OverviewPanel overviewPanel = session.getAttribute(OverviewPanel.class); overviewPanel.refresh(); } } } else if (!isEditable && (child = event.getChildComponent()) != null && (child instanceof ComponentButton)) { // Get the child component which was clicked ComponentButton button = (ComponentButton) child; OverviewPanel overviewPanel = session.getAttribute(OverviewPanel.class); overviewPanel.clickLayout(button, true); } } }); }
From source file:com.skysql.manager.ui.components.SystemLayout.java
License:Open Source License
/** * Instantiates a new system layout./*from w w w. j a va 2 s . c om*/ * * @param systemRecord the system record */ public SystemLayout(SystemRecord systemRecord) { addStyleName("systemLayout"); setWidth(Sizeable.SIZE_UNDEFINED, Sizeable.Unit.PERCENTAGE); setMargin(new MarginInfo(false, true, false, false)); final HorizontalLayout systemHeader = new HorizontalLayout(); systemHeader.addStyleName("panelHeaderLayout"); systemHeader.setSpacing(true); systemHeader.setWidth("100%"); systemHeader.setHeight("23px"); addComponent(systemHeader); backButton = new NativeButton(); backButton.setStyleName("backButton"); backButton.setDescription("Back to Systems"); systemHeader.addComponent(backButton); backButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { VaadinSession session = getSession(); SystemInfo systemInfo = session.getAttribute(SystemInfo.class); OverviewPanel overviewPanel = session.getAttribute(OverviewPanel.class); ComponentButton button = systemInfo.getCurrentSystem().getButton(); String parentID = systemInfo.getCurrentSystem().getParentID(); systemInfo.setCurrentSystem(parentID); session.setAttribute(SystemInfo.class, systemInfo); ManagerUI.log("new systemID: " + parentID); overviewPanel.clickLayout(button, false); overviewPanel.refresh(); } }); final Label systemLabel = new Label("Systems"); systemLabel.setSizeUndefined(); systemHeader.addComponent(systemLabel); systemHeader.setComponentAlignment(systemLabel, Alignment.MIDDLE_LEFT); systemHeader.setExpandRatio(systemLabel, 1.0f); systemSlot = new HorizontalLayout(); addComponent(systemSlot); // initialize System button refresh(null, null); }
From source file:com.skysql.manager.ui.components.SystemLayout.java
License:Open Source License
/** * Delete component.// www . j a va 2s . co m * * @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: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 ww w . j ava 2s. c o 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 a v a 2s .c o m return userSession; }
From source file:de.unioninvestment.eai.portal.support.vaadin.ParameterRetrievalRequestHandler.java
License:Apache License
@Override public boolean handleRequest(VaadinSession session, VaadinRequest request, VaadinResponse response) throws IOException { PortletRequest portletRequest = VaadinPortletService.getCurrentPortletRequest(); if (portletRequest instanceof RenderRequest) { Map<String, String[]> allParameters = getOriginalServletRequestParameters(portletRequest); Map<String, String[]> parameters = copyParametersIgnoreLiferayPrefix(allParameters); session.setAttribute("parameters", parameters); }/*from w w w . j a va 2s. c o m*/ return false; }