Example usage for com.vaadin.ui Alignment MIDDLE_RIGHT

List of usage examples for com.vaadin.ui Alignment MIDDLE_RIGHT

Introduction

In this page you can find the example usage for com.vaadin.ui Alignment MIDDLE_RIGHT.

Prototype

Alignment MIDDLE_RIGHT

To view the source code for com.vaadin.ui Alignment MIDDLE_RIGHT.

Click Source Link

Usage

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

License:Open Source License

private void initUI() {
    final MVerticalLayout mainLayout = new MVerticalLayout().withFullWidth();

    final Label lbInstruct1 = new Label(UserUIContext.getMessage(UserI18nEnum.MSG_PASSWORD_INSTRUCT_LABEL_1));
    mainLayout.addComponent(lbInstruct1);
    mainLayout.setComponentAlignment(lbInstruct1, Alignment.MIDDLE_LEFT);

    final Label lbInstruct2 = new Label(UserUIContext.getMessage(UserI18nEnum.MSG_PASSWORD_INSTRUCT_LABEL_2));
    mainLayout.addComponent(lbInstruct2);
    mainLayout.setComponentAlignment(lbInstruct2, Alignment.MIDDLE_LEFT);

    GridFormLayoutHelper passInfo = GridFormLayoutHelper.defaultFormLayoutHelper(1, 3);

    txtNewPassword = new PasswordField();
    passInfo.addComponent(txtNewPassword, UserUIContext.getMessage(ShellI18nEnum.OPT_NEW_PASSWORD), 0, 0);

    txtConfirmPassword = new PasswordField();
    passInfo.addComponent(txtConfirmPassword, UserUIContext.getMessage(ShellI18nEnum.OPT_CONFIRMED_PASSWORD), 0,
            1);/*from  ww  w .  j  av  a2  s  .  co  m*/

    mainLayout.addComponent(passInfo.getLayout());
    mainLayout.setComponentAlignment(passInfo.getLayout(), Alignment.MIDDLE_CENTER);

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION);

    MButton saveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE),
            clickEvent -> changePassword()).withIcon(FontAwesome.SAVE).withStyleName(WebThemes.BUTTON_ACTION)
                    .withClickShortcut(ShortcutAction.KeyCode.ENTER);

    MHorizontalLayout hlayoutControls = new MHorizontalLayout(cancelBtn, saveBtn)
            .withMargin(new MarginInfo(false, true, false, true));
    mainLayout.with(hlayoutControls).withAlign(hlayoutControls, Alignment.MIDDLE_RIGHT);

    this.setContent(mainLayout);
}

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

License:Open Source License

private void displayInfo(SimpleUser user) {
    Div infoDiv = new Div().appendText(
            "You have not setup SMTP account properly. So we can not send the invitation by email automatically. Please copy/paste below paragraph and inform to the user by yourself")
            .setStyle("font-weight:bold;color:red");
    Label infoLbl = new Label(infoDiv.write(), ContentMode.HTML);

    Div userInfoDiv = new Div().appendText("Your username is ")
            .appendChild(new B().appendText(user.getEmail()));
    Label userInfoLbl = ELabel.html(userInfoDiv.write());

    if (Boolean.TRUE.equals(user.getIsAccountOwner())) {
        user.setRoleName(UserUIContext.getMessage(RoleI18nEnum.OPT_ACCOUNT_OWNER));
    }/*from w w  w . ja  v a  2 s .  c om*/
    Div roleInfoDiv = new Div().appendText("Your role is ").appendChild(new B().appendText(user.getRoleName()));
    Label roleInfoLbl = new Label(roleInfoDiv.write(), ContentMode.HTML);
    contentLayout.with(infoLbl, userInfoLbl, roleInfoLbl);

    final Button addNewBtn = new Button("Create another user", clickEvent -> {
        EventBusFactory.getInstance().post(new UserEvent.GotoAdd(GetStartedInstructionWindow.this, null));
        close();
    });
    addNewBtn.setStyleName(WebThemes.BUTTON_ACTION);

    Button doneBtn = new Button(UserUIContext.getMessage(GenericI18Enum.ACTION_DONE), clickEvent -> close());
    doneBtn.setStyleName(WebThemes.BUTTON_ACTION);

    final MHorizontalLayout controlsBtn = new MHorizontalLayout(addNewBtn, doneBtn).withMargin(true);
    contentLayout.with(controlsBtn).withAlign(controlsBtn, Alignment.MIDDLE_RIGHT);
}

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

License:Open Source License

public NewUserAddedWindow(final SimpleUser user, String uncryptPassword) {
    super(UserUIContext.getMessage(UserI18nEnum.NEW));
    MVerticalLayout content = new MVerticalLayout();
    this.withModal(true).withResizable(false).withClosable(false).withCenter().withWidth("600px")
            .withContent(content);/*from  w  w  w  . j av a 2s .c  om*/

    ELabel infoLbl = ELabel.html(FontAwesome.CHECK_CIRCLE.getHtml()
            + UserUIContext.getMessage(UserI18nEnum.OPT_NEW_USER_CREATED, user.getDisplayName()));
    content.with(infoLbl);

    String signinInstruction = UserUIContext.getMessage(UserI18nEnum.OPT_SIGN_IN_MSG, MyCollabUI.getSiteUrl(),
            MyCollabUI.getSiteUrl());
    content.with(new MVerticalLayout(new Label(signinInstruction, ContentMode.HTML),
            new ELabel(UserUIContext.getMessage(GenericI18Enum.FORM_EMAIL))
                    .withStyleName(UIConstants.META_INFO),
            new Label("    " + user.getUsername()),
            new ELabel(UserUIContext.getMessage(ShellI18nEnum.FORM_PASSWORD))
                    .withStyleName(UIConstants.META_INFO),
            new Label("    " + (uncryptPassword != null ? uncryptPassword
                    : UserUIContext.getMessage(UserI18nEnum.OPT_USER_SET_OWN_PASSWORD)))));

    content.with(new ELabel(UserUIContext.getMessage(GenericI18Enum.HELP_SPAM_FILTER_PREVENT_MESSAGE))
            .withStyleName(UIConstants.META_INFO));

    Button createMoreUserBtn = new Button(UserUIContext.getMessage(UserI18nEnum.OPT_CREATE_ANOTHER_USER),
            clickEvent -> {
                EventBusFactory.getInstance().post(new UserEvent.GotoAdd(this, null));
                close();
            });
    createMoreUserBtn.addStyleName(WebThemes.BUTTON_LINK);

    Button doneBtn = new Button(UserUIContext.getMessage(GenericI18Enum.ACTION_DONE), clickEvent -> {
        EventBusFactory.getInstance().post(new UserEvent.GotoList(this, null));
        close();
    });
    doneBtn.addStyleName(WebThemes.BUTTON_ACTION);
    MHorizontalLayout buttonControls = new MHorizontalLayout(createMoreUserBtn, doneBtn).withFullWidth()
            .withAlign(createMoreUserBtn, Alignment.MIDDLE_LEFT).withAlign(doneBtn, Alignment.MIDDLE_RIGHT);
    content.with(buttonControls);
}

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

License:Open Source License

private Component generateMemberBlock(final SimpleUser member) {
    VerticalLayout blockContent = new VerticalLayout();
    blockContent.setWidth("350px");
    blockContent.setStyleName("member-block");
    if (RegisterStatusConstants.NOT_LOG_IN_YET.equals(member.getRegisterstatus())) {
        blockContent.addStyleName("inactive");
    }//  ww  w. ja v  a 2 s  .  co  m
    MHorizontalLayout blockTop = new MHorizontalLayout().withFullWidth();
    Image memberAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(member.getAvatarid(), 100);
    memberAvatar.addStyleName(UIConstants.CIRCLE_BOX);
    blockTop.addComponent(memberAvatar);

    MVerticalLayout memberInfo = new MVerticalLayout().withMargin(false);

    MHorizontalLayout buttonControls = new MHorizontalLayout();
    buttonControls.setDefaultComponentAlignment(Alignment.TOP_RIGHT);
    buttonControls.setVisible(UserUIContext.canWrite(RolePermissionCollections.ACCOUNT_USER));

    if (RegisterStatusConstants.NOT_LOG_IN_YET.equals(member.getRegisterstatus())) {
        MButton resendBtn = new MButton(UserUIContext.getMessage(UserI18nEnum.ACTION_RESEND_INVITATION),
                clickEvent -> {
                    SendUserInvitationEvent invitationEvent = new SendUserInvitationEvent(member.getUsername(),
                            null, member.getInviteUser(), MyCollabUI.getSubDomain(), MyCollabUI.getAccountId());
                    AsyncEventBus asyncEventBus = AppContextUtil.getSpringBean(AsyncEventBus.class);
                    asyncEventBus.post(invitationEvent);
                    NotificationUtil.showNotification(UserUIContext.getMessage(GenericI18Enum.OPT_SUCCESS),
                            UserUIContext.getMessage(UserI18nEnum.OPT_SEND_INVITATION_SUCCESSFULLY,
                                    member.getDisplayName()));
                }).withStyleName(WebThemes.BUTTON_LINK);
        buttonControls.with(resendBtn);
    }

    MButton editBtn = new MButton("",
            clickEvent -> EventBusFactory.getInstance()
                    .post(new UserEvent.GotoEdit(UserListViewImpl.this, member))).withIcon(FontAwesome.EDIT)
                            .withStyleName(WebThemes.BUTTON_LINK);
    buttonControls.with(editBtn);

    MButton deleteBtn = new MButton("",
            clickEvent -> ConfirmDialogExt.show(UI.getCurrent(),
                    UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, MyCollabUI.getSiteName()),
                    UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                    UserUIContext.getMessage(GenericI18Enum.BUTTON_YES),
                    UserUIContext.getMessage(GenericI18Enum.BUTTON_NO), confirmDialog -> {
                        if (confirmDialog.isConfirmed()) {
                            UserService userService = AppContextUtil.getSpringBean(UserService.class);
                            userService.pendingUserAccounts(Collections.singletonList(member.getUsername()),
                                    MyCollabUI.getAccountId());
                            EventBusFactory.getInstance()
                                    .post(new UserEvent.GotoList(UserListViewImpl.this, null));
                        }
                    })).withIcon(FontAwesome.TRASH_O).withStyleName(WebThemes.BUTTON_LINK);
    buttonControls.with(deleteBtn);

    memberInfo.addComponent(buttonControls);
    memberInfo.setComponentAlignment(buttonControls, Alignment.MIDDLE_RIGHT);

    A memberLink = new A(
            AccountLinkGenerator.generatePreviewFullUserLink(MyCollabUI.getSiteUrl(), member.getUsername()))
                    .appendText(member.getDisplayName());
    ELabel memberLinkLbl = ELabel.h3(memberLink.write()).withStyleName(UIConstants.TEXT_ELLIPSIS);
    memberInfo.addComponent(memberLinkLbl);
    memberInfo.addComponent(ELabel.hr());

    if (member.getRoleid() != null) {
        String memberRoleLinkPrefix = String.format("<a href=\"%s\"",
                AccountLinkBuilder.generatePreviewFullRoleLink(member.getRoleid()));
        ELabel memberRole = new ELabel(ContentMode.HTML).withStyleName(UIConstants.TEXT_ELLIPSIS);
        if (Boolean.TRUE.equals(member.getIsAccountOwner())) {
            memberRole.setValue(String.format("%sstyle=\"color: #B00000;\">%s</a>", memberRoleLinkPrefix,
                    UserUIContext.getMessage(RoleI18nEnum.OPT_ACCOUNT_OWNER)));
        } else {
            memberRole.setValue(String.format("%sstyle=\"color:gray;font-size:12px;\">%s</a>",
                    memberRoleLinkPrefix, member.getRoleName()));
        }
        memberInfo.addComponent(memberRole);
    } else if (Boolean.TRUE.equals(member.getIsAccountOwner())) {
        Label memberRole = new Label(String.format("<a style=\"color: #B00000;\">%s</a>",
                UserUIContext.getMessage(RoleI18nEnum.OPT_ACCOUNT_OWNER)), ContentMode.HTML);
        memberInfo.addComponent(memberRole);
    } else {
        Label lbl = new Label();
        lbl.setHeight("10px");
        memberInfo.addComponent(lbl);
    }

    if (Boolean.TRUE.equals(MyCollabUI.showEmailPublicly())) {
        Label memberEmailLabel = ELabel
                .html(String.format("<a href='mailto:%s'>%s</a>", member.getUsername(), member.getUsername()))
                .withStyleName(UIConstants.TEXT_ELLIPSIS, UIConstants.META_INFO).withFullWidth();
        memberInfo.addComponent(memberEmailLabel);
    }

    ELabel memberSinceLabel = ELabel
            .html(UserUIContext.getMessage(UserI18nEnum.OPT_MEMBER_SINCE,
                    UserUIContext.formatPrettyTime(member.getRegisteredtime())))
            .withDescription(UserUIContext.formatDateTime(member.getRegisteredtime())).withFullWidth();
    memberInfo.addComponent(memberSinceLabel);

    ELabel lastAccessTimeLbl = ELabel
            .html(UserUIContext.getMessage(UserI18nEnum.OPT_MEMBER_LOGGED_IN,
                    UserUIContext.formatPrettyTime(member.getLastaccessedtime())))
            .withDescription(UserUIContext.formatDateTime(member.getLastaccessedtime()));
    memberInfo.addComponent(lastAccessTimeLbl);
    blockTop.with(memberInfo).expand(memberInfo);
    blockContent.addComponent(blockTop);
    return blockContent;
}

From source file:com.mycollab.shell.view.components.AdRequestWindow.java

License:Open Source License

public AdRequestWindow(final SimpleUser user) {
    super("Need help!");
    this.setModal(true);
    this.setResizable(false);
    this.setWidth("600px");

    MVerticalLayout content = new MVerticalLayout();

    Label message = new Label("Hey <b>" + AppContext.getUser().getDisplayName() + "</b>, you've been "
            + "using MyCollab for a while now. And we hope you are happy with it. We spent countless hours and money developing this free "
            + "software for you. If you like it, please write a few words on twitter, blog or our "
            + "testimonial form. It will help other "
            + "people find this useful software quickly. <b> Thank you</b>", ContentMode.HTML);

    MVerticalLayout shareControls = new MVerticalLayout();
    Label rateSourceforge = new Label(
            new Div().appendChild(new Text(FontAwesome.THUMBS_O_UP.getHtml()), DivLessFormatter.EMPTY_SPACE(),
                    new A("http://sourceforge.net/projects/mycollab/reviews/new", "_blank")
                            .appendText("Rate us on Sourceforge"))
                    .setStyle("color:#006dac").write(),
            ContentMode.HTML);/*from   w ww .  j  a va  2 s.c o  m*/

    Label tweetUs = new Label(new Div().appendChild(new Text(FontAwesome.TWITTER.getHtml()),
            DivLessFormatter.EMPTY_SPACE(),
            new A("https://twitter.com/intent/tweet?text=Im using MyCollab to manage all project activities, accounts and it works great @mycollabdotcom&source=webclient",
                    "_blank").appendText("Share on Twitter"))
            .setStyle("color:#006dac").write(), ContentMode.HTML);

    Label linkedIn = new Label(new Div().appendChild(new Text(FontAwesome.LINKEDIN_SQUARE.getHtml()),
            DivLessFormatter.EMPTY_SPACE(),
            new A("https://www.linkedin.com/cws/share?url=https%3A%2F%2Fwww.mycollab.com&original_referer=https%3A%2F%2Fwww.mycollab.com&token=&isFramed=false&lang=en_US",
                    "_blank").appendText("Share on LinkedIn"))
            .setStyle("color:#006dac").write(), ContentMode.HTML);

    MButton testimonialBtn = new MButton("Write a testimonial", clickEvent -> {
        close();
        turnOffAdd(user);
        UI.getCurrent().addWindow(new TestimonialWindow());
    }).withIcon(FontAwesome.KEYBOARD_O).withStyleName(UIConstants.BUTTON_LINK);

    shareControls.with(rateSourceforge, tweetUs, linkedIn, testimonialBtn);

    MButton ignoreBtn = new MButton("No, thanks", clickEvent -> {
        close();
        turnOffAdd(user);
    }).withStyleName(UIConstants.BUTTON_OPTION);

    MButton loveBtn = new MButton("I did", clickEvent -> {
        close();
        NotificationUtil.showNotification("We appreciate your kindness action", "Thank you for your time");
        turnOffAdd(user);
    }).withIcon(FontAwesome.HEART).withStyleName(UIConstants.BUTTON_ACTION);

    MHorizontalLayout btnControls = new MHorizontalLayout(ignoreBtn, loveBtn);
    content.with(message, shareControls, btnControls).withAlign(btnControls, Alignment.MIDDLE_RIGHT);
    this.setContent(content);
}

From source file:com.mycollab.shell.view.components.UpgradeConfirmWindow.java

License:Open Source License

public UpgradeConfirmWindow(final String version, String manualDownloadLink, final String installerFilePath) {
    super(UserUIContext.getMessage(ShellI18nEnum.OPT_NEW_UPGRADE_IS_READY));
    this.withModal(true).withResizable(false).withCenter().withWidth("600px");
    this.installerFilePath = installerFilePath;

    currentUI = UI.getCurrent();/*from   ww w . ja  va 2s. co  m*/

    MVerticalLayout content = new MVerticalLayout();
    this.setContent(content);

    Div titleDiv = new Div().appendText(UserUIContext.getMessage(ShellI18nEnum.OPT_REQUEST_UPGRADE, version))
            .setStyle("font-weight:bold");
    content.with(ELabel.html(titleDiv.write()));

    Div manualInstallLink = new Div()
            .appendText("&nbsp;&nbsp;&nbsp;&nbsp;" + UserUIContext.getMessage(ShellI18nEnum.OPT_MANUAL_INSTALL)
                    + ": ")
            .appendChild(new A(manualDownloadLink, "_blank")
                    .appendText(UserUIContext.getMessage(ShellI18nEnum.OPT_DOWNLOAD_LINK)));
    content.with(ELabel.html(manualInstallLink.write()));

    Div manualUpgradeHowtoLink = new Div()
            .appendText("&nbsp;&nbsp;&nbsp;&nbsp;" + UserUIContext.getMessage(ShellI18nEnum.OPT_MANUAL_UPGRADE)
                    + ": ")
            .appendChild(new A(
                    "https://community.mycollab.com/docs/hosting-mycollab-on-your-own-server/upgrade-mycollab-automatically/",
                    "_blank").appendText("Link"));
    content.with(new Label(manualUpgradeHowtoLink.write(), ContentMode.HTML));

    Div releaseNoteLink = new Div()
            .appendText("&nbsp;&nbsp;&nbsp;&nbsp;" + UserUIContext.getMessage(ShellI18nEnum.OPT_RELEASE_NOTES)
                    + ": ")
            .appendChild(
                    new A("https://community.mycollab.com/docs/hosting-mycollab-on-your-own-server/releases/",
                            "_blank").appendText("Link"));
    content.with(new Label(releaseNoteLink.write(), ContentMode.HTML));

    MButton skipBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.ACTION_SKIP), clickEvent -> close())
            .withStyleName(WebThemes.BUTTON_OPTION);

    MButton autoUpgradeBtn = new MButton(UserUIContext.getMessage(ShellI18nEnum.ACTION_AUTO_UPGRADE),
            clickEvent -> {
                close();
                navigateToWaitingUpgradePage();
            }).withStyleName(WebThemes.BUTTON_ACTION);
    if (installerFilePath == null) {
        autoUpgradeBtn.setEnabled(false);
    }

    MHorizontalLayout buttonControls = new MHorizontalLayout(skipBtn, autoUpgradeBtn).withMargin(true);
    content.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT);
}

From source file:com.mycollab.shell.view.SetupNewInstanceView.java

License:Open Source License

SetupNewInstanceView() {
    this.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    MHorizontalLayout content = new MHorizontalLayout().withFullHeight();
    this.with(content);
    content.with(new MHorizontalLayout(
            ELabel.html(UserUIContext.getMessage(ShellI18nEnum.OPT_SUPPORTED_LANGUAGES_INTRO))
                    .withStyleName(WebThemes.META_COLOR)).withMargin(true).withWidth("400px")
                            .withStyleName("separator"));
    MVerticalLayout formLayout = new MVerticalLayout().withWidth("600px");
    content.with(formLayout).withAlign(formLayout, Alignment.TOP_LEFT);
    formLayout.with(ELabel.h2("Last step, you are almost there!").withWidthUndefined());
    formLayout.with(ELabel.h3("All fields are required *").withStyleName("overdue").withWidthUndefined());

    GridFormLayoutHelper formLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(2, 8, "200px");
    formLayoutHelper.getLayout().setWidth("600px");
    final TextField adminField = formLayoutHelper.addComponent(new TextField(), "Admin email", 0, 0);
    final PasswordField passwordField = formLayoutHelper.addComponent(new PasswordField(), "Admin password", 0,
            1);/*  ww  w.  j  a  va 2s . c o  m*/
    final PasswordField retypePasswordField = formLayoutHelper.addComponent(new PasswordField(),
            "Retype Admin password", 0, 2);
    final DateFormatField dateFormatField = formLayoutHelper.addComponent(
            new DateFormatField(SimpleBillingAccount.DEFAULT_DATE_FORMAT),
            UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_YYMMDD_FORMAT),
            UserUIContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 3);

    final DateFormatField shortDateFormatField = formLayoutHelper.addComponent(
            new DateFormatField(SimpleBillingAccount.DEFAULT_SHORT_DATE_FORMAT),
            UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_MMDD_FORMAT),
            UserUIContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 4);

    final DateFormatField longDateFormatField = formLayoutHelper.addComponent(
            new DateFormatField(SimpleBillingAccount.DEFAULT_LONG_DATE_FORMAT),
            UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_HUMAN_DATE_FORMAT),
            UserUIContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 5);

    final TimeZoneSelectionField timeZoneSelectionField = formLayoutHelper.addComponent(
            new TimeZoneSelectionField(false), UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_TIMEZONE), 0,
            6);
    timeZoneSelectionField.setValue(TimeZone.getDefault().getID());
    final LanguageSelectionField languageBox = formLayoutHelper.addComponent(new LanguageSelectionField(),
            UserUIContext.getMessage(AdminI18nEnum.FORM_DEFAULT_LANGUAGE), 0, 7);
    languageBox.setValue(Locale.US.toLanguageTag());
    formLayout.with(formLayoutHelper.getLayout());

    CheckBox createSampleDataSelection = new CheckBox("Create sample data", true);

    MButton installBtn = new MButton("Setup", clickEvent -> {
        String adminName = adminField.getValue();
        String password = passwordField.getValue();
        String retypePassword = retypePasswordField.getValue();
        if (!StringUtils.isValidEmail(adminName)) {
            NotificationUtil.showErrorNotification("Invalid email value");
            return;
        }

        if (!password.equals(retypePassword)) {
            NotificationUtil.showErrorNotification("Password is not match");
            return;
        }

        String dateFormat = dateFormatField.getValue();
        String shortDateFormat = shortDateFormatField.getValue();
        String longDateFormat = longDateFormatField.getValue();
        if (!isValidDayPattern(dateFormat) || !isValidDayPattern(shortDateFormat)
                || !isValidDayPattern(longDateFormat)) {
            NotificationUtil.showErrorNotification("Invalid date format");
            return;
        }
        String language = languageBox.getValue();
        String timezoneDbId = timeZoneSelectionField.getValue();
        BillingAccountMapper billingAccountMapper = AppContextUtil.getSpringBean(BillingAccountMapper.class);
        BillingAccountExample ex = new BillingAccountExample();
        ex.createCriteria().andIdEqualTo(MyCollabUI.getAccountId());
        List<BillingAccount> billingAccounts = billingAccountMapper.selectByExample(ex);
        BillingAccount billingAccount = billingAccounts.get(0);
        billingAccount.setDefaultlanguagetag(language);
        billingAccount.setDefaultyymmddformat(dateFormat);
        billingAccount.setDefaultmmddformat(shortDateFormat);
        billingAccount.setDefaulthumandateformat(longDateFormat);
        billingAccount.setDefaulttimezone(timezoneDbId);
        billingAccountMapper.updateByPrimaryKey(billingAccount);

        BillingAccountService billingAccountService = AppContextUtil.getSpringBean(BillingAccountService.class);
        billingAccountService.createDefaultAccountData(adminName, password, timezoneDbId, language, true,
                createSampleDataSelection.getValue(), MyCollabUI.getAccountId());

        ((DesktopApplication) UI.getCurrent()).doLogin(adminName, password, false);
    }).withStyleName(WebThemes.BUTTON_ACTION);

    MHorizontalLayout buttonControls = new MHorizontalLayout(createSampleDataSelection, installBtn)
            .alignAll(Alignment.MIDDLE_RIGHT);
    formLayout.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT);
}

From source file:com.mycollab.vaadin.web.ui.AbstractBeanPagedList.java

License:Open Source License

protected MHorizontalLayout createPageControls() {
    controlBarWrapper = new MHorizontalLayout().withFullWidth()
            .withMargin(new MarginInfo(false, true, false, true)).withStyleName(listControlStyle);

    pageManagement = new MHorizontalLayout();

    // defined layout here ---------------------------

    if (currentPage > 1) {
        MButton firstLink = new MButton("1", clickEvent -> pageChange(1)).withStyleName("buttonPaging");
        pageManagement.addComponent(firstLink);
    }//from  w  w  w  . ja v a 2  s .com
    if (currentPage >= 5) {
        final Label ss1 = new Label("...");
        ss1.addStyleName("buttonPaging");
        pageManagement.addComponent(ss1);
    }
    if (currentPage > 3) {
        MButton previous2 = new MButton("" + (currentPage - 2), clickEvent -> pageChange(currentPage - 2))
                .withStyleName("buttonPaging");
        pageManagement.addComponent(previous2);
    }
    if (currentPage > 2) {
        MButton previous1 = new MButton("" + (currentPage - 1), clickEvent -> pageChange(currentPage - 1))
                .withStyleName("buttonPaging");
        pageManagement.addComponent(previous1);
    }
    // Here add current ButtonLinkLegacy
    MButton current = new MButton("" + currentPage, clickEvent -> pageChange(currentPage))
            .withStyleName("buttonPaging", "current");

    pageManagement.addComponent(current);
    final int range = this.totalPage - currentPage;
    if (range >= 1) {
        MButton next1 = new MButton("" + (currentPage + 1), clickEvent -> pageChange(currentPage + 1))
                .withStyleName("buttonPaging");
        pageManagement.addComponent(next1);
    }
    if (range >= 2) {
        MButton next2 = new MButton("" + (currentPage + 2), clickEvent -> pageChange(currentPage + 2))
                .withStyleName("buttonPaging");
        pageManagement.addComponent(next2);
    }
    if (range >= 4) {
        Label ss2 = new Label("...");
        ss2.addStyleName("buttonPaging");
        pageManagement.addComponent(ss2);
    }
    if (range >= 3) {
        MButton last = new MButton("" + this.totalPage, clickEvent -> pageChange(totalPage))
                .withStyleName("buttonPaging");
        pageManagement.addComponent(last);
    }

    controlBarWrapper.with(pageManagement).withAlign(pageManagement, Alignment.MIDDLE_RIGHT);
    return controlBarWrapper;
}

From source file:com.mycollab.vaadin.web.ui.Depot.java

License:Open Source License

public Depot(String title, ComponentContainer content) {
    this.addStyleName("depotComp");
    header = new MHorizontalLayout().withHeight("40px").withStyleName("depotHeader");
    bodyContent = content;/*  w ww  . ja  va  2 s .c  o  m*/
    bodyContent.setWidth("100%");
    headerContent = new MHorizontalLayout().withFullHeight().withWidthUndefined().withVisible(false);
    this.addComponent(header);

    headerLbl = new Label(title);
    final MHorizontalLayout headerLeft = new MHorizontalLayout(headerLbl).withStyleName("depot-title")
            .withAlign(headerLbl, Alignment.MIDDLE_LEFT).withFullWidth();
    headerLeft.addLayoutClickListener(layoutClickEvent -> {
        isOpened = !isOpened;
        if (isOpened) {
            bodyContent.setVisible(true);
            removeStyleName("collapsed");
            header.removeStyleName("border-bottom");
        } else {
            bodyContent.setVisible(false);
            addStyleName("collapsed");
            header.addStyleName("border-bottom");
        }
    });
    header.with(headerLeft, headerContent).withAlign(headerLeft, Alignment.MIDDLE_LEFT)
            .withAlign(headerContent, Alignment.MIDDLE_RIGHT).expand(headerLeft);

    bodyContent.addStyleName("depotContent");
    this.addComponent(bodyContent);
}

From source file:com.mycollab.vaadin.web.ui.MassUpdateWindow.java

License:Open Source License

protected ComponentContainer buildButtonControls() {
    MHorizontalLayout controlsLayout = new MHorizontalLayout().withMargin(true).withFullWidth();

    updateBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_UPDATE_LABEL), clickEvent -> {
        updateForm.commit();/*from   www .  java 2s.  c  o m*/
        massUpdateCommand.massUpdate(beanItem);
        close();
    }).withStyleName(WebThemes.BUTTON_ACTION).withIcon(FontAwesome.SAVE);

    closeBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLOSE), clickEvent -> close())
            .withStyleName(WebThemes.BUTTON_OPTION);

    Label spacing = new Label();
    controlsLayout.with(spacing, closeBtn, updateBtn).alignAll(Alignment.MIDDLE_RIGHT).expand(spacing);
    return controlsLayout;
}