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.ui.chart.PieChartWrapper.java

License:Open Source License

@Override
protected final ComponentContainer createLegendBox() {
    final CssLayout mainLayout = new CssLayout();
    mainLayout.addStyleName("legendBoxContent");
    mainLayout.setSizeUndefined();//from  ww  w  .  j a v  a2  s .  c o  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))
                .withStyleName("inline-block").withWidthUndefined();
        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 ELabel lblCircle = ELabel.html(color);

        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)", UserUIContext.getMessage(enumKeyCls, key.toString()),
                    pieDataSet.getValue(key).intValue());
        }
        MButton btnLink = new MButton(StringUtils.trim(btnCaption, 25, true), clickEvent -> {
            if (key instanceof Key) {
                clickLegendItem(((Key) key).getKey());
            } else {
                clickLegendItem(key.toString());
            }
        }).withStyleName(WebThemes.BUTTON_LINK).withDescription(btnCaption);

        layout.with(lblCircle, btnLink);
        mainLayout.addComponent(layout);
    }
    mainLayout.setWidth("100%");
    return mainLayout;
}

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

License:Open Source License

public NotPresentedView() {
    MVerticalLayout bodyLayout = new MVerticalLayout().withMargin(false);
    setContent(bodyLayout);/*w ww  .  j  av  a2s  .c o  m*/
    bodyLayout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    final ELabel titleIcon = ELabel.fontIcon(FontAwesome.EXCLAMATION_CIRCLE).withStyleName("warning-icon",
            ValoTheme.LABEL_NO_MARGIN);
    titleIcon.setWidthUndefined();
    bodyLayout.with(titleIcon);

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

    RestTemplate restTemplate = new RestTemplate();
    try {
        String result = restTemplate.getForObject(SiteConfiguration.getApiUrl("storeweb"), String.class);
        ELabel webPage = ELabel.html(result);
        webPage.setHeight("480px");
        bodyLayout
                .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 = ELabel.html(informDiv.write()).withWidthUndefined();
        bodyLayout.with(new MVerticalLayout(webPage).withAlign(webPage, Alignment.TOP_CENTER));
    }
}

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

License:Open Source License

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

    try {//from   w  w w  .ja  va  2 s .c o m
        if (CollectionUtils.isEmpty(currentListData) && isDisplayEmptyListText) {
            Label noItemLbl = new Label(UserUIContext.getMessage(GenericI18Enum.EXT_NO_ITEM));
            MVerticalLayout widgetFooter = new MVerticalLayout().withFullWidth();
            widgetFooter.addStyleName("widget-footer");
            widgetFooter.with(noItemLbl).withAlign(noItemLbl, Alignment.MIDDLE_CENTER);
            contentLayout.addComponent(widgetFooter);
        } else {
            int i = 0;
            for (T item : currentListData) {
                Component row = rowDisplayHandler.generateRow(this, 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.mycollab.vaadin.web.ui.MailFormWindow.java

License:Open Source License

private void initButtonLinkCcBcc() {
    btnLinkCc = new Button("Add Cc");
    btnLinkCc.setStyleName(WebThemes.BUTTON_LINK);
    inputLayout.addComponent(btnLinkCc, 1, 0);
    inputLayout.setComponentAlignment(btnLinkCc, Alignment.MIDDLE_CENTER);

    btnLinkBcc = new Button("Add Bcc");
    btnLinkBcc.setStyleName(WebThemes.BUTTON_LINK);
    inputLayout.addComponent(btnLinkBcc, 2, 0);
    inputLayout.setComponentAlignment(btnLinkBcc, Alignment.MIDDLE_CENTER);

    btnLinkCc.addClickListener(clickEvent -> toggleCcLink());
    btnLinkBcc.addClickListener(clickEvent -> toggleBccLink());
}

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

License:Open Source License

private void initUI() {
    GridLayout mainLayout = new GridLayout(1, 5);
    mainLayout.setWidth("100%");
    mainLayout.setMargin(true);/*from  ww w  .j  a  v a 2  s . com*/
    mainLayout.setSpacing(true);

    CssLayout inputPanel = new CssLayout();
    inputPanel.setWidth("100%");
    inputPanel.setStyleName("mail-panel");

    inputLayout = new GridLayout(3, 4);
    inputLayout.setSpacing(true);
    inputLayout.setWidth("100%");
    inputLayout.setColumnExpandRatio(0, 1.0f);

    inputPanel.addComponent(inputLayout);

    mainLayout.addComponent(inputPanel);

    tokenFieldMailTo = new EmailTokenField();

    inputLayout.addComponent(createTextFieldMail("To:", tokenFieldMailTo), 0, 0);

    if (lstMail != null) {
        for (String mail : lstMail) {
            if (StringUtils.isNotBlank(mail)) {
                if (mail.indexOf("<") > -1) {
                    String strMail = mail.substring(mail.indexOf("<") + 1, mail.lastIndexOf(">"));
                    if (strMail != null && !strMail.equalsIgnoreCase("null")) {

                    }
                } else {

                }
            }
        }
    }

    final TextField subject = new TextField();
    subject.setRequired(true);
    subject.setWidth("100%");
    subjectField = createTextFieldMail("Subject:", subject);
    inputLayout.addComponent(subjectField, 0, 1);

    initButtonLinkCcBcc();

    ccField = createTextFieldMail("Cc:", tokenFieldMailCc);
    bccField = createTextFieldMail("Bcc:", tokenFieldMailBcc);

    final RichTextArea noteArea = new RichTextArea();
    noteArea.setWidth("100%");
    noteArea.setHeight("200px");
    mainLayout.addComponent(noteArea, 0, 1);
    mainLayout.setComponentAlignment(noteArea, Alignment.MIDDLE_CENTER);

    final AttachmentPanel attachments = new AttachmentPanel();
    attachments.setWidth("500px");

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

    MButton sendBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.ACTION_SEND_EMAIL), clickEvent -> {
        if (tokenFieldMailTo.getListRecipient().size() <= 0 || subject.getValue().equals("")) {
            NotificationUtil.showErrorNotification(
                    "To Email field and Subject field must be not empty! Please fulfil them before sending email.");
            return;
        }
        if (UserUIContext.getUser().getEmail() != null && UserUIContext.getUser().getEmail().length() > 0) {
            ExtMailService systemMailService = AppContextUtil.getSpringBean(ExtMailService.class);

            List<File> listFile = attachments.files();
            List<AttachmentSource> attachmentSource = null;
            if (listFile != null && listFile.size() > 0) {
                attachmentSource = new ArrayList<>();
                for (File file : listFile) {
                    attachmentSource.add(new FileAttachmentSource(file));
                }
            }

            systemMailService.sendHTMLMail(UserUIContext.getUser().getEmail(),
                    UserUIContext.getUser().getDisplayName(), tokenFieldMailTo.getListRecipient(),
                    tokenFieldMailCc.getListRecipient(), tokenFieldMailBcc.getListRecipient(),
                    subject.getValue(), noteArea.getValue(), attachmentSource, true);
            close();
        } else {
            NotificationUtil
                    .showErrorNotification("Your email is empty value, please fulfil it before sending email!");
        }
    }).withIcon(FontAwesome.SEND).withStyleName(WebThemes.BUTTON_ACTION);

    MHorizontalLayout controlsLayout = new MHorizontalLayout(attachments, cancelBtn, sendBtn)
            .expand(attachments).withFullWidth();
    mainLayout.addComponent(controlsLayout, 0, 2);
    this.setContent(mainLayout);
}

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

License:Open Source License

private void toggleCcLink() {
    removeAllInputField();//from  w w w.j a  va  2 s . c om
    if (!isAddCc) {
        btnLinkCc.setCaption("Remove Cc");
        if (!isAddBcc) {
            inputLayout.addComponent(ccField, 0, 1);
            inputLayout.addComponent(btnLinkCc, 1, 1);
            inputLayout.addComponent(btnLinkBcc, 2, 1);
            inputLayout.addComponent(subjectField, 0, 2);
        } else {
            addFullInputFieldByOrder();
        }
    } else {
        btnLinkCc.setCaption("Add Cc");

        if (isAddBcc) {
            inputLayout.addComponent(bccField, 0, 1);
            inputLayout.addComponent(btnLinkBcc, 1, 1);
            inputLayout.addComponent(btnLinkCc, 2, 1);
            inputLayout.addComponent(subjectField, 0, 2);
        } else {
            inputLayout.addComponent(btnLinkBcc, 1, 0);
            inputLayout.addComponent(btnLinkCc, 2, 0);
            inputLayout.addComponent(subjectField, 0, 1);
        }
    }

    inputLayout.setComponentAlignment(btnLinkBcc, Alignment.MIDDLE_CENTER);
    inputLayout.setComponentAlignment(btnLinkCc, Alignment.MIDDLE_CENTER);

    isAddCc = !isAddCc;

    checkToReInitCcBcc();
}

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

License:Open Source License

private void toggleBccLink() {
    removeAllInputField();//  ww w .  j av a 2 s. c om

    if (!isAddBcc) {
        btnLinkBcc.setCaption("Remove Bcc");
        if (!isAddCc) {
            inputLayout.addComponent(bccField, 0, 1);
            inputLayout.addComponent(btnLinkCc, 1, 1);
            inputLayout.addComponent(btnLinkBcc, 2, 1);
            inputLayout.addComponent(subjectField, 0, 2);
        } else {
            addFullInputFieldByOrder();
        }
    } else {
        btnLinkBcc.setCaption("Add Bcc");

        if (isAddCc) {
            inputLayout.addComponent(ccField, 0, 1);
            inputLayout.addComponent(btnLinkCc, 1, 1);
            inputLayout.addComponent(btnLinkBcc, 2, 1);
            inputLayout.addComponent(subjectField, 0, 2);
        } else {
            inputLayout.addComponent(btnLinkBcc, 1, 0);
            inputLayout.addComponent(btnLinkCc, 2, 0);
            inputLayout.addComponent(subjectField, 0, 1);
        }
    }
    inputLayout.setComponentAlignment(btnLinkBcc, Alignment.MIDDLE_CENTER);
    inputLayout.setComponentAlignment(btnLinkCc, Alignment.MIDDLE_CENTER);
    isAddBcc = !isAddBcc;
    checkToReInitCcBcc();
}

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

License:Open Source License

@Override
public void popupVisibilityChange(PopupVisibilityEvent event) {
    notificationContainer.removeAllComponents();

    if (notificationItems.size() > 0) {
        for (AbstractNotification item : notificationItems) {
            Component comp = buildComponentFromNotification(item);
            comp.setStyleName("notification-type");
            comp.addStyleName("notification-type-" + item.getType());
            notificationContainer.addComponent(comp);
        }//from   w ww .j  ava  2 s  . c o  m
    } else {
        Label noItemLbl = new Label(UserUIContext.getMessage(ShellI18nEnum.OPT_NO_NOTIFICATION));
        notificationContainer.addComponent(noItemLbl);
        notificationContainer.setComponentAlignment(noItemLbl, Alignment.MIDDLE_CENTER);
    }
}

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

License:Open Source License

public StyleCalendarExp() {
    this.setWidth("230px");
    this.setHeightUndefined();
    this.setSpacing(false);
    this.setStyleName("stylecalendar-ext");
    this.setMargin(new MarginInfo(true, false, false, false));

    styleCalendar.setRenderHeader(false);
    styleCalendar.setRenderWeekNumbers(false);
    styleCalendar.setImmediate(true);/*w  ww  .ja  v a2  s . c  o  m*/
    styleCalendar.setWidth("100%");
    setDateOptionsGenerator();

    btnShowNextYear = new Button();
    btnShowNextYear.setIcon(
            new ExternalResource(StorageFactory.generateAssetRelativeLink("icons/16/cal_year_next.png")));
    btnShowNextYear.setStyleName(WebThemes.BUTTON_LINK);

    btnShowNextMonth = new Button();
    btnShowNextMonth.setIcon(
            new ExternalResource(StorageFactory.generateAssetRelativeLink("icons/16/cal_month_next.png")));
    btnShowNextMonth.setStyleName(WebThemes.BUTTON_LINK);

    btnShowPreviousMonth = new Button();
    btnShowPreviousMonth.setIcon(
            new ExternalResource(StorageFactory.generateAssetRelativeLink("icons/16/cal_month_pre.png")));
    btnShowPreviousMonth.setStyleName(WebThemes.BUTTON_LINK);

    btnShowPreviousYear = new Button();
    btnShowPreviousYear.setIcon(
            new ExternalResource(StorageFactory.generateAssetRelativeLink("icons/16/cal_year_pre.png")));
    btnShowPreviousYear.setStyleName(WebThemes.BUTTON_LINK);

    lbSelectedDate.setValue(UserUIContext.formatDate(new Date()));
    lbSelectedDate.addStyleName("calendarDateLabel");
    lbSelectedDate.setWidth("80");

    HorizontalLayout layoutControl = new HorizontalLayout();
    layoutControl.setStyleName("calendarHeader");
    layoutControl.setWidth("100%");
    layoutControl.setHeight("35px");

    HorizontalLayout layoutButtonPrevious = new HorizontalLayout();
    layoutButtonPrevious.setSpacing(true);
    layoutButtonPrevious.addComponent(btnShowPreviousYear);
    layoutButtonPrevious.setComponentAlignment(btnShowPreviousYear, Alignment.MIDDLE_LEFT);
    layoutButtonPrevious.addComponent(btnShowPreviousMonth);
    layoutButtonPrevious.setComponentAlignment(btnShowPreviousMonth, Alignment.MIDDLE_LEFT);
    layoutControl.addComponent(layoutButtonPrevious);
    layoutControl.setComponentAlignment(layoutButtonPrevious, Alignment.MIDDLE_LEFT);

    layoutControl.addComponent(lbSelectedDate);
    layoutControl.setComponentAlignment(lbSelectedDate, Alignment.MIDDLE_CENTER);

    MHorizontalLayout layoutButtonNext = new MHorizontalLayout();
    layoutButtonNext.addComponent(btnShowNextMonth);
    layoutButtonNext.setComponentAlignment(btnShowNextMonth, Alignment.MIDDLE_RIGHT);
    layoutButtonNext.addComponent(btnShowNextYear);
    layoutButtonNext.setComponentAlignment(btnShowNextYear, Alignment.MIDDLE_RIGHT);
    layoutControl.addComponent(layoutButtonNext);
    layoutControl.setComponentAlignment(layoutButtonNext, Alignment.MIDDLE_RIGHT);

    this.addComponent(layoutControl);
    this.setComponentAlignment(layoutControl, Alignment.TOP_CENTER);

    this.addComponent(styleCalendar);
    this.setExpandRatio(styleCalendar, 1.0f);
}

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

License:Open Source License

public void addTab(Component component, String id, int level, String caption, String link, Resource resource) {
    if (!hasTab(id)) {
        final ButtonTabImpl button = new ButtonTabImpl(id, level, caption, link);

        button.addClickListener(clickEvent -> {
            if (!clickEvent.isCtrlKey() && !clickEvent.isMetaKey()) {
                if (selectedButton != button) {
                    clearTabSelection(true);
                    selectedButton = button;
                    selectedButton.addStyleName(TAB_SELECTED_STYLENAME);
                    selectedComp = compMap.get(button.getTabId());
                }/* w w w  .j ava 2s  .co  m*/
                fireTabChangeEvent(new SelectedTabChangeEvent(VerticalTabsheet.this));
            } else {
                Page.getCurrent().open(button.link, "_blank", false);
            }
        });

        button.setIcon(resource);
        button.withStyleName(TAB_STYLENAME, UIConstants.TEXT_ELLIPSIS).withWidth("90%");

        if (button.getLevel() > 0) {
            int insertIndex = 0;
            for (int i = 0; i < navigatorContainer.getComponentCount(); i++) {
                ButtonTabImpl buttonTmp = (ButtonTabImpl) navigatorContainer.getComponent(i);
                if (buttonTmp.getLevel() > level) {
                    break;
                } else {
                    insertIndex++;
                }
            }
            navigatorContainer.addComponent(button, insertIndex);
            navigatorContainer.setComponentAlignment(button, Alignment.MIDDLE_CENTER);
        } else {
            navigatorContainer.addComponent(button);
            navigatorContainer.setComponentAlignment(button, Alignment.MIDDLE_CENTER);
        }

        TabImpl tabImpl = new TabImpl(id, caption, component);
        compMap.put(id, tabImpl);
    }
}