List of usage examples for com.vaadin.server WebBrowser isTouchDevice
public boolean isTouchDevice()
From source file:com.lst.deploymentautomation.vaadin.core.LspsUI.java
License:Open Source License
private void initLayout() { //load current user info boolean themeChange = false; userInfo = (UserInfo) getSession().getAttribute("user"); if (userInfo == null) { userInfo = new UserInfo(LspsAppConnectorImpl.INJECTOR_INSTANCE); getSession().setAttribute("user", userInfo); String theme = userInfo.getSettingString("theme", Constants.DEFAULT_THEME); // if user have set other than default theme if (!theme.equals(Constants.DEFAULT_THEME)) { if (Constants.THEMES.contains(theme)) { this.setTheme(theme); } else { this.setTheme(Constants.DEFAULT_THEME); }// ww w .j av a 2s. c o m themeChange = true; } } //get browser info WebBrowser browser = getPage().getWebBrowser(); //set layout style String layoutSetting = "l-layout-" + userInfo.getSettingString("layoutSetting", "compact"); JavaScript.getCurrent().execute("" + "if (!Array.prototype.indexOf) {" + "Array.prototype.indexOf = function(obj, start) {for (var i = (start || 0), j = this.length; i < j; i++) {if (this[i] === obj) { return i; }}return -1;}" + "}" + "var setting = '" + layoutSetting + "';" + "var classes = document.body.className.split(/\\s+/);" + "var index = classes.indexOf(setting);" + "~index || classes.push(setting);" + "document.body.className = classes.join(\" \");" + ""); String fontSetting = "l-font-" + userInfo.getSettingString("fontSetting", "standard"); JavaScript.getCurrent().execute("" + "document.documentElement.className='" + fontSetting + "';" + ""); //set locale to the one preferred by the user Locale userLocale = userInfo.getLocale(); if (userLocale == null) { userLocale = Locale.US; } setLocale(userLocale); //initialize the layout appLayout = new AppLayout(); if (themeChange) { appLayout.setVisible(false); } else { if (browser.isTouchDevice()) { getUI().addStyleName("v-touch"); } else { //use fixed-width layout by default getUI().addStyleName("fixed"); } } setContent(appLayout); //setup navigation, register available views initNavigation(); if (getPage().getUriFragment() == null) { openHomePage(); } //if substitution is active, show warning if (getUser().getPerson().isSubstitutionActive()) { showWarningMessage("settings.substitutionActiveMessage"); } }
From source file:com.selzlein.lojavirtual.vaadin.core.LspsUI.java
License:Open Source License
private void initLayout() { //load current user info boolean themeChange = false; userInfo = (UserInfo) getSession().getAttribute("user"); if (userInfo == null) { userInfo = new UserInfo(LspsAppConnectorImpl.INJECTOR_INSTANCE); getSession().setAttribute("user", userInfo); String theme = userInfo.getSettingString("theme", Constants.DEFAULT_THEME); // if user have set other than default theme if (!theme.equals(Constants.DEFAULT_THEME)) { if (Constants.isValidTheme(vaadinThemeCache, theme)) { setThemeAndReload(theme); } else { setThemeAndReload(Constants.DEFAULT_THEME); }//from w w w .j a v a 2 s .co m themeChange = true; } else { storeThemeInStorage(theme); } } //get browser info WebBrowser browser = getPage().getWebBrowser(); //set locale to the one preferred by the user Locale userLocale = userInfo.getLocale(); if (userLocale == null) { userLocale = Locale.US; } setLocale(userLocale); //initialize the layout appLayout = new AppLayout(); connector.getInjector().inject(appLayout); if (themeChange) { appLayout.setVisible(false); } else { if (browser.isTouchDevice()) { getUI().addStyleName("v-touch"); } } setContent(appLayout); //setup navigation, register available views initNavigation(); if (getPage().getUriFragment() == null) { openHomePage(); } //if substitution is active, show warning if (getUser().getPerson().isSubstitutionActive()) { showWarningMessage("settings.substitutionActiveMessage"); } }