Class Codeeditor
- java.lang.Object
-
- org.zkoss.zk.ui.AbstractComponent
-
- org.zkoss.zk.ui.HtmlBasedComponent
-
- org.zkoss.zul.impl.XulElement
-
- org.zkoss.zul.Codeeditor
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,org.zkoss.zk.ui.Component,org.zkoss.zk.ui.ext.Disable,org.zkoss.zk.ui.ext.Readonly,org.zkoss.zk.ui.ext.Scope,org.zkoss.zk.ui.sys.ComponentCtrl
public class Codeeditor extends XulElement implements org.zkoss.zk.ui.ext.Disable, org.zkoss.zk.ui.ext.Readonly
A code editor that loads and edits source code with syntax highlighting.The Community Edition build provides basic editing: setting/loading the content (
setValue(java.lang.String)), choosing the highlight language (setLanguage(java.lang.String)), toggling read-only (isReadonly()) and line numbers (setLineNumbers(boolean)), and an optional light/dark editor theme (setTheme(java.lang.String)). Edits are reported to the server through the standardonChange/onChangingevents carrying anInputEvent, sovalueparticipates in data binding the same way as other input components.Advanced capabilities (autocomplete, lint, code folding, multi-cursor, search/replace, diff) are not part of the CE build; they are layered on by the EE module through a client-side extension hook, so an application can adopt them later without changing the component or the ZUL.
- Since:
- 11.0.0
- Author:
- peakerlee
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Codeeditor()Codeeditor(java.lang.String value)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetLanguage()Returns the syntax-highlight language.intgetTabSize()Returns the number of columns a tab character is rendered as.java.lang.StringgetTheme()Returns the editor theme.java.lang.StringgetValue()Returns the editor content.protected booleanisChildable()booleanisDisabled()Returns whether the editor is disabled.booleanisLineNumbers()Returns whether the gutter line numbers are shown.booleanisReadonly()Returns whether the editor is read-only.protected voidrenderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer)voidservice(org.zkoss.zk.au.AuRequest request, boolean everError)voidsetDisabled(boolean disabled)Sets whether the editor is disabled.voidsetLanguage(java.lang.String language)Sets the syntax-highlight language.voidsetLineNumbers(boolean lineNumbers)Sets whether the gutter line numbers are shown.voidsetReadonly(boolean readonly)Sets whether the editor is read-only.voidsetTabSize(int tabSize)Sets how many columns a tab character is rendered as.voidsetTheme(java.lang.String theme)Sets the editor theme.voidsetValue(java.lang.String value)Sets the editor content.-
Methods inherited from class org.zkoss.zul.impl.XulElement
clone, getContext, getCtrlKeys, getPopup, getPropertyAccess, getTooltip, setContext, setContext, setContextAttributes, setCtrlKeys, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributes
-
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getExtraCtrl, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getSkeleton, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZindex, getZIndex, removeSclass, removeSclass, setAction, setClass, setClientAction, setDraggable, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setSkeleton, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly
-
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, destroyIndexCacheMap, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, disableHostChanged, enableBindingAnnotation, enableHostChanged, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getForwards, getId, getIndexCacheMap, getLastChild, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, insertBefore, invalidate, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onPageAttached, onPageDetached, onParentChanged, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderPropertiesOnly, replace, response, response, response, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
-
-
-
-
Method Detail
-
getValue
public java.lang.String getValue()
Returns the editor content.Default: an empty string.
-
setValue
public void setValue(java.lang.String value)
Sets the editor content.- Parameters:
value- the source code;nullis treated as an empty string.- Since:
- 11.0.0
-
getLanguage
public java.lang.String getLanguage()
Returns the syntax-highlight language.Default:
"plain".
-
setLanguage
public void setLanguage(java.lang.String language)
Sets the syntax-highlight language.- Parameters:
language- one ofplain,html,xml,java,javascript,css,json,sql,markdown;nullresets it to the default"plain".- Throws:
org.zkoss.zk.ui.WrongValueException- iflanguageis non-null and not an accepted token.- Since:
- 11.0.0
-
isReadonly
public boolean isReadonly()
Returns whether the editor is read-only.Default: false.
- Specified by:
isReadonlyin interfaceorg.zkoss.zk.ui.ext.Readonly
-
setReadonly
public void setReadonly(boolean readonly)
Sets whether the editor is read-only.- Specified by:
setReadonlyin interfaceorg.zkoss.zk.ui.ext.Readonly- Parameters:
readonly- whether to forbid editing the content.- Since:
- 11.0.0
-
isDisabled
public boolean isDisabled()
Returns whether the editor is disabled.Default: false.
- Specified by:
isDisabledin interfaceorg.zkoss.zk.ui.ext.Disable
-
setDisabled
public void setDisabled(boolean disabled)
Sets whether the editor is disabled. A disabled editor cannot be edited or focused and is shown dimmed; unlikesetReadonly(boolean), which keeps the content focusable and selectable.- Specified by:
setDisabledin interfaceorg.zkoss.zk.ui.ext.Disable- Parameters:
disabled- whether to disable the editor.- Since:
- 11.0.0
-
isLineNumbers
public boolean isLineNumbers()
Returns whether the gutter line numbers are shown.Default: true.
-
setLineNumbers
public void setLineNumbers(boolean lineNumbers)
Sets whether the gutter line numbers are shown.- Parameters:
lineNumbers- whether to show the line-number gutter.- Since:
- 11.0.0
-
getTabSize
public int getTabSize()
Returns the number of columns a tab character is rendered as.Default: 4.
-
setTabSize
public void setTabSize(int tabSize)
Sets how many columns a tab character is rendered as. The indent character itself is always a tab; this only changes its displayed width.- Parameters:
tabSize- a positive column count; the default is 4.- Throws:
org.zkoss.zk.ui.WrongValueException- iftabSizeis less than 1.- Since:
- 11.0.0
-
getTheme
public java.lang.String getTheme()
Returns the editor theme.Default:
"light".
-
setTheme
public void setTheme(java.lang.String theme)
Sets the editor theme.- Parameters:
theme-lightordark;nullresets it to the default"light".- Throws:
org.zkoss.zk.ui.WrongValueException- ifthemeis non-null and neitherlightnordark.- Since:
- 11.0.0
-
isChildable
protected boolean isChildable()
- Overrides:
isChildablein classorg.zkoss.zk.ui.AbstractComponent
-
renderProperties
protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws java.io.IOException- Overrides:
renderPropertiesin classXulElement- Throws:
java.io.IOException
-
service
public void service(org.zkoss.zk.au.AuRequest request, boolean everError)- Specified by:
servicein interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
servicein classorg.zkoss.zk.ui.HtmlBasedComponent
-
-