Class sap.ui.codeeditor.CodeEditorModule: sap/ui/codeeditor/CodeEditor

extends Control

Allows to visualize source code of various types with syntax highlighting, line numbers in editable and read only mode. Use this controls in scenarios where the user should be able to inspect and edit source code.
Constructor Summary
new sap.ui.codeeditor.CodeEditor(sId?, mSettings?)Constructor for a new CodeEditor.
Event Summary
change(oControlEvent)
liveChange(oControlEvent)
Events borrowed from class sap.ui.core.Control
Method Summary
sap.ui.codeeditor.CodeEditor.extend(sClassName, oClassInfo?, FNMetaImpl?)Creates a new subclass of class sap.ui.codeeditor.CodeEditor with name sClassName and enriches it with the information contained in oClassInfo.
sap.ui.codeeditor.CodeEditor.getMetadata()Returns a metadata object for class sap.ui.codeeditor.CodeEditor.
attachChange(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the change event of this sap.ui.codeeditor.CodeEditor.
attachLiveChange(oData?, fnFunction, oListener?)Attaches event handler fnFunction to the liveChange event of this sap.ui.codeeditor.CodeEditor.
detachChange(fnFunction, oListener)Detaches event handler fnFunction from the change event of this sap.ui.codeeditor.CodeEditor.
detachLiveChange(fnFunction, oListener)Detaches event handler fnFunction from the liveChange event of this sap.ui.codeeditor.CodeEditor.
fireChange(mParameters?)Fires event change to attached listeners.
fireLiveChange(mParameters?)Fires event liveChange to attached listeners.
focus()Sets the focus to the code editor
getColorTheme()Gets current value of property colorTheme.
getCurrentValue()Returns the current value of the code editor
getEditable()Gets current value of property editable.
getHeight()Gets current value of property height.
getLineNumbers()Gets current value of property lineNumbers.
getMaxLines()Gets current value of property maxLines.
getSyntaxHints()Gets current value of property syntaxHints.
getType()Gets current value of property type.
getValue()Gets current value of property value.
getValueSelection()Gets current value of property valueSelection.
getWidth()Gets current value of property width.
setColorTheme(sTheme)Sets the color theme of the code editor
setEditable(bValue)Sets whether the code editor is editable or not
setHeight(sHeight)Sets a new value for property height.
setLineNumbers(bValue)Sets whether line numbers should be shown or not
setMaxLines(iMaxLines)Sets maxLines property.
setSyntaxHints(bShow)Sets whether syntax hints should be shown or not Hints are only visible if lineNumbers is set to true.
setType(sType)Sets the type of the code editors value used for syntax highlighting
setValue(sValue)Sets the value of the code editor
setValueSelection(bValueSelection)Sets a new value for property valueSelection.
setWidth(sWidth)Sets a new value for property width.
Constructor Detail
new sap.ui.codeeditor.CodeEditor(sId?, mSettings?)

Constructor for a new CodeEditor.

Accepts an object literal mSettings that defines initial property values, aggregated and associated objects as well as event handlers. See sap.ui.base.ManagedObject for a general description of the syntax of the settings object.

The supported settings are:

  • Properties

  • Events

    • liveChange : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]
    • change : fnListenerFunction or [fnListenerFunction, oListenerObject] or [oData, fnListenerFunction, oListenerObject]

In addition, all settings applicable to the base type sap.ui.core.Control can be used as well.

Parameters:
stringsId?id for the new control, generated automatically if no id is given
objectmSettings?initial settings for the new control
Event Detail
change(oControlEvent)
Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.getParameters
liveChange(oControlEvent)
Parameters:
sap.ui.base.EventoControlEvent
sap.ui.base.EventProvideroControlEvent.getSource
objectoControlEvent.getParameters
Method Detail
sap.ui.codeeditor.CodeEditor.extend(sClassName, oClassInfo?, FNMetaImpl?): function

Creates a new subclass of class sap.ui.codeeditor.CodeEditor with name sClassName and enriches it with the information contained in oClassInfo.

oClassInfo might contain the same kind of information as described in sap.ui.core.Control.extend.

Parameters:
stringsClassNameName of the class being created
objectoClassInfo?Object literal with information about the class
functionFNMetaImpl?Constructor function for the metadata object; if not given, it defaults to sap.ui.core.ElementMetadata
Returns:
functionCreated class / constructor function
sap.ui.codeeditor.CodeEditor.getMetadata(): sap.ui.base.Metadata
Returns a metadata object for class sap.ui.codeeditor.CodeEditor.
Returns:
sap.ui.base.MetadataMetadata object describing this class
attachChange(oData?, fnFunction, oListener?): sap.ui.codeeditor.CodeEditor

Attaches event handler fnFunction to the change event of this sap.ui.codeeditor.CodeEditor.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.codeeditor.CodeEditor itself.

Parameters:
objectoData?An application-specific payload object that will be passed to the event handler along with the event object when firing the event
functionfnFunctionThe function to be called when the event occurs
objectoListener?Context object to call the event handler with. Defaults to this sap.ui.codeeditor.CodeEditor itself
Returns:
sap.ui.codeeditor.CodeEditorReference to this in order to allow method chaining
attachLiveChange(oData?, fnFunction, oListener?): sap.ui.codeeditor.CodeEditor

Attaches event handler fnFunction to the liveChange event of this sap.ui.codeeditor.CodeEditor.

When called, the context of the event handler (its this) will be bound to oListener if specified, otherwise it will be bound to this sap.ui.codeeditor.CodeEditor itself.

Parameters:
objectoData?An application-specific payload object that will be passed to the event handler along with the event object when firing the event
functionfnFunctionThe function to be called when the event occurs
objectoListener?Context object to call the event handler with. Defaults to this sap.ui.codeeditor.CodeEditor itself
Returns:
sap.ui.codeeditor.CodeEditorReference to this in order to allow method chaining
detachChange(fnFunction, oListener): sap.ui.codeeditor.CodeEditor

Detaches event handler fnFunction from the change event of this sap.ui.codeeditor.CodeEditor.

The passed function and listener object must match the ones used for event registration.

Parameters:
functionfnFunctionThe function to be called, when the event occurs
objectoListenerContext object on which the given function had to be called
Returns:
sap.ui.codeeditor.CodeEditorReference to this in order to allow method chaining
detachLiveChange(fnFunction, oListener): sap.ui.codeeditor.CodeEditor

Detaches event handler fnFunction from the liveChange event of this sap.ui.codeeditor.CodeEditor.

The passed function and listener object must match the ones used for event registration.

Parameters:
functionfnFunctionThe function to be called, when the event occurs
objectoListenerContext object on which the given function had to be called
Returns:
sap.ui.codeeditor.CodeEditorReference to this in order to allow method chaining
fireChange(mParameters?): sap.ui.codeeditor.CodeEditor
Fires event change to attached listeners.
Parameters:
objectmParameters?Parameters to pass along with the event
Returns:
sap.ui.codeeditor.CodeEditorReference to this in order to allow method chaining
fireLiveChange(mParameters?): sap.ui.codeeditor.CodeEditor
Fires event liveChange to attached listeners.
Parameters:
objectmParameters?Parameters to pass along with the event
Returns:
sap.ui.codeeditor.CodeEditorReference to this in order to allow method chaining
Sets the focus to the code editor
Returns:
sap.ui.codeeditor.CodeEditorReturns this to allow method chaining
getColorTheme(): string

Gets current value of property colorTheme.

Sets the editors color theme possible values

Default value is default.

Returns:
stringValue of property colorTheme
getCurrentValue(): string
Returns the current value of the code editor
Returns:
stringReturns the current value of the code editor
getEditable(): boolean

Gets current value of property editable.

Sets whether the code in the editor can be changed by the user

Default value is true.

Returns:
booleanValue of property editable
getHeight(): sap.ui.core.CSSSize

Gets current value of property height.

The height of the code editor. A minimal height of 3rem will be applied in case the height is less than 20px.

Default value is 100%.

Returns:
sap.ui.core.CSSSizeValue of property height
getLineNumbers(): boolean

Gets current value of property lineNumbers.

Sets whether line numbers should be shown

Default value is true.

Returns:
booleanValue of property lineNumbers
getMaxLines(): int

Gets current value of property maxLines.

Sets whether the editor height should auto expand to a maximum number of lines. After reaching the maximum number of lines specified, the content of the CodeEditor will become scrollable.

Note: Keep in mind that the auto expand CodeEditor behavior requires the height property to be set to auto.

Default value is 0.

Returns:
intValue of property maxLines
Since:
1.48.1
getSyntaxHints(): boolean

Gets current value of property syntaxHints.

Sets whether to show syntax hints the editor. This flag is only available if line numbers are shown.

Default value is true.

Returns:
booleanValue of property syntaxHints
getType(): string

Gets current value of property type.

The type of the code in the editor used for syntax highlighting Possible types are javascript (default), json, html, xml and css.

Default value is javascript.

Returns:
stringValue of property type
getValue(): string

Gets current value of property value.

The value displayed in the code editor

Default value is .

Returns:
stringValue of property value
getValueSelection(): boolean

Gets current value of property valueSelection.

Sets whether the code is automatically selected if a value is set

Default value is false.

Returns:
booleanValue of property valueSelection
getWidth(): sap.ui.core.CSSSize

Gets current value of property width.

The width of the code editor

Default value is 100%.

Returns:
sap.ui.core.CSSSizeValue of property width
setColorTheme(sTheme): sap.ui.codeeditor.CodeEditor
Sets the color theme of the code editor
Parameters:
stringsTheme'default', 'hcb', 'hcb_bright', 'hcb_blue'
Returns:
sap.ui.codeeditor.CodeEditorReturns this to allow method chaining
setEditable(bValue): sap.ui.codeeditor.CodeEditor
Sets whether the code editor is editable or not
Parameters:
booleanbValuetrue to allow editing, otherwise false
Returns:
sap.ui.codeeditor.CodeEditorReturns this to allow method chaining
setHeight(sHeight): sap.ui.codeeditor.CodeEditor

Sets a new value for property height.

The height of the code editor. A minimal height of 3rem will be applied in case the height is less than 20px.

When called with a value of null or undefined, the default value of the property will be restored.

Default value is 100%.

Parameters:
sap.ui.core.CSSSizesHeightNew value for property height
Returns:
sap.ui.codeeditor.CodeEditorReference to this in order to allow method chaining
setLineNumbers(bValue): sap.ui.codeeditor.CodeEditor
Sets whether line numbers should be shown or not
Parameters:
booleanbValuetrue to show line numbers
Returns:
sap.ui.codeeditor.CodeEditorReturns this to allow method chaining
setMaxLines(iMaxLines)
Sets maxLines property.
Parameters:
intiMaxLinesMaximum number of lines the editor should display
Since:
1.48.1
setSyntaxHints(bShow): sap.ui.codeeditor.CodeEditor
Sets whether syntax hints should be shown or not Hints are only visible if lineNumbers is set to true.
Parameters:
booleanbShowtrue(default) to show the syntax hints
Returns:
sap.ui.codeeditor.CodeEditorReturns this to allow method chaining
Sets the type of the code editors value used for syntax highlighting
Parameters:
stringsTypejavascript (default), html, xml, css
Returns:
sap.ui.codeeditor.CodeEditorReturns this to allow method chaining
setValue(sValue): sap.ui.codeeditor.CodeEditor
Sets the value of the code editor
Parameters:
stringsValuethe value of the code editor
Returns:
sap.ui.codeeditor.CodeEditorReturns this to allow method chaining
setValueSelection(bValueSelection): sap.ui.codeeditor.CodeEditor

Sets a new value for property valueSelection.

Sets whether the code is automatically selected if a value is set

When called with a value of null or undefined, the default value of the property will be restored.

Default value is false.

Parameters:
booleanbValueSelectionNew value for property valueSelection
Returns:
sap.ui.codeeditor.CodeEditorReference to this in order to allow method chaining
setWidth(sWidth): sap.ui.codeeditor.CodeEditor

Sets a new value for property width.

The width of the code editor

When called with a value of null or undefined, the default value of the property will be restored.

Default value is 100%.

Parameters:
sap.ui.core.CSSSizesWidthNew value for property width
Returns:
sap.ui.codeeditor.CodeEditorReference to this in order to allow method chaining