List of usage examples for com.vaadin.server VaadinSession getCurrent
public static VaadinSession getCurrent()
From source file:com.ocs.dynamo.service.impl.MessageServiceImpl.java
License:Apache License
private Locale getLocale() { VaadinSession session = VaadinSession.getCurrent(); if (session != null) { return session.getLocale(); }/* ww w. j a v a2 s .c o m*/ return Locale.getDefault(); }
From source file:com.ocs.dynamo.ui.utils.VaadinUtils.java
License:Apache License
/** * Returns the currency symbol to be used - by default this is looked up from the session, with * a fallback to the system property "default.currency.symbol" * //from w w w.j av a 2 s .c o m * @return */ public static String getCurrencySymbol() { String cs = SystemPropertyUtils.getDefaultCurrencySymbol(); VaadinSession vs = VaadinSession.getCurrent(); if (vs != null && vs.getAttribute(DynamoConstants.CURRENCY_SYMBOL) != null) { cs = (String) vs.getAttribute(DynamoConstants.CURRENCY_SYMBOL); } return cs; }
From source file:com.ocs.dynamo.ui.utils.VaadinUtils.java
License:Apache License
/** * Returns the locale associated with the current Vaadin session * //from w ww . j a v a 2 s . c o m * @return */ public static Locale getLocale() { if (VaadinSession.getCurrent() != null) { return VaadinSession.getCurrent().getLocale(); } return new Locale(SystemPropertyUtils.getDefaultLocale()); }
From source file:com.ocs.dynamo.ui.utils.VaadinUtils.java
License:Apache License
/** * Returns the first value from a session attribute that contains a map * /*w w w .ja v a 2 s .co m*/ * @param attributeName * the name of the attribute that holds the map * @param key * the map key * @return */ @SuppressWarnings("unchecked") public static String getSessionAttributeValueFromMap(String attributeName, String key) { Map<String, Object> map = (Map<String, Object>) VaadinSession.getCurrent().getSession() .getAttribute(attributeName); return getFirstValueFromCollection(map, key); }
From source file:com.saax.gestorweb.util.GestorSession.java
public static void setAttribute(String name, Object value) { // se execuo normal if (VaadinSession.getCurrent() != null) { VaadinSession.getCurrent().setAttribute(name, value); } else {/*from www . j a va 2 s.c o m*/ // se em testes setLocalAttribute(name, value); } }
From source file:com.saax.gestorweb.util.GestorSession.java
public static Object getAttribute(String name) { // se execuo normal if (VaadinSession.getCurrent() != null) { return VaadinSession.getCurrent().getAttribute(name); } else {/*from w w w. ja v a2 s. c o m*/ // se em testes return getLocalAttribute(name); } }
From source file:com.scipionyx.butterflyeffect.frontend.configuration.ui.view.AboutView.java
License:Apache License
/** * /*from ww w. j a v a 2s. com*/ * @param justclean * @throws UnknownHostException */ @SuppressWarnings("deprecation") private void loadFrontEndInformation(boolean loadData) throws UnknownHostException { // Remove all before adding tableFrontEndInformation.setItems(new ArrayList<>()); if (!loadData) return; List<GridProperty<?>> items = new ArrayList<>(); // Server Ip Address items.add(new GridProperty<String>("Server Ip 4 Host Address", Inet4Address.getLocalHost().getHostAddress(), "")); items.add(new GridProperty<String>("Server Ip 6 Host Address", Inet6Address.getLocalHost().getHostAddress(), "")); // Server Id // Server Memory items.add(new GridProperty<Long>("Free Memory", Runtime.getRuntime().freeMemory(), "")); items.add(new GridProperty<Long>("Max Memory", Runtime.getRuntime().maxMemory(), "")); items.add(new GridProperty<Long>("Total Memory", Runtime.getRuntime().totalMemory(), "")); // Server items.add(new GridProperty<String>("Availabe Processors", Runtime.getRuntime().availableProcessors() + "", "")); // Session items.add(new GridProperty<String>("Session Id", VaadinSession.getCurrent().getSession().getId(), "")); items.add(new GridProperty<String>("Session CreationTime", (new Date(VaadinSession.getCurrent().getSession().getCreationTime()).toGMTString()), "")); items.add(new GridProperty<String>("Session Last Access Time", (new Date(VaadinSession.getCurrent().getSession().getLastAccessedTime()).toGMTString()), "")); items.add(new GridProperty<String>("User", SecurityContextHolder.getContext().getAuthentication().getName(), "")); Collection<? extends GrantedAuthority> authorities = SecurityContextHolder.getContext().getAuthentication() .getAuthorities(); String roles = null; for (GrantedAuthority grantedAuthority : authorities) { if (roles == null) roles = grantedAuthority.getAuthority(); else roles = roles + "," + grantedAuthority.getAuthority(); } items.add(new GridProperty<String>("Roles", roles, "")); items.add(new GridProperty<String>("Client Ip", Page.getCurrent().getWebBrowser().getAddress(), "")); tableFrontEndInformation.setItems(items); }
From source file:com.skysql.manager.api.ChartProperties.java
License:Open Source License
/** * Instantiates a new chart properties.//from w w w . j ava2 s . c om * * @param dummy */ public ChartProperties(String dummy) { userObject = VaadinSession.getCurrent().getAttribute(UserObject.class); String propertyChartSettings = userObject.getProperty(UserObject.PROPERTY_CHART_SETTINGS); if (propertyChartSettings != null) { ChartProperties chartProperties = APIrestful.getGson().fromJson(propertyChartSettings, ChartProperties.class); timeSpan = chartProperties.getTimeSpan(); theme = chartProperties.getTheme(); } else { timeSpan = ChartControls.DEFAULT_INTERVAL; theme = ChartControls.DEFAULT_THEME; } // Try to get mappings from user properties String propertyChartMappings = userObject.getProperty(UserObject.PROPERTY_CHART_MAPPINGS); if (propertyChartMappings != null) { ChartProperties chartProperties = APIrestful.getGson().fromJson(propertyChartMappings, ChartProperties.class); this.chartsMap = chartProperties.getChartsMap(); } // If not available, create fresh mappings from all available Monitors if (chartsMap == null) { chartsMap = new LinkedHashMap<String, ArrayList<ChartMappings>>(); for (String type : SystemTypes.getList().keySet()) { ArrayList<ChartMappings> chartMappings = new ArrayList<ChartMappings>(); for (MonitorRecord monitor : Monitors.getMonitorsList(type).values()) { if (monitor.getChartType() == null) { continue; } ArrayList<String> monitorsForChart = new ArrayList<String>(); monitorsForChart.add(monitor.getID()); UserChart userChart = new UserChart(monitor.getName(), monitor.getDescription(), monitor.getUnit(), monitor.getChartType(), 15, monitorsForChart); ChartMappings chartMapping = new ChartMappings(userChart); chartMappings.add(chartMapping); } chartsMap.put(type, chartMappings); } } }
From source file:com.skysql.manager.api.MonitorData.java
License:Open Source License
private CachedData getLastModified() { if (lastModified == null || lastModified.get() == null) { lastModified = new ThreadLocal<CachedData>(); lastModified.set(VaadinSession.getCurrent().getAttribute(CachedData.class)); }/* w w w . j a v a 2 s .c o m*/ return lastModified.get(); }
From source file:com.skysql.manager.SystemRecord.java
License:Open Source License
/** * Tool tip. Generates the text to be displayed for this System's tooltip. * * @return the string// w w w .j av a 2s .co m */ public String ToolTip() { DateConversion dateConversion = VaadinSession.getCurrent().getAttribute(DateConversion.class); return "<h2>System</h2>" + "<ul>" + "<li><b>ID:</b> " + this.ID + "</li>" + "<li><b>Type:</b> " + this.systemType + "</li>" + "<li><b>Name:</b> " + this.name + "</li>" + "</li>" + "<li><b>State:</b> " + ((this.state == null) ? NOT_AVAILABLE : this.state) + "</li>" + "<li><b>Nodes:</b> " + ((this.nodes == null) ? NOT_AVAILABLE : Arrays.toString(this.nodes)) + "</li>" + "<li><b>Start Date:</b> " + ((this.startDate == null) ? NOT_AVAILABLE : dateConversion.adjust(this.startDate)) + "</li>" + "<li><b>Last Access:</b> " + ((this.lastAccess == null) ? NOT_AVAILABLE : dateConversion.adjust(this.lastAccess)) + "</li>" + "<li><b>Last Backup:</b> " + ((this.lastBackup == null) ? NOT_AVAILABLE : dateConversion.adjust(this.lastBackup)) + "</li>" + "</ul>"; }