List of usage examples for com.vaadin.server Page getWebBrowser
public WebBrowser getWebBrowser()
From source file:com.hack23.cia.web.impl.ui.application.CitizenIntelligenceAgencyUI.java
License:Apache License
@Override protected void init(final VaadinRequest request) { VaadinSession.getCurrent().setErrorHandler(new UiInstanceErrorHandler(this)); setSizeFull();//www . ja v a 2 s. co m final DiscoveryNavigator navigator = new DiscoveryNavigator(this, this); navigator.addView("", mainView); setNavigator(navigator); final Page currentPage = Page.getCurrent(); final String requestUrl = currentPage.getLocation().toString(); final String language = request.getLocale().getLanguage(); final UserConfiguration userConfiguration = configurationManager.getUserConfiguration(requestUrl, language); currentPage.setTitle( userConfiguration.getAgency().getAgencyName() + ":" + userConfiguration.getPortal().getPortalName() + ":" + userConfiguration.getLanguage().getLanguageName()); if (getSession().getUIs().isEmpty()) { final WebBrowser webBrowser = currentPage.getWebBrowser(); final CreateApplicationSessionRequest serviceRequest = new CreateApplicationSessionRequest(); serviceRequest.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId()); final String ipInformation = WebBrowserUtil.getIpInformation(webBrowser); serviceRequest.setIpInformation(ipInformation); serviceRequest.setUserAgentInformation(webBrowser.getBrowserApplication()); serviceRequest.setLocale(webBrowser.getLocale().toString()); serviceRequest.setOperatingSystem(WebBrowserUtil.getOperatingSystem(webBrowser)); serviceRequest.setSessionType(ApplicationSessionType.ANONYMOUS); final ServiceResponse serviceResponse = applicationManager.service(serviceRequest); LOGGER.info(LOG_INFO_BROWSER_ADDRESS_APPLICATION_SESSION_ID_RESULT, requestUrl, language, ipInformation, webBrowser.getBrowserApplication(), serviceRequest.getSessionId(), serviceResponse.getResult().toString()); } }
From source file:com.haulmont.cuba.web.AbstractConnection.java
License:Apache License
protected String makeClientInfo() { Page page = AppUI.getCurrent().getPage(); WebBrowser webBrowser = page.getWebBrowser(); Configuration configuration = AppBeans.get(Configuration.NAME); GlobalConfig globalConfig = configuration.getConfig(GlobalConfig.class); String serverInfo = "Web (" + globalConfig.getWebHostName() + ":" + globalConfig.getWebPort() + "/" + globalConfig.getWebContextName() + ") "; return serverInfo + webBrowser.getBrowserApplication(); }
From source file:com.haulmont.cuba.web.AbstractConnection.java
License:Apache License
protected TimeZone detectTimeZone() { Page page = AppUI.getCurrent().getPage(); WebBrowser webBrowser = page.getWebBrowser(); int offset = webBrowser.getTimezoneOffset() / 1000 / 60; String hours = StringUtils.leftPad(String.valueOf(offset / 60), 2, '0'); String mins = StringUtils.leftPad(String.valueOf(offset % 60), 2, '0'); char sign = offset >= 0 ? '+' : '-'; return TimeZone.getTimeZone("GMT" + sign + hours + mins); }
From source file:com.haulmont.cuba.web.config.WebDeviceInfoProvider.java
License:Apache License
@Nullable @Override//w ww. j a va2 s .c om public DeviceInfo getDeviceInfo() { // per request cache HttpServletRequest currentServletRequest = VaadinServletService.getCurrentServletRequest(); if (currentServletRequest == null) { return null; } DeviceInfo deviceInfo = (DeviceInfo) currentServletRequest.getAttribute(DeviceInfoProvider.NAME); if (deviceInfo != null) { return deviceInfo; } Page page = Page.getCurrent(); if (page == null) { return null; } WebBrowser webBrowser = page.getWebBrowser(); DeviceInfo di = new DeviceInfo(); di.setAddress(webBrowser.getAddress()); di.setBrowserApplication(webBrowser.getBrowserApplication()); di.setBrowserMajorVersion(webBrowser.getBrowserMajorVersion()); di.setBrowserMinorVersion(webBrowser.getBrowserMinorVersion()); di.setChrome(webBrowser.isChrome()); di.setChromeFrame(webBrowser.isChromeFrame()); di.setChromeFrameCapable(webBrowser.isChromeFrameCapable()); di.setEdge(webBrowser.isEdge()); di.setFirefox(webBrowser.isFirefox()); di.setOpera(webBrowser.isOpera()); di.setIE(webBrowser.isIE()); if (webBrowser.isWindows()) { di.setOperatingSystem(OperatingSystem.WINDOWS); } else if (webBrowser.isAndroid()) { di.setOperatingSystem(OperatingSystem.ANDROID); } else if (webBrowser.isIOS()) { di.setOperatingSystem(OperatingSystem.IOS); } else if (webBrowser.isMacOSX()) { di.setOperatingSystem(OperatingSystem.MACOSX); } else if (webBrowser.isLinux()) { di.setOperatingSystem(OperatingSystem.LINUX); } di.setIPad(webBrowser.isIPad()); di.setIPhone(webBrowser.isIPhone()); di.setWindowsPhone(webBrowser.isWindowsPhone()); di.setSecureConnection(webBrowser.isSecureConnection()); di.setLocale(webBrowser.getLocale()); di.setScreenHeight(webBrowser.getScreenHeight()); di.setScreenWidth(webBrowser.getScreenWidth()); currentServletRequest.setAttribute(DeviceInfoProvider.NAME, di); return di; }
From source file:com.haulmont.cuba.web.gui.components.CubaCurrencyField.java
License:Apache License
protected boolean useWrapper() { Page current = Page.getCurrent(); if (current != null) { WebBrowser browser = current.getWebBrowser(); return browser != null && (browser.isIE() && browser.getBrowserMajorVersion() <= 10 || browser.isSafari()); } else {/* w w w .j a v a 2 s . com*/ return false; } }
From source file:com.haulmont.cuba.web.toolkit.ui.CubaPickerField.java
License:Apache License
protected void initLayout() { container = new CubaCssActionsLayout(); container.setPrimaryStyleName("c-pickerfield-layout"); field.setWidth(100, Unit.PERCENTAGE); Page current = Page.getCurrent(); if (current != null) { WebBrowser browser = current.getWebBrowser(); if (browser != null && (browser.isIE() && browser.getBrowserMajorVersion() <= 10 || browser.isSafari())) { ie9InputWrapper = new CssLayout(); ie9InputWrapper.setWidth(100, Unit.PERCENTAGE); ie9InputWrapper.setPrimaryStyleName("ie9-input-wrap"); ie9InputWrapper.addComponent(field); container.addComponent(ie9InputWrapper); } else {/*from w ww . j a v a2 s . c o m*/ container.addComponent(field); } } else { container.addComponent(field); } if (App.isBound()) { ThemeConstants theme = App.getInstance().getThemeConstants(); setWidth(theme.get("cuba.web.CubaPickerField.width")); } setFocusDelegate(field); }
From source file:de.metas.procurement.webui.LoggingConfiguration.java
License:Open Source License
public void updateMDC() { //// www . java2 s. c o m // Remote address try { final VaadinRequest vaadinRequest = VaadinService.getCurrentRequest(); if (vaadinRequest != null) { final String remoteAddr = vaadinRequest.getRemoteAddr(); MDC.put(MDC_Param_RemoteAddr, remoteAddr); } } catch (final Exception e) { e.printStackTrace(); MDC.put(MDC_Param_RemoteAddr, "?"); } // // LoggedUser try { final MFSession mfSession = MFProcurementUI.getCurrentMFSession(); if (mfSession != null) { final User user = mfSession.getUser(); if (user != null) { final String email = user.getEmail(); if (email != null) { MDC.put(MDC_Param_LoggedUser, email); } } } } catch (final Exception e) { e.printStackTrace(); MDC.put(MDC_Param_LoggedUser, "?"); } // // UserAgent try { final Page page = Page.getCurrent(); if (page != null) { final WebBrowser webBrowser = page.getWebBrowser(); if (webBrowser != null) { final String userAgent = webBrowser.getBrowserApplication(); MDC.put(MDC_Param_UserAgent, userAgent); } } } catch (final Exception e) { e.printStackTrace(); MDC.put(MDC_Param_UserAgent, "?"); } // // SessionId try { final VaadinSession session = VaadinSession.getCurrent(); if (session != null) { final int sessionId = System.identityHashCode(session); MDC.put(MDC_Param_SessionId, Integer.toString(sessionId)); } } catch (final Exception e) { e.printStackTrace(); MDC.put(MDC_Param_SessionId, "?"); } // // UI Id try { final UI ui = UI.getCurrent(); if (ui != null) { final int uiId = ui.getUIId(); MDC.put(MDC_Param_UIId, Integer.toString(uiId)); } } catch (final Exception e) { e.printStackTrace(); MDC.put(MDC_Param_UIId, "?"); } }
From source file:de.metas.procurement.webui.service.impl.LoginRememberMeService.java
License:Open Source License
public boolean isEnabled() { if (!enabled) { return false; }//from w ww .j a v a 2s . co m final Page page = Page.getCurrent(); if (page != null && page.getWebBrowser().isChrome()) { logger.trace( "Considering feature disabled for chome because Chrome's password manager is known to work"); return false; } return true; }
From source file:uk.co.q3c.v7.base.ui.BrowserProvider.java
License:Apache License
@Override public WebBrowser get() { Page page = Page.getCurrent(); return (page == null) ? null : page.getWebBrowser(); }