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.crm.view.lead.LeadConvertInfoWindow.java

License:Open Source License

private MHorizontalLayout createButtonControls() {
    MButton convertButton = new MButton(UserUIContext.getMessage(LeadI18nEnum.BUTTON_CONVERT_LEAD),
            clickEvent -> {/*from  ww  w . j av a 2 s  . c o m*/
                LeadService leadService = AppContextUtil.getSpringBean(LeadService.class);
                lead.setStatus("Converted");
                leadService.updateWithSession(lead, UserUIContext.getUsername());
                Opportunity opportunity = null;
                if (opportunityForm != null && opportunityForm.isVisible()) {
                    if (opportunityForm.validateForm()) {
                        opportunity = opportunityForm.getBean();
                    }
                }

                leadService.convertLead(lead, opportunity, UserUIContext.getUsername());
                LeadConvertInfoWindow.this.close();
                EventBusFactory.getInstance()
                        .post(new LeadEvent.GotoRead(LeadConvertInfoWindow.this, lead.getId()));
            }).withStyleName(WebThemes.BUTTON_ACTION);

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

    return new MHorizontalLayout(cancelButton, convertButton).alignAll(Alignment.MIDDLE_CENTER);
}

From source file:com.mycollab.module.crm.view.lead.LeadSimpleSearchPanel.java

License:Open Source License

private void createBasicSearchLayout() {
    searchPanel = new GridLayout(3, 3);
    searchPanel.setSpacing(true);//from  w w w. ja  v  a 2  s.com

    group = new ValueComboBox(false, "Name", "Email", "Phone",
            AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE));
    group.select("Name");
    group.setImmediate(true);
    group.addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            removeComponents();
            String searchType = (String) group.getValue();
            if (searchType.equals("Name")) {
                addTextFieldSearch();
            } else if (searchType.equals("Email")) {
                addTextFieldSearch();
            } else if (searchType.equals("Phone")) {
                addTextFieldSearch();
            } else if (searchType.equals(AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE))) {
                addUserListSelectField();
            }
        }
    });

    searchPanel.addComponent(group, 1, 0);
    searchPanel.setComponentAlignment(group, Alignment.MIDDLE_CENTER);
    addTextFieldSearch();

    Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH));
    searchBtn.setStyleName(UIConstants.BUTTON_ACTION);
    searchBtn.setIcon(FontAwesome.SEARCH);
    searchBtn.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            doSearch();
        }
    });
    searchPanel.addComponent(searchBtn, 2, 0);
    searchPanel.setComponentAlignment(searchBtn, Alignment.MIDDLE_CENTER);
    this.setCompositionRoot(searchPanel);
}

From source file:com.mycollab.module.crm.view.lead.LeadSimpleSearchPanel.java

License:Open Source License

private void addTextFieldSearch() {
    textValueField = ShortcutExtension.installShortcutAction(new TextField(),
            new ShortcutListener("LeadSearchRequest", ShortcutAction.KeyCode.ENTER, null) {
                @Override/*from  w  ww  .  j a va2 s.c  om*/
                public void handleAction(Object o, Object o1) {
                    doSearch();
                }
            });
    searchPanel.addComponent(textValueField, 0, 0);
    searchPanel.setComponentAlignment(textValueField, Alignment.MIDDLE_CENTER);
}

From source file:com.mycollab.module.crm.view.lead.LeadSimpleSearchPanel.java

License:Open Source License

private void addUserListSelectField() {
    userBox = new ActiveUserComboBox();
    userBox.setImmediate(true);/*from w ww  .  j  a va 2  s . c om*/
    searchPanel.addComponent(userBox, 0, 0);
    searchPanel.setComponentAlignment(userBox, Alignment.MIDDLE_CENTER);
}

From source file:com.mycollab.module.crm.view.opportunity.OpportunitySimpleSearchPanel.java

License:Open Source License

private void createBasicSearchLayout() {
    searchPanel = new GridLayout(3, 3);
    searchPanel.setSpacing(true);//from ww w . java2  s  .c  o  m

    group = new ValueComboBox(false, "Name", "Account Name", "Sales Stage",
            AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE));
    group.select("Name");
    group.setImmediate(true);
    group.addValueChangeListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            removeComponents();
            String searchType = (String) group.getValue();
            if (searchType.equals("Name")) {
                addTextFieldSearch();
            } else if (searchType.equals("Account Name")) {
                addTextFieldSearch();
            } else if (searchType.equals("Sales Stage")) {
                addTextFieldSearch();
            } else if (searchType.equals(AppContext.getMessage(GenericI18Enum.FORM_ASSIGNEE))) {
                addUserListSelectField();
            }
        }
    });

    searchPanel.addComponent(group, 1, 0);
    searchPanel.setComponentAlignment(group, Alignment.MIDDLE_CENTER);
    addTextFieldSearch();

    Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH));
    searchBtn.setStyleName(UIConstants.BUTTON_ACTION);
    searchBtn.setIcon(FontAwesome.SEARCH);
    searchBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            doSearch();
        }
    });
    searchPanel.addComponent(searchBtn, 2, 0);
    searchPanel.setComponentAlignment(searchBtn, Alignment.MIDDLE_CENTER);
    this.setCompositionRoot(searchPanel);
}

From source file:com.mycollab.module.crm.view.opportunity.OpportunitySimpleSearchPanel.java

License:Open Source License

private void addTextFieldSearch() {
    textValueField = new TextField();
    textValueField.addShortcutListener(//from  ww w . j a  v a2 s  .c  o  m
            new ShortcutListener("OpportunitySearchField", ShortcutAction.KeyCode.ENTER, null) {
                @Override
                public void handleAction(Object o, Object o1) {
                    doSearch();
                }
            });
    searchPanel.addComponent(textValueField, 0, 0);
    searchPanel.setComponentAlignment(textValueField, Alignment.MIDDLE_CENTER);
}

From source file:com.mycollab.module.crm.view.SalesDashboardView.java

License:Open Source License

void displayReport() {
    final String reportName = this.reportDashboard[this.currentReportIndex];

    final VerticalLayout bodyContent = (VerticalLayout) this.bodyContent;
    bodyContent.removeAllComponents();//w ww .j  a va 2 s  . c  o m
    bodyContent.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    if ("OpportunitySalesStage".equals(reportName)) {
        this.setTitle(UserUIContext.getMessage(OpportunityI18nEnum.OPT_SALES_STAGE));
        OpportunitySalesStageDashboard salesStageDashboard = new OpportunitySalesStageDashboard();
        bodyContent.addComponent(salesStageDashboard);

        final OpportunitySearchCriteria criteria = new OpportunitySearchCriteria();
        criteria.setSaccountid(new NumberSearchField(MyCollabUI.getAccountId()));
        salesStageDashboard.displayChart(criteria);
    } else if ("OpportunityLeadSource".equals(reportName)) {
        this.setTitle(UserUIContext.getMessage(OpportunityI18nEnum.OPT_LEAD_SOURCES));
        OpportunityLeadSourceDashboard leadSourceDashboard = new OpportunityLeadSourceDashboard();
        bodyContent.addComponent(leadSourceDashboard);

        final OpportunitySearchCriteria criteria = new OpportunitySearchCriteria();
        criteria.setSaccountid(new NumberSearchField(MyCollabUI.getAccountId()));
        leadSourceDashboard.displayChart(criteria);
    }
}

From source file:com.mycollab.module.file.view.components.FileDownloadWindow.java

License:Open Source License

private void constructBody() {
    final MVerticalLayout layout = new MVerticalLayout().withFullWidth();
    CssLayout iconWrapper = new CssLayout();
    final ELabel iconEmbed = ELabel.fontIcon(FileAssetsUtil.getFileIconResource(content.getName()));
    iconEmbed.addStyleName("icon-48px");
    iconWrapper.addComponent(iconEmbed);
    layout.with(iconWrapper).withAlign(iconWrapper, Alignment.MIDDLE_CENTER);

    final GridFormLayoutHelper inforLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 4);

    if (content.getDescription() != null) {
        final Label descLbl = new Label();
        if (!content.getDescription().equals("")) {
            descLbl.setData(content.getDescription());
        } else {//  www.j  a  va2  s .  c  o  m
            descLbl.setValue(" ");
            descLbl.setContentMode(ContentMode.HTML);
        }
        inforLayout.addComponent(descLbl, "Description", 0, 0);
    }

    UserService userService = AppContextUtil.getSpringBean(UserService.class);
    SimpleUser user = userService.findUserByUserNameInAccount(content.getCreatedUser(),
            AppContext.getAccountId());
    if (user == null) {
        inforLayout.addComponent(new UserLink(AppContext.getUsername(), AppContext.getUserAvatarId(),
                AppContext.getUserDisplayName()), "Created by", 0, 1);
    } else {
        inforLayout.addComponent(new UserLink(user.getUsername(), user.getAvatarid(), user.getDisplayName()),
                "Created by", 0, 1);
    }

    final Label size = new Label(FileUtils.getVolumeDisplay(content.getSize()));
    inforLayout.addComponent(size, "Size", 0, 2);

    ELabel dateCreate = new ELabel().prettyDateTime(content.getCreated().getTime());
    inforLayout.addComponent(dateCreate, "Created date", 0, 3);

    layout.addComponent(inforLayout.getLayout());

    final MHorizontalLayout buttonControls = new MHorizontalLayout()
            .withMargin(new MarginInfo(true, false, true, false));

    final Button downloadBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DOWNLOAD));
    List<Resource> resources = new ArrayList<>();
    resources.add(content);

    StreamResource downloadResource = StreamDownloadResourceUtil.getStreamResourceSupportExtDrive(resources);

    FileDownloader fileDownloader = new FileDownloader(downloadResource);
    fileDownloader.extend(downloadBtn);
    downloadBtn.setIcon(FontAwesome.DOWNLOAD);
    downloadBtn.addStyleName(UIConstants.BUTTON_ACTION);

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

                @Override
                public void buttonClick(ClickEvent event) {
                    close();
                }
            });
    cancelBtn.addStyleName(UIConstants.BUTTON_OPTION);
    buttonControls.with(cancelBtn, downloadBtn).alignAll(Alignment.TOP_RIGHT);
    layout.with(buttonControls).withAlign(buttonControls, Alignment.TOP_RIGHT);
    this.setContent(layout);
}

From source file:com.mycollab.module.file.view.FileDownloadWindow.java

License:Open Source License

private void constructBody() {
    final MVerticalLayout layout = new MVerticalLayout().withFullWidth();
    CssLayout iconWrapper = new CssLayout();
    final ELabel iconEmbed = ELabel.fontIcon(FileAssetsUtil.getFileIconResource(content.getName()));
    iconEmbed.addStyleName("icon-48px");
    iconWrapper.addComponent(iconEmbed);
    layout.with(iconWrapper).withAlign(iconWrapper, Alignment.MIDDLE_CENTER);

    final GridFormLayoutHelper inforLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 4);

    if (content.getDescription() != null) {
        final Label descLbl = new Label();
        if (!content.getDescription().equals("")) {
            descLbl.setData(content.getDescription());
        } else {/* w  ww  .  j  av  a 2 s  .c  o m*/
            descLbl.setValue("&nbsp;");
            descLbl.setContentMode(ContentMode.HTML);
        }
        inforLayout.addComponent(descLbl, UserUIContext.getMessage(GenericI18Enum.FORM_DESCRIPTION), 0, 0);
    }

    UserService userService = AppContextUtil.getSpringBean(UserService.class);
    SimpleUser user = userService.findUserByUserNameInAccount(content.getCreatedUser(),
            MyCollabUI.getAccountId());
    if (user == null) {
        inforLayout.addComponent(
                new UserLink(UserUIContext.getUsername(), UserUIContext.getUserAvatarId(),
                        UserUIContext.getUserDisplayName()),
                UserUIContext.getMessage(GenericI18Enum.OPT_CREATED_BY), 0, 1);
    } else {
        inforLayout.addComponent(new UserLink(user.getUsername(), user.getAvatarid(), user.getDisplayName()),
                UserUIContext.getMessage(GenericI18Enum.OPT_CREATED_BY), 0, 1);
    }

    final Label size = new Label(FileUtils.getVolumeDisplay(content.getSize()));
    inforLayout.addComponent(size, UserUIContext.getMessage(FileI18nEnum.OPT_SIZE), 0, 2);

    ELabel dateCreate = new ELabel().prettyDateTime(content.getCreated().getTime());
    inforLayout.addComponent(dateCreate, UserUIContext.getMessage(GenericI18Enum.FORM_CREATED_TIME), 0, 3);

    layout.addComponent(inforLayout.getLayout());

    MButton downloadBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_DOWNLOAD))
            .withIcon(FontAwesome.DOWNLOAD).withStyleName(WebThemes.BUTTON_ACTION);
    List<Resource> resources = new ArrayList<>();
    resources.add(content);

    StreamResource downloadResource = StreamDownloadResourceUtil.getStreamResourceSupportExtDrive(resources);

    FileDownloader fileDownloader = new FileDownloader(downloadResource);
    fileDownloader.extend(downloadBtn);

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION);
    final MHorizontalLayout buttonControls = new MHorizontalLayout(cancelBtn, downloadBtn);
    layout.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT);
    this.setContent(layout);
}

From source file:com.mycollab.module.project.ui.components.ProjectListNoItemView.java

License:Open Source License

public ProjectListNoItemView() {
    MVerticalLayout content = new MVerticalLayout().withWidth("700px");
    ELabel image = ELabel.h2(viewIcon().getHtml()).withWidthUndefined();

    ELabel title = ELabel.h2(viewTitle()).withWidthUndefined();
    ELabel body = ELabel.html(viewHint()).withStyleName(UIConstants.LABEL_WORD_WRAP).withWidthUndefined();
    MHorizontalLayout links = createControlButtons();
    content.with(image, title, body, links).alignAll(Alignment.TOP_CENTER);
    this.addComponent(content);
    this.setComponentAlignment(content, Alignment.MIDDLE_CENTER);
}