Example usage for com.vaadin.server WebBrowser getBrowserMajorVersion

List of usage examples for com.vaadin.server WebBrowser getBrowserMajorVersion

Introduction

In this page you can find the example usage for com.vaadin.server WebBrowser getBrowserMajorVersion.

Prototype

public int getBrowserMajorVersion() 

Source Link

Document

Gets the major version of the browser the user is using.

Usage

From source file:annis.gui.SearchUI.java

License:Apache License

@Override
public void notifyCannotPlayMimeType(String mimeType) {
    if (mimeType == null) {
        return;/* w w w .  ja  v a  2 s .c  o m*/
    }

    if (mimeType.startsWith("audio/ogg") || mimeType.startsWith("video/web")) {
        String browserList = "<ul>"
                + "<li>Mozilla Firefox: <a href=\"http://www.mozilla.org/firefox\" target=\"_blank\">http://www.mozilla.org/firefox</a></li>"
                + "<li>Google Chrome: <a href=\"http://www.google.com/chrome\" target=\"_blank\">http://www.google.com/chrome</a></li>"
                + "</ul>";

        WebBrowser browser = getPage().getWebBrowser();

        // IE9 users can install a plugin
        Set<String> supportedByIE9Plugin = new HashSet<String>();
        supportedByIE9Plugin.add("video/webm");
        supportedByIE9Plugin.add("audio/ogg");
        supportedByIE9Plugin.add("video/ogg");

        if (browser.isIE() && browser.getBrowserMajorVersion() >= 9
                && supportedByIE9Plugin.contains(mimeType)) {
            Notification.show("Media file type unsupported by your browser",
                    "Please install the WebM plugin for Internet Explorer 9 from "
                            + "<a href=\"https://tools.google.com/dlpage/webmmf\">https://tools.google.com/dlpage/webmmf</a> "
                            + " or use a browser from the following list "
                            + "(these are known to work with WebM or OGG files)<br/>" + browserList,
                    Notification.Type.WARNING_MESSAGE);
        } else {
            Notification.show("Media file type unsupported by your browser",
                    "Please use a browser from the following list "
                            + "(these are known to work with WebM or OGG files)<br/>" + browserList,
                    Notification.Type.WARNING_MESSAGE);
        }
    } else {
        Notification.show("Media file type \"" + mimeType + "\" unsupported by your browser!",
                "Try to check your browsers documentation how to enable "
                        + "support for the media type or inform the corpus creator about this problem.",
                Notification.Type.WARNING_MESSAGE);
    }

}

From source file:annis.gui.SearchView.java

License:Apache License

@Override
public void notifyCannotPlayMimeType(String mimeType) {
    if (mimeType == null) {
        return;/* w ww  . j  a va2  s.c  om*/
    }

    if (mimeType.startsWith("audio/ogg") || mimeType.startsWith("video/web")) {
        String browserList = "<ul>"
                + "<li>Mozilla Firefox: <a href=\"http://www.mozilla.org/firefox\" target=\"_blank\">http://www.mozilla.org/firefox</a></li>"
                + "<li>Google Chrome: <a href=\"http://www.google.com/chrome\" target=\"_blank\">http://www.google.com/chrome</a></li>"
                + "</ul>";

        WebBrowser browser = Page.getCurrent().getWebBrowser();

        // IE9 users can install a plugin
        Set<String> supportedByIE9Plugin = new HashSet<>();
        supportedByIE9Plugin.add("video/webm");
        supportedByIE9Plugin.add("audio/ogg");
        supportedByIE9Plugin.add("video/ogg");

        if (browser.isIE() && browser.getBrowserMajorVersion() >= 9
                && supportedByIE9Plugin.contains(mimeType)) {
            Notification n = new Notification("Media file type unsupported by your browser",
                    "Please install the WebM plugin for Internet Explorer 9 from "
                            + "<a target=\"_blank\" href=\"https://tools.google.com/dlpage/webmmf\">https://tools.google.com/dlpage/webmmf</a> "
                            + " or use a browser from the following list "
                            + "(these are known to work with WebM or OGG files)<br/>" + browserList
                            + "<br/><br /><strong>Click on this message to hide it</strong>",
                    Notification.Type.WARNING_MESSAGE, true);
            n.setDelayMsec(15000);

            n.show(Page.getCurrent());
        } else {
            Notification n = new Notification("Media file type unsupported by your browser",
                    "Please use a browser from the following list "
                            + "(these are known to work with WebM or OGG files)<br/>" + browserList
                            + "<br/><br /><strong>Click on this message to hide it</strong>",
                    Notification.Type.WARNING_MESSAGE, true);
            n.setDelayMsec(15000);
            n.show(Page.getCurrent());
        }
    } else {
        Notification.show("Media file type \"" + mimeType + "\" unsupported by your browser!",
                "Try to check your browsers documentation how to enable "
                        + "support for the media type or inform the corpus creator about this problem.",
                Notification.Type.WARNING_MESSAGE);
    }

}

From source file:com.esofthead.mycollab.community.ui.chart.JFreeChartWrapper.java

License:Open Source License

@Override
public void attach() {
    super.attach();
    if (mode == RenderingMode.AUTO) {
        WebBrowser browser = Page.getCurrent().getWebBrowser();
        if (browser.isIE() && browser.getBrowserMajorVersion() < 9) {
            setRenderingMode(RenderingMode.PNG);
        } else {//from  w  w  w .  j av a  2 s . c o  m
            // all decent browsers support SVG
            setRenderingMode(RenderingMode.SVG);
        }
    }
    setResource("src", getSource());
}

From source file:com.foc.vaadin.gui.components.chart.JFreeChartWrapper.java

License:Apache License

@Override
public void attach() {
    super.attach();
    if (mode == RenderingMode.AUTO) {
        WebBrowser browser = getSession().getBrowser();
        if (browser.isIE() && browser.getBrowserMajorVersion() < 9) {
            setRenderingMode(RenderingMode.PNG);
        } else {/*  w  w w  .  ja  v  a  2s  .  co  m*/
            // all decent browsers support SVG
            setRenderingMode(RenderingMode.SVG);
        }
    }
    // Workaround for a regression that Vaadin core update caused
    // at some point
    setResource("src", getSource());
}

From source file:com.foc.vaadin.gui.components.chart.JFreeChartWrapper_Modified.java

License:Apache License

@Override
public void attach() {
    //      super.attach();
    //      AbstractWebApplicationContext context = (AbstractWebApplicationContext) getUI().getContext();
    ServletContext context = VaadinServlet.getCurrent().getServletContext();
    if (mode == RenderingMode.AUTO) {
        WebBrowser webBrowser = getWebBrowser();
        if (webBrowser.isIE() && webBrowser.getBrowserMajorVersion() < 9) {
            setRenderingMode(RenderingMode.PNG);
        } else {//from ww w  . ja  v a  2  s .  c om
            // all decent browsers support SVG
            setRenderingMode(RenderingMode.SVG);
        }
    }
    ;
    Image image = new Image("", getSource());

    chartLayout.addComponent(image);
    //VAADIN 7
    //      getApplication().addResource((ConnectorResource) getSource());

    setResource("src", getSource());//Antoine See Workarround from https://vaadin.com/forum#!/thread/8366526
    markAsDirtyRecursive();
}

From source file:com.haulmont.cuba.web.config.WebDeviceInfoProvider.java

License:Apache License

@Nullable
@Override/*from   www. j a  v  a 2  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();//from  w w w  . j  av  a  2 s.  co m
    if (current != null) {
        WebBrowser browser = current.getWebBrowser();
        return browser != null
                && (browser.isIE() && browser.getBrowserMajorVersion() <= 10 || browser.isSafari());
    } else {
        return false;
    }
}

From source file:com.haulmont.cuba.web.gui.components.WebFileMultiUploadField.java

License:Apache License

public WebFileMultiUploadField() {
    fileUploading = AppBeans.get(FileUploadingAPI.NAME);

    WebBrowser webBrowser = Page.getCurrent().getWebBrowser();
    if ((webBrowser.isIE() && !webBrowser.isEdge()) && webBrowser.getBrowserMajorVersion() < 10) {
        initOldComponent();/*from  ww w .  ja  va 2 s.  c  om*/
    } else {
        initComponent();
    }
}

From source file:com.haulmont.cuba.web.gui.components.WebFileUploadField.java

License:Apache License

public WebFileUploadField() {
    fileUploading = AppBeans.get(FileUploadingAPI.NAME);
    exportDisplay = AppBeans.get(ExportDisplay.NAME);
    messages = AppBeans.get(Messages.NAME);

    WebBrowser webBrowser = Page.getCurrent().getWebBrowser();
    if ((webBrowser.isIE() && !webBrowser.isEdge()) && webBrowser.getBrowserMajorVersion() < 10) {
        initOldUploadButton();//from  w w  w .  j  a v  a  2 s. c o m
    } else {
        initUploadButton();
    }

    initComponent();
    attachListener(component);
}

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();/*w ww .ja va  2 s. c  o m*/
    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 {
            container.addComponent(field);
        }
    } else {
        container.addComponent(field);
    }

    if (App.isBound()) {
        ThemeConstants theme = App.getInstance().getThemeConstants();
        setWidth(theme.get("cuba.web.CubaPickerField.width"));
    }

    setFocusDelegate(field);
}