Package com.hilerio.ace
Class AceEditor
java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.AbstractField<C,T>
com.vaadin.flow.component.AbstractSinglePropertyField<AceEditor,java.lang.String>
com.hilerio.ace.AceEditor
- All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier
,com.vaadin.flow.component.BlurNotifier<AceEditor>
,com.vaadin.flow.component.DetachNotifier
,com.vaadin.flow.component.Focusable<AceEditor>
,com.vaadin.flow.component.FocusNotifier<AceEditor>
,com.vaadin.flow.component.HasElement
,com.vaadin.flow.component.HasEnabled
,com.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<AceEditor,java.lang.String>,java.lang.String>
,com.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<AceEditor,java.lang.String>,java.lang.String>
,java.io.Serializable
@Tag("ace-widget") @NpmPackage(value="@f0rce/ace-widget", version="1.0.0") @JsModule("./@f0rce/ace-widget/ace-widget.js") public class AceEditor extends com.vaadin.flow.component.AbstractSinglePropertyField<AceEditor,java.lang.String> implements com.vaadin.flow.component.Focusable<AceEditor>
- Author:
- Sergio Alberto Hilerio, David Dodlek
- See Also:
- Serialized Form
-
Nested Class Summary
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 java.lang.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>
-
Constructor Summary
Constructors Constructor Description AceEditor()
-
Method Summary
Modifier and Type Method Description java.lang.String
addMarkerAtCurrentSelection(AceMarkerColor color)
Adds a marker to the editor at the current selection.java.lang.String
addMarkerAtCurrentSelection(AceMarkerColor color, java.lang.String alias)
Adds a marker to the editor at the current selection.java.lang.String
addMarkerAtSelection(int rowStart, int from, int rowEnd, int to, AceMarkerColor color)
Adds a marker to the editor.java.lang.String
addMarkerAtSelection(int rowStart, int from, int rowEnd, int to, AceMarkerColor color, java.lang.String alias)
Adds a marker to the editor.java.lang.String
addMarkerAtSelection(int from, int to, AceMarkerColor color)
Adds a marker to the editor.java.lang.String
addMarkerAtSelection(int from, int to, AceMarkerColor color, java.lang.String alias)
Adds a marker to the editor.void
addTextAtCurrentPosition(java.lang.String text)
Adds text at the current position of the editor.
First Priority: If there is a selection, the selection will be replaced.
Second Priority: If the cursor position has been set, the text will be added at the position of the cursor.
Third/Last Priority: If no text is selected and the cursor has not been set, the text will be added to the end of the text.
void
addTextAtPosition(java.lang.String text, int position)
Adds text to a specific position of the editor.void
clear()
Cleans the value contained in the editor.void
disableCustomAutoCompletion()
Removes the custom autocompletion list set with setCustomAutoCompletiton() and replaces it with the default one.java.util.List<AceMarker>
getAllMarkers()
Returns a list of all current active markers.java.lang.String
getBasePath()
Return the current BasePath / BaseUrl.int[]
getCursorPosition()
Returns the current set cursor position in the editor where the first index represents the line and the second index represents the position.java.lang.String[]
getCustomAutoCompletion()
Returns a String array of the current custom autocompletion for the editor.java.lang.String
getFontSize()
Returns the current set font-size of the editor in pixels.java.lang.String
getHeight()
Returns the height set for the editor in px/pixel or percent.java.lang.String
getMaxHeight()
Returns the max-height set for the editor in px/pixel or percent.int
getMaxLines()
Return the maximum lines set for the editor.java.lang.String
getMaxWidth()
Returns the max-width set for the editor in px/pixel or percent.java.lang.String
getMinHeight()
Returns the min-height set for the editor in px/pixel or percent.int
getMinLines()
Returns the minimum set lines for the editor.java.lang.String
getMinWidth()
Returns the min-width set for the editor in px/pixel or percent.AceMode
getMode()
Returns the current set mode for the editor.java.lang.String
getPlaceholder()
Returns the placeholder set for the editor.int[]
getSelection()
Returns an int array of the current selection where the first index represents "rowStart", the second index "from", the third index "rowEnd" and the forth index "to".int
getTabSize()
Returns the current set tab-size for the editor.AceTheme
getTheme()
Returns the current set theme for the editor.java.lang.String
getWidth()
Returns the width set for the editor in px/pixel or percent.boolean
isAutoComplete()
Returns if autocomplete is enabled/disabled for the editor.boolean
isDisplayIndentGuides()
Returns if displayIndentGuides is enabled/disabled for the editor.boolean
isEnableSnippets()
Returns if snippets are enabled/disabled for the editor.boolean
isHightlightActiveLine()
Returns if hightlightActiveLine is enabled/disabled for the editor.boolean
isHightlightSelectedWord()
Returns if hightlightSelectedWord is enabled/disabled for the editor.boolean
isInitialFocus()
Returns if initial focus is enabled/disabled for the editor.boolean
isLiveAutocompletion()
Returns if live autocompletion is enabled/disabled for the editor.boolean
isReadOnly()
Returns if readOnly is enabled/disabled for the editor.boolean
isShowGutter()
Returns if showGutter is enabled/disabled for the editor.boolean
isShowInvisibles()
Returns if showInvisibles is enabled/disabled for the editor.boolean
isShowPrintMargin()
Returns if showPrintMargin is enabled/disabled for the editor.boolean
isSofttabs()
Returns if softtabs are currently enabled/disabled for the editor.boolean
isUseWorker()
Returns if useWorker is enabled/disabled for the editor.boolean
isWrap()
Returns if wrap is enabled/disabled for the editor.void
removeAllMarkers()
Removes every marker from the editor.void
removeMarker(AceMarker marker)
void
removeMarkerByAlias(java.lang.String alias)
Removes a specific marker from the editor by alias.
You can get all the active markers withgetAllMarkers()
.void
removeMarkerByID(java.lang.String id)
Removes a specific marker from the editor by id.
You can get all the active markers withgetAllMarkers()
.void
setAutoComplete(boolean value)
Sets AutoComplete for the editor.void
setBasePath(java.lang.String baseurl)
Sets BasePath / BaseUrl.void
setCursorPosition(int pos)
Sets cursorPosition for the editor.void
setCursorPosition(int pos, boolean focus)
Sets cursorPosition for the editor and optionally also sets the focus.void
setCustomAutoCompletion(java.lang.String[] wordList)
Sets a custom autocompletion list for the editor.void
setCustomAutoCompletion(java.lang.String[] wordList, java.lang.String category)
Sets a custom autocompletion list for the editor and sets the category aswell (default: "").void
setDisplayIndentGuides(boolean value)
Sets displayIndentGuides for the editor.void
setEnableSnippets(boolean value)
Sets enableSnippets for the editor.void
setFontSize(int value)
Sets font-size for the editor in pixels.void
setHeight(java.lang.String height)
Sets height in px/pixel or percent.void
setHeightFull()
Sets the height to 100%.void
setHighlightActiveLine(boolean value)
Sets highlightActiveLine for the editor.void
setHighlightSelectedWord(boolean value)
Sets highlightSelectedWord for the editor.void
setInitialFocus(boolean value)
Sets initialFocus for the editor.void
setLiveAutocompletion(boolean value)
Sets liveAutocompletion for the editor.void
setMaxHeight(java.lang.String height)
Sets max-height in px/pixel or percent.void
setMaxlines(int maxlines)
Sets maxlines for the editor.void
setMaxWidth(java.lang.String width)
Sets max-width in px/pixel or percent.void
setMinHeight(java.lang.String height)
Sets min-height in px/pixel or percent.void
setMinlines(int minlines)
Sets minlines for the editor.void
setMinWidth(java.lang.String width)
Sets min-width in px/pixel or percent.void
setMode(AceMode mode)
Sets the mode(language) of the editor.void
setPlaceholder(java.lang.String value)
Sets placeholder for the editor.void
setReadOnly(boolean value)
Sets readOnly for the editor.void
setSelection(int from, int to)
Sets selection for the editor.void
setSelection(int from, int to, boolean focus)
Sets selection for the editor and optionally also sets the focus.void
setSelection(int rowStart, int from, int rowEnd, int to)
Sets selection for the editor.void
setSelection(int rowStart, int from, int rowEnd, int to, boolean focus)
Sets selection for the editor and optionally also sets the focus.void
setShowGutter(boolean value)
Sets showGutter for the editor.void
setShowInvisibles(boolean value)
Sets showInvisibles for the editor.void
setShowPrintMargin(boolean value)
Sets showPrintMargin for the editor.void
setSizeFull()
Sets the height and width to 100%.void
setSofttabs(boolean value)
Sets softtabs for the editor.void
setTabSize(int value)
Sets tab-size for the editor.void
setTheme(AceTheme theme)
Sets the theme (style) of the editor.void
setUseWorker(boolean value)
Sets useWorker for the editor.void
setValue(java.lang.String value)
Sets value for the editor.void
setVisible(boolean visible)
Changes the visibilty of the editor.void
setWidth(java.lang.String width)
Sets width in px/pixel or percent.void
setWidthFull()
Sets the width to 100%.void
setWrap(boolean wrap)
Sets wrap for the editor.Methods inherited from class com.vaadin.flow.component.AbstractField
addValueChangeListener, getEmptyValue, getValue, isEmpty
Methods inherited from class com.vaadin.flow.component.Component
from, getChildren, getElement, getId, getParent, getTranslation, getTranslation, getUI, isVisible, onEnabledStateChanged, setId
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
AceEditor
public AceEditor()
-
-
Method Details
-
setMode
Sets the mode(language) of the editor.- Parameters:
mode
- AceMode
-
getMode
Returns the current set mode for the editor.- Returns:
- AceMode
-
setTheme
Sets the theme (style) of the editor.- Parameters:
theme
- AceTheme
-
getTheme
Returns the current set theme for the editor.- Returns:
- AceTheme
-
clear
public void clear()Cleans the value contained in the editor.- Specified by:
clear
in interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<AceEditor,java.lang.String>,java.lang.String>
-
setValue
public void setValue(java.lang.String value)Sets value for the editor.- Specified by:
setValue
in interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<AceEditor,java.lang.String>,java.lang.String>
- Overrides:
setValue
in classcom.vaadin.flow.component.AbstractField<AceEditor,java.lang.String>
- Parameters:
value
- String
-
setFontSize
public void setFontSize(int value)Sets font-size for the editor in pixels.- Parameters:
value
- int
-
getFontSize
public java.lang.String getFontSize()Returns the current set font-size of the editor in pixels.- Returns:
- String
-
setSofttabs
public void setSofttabs(boolean value)Sets softtabs for the editor.- Parameters:
value
- boolean
-
isSofttabs
public boolean isSofttabs()Returns if softtabs are currently enabled/disabled for the editor.- Returns:
- boolean
-
setTabSize
public void setTabSize(int value)Sets tab-size for the editor.- Parameters:
value
- int
-
getTabSize
public int getTabSize()Returns the current set tab-size for the editor.- Returns:
- int
-
setWrap
public void setWrap(boolean wrap)Sets wrap for the editor.- Parameters:
wrap
- boolean
-
isWrap
public boolean isWrap()Returns if wrap is enabled/disabled for the editor.- Returns:
- boolean
-
setAutoComplete
public void setAutoComplete(boolean value)Sets AutoComplete for the editor.- Parameters:
value
- boolean
-
isAutoComplete
public boolean isAutoComplete()Returns if autocomplete is enabled/disabled for the editor.- Returns:
- boolean
-
setMinlines
public void setMinlines(int minlines)Sets minlines for the editor.- Parameters:
minlines
- int
-
getMinLines
public int getMinLines()Returns the minimum set lines for the editor.- Returns:
- int
-
setMaxlines
public void setMaxlines(int maxlines)Sets maxlines for the editor.- Parameters:
maxlines
- int
-
getMaxLines
public int getMaxLines()Return the maximum lines set for the editor.- Returns:
- int
-
setInitialFocus
public void setInitialFocus(boolean value)Sets initialFocus for the editor.- Parameters:
value
- boolean
-
isInitialFocus
public boolean isInitialFocus()Returns if initial focus is enabled/disabled for the editor.- Returns:
- boolean
-
setPlaceholder
public void setPlaceholder(java.lang.String value)Sets placeholder for the editor.- Parameters:
value
- String
-
getPlaceholder
public java.lang.String getPlaceholder()Returns the placeholder set for the editor.- Returns:
- String
-
setReadOnly
public void setReadOnly(boolean value)Sets readOnly for the editor.- Specified by:
setReadOnly
in interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<AceEditor,java.lang.String>,java.lang.String>
- Specified by:
setReadOnly
in interfacecom.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<AceEditor,java.lang.String>,java.lang.String>
- Parameters:
value
- boolean
-
isReadOnly
public boolean isReadOnly()Returns if readOnly is enabled/disabled for the editor.- Specified by:
isReadOnly
in interfacecom.vaadin.flow.component.HasValue<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<AceEditor,java.lang.String>,java.lang.String>
- Specified by:
isReadOnly
in interfacecom.vaadin.flow.component.HasValueAndElement<com.vaadin.flow.component.AbstractField.ComponentValueChangeEvent<AceEditor,java.lang.String>,java.lang.String>
- Returns:
- boolean
-
setHeight
public void setHeight(java.lang.String height)Sets height in px/pixel or percent.- Parameters:
height
- String
-
getHeight
public java.lang.String getHeight()Returns the height set for the editor in px/pixel or percent.- Returns:
- String
-
setHeightFull
public void setHeightFull()Sets the height to 100%. -
setMaxHeight
public void setMaxHeight(java.lang.String height)Sets max-height in px/pixel or percent.- Parameters:
height
- String
-
getMaxHeight
public java.lang.String getMaxHeight()Returns the max-height set for the editor in px/pixel or percent.- Returns:
- String
-
setMinHeight
public void setMinHeight(java.lang.String height)Sets min-height in px/pixel or percent.- Parameters:
height
- String
-
getMinHeight
public java.lang.String getMinHeight()Returns the min-height set for the editor in px/pixel or percent.- Returns:
- String
-
setWidth
public void setWidth(java.lang.String width)Sets width in px/pixel or percent.- Parameters:
width
- String
-
setWidthFull
public void setWidthFull()Sets the width to 100%. -
getWidth
public java.lang.String getWidth()Returns the width set for the editor in px/pixel or percent.- Returns:
- String
-
setMaxWidth
public void setMaxWidth(java.lang.String width)Sets max-width in px/pixel or percent.- Parameters:
width
- String
-
getMaxWidth
public java.lang.String getMaxWidth()Returns the max-width set for the editor in px/pixel or percent.- Returns:
- String
-
setMinWidth
public void setMinWidth(java.lang.String width)Sets min-width in px/pixel or percent.- Parameters:
width
- String
-
getMinWidth
public java.lang.String getMinWidth()Returns the min-width set for the editor in px/pixel or percent.- Returns:
- String
-
setSizeFull
public void setSizeFull()Sets the height and width to 100%. -
setBasePath
public void setBasePath(java.lang.String baseurl)Sets BasePath / BaseUrl.- Parameters:
baseurl
- String
-
getBasePath
public java.lang.String getBasePath()Return the current BasePath / BaseUrl.- Returns:
- String
-
setShowPrintMargin
public void setShowPrintMargin(boolean value)Sets showPrintMargin for the editor.- Parameters:
value
- boolean
-
isShowPrintMargin
public boolean isShowPrintMargin()Returns if showPrintMargin is enabled/disabled for the editor.- Returns:
- boolean
-
setShowInvisibles
public void setShowInvisibles(boolean value)Sets showInvisibles for the editor.- Parameters:
value
- boolean
-
isShowInvisibles
public boolean isShowInvisibles()Returns if showInvisibles is enabled/disabled for the editor.- Returns:
- boolean
-
setShowGutter
public void setShowGutter(boolean value)Sets showGutter for the editor.- Parameters:
value
- boolean
-
isShowGutter
public boolean isShowGutter()Returns if showGutter is enabled/disabled for the editor.- Returns:
- boolean
-
setHighlightActiveLine
public void setHighlightActiveLine(boolean value)Sets highlightActiveLine for the editor.- Parameters:
value
- boolean
-
isHightlightActiveLine
public boolean isHightlightActiveLine()Returns if hightlightActiveLine is enabled/disabled for the editor.- Returns:
- boolean
-
setDisplayIndentGuides
public void setDisplayIndentGuides(boolean value)Sets displayIndentGuides for the editor.- Parameters:
value
- boolean
-
isDisplayIndentGuides
public boolean isDisplayIndentGuides()Returns if displayIndentGuides is enabled/disabled for the editor.- Returns:
- boolean
-
setHighlightSelectedWord
public void setHighlightSelectedWord(boolean value)Sets highlightSelectedWord for the editor.- Parameters:
value
- boolean
-
isHightlightSelectedWord
public boolean isHightlightSelectedWord()Returns if hightlightSelectedWord is enabled/disabled for the editor.- Returns:
- boolean
-
setSelection
public void setSelection(int from, int to)Sets selection for the editor.- Parameters:
from
- intto
- int
-
setSelection
public void setSelection(int from, int to, boolean focus)Sets selection for the editor and optionally also sets the focus.- Parameters:
from
- intto
- intfocus
- boolean
-
setSelection
public void setSelection(int rowStart, int from, int rowEnd, int to)Sets selection for the editor.- Parameters:
rowStart
- intfrom
- introwEnd
- intto
- int
-
setSelection
public void setSelection(int rowStart, int from, int rowEnd, int to, boolean focus)Sets selection for the editor and optionally also sets the focus.- Parameters:
rowStart
- intfrom
- introwEnd
- intto
- intfocus
- boolean
-
getSelection
public int[] getSelection()Returns an int array of the current selection where the first index represents "rowStart", the second index "from", the third index "rowEnd" and the forth index "to".- Returns:
- int[]
-
setUseWorker
public void setUseWorker(boolean value)Sets useWorker for the editor.- Parameters:
value
- boolean
-
isUseWorker
public boolean isUseWorker()Returns if useWorker is enabled/disabled for the editor.- Returns:
- boolean
-
setCursorPosition
public void setCursorPosition(int pos)Sets cursorPosition for the editor.- Parameters:
pos
- int
-
setCursorPosition
public void setCursorPosition(int pos, boolean focus)Sets cursorPosition for the editor and optionally also sets the focus.- Parameters:
pos
- intfocus
- boolean
-
getCursorPosition
public int[] getCursorPosition()Returns the current set cursor position in the editor where the first index represents the line and the second index represents the position.- Returns:
- int[]
-
setLiveAutocompletion
public void setLiveAutocompletion(boolean value)Sets liveAutocompletion for the editor.- Parameters:
value
- boolean
-
isLiveAutocompletion
public boolean isLiveAutocompletion()Returns if live autocompletion is enabled/disabled for the editor.- Returns:
- boolean
-
setEnableSnippets
public void setEnableSnippets(boolean value)Sets enableSnippets for the editor.- Parameters:
value
- boolean
-
isEnableSnippets
public boolean isEnableSnippets()Returns if snippets are enabled/disabled for the editor.- Returns:
- boolean
-
setCustomAutoCompletion
public void setCustomAutoCompletion(java.lang.String[] wordList)Sets a custom autocompletion list for the editor.- Parameters:
wordList
- String[]
-
setCustomAutoCompletion
public void setCustomAutoCompletion(java.lang.String[] wordList, java.lang.String category)Sets a custom autocompletion list for the editor and sets the category aswell (default: "").- Parameters:
wordList
- String[]category
- String
-
getCustomAutoCompletion
public java.lang.String[] getCustomAutoCompletion()Returns a String array of the current custom autocompletion for the editor.- Returns:
- String[]
-
disableCustomAutoCompletion
public void disableCustomAutoCompletion()Removes the custom autocompletion list set with setCustomAutoCompletiton() and replaces it with the default one. -
addTextAtPosition
public void addTextAtPosition(java.lang.String text, int position)Adds text to a specific position of the editor.- Parameters:
text
- Stringposition
- int
-
addTextAtCurrentPosition
public void addTextAtCurrentPosition(java.lang.String text)Adds text at the current position of the editor.
First Priority: If there is a selection, the selection will be replaced.
Second Priority: If the cursor position has been set, the text will be added at the position of the cursor.
Third/Last Priority: If no text is selected and the cursor has not been set, the text will be added to the end of the text.
- Parameters:
text
- String
-
addMarkerAtCurrentSelection
Adds a marker to the editor at the current selection. If the returned string is null, there is no current selection. Use any addMarkerAtSelection() method instead. If the marker is not visible make sure thatsetHightlightActiveLine()
andsetHighlightSelectedWord
are set to false.- Parameters:
color
- AceMarkerColor- Returns:
- String
-
addMarkerAtCurrentSelection
Adds a marker to the editor at the current selection. If the returned string is null, there is no current selection. Use any addMarkerAtSelection() method instead. If the marker is not visible make sure thatsetHightlightActiveLine()
andsetHighlightSelectedWord
are set to false.- Parameters:
color
- AceMarkerColoralias
- String- Returns:
- String
-
addMarkerAtSelection
Adds a marker to the editor. If the marker is not visible make sure thatsetHightlightActiveLine()
andsetHighlightSelectedWord
are set to false.- Parameters:
from
- intto
- intcolor
- AceMarkerColor- Returns:
- String
-
addMarkerAtSelection
public java.lang.String addMarkerAtSelection(int rowStart, int from, int rowEnd, int to, AceMarkerColor color)Adds a marker to the editor. If the marker is not visible make sure thatsetHightlightActiveLine()
andsetHighlightSelectedWord
are set to false.- Parameters:
rowStart
- intfrom
- introwEnd
- intto
- intcolor
- AceMarkerColor- Returns:
- String
-
addMarkerAtSelection
public java.lang.String addMarkerAtSelection(int from, int to, AceMarkerColor color, java.lang.String alias)Adds a marker to the editor. If the marker is not visible make sure thatsetHightlightActiveLine()
andsetHighlightSelectedWord
are set to false.- Parameters:
from
- intto
- intcolor
- AceMarkerColoralias
- String- Returns:
- String
-
addMarkerAtSelection
public java.lang.String addMarkerAtSelection(int rowStart, int from, int rowEnd, int to, AceMarkerColor color, java.lang.String alias)Adds a marker to the editor. If the marker is not visible make sure thatsetHightlightActiveLine()
andsetHighlightSelectedWord
are set to false.- Parameters:
rowStart
- intfrom
- introwEnd
- intto
- intcolor
- AceMarkerColoralias
- String- Returns:
- String
-
getAllMarkers
Returns a list of all current active markers. If the list is empty, no marker is set at the moment.- Returns:
- a List of all AceMarkers
-
removeMarker
- Parameters:
marker
- AceMarker
-
removeMarkerByID
public void removeMarkerByID(java.lang.String id)Removes a specific marker from the editor by id.
You can get all the active markers withgetAllMarkers()
.- Parameters:
id
- String
-
removeMarkerByAlias
public void removeMarkerByAlias(java.lang.String alias)Removes a specific marker from the editor by alias.
You can get all the active markers withgetAllMarkers()
.- Parameters:
alias
- String
-
removeAllMarkers
public void removeAllMarkers()Removes every marker from the editor. -
setVisible
public void setVisible(boolean visible)Changes the visibilty of the editor.- Overrides:
setVisible
in classcom.vaadin.flow.component.Component
- Parameters:
visible
- boolean
-