Java Code Examples for org.vaadin.viritin.layouts.MVerticalLayout#with()

The following examples show how to use org.vaadin.viritin.layouts.MVerticalLayout#with() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ProjectViewImpl.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
AskToAddMoreMembersWindow() {
    super(UserUIContext.getMessage(GenericI18Enum.OPT_QUESTION));
    MVerticalLayout content = new MVerticalLayout();
    this.withWidth("600px").withResizable(false).withModal(true).withContent(content).withCenter();

    content.with(new Label(UserUIContext.getMessage(ProjectI18nEnum.OPT_ASK_TO_ADD_MEMBERS)));

    MButton skipBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.ACTION_SKIP), clickEvent -> {
        ProjectService projectService = AppContextUtil.getSpringBean(ProjectService.class);
        SimpleProject project = CurrentProjectVariables.getProject();
        project.setContextask(false);
        projectService.updateSelectiveWithSession(project, UserUIContext.getUsername());
        close();
    }).withStyleName(WebThemes.BUTTON_OPTION);

    MButton addNewMembersBtn = new MButton(UserUIContext.getMessage(ProjectI18nEnum.ACTION_ADD_MEMBERS), clickEvent -> {
        close();
        EventBusFactory.getInstance().post(new ProjectMemberEvent.GotoInviteMembers(this, null));
    }).withStyleName(WebThemes.BUTTON_ACTION);

    MHorizontalLayout btnControls = new MHorizontalLayout(skipBtn, addNewMembersBtn);
    content.with(btnControls).withAlign(btnControls, Alignment.MIDDLE_RIGHT);
}
 
Example 2
Source File: MilestoneReadViewImpl.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void initRelatedComponents() {
    activityComponent = new ProjectActivityComponent(ProjectTypeConstants.MILESTONE, CurrentProjectVariables.getProjectId());
    dateInfoComp = new DateInfoComp();
    peopleInfoComp = new PeopleInfoComp();
    planningInfoComp = new PlanningInfoComp();

    ProjectView projectView = UIUtils.getRoot(this, ProjectView.class);
    MVerticalLayout detailLayout = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, true));
    if (SiteConfiguration.isCommunityEdition()) {
        detailLayout.with(peopleInfoComp, planningInfoComp, dateInfoComp);
    } else {
        milestoneTimeLogComp = new MilestoneTimeLogComp();
        detailLayout.with(peopleInfoComp, planningInfoComp, milestoneTimeLogComp, dateInfoComp);
    }

    Panel detailPanel = new Panel(UserUIContext.getMessage(GenericI18Enum.OPT_DETAILS), detailLayout);
    UIUtils.makeStackPanel(detailPanel);
    projectView.addComponentToRightBar(detailPanel);
}
 
Example 3
Source File: BugReadViewImpl.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void initRelatedComponents() {
    activityComponent = new ProjectActivityComponent(ProjectTypeConstants.BUG, CurrentProjectVariables.getProjectId());
    dateInfoComp = new DateInfoComp();
    peopleInfoComp = new PeopleInfoComp();
    planningInfoComp = new PlanningInfoComp();
    bugFollowersList = new ProjectFollowersComp<>(ProjectTypeConstants.BUG, ProjectRolePermissionCollections.BUGS);

    ProjectView projectView = UIUtils.getRoot(this, ProjectView.class);
    MVerticalLayout detailLayout = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, true));

    if (SiteConfiguration.isCommunityEdition()) {
        detailLayout.with(peopleInfoComp, planningInfoComp, bugFollowersList, dateInfoComp);
    } else {
        bugTimeLogList = ViewManager.getCacheComponent(BugTimeLogSheet.class);
        detailLayout.with(peopleInfoComp, planningInfoComp, bugTimeLogList, bugFollowersList, dateInfoComp);
    }

    Panel detailPanel = new Panel(UserUIContext.getMessage(GenericI18Enum.OPT_DETAILS), detailLayout);
    UIUtils.makeStackPanel(detailPanel);
    projectView.addComponentToRightBar(detailPanel);
}
 
Example 4
Source File: ComponentReadViewImpl.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void initRelatedComponents() {
    activityComponent = new ProjectActivityComponent(ProjectTypeConstants.COMPONENT, CurrentProjectVariables.getProjectId());
    dateInfoComp = new DateInfoComp();
    peopleInfoComp = new PeopleInfoComp();

    ProjectView projectView = UIUtils.getRoot(this, ProjectView.class);
    MVerticalLayout detailLayout = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, true));

    if (SiteConfiguration.isCommunityEdition()) {
        detailLayout.with(dateInfoComp, peopleInfoComp);
    } else {
        componentTimeLogComp = new ComponentTimeLogComp();
        detailLayout.with(dateInfoComp, peopleInfoComp, componentTimeLogComp);
    }

    Panel detailPanel = new Panel(UserUIContext.getMessage(GenericI18Enum.OPT_DETAILS), detailLayout);
    UIUtils.makeStackPanel(detailPanel);
    projectView.addComponentToRightBar(detailPanel);
}
 
Example 5
Source File: GeneralSettingViewImpl.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
private void buildLanguageUpdatePanel() {
    FormContainer formContainer = new FormContainer();
    MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withMargin(new MarginInfo(true, false, true, false));
    MVerticalLayout leftPanel = new MVerticalLayout().withMargin(false);
    ELabel languageDownloadDesc = ELabel.html(UserUIContext.getMessage(ShellI18nEnum.OPT_LANGUAGE_DOWNLOAD)).withFullWidth();
    leftPanel.with(languageDownloadDesc).withWidth("250px");
    MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false);
    MButton downloadBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_DOWNLOAD))
            .withStyleName(WebThemes.BUTTON_ACTION).withIcon(VaadinIcons.DOWNLOAD);
    ServerConfiguration serverConfiguration = AppContextUtil.getSpringBean(ServerConfiguration.class);
    BrowserWindowOpener opener = new BrowserWindowOpener(serverConfiguration.getApiUrl("localization/translations"));
    opener.extend(downloadBtn);
    rightPanel.with(downloadBtn, new ELabel(UserUIContext.getMessage(ShellI18nEnum.OPT_UPDATE_LANGUAGE_INSTRUCTION))
            .withStyleName(WebThemes.META_INFO).withFullWidth());
    layout.with(leftPanel, rightPanel).expand(rightPanel);
    formContainer.addSection("Languages", layout);
    this.with(formContainer);
}
 
Example 6
Source File: TaskReadViewImpl.java    From mycollab with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
protected void initRelatedComponents() {
    activityComponent = new ProjectActivityComponent(ProjectTypeConstants.TASK, CurrentProjectVariables.getProjectId());
    dateInfoComp = new DateInfoComp();
    peopleInfoComp = new PeopleInfoComp();
    followerSheet = new ProjectFollowersComp<>(ProjectTypeConstants.TASK, ProjectRolePermissionCollections.TASKS);
    planningInfoComp = new PlanningInfoComp();

    ProjectView projectView = UIUtils.getRoot(this, ProjectView.class);
    MVerticalLayout detailLayout = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, true));
    if (SiteConfiguration.isCommunityEdition()) {
        detailLayout.with(peopleInfoComp, planningInfoComp, followerSheet, dateInfoComp);
    } else {
        timeLogComp = ViewManager.getCacheComponent(TaskTimeLogSheet.class);
        detailLayout.with(peopleInfoComp, planningInfoComp, timeLogComp, followerSheet, dateInfoComp);
    }

    Panel detailPanel = new Panel(UserUIContext.getMessage(GenericI18Enum.OPT_DETAILS), detailLayout);
    UIUtils.makeStackPanel(detailPanel);
    projectView.addComponentToRightBar(detailPanel);
}
 
Example 7
Source File: UpgradeConfirmWindow.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
public UpgradeConfirmWindow(final String version, String manualDownloadLink, final String installerFilePath) {
    super(UserUIContext.getMessage(ShellI18nEnum.OPT_NEW_UPGRADE_IS_READY));
    this.withModal(true).withResizable(false).withCenter().withWidth("600px");
    this.installerFilePath = installerFilePath;

    currentUI = UI.getCurrent();

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

    Div titleDiv = new Div().appendText(UserUIContext.getMessage(ShellI18nEnum.OPT_REQUEST_UPGRADE, version)).setStyle("font-weight:bold");
    content.with(ELabel.html(titleDiv.write()));

    Div manualInstallLink = new Div().appendText("&nbsp;&nbsp;&nbsp;&nbsp;" + UserUIContext.getMessage(ShellI18nEnum.OPT_MANUAL_INSTALL) + ": ")
            .appendChild(new A(manualDownloadLink, "_blank")
                    .appendText(UserUIContext.getMessage(ShellI18nEnum.OPT_DOWNLOAD_LINK)));
    content.with(ELabel.html(manualInstallLink.write()));

    Div manualUpgradeHowtoLink = new Div().appendText("&nbsp;&nbsp;&nbsp;&nbsp;" + UserUIContext.getMessage(ShellI18nEnum.OPT_MANUAL_UPGRADE) + ": ")
            .appendChild(new A("https://docs.mycollab.com/administration/upgrade-mycollab-automatically/", "_blank").appendText("Link"));
    content.with(ELabel.html(manualUpgradeHowtoLink.write()));

    Div releaseNoteLink = new Div().appendText("&nbsp;&nbsp;&nbsp;&nbsp;" + UserUIContext.getMessage(ShellI18nEnum.OPT_RELEASE_NOTES) + ": ")
            .appendChild(new A("https://docs.mycollab.com/administration/hosting-mycollab-on-your-own-server/releases/", "_blank").appendText("Link"));
    content.with(ELabel.html(releaseNoteLink.write()));

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

    MButton autoUpgradeBtn = new MButton(UserUIContext.getMessage(ShellI18nEnum.ACTION_AUTO_UPGRADE), clickEvent -> {
        close();
        navigateToWaitingUpgradePage();
    }).withStyleName(WebThemes.BUTTON_ACTION);
    if (installerFilePath == null) {
        autoUpgradeBtn.setEnabled(false);
    }

    MHorizontalLayout buttonControls = new MHorizontalLayout(skipBtn, autoUpgradeBtn).withMargin(true);
    content.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT);
}
 
Example 8
Source File: TicketComponentFactoryImpl.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
NewTicketWindow(LocalDate date, Integer projectId, Integer milestoneId, boolean isIncludeMilestone) {
    super(UserUIContext.getMessage(TicketI18nEnum.NEW));
    this.isIncludeMilestone = isIncludeMilestone;
    this.addStyleName(WebThemes.NO_SCROLLABLE_CONTAINER);
    MVerticalLayout content = new MVerticalLayout();
    withModal(true).withResizable(false).withCenter().withWidth(WebThemes.WINDOW_FORM_WIDTH).withContent(content);

    UserProjectComboBox projectListSelect = new UserProjectComboBox();
    projectListSelect.setEmptySelectionAllowed(false);
    selectedProject = projectListSelect.setSelectedProjectById(projectId);

    typeSelection = new ComboBox<>();
    typeSelection.setWidth(WebThemes.FORM_CONTROL_WIDTH);
    typeSelection.setEmptySelectionAllowed(false);

    projectListSelect.addValueChangeListener(valueChangeEvent -> {
        selectedProject = projectListSelect.getValue();
        loadAssociateTicketTypePerProject();
    });

    loadAssociateTicketTypePerProject();
    typeSelection.addValueChangeListener(event -> doChange(date, milestoneId));

    GridFormLayoutHelper formLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(LayoutType.TWO_COLUMN);
    formLayoutHelper.addComponent(projectListSelect, UserUIContext.getMessage(ProjectI18nEnum.SINGLE), 0, 0);
    formLayoutHelper.addComponent(typeSelection, UserUIContext.getMessage(GenericI18Enum.FORM_TYPE), 1, 0);
    formLayoutHelper.getLayout().addStyleName(WebThemes.BORDER_BOTTOM);

    formLayout = new MCssLayout().withFullWidth();
    content.with(formLayoutHelper.getLayout(), formLayout);
    doChange(date, milestoneId);
}
 
Example 9
Source File: ProjectMemberInvitePresenter.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
private void displayInfo(InviteMembers invitation) {
    Div infoDiv = new Div().appendText(UserUIContext.getMessage(ProjectMemberI18nEnum.OPT_NO_SMTP_SEND_MEMBERS))
            .setStyle("font-weight:bold;color:red");
    contentLayout.with(ELabel.html(infoDiv.write()));

    Div introDiv = new Div().appendText("Below users are invited to the project ")
            .appendChild(new B().appendText(CurrentProjectVariables.getProject().getName()))
            .appendText(" as role ").appendChild(new B().appendText(invitation.getRoleName()));
    contentLayout.with(ELabel.html(introDiv.write()));

    MVerticalLayout linksContainer = new MVerticalLayout().withStyleName(WebThemes.SCROLLABLE_CONTAINER);
    contentLayout.with(linksContainer);

    Collection<String> inviteEmails = invitation.getEmails();
    for (String inviteEmail : inviteEmails) {
        Div userEmailDiv = new Div().appendText(String.format("&nbsp;&nbsp;&nbsp;&nbsp;%s %s: ", VaadinIcons.PAPERPLANE.getHtml(),
                UserUIContext.getMessage(GenericI18Enum.FORM_EMAIL))).appendChild(new A().setHref("mailto:" + inviteEmail)
                .appendText(inviteEmail));
        linksContainer.with(ELabel.html(userEmailDiv.write()), ELabel.hr());
    }

    MButton addNewBtn = new MButton(UserUIContext.getMessage(ProjectMemberI18nEnum.ACTION_INVITE_MORE_MEMBERS), clickEvent -> {
        EventBusFactory.getInstance().post(new ProjectMemberEvent.GotoInviteMembers(CanSendEmailInstructionWindow.this, null));
        close();
    }).withStyleName(WebThemes.BUTTON_ACTION);

    MButton doneBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.ACTION_DONE), clickEvent -> {
        EventBusFactory.getInstance().post(new ProjectMemberEvent.GotoList(this, CurrentProjectVariables.getProjectId()));
        close();
    }).withStyleName(WebThemes.BUTTON_ACTION);

    MHorizontalLayout controlsBtn = new MHorizontalLayout(addNewBtn, doneBtn).withMargin(true);
    contentLayout.with(controlsBtn).withAlign(controlsBtn, Alignment.MIDDLE_RIGHT);
}
 
Example 10
Source File: NewUserAddedWindow.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
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);

    ELabel infoLbl = ELabel.html(VaadinIcons.CHECK_CIRCLE.getHtml() + UserUIContext.getMessage(UserI18nEnum.OPT_NEW_USER_CREATED,
            user.getDisplayName()));
    content.with(infoLbl);

    String signinInstruction = UserUIContext.getMessage(UserI18nEnum.OPT_SIGN_IN_MSG, AppUI.getSiteUrl(), AppUI.getSiteUrl());
    content.with(new MVerticalLayout(ELabel.html(signinInstruction),
            new ELabel(UserUIContext.getMessage(GenericI18Enum.FORM_EMAIL)).withStyleName(WebThemes.META_INFO),
            new Label("    " + user.getUsername()),
            new ELabel(UserUIContext.getMessage(ShellI18nEnum.FORM_PASSWORD)).withStyleName(WebThemes.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
            (WebThemes.META_INFO).withFullWidth());

    MButton createMoreUserBtn = new MButton(UserUIContext.getMessage(UserI18nEnum.OPT_CREATE_ANOTHER_USER), clickEvent -> {
        EventBusFactory.getInstance().post(new UserEvent.GotoAdd(this, null));
        close();
    }).withStyleName(WebThemes.BUTTON_LINK);

    MButton doneBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.ACTION_DONE), clickEvent -> {
        EventBusFactory.getInstance().post(new UserEvent.GotoList(this, null));
        close();
    }).withStyleName(WebThemes.BUTTON_ACTION);

    MHorizontalLayout buttonControls = new MHorizontalLayout(createMoreUserBtn, doneBtn).withFullWidth()
            .withAlign(createMoreUserBtn, Alignment.MIDDLE_LEFT).withAlign(doneBtn, Alignment.MIDDLE_RIGHT);
    content.with(buttonControls);
}
 
Example 11
Source File: PageReadViewImpl.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
void displayPageInfo(Page beanItem) {
    MVerticalLayout header = new MVerticalLayout().withMargin(false);
    ELabel titleLbl = ELabel.h3(beanItem.getSubject());
    header.with(titleLbl);
    Div footer = new Div().setStyle("width:100%").setCSSClass(WebThemes.META_INFO);
    Span lastUpdatedTimeTxt = new Span().appendText(UserUIContext.getMessage(DayI18nEnum.LAST_UPDATED_ON,
            UserUIContext.formatPrettyTime(DateTimeUtils.toLocalDateTime(beanItem.getLastUpdatedTime()))))
            .setTitle(UserUIContext.formatDateTime(DateTimeUtils.toLocalDateTime(beanItem.getLastUpdatedTime())));

    ProjectMemberService projectMemberService = AppContextUtil.getSpringBean(ProjectMemberService.class);
    SimpleProjectMember member = projectMemberService.findMemberByUsername(beanItem.getCreatedUser(),
            CurrentProjectVariables.getProjectId(), AppUI.getAccountId());
    if (member != null) {
        Img userAvatar = new Img("", StorageUtils.getAvatarPath(member.getMemberAvatarId(), 16))
                .setCSSClass(WebThemes.CIRCLE_BOX);
        A userLink = new A().setId("tag" + TooltipHelper.TOOLTIP_ID).
                setHref(ProjectLinkGenerator.generateProjectMemberLink(member.getProjectid(),
                        member.getUsername())).
                appendText(StringUtils.trim(member.getMemberFullName(), 30, true));
        userLink.setAttribute("onmouseover", TooltipHelper.userHoverJsFunction(member.getUsername()));
        userLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction());
        footer.appendChild(lastUpdatedTimeTxt, new Text("&nbsp;-&nbsp;" + UserUIContext.getMessage
                        (GenericI18Enum.OPT_CREATED_BY) + ": "), userAvatar,
                DivLessFormatter.EMPTY_SPACE, userLink, DivLessFormatter.EMPTY_SPACE);
    } else {
        footer.appendChild(lastUpdatedTimeTxt);
    }

    header.addComponent(ELabel.html(footer.write()));
    this.addHeader(header);
}
 
Example 12
Source File: GeneralSettingViewImpl.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
private void buildShortcutIconPanel() {
    FormContainer formContainer = new FormContainer();
    MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withMargin(new MarginInfo(true, false, true, false));
    MVerticalLayout leftPanel = new MVerticalLayout().withMargin(false);
    ELabel logoDesc = ELabel.html(UserUIContext.getMessage(FileI18nEnum.OPT_FAVICON_FORMAT_DESCRIPTION)).withFullWidth();
    leftPanel.with(logoDesc).withWidth("250px");
    MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false);
    final Image favIconRes = new Image("", new ExternalResource(StorageUtils.getFavIconPath(billingAccount.getId(),
            billingAccount.getFaviconpath())));

    MHorizontalLayout buttonControls = new MHorizontalLayout().withMargin(new MarginInfo(true, false, false, false));
    buttonControls.setDefaultComponentAlignment(Alignment.BOTTOM_LEFT);
    final UploadField favIconUploadField = new UploadField() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void updateDisplayComponent() {
            byte[] imageData = this.getValue();
            String mimeType = this.getLastMimeType();
            if (mimeType.equals("image/jpeg")) {
                imageData = ImageUtil.convertJpgToPngFormat(imageData);
                if (imageData == null) {
                    throw new UserInvalidInputException(UserUIContext.getMessage(FileI18nEnum.ERROR_INVALID_SUPPORTED_IMAGE_FORMAT));
                } else {
                    mimeType = "image/png";
                }
            }

            if (mimeType.equals("image/png")) {
                try {
                    AccountFavIconService favIconService = AppContextUtil.getSpringBean(AccountFavIconService.class);
                    BufferedImage image = ImageIO.read(new ByteArrayInputStream(imageData));
                    String newFavIconPath = favIconService.upload(UserUIContext.getUsername(), image, AppUI.getAccountId());
                    favIconRes.setSource(new ExternalResource(StorageUtils.getFavIconPath(billingAccount.getId(),
                            newFavIconPath)));
                    UIUtils.reloadPage();
                } catch (IOException e) {
                    throw new MyCollabException(e);
                }
            } else {
                throw new UserInvalidInputException(UserUIContext.getMessage(FileI18nEnum.ERROR_UPLOAD_INVALID_SUPPORTED_IMAGE_FORMAT));
            }
        }
    };
    favIconUploadField.setButtonCaption(UserUIContext.getMessage(GenericI18Enum.ACTION_CHANGE));
    favIconUploadField.addStyleName("upload-field");
    favIconUploadField.setSizeUndefined();
    favIconUploadField.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME));

    MButton resetButton = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_RESET), clickEvent -> {
        BillingAccountService billingAccountService = AppContextUtil.getSpringBean(BillingAccountService.class);
        billingAccount.setFaviconpath(null);
        billingAccountService.updateWithSession(billingAccount, UserUIContext.getUsername());
        UIUtils.reloadPage();
    }).withStyleName(WebThemes.BUTTON_OPTION);
    resetButton.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME));

    buttonControls.with(resetButton, favIconUploadField);
    rightPanel.with(favIconRes, buttonControls);
    layout.with(leftPanel, rightPanel).expand(rightPanel);
    formContainer.addSection("Favicon", layout);
    this.with(formContainer);
}
 
Example 13
Source File: GeneralSettingViewImpl.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
private void buildLogoPanel() {
    FormContainer formContainer = new FormContainer();
    MHorizontalLayout layout = new MHorizontalLayout().withFullWidth().withMargin(new MarginInfo(true, false, true, false));
    MVerticalLayout leftPanel = new MVerticalLayout().withMargin(false);
    ELabel logoDesc = ELabel.html(UserUIContext.getMessage(AdminI18nEnum.OPT_LOGO_FORMAT_DESCRIPTION)).withFullWidth();
    leftPanel.with(logoDesc).withWidth("250px");

    MVerticalLayout rightPanel = new MVerticalLayout().withMargin(false);
    CustomLayout previewLayout = CustomLayoutExt.createLayout("topNavigation");
    previewLayout.setStyleName("example-block");
    previewLayout.setHeight("40px");
    previewLayout.setWidth("520px");

    Button currentLogo = AccountAssetsResolver.createAccountLogoImageComponent(billingAccount.getLogopath(), 150);
    previewLayout.addComponent(currentLogo, "mainLogo");
    final ServiceMenu serviceMenu = new ServiceMenu();

    Button.ClickListener clickListener = new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(final Button.ClickEvent event) {

            for (Component comp : serviceMenu) {
                if (comp != event.getButton()) {
                    comp.removeStyleName("selected");
                }
            }
            event.getButton().addStyleName("selected");
        }
    };

    serviceMenu.addService(UserUIContext.getMessage(GenericI18Enum.MODULE_CRM), VaadinIcons.MONEY, clickListener);
    serviceMenu.addService(UserUIContext.getMessage(GenericI18Enum.MODULE_PROJECT), VaadinIcons.TASKS, clickListener);
    serviceMenu.addService(UserUIContext.getMessage(GenericI18Enum.MODULE_DOCUMENT), VaadinIcons.SUITCASE, clickListener);
    serviceMenu.selectService(0);

    previewLayout.addComponent(serviceMenu, "serviceMenu");

    MHorizontalLayout buttonControls = new MHorizontalLayout().withMargin(new MarginInfo(true, false, false, false));
    buttonControls.setDefaultComponentAlignment(Alignment.TOP_LEFT);
    final UploadField logoUploadField = new UploadField() {
        private static final long serialVersionUID = 1L;

        @Override
        protected void updateDisplayComponent() {
            byte[] imageData = this.getValue();
            String mimeType = this.getLastMimeType();
            if (mimeType.equals("image/jpeg")) {
                imageData = ImageUtil.convertJpgToPngFormat(imageData);
                if (imageData == null) {
                    throw new UserInvalidInputException(UserUIContext.getMessage(FileI18nEnum.ERROR_INVALID_SUPPORTED_IMAGE_FORMAT));
                } else {
                    mimeType = "image/png";
                }
            }

            if (mimeType.equals("image/png")) {
                UI.getCurrent().addWindow(new LogoEditWindow(imageData));
            } else {
                throw new UserInvalidInputException(UserUIContext.getMessage(FileI18nEnum.ERROR_UPLOAD_INVALID_SUPPORTED_IMAGE_FORMAT));
            }
        }
    };
    logoUploadField.setButtonCaption(UserUIContext.getMessage(GenericI18Enum.ACTION_CHANGE));
    logoUploadField.addStyleName("upload-field");
    logoUploadField.setSizeUndefined();
    logoUploadField.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME));

    MButton resetButton = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_RESET), clickEvent -> {
        BillingAccountService billingAccountService = AppContextUtil.getSpringBean(BillingAccountService.class);
        billingAccount.setLogopath(null);
        billingAccountService.updateWithSession(billingAccount, UserUIContext.getUsername());
        UIUtils.reloadPage();
    }).withStyleName(WebThemes.BUTTON_OPTION);
    resetButton.setVisible(UserUIContext.canBeYes(RolePermissionCollections.ACCOUNT_THEME));

    buttonControls.with(resetButton, logoUploadField);
    rightPanel.with(previewLayout, buttonControls);
    layout.with(leftPanel, rightPanel).expand(rightPanel);
    formContainer.addSection("Logo", layout);
    this.with(formContainer);
}
 
Example 14
Source File: GenericItemRowDisplayHandler.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Component generateRow(IBeanList<ProjectGenericItem> host, ProjectGenericItem item, int rowIndex) {
    MVerticalLayout layout = new MVerticalLayout().withFullWidth().withStyleName(WebThemes.BORDER_BOTTOM, WebThemes.HOVER_EFFECT_NOT_BOX);
    ELabel link = ELabel.h3("").withFullWidth();
    if (item.isBug() || item.isTask()) {
        link.setValue(ProjectLinkBuilder.generateProjectItemHtmlLinkAndTooltip(item.getProjectShortName(),
                item.getProjectId(), item.getName(), item.getType(), item.getExtraTypeId() + ""));
    } else {
        link.setValue(ProjectLinkBuilder.generateProjectItemHtmlLinkAndTooltip(item.getProjectShortName(),
                item.getProjectId(), item.getName(), item.getType(), item.getTypeId()));
    }

    String desc = (StringUtils.isBlank(item.getDescription())) ? UserUIContext.getMessage(GenericI18Enum.OPT_UNDEFINED) :
            item.getDescription();
    SafeHtmlLabel descLbl = new SafeHtmlLabel(desc);

    Div div = new Div().setStyle("width:100%");
    Text createdByTxt = new Text(UserUIContext.getMessage(GenericI18Enum.OPT_CREATED_BY) + ": ");
    Div lastUpdatedOn = new Div().appendChild(new Text(UserUIContext.getMessage(GenericI18Enum.OPT_LAST_MODIFIED,
            UserUIContext.formatPrettyTime(item.getLastUpdatedTime()))))
            .setTitle(UserUIContext.formatDateTime(item.getLastUpdatedTime())).setStyle("float:right;margin-right:5px");

    if (StringUtils.isBlank(item.getCreatedUser())) {
        div.appendChild(createdByTxt, DivLessFormatter.EMPTY_SPACE, new Text(UserUIContext.getMessage(GenericI18Enum.OPT_UNDEFINED)),
                lastUpdatedOn);
    } else {
        Img userAvatar = new Img("", StorageUtils.getAvatarPath(item.getCreatedUserAvatarId(), 16))
                .setCSSClass(WebThemes.CIRCLE_BOX);
        A userLink = new A().setId("tag" + TooltipHelper.TOOLTIP_ID).setHref(ProjectLinkGenerator.generateProjectMemberLink(item.getProjectId(), item
                .getCreatedUser())).appendText(item.getCreatedUserDisplayName());
        userLink.setAttribute("onmouseover", TooltipHelper.userHoverJsFunction(item.getCreatedUser()));
        userLink.setAttribute("onmouseleave", TooltipHelper.itemMouseLeaveJsFunction());

        div.appendChild(createdByTxt, DivLessFormatter.EMPTY_SPACE, userAvatar, DivLessFormatter.EMPTY_SPACE,
                userLink, lastUpdatedOn);
    }

    ELabel footer = ELabel.html(div.write()).withStyleName(WebThemes.META_INFO).withFullWidth();
    layout.with(link, descLbl, footer);
    return layout;
}
 
Example 15
Source File: ProjectActivityComponent.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
private Component buildCommentBlock(final SimpleComment comment) {
    MHorizontalLayout layout = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false))
            .withFullWidth();

    ProjectMemberBlock memberBlock = new ProjectMemberBlock(comment.getCreateduser(), comment.getOwnerAvatarId(),
            comment.getOwnerFullName());
    layout.addComponent(memberBlock);

    MVerticalLayout rowLayout = new MVerticalLayout().withFullWidth().withStyleName(WebThemes.MESSAGE_CONTAINER);

    MHorizontalLayout messageHeader = new MHorizontalLayout().withFullWidth();
    messageHeader.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    ELabel timePostLbl = ELabel.html(UserUIContext.getMessage(GenericI18Enum.EXT_ADDED_COMMENT, comment.getOwnerFullName(),
            UserUIContext.formatPrettyTime(comment.getCreatedtime())))
            .withDescription(UserUIContext.formatDateTime(comment.getCreatedtime()))
            .withStyleName(WebThemes.META_INFO);

    if (hasDeletePermission(comment)) {
        MButton msgDeleteBtn = new MButton(VaadinIcons.TRASH).withListener(clickEvent -> {
            ConfirmDialogExt.show(UI.getCurrent(),
                    UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, AppUI.getSiteName()),
                    UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                    UserUIContext.getMessage(GenericI18Enum.ACTION_YES),
                    UserUIContext.getMessage(GenericI18Enum.ACTION_NO),
                    confirmDialog -> {
                        if (confirmDialog.isConfirmed()) {
                            CommentService commentService = AppContextUtil.getSpringBean(CommentService.class);
                            commentService.removeWithSession(comment, UserUIContext.getUsername(), AppUI.getAccountId());
                            activityBox.removeComponent(layout);
                        }
                    });
        }).withStyleName(WebThemes.BUTTON_ICON_ONLY);
        messageHeader.with(timePostLbl, msgDeleteBtn).expand(timePostLbl);
    } else {
        messageHeader.with(timePostLbl).expand(timePostLbl);
    }

    rowLayout.addComponent(messageHeader);

    Label messageContent = new SafeHtmlLabel(comment.getComment());
    rowLayout.addComponent(messageContent);

    List<Content> attachments = comment.getAttachments();
    if (!CollectionUtils.isEmpty(attachments)) {
        MVerticalLayout messageFooter = new MVerticalLayout().withMargin(false).withSpacing(false).withFullWidth();
        AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments);
        attachmentDisplay.setWidth("100%");
        messageFooter.with(attachmentDisplay);
        rowLayout.addComponent(messageFooter);
    }

    layout.with(rowLayout).expand(rowLayout);
    return layout;
}
 
Example 16
Source File: PageListViewImpl.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
private Layout displayPageBlock(final Page resource) {
    MVerticalLayout container = new MVerticalLayout().withFullWidth().withStyleName("page-item-block");
    A pageHtml = new A(ProjectLinkGenerator.generatePageRead(CurrentProjectVariables.getProjectId(), resource
            .getPath())).appendText(VaadinIcons.FILE_TEXT.getHtml() + " " + resource.getSubject());
    ELabel pageLink = ELabel.h3(pageHtml.write());

    container.with(pageLink, new SafeHtmlLabel(resource.getContent(), 400));

    Label lastUpdateInfo = ELabel.html(UserUIContext.getMessage(
            PageI18nEnum.LABEL_LAST_UPDATE, ProjectLinkBuilder.generateProjectMemberHtmlLink(
                    CurrentProjectVariables.getProjectId(), resource.getLastUpdatedUser(), true),
            UserUIContext.formatPrettyTime(DateTimeUtils.toLocalDateTime(resource.getLastUpdatedTime()))))
            .withDescription(UserUIContext.formatDateTime(DateTimeUtils.toLocalDateTime(resource.getLastUpdatedTime())))
            .withStyleName(WebThemes.META_INFO);
    container.addComponent(lastUpdateInfo);

    MButton editBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_EDIT),
            clickEvent -> EventBusFactory.getInstance().post(new PageEvent.GotoEdit(PageListViewImpl.this, resource)))
            .withIcon(VaadinIcons.EDIT).withStyleName(WebThemes.BUTTON_LINK, WebThemes.BUTTON_SMALL_PADDING)
            .withVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.PAGES));

    MButton deleteBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_DELETE), clickEvent -> {
        ConfirmDialogExt.show(UI.getCurrent(),
                UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, AppUI.getSiteName()),
                UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                UserUIContext.getMessage(GenericI18Enum.ACTION_YES),
                UserUIContext.getMessage(GenericI18Enum.ACTION_NO),
                confirmDialog -> {
                    if (confirmDialog.isConfirmed()) {
                        PageService pageService = AppContextUtil.getSpringBean(PageService.class);
                        pageService.removeResource(resource.getPath());
                        resources.remove(resource);
                        displayPages(resources);
                    }
                });
    }).withIcon(VaadinIcons.TRASH).withStyleName(WebThemes.BUTTON_LINK, WebThemes.BUTTON_SMALL_PADDING)
            .withVisible(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.PAGES));

    container.addComponent(new MHorizontalLayout(editBtn, deleteBtn));
    return container;
}
 
Example 17
Source File: ProjectMemberListViewImpl.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
private Component generateMemberBlock(final SimpleProjectMember member) {
    MHorizontalLayout blockContent = new MHorizontalLayout().withSpacing(false).withStyleName("member-block").withWidth("350px");
    if (ProjectMemberStatusConstants.NOT_ACCESS_YET.equals(member.getStatus())) {
        blockContent.addStyleName("inactive");
    }

    Image memberAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(member.getMemberAvatarId(), 100);
    memberAvatar.addStyleName(WebThemes.CIRCLE_BOX);
    memberAvatar.setWidthUndefined();
    blockContent.addComponent(memberAvatar);

    MVerticalLayout blockTop = new MVerticalLayout().withMargin(new MarginInfo(false, false, false, true)).withFullWidth();

    MButton editBtn = new MButton("", clickEvent -> EventBusFactory.getInstance().post(new ProjectMemberEvent.GotoEdit(this, member)))
            .withIcon(VaadinIcons.EDIT).withStyleName(WebThemes.BUTTON_LINK)
            .withVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS));
    editBtn.setDescription("Edit user '" + member.getDisplayName() + "' information");

    MButton deleteBtn = new MButton("", clickEvent -> {
        ConfirmDialogExt.show(UI.getCurrent(),
                UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, AppUI.getSiteName()),
                UserUIContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                UserUIContext.getMessage(GenericI18Enum.ACTION_YES),
                UserUIContext.getMessage(GenericI18Enum.ACTION_NO),
                confirmDialog -> {
                    if (confirmDialog.isConfirmed()) {
                        ProjectMemberService prjMemberService = AppContextUtil.getSpringBean(ProjectMemberService.class);
                        prjMemberService.removeWithSession(member, UserUIContext.getUsername(), AppUI.getAccountId());
                        EventBusFactory.getInstance().post(new ProjectMemberEvent.GotoList(ProjectMemberListViewImpl.this, CurrentProjectVariables.getProjectId()));
                    }
                });
    }).withIcon(VaadinIcons.TRASH).withStyleName(WebThemes.BUTTON_LINK)
            .withVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.USERS))
            .withDescription("Remove user '" + member.getDisplayName() + "' out of this project");

    MHorizontalLayout buttonControls = new MHorizontalLayout(editBtn, deleteBtn);
    blockTop.addComponent(buttonControls);
    blockTop.setComponentAlignment(buttonControls, Alignment.TOP_RIGHT);

    A memberLink = new A(ProjectLinkGenerator.generateProjectMemberLink(member.getProjectid(), member
            .getUsername())).appendText(member.getMemberFullName()).setTitle(member.getMemberFullName());
    ELabel memberNameLbl = ELabel.h3(memberLink.write()).withStyleName(WebThemes.TEXT_ELLIPSIS).withFullWidth();

    blockTop.with(memberNameLbl, ELabel.hr());

    A roleLink = new A(ProjectLinkGenerator.generateRolePreviewLink(member.getProjectid(), member.getProjectroleid()))
            .appendText(member.getRoleName());
    blockTop.addComponent(ELabel.html(roleLink.write()).withFullWidth().withStyleName(WebThemes.TEXT_ELLIPSIS));

    if (Boolean.TRUE.equals(AppUI.showEmailPublicly())) {
        Label memberEmailLabel = ELabel.html(String.format("<a href='mailto:%s'>%s</a>", member.getUsername(), member.getUsername()))
                .withStyleName(WebThemes.META_INFO).withFullWidth();
        blockTop.addComponent(memberEmailLabel);
    }

    ELabel memberSinceLabel = ELabel.html(UserUIContext.getMessage(UserI18nEnum.OPT_MEMBER_SINCE,
            UserUIContext.formatPrettyTime(member.getCreatedtime()))).withDescription(UserUIContext.formatDateTime(member.getCreatedtime()))
            .withFullWidth();
    blockTop.addComponent(memberSinceLabel);

    if (ProjectMemberStatusConstants.ACTIVE.equals(member.getStatus())) {
        ELabel lastAccessTimeLbl = ELabel.html(UserUIContext.getMessage(UserI18nEnum.OPT_MEMBER_LOGGED_IN, UserUIContext
                .formatPrettyTime(member.getLastAccessTime())))
                .withDescription(UserUIContext.formatDateTime(member.getLastAccessTime()));
        blockTop.addComponent(lastAccessTimeLbl);
    }

    String memberWorksInfo = ProjectAssetsManager.getAsset(ProjectTypeConstants.TASK).getHtml() + " " + new Span()
            .appendText("" + member.getNumOpenTasks()).setTitle(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_OPEN_TASKS)) +
            "  " + ProjectAssetsManager.getAsset(ProjectTypeConstants.BUG).getHtml() + " " + new Span()
            .appendText("" + member.getNumOpenBugs()).setTitle(UserUIContext.getMessage(ProjectCommonI18nEnum.OPT_OPEN_BUGS)) +
            " " + VaadinIcons.MONEY.getHtml() + " " + new Span().appendText("" + NumberUtils.roundDouble(2,
            member.getTotalBillableLogTime())).setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_BILLABLE_HOURS)) +
            "  " + VaadinIcons.GIFT.getHtml() +
            " " + new Span().appendText("" + NumberUtils.roundDouble(2, member.getTotalNonBillableLogTime()))
            .setTitle(UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_NON_BILLABLE_HOURS));

    blockTop.addComponent(ELabel.html(memberWorksInfo).withStyleName(WebThemes.META_INFO));

    blockContent.with(blockTop);
    blockContent.setExpandRatio(blockTop, 1.0f);
    return blockContent;
}
 
Example 18
Source File: NotificationSettingWindow.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public NotificationSettingWindow(SimpleProjectMember projectMember) {
    super(UserUIContext.getMessage(ProjectCommonI18nEnum.ACTION_EDIT_NOTIFICATION));
    withModal(true).withResizable(false).withWidth("600px").withCenter();
    ProjectNotificationSettingService prjNotificationSettingService = AppContextUtil.getSpringBean(ProjectNotificationSettingService.class);
    ProjectNotificationSetting notification = prjNotificationSettingService.findNotification(projectMember.getUsername(), projectMember.getProjectid(),
            projectMember.getSaccountid());

    MVerticalLayout body = new MVerticalLayout();

    final RadioButtonGroup<String> optionGroup = new RadioButtonGroup(null);
    optionGroup.setItems(NotificationType.Default.name(), NotificationType.None.name(), NotificationType.Minimal.name(), NotificationType.Full.name());
    optionGroup.setItemCaptionGenerator((ItemCaptionGenerator<String>) item -> {
        if (item.equals(NotificationType.Default.name())) {
            return UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_DEFAULT_SETTING);
        } else if (item.equals(NotificationType.None.name())) {
            return UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_NONE_SETTING);
        } else if (item.equals(NotificationType.Minimal.name())) {
            return UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_MINIMUM_SETTING);
        } else if (item.equals(NotificationType.Full.name())) {
            return UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_MAXIMUM_SETTING);
        } else {
            throw new MyCollabException("Not supported");
        }
    });

    optionGroup.setWidth("100%");
    body.with(optionGroup);

    String levelVal = notification.getLevel();
    if (levelVal == null) {
        optionGroup.setValue(NotificationType.Default.name());
    } else {
        optionGroup.setValue(levelVal);
    }

    MButton closeBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLOSE), clickEvent -> close())
            .withStyleName(WebThemes.BUTTON_OPTION);
    MButton saveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE), clickEvent -> {
        try {
            notification.setLevel(optionGroup.getValue());
            ProjectNotificationSettingService projectNotificationSettingService = AppContextUtil.getSpringBean(ProjectNotificationSettingService.class);

            if (notification.getId() == null) {
                projectNotificationSettingService.saveWithSession(notification, UserUIContext.getUsername());
            } else {
                projectNotificationSettingService.updateWithSession(notification, UserUIContext.getUsername());
            }
            NotificationUtil.showNotification(UserUIContext.getMessage(GenericI18Enum.OPT_CONGRATS),
                    UserUIContext.getMessage(ProjectSettingI18nEnum.DIALOG_UPDATE_SUCCESS));
            close();
        } catch (Exception e) {
            throw new MyCollabException(e);
        }
    }).withStyleName(WebThemes.BUTTON_ACTION).withIcon(VaadinIcons.CLIPBOARD)
            .withClickShortcut(ShortcutAction.KeyCode.ENTER);
    MHorizontalLayout btnControls = new MHorizontalLayout(closeBtn, saveBtn);
    body.with(btnControls).withAlign(btnControls, Alignment.TOP_RIGHT);

    withContent(body);
}
 
Example 19
Source File: ProjectNotificationSettingViewComponent.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
public ProjectNotificationSettingViewComponent(final ProjectNotificationSetting bean) {
    super(UserUIContext.getMessage(ProjectSettingI18nEnum.VIEW_TITLE));

    MVerticalLayout body = new MVerticalLayout().withMargin(new MarginInfo(true, false, false, false));
    body.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    final RadioButtonGroup<String> optionGroup = new RadioButtonGroup<>(null);
    optionGroup.setItems(NotificationType.Default.name(), NotificationType.None.name(), NotificationType.Minimal.name(), NotificationType.Full.name());
    optionGroup.setItemCaptionGenerator((ItemCaptionGenerator<String>) item -> {
        if (item.equals(NotificationType.Default.name())) {
            return UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_DEFAULT_SETTING);
        } else if (item.equals(NotificationType.None.name())) {
            return UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_NONE_SETTING);
        } else if (item.equals(NotificationType.Minimal.name())) {
            return UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_MINIMUM_SETTING);
        } else if (item.equals(NotificationType.Full.name())) {
            return UserUIContext.getMessage(ProjectSettingI18nEnum.OPT_MAXIMUM_SETTING);
        } else {
            throw new MyCollabException("Not supported");
        }
    });

    optionGroup.setWidth("100%");
    body.with(optionGroup);

    String levelVal = bean.getLevel();
    if (levelVal == null) {
        optionGroup.setValue(NotificationType.Default.name());
    } else {
        optionGroup.setValue(levelVal);
    }

    MButton saveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE), clickEvent -> {
        try {
            bean.setLevel(optionGroup.getValue());
            ProjectNotificationSettingService projectNotificationSettingService = AppContextUtil.getSpringBean(ProjectNotificationSettingService.class);

            if (bean.getId() == null) {
                projectNotificationSettingService.saveWithSession(bean, UserUIContext.getUsername());
            } else {
                projectNotificationSettingService.updateWithSession(bean, UserUIContext.getUsername());
            }
            NotificationUtil.showNotification(UserUIContext.getMessage(GenericI18Enum.OPT_CONGRATS),
                    UserUIContext.getMessage(ProjectSettingI18nEnum.DIALOG_UPDATE_SUCCESS));
        } catch (Exception e) {
            throw new MyCollabException(e);
        }
    }).withIcon(VaadinIcons.CLIPBOARD).withStyleName(WebThemes.BUTTON_ACTION).withVisible(!CurrentProjectVariables.isProjectArchived())
            .withClickShortcut(KeyCode.ENTER);
    body.addComponent(saveBtn);

    this.addComponent(body);
}
 
Example 20
Source File: MailFormWindow.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
private void initUI() {
    MVerticalLayout mainLayout = new MVerticalLayout().withFullWidth();

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

    mainLayout.addComponent(inputLayout);

    tokenFieldMailTo = new EmailTokenField();
    inputLayout.addComponent(createTextFieldMailWithHelp("To:", tokenFieldMailTo), 0, 0);

    if (mails != null) {
        mails.stream().filter(mail -> mail.indexOf("<") > 0).map(mail -> {
            String strMail = mail.substring(mail.indexOf("<") + 1, mail.lastIndexOf(">"));
            if (strMail != null && !strMail.equalsIgnoreCase("null")) {
                return strMail;
            } else {
                return "";
            }
        });
    }

    final MTextField subject = new MTextField().withRequiredIndicatorVisible(true).withFullWidth();
    subjectField = createTextFieldMail("Subject:", subject);
    inputLayout.addComponent(subjectField, 0, 1);

    initButtonLinkCcBcc();

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

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

    final AttachmentPanel attachments = new AttachmentPanel();

    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.getListRecipients().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> files = attachments.files();
            List<AttachmentSource> attachmentSource = new ArrayList<>();
            if (CollectionUtils.isNotEmpty(files)) {
                files.forEach(file -> attachmentSource.add(new FileAttachmentSource(file)));
            }

            if (reportTemplateExecutor != null) {
                attachmentSource.add(new FileAttachmentSource(reportTemplateExecutor.getDefaultExportFileName(),
                        reportTemplateExecutor.exportStream()));
            }

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

    MHorizontalLayout controlsLayout = new MHorizontalLayout(cancelBtn, sendBtn)
            .withMargin(new MarginInfo(false, true, true, false));
    mainLayout.with(attachments);
    mainLayout.addStyleName(WebThemes.SCROLLABLE_CONTAINER);
    this.setContent(new MVerticalLayout(mainLayout, controlsLayout).withMargin(false)
            .withSpacing(false).withAlign(controlsLayout, Alignment.TOP_RIGHT));
}