Search in sources :

Example 1 with SyntaxContent

use of org.xwiki.rendering.syntax.SyntaxContent in project xwiki-platform by xwiki.

the class TextAreaClass method displayEdit.

@Override
public void displayEdit(StringBuffer buffer, String name, String prefix, BaseCollection object, XWikiContext context) {
    String editorType = getEditorType(context);
    EditorManager editorManager = Utils.getComponent(EditorManager.class);
    Editor<SyntaxContent> editor = editorManager.getDefaultEditor(SyntaxContent.class, editorType);
    Map<String, Object> parameters = new HashMap<>();
    String fieldName = prefix + name;
    parameters.put("id", fieldName);
    parameters.put("name", fieldName);
    parameters.put("cols", getSize());
    parameters.put("rows", getRows());
    parameters.put("disabled", isDisabled());
    parameters.put("sourceDocumentReference", object.getDocumentReference());
    Syntax syntax = "puretext".equals(editorType) ? Syntax.PLAIN_1_0 : getObjectDocumentSyntax(object, context);
    SyntaxContent syntaxContent = new SyntaxContent(object.getStringValue(name), syntax);
    try {
        buffer.append(editor.render(syntaxContent, parameters));
    } catch (EditException e) {
        LOGGER.error("Failed to display the text area property.", e);
    }
}
Also used : HashMap(java.util.HashMap) Syntax(org.xwiki.rendering.syntax.Syntax) EditorManager(org.xwiki.edit.EditorManager) EditException(org.xwiki.edit.EditException) SyntaxContent(org.xwiki.rendering.syntax.SyntaxContent)

Aggregations

HashMap (java.util.HashMap)1 EditException (org.xwiki.edit.EditException)1 EditorManager (org.xwiki.edit.EditorManager)1 Syntax (org.xwiki.rendering.syntax.Syntax)1 SyntaxContent (org.xwiki.rendering.syntax.SyntaxContent)1