Example usage for com.vaadin.ui Alignment MIDDLE_CENTER

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

Introduction

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

Prototype

Alignment MIDDLE_CENTER

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

Click Source Link

Usage

From source file:com.mycollab.module.project.ui.ProjectAssetsUtil.java

License:Open Source License

public static Component buildProjectLogo(String projectShortname, Integer projectId, String projectAvatarId,
        int size) {
    AbstractComponent wrapper;/*from  www  .  ja  v a 2 s .  c  om*/
    if (!StringUtils.isBlank(projectAvatarId)) {
        wrapper = new Image(null,
                new ExternalResource(StorageFactory.getResourcePath(String.format("%s/%s_%d.png",
                        PathUtils.getProjectLogoPath(MyCollabUI.getAccountId(), projectId), projectAvatarId,
                        size))));
    } else {
        ELabel projectIcon = new ELabel(projectShortname).withStyleName(UIConstants.TEXT_ELLIPSIS,
                ValoTheme.LABEL_LARGE, "center");
        wrapper = new VerticalLayout();
        ((VerticalLayout) wrapper).addComponent(projectIcon);
        ((VerticalLayout) wrapper).setComponentAlignment(projectIcon, Alignment.MIDDLE_CENTER);
    }
    wrapper.setWidth(size, Sizeable.Unit.PIXELS);
    wrapper.setHeight(size, Sizeable.Unit.PIXELS);
    wrapper.addStyleName(UIConstants.CIRCLE_BOX);
    wrapper.setDescription(UserUIContext.getMessage(ProjectI18nEnum.OPT_CHANGE_LOGO_HELP,
            UserUIContext.getMessage(ProjectI18nEnum.EDIT)));
    return wrapper;
}

From source file:com.mycollab.module.project.ui.ProjectAssetsUtil.java

License:Open Source License

public static Component buildClientLogo(SimpleAccount account, int size) {
    AbstractComponent wrapper;/*from  ww w  .  ja v  a  2 s .c o m*/
    if (!StringUtils.isBlank(account.getAvatarid())) {
        wrapper = new Image(null, new ExternalResource(
                StorageFactory.getEntityLogoPath(MyCollabUI.getAccountId(), account.getAvatarid(), 100)));
    } else {
        String accountName = account.getAccountname();
        accountName = (accountName.length() > 3) ? accountName.substring(0, 3) : accountName;
        ELabel projectIcon = new ELabel(accountName).withStyleName(UIConstants.TEXT_ELLIPSIS, "center");
        wrapper = new VerticalLayout();
        ((VerticalLayout) wrapper).addComponent(projectIcon);
        ((VerticalLayout) wrapper).setComponentAlignment(projectIcon, Alignment.MIDDLE_CENTER);
    }
    wrapper.setWidth(size, Sizeable.Unit.PIXELS);
    wrapper.setHeight(size, Sizeable.Unit.PIXELS);
    wrapper.addStyleName(UIConstants.CIRCLE_BOX);
    wrapper.setDescription(UserUIContext.getMessage(ClientI18nEnum.OPT_CHANGE_LOGO_HELP,
            UserUIContext.getMessage(ClientI18nEnum.EDIT)));
    return wrapper;
}

From source file:com.mycollab.module.project.view.milestone.MilestoneListViewImpl.java

License:Open Source License

private void constructBody() {
    CustomLayout bodyContent = CustomLayoutExt.createLayout("milestoneView");
    bodyContent.setWidth("100%");
    bodyContent.setStyleName("milestone-view");

    MHorizontalLayout closedHeaderLayout = new MHorizontalLayout();

    closedHeader = ELabel.html("").withWidthUndefined();
    closedHeaderLayout.with(closedHeader).withAlign(closedHeader, Alignment.MIDDLE_CENTER);

    bodyContent.addComponent(closedHeaderLayout, "closed-header");
    closeContainer = new MVerticalLayout().withStyleName("milestone-col").withFullWidth();
    bodyContent.addComponent(closeContainer, "closed-milestones");

    MHorizontalLayout inProgressHeaderLayout = new MHorizontalLayout();
    inProgressHeader = ELabel.html("").withWidthUndefined();
    inProgressHeaderLayout.addComponent(inProgressHeader);
    inProgressHeaderLayout.setComponentAlignment(inProgressHeader, Alignment.MIDDLE_CENTER);

    bodyContent.addComponent(inProgressHeaderLayout, "in-progress-header");
    inProgressContainer = new MVerticalLayout().withStyleName("milestone-col").withFullWidth();
    bodyContent.addComponent(this.inProgressContainer, "in-progress-milestones");

    MHorizontalLayout futureHeaderLayout = new MHorizontalLayout();
    futureHeader = ELabel.html("").withWidthUndefined();
    futureHeaderLayout.addComponent(futureHeader);
    futureHeaderLayout.setComponentAlignment(futureHeader, Alignment.MIDDLE_CENTER);

    bodyContent.addComponent(futureHeaderLayout, "future-header");
    futureContainer = new MVerticalLayout().withStyleName("milestone-col").withFullWidth();
    bodyContent.addComponent(this.futureContainer, "future-milestones");

    this.addComponent(bodyContent);
}

From source file:com.mycollab.module.project.view.page.PageListNoItemView.java

License:Open Source License

protected MHorizontalLayout createControlButtons() {
    if (hasPermission()) {
        MButton createPageBtn = new MButton(actionMessage(), actionListener())
                .withStyleName(WebThemes.BUTTON_ACTION);

        MButton createPageGroupBtn = new MButton(UserUIContext.getMessage(PageI18nEnum.NEW_GROUP),
                clickEvent -> {/*w  w  w.  j a v a 2 s  .  c  o  m*/
                    UI.getCurrent().addWindow(new GroupPageAddWindow());
                }).withStyleName(WebThemes.BUTTON_ACTION);

        return new MHorizontalLayout(createPageBtn, new Label(" or "), createPageGroupBtn)
                .alignAll(Alignment.MIDDLE_CENTER);
    } else {
        return new MHorizontalLayout();
    }
}

From source file:com.mycollab.module.project.view.ProjectListViewImpl.java

License:Open Source License

private ComponentContainer constructTableActionControls() {
    MHorizontalLayout layout = new MHorizontalLayout().withFullWidth();
    layout.addStyleName(WebThemes.TABLE_ACTION_CONTROLS);

    selectOptionButton = new SelectionOptionButton(tableItem);
    selectOptionButton.setWidthUndefined();
    layout.addComponent(selectOptionButton);

    tableActionControls = new DefaultMassItemActionHandlerContainer();

    tableActionControls.addDownloadPdfActionItem();
    tableActionControls.addDownloadExcelActionItem();
    tableActionControls.addDownloadCsvActionItem();

    tableActionControls.setVisible(false);
    tableActionControls.setWidthUndefined();

    layout.addComponent(tableActionControls);
    selectedItemsNumberLabel.setWidth("100%");
    layout.with(selectedItemsNumberLabel).withAlign(selectedItemsNumberLabel, Alignment.MIDDLE_CENTER)
            .expand(selectedItemsNumberLabel);

    MButton customizeViewBtn = new MButton("",
            clickEvent -> UI.getCurrent().addWindow(new ProjectListCustomizeWindow(tableItem)))
                    .withStyleName(WebThemes.BUTTON_ACTION).withIcon(FontAwesome.ADJUST);
    customizeViewBtn.setDescription(UserUIContext.getMessage(GenericI18Enum.OPT_LAYOUT_OPTIONS));
    layout.with(customizeViewBtn).withAlign(customizeViewBtn, Alignment.MIDDLE_RIGHT);

    return layout;
}

From source file:com.mycollab.module.project.view.settings.ComponentListViewImpl.java

License:Open Source License

private ComponentContainer constructTableActionControls() {
    final CssLayout layoutWrapper = new CssLayout();
    layoutWrapper.setWidth("100%");

    MHorizontalLayout layout = new MHorizontalLayout();
    layoutWrapper.addStyleName(WebThemes.TABLE_ACTION_CONTROLS);
    layoutWrapper.addComponent(layout);/*ww  w.j  a v  a  2  s. c om*/

    this.selectOptionButton = new SelectionOptionButton(tableItem);
    layout.addComponent(this.selectOptionButton);

    tableActionControls = new DefaultMassItemActionHandlerContainer();
    if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.COMPONENTS)) {
        tableActionControls.addDeleteActionItem();
    }

    tableActionControls.addMailActionItem();
    tableActionControls.addDownloadPdfActionItem();
    tableActionControls.addDownloadExcelActionItem();
    tableActionControls.addDownloadCsvActionItem();

    layout.with(tableActionControls, selectedItemsNumberLabel).withAlign(selectedItemsNumberLabel,
            Alignment.MIDDLE_CENTER);
    return layoutWrapper;
}

From source file:com.mycollab.module.project.view.settings.VersionListViewImpl.java

License:Open Source License

private ComponentContainer constructTableActionControls() {
    final CssLayout layoutWrapper = new CssLayout();
    layoutWrapper.setWidth("100%");
    MHorizontalLayout layout = new MHorizontalLayout();
    layoutWrapper.addStyleName(WebThemes.TABLE_ACTION_CONTROLS);
    layoutWrapper.addComponent(layout);//from w  ww .  j a  v a 2 s.  c o  m

    this.selectOptionButton = new SelectionOptionButton(this.tableItem);
    layout.addComponent(this.selectOptionButton);

    tableActionControls = new DefaultMassItemActionHandlerContainer();

    if (CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.VERSIONS)) {
        tableActionControls.addDeleteActionItem();
    }

    tableActionControls.addMailActionItem();
    tableActionControls.addDownloadPdfActionItem();
    tableActionControls.addDownloadExcelActionItem();
    tableActionControls.addDownloadCsvActionItem();

    layout.with(tableActionControls, selectedItemsNumberLabel).withAlign(selectedItemsNumberLabel,
            Alignment.MIDDLE_CENTER);
    return layoutWrapper;
}

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 www . j  a v  a2  s.  c  o  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.ui.components.ImagePreviewCropWindow.java

License:Open Source License

public ImagePreviewCropWindow(final ImageSelectionCommand imageSelectionCommand, final byte[] imageData) {
    super(UserUIContext.getMessage(ShellI18nEnum.OPT_PREVIEW_EDIT_IMAGE));
    MVerticalLayout content = new MVerticalLayout();
    withModal(true).withResizable(false).withWidth("700px").withCenter().withContent(content);

    try {/*w w  w .ja  va 2 s .  c  o  m*/
        originalImage = ImageIO.read(new ByteArrayInputStream(imageData));
    } catch (IOException e) {
        throw new UserInvalidInputException("Invalid image type");
    }
    originalImage = ImageUtil.scaleImage(originalImage, 650, 650);

    MHorizontalLayout previewBox = new MHorizontalLayout().withMargin(new MarginInfo(false, true, true, false))
            .withFullWidth();

    previewPhoto = new VerticalLayout();
    previewPhoto.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    previewPhoto.setWidth("100px");

    previewBox.with(previewPhoto).withAlign(previewPhoto, Alignment.TOP_LEFT);

    VerticalLayout previewBoxTitle = new VerticalLayout();
    previewBoxTitle.setMargin(new MarginInfo(false, true, false, true));
    previewBoxTitle
            .addComponent(ELabel.html(UserUIContext.getMessage(ShellI18nEnum.OPT_IMAGE_EDIT_INSTRUCTION)));

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

    MButton acceptBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ACCEPT), clickEvent -> {
        if (scaleImageData != null && scaleImageData.length > 0) {
            try {
                BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData));
                imageSelectionCommand.process(image);
                close();
            } catch (IOException e) {
                throw new MyCollabException("Error when saving user avatar", e);
            }
        }
    }).withIcon(FontAwesome.CHECK).withStyleName(WebThemes.BUTTON_ACTION);

    MHorizontalLayout controlBtns = new MHorizontalLayout(acceptBtn, cancelBtn);

    previewBoxTitle.addComponent(controlBtns);
    previewBoxTitle.setComponentAlignment(controlBtns, Alignment.TOP_LEFT);
    previewBox.with(previewBoxTitle).expand(previewBoxTitle);

    CssLayout cropBox = new CssLayout();
    cropBox.setWidth("100%");
    VerticalLayout currentPhotoBox = new VerticalLayout();
    Resource resource = new ByteArrayImageResource(ImageUtil.convertImageToByteArray(originalImage),
            "image/png");
    CropField cropField = new CropField(resource);
    cropField.setImmediate(true);
    cropField.setSelectionAspectRatio(1.0f);
    cropField.addValueChangeListener(valueChangeEvent -> {
        VCropSelection newSelection = (VCropSelection) valueChangeEvent.getProperty().getValue();
        int x1 = newSelection.getXTopLeft();
        int y1 = newSelection.getYTopLeft();
        int x2 = newSelection.getXBottomRight();
        int y2 = newSelection.getYBottomRight();
        if (x2 > x1 && y2 > y1) {
            BufferedImage subImage = originalImage.getSubimage(x1, y1, (x2 - x1), (y2 - y1));
            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
            try {
                ImageIO.write(subImage, "png", outStream);
                scaleImageData = outStream.toByteArray();
                displayPreviewImage();
            } catch (IOException e) {
                LOG.error("Error while scale image: ", e);
            }
        }
    });
    currentPhotoBox.setWidth("520px");
    currentPhotoBox.setHeight("470px");
    currentPhotoBox.addComponent(cropField);
    cropBox.addComponent(currentPhotoBox);

    content.with(previewBox, ELabel.hr(), cropBox);
    displayPreviewImage();
}

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

License:Open Source License

public NoSubDomainExistedWindow(final String domain) {
    this.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    final Label titleIcon = ELabel.fontIcon(FontAwesome.EXCLAMATION_CIRCLE)
            .withStyleName("warning-icon", ValoTheme.LABEL_NO_MARGIN).withWidthUndefined();

    Label warningMsg = new ELabel(UserUIContext.getMessage(ShellI18nEnum.ERROR_NO_SUB_DOMAIN, domain))
            .withWidthUndefined();/*from w w w. ja v  a 2s .c om*/

    Button backToHome = new Button(UserUIContext.getMessage(ShellI18nEnum.BUTTON_BACK_TO_HOME_PAGE),
            clickEvent -> getUI().getPage().setLocation("https://www.mycollab.com"));
    backToHome.addStyleName(WebThemes.BUTTON_ACTION);
    this.with(titleIcon, warningMsg, backToHome);
}