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: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);//ww  w. j  av a  2s  .c  o  m
    addComponent(rtarea);
}

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

License:Apache License

public TextFields() {
    setMargin(true);// w w w.j  a v a  2 s. co m
    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:module.contents.presentationTier.component.ContentEditorLayout.java

License:Open Source License

public ContentEditorLayout(final String okButtonTitle, final boolean plainHtmlEditor) {
    setSpacing(true);/*w  ww.ja v a2 s .  c  o m*/
    setMargin(true);
    setSizeUndefined();

    titleField.setImmediate(true);
    titleField.setColumns(50);
    addComponent(titleField);

    richTextArea = plainHtmlEditor ? titleField : new RichTextArea();
    //   richTextArea.setNullSettingAllowed(true);
    //   richTextArea.setNullRepresentation(StringUtils.EMPTY);
    richTextArea.setWidth("600px");
    richTextArea.setHeight("350px");
    richTextArea.setImmediate(true);
    richTextArea.setWriteThrough(true);
    richTextArea.setEnabled(true);
    addComponent(richTextArea);

    final HorizontalLayout horizontalLayout = new HorizontalLayout();

    final Button save = new Button(getMessage(okButtonTitle), new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (contentEditorSaveListner != null) {
                contentEditorSaveListner.save((String) titleField.getValue(), (String) richTextArea.getValue());
            }
        }
    });
    horizontalLayout.addComponent(save);

    final Button close = new Button(getMessage("label.close"), new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (contentEditorCloseListner != null) {
                contentEditorCloseListner.close();
            }
        }
    });
    horizontalLayout.addComponent(close);

    addComponent(horizontalLayout);
}

From source file:org.hip.vif.admin.admin.ui.SendMailView.java

License:Open Source License

/** @param inGroups {@link GroupContainer}
 * @param inTask {@link SendMailTask} */
public SendMailView(final GroupContainer inGroups, final SendMailTask inTask) {
    final IMessages lMessages = Activator.getMessages();
    final VerticalLayout lLayout = initLayout(lMessages, "admin.send.mail.title.page"); //$NON-NLS-1$

    lLayout.addComponent(new Label(lMessages.getMessage("admin.send.remark"), ContentMode.HTML)); //$NON-NLS-1$
    lLayout.addComponent(RiplaViewHelper.createSpacer());

    final LabelValueTable lTable = new LabelValueTable();
    final ListSelect lGroups = new ListSelect();
    lGroups.setContainerDataSource(inGroups);
    lGroups.setRows(Math.min(SELECT_SIZE, inGroups.size()));
    lGroups.setStyleName(VIF_STYLE);/*from   w  ww . j a  v a 2  s .  c o m*/
    lGroups.setMultiSelect(true);
    lGroups.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    lGroups.setItemCaptionPropertyId(GroupContainer.PROPERTY_CAPTION);
    lGroups.focus();
    lTable.addRowEmphasized(lMessages.getMessage("admin.send.mail.label.select"), lGroups); //$NON-NLS-1$

    final TextField lSubject = new TextField();
    lSubject.setWidth(WIDTH, Unit.PIXELS);
    lSubject.setStyleName(VIF_STYLE);
    lTable.addRowEmphasized(lMessages.getMessage("admin.send.mail.label.subject"), lSubject); //$NON-NLS-1$

    final RichTextArea lBody = new RichTextArea();
    lBody.setStyleName("vif-editor " + VIF_STYLE); //$NON-NLS-1$
    lBody.setWidth(WIDTH, Unit.PIXELS);
    lTable.addRowEmphasized(lMessages.getMessage("admin.send.mail.label.body"), lBody); //$NON-NLS-1$
    lLayout.addComponent(lTable);

    send = new Button(lMessages.getMessage("admin.send.mail.button.send")); //$NON-NLS-1$
    // send.setClickShortcut(KeyCode.ENTER);
    send.addClickListener(new Button.ClickListener() {
        @Override
        @SuppressWarnings("unchecked")
        public void buttonClick(final ClickEvent inEvent) {
            if (!isValid(lGroups, lSubject, lBody)) {
                Notification.show(lMessages.getMessage("admin.send.mail.msg.not.valid"), //$NON-NLS-1$
                        Type.WARNING_MESSAGE);
                return;
            }
            if (!inTask.processGroups((Collection<GroupWrapper>) lGroups.getValue(),
                    lSubject.getValue().toString(), lBody.getValue())) {
                Notification.show(lMessages.getMessage("admin.send.mail.msg.errmsg"), Type.WARNING_MESSAGE); //$NON-NLS-1$
            }
        }
    });
    lLayout.addComponent(send);
}

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);//from w  w  w  .j  av a2 s. c om
    outEditor.setStyleName("vif-editor"); //$NON-NLS-1$
    return outEditor;
}

From source file:org.hip.vif.forum.groups.ui.CompletionView.java

License:Open Source License

/** Constructor
 *
 * @param inCompletion String the completion text
 * @param inCompletionID Long/*  w  w  w  .  ja v a2 s  . com*/
 * @param inQuestion {@link DomainObject} the question the completion is belonging to
 * @param inCompletions {@link QueryResult} other completions belonging to the question
 * @param inGroup {@link Group} the discussion group the question belongs to
 * @param inCodeList {@link CodeList} the code list for the contributions' workflow states
 * @param inTask {@link AbstractCompletionTask}
 * @throws VException
 * @throws SQLException */
public CompletionView(final String inCompletion, final Long inCompletionID, final DomainObject inQuestion,
        final QueryResult inCompletions, final Group inGroup, final CodeList inCodeList,
        final AbstractCompletionTask inTask) throws VException, SQLException {
    final VerticalLayout lLayout = new VerticalLayout();
    setCompositionRoot(lLayout);

    final IMessages lMessages = Activator.getMessages();
    lLayout.setStyleName("vif-view"); //$NON-NLS-1$
    final String lTitle = String.format(lMessages.getFormattedMessage("ui.completion.group.title", //$NON-NLS-1$
            BeanWrapperHelper.getString(GroupHome.KEY_ID, inGroup),
            BeanWrapperHelper.getString(GroupHome.KEY_NAME, inGroup)));
    lLayout.addComponent(
            new Label(String.format(VIFViewHelper.TMPL_TITLE, "vif-title", lTitle), ContentMode.HTML)); //$NON-NLS-1$

    final String lSubTitle = String.format(lMessages.getFormattedMessage("ui.completion.title", //$NON-NLS-1$
            BeanWrapperHelper.getPlain(QuestionHome.KEY_QUESTION_DECIMAL, inQuestion)));
    lLayout.addComponent(
            new Label(String.format(VIFViewHelper.TMPL_TITLE, "vif-pagetitle", lSubTitle), ContentMode.HTML)); //$NON-NLS-1$

    addProperQuestion(inQuestion, lMessages, lLayout);

    // completions
    while (inCompletions.hasMoreElements()) {
        final GeneralDomainObject lCompletionBO = inCompletions.next();
        final Long lCompletionID = BeanWrapperHelper.getLong(CompletionHome.KEY_ID, lCompletionBO);
        // we have to filter out the actual completion in the edit case because this completion is displayed in the
        // editor
        if (!lCompletionID.equals(inCompletionID)) {
            lLayout.addComponent(createCompletion(lCompletionBO, inCodeList, lMessages, false, inTask));
        }
    }

    lLayout.addComponent(new Label(String.format(VIFViewHelper.TMPL_TITLE, "vif-subtitle", //$NON-NLS-1$
            lMessages.getMessage("ui.completion.label")), ContentMode.HTML)); //$NON-NLS-1$

    completionEditor = new RichTextArea();
    completionEditor.setWidth("70%"); //$NON-NLS-1$
    completionEditor.setHeight(250, Unit.PIXELS);
    completionEditor.setValue(inCompletion);
    completionEditor.setStyleName("vif-editor"); //$NON-NLS-1$
    lLayout.addComponent(completionEditor);

    final Button lSave = new Button(lMessages.getMessage("ui.button.save")); //$NON-NLS-1$
    lLayout.addComponent(lSave);
    lSave.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent inEvent) {
            final String lValue = completionEditor.getValue();
            if (checkEditorInput(lValue)) { //$NON-NLS-1$
                completionEditor.setValue(""); //$NON-NLS-1$
                Notification.show(lMessages.getMessage("errmsg.completion.not.empty"), Type.WARNING_MESSAGE); //$NON-NLS-1$
                return;
            }
            if (!inTask.saveCompletion(lValue)) {
                Notification.show(lMessages.getMessage("errmsg.save.general"), Type.WARNING_MESSAGE); //$NON-NLS-1$
            }
        }
    });
}

From source file:org.hip.vif.web.util.VIFViewHelper.java

License:Open Source License

/** Helper method to create a text field.
 *
 * @param inContent String the field's content
 * @param inWidth int the field width (in pixels)
 * @param inHeight int the field width (in pixels)
 * @param inValidator {@link Validator} the field's validator or <code>null</code>, if no validation is applied
 * @return {@link RichTextArea} */
public static RichTextArea createTextArea(final String inContent, final int inWidth, final int inHeight,
        final Validator inValidator) {
    final RichTextArea out = new RichTextArea();
    out.setValue(inContent);//w ww.  j  a v a2 s  .c om
    if (inValidator != null) {
        out.addValidator(inValidator);
    }
    out.setWidth(inWidth, Unit.PIXELS);
    out.setHeight(inHeight, Unit.PIXELS);
    out.setStyleName("vif-editor"); //$NON-NLS-1$
    return out;
}

From source file:org.lucidj.html_renderer.HtmlRenderer.java

License:Apache License

private void init_main() {
    // Full width
    setWidth("100%");

    rich_text = new RichTextArea();
    rich_text.setWidth("100%");
    rich_text.setImmediate(true);// ww  w  .j av a 2s. com

    addContextClickListener(new ContextClickEvent.ContextClickListener() {
        @Override
        public void contextClick(ContextClickEvent contextClickEvent) {
            log.info("CONTEXTCLICK: {}", contextClickEvent);
        }
    });

    addLayoutClickListener(new LayoutEvents.LayoutClickListener() {
        @Override
        public void layoutClick(LayoutEvents.LayoutClickEvent layoutClickEvent) {
            if (layoutClickEvent.isDoubleClick()) {
                show_hide_rich_text();
            }
        }
    });

    rich_text.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            source.setValue(rich_text.getValue());
        }
    });

    addComponent(rich_text);
    addComponent(html_output);
}

From source file:org.lunarray.model.generation.vaadin.render.factories.form.vaadin.components.RichTextAreaPropertyStrategy.java

License:Open Source License

/** {@inheritDoc} */
@Override
protected Component createComponent() {
    return new RichTextArea();
}

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

License:Open Source License

public Field createField(Item item, Object propertyId, Component uiContext) {
    String pid = (String) propertyId;
    if (pid.equals("sectionName")) {
        TextField tf = new TextField(messages.getString("sectionName"));
        tf.setNullRepresentation("");
        tf.setWidth("300px");
        tf.setRequired(true);/*from w  ww  . ja  va 2s  .  c o m*/
        tf.setRequiredError(messages.getString("requiredField"));
        return tf;
    } else if (pid.equals("sectionDesc")) {
        TextField tf = new TextField(messages.getString("sectionDesc"));
        tf.setNullRepresentation("");
        tf.setWidth("150px");
        tf.setRequired(true);
        tf.setRequiredError(messages.getString("requiredField"));
        return tf;
    } else if (pid.equals("taskName") || pid.equals("name")) {
        TextField tf = new TextField(("taskName"));
        tf.setNullRepresentation("");
        tf.setSizeFull();
        tf.setRequired(true);
        tf.setRequiredError("? !");
        return tf;
    } else if (pid.equals("dataXml")) {
        RichTextArea ra = new RichTextArea();
        ra.setCaption(("taskText"));
        ra.setNullRepresentation("");
        ra.setRequired(true);
        ra.setRequiredError("? !");
        return ra;
    } else if (pid.equals("startDate") || pid.equals("expireDate") || pid.equals("endDate")) {
        PopupDateField df = new PopupDateField((pid));
        df.setResolution(DateField.RESOLUTION_MIN);
        df.setValue(new Date());
        df.setRequired(true);
        df.setRequiredError("? !");
        return df;
    } else if (pid.equals("nxuserId")) {
        TextField tf = new TextField(("author"));
        tf.setNullRepresentation("");
        tf.setSizeFull();
        tf.setRequired(true);
        tf.setReadOnly(true);
        return tf;
    } else if (pid.equals("assignedTo")) {
        TextField tf = new TextField(("assignedTo"));
        tf.setNullRepresentation("");
        tf.setSizeFull();
        tf.setRequired(true);
        tf.setReadOnly(true);
        return tf;
    } else if (pid.equals("status")) {
        TextField tf = new TextField(("status"));
        tf.setNullRepresentation("");
        tf.setReadOnly(true);
        return tf;
    } else if (pid.equals("id")) {
        TextField tf = new TextField("ID");
        tf.setNullRepresentation("");
        tf.setReadOnly(true);
        return tf;
    }
    return null;
}