Example usage for com.vaadin.ui RichTextArea setValue

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

Introduction

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

Prototype

@Override
public void setValue(String value) 

Source Link

Document

Sets the value of this object.

Usage

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

License:Apache License

public Forms() {
    setSpacing(true);/*from   w ww .j  av 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.cavisson.gui.dashboard.components.controls.TextFields.java

License:Apache License

public TextFields() {
    setMargin(true);//from  w  ww. j  a  v  a2s .  co m

    Label h1 = new Label("Text Fields");
    h1.addStyleName("h1");
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    TextField tf = new TextField("Normal");
    tf.setInputPrompt("First name");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField("Custom color");
    tf.setInputPrompt("Email");
    tf.addStyleName("color1");
    row.addComponent(tf);

    tf = new TextField("User Color");
    tf.setInputPrompt("Gender");
    tf.addStyleName("color2");
    row.addComponent(tf);

    tf = new TextField("Themed");
    tf.setInputPrompt("Age");
    tf.addStyleName("color3");
    row.addComponent(tf);

    tf = new TextField("Error");
    tf.setValue("Somethings wrong");
    tf.setComponentError(new UserError("Fix it, now!"));
    row.addComponent(tf);

    tf = new TextField("Error, borderless");
    tf.setValue("Somethings wrong");
    tf.setComponentError(new UserError("Fix it, now!"));
    tf.addStyleName("borderless");
    row.addComponent(tf);

    tf = new TextField("Read-only");
    tf.setInputPrompt("Nationality");
    tf.setValue("Finnish");
    tf.setReadOnly(true);
    row.addComponent(tf);

    tf = new TextField("Small");
    tf.setValue("Field value");
    tf.addStyleName("small");
    row.addComponent(tf);

    tf = new TextField("Large");
    tf.setValue("Field value");
    tf.addStyleName("large");
    tf.setIcon(testIcon.get(true));
    row.addComponent(tf);

    tf = new TextField("Icon inside");
    tf.setInputPrompt("Ooh, an icon");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField("Large, Icon inside");
    tf.setInputPrompt("Ooh, an icon");
    tf.addStyleName("large");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField("Small, Icon inside");
    tf.setInputPrompt("Ooh, an icon");
    tf.addStyleName("small");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField("16px supported by default");
    tf.setInputPrompt("Image icon");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get(true, 16));
    row.addComponent(tf);

    tf = new TextField();
    tf.setValue("Font, no caption");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField();
    tf.setValue("Image, no caption");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get(true, 16));
    row.addComponent(tf);

    CssLayout group = new CssLayout();
    group.addStyleName("v-component-group");
    row.addComponent(group);

    tf = new TextField();
    tf.setInputPrompt("Grouped with a button");
    tf.addStyleName("inline-icon");
    tf.setIcon(testIcon.get());
    tf.setWidth("260px");
    group.addComponent(tf);

    Button button = new Button("Do It");
    // button.addStyleName("primary");
    group.addComponent(button);

    tf = new TextField("Borderless");
    tf.setInputPrompt("Write here");
    tf.addStyleName("inline-icon");
    tf.addStyleName("borderless");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField("Right-aligned");
    tf.setValue("1,234");
    tf.addStyleName("align-right");
    row.addComponent(tf);

    tf = new TextField("Centered");
    tf.setInputPrompt("Guess what?");
    tf.addStyleName("align-center");
    row.addComponent(tf);

    PasswordField pwf = new PasswordField("Password");
    pwf.setInputPrompt("Secret words");
    pwf.addStyleName("inline-icon");
    pwf.setIcon(FontAwesome.LOCK);
    row.addComponent(pwf);

    pwf = new PasswordField("Password, right-aligned");
    pwf.setInputPrompt("Secret words");
    pwf.addStyleName("inline-icon");
    pwf.addStyleName("align-right");
    pwf.setIcon(FontAwesome.LOCK);
    row.addComponent(pwf);

    pwf = new PasswordField("Password, centered");
    pwf.setInputPrompt("Secret words");
    pwf.addStyleName("inline-icon");
    pwf.addStyleName("align-center");
    pwf.setIcon(FontAwesome.LOCK);
    row.addComponent(pwf);

    tf = new TextField("Tiny");
    tf.setValue("Field value");
    tf.addStyleName("tiny");
    row.addComponent(tf);

    tf = new TextField("Huge");
    tf.setValue("Field value");
    tf.addStyleName("huge");
    row.addComponent(tf);

    h1 = new Label("Text Areas");
    h1.addStyleName("h1");
    addComponent(h1);

    row = new HorizontalLayout();
    row.addStyleName("wrapping");
    row.setSpacing(true);
    addComponent(row);

    TextArea ta = new TextArea("Normal");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    ta = new TextArea("Inline icon");
    ta.setInputPrompt("Inline icon not really working");
    ta.addStyleName("inline-icon");
    ta.setIcon(testIcon.get());
    row.addComponent(ta);

    ta = new TextArea("Custom color");
    ta.addStyleName("color1");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    ta = new TextArea("Custom color, read-only");
    ta.addStyleName("color2");
    ta.setValue("Field value, spanning multiple lines of text");
    ta.setReadOnly(true);
    row.addComponent(ta);

    ta = new TextArea("Custom color");
    ta.addStyleName("color3");
    ta.setValue("Field value, spanning multiple lines of text");
    row.addComponent(ta);

    ta = new TextArea("Small");
    ta.addStyleName("small");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    ta = new TextArea("Large");
    ta.addStyleName("large");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    ta = new TextArea("Borderless");
    ta.addStyleName("borderless");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    ta = new TextArea("Right-aligned");
    ta.addStyleName("align-right");
    ta.setValue("Field value, spanning multiple lines of text");
    row.addComponent(ta);

    ta = new TextArea("Centered");
    ta.addStyleName("align-center");
    ta.setValue("Field value, spanning multiple lines of text");
    row.addComponent(ta);

    ta = new TextArea("Tiny");
    ta.addStyleName("tiny");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    ta = new TextArea("Huge");
    ta.addStyleName("huge");
    ta.setInputPrompt("Write your comment");
    row.addComponent(ta);

    RichTextArea rta = new RichTextArea();
    rta.setValue("<b>Some</b> <i>rich</i> content");
    row.addComponent(rta);

    rta = new RichTextArea("Read-only");
    rta.setValue("<b>Some</b> <i>rich</i> content");
    rta.setReadOnly(true);
    row.addComponent(rta);
}

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

License:Apache License

public Forms() {
    setSpacing(true);/*from   www  .  j  ava2s .c  om*/
    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.mcparland.john.AdjustableLayout.java

License:Apache License

/**
 * Create the editor panel./* w  w  w. java 2  s .c o  m*/
 * 
 * @return the editor panel.
 */
private Component createEditorPanel() {
    SafeHtml safeHtml = SafeHtmlUtils.fromSafeConstant("<b>Help</b> <br />" + LIPSUM);
    HorizontalSplitPanel editorPanel = new HorizontalSplitPanel();
    RichTextArea editor = new RichTextArea();
    editor.setSizeFull();
    editor.setValue(LIPSUM);
    editorPanel.setFirstComponent(editor);
    editorPanel.setSecondComponent(new Label(safeHtml.asString(), ContentMode.HTML));
    editorPanel.setSplitPosition(80, Unit.PERCENTAGE);
    return editorPanel;
}

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 w  w .  j av a  2 s  . c  o  m
        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);

    Button saveButton = new Button("Speichern", new Button.ClickListener() {
        @Override/*w w w. j ava 2s. c  o m*/
        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);
}

From source file:de.unioninvestment.portal.explorer.view.vfs.HelpView.java

License:Apache License

public HelpView() {
    final RichTextArea rtarea = new RichTextArea();

    rtarea.setCaption("VFSFileExplorerPortlet");

    rtarea.setValue("<h1>Configuration Example</h1>\n" + "<h2>File access</h2>\n"
            + "windows : file:///C:/Temp\n" + "unix: file:///home/someuser/somedir\n" + "\n"
            + "<h2>FTP access</h2>\n" + "ftp://hostname[: port]\n " + "plus username and password\n" + "\n"
            + "<h2>SFTP access</h2>\n" + "sftp://hostname[: port][ absolute-path]\n "
            + "plus username and password \n" + "and / or\n "
            + "path to keyfile like /home/user/keyfile/id_rsa ");
    rtarea.setReadOnly(true);/*from ww  w.j a va 2 s .co  m*/
    addComponent(rtarea);
}

From source file:fr.ortec.dsi.pointage.presentation.ihm.view.TextFields.java

License:Apache License

public TextFields() {
    setMargin(true);/*from w  w  w.  j a v a  2  s  . com*/
    setSpacing(true);

    Label h1 = new Label("Text Fields");
    h1.addStyleName(ValoTheme.LABEL_H1);
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
    addComponent(row);

    TextField tf = new TextField("Normal");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField("Custom color");
    tf.addStyleName("color1");
    row.addComponent(tf);

    tf = new TextField("User Color");
    tf.addStyleName("color2");
    row.addComponent(tf);

    tf = new TextField("Themed");
    tf.addStyleName("color3");
    row.addComponent(tf);

    tf = new TextField("Error");
    tf.setValue("Somethings wrong");
    tf.setComponentError(new UserError("Fix it, now!"));
    row.addComponent(tf);

    tf = new TextField("Error, borderless");
    tf.setValue("Somethings wrong");
    tf.setComponentError(new UserError("Fix it, now!"));
    tf.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    row.addComponent(tf);

    tf = new TextField("Small");
    tf.setValue("Field value");
    tf.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    row.addComponent(tf);

    tf = new TextField("Large");
    tf.setValue("Field value");
    tf.addStyleName(ValoTheme.TEXTFIELD_LARGE);
    tf.setIcon(testIcon.get(true));
    row.addComponent(tf);

    tf = new TextField();
    tf.setValue("Font, no caption");
    tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField();
    tf.setValue("Image, no caption");
    tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    tf.setIcon(testIcon.get(true, 16));
    row.addComponent(tf);

    CssLayout group = new CssLayout();
    group.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    row.addComponent(group);

    Button button = new Button("Do It");
    // button.addStyleName(ValoTheme.BUTTON_PRIMARY);
    group.addComponent(button);

    tf = new TextField("Right-aligned");
    tf.setValue("1,234");
    tf.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);
    row.addComponent(tf);

    tf = new TextField("Tiny");
    tf.setValue("Field value");
    tf.addStyleName(ValoTheme.TEXTFIELD_TINY);
    row.addComponent(tf);

    tf = new TextField("Huge");
    tf.setValue("Field value");
    tf.addStyleName(ValoTheme.TEXTFIELD_HUGE);
    row.addComponent(tf);

    h1 = new Label("Text Areas");
    h1.addStyleName(ValoTheme.LABEL_H1);
    addComponent(h1);

    row = new HorizontalLayout();
    row.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
    addComponent(row);

    RichTextArea rta = new RichTextArea();
    rta.setValue("<b>Some</b> <i>rich</i> content");
    row.addComponent(rta);

    rta = new RichTextArea("Read-only");
    rta.setValue("<b>Some</b> <i>rich</i> content");
    rta.setReadOnly(true);
    row.addComponent(rta);
}

From source file:org.hip.vif.admin.groupadmin.ui.CompletionView.java

License:Open Source License

/** @param inEditor
 * @param inValueBefore// ww w .  j  a v  a 2  s.  com
 * @param inMessages
 * @param inTask
 * @return Button */
private Button createSaveButton(final RichTextArea inEditor, final String inValueBefore,
        final IMessages inMessages, final AbstractCompletionTask inTask) {
    final Button lSave = new Button(inMessages.getMessage("ui.button.save")); //$NON-NLS-1$
    lSave.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent inEvent) {
            final String lValue = inEditor.getValue();
            if (checkEditorInput(lValue)) { //$NON-NLS-1$
                inEditor.setValue(inValueBefore); //$NON-NLS-1$
                Notification.show(inMessages.getMessage("errmsg.completion.not.empty"), Type.WARNING_MESSAGE); //$NON-NLS-1$
                return;
            }
            if (!inTask.saveCompletion(lValue)) {
                Notification.show(inMessages.getMessage("errmsg.save.general"), Type.WARNING_MESSAGE); //$NON-NLS-1$
            }
        }
    });
    return lSave;
}

From source file:org.hip.vif.admin.groupadmin.ui.CompletionView.java

License:Open Source License

private RichTextArea createEditField(final String inContent, final int inHeight) {
    final RichTextArea outEditor = new RichTextArea();
    outEditor.setWidth("70%"); //$NON-NLS-1$
    outEditor.setHeight(inHeight, Unit.PIXELS);
    outEditor.setValue(inContent);
    outEditor.setStyleName("vif-editor"); //$NON-NLS-1$
    return outEditor;
}