1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.client.console.wicket.markup.html.form;
20
21 import org.apache.syncope.client.console.panels.AbstractModalPanel;
22 import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
23 import org.apache.wicket.PageReference;
24 import org.apache.wicket.markup.head.IHeaderResponse;
25 import org.apache.wicket.markup.head.OnLoadHeaderItem;
26 import org.apache.wicket.markup.html.form.TextArea;
27 import org.apache.wicket.model.IModel;
28
29 public class TextEditorPanel extends AbstractModalPanel<String> {
30
31 private static final long serialVersionUID = -5110368813584745668L;
32
33 private final IModel<String> content;
34
35 private final boolean readOnly;
36
37 public TextEditorPanel(final IModel<String> content) {
38 this(null, content, false, null);
39 }
40
41 public TextEditorPanel(
42 final BaseModal<String> modal,
43 final IModel<String> content,
44 final boolean readOnly,
45 final PageReference pageRef) {
46
47 super(modal, pageRef);
48 this.content = content;
49 this.readOnly = readOnly;
50 TextArea<String> textEditorInfoDefArea = new TextArea<>("textEditorInfo", this.content);
51 textEditorInfoDefArea.setMarkupId("textEditorInfo").setOutputMarkupPlaceholderTag(true);
52 add(textEditorInfoDefArea);
53 }
54
55 @Override
56 public void renderHead(final IHeaderResponse response) {
57 super.renderHead(response);
58 response.render(OnLoadHeaderItem.forScript(
59 "CodeMirror.fromTextArea(document.getElementById('textEditorInfo'), {"
60 + " readOnly: " + readOnly + ", "
61 + " lineNumbers: true, "
62 + " lineWrapping: true, "
63 + " mode: 'text/plain', "
64 + " autoRefresh: true"
65 + "}).on('change', updateTextArea);"));
66 }
67 }