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

The following examples show how to use org.vaadin.viritin.layouts.MVerticalLayout#addComponent() . 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: ReportContainerImpl.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void showDashboard() {
    body.removeAllComponents();
    body.with(ELabel.h2(VaadinIcons.PIE_CHART.getHtml() + " " + UserUIContext.getMessage(ProjectCommonI18nEnum.VIEW_REPORTS)));
    MCssLayout contentLayout = new MCssLayout().withStyleName(WebThemes.FLEX_DISPLAY);

    MVerticalLayout standupConsole = new MVerticalLayout().withWidth("300px").withStyleName("member-block");
    standupConsole.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    standupConsole.addComponent(ELabel.fontIcon(VaadinIcons.CALENDAR_CLOCK).withStyleName("icon-38px"));
    A standupReportLink = new A(ProjectLinkGenerator.generateStandupDashboardLink())
            .appendText(UserUIContext.getMessage(ProjectReportI18nEnum.REPORT_STANDUP));
    standupConsole.addComponent(ELabel.h3(standupReportLink.write()).withUndefinedWidth());
    standupConsole.addComponent(new ELabel(UserUIContext.getMessage(ProjectReportI18nEnum.REPORT_STANDUP_HELP)).withFullWidth());
    contentLayout.addComponent(standupConsole);


    MVerticalLayout userWorkloadReport = new MVerticalLayout().withWidth("300px").withStyleName("member-block");
    userWorkloadReport.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    userWorkloadReport.addComponent(ELabel.fontIcon(VaadinIcons.CALENDAR_CLOCK).withStyleName("icon-38px"));
    A userWorkloadReportLink = new A(ProjectLinkGenerator.generateUsersWorkloadReportLink())
            .appendText(UserUIContext.getMessage(ProjectReportI18nEnum.REPORT_TICKET_ASSIGNMENT));
    userWorkloadReport.addComponent(ELabel.h3(userWorkloadReportLink.write()).withUndefinedWidth());
    userWorkloadReport.addComponent(new ELabel(UserUIContext.getMessage(ProjectReportI18nEnum.REPORT_TICKET_ASSIGNMENT_HELP)).withFullWidth());
    contentLayout.addComponent(userWorkloadReport);

    body.with(contentLayout).expand(contentLayout).withAlign(contentLayout, Alignment.TOP_LEFT);
}
 
Example 2
Source File: ContactInfoChangeWindow.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
private void initUI() {
    MVerticalLayout mainLayout = new MVerticalLayout().withMargin(true).withFullWidth();

    GridFormLayoutHelper passInfo = GridFormLayoutHelper.defaultFormLayoutHelper(LayoutType.ONE_COLUMN);

    passInfo.addComponent(txtWorkPhone, UserUIContext.getMessage(UserI18nEnum.FORM_WORK_PHONE), 0, 0);
    passInfo.addComponent(txtHomePhone, UserUIContext.getMessage(UserI18nEnum.FORM_HOME_PHONE), 0, 1);
    passInfo.addComponent(txtFaceBook, "Facebook", 0, 2);
    passInfo.addComponent(txtTwitter, "Twitter", 0, 3);
    passInfo.addComponent(txtSkype, "Skype", 0, 4);

    txtWorkPhone.setValue(MoreObjects.firstNonNull(user.getWorkphone(), ""));
    txtHomePhone.setValue(MoreObjects.firstNonNull(user.getHomephone(), ""));
    txtFaceBook.setValue(MoreObjects.firstNonNull(user.getFacebookaccount(), ""));
    txtTwitter.setValue(MoreObjects.firstNonNull(user.getTwitteraccount(), ""));
    txtSkype.setValue(MoreObjects.firstNonNull(user.getSkypecontact(), ""));
    mainLayout.addComponent(passInfo.getLayout());
    mainLayout.setComponentAlignment(passInfo.getLayout(), Alignment.TOP_LEFT);

    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 -> changeUserInfo())
            .withIcon(VaadinIcons.CLIPBOARD).withStyleName(WebThemes.BUTTON_ACTION).withClickShortcut(KeyCode.ENTER);

    MHorizontalLayout hlayoutControls = new MHorizontalLayout(cancelBtn, saveBtn);
    mainLayout.with(hlayoutControls).withAlign(hlayoutControls, Alignment.MIDDLE_RIGHT);
    this.setContent(mainLayout);
}
 
Example 3
Source File: UserAddViewImpl.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
private Layout createBottomPanel() {
    MVerticalLayout bottomPanel = new MVerticalLayout().withMargin(false);
    Button moreInfoBtn = new MButton(UserUIContext.getMessage(UserI18nEnum.ACTION_MORE_INFORMATION), event -> {
        editUserForm.displayAdvancedForm(user);
    }).withStyleName(WebThemes.BUTTON_LINK);
    MHorizontalLayout linkWrap = new MHorizontalLayout(moreInfoBtn).withMargin(true);
    bottomPanel.with(linkWrap).withAlign(linkWrap, Alignment.MIDDLE_LEFT);
    rolePermissionLayout = new RolePermissionContainer();
    bottomPanel.addComponent(rolePermissionLayout);
    return bottomPanel;
}
 
Example 4
Source File: AssignTaskWindow.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
AssignTaskWindow(Task task) {
    super(UserUIContext.getMessage(TaskI18nEnum.DIALOG_ASSIGN_TASK_TITLE, task.getName()));
    this.task = task;
    MVerticalLayout contentLayout = new MVerticalLayout().withMargin(new MarginInfo(false, false, true, false));
    this.withWidth("750px").withModal(true).withResizable(false).withCenter().withContent(contentLayout);
    EditForm editForm = new EditForm();
    contentLayout.addComponent(editForm);
    editForm.setBean(task);
}
 
Example 5
Source File: ResourcesDisplayComponent.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
AddNewFolderWindow() {
    this.setCaption(UserUIContext.getMessage(FileI18nEnum.ACTION_NEW_FOLDER));

    MVerticalLayout contentLayout = new MVerticalLayout().withSpacing(false).withMargin(new MarginInfo(false, true, true, true));
    withModal(true).withResizable(false).withWidth("500px").withCenter().withContent(contentLayout);

    GridFormLayoutHelper layoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(LayoutType.ONE_COLUMN);
    TextField folderName = layoutHelper.addComponent(new TextField(), UserUIContext.getMessage(GenericI18Enum.FORM_NAME), 0, 0);
    TextArea descAreaField = layoutHelper.addComponent(new TextArea(), UserUIContext.getMessage(GenericI18Enum.FORM_DESCRIPTION), 0, 1);
    contentLayout.addComponent(layoutHelper.getLayout());

    MButton saveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_SAVE), clickEvent -> {
        String folderVal = folderName.getValue();

        if (StringUtils.isNotBlank(folderVal)) {
            FileUtils.assertValidFolderName(folderVal);
            String baseFolderPath = baseFolder.getPath();
            String desc = descAreaField.getValue();
            folderVal = FileUtils.escape(folderVal);

            resourceService.createNewFolder(baseFolderPath, folderVal, desc, UserUIContext.getUsername());
            resourcesContainer.constructBody(baseFolder);
            close();
        } else {
            NotificationUtil.showErrorNotification(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL,
                    UserUIContext.getMessage(GenericI18Enum.FORM_NAME)));
        }
    }).withIcon(VaadinIcons.CLIPBOARD).withStyleName(WebThemes.BUTTON_ACTION)
            .withClickShortcut(KeyCode.ENTER);

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL), clickEvent -> close())
            .withStyleName(WebThemes.BUTTON_OPTION);
    MHorizontalLayout controlsLayout = new MHorizontalLayout(cancelBtn, saveBtn);
    contentLayout.with(controlsLayout).withAlign(controlsLayout, Alignment.MIDDLE_RIGHT);
}
 
Example 6
Source File: StandupListViewImpl.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public Component generateRow(IBeanList<SimpleStandupReport> host, SimpleStandupReport report, int rowIndex) {
    MHorizontalLayout rowLayout = new MHorizontalLayout().withStyleName(WebThemes.BORDER);

    MVerticalLayout userInfo = new MVerticalLayout().withWidth("200px").withFullHeight().withStyleName(WebThemes
            .HOVER_EFFECT_NOT_BOX);
    userInfo.setDefaultComponentAlignment(Alignment.TOP_CENTER);

    Image userAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(report.getLogByAvatarId(), 100);
    userAvatar.addStyleName(WebThemes.CIRCLE_BOX);
    userInfo.addComponent(userAvatar);
    Label memberLink = ELabel.html(buildMemberLink(report));
    userInfo.with(memberLink).expand(memberLink).withAlign(memberLink, Alignment.TOP_CENTER);
    rowLayout.addComponent(userInfo);

    MVerticalLayout reportContent = new MVerticalLayout().withStyleName(WebThemes.BORDER_LEFT, WebThemes.HOVER_EFFECT_NOT_BOX);

    reportContent.addComponent(ELabel.h3(UserUIContext.getMessage(StandupI18nEnum.STANDUP_LASTDAY)).withStyleName(WebThemes.LABEL_WORD_WRAP).withFullWidth());
    Label whatYesterdayField = new SafeHtmlLabel(report.getWhatlastday());
    whatYesterdayField.setWidth("100%");
    reportContent.addComponent(whatYesterdayField);

    reportContent.addComponent(ELabel.h3(UserUIContext.getMessage(StandupI18nEnum.STANDUP_TODAY)).withStyleName(WebThemes.LABEL_WORD_WRAP).withFullWidth());
    Label whatTodayField = new SafeHtmlLabel(report.getWhattoday());
    whatTodayField.setWidth("100%");
    reportContent.addComponent(whatTodayField);

    reportContent.addComponent(ELabel.h3(UserUIContext.getMessage(StandupI18nEnum.STANDUP_ISSUE)).withStyleName(WebThemes.LABEL_WORD_WRAP).withFullWidth());
    Label whatProblemField = new SafeHtmlLabel(report.getWhatproblem());
    whatProblemField.setWidth("100%");
    reportContent.addComponent(whatProblemField);

    rowLayout.with(reportContent).expand(reportContent);
    return rowLayout;
}
 
Example 7
Source File: StandupReportFormLayoutFactory.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public AbstractComponent getLayout() {
    AddViewLayout reportAddLayout = new AddViewLayout(title, ProjectAssetsManager.getAsset(ProjectTypeConstants.STANDUP));
    reportAddLayout.addHeaderRight(this.createTopPanel());

    MHorizontalLayout mainLayout = new MHorizontalLayout().withFullWidth();
    final MVerticalLayout layoutField = new MVerticalLayout().withMargin(new MarginInfo(false, false, true,
            false)).withFullWidth();

    final ELabel whatYesterdayLbl = ELabel.h3(UserUIContext.getMessage(StandupI18nEnum.STANDUP_LASTDAY));
    layoutField.addComponent(whatYesterdayLbl);
    whatYesterdayField = new StandupCustomField();
    layoutField.addComponent(whatYesterdayField);

    final ELabel whatTodayLbl = ELabel.h3(UserUIContext.getMessage(StandupI18nEnum.STANDUP_TODAY));
    layoutField.with(whatTodayLbl);
    whatTodayField = new StandupCustomField();
    layoutField.addComponent(whatTodayField);

    final ELabel roadblockLbl = ELabel.h3(UserUIContext.getMessage(StandupI18nEnum.STANDUP_ISSUE)).withStyleName(WebThemes.LABEL_WORD_WRAP);
    layoutField.with(roadblockLbl);
    whatProblemField = new StandupCustomField();
    layoutField.addComponent(whatProblemField);

    mainLayout.addComponent(layoutField);
    mainLayout.setExpandRatio(layoutField, 2.0f);

    MVerticalLayout instructionLayout = new MVerticalLayout(ELabel.html(UserUIContext.getMessage(StandupI18nEnum.HINT1_MSG)).withFullWidth(),
            ELabel.html(UserUIContext.getMessage(StandupI18nEnum.HINT2_MG)).withFullWidth()).withStyleName("instruction-box").withWidth("300px");

    mainLayout.addComponent(instructionLayout);
    mainLayout.setExpandRatio(instructionLayout, 1.0f);
    mainLayout.setComponentAlignment(instructionLayout, Alignment.TOP_CENTER);

    reportAddLayout.addBody(mainLayout);
    return reportAddLayout;
}
 
Example 8
Source File: BasicInfoChangeWindow.java    From mycollab with GNU Affero General Public License v3.0 5 votes vote down vote up
private void initUI() {
    MVerticalLayout mainLayout = new MVerticalLayout().withMargin(true).withFullWidth();

    GridFormLayoutHelper passInfo = GridFormLayoutHelper.defaultFormLayoutHelper(LayoutType.ONE_COLUMN);

    passInfo.addComponent(txtFirstName, UserUIContext.getMessage(UserI18nEnum.FORM_FIRST_NAME), 0, 0);
    passInfo.addComponent(txtLastName, UserUIContext.getMessage(UserI18nEnum.FORM_LAST_NAME), 0, 1);
    txtLastName.setRequiredIndicatorVisible(true);
    passInfo.addComponent(txtEmail, UserUIContext.getMessage(GenericI18Enum.FORM_EMAIL), 0, 2);
    txtEmail.setRequiredIndicatorVisible(true);
    passInfo.addComponent(birthdayField, UserUIContext.getMessage(UserI18nEnum.FORM_BIRTHDAY), 0, 3);
    birthdayField.setValue(user.getBirthday());

    passInfo.addComponent(timeZoneField, UserUIContext.getMessage(UserI18nEnum.FORM_TIMEZONE), 0, 4);
    timeZoneField.setValue(user.getTimezone());

    passInfo.addComponent(languageBox, UserUIContext.getMessage(UserI18nEnum.FORM_LANGUAGE),
            UserUIContext.getMessage(ShellI18nEnum.OPT_SUPPORTED_LANGUAGES_INTRO), 0, 5);
    languageBox.setValue(user.getLanguage());

    txtFirstName.setValue(MoreObjects.firstNonNull(user.getFirstname(), ""));
    txtLastName.setValue(MoreObjects.firstNonNull(user.getLastname(), ""));
    txtEmail.setValue(MoreObjects.firstNonNull(user.getEmail(), ""));

    mainLayout.addComponent(passInfo.getLayout());
    mainLayout.setComponentAlignment(passInfo.getLayout(), Alignment.TOP_LEFT);

    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 -> changeUserInfo())
            .withStyleName(WebThemes.BUTTON_ACTION).withIcon(VaadinIcons.CLIPBOARD).withClickShortcut(KeyCode.ENTER);

    MHorizontalLayout hlayoutControls = new MHorizontalLayout(cancelBtn, saveBtn);
    mainLayout.with(hlayoutControls).withAlign(hlayoutControls, Alignment.MIDDLE_RIGHT);

    this.setContent(mainLayout);
}
 
Example 9
Source File: UserReadViewImpl.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
private void displayUserAvatar() {
    header.removeAllComponents();
    MHorizontalLayout avatarAndPass = new MHorizontalLayout().withFullWidth();
    Image cropField = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(user.getAvatarid(), 100);
    cropField.addStyleName(WebThemes.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 = GridFormLayoutHelper.defaultFormLayoutHelper(LayoutType.ONE_COLUMN);
    userFormLayout.getLayout().addStyleName(WebThemes.GRIDFORM_BORDERLESS);
    basicLayout.addComponent(userFormLayout.getLayout());

    Node roleDiv;
    if (Boolean.TRUE.equals(user.isAccountOwner())) {
        roleDiv = new Div().appendText(UserUIContext.getMessage(RoleI18nEnum.OPT_ACCOUNT_OWNER));
    } else {
        roleDiv = new A(AccountLinkGenerator.generateRoleLink(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.getBirthday())),
            UserUIContext.getMessage(UserI18nEnum.FORM_BIRTHDAY), 0, 1);

    if (Boolean.TRUE.equals(AppUI.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);
        ELabel label = ELabel.EMPTY_SPACE();
        userFormLayout.addComponent(new MHorizontalLayout(new ELabel("***********"), btnChangePassword, label).expand(label),
                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);
}
 
Example 10
Source File: FileDownloadWindow.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
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 infoLayout = GridFormLayoutHelper.defaultFormLayoutHelper(LayoutType.ONE_COLUMN);

    if (content.getDescription() != null) {
        final Label descLbl = new Label();
        if (!content.getDescription().equals("")) {
            descLbl.setData(content.getDescription());
        } else {
            descLbl.setValue("&nbsp;");
            descLbl.setContentMode(ContentMode.HTML);
        }
        infoLayout.addComponent(descLbl, UserUIContext.getMessage(GenericI18Enum.FORM_DESCRIPTION), 0, 0);
    }

    UserService userService = AppContextUtil.getSpringBean(UserService.class);
    SimpleUser user = userService.findUserByUserNameInAccount(content.getCreatedUser(), AppUI.getAccountId());
    if (user == null) {
        infoLayout.addComponent(new UserLink(UserUIContext.getUsername(), UserUIContext.getUserAvatarId(),
                UserUIContext.getUserDisplayName()), UserUIContext.getMessage(GenericI18Enum.OPT_CREATED_BY), 0, 1);
    } else {
        infoLayout.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()));
    infoLayout.addComponent(size, UserUIContext.getMessage(FileI18nEnum.OPT_SIZE), 0, 2);

    ELabel dateCreate = new ELabel().prettyDateTime(DateTimeUtils.toLocalDateTime(content.getCreated()));
    infoLayout.addComponent(dateCreate, UserUIContext.getMessage(GenericI18Enum.FORM_CREATED_TIME), 0, 3);

    layout.addComponent(infoLayout.getLayout());

    MButton downloadBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_DOWNLOAD))
            .withIcon(VaadinIcons.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);
    MHorizontalLayout buttonControls = new MHorizontalLayout(cancelBtn, downloadBtn);
    layout.with(buttonControls).withAlign(buttonControls, Alignment.MIDDLE_RIGHT);
    this.setContent(layout);
}
 
Example 11
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 12
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 13
Source File: ProjectActivityComponent.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
private Component buildAuditBlock(SimpleAuditLog auditLog) {
    List<AuditChangeItem> changeItems = auditLog.getChangeItems();
    if (CollectionUtils.isNotEmpty(changeItems)) {
        MHorizontalLayout layout = new MHorizontalLayout().withMargin(new MarginInfo(true, false, true, false))
                .withFullWidth();

        ProjectMemberBlock memberBlock = new ProjectMemberBlock(auditLog.getCreateduser(), auditLog.getPostedUserAvatarId(),
                auditLog.getPostedUserFullName());
        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_MODIFIED_ITEM, auditLog.getPostedUserFullName(),
                UserUIContext.formatPrettyTime(auditLog.getCreatedtime())))
                .withDescription(UserUIContext.formatDateTime(auditLog.getCreatedtime()));
        timePostLbl.setStyleName(WebThemes.META_INFO);
        messageHeader.with(timePostLbl).expand(timePostLbl);

        rowLayout.addComponent(messageHeader);

        for (AuditChangeItem item : changeItems) {
            String fieldName = item.getField();

            DefaultFieldDisplayHandler fieldDisplayHandler = groupFormatter.getFieldDisplayHandler(fieldName);
            if (fieldDisplayHandler != null) {
                Span fieldBlock = new Span().appendText(UserUIContext.getMessage(fieldDisplayHandler.getDisplayName()))
                        .setCSSClass(WebThemes.BLOCK);
                Div historyDiv = new Div().appendChild(fieldBlock).appendText(fieldDisplayHandler.getFormat()
                        .toString(item.getOldvalue())).appendText(" " + VaadinIcons.ARROW_RIGHT.getHtml() +
                        " ").appendText(fieldDisplayHandler.getFormat().toString(item.getNewvalue()));
                rowLayout.addComponent(new MCssLayout(ELabel.html(historyDiv.write()).withFullWidth()).withFullWidth());
            }
        }

        layout.with(rowLayout).expand(rowLayout);
        return layout;
    } else {
        return null;
    }
}
 
Example 14
Source File: PageListViewImpl.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
private Layout displayFolderBlock(final Folder resource) {
    MVerticalLayout container = new MVerticalLayout().withFullWidth().withStyleName("page-item-block");

    A folderHtml = new A(ProjectLinkGenerator.generatePagesLink(CurrentProjectVariables
            .getProjectId(), resource.getPath())).appendText(VaadinIcons.FOLDER_OPEN.getHtml() + " " + resource.getName());
    ELabel folderLink = ELabel.h3(folderHtml.write());
    container.addComponent(folderLink);
    if (StringUtils.isNotBlank(resource.getDescription())) {
        container.addComponent(new Label(StringUtils.trimHtmlTags(resource.getDescription())));
    }

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

    MButton editBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_EDIT),
            clickEvent -> UI.getCurrent().addWindow(new GroupPageAddWindow(resource)))
            .withStyleName(WebThemes.BUTTON_LINK, WebThemes.BUTTON_SMALL_PADDING).withIcon(VaadinIcons.EDIT)
            .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 15
Source File: ReOpenWindow.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public AbstractComponent getLayout() {
    MVerticalLayout layout = new MVerticalLayout();
    informationLayout = GridFormLayoutHelper.defaultFormLayoutHelper(LayoutType.TWO_COLUMN);
    layout.addComponent(informationLayout.getLayout());

    MButton reOpenBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_REOPEN), clickEvent -> {
        if (validateForm()) {
            bug.setStatus(StatusI18nEnum.ReOpen.name());
            bug.setResolution(BugResolution.None.name());

            // Save bug status and assignee
            BugService bugService = AppContextUtil.getSpringBean(BugService.class);
            bugService.updateSelectiveWithSession(bug, UserUIContext.getUsername());

            TicketRelationService ticketRelationService = AppContextUtil.getSpringBean(TicketRelationService.class);
            ticketRelationService.updateAffectedVersionsOfTicket(bug.getId(), ProjectTypeConstants.BUG, affectedVersionsSelect.getSelectedItems());
            ticketRelationService.updateFixedVersionsOfTicket(bug.getId(), ProjectTypeConstants.BUG, null);

            ticketRelationService.removeRelationsByRel(bug.getId(), ProjectTypeConstants.BUG, Duplicated.name());

            // Save comment
            String commentValue = commentArea.getValue();
            if (StringUtils.isNotBlank(commentValue)) {
                CommentWithBLOBs comment = new CommentWithBLOBs();
                comment.setComment(Jsoup.clean(commentValue, Whitelist.relaxed()));
                comment.setCreatedtime(LocalDateTime.now());
                comment.setCreateduser(UserUIContext.getUsername());
                comment.setSaccountid(AppUI.getAccountId());
                comment.setType(ProjectTypeConstants.BUG);
                comment.setTypeid("" + bug.getId());
                comment.setExtratypeid(CurrentProjectVariables.getProjectId());

                CommentService commentService = AppContextUtil.getSpringBean(CommentService.class);
                commentService.saveWithSession(comment, UserUIContext.getUsername());
            }

            close();
            EventBusFactory.getInstance().post(new BugEvent.BugChanged(this, bug.getId()));
        }
    }).withStyleName(WebThemes.BUTTON_ACTION);

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

    MHorizontalLayout controlsBtn = new MHorizontalLayout(cancelBtn, reOpenBtn);

    layout.with(controlsBtn).withAlign(controlsBtn, Alignment.MIDDLE_RIGHT);
    return layout;
}
 
Example 16
Source File: ApproveInputWindow.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public AbstractComponent getLayout() {
    MVerticalLayout layout = new MVerticalLayout();
    informationLayout = GridFormLayoutHelper.defaultFormLayoutHelper(LayoutType.TWO_COLUMN);

    layout.addComponent(informationLayout.getLayout());

    final MButton approveBtn = new MButton(UserUIContext.getMessage(BugI18nEnum.BUTTON_APPROVE_CLOSE), clickEvent -> {
        if (EditForm.this.validateForm()) {
            // Save bug status and assignee
            bug.setStatus(StatusI18nEnum.Verified.name());

            BugService bugService = AppContextUtil.getSpringBean(BugService.class);
            bugService.updateSelectiveWithSession(bug, UserUIContext.getUsername());

            // Save comment
            String commentValue = commentArea.getValue();
            if (StringUtils.isNotBlank(commentValue)) {
                CommentWithBLOBs comment = new CommentWithBLOBs();
                comment.setComment(Jsoup.clean(commentArea.getValue(), Whitelist.relaxed()));
                comment.setCreatedtime(LocalDateTime.now());
                comment.setCreateduser(UserUIContext.getUsername());
                comment.setSaccountid(AppUI.getAccountId());
                comment.setType(ProjectTypeConstants.BUG);
                comment.setTypeid("" + bug.getId());
                comment.setExtratypeid(CurrentProjectVariables.getProjectId());

                CommentService commentService = AppContextUtil.getSpringBean(CommentService.class);
                commentService.saveWithSession(comment, UserUIContext.getUsername());
            }

            close();
            EventBusFactory.getInstance().post(new BugEvent.BugChanged(this, bug.getId()));
        }
    }).withStyleName(WebThemes.BUTTON_ACTION);

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

    MHorizontalLayout controlsBtn = new MHorizontalLayout(cancelBtn, approveBtn).withMargin(false);
    layout.with(controlsBtn).withAlign(controlsBtn, Alignment.MIDDLE_RIGHT);
    return layout;
}
 
Example 17
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 18
Source File: ResolvedInputForm.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public AbstractComponent getLayout() {
    MVerticalLayout layout = new MVerticalLayout();
    informationLayout = GridFormLayoutHelper.defaultFormLayoutHelper(LayoutType.TWO_COLUMN);
    layout.addComponent(informationLayout.getLayout());

    MButton resolveBtn = new MButton(UserUIContext.getMessage(BugI18nEnum.BUTTON_RESOLVED), clickEvent -> {
        if (validateForm()) {
            String commentValue = commentArea.getValue();
            if (BugResolution.Duplicate.name().equals(bug.getResolution())) {
                if (ticketRelationSelectField != null && ticketRelationSelectField.getSelectedTicket() != null) {
                    ProjectTicket relationTicket = ticketRelationSelectField.getSelectedTicket();
                    if (relationTicket.getTypeId().equals(bug.getId()) && relationTicket.getType().equals(ProjectTypeConstants.BUG)) {
                        throw new UserInvalidInputException("The relation is invalid since the both entries are the same");
                    }

                    TicketRelationService relatedBugService = AppContextUtil.getSpringBean(TicketRelationService.class);
                    com.mycollab.module.project.domain.TicketRelation relatedTicket = new com.mycollab.module.project.domain.TicketRelation();
                    relatedTicket.setTicketid(bug.getId());
                    relatedTicket.setTickettype(ProjectTypeConstants.BUG);
                    relatedTicket.setRel(OptionI18nEnum.TicketRel.Duplicated.name());
                    relatedTicket.setTypeid(relationTicket.getTypeId());
                    relatedTicket.setType(relatedTicket.getType());
                    relatedBugService.saveWithSession(relatedTicket, UserUIContext.getUsername());
                } else {
                    NotificationUtil.showErrorNotification(UserUIContext.getMessage(BugI18nEnum.ERROR_DUPLICATE_BUG_SELECT));
                    return;
                }
            } else if (BugResolution.InComplete.name().equals(bug.getResolution()) ||
                    BugResolution.CannotReproduce.name().equals(bug.getResolution()) ||
                    BugResolution.Invalid.name().equals(bug.getResolution())) {
                if (StringUtils.isBlank(commentValue)) {
                    NotificationUtil.showErrorNotification(UserUIContext.getMessage(BugI18nEnum.ERROR_COMMENT_NOT_BLANK_FOR_RESOLUTION, bug.getResolution()));
                    return;
                }
            }
            bug.setStatus(StatusI18nEnum.Resolved.name());

            TicketRelationService ticketRelationService = AppContextUtil.getSpringBean(TicketRelationService.class);
            ticketRelationService.updateFixedVersionsOfTicket(bug.getId(), ProjectTypeConstants.BUG, fixedVersionSelect.getSelectedItems());

            // Save bug status and assignee
            BugService bugService = AppContextUtil.getSpringBean(BugService.class);
            bugService.updateSelectiveWithSession(bug, UserUIContext.getUsername());

            // Save comment
            if (StringUtils.isNotBlank(commentValue)) {
                CommentWithBLOBs comment = new CommentWithBLOBs();
                comment.setComment(commentValue);
                comment.setCreatedtime(LocalDateTime.now());
                comment.setCreateduser(UserUIContext.getUsername());
                comment.setSaccountid(AppUI.getAccountId());
                comment.setType(ProjectTypeConstants.BUG);
                comment.setTypeid("" + bug.getId());
                comment.setExtratypeid(CurrentProjectVariables.getProjectId());

                CommentService commentService = AppContextUtil.getSpringBean(CommentService.class);
                commentService.saveWithSession(comment, UserUIContext.getUsername());
            }

            postExecution();
            EventBusFactory.getInstance().post(new BugEvent.BugChanged(this, bug.getId()));
        }
    }).withStyleName(WebThemes.BUTTON_ACTION).withClickShortcut(KeyCode.ENTER);

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

    final MHorizontalLayout controlsBtn = new MHorizontalLayout(cancelBtn, resolveBtn);
    layout.with(controlsBtn).withAlign(controlsBtn, Alignment.MIDDLE_RIGHT);

    return layout;
}
 
Example 19
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));
}
 
Example 20
Source File: CommentRowDisplayHandler.java    From mycollab with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public Component generateRow(IBeanList<SimpleComment> host, final SimpleComment comment, int rowIndex) {
    final MHorizontalLayout layout = new MHorizontalLayout().withMargin(new MarginInfo(true, true, 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().withMargin(false).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()));
    timePostLbl.setStyleName(WebThemes.META_INFO);

    if (hasDeletePermission(comment)) {
        MButton msgDeleteBtn = new MButton(VaadinIcons.TRASH).withStyleName(WebThemes.BUTTON_ICON_ONLY)
                .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());
                                ((BeanList) host).removeRow(layout);
                            }
                        }));
        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().withSpacing(false).withFullWidth();
        AttachmentDisplayComponent attachmentDisplay = new AttachmentDisplayComponent(attachments);
        attachmentDisplay.setWidth("100%");
        messageFooter.with(attachmentDisplay).withAlign(attachmentDisplay, Alignment.MIDDLE_RIGHT);
        rowLayout.addComponent(messageFooter);
    }

    layout.with(rowLayout).expand(rowLayout);
    return layout;
}