Example usage for com.vaadin.ui RichTextArea RichTextArea

List of usage examples for com.vaadin.ui RichTextArea RichTextArea

Introduction

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

Prototype

public RichTextArea() 

Source Link

Document

Constructs an empty RichTextArea with no caption.

Usage

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

License:Open Source License

@Override
protected Field<?> onCreateField(Object propertyId) {
    if (propertyId.equals("campaignid")) {
        return new CampaignSelectionField();
    } else if (propertyId.equals("accountid")) {
        AccountSelectionField accountField = new AccountSelectionField();
        accountField.setRequired(true);//from ww w .  j a v a 2s  .c  o  m
        return accountField;
    } else if (propertyId.equals("opportunityname")) {
        MTextField tf = new MTextField();
        if (isValidateForm) {
            tf.withNullRepresentation("").withRequired(true).withRequiredError(UserUIContext.getMessage(
                    ErrorI18nEnum.FIELD_MUST_NOT_NULL, UserUIContext.getMessage(GenericI18Enum.FORM_NAME)));
        }
        return tf;
    } else if (propertyId.equals("currencyid")) {
        return new CurrencyComboBoxField();
    } else if (propertyId.equals("salesstage")) {
        return new OpportunitySalesStageComboBox();
    } else if (propertyId.equals("opportunitytype")) {
        return new OpportunityTypeComboBox();
    } else if (propertyId.equals("source")) {
        return new LeadSourceComboBox();
    } else if (propertyId.equals("description")) {
        return new RichTextArea();
    } else if (propertyId.equals("assignuser")) {
        return new ActiveUserComboBox();
    } else if (Opportunity.Field.amount.equalTo(propertyId)) {
        return new DoubleField();
    } else if (Opportunity.Field.probability.equalTo(propertyId)) {
        return new IntegerField();
    }

    return null;
}

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

License:Open Source License

ProjectCommentInput(final ReloadableComponent component, final String typeVal, Integer extraTypeIdVal) {
    this.withMargin(new MarginInfo(true, true, false, false)).withFullWidth().withHeightUndefined();

    SimpleUser currentUser = UserUIContext.getUser();
    ProjectMemberBlock userBlock = new ProjectMemberBlock(currentUser.getUsername(), currentUser.getAvatarid(),
            currentUser.getDisplayName());

    MVerticalLayout textAreaWrap = new MVerticalLayout().withFullWidth()
            .withStyleName(WebThemes.MESSAGE_CONTAINER);
    this.with(userBlock, textAreaWrap).expand(textAreaWrap);

    type = typeVal;// w  w  w .  j a va2  s  . c o m
    extraTypeId = extraTypeIdVal;

    commentArea = new RichTextArea();
    commentArea.setWidth("100%");
    commentArea.setHeight("200px");
    commentArea.addStyleName("comment-attachment");

    final AttachmentPanel attachments = new AttachmentPanel();
    attachments.setWidth("100%");

    final MButton newCommentBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_POST),
            clickEvent -> {
                CommentWithBLOBs comment = new CommentWithBLOBs();
                comment.setComment(Jsoup.clean(commentArea.getValue(), Whitelist.relaxed()));
                comment.setCreatedtime(new GregorianCalendar().getTime());
                comment.setCreateduser(UserUIContext.getUsername());
                comment.setSaccountid(MyCollabUI.getAccountId());
                comment.setType(type);
                comment.setTypeid("" + typeId);
                comment.setExtratypeid(extraTypeId);

                final CommentService commentService = AppContextUtil.getSpringBean(CommentService.class);
                int commentId = commentService.saveWithSession(comment, UserUIContext.getUsername());

                String attachmentPath = AttachmentUtils.getCommentAttachmentPath(typeVal,
                        MyCollabUI.getAccountId(), CurrentProjectVariables.getProjectId(), typeId, commentId);

                if (!"".equals(attachmentPath)) {
                    attachments.saveContentsToRepo(attachmentPath);
                }

                // save success, clear comment area and load list
                // comments again
                commentArea.setValue("");
                component.reload();
            }).withStyleName(WebThemes.BUTTON_ACTION).withIcon(FontAwesome.SEND);

    textAreaWrap.with(new MCssLayout(commentArea, attachments), newCommentBtn).withAlign(newCommentBtn,
            Alignment.TOP_RIGHT);
}

From source file:com.mycollab.module.project.view.bug.BugEditFormFieldFactory.java

License:Open Source License

@Override
protected Field<?> onCreateField(final Object propertyId) {
    final SimpleBug beanItem = attachForm.getBean();
    if (propertyId.equals("environment")) {
        return new RichTextArea();
    } else if (propertyId.equals("description")) {
        return new RichTextArea();
    } else if (propertyId.equals("priority")) {
        return new PriorityComboBox();
    } else if (propertyId.equals("assignuser")) {
        ProjectMemberSelectionField field = new ProjectMemberSelectionField();
        field.addValueChangeListener(valueChangeEvent -> {
            Property property = valueChangeEvent.getProperty();
            SimpleProjectMember member = (SimpleProjectMember) property.getValue();
            if (member != null) {
                subscribersComp.addFollower(member.getUsername());
            }//w w w .  j ava  2 s . co m
        });
        return field;
    } else if (propertyId.equals("id")) {
        if (beanItem.getId() != null) {
            String attachmentPath = AttachmentUtils.getProjectEntityAttachmentPath(MyCollabUI.getAccountId(),
                    beanItem.getProjectid(), ProjectTypeConstants.BUG, "" + beanItem.getId());
            attachmentUploadField = new AttachmentUploadField(attachmentPath);
        } else {
            attachmentUploadField = new AttachmentUploadField();
        }
        return attachmentUploadField;
    } else if (propertyId.equals("severity")) {
        return new BugSeverityComboBox();
    } else if (propertyId.equals("components")) {
        componentSelect = new ComponentMultiSelectField();
        return componentSelect;
    } else if (propertyId.equals("affectedVersions")) {
        affectedVersionSelect = new VersionMultiSelectField();
        return affectedVersionSelect;
    } else if (propertyId.equals("fixedVersions")) {
        fixedVersionSelect = new VersionMultiSelectField();
        return fixedVersionSelect;
    } else if (propertyId.equals("name")) {
        final TextField tf = new TextField();
        if (isValidateForm) {
            tf.setNullRepresentation("");
            tf.setRequired(true);
            tf.setRequiredError(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL,
                    UserUIContext.getMessage(BugI18nEnum.FORM_SUMMARY)));
        }

        return tf;
    } else if (propertyId.equals("milestoneid")) {
        final MilestoneComboBox milestoneBox = new MilestoneComboBox();
        milestoneBox.addValueChangeListener(valueChangeEvent -> {
            String milestoneName = milestoneBox.getItemCaption(milestoneBox.getValue());
            beanItem.setMilestoneName(milestoneName);
        });
        return milestoneBox;
    } else if (BugWithBLOBs.Field.originalestimate.equalTo(propertyId)
            || (BugWithBLOBs.Field.remainestimate.equalTo(propertyId))) {
        return new DoubleField();
    } else if (propertyId.equals("selected")) {
        return subscribersComp;
    } else if (BugWithBLOBs.Field.startdate.equalTo(propertyId)
            || BugWithBLOBs.Field.enddate.equalTo(propertyId)
            || BugWithBLOBs.Field.duedate.equalTo(propertyId)) {
        return new DateTimeOptionField(true);
    }

    return null;
}

From source file:com.mycollab.module.project.view.milestone.MilestoneEditFormFieldFactory.java

License:Open Source License

@Override
protected Field<?> onCreateField(Object propertyId) {
    if (Milestone.Field.assignuser.equalTo(propertyId)) {
        ProjectMemberSelectionField memberSelectionField = new ProjectMemberSelectionField();
        memberSelectionField.setRequired(true);
        memberSelectionField.setRequiredError("Please select an assignee");
        return memberSelectionField;
    } else if (propertyId.equals("status")) {
        return new ProgressStatusComboBox();
    } else if (propertyId.equals("name")) {
        final TextField tf = new TextField();
        if (isValidateForm) {
            tf.setNullRepresentation("");
            tf.setRequired(true);// w w w  .j  a va  2  s .  com
            tf.setRequiredError("Please enter name");
        }
        return tf;
    } else if (propertyId.equals("description")) {
        RichTextArea descArea = new RichTextArea();
        descArea.setNullRepresentation("");
        return descArea;
    } else if (Milestone.Field.saccountid.equalTo(propertyId)) {
        Milestone beanItem = attachForm.getBean();
        if (beanItem.getId() != null) {
            String attachmentPath = AttachmentUtils.getProjectEntityAttachmentPath(MyCollabUI.getAccountId(),
                    beanItem.getProjectid(), ProjectTypeConstants.MILESTONE, "" + beanItem.getId());
            attachmentUploadField = new AttachmentUploadField(attachmentPath);
        } else {
            attachmentUploadField = new AttachmentUploadField();
        }
        return attachmentUploadField;
    }

    return null;
}

From source file:com.mycollab.module.project.view.settings.component.ComponentEditFormFieldFactory.java

License:Open Source License

@Override
protected Field<?> onCreateField(final Object propertyId) {
    if (Component.Field.name.equalTo(propertyId)) {
        final TextField tf = new TextField();
        if (isValidateForm) {
            tf.setNullRepresentation("");
            tf.setRequired(true);//from   ww  w  . j  av  a 2  s  . co  m
            tf.setRequiredError(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL,
                    UserUIContext.getMessage(GenericI18Enum.FORM_NAME)));
        }
        return tf;
    } else if (Component.Field.description.equalTo(propertyId)) {
        return new RichTextArea();
    } else if (Component.Field.userlead.equalTo(propertyId)) {
        return new ProjectMemberSelectionField();
    }

    return null;
}

From source file:com.mycollab.module.project.view.settings.component.VersionEditFormFieldFactory.java

License:Open Source License

@Override
protected Field<?> onCreateField(final Object propertyId) {
    if (Version.Field.name.equalTo(propertyId)) {
        final TextField tf = new TextField();
        if (isValidateForm) {
            tf.setNullRepresentation("");
            tf.setRequired(true);// w w w  .ja  v a  2 s  .c o m
            tf.setRequiredError(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL,
                    UserUIContext.getMessage(GenericI18Enum.FORM_NAME)));
        }
        return tf;
    } else if (Version.Field.description.equalTo(propertyId)) {
        return new RichTextArea();
    } else if (Version.Field.duedate.equalTo(propertyId)) {
        final PopupDateFieldExt dateField = new PopupDateFieldExt();
        dateField.setResolution(Resolution.DAY);
        return dateField;
    }

    return null;
}

From source file:com.mycollab.module.project.view.task.TaskEditFormFieldFactory.java

License:Open Source License

@Override
protected Field<?> onCreateField(final Object propertyId) {
    if (Task.Field.assignuser.equalTo(propertyId)) {
        ProjectMemberSelectionField field = new ProjectMemberSelectionField();
        field.addValueChangeListener(valueChangeEvent -> {
            Property property = valueChangeEvent.getProperty();
            SimpleProjectMember member = (SimpleProjectMember) property.getValue();
            if (member != null) {
                subscribersComp.addFollower(member.getUsername());
            }//from w w w  . jav  a  2  s .c  o m
        });
        return field;
    } else if (Task.Field.milestoneid.equalTo(propertyId)) {
        return new MilestoneComboBox();
    } else if (Task.Field.description.equalTo(propertyId)) {
        final RichTextArea richTextArea = new RichTextArea();
        richTextArea.setNullRepresentation("");
        return richTextArea;
    } else if (Task.Field.name.equalTo(propertyId)) {
        return new MTextField().withNullRepresentation("").withRequired(true)
                .withRequiredError(UserUIContext.getMessage(ErrorI18nEnum.FIELD_MUST_NOT_NULL,
                        UserUIContext.getMessage(GenericI18Enum.FORM_NAME)));
    } else if (Task.Field.status.equalTo(propertyId)) {
        return new TaskStatusComboBox();
    } else if (Task.Field.percentagecomplete.equalTo(propertyId)) {
        return new TaskSliderField();
    } else if (Task.Field.priority.equalTo(propertyId)) {
        return new PriorityComboBox();
    } else if (Task.Field.duration.equalTo(propertyId)) {
        final TextField field = new TextField();
        field.setConverter(new HumanTimeConverter());
        final SimpleTask beanItem = attachForm.getBean();
        if (beanItem.getNumSubTasks() != null && beanItem.getNumSubTasks() > 0) {
            field.setEnabled(false);
            field.setDescription(UserUIContext.getMessage(TaskI18nEnum.ERROR_CAN_NOT_EDIT_PARENT_TASK_FIELD));
        }

        //calculate the end date if the start date is set
        field.addBlurListener(blurEvent -> {
            HumanTime humanTime = HumanTime.eval(field.getValue());
            long duration = Long.valueOf(humanTime.getDelta() + "");
            DateTimeOptionField startDateField = (DateTimeOptionField) fieldGroup
                    .getField(Task.Field.startdate.name());
            Date startDateVal = startDateField.getValue();
            if (duration > 0 && startDateVal != null) {
                int daysDuration = (int) (duration / DateTimeUtils.MILLISECONDS_IN_A_DAY);
                if (daysDuration > 0) {
                    DateTime startDateJoda = new DateTime(startDateVal);
                    LocalDate calculatedDate = BusinessDayTimeUtils.plusDays(startDateJoda.toLocalDate(),
                            daysDuration);
                    DateTime endDateJoda = new DateTime(calculatedDate.toDate());
                    DateTimeOptionField endDateField = (DateTimeOptionField) fieldGroup
                            .getField(Task.Field.enddate.name());
                    beanItem.setEnddate(endDateJoda.toDate());
                    endDateField.setPropertyDataSource(
                            new TransactionalPropertyWrapper<>(new MethodProperty(beanItem, "enddate")));
                }
            }
        });
        return field;
    } else if (Task.Field.originalestimate.equalTo(propertyId)
            || Task.Field.remainestimate.equalTo(propertyId)) {
        return new DoubleField();
    } else if (Task.Field.startdate.equalTo(propertyId)) {
        final DateTimeOptionField startDateField = new DateTimeOptionField(true);
        startDateField.addValueChangeListener(valueChangeEvent -> calculateDurationBaseOnStartAndEndDates());
        return startDateField;
    } else if (Task.Field.enddate.equalTo(propertyId)) {
        DateTimeOptionField endDateField = new DateTimeOptionField(true);
        endDateField.addValueChangeListener(valueChangeEvent -> calculateDurationBaseOnStartAndEndDates());
        return endDateField;
    } else if (Task.Field.id.equalTo(propertyId)) {
        Task beanItem = attachForm.getBean();
        if (beanItem.getId() != null) {
            String attachmentPath = AttachmentUtils.getProjectEntityAttachmentPath(MyCollabUI.getAccountId(),
                    beanItem.getProjectid(), ProjectTypeConstants.TASK, "" + beanItem.getId());
            attachmentUploadField = new AttachmentUploadField(attachmentPath);
        } else {
            attachmentUploadField = new AttachmentUploadField();
        }
        return attachmentUploadField;
    } else if (Task.Field.duedate.equalTo(propertyId)) {
        return new DateTimeOptionField(true);
    } else if (propertyId.equals("selected")) {
        return subscribersComp;
    }
    return null;
}

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

License:Open Source License

private void initUI() {
    GridLayout mainLayout = new GridLayout(1, 5);
    mainLayout.setWidth("100%");
    mainLayout.setMargin(true);/*from w w w.ja v a2 s  .c  om*/
    mainLayout.setSpacing(true);

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

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

    inputPanel.addComponent(inputLayout);

    mainLayout.addComponent(inputPanel);

    tokenFieldMailTo = new EmailTokenField();

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

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

                    }
                } else {

                }
            }
        }
    }

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

    initButtonLinkCcBcc();

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

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

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

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

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

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

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

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

From source file:com.trivago.mail.pigeon.web.components.mail.ActionButtonColumnGenerator.java

License:Apache License

@Override
public Object generateCell(final Table source, final Object itemId, final Object columnId) {
    HorizontalLayout hl = new HorizontalLayout();
    Button showNlConentButton = new Button();
    showNlConentButton.setDescription("View");
    showNlConentButton.setImmediate(true);
    showNlConentButton.setIcon(new ThemeResource("../runo/icons/16/document-txt.png"));

    showNlConentButton.addListener(new Button.ClickListener() {
        @Override//from   w  ww  .  j av  a 2  s.  c  om
        public void buttonClick(Button.ClickEvent event) {
            Mail m = new Mail((Long) itemId);
            Window nlConentView = new Window("Newsletter Contents of ID " + itemId);
            // Create an empty tab sheet.
            TabSheet tabsheet = new TabSheet();

            Panel pText = new Panel("Text Content");
            Panel pHtml = new Panel("Text Content");
            RichTextArea textArea = new RichTextArea();
            textArea.setValue(m.getText());
            textArea.setReadOnly(true);

            RichTextArea richTextArea = new RichTextArea();
            richTextArea.setValue(m.getHtml());
            richTextArea.setReadOnly(true);

            pText.addComponent(textArea);
            pHtml.addComponent(richTextArea);

            richTextArea.setHeight("50%");
            richTextArea.setWidth("100%");
            textArea.setHeight("50%");
            textArea.setWidth("100%");

            nlConentView.setResizable(true);
            nlConentView.setWidth("800px");
            nlConentView.setHeight("600px");

            tabsheet.addTab(pText);
            tabsheet.getTab(pText).setCaption("Text Version");
            tabsheet.addTab(pHtml);
            tabsheet.getTab(pHtml).setCaption("Html Version");

            nlConentView.addComponent(tabsheet);
            source.getWindow().addWindow(nlConentView);
            nlConentView.setVisible(true);
        }
    });

    final Button showOpenendMails = new Button();
    showOpenendMails.setDescription("Show recipients of this mailling");
    showOpenendMails.setIcon(new ThemeResource("../runo/icons/16/users.png"));
    showOpenendMails.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Mail m = new Mail((Long) itemId);
            ModalRecipientListByMail modalRecipientListByMail = new ModalRecipientListByMail(m);
            source.getWindow().addWindow(modalRecipientListByMail);
            modalRecipientListByMail.setVisible(true);

        }
    });

    hl.addComponent(showNlConentButton);
    hl.addComponent(showOpenendMails);
    return hl;
}

From source file:de.unioninvestment.eai.portal.portlet.crud.mvp.views.DefaultTextAreaView.java

License:Apache License

@Override
public void showEditor(String xhtml) {

    final RichTextArea richTextArea = new RichTextArea();
    richTextArea.setNullRepresentation("");
    richTextArea.setWidth("100%");
    richTextArea.setValue(xhtml);//from ww w . j a  v  a  2s  .  c o m

    Button saveButton = new Button("Speichern", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            String changedContent = (String) richTextArea.getValue();
            presenter.contentChanged(changedContent);
        }
    });

    Button cancelButton = new Button("Abbrechen", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            presenter.cancelEditing();
        }
    });

    CssLayout buttons = new CssLayout(saveButton, cancelButton);
    buttons.setStyleName("actions");
    VerticalLayout layout = new VerticalLayout(richTextArea, buttons);
    layout.setSpacing(true);
    if (getHeight() >= 0f) {
        richTextArea.setHeight("100%");
        layout.setExpandRatio(richTextArea, 1f);
    }
    setCompositionRoot(layout);
}