1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.primefaces.extensions.component.monacoeditor;
23
24 import java.io.IOException;
25 import java.util.Map;
26
27 import javax.faces.context.FacesContext;
28 import javax.faces.context.ResponseWriter;
29
30 import org.primefaces.shaded.json.JSONWriter;
31 import org.primefaces.util.WidgetBuilder;
32
33
34
35
36
37
38 public class MonacoEditorFramedRenderer extends MonacoEditorBaseRenderer<MonacoEditorFramed> {
39
40
41
42
43 public MonacoEditorFramedRenderer() {
44 super(MonacoEditorFramed.class);
45 }
46
47 @Override
48 protected void addWidgetProperties(FacesContext context, WidgetBuilder wb, MonacoEditorFramed monacoEditor) throws IOException {
49 wb.attr("extender", monacoEditor.getExtender(), null);
50 if (monacoEditor.getIframeUrlParams() instanceof Map<?, ?>) {
51 wb.nativeAttr("iframeUrlParams", JSONWriter.valueToString(monacoEditor.getIframeUrlParams()));
52 }
53 else if (monacoEditor.getIframeUrlParams() instanceof String) {
54 wb.nativeAttr("iframeUrlParams", (String) monacoEditor.getIframeUrlParams());
55 }
56 }
57
58 @Override
59 protected final void encodeMonacoEditor(final FacesContext context, final MonacoEditorFramed monacoEditor) throws IOException {
60 final ResponseWriter writer = context.getResponseWriter();
61 final String clientId = monacoEditor.getClientId();
62 writer.startElement("iframe", null);
63 writer.writeAttribute("id", clientId + "_editor", null);
64 writer.writeAttribute("class", "ui-monaco-editor-ed", null);
65 writer.writeAttribute("style", "width:100%;height:100%;border:0;margin:0;padding:0;overflow:hidden;", null);
66 writer.endElement("iframe");
67 }
68
69 @Override
70 protected String getMainStyleClass() {
71 return MonacoEditorFramed.STYLE_CLASS;
72 }
73
74 @Override
75 protected String getWidgetName() {
76 return MonacoEditorFramed.WIDGET_NAME;
77 }
78 }