Class JmixCodeEditor
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<C,T>
com.vaadin.flow.component.AbstractSinglePropertyField<JmixCodeEditor,String>
io.jmix.flowui.kit.component.codeeditor.JmixCodeEditor
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier,com.vaadin.flow.component.BlurNotifier<JmixCodeEditor>,com.vaadin.flow.component.CompositionNotifier,com.vaadin.flow.component.DetachNotifier,com.vaadin.flow.component.Focusable<JmixCodeEditor>,com.vaadin.flow.component.FocusNotifier<JmixCodeEditor>,com.vaadin.flow.component.HasElement,com.vaadin.flow.component.HasEnabled,com.vaadin.flow.component.HasHelper,com.vaadin.flow.component.HasLabel,com.vaadin.flow.component.HasSize,com.vaadin.flow.component.HasStyle,com.vaadin.flow.component.HasValidation,com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<JmixCodeEditor,,String>, String> com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<JmixCodeEditor,,String>, String> com.vaadin.flow.component.InputNotifier,com.vaadin.flow.component.KeyNotifier,com.vaadin.flow.component.shared.HasClientValidation,com.vaadin.flow.component.shared.HasTooltip,com.vaadin.flow.component.shared.HasValidationProperties,com.vaadin.flow.data.binder.HasValidator<String>,HasTitle,Serializable
- Direct Known Subclasses:
CodeEditor
@Tag("jmix-code-editor")
@NpmPackage(value="ace-builds",
version="1.39.0")
@JsModule("./src/code-editor/jmix-code-editor.js")
public class JmixCodeEditor
extends com.vaadin.flow.component.AbstractSinglePropertyField<JmixCodeEditor,String>
implements com.vaadin.flow.component.CompositionNotifier, com.vaadin.flow.component.Focusable<JmixCodeEditor>, com.vaadin.flow.component.shared.HasClientValidation, com.vaadin.flow.component.HasHelper, com.vaadin.flow.component.HasLabel, HasTitle, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.shared.HasTooltip, com.vaadin.flow.component.shared.HasValidationProperties, com.vaadin.flow.data.binder.HasValidator<String>, com.vaadin.flow.component.InputNotifier, com.vaadin.flow.component.KeyNotifier
Code Editor is a multi-line text area to display and enter source code featured
with code highlighting and optional print margin and gutter with line numbers.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classAn event fired when the value of aJmixCodeEditorchanges.Nested classes/interfaces inherited from class com.vaadin.flow.component.AbstractField
com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<C extends com.vaadin.flow.component.Component,V extends Object> Nested classes/interfaces inherited from interface com.vaadin.flow.component.BlurNotifier
com.vaadin.flow.component.BlurNotifier.BlurEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.FocusNotifier
com.vaadin.flow.component.FocusNotifier.FocusEvent<C extends com.vaadin.flow.component.Component>Nested classes/interfaces inherited from interface com.vaadin.flow.component.shared.HasClientValidation
com.vaadin.flow.component.shared.HasClientValidation.ClientValidatedEventNested classes/interfaces inherited from interface com.vaadin.flow.component.HasValue
com.vaadin.flow.component.HasValue.ValueChangeEvent<V extends Object>, com.vaadin.flow.component.HasValue.ValueChangeListener<E extends com.vaadin.flow.component.HasValue.ValueChangeEvent<?>> -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final Stringprotected static final Stringprotected elemental.json.JsonFactoryprotected com.fasterxml.jackson.databind.ObjectMapperprotected static final intprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected Suggesterprotected CodeEditorValidationSupport -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncom.vaadin.flow.shared.RegistrationaddValidationStatusChangeListener(com.vaadin.flow.data.binder.ValidationStatusChangeListener<String> listener) com.vaadin.flow.data.binder.Validator<String>protected elemental.json.JsonFactorygetMode()protected com.fasterxml.jackson.databind.ObjectMapperintprotected elemental.json.JsonValuegetSuggestions(String value, Double cursorPosition, String prefix) Returns a serialized list of suggestions for the client-side.getTheme()protected CodeEditorValidationSupportprotected voidhandleValueChanged(boolean isFromClient, String newValue) protected voidbooleanbooleanbooleanbooleanbooleanDetermines whether the field is marked as input required.booleanbooleanbooleanbooleanbooleanprotected voidonAttach(com.vaadin.flow.component.AttachEvent attachEvent) protected voidprotected elemental.json.JsonValuevoidsetDefaultSuggestionsEnabled(boolean defaultSuggestionsEnabled) Sets whether default suggestions based on the current editor mode are enabled.voidsetFontSize(String fontSize) Sets the font size for code in the editor.voidsetHighlightActiveLine(boolean highlightActiveLine) Sets the highlight of the active line.voidsetHighlightGutterLine(boolean highlightGutterLine) Sets the highlight of the current gutter line.voidsetLiveSuggestionsEnabled(boolean liveSuggestionsEnabled) Sets whether live suggestions that are suggested while typing are enabled.voidsetMode(CodeEditorMode mode) Sets syntax highlighting for a specific mode.protected voidsetPresentationValue(String newPresentationValue) voidsetPrintMarginColumn(int printMarginColumn) Sets the column for the vertical line, which shows the limit on the length of a line of code.voidsetRequired(boolean required) Specifies that the user must fill in a value.voidsetRequiredIndicatorVisible(boolean requiredIndicatorVisible) voidsetShowGutter(boolean showGutter) Sets the visibility of the gutter.voidsetShowLineNumbers(boolean showLineNumbers) Sets the line numbers visibility.voidsetShowPrintMargin(boolean showPrintMargin) Sets the visibility of the vertical line that shows the limit on the length of a line of code.voidsetSuggester(Suggester suggester) Sets theSuggesterthat providessuggestion optionson request from client-side.voidsetSuggestOn(String suggestOn) Sets the regular expression that triggers the display of a popup with suggestions.voidsetTextWrap(boolean textWrap) Sets the text content wrapping mode.voidsetTheme(CodeEditorTheme theme) Sets the visual theme of the editor.voidsetUseSoftTabs(boolean useSoftTabs) Sets the tab character representing mode.protected voidvalidate()Methods inherited from class com.vaadin.flow.component.AbstractSinglePropertyField
getSynchronizationRegistration, hasValidValue, setSynchronizedEventMethods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getValue, isEmpty, setModelValue, setValue, valueEqualsMethods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.BlurNotifier
addBlurListenerMethods inherited from interface com.vaadin.flow.component.CompositionNotifier
addCompositionEndListener, addCompositionStartListener, addCompositionUpdateListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.Focusable
addFocusShortcut, blur, focus, getTabIndex, setTabIndexMethods inherited from interface com.vaadin.flow.component.FocusNotifier
addFocusListenerMethods inherited from interface com.vaadin.flow.component.shared.HasClientValidation
addClientValidatedEventListenerMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasHelper
getHelperComponent, getHelperText, setHelperComponent, setHelperTextMethods inherited from interface com.vaadin.flow.component.HasLabel
getLabel, setLabelMethods inherited from interface com.vaadin.flow.component.HasSize
getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNameMethods inherited from interface com.vaadin.flow.component.shared.HasTooltip
getTooltip, setTooltipTextMethods inherited from interface com.vaadin.flow.component.HasValidation
setManualValidationMethods inherited from interface com.vaadin.flow.component.shared.HasValidationProperties
getErrorMessage, isInvalid, setErrorMessage, setInvalidMethods inherited from interface com.vaadin.flow.component.HasValue
clear, getOptionalValueMethods inherited from interface com.vaadin.flow.component.HasValueAndElement
isReadOnly, isRequiredIndicatorVisible, setReadOnlyMethods inherited from interface com.vaadin.flow.component.InputNotifier
addInputListenerMethods inherited from interface com.vaadin.flow.component.KeyNotifier
addKeyDownListener, addKeyDownListener, addKeyPressListener, addKeyPressListener, addKeyUpListener, addKeyUpListener
-
Field Details
-
CODE_EDITOR_VALUE_CHANGED_EVENT
- See Also:
-
PROPERTY_THEME_CHANGED_EVENT
- See Also:
-
PROPERTY_VALUE
- See Also:
-
PROPERTY_THEME
- See Also:
-
PROPERTY_MODE
- See Also:
-
PROPERTY_HIGHLIGHT_ACTIVE_LINE
- See Also:
-
PROPERTY_HIGHLIGHT_GUTTER_LINE
- See Also:
-
PROPERTY_SHOW_GUTTER
- See Also:
-
PROPERTY_SHOW_LINE_NUMBERS
- See Also:
-
PROPERTY_SHOW_PRINT_MARGIN
- See Also:
-
PROPERTY_PRINT_MARGIN_COLUMN
- See Also:
-
PROPERTY_FONT_SIZE
- See Also:
-
PROPERTY_TEXT_WRAP
- See Also:
-
PROPERTY_USE_SOFT_TABS
- See Also:
-
PRINT_MARGIN_COLUMN_DEFAULT_VALUE
protected static final int PRINT_MARGIN_COLUMN_DEFAULT_VALUE- See Also:
-
FONT_SIZE_DEFAULT_VALUE
- See Also:
-
validationSupport
-
suggester
-
objectMapper
protected com.fasterxml.jackson.databind.ObjectMapper objectMapper -
jsonFactory
protected elemental.json.JsonFactory jsonFactory
-
-
Constructor Details
-
JmixCodeEditor
public JmixCodeEditor()
-
-
Method Details
-
initComponent
protected void initComponent() -
isHighlightActiveLine
@Synchronize("highlightActiveLine") public boolean isHighlightActiveLine()- Returns:
trueif the active line highlighting is enabled,falseotherwise
-
setHighlightActiveLine
public void setHighlightActiveLine(boolean highlightActiveLine) Sets the highlight of the active line. If the highlighting is enabled, the line the cursor is on will be highlighted. The highlight is enabled by default.- Parameters:
highlightActiveLine- whether to use active line highlighting
-
isHighlightGutterLine
@Synchronize("highlightGutterLine") public boolean isHighlightGutterLine()- Returns:
trueif the current gutter line highlighting is enabled,falseotherwise
-
setHighlightGutterLine
public void setHighlightGutterLine(boolean highlightGutterLine) Sets the highlight of the current gutter line. If the highlighting is enabled, the gutter line the cursor is on will be highlighted. The highlight is enabled by default.- Parameters:
highlightGutterLine- whether to use gutter line highlighting
-
isShowGutter
@Synchronize("showGutter") public boolean isShowGutter()- Returns:
trueif gutter is visible,falseotherwise
-
setShowGutter
public void setShowGutter(boolean showGutter) Sets the visibility of the gutter. The gutter is visible by default.- Parameters:
showGutter- whether to show the gutter
-
isShowLineNumbers
@Synchronize("showLineNumbers") public boolean isShowLineNumbers()- Returns:
trueif line numbers is visible,falseotherwise
-
setShowLineNumbers
public void setShowLineNumbers(boolean showLineNumbers) Sets the line numbers visibility. The line number is visible by default.- Parameters:
showLineNumbers- whether to show the line numbers
-
isShowPrintMargin
@Synchronize("showPrintMargin") public boolean isShowPrintMargin()- Returns:
trueif the print margin,falseotherwise
-
setShowPrintMargin
public void setShowPrintMargin(boolean showPrintMargin) Sets the visibility of the vertical line that shows the limit on the length of a line of code. The print margin is visible by default.- Parameters:
showPrintMargin- whether to show the print margin
-
getPrintMarginColumn
@Synchronize("printMarginColumn") public int getPrintMarginColumn()- Returns:
- print margin position in symbols
-
setPrintMarginColumn
public void setPrintMarginColumn(int printMarginColumn) Sets the column for the vertical line, which shows the limit on the length of a line of code. The print margin column is 80 by default.- Parameters:
printMarginColumn- print margin position in symbols
-
getTheme
- Returns:
- current visual theme applied to the editor
-
setTheme
Sets the visual theme of the editor. The visual theme isCodeEditorTheme.TEXTMATEby default, but if no theme is specified explicitly, the component will adapt the visual theme to the theme of the application.Thus - when using the light theme of the application,
CodeEditorTheme.TEXTMATEwill be applied, when using the dark theme -CodeEditorTheme.NORD_DARKwill be applied.- Parameters:
theme- the instance of theCodeEditorThemeto be applied
-
getMode
- Returns:
- current syntax highlighting mode applied to the editor
-
setMode
Sets syntax highlighting for a specific mode. The syntax highlighting mode isCodeEditorMode.PLAIN_TEXTby default.- Parameters:
mode- the instance of theCodeEditorModeto be applied
-
getFontSize
- Returns:
- font size for code in the editor in CSS font-size string format
-
setFontSize
Sets the font size for code in the editor. The font size is1remby default.- Parameters:
fontSize- CSS font-size string
-
isTextWrap
@Synchronize("textWrap") public boolean isTextWrap()- Returns:
trueif the text content inside editor should be wrapped,falseotherwise
-
setTextWrap
public void setTextWrap(boolean textWrap) Sets the text content wrapping mode. The text wrap isfalseby default.- Parameters:
textWrap- whether to wrap text content
-
isUseSoftTabs
@Synchronize("useSoftTabs") public boolean isUseSoftTabs()- Returns:
trueif tab character should be represented as spaces instead of a special\tcharacter,falseotherwise.
-
setUseSoftTabs
public void setUseSoftTabs(boolean useSoftTabs) Sets the tab character representing mode. Soft tabs mode means that tab character will be represented as a series of spaces. Hard tabs mode means that tab character will be represented as the special\tcharacter. The soft tabs istrueby default.- Parameters:
useSoftTabs- whether to use soft tabs
-
isRequired
public boolean isRequired()Determines whether the field is marked as input required.- Returns:
trueif the input is required,falseotherwise
-
setRequired
public void setRequired(boolean required) Specifies that the user must fill in a value.- Parameters:
required- the boolean value to set
-
isDefaultSuggestionsEnabled
public boolean isDefaultSuggestionsEnabled()- Returns:
trueif default suggestions based on the current editor mode are enabled,falseotherwise- See Also:
-
setDefaultSuggestionsEnabled
public void setDefaultSuggestionsEnabled(boolean defaultSuggestionsEnabled) Sets whether default suggestions based on the current editor mode are enabled.For example, if the
CodeEditorMode.JAVAis set, then when prompted for a suggestion, the standard keywords and local variables and methods defined in the code will be suggested.It is allowed to use custom
Suggesterwith the default suggester at the same time.- Parameters:
defaultSuggestionsEnabled- whether to enable default suggestions
-
isLiveSuggestionsEnabled
public boolean isLiveSuggestionsEnabled()- Returns:
trueif live suggestions that are suggested while typing are enabled,falseotherwise
-
setLiveSuggestionsEnabled
public void setLiveSuggestionsEnabled(boolean liveSuggestionsEnabled) Sets whether live suggestions that are suggested while typing are enabled.At least one suggester is required.
- Parameters:
liveSuggestionsEnabled- whether to enable live suggestions- See Also:
-
getSuggestOn
- Returns:
- regular expression that triggers the display of a popup with suggestions
-
setSuggestOn
Sets the regular expression that triggers the display of a popup with suggestions. If the end-user enters a sequence of characters that matches the regular expression then a popup with suggestions will open.- Parameters:
suggestOn- regular expression that triggers the display of a popup with suggestions
-
getSuggester
- Returns:
- the current editor suggester that provides suggestion options on request from the client-side
-
setSuggester
Sets theSuggesterthat providessuggestion optionson request from client-side.- Parameters:
suggester- suggester to set- See Also:
-
getSuggestions
@ClientCallable protected elemental.json.JsonValue getSuggestions(String value, Double cursorPosition, String prefix) Returns a serialized list of suggestions for the client-side. The list is generated using asuggesterbased on the current state of the editor on the client-side.- Parameters:
value- current value from the client-side of the editor (may not match the server-side value)cursorPosition- current cursor position in the editorprefix- literal before current cursor position- Returns:
- serialized list of suggestions
- See Also:
-
setPresentationValue
- Overrides:
setPresentationValuein classcom.vaadin.flow.component.AbstractSinglePropertyField<JmixCodeEditor,String>
-
getEmptyValue
- Specified by:
getEmptyValuein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<JmixCodeEditor,String>, String> - Overrides:
getEmptyValuein classcom.vaadin.flow.component.AbstractField<JmixCodeEditor,String>
-
setRequiredIndicatorVisible
public void setRequiredIndicatorVisible(boolean requiredIndicatorVisible) - Specified by:
setRequiredIndicatorVisiblein interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<JmixCodeEditor,String>, String> - Specified by:
setRequiredIndicatorVisiblein interfacecom.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<JmixCodeEditor,String>, String>
-
getDefaultValidator
- Specified by:
getDefaultValidatorin interfacecom.vaadin.flow.data.binder.HasValidator<String>
-
addValidationStatusChangeListener
public com.vaadin.flow.shared.Registration addValidationStatusChangeListener(com.vaadin.flow.data.binder.ValidationStatusChangeListener<String> listener) - Specified by:
addValidationStatusChangeListenerin interfacecom.vaadin.flow.data.binder.HasValidator<String>
-
validate
protected void validate() -
onAttach
protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent) - Overrides:
onAttachin classcom.vaadin.flow.component.Component
-
onCodeEditorValueChangedEvent
-
handleValueChanged
-
getValidationSupport
-
serialize
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
getJsonFactory
protected elemental.json.JsonFactory getJsonFactory()
-