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.mycollab.module.user.accountsettings.profile.view.AdvancedInfoChangeWindow.java

License:Open Source License

private void changeInfo() {
    user.setWebsite(txtWebsite.getValue());
    user.setCompany(txtCompany.getValue());
    user.setCountry((String) cboCountry.getValue());

    UserService userService = AppContextUtil.getSpringBean(UserService.class);
    userService.updateWithSession(user, UserUIContext.getUsername());
    close();//w  ww.j  a  v  a  2 s . c  o m
    Page.getCurrent().getJavaScript().execute("window.location.reload();");
}

From source file:com.mycollab.module.user.accountsettings.profile.view.BasicInfoChangeWindow.java

License:Open Source License

private void changeUserInfo() {
    txtLastName.removeStyleName("errorField");
    txtEmail.removeStyleName("errorField");

    if (txtLastName.getValue().equals("")) {
        NotificationUtil.showErrorNotification(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL,
                UserUIContext.getMessage(GenericI18Enum.FORM_LASTNAME)));
        txtLastName.addStyleName("errorField");
        return;//from  w ww. ja  v a2s . co  m
    }

    if (txtEmail.getValue().equals("")) {
        NotificationUtil.showErrorNotification(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL,
                UserUIContext.getMessage(GenericI18Enum.FORM_EMAIL)));
        txtLastName.addStyleName("errorField");
        return;
    }

    user.setFirstname(txtFirstName.getValue());
    user.setLastname(txtLastName.getValue());
    user.setEmail(txtEmail.getValue());
    user.setDateofbirth(birthdayField.getDate());
    user.setLanguage(languageBox.getValue());
    user.setTimezone(timeZoneField.getValue());

    final UserService userService = AppContextUtil.getSpringBean(UserService.class);
    userService.updateWithSession(user, UserUIContext.getUsername());
    close();
    Page.getCurrent().getJavaScript().execute("window.location.reload();");
}

From source file:com.mycollab.module.user.accountsettings.profile.view.ContactInfoChangeWindow.java

License:Open Source License

private void changeUserInfo() {
    txtWorkPhone.removeStyleName("errorField");
    txtHomePhone.removeStyleName("errorField");

    user.setWorkphone(txtWorkPhone.getValue());
    user.setHomephone(txtHomePhone.getValue());
    user.setFacebookaccount(txtFaceBook.getValue());
    user.setTwitteraccount(txtTwitter.getValue());
    user.setSkypecontact(txtSkype.getValue());

    if (validateForm(user)) {
        UserService userService = AppContextUtil.getSpringBean(UserService.class);
        userService.updateWithSession(user, UserUIContext.getUsername());
        close();//  w w  w  . ja v a2s  .c  om
        Page.getCurrent().getJavaScript().execute("window.location.reload();");
    }
}

From source file:com.mycollab.module.user.accountsettings.profile.view.ProfileReadViewImpl.java

License:Open Source License

@Override
public void process(BufferedImage image) {
    UserAvatarService userAvatarService = AppContextUtil.getSpringBean(UserAvatarService.class);
    userAvatarService.uploadAvatar(image, UserUIContext.getUsername(), UserUIContext.getUserAvatarId());
    Page.getCurrent().getJavaScript().execute("window.location.reload();");
}

From source file:com.mycollab.module.user.accountsettings.team.view.UserAddPresenter.java

License:Open Source License

private void save(SimpleUser user) {
    boolean isRefreshable = false;
    if (user.getUsername() != null && user.getUsername().equals(UserUIContext.getUsername())) {
        isRefreshable = true;//from  w w w  . j  ava  2  s.com
    }

    UserService userService = AppContextUtil.getSpringBean(UserService.class);
    user.setAccountId(MyCollabUI.getAccountId());
    user.setSubdomain(MyCollabUI.getSubDomain());

    if (user.getStatus() == null) {
        user.setStatus(UserStatusConstants.EMAIL_VERIFIED_REQUEST);
    }

    if (user.getRegisterstatus() == null) {
        user.setRegisterstatus(RegisterStatusConstants.NOT_LOG_IN_YET);
    }

    if (user.getUsername() == null) {
        if (user.getPassword() == null) {
            user.setPassword(RandomPasswordGenerator.generateRandomPassword());
        }
        String userPassword = user.getPassword();
        userService.saveUserAccount(user, user.getRoleid(), MyCollabUI.getSubDomain(),
                MyCollabUI.getAccountId(), UserUIContext.getUsername(), true);
        UI.getCurrent().addWindow(new NewUserAddedWindow(user, userPassword));
    } else {
        userService.updateUserAccount(user, MyCollabUI.getAccountId());
        EventBusFactory.getInstance().post(new UserEvent.GotoList(this, null));
    }

    if (isRefreshable) {
        Page.getCurrent().getJavaScript().execute("window.location.reload();");
    }
}

From source file:com.mycollab.vaadin.AppContext.java

License:Open Source License

/**
 * @param fragment//from  w w w.  j av  a2s  .  co m
 * @param windowTitle
 */
public static void addFragment(String fragment, String windowTitle) {
    Page.getCurrent().setUriFragment(fragment, false);
    Page.getCurrent()
            .setTitle(String.format("%s [%s]", StringUtils.trim(windowTitle, 150), AppContext.getSiteName()));
    googleAnalyticsService.trackPageView(fragment);
}

From source file:com.mycollab.vaadin.MyCollabUI.java

License:Open Source License

/**
 * @param fragment//w w  w. j a va  2s  .  co m
 * @param windowTitle
 */
public static void addFragment(String fragment, String windowTitle) {
    Page.getCurrent().setUriFragment(fragment, false);
    Page.getCurrent().setTitle(String.format("%s [%s]", StringUtils.trim(windowTitle, 150), getSiteName()));
}

From source file:com.mycollab.vaadin.MyCollabUI.java

License:Open Source License

public static boolean isTablet() {
    try {/*from   w ww  .  ja v  a2  s . c  o  m*/
        WebBrowser webBrowser = Page.getCurrent().getWebBrowser();
        return webBrowser.isIPad();
    } catch (Exception e) {
        return false;
    }
}

From source file:com.mycollab.vaadin.ui.NotificationUtil.java

License:Open Source License

public static void showNotification(String caption, String description, Type type) {
    Notification notification = new Notification(caption, description, type);
    notification.setHtmlContentAllowed(true);
    notification.setDelayMsec(3000);//from  www.jav a 2 s.c om

    if (Page.getCurrent() != null) {
        notification.show(Page.getCurrent());
    } else {
        LOG.error("Current page is null");
    }

}

From source file:com.mycollab.vaadin.ui.ThemeManager.java

License:Open Source License

public static void loadMobileTheme(int sAccountId) {
    AccountThemeService themeService = AppContextUtil.getSpringBean(AccountThemeService.class);
    AccountTheme accountTheme = themeService.findTheme(sAccountId);

    if (accountTheme == null) {
        accountTheme = themeService.findDefaultTheme(MyCollabUI.getAccountId());
        if (accountTheme == null) {
            throw new UserInvalidInputException(
                    UserUIContext.getMessage(ShellI18nEnum.ERROR_CAN_NOT_LOAD_THEME));
        }//from w  w w  .  j a v  a 2s  . c  om
    }

    StringBuilder extraStyles = new StringBuilder();

    extraStyles.append(
            ".v-touchkit-navbar-caption { width: " + (UIUtils.getBrowserWidth() - 144) + "px !important; }");
    extraStyles.append(".v-touchkit-navbar-caption span { width: " + (UIUtils.getBrowserWidth() - 144)
            + "px !important; }");

    if (accountTheme.getVtabsheetbg() != null) {
        extraStyles.append(".section { background-color: #" + accountTheme.getVtabsheetbg() + "; }");
        extraStyles.append(
                ".v-navbar-quickmenu-content { background-color: #" + accountTheme.getVtabsheetbg() + "; }");
        extraStyles.append(
                ".slidemenu .v-window-contents { background-color: #" + accountTheme.getVtabsheetbg() + "; }");
        extraStyles.append(".project-dashboard .project-info-layout { background-color: #"
                + accountTheme.getVtabsheetbg() + "; }");
    }

    if (accountTheme.getVtabsheettext() != null) {
        extraStyles.append(".project-dashboard .project-info-layout .v-icon { color: #"
                + accountTheme.getVtabsheettext() + "; }");
        extraStyles.append(".project-dashboard .project-info-layout .project-name { color: #"
                + accountTheme.getVtabsheettext() + "; }");
        extraStyles.append(".project-dashboard .project-info-layout .meta-info { color: "
                + ColorUtils.darkerColor("#" + accountTheme.getVtabsheettext()) + "; }");
        extraStyles.append(
                ".v-navbar-quickmenu-content .v-button { color: #" + accountTheme.getVtabsheettext() + "; }");
        extraStyles.append(".slidemenu .v-window-contents .v-button { color: #"
                + accountTheme.getVtabsheettext() + " !important; }");
        extraStyles.append(".section { color: #" + accountTheme.getVtabsheettext() + "; }");
        extraStyles.append(".section .v-touchkit-navbutton { color: #" + accountTheme.getVtabsheettext()
                + " !important; }");
        extraStyles.append(".section .v-touchkit-navbutton::after { color: #" + accountTheme.getVtabsheettext()
                + " !important; }");
        extraStyles.append(".slidemenu .v-window-contents .menulabel { color: "
                + ColorUtils.brighterColor("#" + accountTheme.getVtabsheettext()) + "; }");
    }

    /* Action Buttons */

    if (accountTheme.getActionbtn() != null) {
        extraStyles.append(".v-touchkit-tabbar-toolbar .v-button.selected { background-color: #"
                + accountTheme.getActionbtn() + " !important; }");

        extraStyles.append(".v-button.v-button-action-btn, .v-button-action-btn:focus { background-color: #"
                + accountTheme.getActionbtn() + "; }");
    }

    if (accountTheme.getActionbtntext() != null) {
        extraStyles.append(".v-touchkit-tabbar-toolbar .v-button.selected { color: #"
                + accountTheme.getActionbtntext() + "; }");

        extraStyles.append(".v-button.v-button-action-btn, .v-button-action-btn:focus { color: #"
                + accountTheme.getActionbtntext() + "; }");
    }

    /* Option Buttons */

    if (accountTheme.getOptionbtn() != null) {
        extraStyles.append(".v-touchkit-tabbar-toolbar .v-button { background-color: #"
                + accountTheme.getOptionbtn() + " !important; }");

        extraStyles.append(".v-button.v-button-option-btn, .v-button-option-btn:focus { background-color: #"
                + accountTheme.getOptionbtn() + "; }");
    }

    if (accountTheme.getOptionbtntext() != null) {
        extraStyles.append(".v-touchkit-tabbar-toolbar .v-button { color: #" + accountTheme.getOptionbtntext()
                + " !important; }");

        extraStyles.append(".v-button.v-button-option-btn, .v-button-option-btn:focus { color: #"
                + accountTheme.getOptionbtntext() + "; }");
    }

    /* Danger Buttons */

    if (accountTheme.getDangerbtn() != null) {

    }

    if (accountTheme.getDangerbtntext() != null) {

    }

    if (extraStyles.length() > 0) {
        Page.getCurrent().getStyles().add(extraStyles.toString());
    }
}