Example usage for com.vaadin.ui Alignment MIDDLE_LEFT

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

Introduction

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

Prototype

Alignment MIDDLE_LEFT

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

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 w w  w . ja  va2 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.profile.view.ProfileReadViewImpl.java

License:Open Source License

private void displayUserAvatar() {
    avatarAndPass.removeAllComponents();
    Image cropField = UserAvatarControlFactory
            .createUserAvatarEmbeddedComponent(UserUIContext.getUserAvatarId(), 100);
    cropField.addStyleName(UIConstants.CIRCLE_BOX);
    CssLayout avatarWrapper = new CssLayout();
    avatarWrapper.addComponent(cropField);
    MVerticalLayout userAvatar = new MVerticalLayout().withMargin(false).with(avatarWrapper);
    userAvatar.setSizeUndefined();//from   www  .  j a v a2  s . c  o  m

    final UploadImageField avatarUploadField = new UploadImageField(this);
    avatarUploadField.setButtonCaption(UserUIContext.getMessage(UserI18nEnum.BUTTON_CHANGE_AVATAR));
    userAvatar.addComponent(avatarUploadField);

    avatarAndPass.with(userAvatar);

    User user = formItem.getBean();
    MVerticalLayout basicLayout = new MVerticalLayout().withMargin(false);

    ELabel usernameLbl = ELabel.h2(UserUIContext.getUser().getDisplayName()).withWidthUndefined();

    MButton btnChangeBasicInfo = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_EDIT),
            clickEvent -> UI.getCurrent().addWindow(new BasicInfoChangeWindow(formItem.getBean())))
                    .withStyleName(WebThemes.BUTTON_LINK);

    MHorizontalLayout userWrapper = new MHorizontalLayout(usernameLbl, btnChangeBasicInfo);
    basicLayout.addComponent(userWrapper);
    basicLayout.setComponentAlignment(userWrapper, Alignment.MIDDLE_LEFT);

    GridFormLayoutHelper userFormLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 5)
            .withCaptionWidth("140px");
    userFormLayout.getLayout().addStyleName(WebThemes.GRIDFORM_BORDERLESS);
    userFormLayout.addComponent(new Label(UserUIContext.formatDate(user.getDateofbirth())),
            UserUIContext.getMessage(UserI18nEnum.FORM_BIRTHDAY), 0, 0);
    userFormLayout
            .addComponent(
                    new Label(new A("mailto:" + user.getEmail()).appendText(user.getEmail()).setTarget("_blank")
                            .write(), ContentMode.HTML),
                    UserUIContext.getMessage(GenericI18Enum.FORM_EMAIL), 0, 1);
    userFormLayout.addComponent(
            new Label(TimezoneVal.getDisplayName(UserUIContext.getUserLocale(), user.getTimezone())),
            UserUIContext.getMessage(UserI18nEnum.FORM_TIMEZONE), 0, 2);
    userFormLayout.addComponent(
            new Label(LocalizationHelper.getLocaleInstance(user.getLanguage())
                    .getDisplayLanguage(UserUIContext.getUserLocale())),
            UserUIContext.getMessage(UserI18nEnum.FORM_LANGUAGE),
            UserUIContext.getMessage(ShellI18nEnum.OPT_SUPPORTED_LANGUAGES_INTRO), 0, 3);

    MButton btnChangePassword = new MButton(UserUIContext.getMessage(GenericI18Enum.ACTION_CHANGE),
            clickEvent -> UI.getCurrent().addWindow(new PasswordChangeWindow(formItem.getBean())))
                    .withStyleName(WebThemes.BUTTON_LINK);
    userFormLayout.addComponent(new MHorizontalLayout(new Label("***********"), btnChangePassword),
            UserUIContext.getMessage(ShellI18nEnum.FORM_PASSWORD), 0, 4);
    basicLayout.addComponent(userFormLayout.getLayout());

    avatarAndPass.with(basicLayout).expand(basicLayout);
}

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.  jav  a 2  s  .c o m*/

    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.RoleListViewImpl.java

License:Open Source License

private ComponentContainer constructTableActionControls() {
    MHorizontalLayout layout = new MHorizontalLayout();
    MCssLayout layoutWrapper = new MCssLayout(layout).withFullWidth()
            .withStyleName(WebThemes.TABLE_ACTION_CONTROLS);

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

    tableActionControls = new DefaultMassItemActionHandlerContainer();
    if (UserUIContext.canAccess(RolePermissionCollections.ACCOUNT_ROLE)) {
        tableActionControls.addDeleteActionItem();
    }/*from   w  ww  .  ja v a2  s  .c o m*/
    tableActionControls.addDownloadPdfActionItem();
    tableActionControls.addDownloadExcelActionItem();
    tableActionControls.addDownloadCsvActionItem();

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

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

License:Open Source License

public RoleReadViewImpl() {
    super();/*w  ww .j  a v  a  2 s .c o  m*/
    this.setMargin(new MarginInfo(false, true, true, true));

    MHorizontalLayout header = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false))
            .withFullWidth();
    header.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    ELabel headerText = ELabel
            .h2(FontAwesome.USERS.getHtml() + " " + UserUIContext.getMessage(RoleI18nEnum.DETAIL));
    header.with(headerText).expand(headerText);
    this.addComponent(header);

    this.previewForm = new AdvancedPreviewBeanForm<>();
    this.addComponent(this.previewForm);

    Layout controlButtons = createTopPanel();
    if (controlButtons != null) {
        header.addComponent(controlButtons);
    }
}

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

License:Open Source License

public UserListViewImpl() {
    super();/*w ww.  ja v a2 s .  co  m*/
    this.setMargin(new MarginInfo(false, true, false, true));
    MHorizontalLayout header = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false))
            .withFullWidth();
    MButton createBtn = new MButton(UserUIContext.getMessage(UserI18nEnum.NEW),
            clickEvent -> EventBusFactory.getInstance().post(new UserEvent.GotoAdd(this, null)))
                    .withIcon(FontAwesome.PLUS).withStyleName(WebThemes.BUTTON_ACTION)
                    .withVisible(UserUIContext.canWrite(RolePermissionCollections.ACCOUNT_USER));

    headerText = HeaderWithFontAwesome.h2(FontAwesome.USERS, UserUIContext.getMessage(UserI18nEnum.LIST) + " "
            + UserUIContext.getMessage(GenericI18Enum.OPT_TOTAL_VALUE, 0));

    final MButton sortBtn = new MButton().withIcon(FontAwesome.SORT_ALPHA_ASC)
            .withStyleName(WebThemes.BUTTON_ICON_ONLY);
    sortBtn.addClickListener(clickEvent -> {
        sortAsc = !sortAsc;
        if (sortAsc) {
            sortBtn.setIcon(FontAwesome.SORT_ALPHA_ASC);
            displayUsers();
        } else {
            sortBtn.setIcon(FontAwesome.SORT_ALPHA_DESC);
            displayUsers();
        }
    });
    header.addComponent(sortBtn);

    final SearchTextField searchTextField = new SearchTextField() {
        @Override
        public void doSearch(String value) {
            searchCriteria.setDisplayName(StringSearchField.and(value));
            displayUsers();
        }

        @Override
        public void emptySearch() {
            searchCriteria.setDisplayName(null);
            displayUsers();
        }
    };
    searchTextField.addStyleName(ValoTheme.TEXTFIELD_SMALL);

    MButton printBtn = new MButton("", clickEvent -> UI.getCurrent()
            .addWindow(new UserCustomizeReportOutputWindow(new LazyValueInjector() {
                @Override
                protected Object doEval() {
                    return searchCriteria;
                }
            }))).withIcon(FontAwesome.PRINT).withStyleName(WebThemes.BUTTON_OPTION)
                    .withDescription(UserUIContext.getMessage(GenericI18Enum.ACTION_EXPORT));

    header.with(headerText, sortBtn, searchTextField, printBtn, createBtn).alignAll(Alignment.MIDDLE_LEFT)
            .expand(headerText);
    this.addComponent(header);

    contentLayout = new CssLayout();
    contentLayout.setWidth("100%");
    this.addComponent(contentLayout);
}

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

License:Open Source License

private void displayUserAvatar() {
    header.removeAllComponents();//from  www.j  a va  2  s  . c  om
    MHorizontalLayout avatarAndPass = new MHorizontalLayout().withFullWidth();
    Image cropField = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(user.getAvatarid(), 100);
    cropField.addStyleName(UIConstants.CIRCLE_BOX);
    CssLayout userAvatar = new CssLayout();
    userAvatar.addComponent(cropField);
    avatarAndPass.addComponent(userAvatar);

    MVerticalLayout basicLayout = new MVerticalLayout().withMargin(new MarginInfo(false, true, false, true));
    CssLayout userWrapper = new CssLayout();
    String nickName = user.getNickname();
    ELabel userName = ELabel.h2(user.getDisplayName()
            + (StringUtils.isEmpty(nickName) ? "" : (String.format(" ( %s )", nickName))));
    userWrapper.addComponent(userName);

    basicLayout.addComponent(userWrapper);
    basicLayout.setComponentAlignment(userWrapper, Alignment.MIDDLE_LEFT);

    GridFormLayoutHelper userFormLayout;
    if (UserUIContext.isAdmin()) {
        userFormLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 6).withCaptionWidth("140px");
    } else {
        userFormLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 5).withCaptionWidth("140px");
    }
    userFormLayout.getLayout().addStyleName(WebThemes.GRIDFORM_BORDERLESS);
    basicLayout.addComponent(userFormLayout.getLayout());

    Node roleDiv;
    if (Boolean.TRUE.equals(user.getIsAccountOwner())) {
        roleDiv = new Div().appendText(UserUIContext.getMessage(RoleI18nEnum.OPT_ACCOUNT_OWNER));
    } else {
        roleDiv = new A(AccountLinkBuilder.generatePreviewFullRoleLink(user.getRoleid()))
                .appendText(user.getRoleName());
    }

    userFormLayout.addComponent(ELabel.html(roleDiv.write()), UserUIContext.getMessage(UserI18nEnum.FORM_ROLE),
            0, 0);
    userFormLayout.addComponent(new Label(UserUIContext.formatDate(user.getDateofbirth())),
            UserUIContext.getMessage(UserI18nEnum.FORM_BIRTHDAY), 0, 1);

    if (Boolean.TRUE.equals(MyCollabUI.showEmailPublicly())) {
        userFormLayout.addComponent(
                ELabel.html(new A("mailto:" + user.getEmail()).appendText(user.getEmail()).write()),
                UserUIContext.getMessage(GenericI18Enum.FORM_EMAIL), 0, 2);
    } else {
        userFormLayout.addComponent(ELabel.html("******"), UserUIContext.getMessage(GenericI18Enum.FORM_EMAIL),
                0, 2);
    }

    userFormLayout.addComponent(
            new Label(TimezoneVal.getDisplayName(UserUIContext.getUserLocale(), user.getTimezone())),
            UserUIContext.getMessage(UserI18nEnum.FORM_TIMEZONE), 0, 3);
    userFormLayout.addComponent(
            new Label(LocalizationHelper.getLocaleInstance(user.getLanguage())
                    .getDisplayLanguage(UserUIContext.getUserLocale())),
            UserUIContext.getMessage(UserI18nEnum.FORM_LANGUAGE), 0, 4);

    if (UserUIContext.isAdmin()) {
        MButton btnChangePassword = new MButton(UserUIContext.getMessage(GenericI18Enum.ACTION_CHANGE),
                clickEvent -> UI.getCurrent().addWindow(new PasswordChangeWindow(user)))
                        .withStyleName(WebThemes.BUTTON_LINK);
        userFormLayout.addComponent(new MHorizontalLayout(new Label("***********"), btnChangePassword),
                UserUIContext.getMessage(ShellI18nEnum.FORM_PASSWORD), 0, 5);
    }

    avatarAndPass.with(basicLayout).withAlign(basicLayout, Alignment.TOP_LEFT).expand(basicLayout);

    Layout controlButtons = createTopPanel();
    CssLayout avatarAndPassWrapper = new CssLayout();
    avatarAndPass.setWidthUndefined();
    avatarAndPassWrapper.addComponent(avatarAndPass);
    header.with(avatarAndPass, controlButtons).withAlign(avatarAndPass, Alignment.TOP_LEFT)
            .withAlign(controlButtons, Alignment.TOP_RIGHT);
}

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

License:Open Source License

public AccountModuleImpl() {
    addStyleName("module");
    ControllerRegistry.addController(new UserAccountController(this));

    MHorizontalLayout topPanel = new MHorizontalLayout().withFullWidth().withMargin(true)
            .withStyleName("border-bottom");
    AccountSettingBreadcrumb breadcrumb = ViewManager.getCacheComponent(AccountSettingBreadcrumb.class);

    MButton helpBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.ACTION_HELP))
            .withIcon(FontAwesome.MORTAR_BOARD).withStyleName(WebThemes.BUTTON_LINK);
    ExternalResource helpRes = new ExternalResource("https://community.mycollab.com/docs/account-management/");
    BrowserWindowOpener helpOpener = new BrowserWindowOpener(helpRes);
    helpOpener.extend(helpBtn);//from   w  w w . j  a  va  2s  .c  om

    topPanel.with(breadcrumb, helpBtn).expand(breadcrumb).alignAll(Alignment.MIDDLE_LEFT);

    tabSheet = new VerticalTabsheet();
    tabSheet.setSizeFull();
    tabSheet.setNavigatorStyleName("sidebar-menu");
    tabSheet.addToggleNavigatorControl();
    VerticalLayout contentWrapper = tabSheet.getContentWrapper();
    contentWrapper.addStyleName("main-content");
    contentWrapper.addComponentAsFirst(topPanel);

    this.buildComponents();
    this.setContent(tabSheet);
}

From source file:com.mycollab.reporting.CustomizeReportOutputWindow.java

License:Open Source License

public CustomizeReportOutputWindow(final String viewId, final String reportTitle, final Class<B> beanCls,
        final ISearchableService<S> searchableService, final VariableInjector<S> variableInjector) {
    super(UserUIContext.getMessage(GenericI18Enum.ACTION_EXPORT));
    MVerticalLayout contentLayout = new MVerticalLayout();
    this.withModal(true).withResizable(false).withWidth("1000px").withCenter().withContent(contentLayout);
    this.viewId = viewId;
    this.variableInjector = variableInjector;

    final OptionGroup optionGroup = new OptionGroup();
    optionGroup.addStyleName("sortDirection");
    optionGroup.addItems(UserUIContext.getMessage(FileI18nEnum.CSV), UserUIContext.getMessage(FileI18nEnum.PDF),
            UserUIContext.getMessage(FileI18nEnum.EXCEL));
    optionGroup.setValue(UserUIContext.getMessage(FileI18nEnum.CSV));
    contentLayout.with(new MHorizontalLayout(ELabel.h3(UserUIContext.getMessage(GenericI18Enum.ACTION_EXPORT)),
            optionGroup).alignAll(Alignment.MIDDLE_LEFT));

    contentLayout.with(ELabel.h3(UserUIContext.getMessage(GenericI18Enum.ACTION_SELECT_COLUMNS)));
    listBuilder = new ListBuilder();
    listBuilder.setImmediate(true);/*from  w ww .  j av a 2 s. co m*/
    listBuilder.setColumns(0);
    listBuilder.setLeftColumnCaption(UserUIContext.getMessage(GenericI18Enum.OPT_AVAILABLE_COLUMNS));
    listBuilder.setRightColumnCaption(UserUIContext.getMessage(GenericI18Enum.OPT_VIEW_COLUMNS));
    listBuilder.setWidth(100, Sizeable.Unit.PERCENTAGE);
    listBuilder.setItemCaptionMode(AbstractSelect.ItemCaptionMode.EXPLICIT);
    final BeanItemContainer<TableViewField> container = new BeanItemContainer<>(TableViewField.class,
            this.getAvailableColumns());
    listBuilder.setContainerDataSource(container);
    for (TableViewField field : getAvailableColumns()) {
        listBuilder.setItemCaption(field, UserUIContext.getMessage(field.getDescKey()));
    }
    final Collection<TableViewField> viewColumnIds = this.getViewColumns();
    listBuilder.setValue(viewColumnIds);
    contentLayout.with(listBuilder).withAlign(listBuilder, Alignment.TOP_CENTER);

    contentLayout.with(ELabel.h3(UserUIContext.getMessage(GenericI18Enum.ACTION_PREVIEW)));
    sampleTableDisplay = new Table();
    for (TableViewField field : getAvailableColumns()) {
        sampleTableDisplay.addContainerProperty(field.getField(), String.class, "",
                UserUIContext.getMessage(field.getDescKey()), null, Table.Align.LEFT);
        sampleTableDisplay.setColumnWidth(field.getField(), field.getDefaultWidth());
    }
    sampleTableDisplay.setWidth("100%");
    sampleTableDisplay.addItem(buildSampleData(), 1);
    sampleTableDisplay.setPageLength(1);
    contentLayout.with(sampleTableDisplay);
    filterColumns();

    listBuilder.addValueChangeListener(valueChangeEvent -> filterColumns());

    MButton resetBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_RESET), clickEvent -> {
        listBuilder.setValue(getDefaultColumns());
        filterColumns();
    }).withStyleName(WebThemes.BUTTON_LINK);

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

    final MButton exportBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.ACTION_EXPORT))
            .withStyleName(WebThemes.BUTTON_ACTION).withIcon(FontAwesome.DOWNLOAD);
    OnDemandFileDownloader pdfFileDownloader = new OnDemandFileDownloader(new LazyStreamSource() {
        @Override
        protected StreamResource.StreamSource buildStreamSource() {
            return (StreamResource.StreamSource) () -> {
                Collection<TableViewField> columns = (Collection<TableViewField>) listBuilder.getValue();
                // Save custom table view def
                CustomViewStoreService customViewStoreService = AppContextUtil
                        .getSpringBean(CustomViewStoreService.class);
                CustomViewStore viewDef = new CustomViewStore();
                viewDef.setSaccountid(MyCollabUI.getAccountId());
                viewDef.setCreateduser(UserUIContext.getUsername());
                viewDef.setViewid(viewId);
                viewDef.setViewinfo(FieldDefAnalyzer.toJson(new ArrayList<>(columns)));
                customViewStoreService.saveOrUpdateViewLayoutDef(viewDef);

                SimpleReportTemplateExecutor reportTemplateExecutor = new SimpleReportTemplateExecutor.AllItems<>(
                        reportTitle, new RpFieldsBuilder(columns), exportType, beanCls, searchableService);
                ReportStreamSource streamSource = new ReportStreamSource(reportTemplateExecutor) {
                    @Override
                    protected void initReportParameters(Map<String, Object> parameters) {
                        parameters.put(SimpleReportTemplateExecutor.CRITERIA, variableInjector.eval());
                    }
                };
                return streamSource.getStream();
            };
        }

        @Override
        public String getFilename() {
            String exportTypeVal = (String) optionGroup.getValue();
            if (UserUIContext.getMessage(FileI18nEnum.CSV).equals(exportTypeVal)) {
                exportType = ReportExportType.CSV;
            } else if (UserUIContext.getMessage(FileI18nEnum.EXCEL).equals(exportTypeVal)) {
                exportType = ReportExportType.EXCEL;
            } else {
                exportType = ReportExportType.PDF;
            }
            return exportType.getDefaultFileName();
        }
    });
    pdfFileDownloader.extend(exportBtn);

    MHorizontalLayout buttonControls = new MHorizontalLayout(resetBtn, cancelBtn, exportBtn);
    contentLayout.with(buttonControls).withAlign(buttonControls, Alignment.TOP_RIGHT);
}

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

License:Open Source License

private CustomLayout createTopMenu() {
    headerLayout = CustomLayoutExt.createLayout("topNavigation");
    headerLayout.setStyleName("topNavigation");
    headerLayout.setHeight("45px");
    headerLayout.setWidth("100%");

    final PopupButton modulePopup = new PopupButton("");
    modulePopup.setIcon(/*from  w  w w  .java 2s.  c o  m*/
            AccountAssetsResolver.createLogoResource(MyCollabUI.getBillingAccount().getLogopath(), 150));
    modulePopup.setHeightUndefined();
    modulePopup.setDirection(Alignment.BOTTOM_LEFT);
    OptionPopupContent modulePopupContent = new OptionPopupContent();
    modulePopup.setContent(modulePopupContent);

    MButton projectModuleBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.MODULE_PROJECT),
            clickEvent -> {
                modulePopup.setPopupVisible(false);
                EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null));
            }).withIcon(VaadinIcons.TASKS);
    modulePopupContent.addOption(projectModuleBtn);

    MButton crmModuleBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.MODULE_CRM), clickEvent -> {
        modulePopup.setPopupVisible(false);
        EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null));
    }).withIcon(VaadinIcons.MONEY);
    modulePopupContent.addOption(crmModuleBtn);

    /*MButton fileModuleBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.MODULE_DOCUMENT), clickEvent -> {
    modulePopup.setPopupVisible(false);
    EventBusFactory.getInstance().post(new ShellEvent.GotoFileModule(this, null));
    }).withIcon(VaadinIcons.SUITCASE);
    modulePopupContent.addOption(fileModuleBtn);*/

    MButton peopleBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.MODULE_PEOPLE), clickEvent -> {
        modulePopup.setPopupVisible(false);
        EventBusFactory.getInstance()
                .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "user", "list" }));
    }).withIcon(VaadinIcons.USERS);
    modulePopupContent.addOption(peopleBtn);

    headerLayout.addComponent(
            new MHorizontalLayout(modulePopup).alignAll(Alignment.MIDDLE_LEFT).withFullHeight(), "mainLogo");

    accountLayout = new MHorizontalLayout().withMargin(new MarginInfo(false, true, false, false))
            .withHeight("45px");
    accountLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    buildAccountMenuLayout();

    headerLayout.addComponent(accountLayout, "accountMenu");
    return headerLayout;
}