View Javadoc
1   /*
2    * Copyright (c) 2011-2024 PrimeFaces Extensions
3    *
4    *  Permission is hereby granted, free of charge, to any person obtaining a copy
5    *  of this software and associated documentation files (the "Software"), to deal
6    *  in the Software without restriction, including without limitation the rights
7    *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    *  copies of the Software, and to permit persons to whom the Software is
9    *  furnished to do so, subject to the following conditions:
10   *
11   *  The above copyright notice and this permission notice shall be included in
12   *  all copies or substantial portions of the Software.
13   *
14   *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20   *  THE SOFTWARE.
21   */
22  package org.primefaces.extensions.component.monacoeditor;
23  
24  import java.util.Collection;
25  import java.util.Map;
26  
27  import javax.faces.application.ResourceDependency;
28  import javax.faces.event.BehaviorEvent;
29  
30  /**
31   * Component for the Monaco diff code editor JavaScript library. This is the inline monaco editor that creates a new instance in a textarea element on the same
32   * page. There is also framed version available that creates an editor in an iframe for better scoping.
33   *
34   * @see MonacoDiffEditorFramed
35   * @since 11.0.1
36   */
37  @SuppressWarnings("java:S110")
38  @ResourceDependency(library = "primefaces", name = "jquery/jquery.js")
39  @ResourceDependency(library = "primefaces", name = "core.js")
40  @ResourceDependency(library = "primefaces-extensions", name = "primefaces-extensions.js")
41  @ResourceDependency(library = "primefaces-extensions", name = "monacoeditor/widget-inline.js")
42  @ResourceDependency(library = "primefaces-extensions", name = "monacoeditor/monacoeditor.css")
43  public class MonacoDiffEditorInline extends MonacoDiffEditorBase {
44  
45      public static final String COMPONENT_TYPE = "org.primefaces.extensions.component.MonacoDiffEditorInline";
46  
47      public static final String RENDERER_TYPE = "org.primefaces.extensions.component.MonacoDiffEditorInlineRenderer";
48  
49      public static final String STYLE_CLASS = "ui-monaco-editor ui-monaco-editor-diff ui-monaco-editor-inline ";
50  
51      public static final String WIDGET_NAME = "ExtMonacoDiffEditorInline";
52  
53      /**
54       * Default no-arg constructor for this widget invoked by the framework.
55       */
56      public MonacoDiffEditorInline() {
57          super(RENDERER_TYPE);
58      }
59  
60      @Override
61      public Map<String, Class<? extends BehaviorEvent>> getBehaviorEventMapping() {
62          // no additional events for now
63          return BASE_BEHAVIOR_EVENT_MAPPING;
64      }
65  
66      @Override
67      public final Collection<String> getEventNames() {
68          // no additional events for now
69          return BASE_EVENT_NAMES;
70      }
71  
72      public final String getExtender() {
73          return (String) getStateHelper().eval(DiffEditorInlinePropertyKeys.extender, null);
74      }
75  
76      public final void setExtender(final String extender) {
77          getStateHelper().put(DiffEditorInlinePropertyKeys.extender, extender);
78      }
79  
80      public final String getOverflowWidgetsDomNode() {
81          return (String) getStateHelper().eval(DiffEditorInlinePropertyKeys.overflowWidgetsDomNode, null);
82      }
83  
84      public final void setOverflowWidgetsDomNode(final String overflowWidgetsDomNode) {
85          getStateHelper().put(DiffEditorInlinePropertyKeys.overflowWidgetsDomNode, overflowWidgetsDomNode);
86      }
87  }