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(ValueChangeListener<String> valueChangeListener) 

Source Link

Document

Constructs a new RichTextArea with a value change listener.

Usage

From source file:com.cavisson.gui.dashboard.components.controls.Forms.java

License:Apache License

public Forms() {
    setSpacing(true);//from   w  w w . j  a  v a 2  s  .  c o  m
    setMargin(true);

    Label title = new Label("Forms");
    title.addStyleName("h1");
    addComponent(title);

    final FormLayout form = new FormLayout();
    form.setMargin(false);
    form.setWidth("800px");
    form.addStyleName("light");
    addComponent(form);

    Label section = new Label("Personal Info");
    section.addStyleName("h2");
    section.addStyleName("colored");
    form.addComponent(section);
    StringGenerator sg = new StringGenerator();

    TextField name = new TextField("Name");
    name.setValue(sg.nextString(true) + " " + sg.nextString(true));
    name.setWidth("50%");
    form.addComponent(name);

    DateField birthday = new DateField("Birthday");
    birthday.setValue(new Date(80, 0, 31));
    form.addComponent(birthday);

    TextField username = new TextField("Username");
    username.setValue(sg.nextString(false) + sg.nextString(false));
    username.setRequired(true);
    form.addComponent(username);

    OptionGroup sex = new OptionGroup("Sex");
    sex.addItem("Female");
    sex.addItem("Male");
    sex.select("Male");
    sex.addStyleName("horizontal");
    form.addComponent(sex);

    section = new Label("Contact Info");
    section.addStyleName("h3");
    section.addStyleName("colored");
    form.addComponent(section);

    TextField email = new TextField("Email");
    email.setValue(sg.nextString(false) + "@" + sg.nextString(false) + ".com");
    email.setWidth("50%");
    email.setRequired(true);
    form.addComponent(email);

    TextField location = new TextField("Location");
    location.setValue(sg.nextString(true) + ", " + sg.nextString(true));
    location.setWidth("50%");
    location.setComponentError(new UserError("This address doesn't exist"));
    form.addComponent(location);

    TextField phone = new TextField("Phone");
    phone.setWidth("50%");
    form.addComponent(phone);

    HorizontalLayout wrap = new HorizontalLayout();
    wrap.setSpacing(true);
    wrap.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    wrap.setCaption("Newsletter");
    CheckBox newsletter = new CheckBox("Subscribe to newsletter", true);
    wrap.addComponent(newsletter);

    ComboBox period = new ComboBox();
    period.setTextInputAllowed(false);
    period.addItem("Daily");
    period.addItem("Weekly");
    period.addItem("Montly");
    period.setNullSelectionAllowed(false);
    period.select("Weekly");
    period.addStyleName("small");
    period.setWidth("10em");
    wrap.addComponent(period);
    form.addComponent(wrap);

    section = new Label("Additional Info");
    section.addStyleName("h4");
    section.addStyleName("colored");
    form.addComponent(section);

    TextField website = new TextField("Website");
    website.setInputPrompt("http://");
    website.setWidth("100%");
    form.addComponent(website);

    TextArea shortbio = new TextArea("Short Bio");
    shortbio.setValue(
            "Quis aute iure reprehenderit in voluptate velit esse. Cras mattis iudicium purus sit amet fermentum.");
    shortbio.setWidth("100%");
    shortbio.setRows(2);
    form.addComponent(shortbio);

    final RichTextArea bio = new RichTextArea("Bio");
    bio.setWidth("100%");
    bio.setValue(
            "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi  dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>");
    form.addComponent(bio);

    form.setReadOnly(true);
    bio.setReadOnly(true);

    Button edit = new Button("Edit", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            boolean readOnly = form.isReadOnly();
            if (readOnly) {
                bio.setReadOnly(false);
                form.setReadOnly(false);
                form.removeStyleName("light");
                event.getButton().setCaption("Save");
                event.getButton().addStyleName("primary");
            } else {
                bio.setReadOnly(true);
                form.setReadOnly(true);
                form.addStyleName("light");
                event.getButton().setCaption("Edit");
                event.getButton().removeStyleName("primary");
            }
        }
    });

    HorizontalLayout footer = new HorizontalLayout();
    footer.setMargin(new MarginInfo(true, false, true, false));
    footer.setSpacing(true);
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    form.addComponent(footer);
    footer.addComponent(edit);

    Label lastModified = new Label("Last modified by you a minute ago");
    lastModified.addStyleName("light");
    footer.addComponent(lastModified);
}

From source file:com.etest.valo.Forms.java

License:Apache License

public Forms() {
    setSpacing(true);//from  ww  w  .ja  v  a2  s  .c o  m
    setMargin(true);

    Label title = new Label("Forms");
    title.addStyleName("h1");
    addComponent(title);

    final FormLayout form = new FormLayout();
    form.setMargin(false);
    form.setWidth("800px");
    form.addStyleName("light");
    addComponent(form);

    Label section = new Label("Personal Info");
    section.addStyleName("h2");
    section.addStyleName("colored");
    form.addComponent(section);
    StringGenerator sg = new StringGenerator();

    TextField name = new TextField("Name");
    name.setValue(sg.nextString(true) + " " + sg.nextString(true));
    name.setWidth("50%");
    form.addComponent(name);

    DateField birthday = new DateField("Birthday");
    birthday.setValue(new Date(80, 0, 31));
    form.addComponent(birthday);

    TextField username = new TextField("Username");
    username.setValue(sg.nextString(false) + sg.nextString(false));
    username.setRequired(true);
    form.addComponent(username);

    OptionGroup sex = new OptionGroup("Sex");
    sex.addItem("Female");
    sex.addItem("Male");
    sex.select("Male");
    sex.addStyleName("horizontal");
    form.addComponent(sex);

    section = new Label("Contact Info");
    section.addStyleName("h3");
    section.addStyleName("colored");
    form.addComponent(section);

    TextField email = new TextField("Email");
    email.setValue(sg.nextString(false) + "@" + sg.nextString(false) + ".com");
    email.setWidth("50%");
    email.setRequired(true);
    form.addComponent(email);

    TextField location = new TextField("Location");
    location.setValue(sg.nextString(true) + ", " + sg.nextString(true));
    location.setWidth("50%");
    location.setComponentError(new UserError("This address doesn't exist"));
    form.addComponent(location);

    TextField phone = new TextField("Phone");
    phone.setWidth("50%");
    form.addComponent(phone);

    HorizontalLayout wrap = new HorizontalLayout();
    wrap.setSpacing(true);
    wrap.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    wrap.setCaption("Newsletter");
    CheckBox newsletter = new CheckBox("Subscribe to newsletter", true);
    wrap.addComponent(newsletter);

    ComboBox period = new ComboBox();
    period.setTextInputAllowed(false);
    period.addItem("Daily");
    period.addItem("Weekly");
    period.addItem("Monthly");
    period.setNullSelectionAllowed(false);
    period.select("Weekly");
    period.addStyleName("small");
    period.setWidth("10em");
    wrap.addComponent(period);
    form.addComponent(wrap);

    section = new Label("Additional Info");
    section.addStyleName("h4");
    section.addStyleName("colored");
    form.addComponent(section);

    TextField website = new TextField("Website");
    website.setInputPrompt("http://");
    website.setWidth("100%");
    form.addComponent(website);

    TextArea shortbio = new TextArea("Short Bio");
    shortbio.setValue(
            "Quis aute iure reprehenderit in voluptate velit esse. Cras mattis iudicium purus sit amet fermentum.");
    shortbio.setWidth("100%");
    shortbio.setRows(2);
    form.addComponent(shortbio);

    final RichTextArea bio = new RichTextArea("Bio");
    bio.setWidth("100%");
    bio.setValue(
            "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi  dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>");
    form.addComponent(bio);

    form.setReadOnly(true);
    bio.setReadOnly(true);

    Button edit = new Button("Edit", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            boolean readOnly = form.isReadOnly();
            if (readOnly) {
                bio.setReadOnly(false);
                form.setReadOnly(false);
                form.removeStyleName("light");
                event.getButton().setCaption("Save");
                event.getButton().addStyleName("primary");
            } else {
                bio.setReadOnly(true);
                form.setReadOnly(true);
                form.addStyleName("light");
                event.getButton().setCaption("Edit");
                event.getButton().removeStyleName("primary");
            }
        }
    });

    HorizontalLayout footer = new HorizontalLayout();
    footer.setMargin(new MarginInfo(true, false, true, false));
    footer.setSpacing(true);
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    form.addComponent(footer);
    footer.addComponent(edit);

    Label lastModified = new Label("Last modified by you a minute ago");
    lastModified.addStyleName("light");
    footer.addComponent(lastModified);
}

From source file:com.hivesys.dashboard.view.preferences.PreferencesView.java

License:Apache License

public PreferencesView() {

    user = (User) VaadinSession.getCurrent().getAttribute(User.class.getName());

    setSpacing(true);/*w  w  w .  j av  a2s.  c  o m*/
    setMargin(true);

    Label title = new Label("Forms");
    title.addStyleName("h1");
    addComponent(title);

    final FormLayout form = new FormLayout();
    form.setMargin(false);
    form.setWidth("800px");
    form.addStyleName("light");
    addComponent(form);

    Label section = new Label("Personal Info");
    section.addStyleName("h2");
    section.addStyleName("colored");
    form.addComponent(section);

    firstNameField = new TextField("First Name");
    firstNameField.setWidth("50%");
    form.addComponent(firstNameField);

    lastNameField = new TextField("Last Name");
    lastNameField.setWidth("50%");
    form.addComponent(lastNameField);

    titleField = new ComboBox("Title");
    titleField.setInputPrompt("Please specify");
    titleField.addItem("Mr.");
    titleField.addItem("Mrs.");
    titleField.addItem("Ms.");
    titleField.setNewItemsAllowed(true);
    form.addComponent(titleField);

    usernameField = new TextField("Username");
    usernameField.setRequired(true);
    form.addComponent(usernameField);

    sexField = new OptionGroup("Sex");
    sexField.addItem(Boolean.FALSE);
    sexField.setItemCaption(Boolean.FALSE, "Female");
    sexField.addItem(Boolean.TRUE);
    sexField.setItemCaption(Boolean.TRUE, "Male");
    sexField.addStyleName("horizontal");
    form.addComponent(sexField);

    section = new Label("Contact Info");
    section.addStyleName("h3");
    section.addStyleName("colored");
    form.addComponent(section);

    emailField = new TextField("Email");
    emailField.setWidth("50%");
    emailField.setRequired(true);
    form.addComponent(emailField);

    locationField = new TextField("Location");
    locationField.setWidth("50%");
    locationField.setNullRepresentation("");
    form.addComponent(locationField);

    phoneField = new TextField("Phone");
    phoneField.setWidth("50%");
    phoneField.setNullRepresentation("");
    form.addComponent(phoneField);

    section = new Label("Additional Info");
    section.addStyleName("h4");
    section.addStyleName("colored");
    form.addComponent(section);

    websiteField = new TextField("Website");
    websiteField.setInputPrompt("http://");
    websiteField.setWidth("100%");
    form.addComponent(websiteField);

    bioField = new RichTextArea("Bio");
    bioField.setWidth("100%");
    bioField.setValue(
            "<div><p><span>Integer legentibus erat a ante historiarum dapibus.</span> <span>Vivamus sagittis lacus vel augue laoreet rutrum faucibus.</span> <span>A communi observantia non est recedendum.</span> <span>Morbi fringilla convallis sapien, id pulvinar odio volutpat.</span> <span>Ab illo tempore, ab est sed immemorabili.</span> <span>Quam temere in vitiis, legem sancimus haerentia.</span></p><p><span>Morbi odio eros, volutpat ut pharetra vitae, lobortis sed nibh.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Cum sociis natoque penatibus et magnis dis parturient.</span> <span>Quam diu etiam furor iste tuus nos eludet?</span> <span>Tityre, tu patulae recubans sub tegmine fagi  dolor.</span></p><p><span>Curabitur blandit tempus ardua ridiculus sed magna.</span> <span>Phasellus laoreet lorem vel dolor tempus vehicula.</span> <span>Etiam habebis sem dicantur magna mollis euismod.</span> <span>Hi omnes lingua, institutis, legibus inter se differunt.</span></p></div>");
    form.addComponent(bioField);

    Button edit = new Button("Edit", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            boolean readOnly = form.isReadOnly();
            if (readOnly) {
                bioField.setReadOnly(false);
                form.setReadOnly(false);
                form.removeStyleName("light");
                event.getButton().setCaption("Save");
                event.getButton().addStyleName("primary");
            } else {
                bioField.setReadOnly(true);
                form.setReadOnly(true);
                form.addStyleName("light");
                event.getButton().setCaption("Edit");
                event.getButton().removeStyleName("primary");
            }
        }
    });

    HorizontalLayout footer = new HorizontalLayout();
    footer.setMargin(new MarginInfo(true, false, true, false));
    footer.setSpacing(true);
    footer.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    form.addComponent(footer);
    footer.addComponent(edit);

    Label lastModified = new Label("Last modified by you a minute ago");
    lastModified.addStyleName("light");
    footer.addComponent(lastModified);

    fieldGroup = new BeanFieldGroup<>(User.class);
    fieldGroup.bindMemberFields(this);
    fieldGroup.setItemDataSource(user);

    form.setReadOnly(true);
    bioField.setReadOnly(true);

}

From source file:fr.amapj.view.engine.popup.formpopup.AbstractFormPopup.java

License:Open Source License

protected RichTextArea addRichTextAeraField(String title, Object propertyId) {
    RichTextArea f = new RichTextArea(title);
    binder.bind(f, propertyId);/*from  ww w . ja v  a 2 s .c o m*/

    f.setNullRepresentation("");
    f.setStyleName(ChameleonTheme.TEXTFIELD_BIG);
    f.setWidth("80%");
    form.addComponent(f);

    return f;
}

From source file:fr.amapj.view.views.sendmail.SendMailView.java

License:Open Source License

/**
 * //from  w ww .  ja  v  a  2 s.c om
 */
@Override
public void enterIn(ViewChangeEvent event) {

    ParametresDTO param = new ParametresService().getParametres();

    VerticalLayout layout = this;

    addLabel(layout, "Cet outil permet d'envoyer un mail  une personne, ou  tous les utilisateurs actifs.");
    addLabel(layout, "Cet outil permet de tester le bon fonctionnement de l'envoi des mails");
    addLabel(layout,
            "Cet outil ne devrait pas tre utilis pour une communication rgulire avec les amapiens.");
    addEmptyLine(layout);

    TextField expediteur = addTextField(layout, "Expditeur du mail");
    expediteur.setEnabled(false);
    expediteur.setValue(param.sendingMailUsername);

    titre = addTextField(layout, "Titre du mail");

    destinataires = addTextField(layout, "Destinataire du mail");

    zoneTexte = new RichTextArea("Message");
    zoneTexte.setWidth("100%");
    zoneTexte.setHeight("500px");

    layout.addComponent(zoneTexte);

    addButton(layout, "Envoyer", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            handleEnvoyerMail();
        }
    });

}

From source file:org.processbase.ui.bpm.generator.GeneratedWindow.java

License:Open Source License

private RichTextArea getRichTextArea(Widget widget) {
    RichTextArea component = new RichTextArea(widget.getLabel());
    component.setNullRepresentation("");
    return component;
}

From source file:org.processbase.ui.core.template.HumanTaskWindow.java

License:Open Source License

public void initUI() {
    //        System.out.println("ProcessbaseApplication.getCurrent() = " + ProcessbaseApplication.getCurrent());
    //        System.out.println("currentUserName = " + ProcessbaseApplication.getCurrent().getUserName());
    currentUserName = ProcessbaseApplication.getCurrent().getUserName();
    bpmModule = ProcessbaseApplication.getCurrent().getBpmModule();
    messages = ProcessbaseApplication.getCurrent().getPbMessages();
    commentEditor = new RichTextArea(messages.getString("addComment"));
    addCommentBtn = new Button(messages.getString("btnSave"), (Button.ClickListener) this);

    if (taskInstance != null) {
        mainLayout = new VerticalLayout();
        prepareTopBar();//from   w  w w. j  a va 2  s. c  o m
        //addDescription();
        layout.setSizeFull();
        layout.setMargin(true, true, true, true);
        layout.setSpacing(false);
        mainLayout.addComponent(layout);
        mainLayout.setExpandRatio(layout, 1.0f);
        mainLayout.setMargin(false);
        mainLayout.setSpacing(false);
    } else {
        mainLayout = new HorizontalLayout();
        mainLayout.setMargin(true);
        mainLayout.setSpacing(true);
    }
    mainLayout.setStyleName("white");

    if (custom) {
        prepareCustom();
    } else if (!custom) { // set only for generated window
        mainLayout.setSizeFull();
    }
    prepareVariables();
    preparePanel();
    if (taskInstance != null) {
        prepareComments();
    }

    //        mainLayout.setStyleName(Reindeer.LAYOUT_BLACK);
    //        setStyleName(Reindeer.LAYOUT_WHITE);
    //        layout.setStyleName(Reindeer.LAYOUT_BLUE);
    setContent(mainLayout);
    setWidth("90%");
    setHeight("90%");
    center();
    setModal(true);
    setResizable(false);
}

From source file:org.processbase.ui.core.template.HumanTaskWindow.java

License:Open Source License

private void prepareComments() {
    commentsLayout.setWidth("100%");
    commentsLayout.setMargin(true);/*www .  j a v a 2  s . c  om*/
    commentsLayout.setSpacing(true);
    commentsLayout.removeAllComponents();
    List<Comment> comments = new ArrayList<Comment>(0);
    try {
        comments = bpmModule.getCommentFeed(taskInstance.getProcessInstanceUUID());
    } catch (Exception ex) {
        ex.printStackTrace();
    }

    for (Comment comment : comments) {
        commentsLayout
                .addComponent(getCommentPanel(comment.getDate(), comment.getUserId(), comment.getMessage()));
    }
    commentEditor = new RichTextArea(messages.getString("addComment"));
    commentEditor.setWidth("100%");
    commentEditor.setNullRepresentation("");
    commentsLayout.addComponent(commentEditor);
    commentsLayout.addComponent(addCommentBtn);

    tabSheet.addTab(commentsLayout, messages.getString("comments") + " (" + comments.size() + ")",
            new ThemeResource("icons/comment_yellow.gif"));
}

From source file:ru.codeinside.adm.ui.CrudNews.java

License:Mozilla Public License

private AbstractField createField(String caption, Boolean readOnly) {
    AbstractField textField;//ww w .java 2 s . c  om
    if (caption.equals("")) {
        textField = new RichTextArea(caption);
    } else {
        textField = new TextField(caption);
        ((TextField) textField).setMaxLength(255);
    }
    textField.setImmediate(true);
    textField.setWidth("40%");
    textField.setReadOnly(readOnly);
    return textField;
}

From source file:ui.wizard.CreateEmailStep.java

License:Apache License

public CreateEmailStep(JobOffer jobOffer, JobApplication jobApplication) {
    super(jobApplication.getUserId(), jobApplication.getLanguage());
    this.jobOffer = jobOffer;
    this.jobApplication = jobApplication;
    output = new LifetimeLabel("", getLanguage(), ContentMode.HTML);
    template = new EmailTextComboBox(getUserId(), getLanguage());
    template.addValueChangeListener(this);

    email = new RichTextArea("Email text");
    email.addValueChangeListener(this);
    email.setValue(getDefaultEmailBody());
    email.setSizeFull();// w ww. ja  v a2 s . c  o  m
}