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 XMLEditorPanel 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 XMLEditorPanel(final IModel<String> content) {
38 this(null, content, false, null);
39 }
40
41 public XMLEditorPanel(
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 final TextArea<String> xmlEditorInfoDefArea = new TextArea<>("xmlEditorInfo", this.content);
51 xmlEditorInfoDefArea.setMarkupId("xmlEditorInfo").setOutputMarkupPlaceholderTag(true);
52 add(xmlEditorInfoDefArea);
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('xmlEditorInfo'), {"
60 + " readOnly: " + readOnly + ", "
61 + " lineNumbers: true, "
62 + " lineWrapping: true, "
63 + " autoCloseTags: true, "
64 + " mode: 'text/html', "
65 + " autoRefresh: true"
66 + "}).on('change', updateTextArea);"));
67 }
68 }