Example usage for com.vaadin.server Page getCurrent

List of usage examples for com.vaadin.server Page getCurrent

Introduction

In this page you can find the example usage for com.vaadin.server Page getCurrent.

Prototype

public static Page getCurrent() 

Source Link

Document

Gets the Page to which the current uI belongs.

Usage

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 w  ww .jav a  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.  com
    } else {
        initUploadButton();
    }

    initComponent();
    attachListener(component);
}

From source file:com.haulmont.cuba.web.gui.WebWindow.java

License:Apache License

@Override
public void setCaption(String caption) {
    this.caption = caption;

    if (component.isAttached()) {
        com.vaadin.ui.Window dialogWindow = asDialogWindow();
        if (dialogWindow != null) {
            dialogWindow.setCaption(caption);
        } else {//from www.  jav a2  s .  c o  m
            TabSheet.Tab tabWindow = asTabWindow();
            if (tabWindow != null) {
                setTabCaptionAndDescription(tabWindow);
                windowManager.getBreadCrumbs((ComponentContainer) tabWindow.getComponent()).update();
            } else {
                Layout singleModeWindow = asSingleWindow();
                if (singleModeWindow != null) {
                    windowManager.getBreadCrumbs(singleModeWindow).update();
                }
            }
        }

    }

    if (getWrapper() instanceof TopLevelWindow) {
        Page.getCurrent().setTitle(caption);
    }
}

From source file:com.haulmont.cuba.web.sys.LinkHandler.java

License:Apache License

protected void substituteUserAndOpenWindow(final WindowInfo windowInfo, UUID userId) {
    UserSession userSession = app.getConnection().getSession();
    final User substitutedUser = loadUser(userId, userSession.getUser());
    if (substitutedUser != null) {
        Map<String, String> currentRequestParams = new HashMap<>(requestParams);

        app.getWindowManager().showOptionDialog(messages.getMainMessage("toSubstitutedUser.title"),
                getDialogMessage(substitutedUser), MessageType.CONFIRMATION_HTML,
                new Action[] { new ChangeSubstUserAction(substitutedUser) {
                    @Override/* w w w  .j  a  va  2  s  . co  m*/
                    public void doAfterChangeUser() {
                        super.doAfterChangeUser();
                        openWindow(windowInfo, currentRequestParams);
                    }

                    @Override
                    public void doRevert() {
                        super.doRevert();

                        JavaScript js = Page.getCurrent().getJavaScript();
                        js.execute("window.close();");
                    }

                    @Override
                    public String getCaption() {
                        return messages.getMainMessage("action.switch");
                    }
                }, new DoNotChangeSubstUserAction() {
                    @Override
                    public void actionPerform(Component component) {
                        super.actionPerform(component);

                        JavaScript js = Page.getCurrent().getJavaScript();
                        js.execute("window.close();");
                    }

                    @Override
                    public String getCaption() {
                        return messages.getMainMessage("action.cancel");
                    }
                } });
    } else {
        User user = loadUser(userId);
        app.getWindowManager().showOptionDialog(messages.getMainMessage("warning.title"),
                getWarningMessage(user), MessageType.WARNING_HTML,
                new Action[] { new DialogAction(DialogAction.Type.OK).withHandler(event -> {
                    JavaScript js = Page.getCurrent().getJavaScript();
                    js.execute("window.close();");
                }) });
    }
}

From source file:com.haulmont.cuba.web.toolkit.ui.CubaImage.java

License:Apache License

@Override
public void attach() {
    super.attach();

    WebBrowser webBrowser = Page.getCurrent().getWebBrowser();
    if (webBrowser.isIE() || webBrowser.isEdge()) {
        CubaImageObjectFitPolyfillExtension.get(getUI());
    }/*from   www .j  ava2  s . co m*/
}

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 {// w  w  w  . j  a v a 2s.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:com.haulmont.cuba.web.toolkit.ui.CubaTable.java

License:Apache License

@Override
public void changeVariables(Object source, Map<String, Object> variables) {
    if (Page.getCurrent().getWebBrowser().isIE() && variables.containsKey("clickEvent")) {
        focus();/*from  ww  w .  j  a  v  a 2s .c om*/
    }

    super.changeVariables(source, variables);

    if (shortcutActionManager != null) {
        shortcutActionManager.handleActions(variables, this);
    }

    String profilerMarker = (String) variables.get("profilerMarker");
    if (StringUtils.isNotEmpty(profilerMarker)) {
        AppUI ui = AppUI.getCurrent();
        ui.setProfilerMarker(profilerMarker);
    }
}

From source file:com.haulmont.cuba.web.toolkit.ui.CubaTreeTable.java

License:Apache License

@Override
public void changeVariables(Object source, Map<String, Object> variables) {

    if (Page.getCurrent().getWebBrowser().isIE() && variables.containsKey("clickEvent")) {
        focus();//from   ww w  .  j a  va2 s .  c o m
    }

    super.changeVariables(source, variables);

    if (shortcutActionManager != null) {
        shortcutActionManager.handleActions(variables, this);
    }
}

From source file:com.haulmont.cuba.web.WebWindowManager.java

License:Apache License

@Override
public void showNotification(String caption, String description, NotificationType type) {
    backgroundWorker.checkUIAccess();/* w  w  w .  ja v a  2s.  c  o m*/

    Notification notification = new Notification(caption, description, convertNotificationType(type));
    notification.setHtmlContentAllowed(NotificationType.isHTML(type));
    setNotificationDelayMsec(notification, type);
    notification.show(Page.getCurrent());
}

From source file:com.haulmont.cuba.web.widgets.CubaFileDownloader.java

License:Apache License

protected boolean isSafariOrIOS() {
    return Page.getCurrent().getWebBrowser().isSafari() || Page.getCurrent().getWebBrowser().isIOS();
}