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.event.BehaviorEvent;
28  
29  import org.primefaces.util.MapBuilder;
30  
31  /**
32   * Base component for both the framed and inline monaco code editor widget.
33   *
34   * @since 10.0.0
35   */
36  @SuppressWarnings("java:S110")
37  public abstract class MonacoEditorBase
38                                         extends MonacoEditorCommon<org.primefaces.extensions.model.monacoeditor.EditorOptions> {
39      static final String DEFAULT_EVENT = "change";
40  
41      static final Map<String, Class<? extends BehaviorEvent>> BASE_BEHAVIOR_EVENT_MAPPING = MapBuilder.<String, Class<? extends BehaviorEvent>> builder() //
42                  .put(DEFAULT_EVENT, null) //
43                  .put("blur", null) //
44                  .put("focus", null) //
45                  .put("initialized", null) //
46                  .put("keydown", null) //
47                  .put("keyup", null) //
48                  .put("mousedown", null) //
49                  .put("mousemove", null) //
50                  .put("mouseup", null) //
51                  .put("paste", null) //
52                  .build();
53  
54      static final Collection<String> BASE_EVENT_NAMES = BASE_BEHAVIOR_EVENT_MAPPING.keySet();
55  
56      protected MonacoEditorBase(final String rendererType) {
57          super(rendererType, org.primefaces.extensions.model.monacoeditor.EditorOptions.class);
58      }
59  
60      @Override
61      public final String getDefaultEventName() {
62          return DEFAULT_EVENT;
63      }
64  }