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

License:Open Source License

private void initUI() {
    final MVerticalLayout mainLayout = new MVerticalLayout().withWidth("100%");

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

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

    final GridFormLayoutHelper passInfo = new GridFormLayoutHelper(1, 3, "300px", "180px");

    txtNewPassword = new PasswordField();
    passInfo.addComponent(txtNewPassword, "New Password", 0, 0);

    txtConfirmPassword = new PasswordField();
    passInfo.addComponent(txtConfirmPassword, "Confirmed New Password", 0, 1);

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

    final MHorizontalLayout hlayoutControls = new MHorizontalLayout().withMargin(true);

    final Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override/*from   www.j  a v a 2 s  . c  o  m*/
                public void buttonClick(final ClickEvent event) {
                    PasswordChangeWindow.this.close();
                }
            });
    cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);

    final Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    PasswordChangeWindow.this.changePassword();
                }
            });
    saveBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    saveBtn.setIcon(FontAwesome.SAVE);

    hlayoutControls.with(saveBtn, cancelBtn).alignAll(Alignment.MIDDLE_CENTER);

    mainLayout.with(hlayoutControls).withAlign(hlayoutControls, Alignment.MIDDLE_RIGHT);

    this.setModal(true);
    this.setContent(mainLayout);
}

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

License:Open Source License

private ComponentContainer constructTableActionControls() {
    final CssLayout layoutWrapper = new CssLayout();
    layoutWrapper.setWidth("100%");
    final HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);//from w  w w.  j  av  a2 s. c om
    layoutWrapper.addStyleName(UIConstants.TABLE_ACTION_CONTROLS);
    layoutWrapper.addComponent(layout);

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

    final Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE));
    deleteBtn.setEnabled(AppContext.canAccess(RolePermissionCollections.ACCOUNT_ROLE));

    this.tableActionControls = new DefaultMassItemActionHandlersContainer();
    if (AppContext.canAccess(RolePermissionCollections.ACCOUNT_ROLE)) {
        tableActionControls.addActionItem(MassItemActionHandler.DELETE_ACTION, FontAwesome.TRASH_O, "delete",
                AppContext.getMessage(GenericI18Enum.BUTTON_DELETE));
    }
    tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_PDF_ACTION, FontAwesome.FILE_PDF_O,
            "export", "export.pdf", AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_PDF));

    tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_EXCEL_ACTION,
            FontAwesome.FILE_EXCEL_O, "export", "export.xlsx",
            AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_EXCEL));

    tableActionControls.addDownloadActionItem(MassItemActionHandler.EXPORT_CSV_ACTION, FontAwesome.FILE_TEXT_O,
            "export", "export.csv", AppContext.getMessage(GenericI18Enum.BUTTON_EXPORT_CSV));

    layout.addComponent(this.tableActionControls);
    layout.addComponent(this.selectedItemsNumberLabel);
    layout.setComponentAlignment(this.selectedItemsNumberLabel, Alignment.MIDDLE_CENTER);
    return layoutWrapper;
}

From source file:com.esofthead.mycollab.module.user.ui.components.ImagePreviewCropWindow.java

License:Open Source License

public ImagePreviewCropWindow(final ImageSelectionCommand imageSelectionCommand, final byte[] imageData) {
    super("Preview and modify image");
    setModal(true);/* w ww. j av a  2 s . co m*/
    setResizable(false);
    setWidth("700px");
    center();

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

    try {
        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().withSpacing(true)
            .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));
    Label lbPreview = new Label("<p style='margin: 0px;'><strong>To the bottom is what your profile photo will "
            + "look like.</strong></p>"
            + "<p style='margin-top: 0px;'>To make adjustment, you can drag around and resize the selection square below. "
            + "When you are happy with your photo, click the &ldquo;Accept&ldquo; button.</p>",
            ContentMode.HTML);
    previewBoxTitle.addComponent(lbPreview);

    MHorizontalLayout controlBtns = new MHorizontalLayout();
    controlBtns.setSizeUndefined();

    Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    close();
                }
            });
    cancelBtn.setStyleName(UIConstants.BUTTON_OPTION);

    Button acceptBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ACCEPT),
            new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    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);
                        }
                    }
                }
            });
    acceptBtn.setStyleName(UIConstants.BUTTON_ACTION);
    acceptBtn.setIcon(FontAwesome.CHECK);

    controlBtns.with(acceptBtn, cancelBtn).alignAll(Alignment.MIDDLE_LEFT);

    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(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            VCropSelection newSelection = (VCropSelection) event.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.esofthead.mycollab.shell.view.components.NoSubDomainExistedWindow.java

License:Open Source License

public NoSubDomainExistedWindow(final String domain) {
    this.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    final Label titleIcon = new ELabel(FontAwesome.EXCLAMATION_CIRCLE.getHtml(), ContentMode.HTML)
            .withWidthUndefined();//from  w  ww  . ja v a2s  .c  o m
    titleIcon.setStyleName("warning-icon");
    titleIcon.addStyleName(ValoTheme.LABEL_NO_MARGIN);

    Label warningMsg = new ELabel(AppContext.getMessage(ShellI18nEnum.ERROR_NO_SUB_DOMAIN, domain))
            .withWidthUndefined();

    Button backToHome = new Button(AppContext.getMessage(ShellI18nEnum.BUTTON_BACK_TO_HOME_PAGE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    getUI().getPage().setLocation("https://www.mycollab.com");
                }
            });
    backToHome.addStyleName(UIConstants.BUTTON_ACTION);
    this.with(titleIcon, warningMsg, backToHome);
}

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

License:Open Source License

public NoSubDomainExistedWindow(final String domain) {
    final NoSubDomainLayout contentLayout = new NoSubDomainLayout(domain);
    contentLayout.setWidth("616px");
    this.addComponent(contentLayout);
    this.setComponentAlignment(contentLayout, Alignment.MIDDLE_CENTER);
}

From source file:com.esofthead.mycollab.ui.chart.PieChartWrapper.java

License:Open Source License

@Override
protected final ComponentContainer createLegendBox() {
    final CssLayout mainLayout = new CssLayout();
    mainLayout.addStyleName("legendBoxContent");
    mainLayout.setSizeUndefined();/*from  w w w  .  j a v a  2s.co m*/
    final List keys = pieDataSet.getKeys();

    for (int i = 0; i < keys.size(); i++) {
        MHorizontalLayout layout = new MHorizontalLayout()
                .withMargin(new MarginInfo(false, false, false, true));
        layout.addStyleName("inline-block");
        layout.setSizeUndefined();
        layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

        final Comparable key = (Comparable) keys.get(i);
        int colorIndex = i % CHART_COLOR_STR.size();
        final String color = "<div style = \" width:13px;height:13px;background: #"
                + CHART_COLOR_STR.get(colorIndex) + "\" />";
        final Label lblCircle = new Label(color);
        lblCircle.setContentMode(ContentMode.HTML);

        String btnCaption;
        if (enumKeyCls == null) {
            if (key instanceof Key) {
                btnCaption = String.format("%s (%d)", StringUtils.trim(((Key) key).getDisplayName(), 20, true),
                        pieDataSet.getValue(key).intValue());
            } else {
                btnCaption = String.format("%s (%d)", key, pieDataSet.getValue(key).intValue());
            }
        } else {
            btnCaption = String.format("%s(%d)", AppContext.getMessage(enumKeyCls, key.toString()),
                    pieDataSet.getValue(key).intValue());
        }
        final Button btnLink = new Button(StringUtils.trim(btnCaption, 25, true), new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final ClickEvent event) {
                if (key instanceof Key) {
                    clickLegendItem(((Key) key).getKey());
                } else {
                    clickLegendItem(key.toString());
                }
            }
        });
        btnLink.setDescription(btnCaption);
        btnLink.addStyleName(UIConstants.BUTTON_LINK);
        layout.with(lblCircle, btnLink);
        mainLayout.addComponent(layout);
    }
    mainLayout.setWidth("100%");
    return mainLayout;
}

From source file:com.esofthead.mycollab.vaadin.mvp.view.NotPresentedView.java

License:Open Source License

public NotPresentedView() {
    this.withSpacing(true).withFullWidth();
    this.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    final Label titleIcon = new Label(FontAwesome.EXCLAMATION_CIRCLE.getHtml(), ContentMode.HTML);
    titleIcon.setStyleName("warning-icon");
    titleIcon.addStyleName(ValoTheme.LABEL_NO_MARGIN);
    titleIcon.setWidthUndefined();/* w w  w.  ja va  2 s.  c o  m*/
    this.with(titleIcon);

    Label label = ELabel.h2(AppContext.getMessage(GenericI18Enum.NOTIFICATION_FEATURE_NOT_AVAILABLE_IN_VERSION))
            .withWidthUndefined();
    this.with(label).withAlign(label, Alignment.MIDDLE_CENTER);

    RestTemplate restTemplate = new RestTemplate();
    try {
        String result = restTemplate.getForObject("https://api.mycollab.com/api/storeweb", String.class);
        Label webPage = new Label(result, ContentMode.HTML);
        webPage.setHeight("480px");
        this.with(new MVerticalLayout(webPage).withMargin(false).withAlign(webPage, Alignment.TOP_CENTER));
    } catch (Exception e) {
        Div informDiv = new Div()
                .appendText("Can not load the store page. You can check the online edition at ")
                .appendChild(new A("https://www.mycollab.com/pricing/download/", "_blank").appendText("here"));
        ELabel webPage = new ELabel(informDiv.write(), ContentMode.HTML).withWidthUndefined();
        this.with(new MVerticalLayout(webPage).withAlign(webPage, Alignment.TOP_CENTER));
    }
}

From source file:com.esofthead.mycollab.vaadin.ui.AttachmentPanel.java

License:Open Source License

private void displayFileName(final String fileName) {
    final MHorizontalLayout fileAttachmentLayout = new MHorizontalLayout();
    Button removeBtn = new Button(null, new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override//from   ww  w.j a va  2  s  .c o  m
        public void buttonClick(ClickEvent event) {
            File file = fileStores.get(fileName);
            if (file != null) {
                file.delete();
            }
            fileStores.remove(fileName);
            AttachmentPanel.this.removeComponent(fileAttachmentLayout);
            if (multiFileUpload != null) {
                multiFileUpload.removeAndReInitMultiUpload();
            }
        }
    });
    removeBtn.setIcon(FontAwesome.TRASH_O);
    removeBtn.setStyleName(UIConstants.BUTTON_ICON_ONLY);

    Label fileIcon = new Label(getFileIconResource(fileName).getHtml(), ContentMode.HTML);
    Label fileLbl = new Label(fileName);
    fileAttachmentLayout.with(fileIcon, fileLbl, removeBtn).withAlign(fileLbl, Alignment.MIDDLE_CENTER);
    this.addComponent(fileAttachmentLayout);
}

From source file:com.esofthead.mycollab.vaadin.ui.BeanList.java

License:Open Source License

public void loadItems(List<T> currentListData) {
    contentLayout.removeAllComponents();

    try {/*w  w w .jav  a2 s . co  m*/
        if (CollectionUtils.isEmpty(currentListData) && isDisplayEmptyListText) {
            Label noItemLbl = new Label(AppContext.getMessage(GenericI18Enum.EXT_NO_ITEM));
            final VerticalLayout widgetFooter = new VerticalLayout();
            widgetFooter.addStyleName("widget-footer");
            widgetFooter.setWidth("100%");
            widgetFooter.addComponent(noItemLbl);
            widgetFooter.setComponentAlignment(noItemLbl, Alignment.MIDDLE_CENTER);
            contentLayout.addComponent(widgetFooter);
        } else {
            int i = 0;
            for (T item : currentListData) {
                RowDisplayHandler<T> rowHandler = constructRowDisplayHandler();

                Component row = rowHandler.generateRow(item, i);
                if (row != null) {
                    row.setWidth("100%");
                    contentLayout.addComponent(row);
                }

                i++;
            }
        }

    } catch (Exception e) {
        LOG.error("Error while generate column display", e);
    }
}

From source file:com.esofthead.mycollab.vaadin.ui.DateRangeField.java

License:Open Source License

@Override
protected Component initContent() {
    MHorizontalLayout container = new MHorizontalLayout();
    container.setSpacing(true);//from  www . j a v a 2 s.  c  om
    Label dateStartLb = new Label("From:");
    Label dateEndLb = new Label("To:");

    container.with(dateStartLb, dateEndLb).withAlign(dateStartLb, Alignment.MIDDLE_CENTER).withAlign(dateEndLb,
            Alignment.MIDDLE_CENTER);

    setDateWidth(120);
    setDefaultValue();

    return container;
}