Example usage for com.vaadin.server WebBrowser isWindows

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

Introduction

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

Prototype

public boolean isWindows() 

Source Link

Document

Tests whether the user is using Windows.

Usage

From source file:com.hack23.cia.web.impl.ui.application.util.WebBrowserUtil.java

License:Apache License

/**
 * Gets the operating system./*w  w w  .  j  a va  2s .  co  m*/
 *
 * @param webBrowser
 *            the web browser
 * @return the operating system
 */
public static String getOperatingSystem(final WebBrowser webBrowser) {
    String osName = UNKNOWN;
    if (webBrowser.isLinux()) {
        osName = LINUX;
    } else if (webBrowser.isWindows()) {
        osName = WINDOWS2;
    } else if (webBrowser.isWindowsPhone()) {
        osName = WINDOWS_PHONE;
    } else if (webBrowser.isMacOSX()) {
        osName = MAC_OSX;
    } else if (webBrowser.isAndroid()) {
        osName = ANDROID;
    } else if (webBrowser.isIOS()) {
        osName = IOS;
    } else if (webBrowser.isIPad()) {
        osName = IPAD;
    } else if (webBrowser.isIPhone()) {
        osName = I_PHONE;
    }
    return osName;
}

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

License:Apache License

@Nullable
@Override//w  w  w .j  ava 2s . com
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:edu.nps.moves.mmowgli.MmowgliSessionGlobals.java

License:Open Source License

private String returnBrowserOS(WebBrowser webBr) {
    if (webBr.isAndroid()) {
        return "Android";
    }//from w  w  w. j  a v a 2 s .  c o  m
    if (webBr.isIOS()) {
        return "IOS";
    }
    if (webBr.isIPad()) {
        return "IPad";
    }
    if (webBr.isIPhone()) {
        return "IPhone";
    }
    if (webBr.isLinux()) {
        return "Linux";
    }
    if (webBr.isMacOSX()) {
        return "MacOSX";
    }
    if (webBr.isWindows()) {
        return "Windows";
    }
    if (webBr.isWindowsPhone()) {
        return "Windows Phone";
    }
    return "Unknown OS/platform";
}

From source file:info.magnolia.ui.dialog.BaseDialogPresenter.java

License:Open Source License

@Override
public DialogView start(DialogDefinition dialogDefinition, UiContext uiContext) {
    // Additional close handler to check for cases when the dialog isn't closed from an action (shortcut, dialog close icon), and process callback accordingly
    getView().addDialogCloseHandler(new DialogCloseHandler() {

        @Override/*  w  w  w .  j ava  2  s  . co m*/
        public void onDialogClose(DialogView dialogView) {
            if (!isExecutingAction) {
                onCancel();
            }
        }
    });

    this.uiContext = uiContext;
    // ChooseDialogDefinition is already enhanced as it is obtained via ContentAppDescriptor.getChooseDialog() at ContentApp.openChooseDialog(..)
    if (Enhancer.isEnhanced(dialogDefinition.getClass())) {
        this.definition = dialogDefinition;
    } else {
        this.definition = i18nizer.decorate(dialogDefinition);
    }

    this.editorActionAreaPresenter = componentProvider
            .newInstance(definition.getActionArea().getPresenterClass());
    EditorActionAreaView editorActionAreaView = editorActionAreaPresenter.start(filterActions(),
            definition.getActionArea(), this, uiContext);

    // Set modifier key based on OS.
    int osSpecificModifierKey;
    UI ui = UI.getCurrent();
    if (ui != null) {
        WebBrowser browser = ui.getPage().getWebBrowser();
        if (browser.isWindows()) {
            osSpecificModifierKey = ModifierKey.CTRL;
        } else {
            // osx and linux
            osSpecificModifierKey = ModifierKey.META;
        }

        if (definition.getActions().containsKey(BaseDialog.COMMIT_ACTION_NAME)) {
            addShortcut(BaseDialog.COMMIT_ACTION_NAME, KeyCode.S, osSpecificModifierKey);
        }
        if (definition.getActions().containsKey(BaseDialog.CANCEL_ACTION_NAME)) {
            addShortcut(BaseDialog.CANCEL_ACTION_NAME, KeyCode.W, osSpecificModifierKey);
        }
        if (definition.getModalityLevel() == ModalityLevel.LIGHT) {
            view.addShortcut(new CloseDialogShortcutListener(KeyCode.ESCAPE));
        }

    } else {
        log.warn(
                "The current Vaadin UI was null when starting {}, as a result dialog keyboard shortcuts will not work.",
                this);
    }

    view.addShortcut(new CloseDialogAfterConfirmationShortcutListener(KeyCode.ESCAPE));
    view.addShortcut(new CommitDialogShortcutListener(KeyCode.ENTER));

    this.view.setActionAreaView(editorActionAreaView);
    this.view.setModalityLevel(definition.getModalityLevel());
    if (definition.isWide()) {
        this.view.setWide(true);
    }
    return this.view;
}