View Javadoc
1   
2   /*
3    * Copyright (c) 2011-2022 PrimeFaces Extensions
4    *
5    *  Permission is hereby granted, free of charge, to any person obtaining a copy
6    *  of this software and associated documentation files (the "Software"), to deal
7    *  in the Software without restriction, including without limitation the rights
8    *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9    *  copies of the Software, and to permit persons to whom the Software is
10   *  furnished to do so, subject to the following conditions:
11   *
12   *  The above copyright notice and this permission notice shall be included in
13   *  all copies or substantial portions of the Software.
14   *
15   *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16   *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17   *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18   *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19   *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20   *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21   *  THE SOFTWARE.
22   */
23  
24  package org.primefaces.extensions.model.monacoeditor;
25  
26  import org.primefaces.shaded.json.*;
27  import java.io.ObjectStreamException;
28  import java.io.Serializable;
29  
30  // ============================================================
31  // THIS FILE WAS GENERATED AUTOMATICALLY. DO NOT EDIT DIRECTLY.
32  // ============================================================
33  
34  /**
35   * Control the behavior and rendering of the inline completions.
36   */
37  @SuppressWarnings("serial")
38  public class EditorInlineSuggestOptions extends JSONObject implements Serializable {
39      private Object writeReplace() throws ObjectStreamException {
40          return new SerializedEditorInlineSuggestOptions(this);
41      }
42  
43      private static class SerializedEditorInlineSuggestOptions implements Serializable {
44          private String json;
45  
46          public SerializedEditorInlineSuggestOptions(EditorInlineSuggestOptions editorInlineSuggestOptions) {
47              this.json = editorInlineSuggestOptions.toString();
48          }
49  
50          private Object readResolve() throws ObjectStreamException {
51              final EditorInlineSuggestOptions editorInlineSuggestOptions = new EditorInlineSuggestOptions();
52              final JSONObject data = new JSONObject(json);
53              for (final String key : data.keySet()) {
54                  final Object value = data.get(key);
55                  editorInlineSuggestOptions.put(key, value);
56              }
57              return editorInlineSuggestOptions;
58          }
59      }
60  
61      /**
62       * @return Enable or disable the rendering of automatic inline completions.
63       */
64      public Boolean isEnabled() {
65          return (Boolean) (has("enabled") ? get("enabled") : null);
66      }
67  
68      /**
69       * @param enabled Enable or disable the rendering of automatic inline completions.
70       * @return This same instance, useful for chaining multiple setter methods in one call.
71       */
72      public EditorInlineSuggestOptions setEnabled(final Boolean enabled) {
73          put("enabled", enabled);
74          return this;
75      }
76  
77      /**
78       * @return Does not clear active inline suggestions when the editor loses focus.
79       */
80      public Boolean isKeepOnBlur() {
81          return (Boolean) (has("keepOnBlur") ? get("keepOnBlur") : null);
82      }
83  
84      /**
85       * @param keepOnBlur Does not clear active inline suggestions when the editor loses focus.
86       * @return This same instance, useful for chaining multiple setter methods in one call.
87       */
88      public EditorInlineSuggestOptions setKeepOnBlur(final Boolean keepOnBlur) {
89          put("keepOnBlur", keepOnBlur);
90          return this;
91      }
92  
93      /**
94       * @return Configures the mode. Use prefix to only show ghost text if the text to replace is a prefix of the
95       * suggestion text. Use {@link subword} to only show ghost text if the replace text is a sub word of the suggestion
96       * text. Use {@link subwordSmart} to only show ghost text if the replace text is a sub word of the suggestion text,
97       * but the sub word must start after the cursor position. Defaults to {@code prefix}.
98       */
99      public String getMode() {
100         return (String) (has("mode") ? get("mode") : null);
101     }
102 
103     /**
104      * @param mode Configures the mode. Use prefix to only show ghost text if the text to replace is a prefix of the
105      * suggestion text. Use {@link subword} to only show ghost text if the replace text is a sub word of the suggestion
106      * text. Use {@link subwordSmart} to only show ghost text if the replace text is a sub word of the suggestion text,
107      * but the sub word must start after the cursor position. Defaults to {@code prefix}.
108      * @return This same instance, useful for chaining multiple setter methods in one call.
109      */
110     public EditorInlineSuggestOptions setMode(final EInlineSuggestMode mode) {
111         put("mode", mode != null ? mode.toString() : null);
112         return this;
113     }
114 
115     /**
116      * @param mode Configures the mode. Use prefix to only show ghost text if the text to replace is a prefix of the
117      * suggestion text. Use {@link subword} to only show ghost text if the replace text is a sub word of the suggestion
118      * text. Use {@link subwordSmart} to only show ghost text if the replace text is a sub word of the suggestion text,
119      * but the sub word must start after the cursor position. Defaults to {@code prefix}.
120      * @return This same instance, useful for chaining multiple setter methods in one call.
121      */
122     public EditorInlineSuggestOptions setMode(final String mode) {
123         put("mode", mode);
124         return this;
125     }
126 
127     /**
128      * @return Configures whether to show the inline suggest toolbar.
129      */
130     public String getShowToolbar() {
131         return (String) (has("showToolbar") ? get("showToolbar") : null);
132     }
133 
134     /**
135      * @param showToolbar Configures whether to show the inline suggest toolbar.
136      * @return This same instance, useful for chaining multiple setter methods in one call.
137      */
138     public EditorInlineSuggestOptions setShowToolbar(final EShowToolbarMode showToolbar) {
139         put("showToolbar", showToolbar != null ? showToolbar.toString() : null);
140         return this;
141     }
142 
143     /**
144      * @param showToolbar Configures whether to show the inline suggest toolbar.
145      * @return This same instance, useful for chaining multiple setter methods in one call.
146      */
147     public EditorInlineSuggestOptions setShowToolbar(final String showToolbar) {
148         put("showToolbar", showToolbar);
149         return this;
150     }
151 
152     public Boolean isSuppressSuggestions() {
153         return (Boolean) (has("suppressSuggestions") ? get("suppressSuggestions") : null);
154     }
155 
156     public EditorInlineSuggestOptions setSuppressSuggestions(final Boolean suppressSuggestions) {
157         put("suppressSuggestions", suppressSuggestions);
158         return this;
159     }
160 
161     /**
162      * @return This options object as a serializable JSON object
163      */
164     JSONObject getJSONObject() {
165         return this;
166     }
167 }