com.extjs.gxt.ui.client.widget
Class Editor

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.extjs.gxt.ui.client.widget.Component
              extended by com.extjs.gxt.ui.client.widget.BoxComponent
                  extended by com.extjs.gxt.ui.client.widget.Editor
All Implemented Interfaces:
Observable, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.IsWidget
Direct Known Subclasses:
CellEditor

public class Editor
extends BoxComponent

A base editor field that handles displaying/hiding on demand and has some built-in sizing and event handling logic.

Events:
BeforeCancelEdit : EditorEvent(editor, value, startValue)
Fires before editing is canceled
BeforeStartEdit : EditorEvent(editor, boundEl, value)
Fires when editing is initiated, but before the value changes.
StartEdit : EditorEvent(editor, value)
Fires when this editor is displayed.
BeforeComplete : EditorEvent(editor, value, startValue)
Fires after a change has been made to the field, but before the change is reflected in the underlying field.
CancelEdit : EditorEvent(editor, value, startValue)
Fires after editing is canceled
Complete : EditorEvent(editor, value, startValue)
Fires after editing is complete and any changed value has been written to the underlying field.
SpecialKey : EditorEvent(field)
Fires when any key related to navigation (arrows, tab, enter, esc, etc.) is pressed.
Inherited Events:
BoxComponent Move
BoxComponent Resize
Component Enable
Component Disable
Component BeforeHide
Component Hide
Component BeforeShow
Component Show
Component Attach
Component Detach
Component BeforeRender
Component Render
Component BrowserEvent
Component BeforeStateRestore
Component StateRestore
Component BeforeStateSave
Component SaveState


Nested Class Summary
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
adjustSize, cacheSizes, ensureVisibilityOnSizing, height, lastSize, layer, shim, width
 
Fields inherited from class com.extjs.gxt.ui.client.widget.Component
afterRender, attachables, baseStyle, disabled, disabledStyle, disableTextSelection, dummy, focusable, hidden, mask, maskMessage, maskMessageStyleName, monitorWindowResize, rendered, resizeHandler, setElementRender, stateId, swallowEvents, toolTip, windowResizeDelay, windowResizeTask
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
Editor(Field field)
          Creates a new editor.
 
Method Summary
 void cancelEdit()
          Cancels the editing process and hides the editor without persisting any changes.
protected  void cancelEdit(boolean remainVisible, boolean revertInvalid)
           
 void completeEdit()
          Ends the editing process, persists the changed value to the underlying field, and hides the editor.
protected  void completeEdit(boolean remainVisible)
           
protected  void doAttachChildren()
           
protected  void doAutoSize()
           
protected  void doDetachChildren()
           
 java.lang.String getAlignment()
          Returns the editor's alignment.
 Style.AutoSizeMode getAutoSizeMode()
          Returns the auto size mode.
 Field getField()
          Returns the editor's field.
 java.lang.Object getValue()
          Returns the data value of the editor.
 boolean isAllowBlur()
          Returns true if blurs are allowed.
 boolean isCancelOnEsc()
          Returns true if cancel on escape is enabled.
 boolean isCancelOnInvalid()
          Deprecated. duplicate method see isRevertInvalid()
 boolean isCompleteOnEnter()
          Returns true if complete on enter is enabled.
 boolean isConstrain()
          Returns true if the editor is constrained to the viewport.
 boolean isRevertInvalid()
          Returns true of the editor reverts the value to the start value on invalid.
 boolean isSwallowKeys()
          Returns true if key presses are being swallowed.
 boolean isUpdateEl()
          Returns true if the inner HTML of the bound element is updated when the update is complete.
protected  void onBlur(FieldEvent fe)
           
protected  void onDisable()
           
protected  void onEnable()
           
protected  void onHide()
           
protected  void onRender(com.google.gwt.user.client.Element target, int index)
          Subclasses must override and ensure setElement is called for lazy rendered components.
protected  void onResize(int width, int height)
          Called after the component is resized, this method is empty by default but can be implemented by any subclass that needs to perform custom logic after a resize occurs.
protected  void onShow()
           
protected  void onSpecialKey(FieldEvent fe)
           
 java.lang.Object postProcessValue(java.lang.Object value)
          Called after the editor completes an edit.
 java.lang.Object preProcessValue(java.lang.Object value)
          Called before the editor sets the value on the wrapped field.
 void realign()
          Realigns the editor to the bound field based on the current alignment config value.
 void setAlignment(java.lang.String alignment)
          The position to align to (see El.alignTo(com.google.gwt.user.client.Element, java.lang.String, int[]) for more details, defaults to "c-c?").
 void setAllowBlur(boolean allowBlur)
          Sets whether editing should be cancelled when the field is blurred (defaults to false).
 void setAutoSizeMode(Style.AutoSizeMode autoSizeMode)
          Sets the mode the editor gets sized by (defaults to AutoSizeMode.BOTH).
 void setCancelOnEsc(boolean cancelOnEsc)
          True to cancel the edit when the escape key is pressed (defaults to false).
 void setCancelOnInvalid(boolean cancelOnInvalid)
          Deprecated. duplicate method see setRevertInvalid(boolean)
 void setCompleteOnEnter(boolean completeOnEnter)
          True to complete the edit when the enter key is pressed (defaults to false).
 void setConstrain(boolean constrain)
          True to constrain the editor to the viewport.
 void setRevertInvalid(boolean revertInvalid)
          True to automatically revert the field value and cancel the edit when the user completes an edit and the field validation fails (defaults to true).
 void setSwallowKeys(boolean swallowKeys)
          Handle the keypress events so they don't propagate (defaults to true).
 void setUpdateEl(boolean updateEl)
          True to update the innerHTML of the bound element when the update completes (defaults to false).
 void setValue(java.lang.Object value)
          Sets the data value of the editor
 void startEdit(com.google.gwt.user.client.Element el, java.lang.Object value)
          Starts the editing process and shows the editor.
protected  void triggerBlur(TriggerField field)
           
 
Methods inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
adjustPosition, adjustSize, afterRender, createComponentEvent, getBounds, getHeight, getHeight, getPosition, getPositionEl, getResizeEl, getShadow, getShadowOffset, getShadowPosition, getSize, getWidth, getWidth, hideShadow, hideShim, hideUnders, isAutoHeight, isAutoWidth, isDeferHeight, isShim, onPosition, onUnload, setAutoHeight, setAutoWidth, setBounds, setBounds, setDeferHeight, setHeight, setHeight, setPagePosition, setPagePosition, setPixelSize, setPosition, setShadow, setShadowOffset, setShadowPosition, setShim, setSize, setSize, setWidth, setWidth, sync, syncSize
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Component
addAttachable, addListener, addPlugin, addStyleName, addStyleOnOver, addWidgetListener, applyState, assertAfterRender, assertPreRender, beforeRender, blur, clearState, createObservable, createStyles, disable, disableContextMenu, disableEvents, disableTextSelection, el, enable, enableEvents, fireEvent, fireEvent, fireEvent, fly, focus, frame, getAriaSupport, getBaseStyle, getBorders, getContextMenu, getData, getElement, getFocusEl, getFocusSupport, getHideMode, getId, getItemId, getListeners, getModel, getObservable, getPlugins, getState, getStateId, getTabIndex, getTitle, getToolTip, getWindowResizeDelay, hasListeners, hasListeners, hide, hideToolTip, initState, isDisabledEvents, isDisableTextSelection, isEnabled, isMasked, isMonitorWindowResize, isRendered, isStateful, isVisible, isVisible, mask, mask, mask, notifyHide, notifyShow, onAttach, onBrowserEvent, onComponentEvent, onDetach, onDetachHelper, onEnsureDebugId, onHideContextMenu, onLoad, onRightClick, onShowContextMenu, onWindowResize, previewEvent, recalculate, removeAllListeners, removeAttachagle, removeFromParent, removeListener, removeStyleName, removeStyleOnOver, removeSwallow, removeToolTip, removeWidgetListener, render, render, repaint, saveState, setAriaRole, setAriaState, setAriaSupport, setBorders, setContextMenu, setData, setEl, setElement, setElement, setEnabled, setFiresEvents, setHideMode, setId, setIntStyleAttribute, setItemId, setModel, setMonitorWindowResize, setParent, setStateful, setStateId, setStyleAttribute, setStyleName, setTabIndex, setTitle, setToolTip, setToolTip, setVisible, setWindowResizeDelay, setZIndex, show, sinkEvents, swallowEvent, swallowEvent, toString, unframe, unmask
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, setLayoutData
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, removeStyleDependentName, setElement, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, sinkBitlessEvent, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Editor

public Editor(Field field)
Creates a new editor.

Parameters:
field - the field
Method Detail

cancelEdit

public void cancelEdit()
Cancels the editing process and hides the editor without persisting any changes. The field value will be reverted to the original starting value.


completeEdit

public void completeEdit()
Ends the editing process, persists the changed value to the underlying field, and hides the editor.


getAlignment

public java.lang.String getAlignment()
Returns the editor's alignment.

Returns:
the alignment

getAutoSizeMode

public Style.AutoSizeMode getAutoSizeMode()
Returns the auto size mode.

Returns:
the autoSizeMode

getField

public Field getField()
Returns the editor's field.

Returns:
the field

getValue

public java.lang.Object getValue()
Returns the data value of the editor.

Returns:
the value

isAllowBlur

public boolean isAllowBlur()
Returns true if blurs are allowed.

Returns:
the allow blur state

isCancelOnEsc

public boolean isCancelOnEsc()
Returns true if cancel on escape is enabled.

Returns:
the cancel on escape state

isCancelOnInvalid

public boolean isCancelOnInvalid()
Deprecated. duplicate method see isRevertInvalid()

Returns true of the editor reverts the value to the start value on invalid.

Returns:
true if the edit is canceled

isCompleteOnEnter

public boolean isCompleteOnEnter()
Returns true if complete on enter is enabled.

Returns:
the complete on enter state

isConstrain

public boolean isConstrain()
Returns true if the editor is constrained to the viewport.

Returns:
the constrain state

isRevertInvalid

public boolean isRevertInvalid()
Returns true of the editor reverts the value to the start value on invalid.

Returns:
the revert invalid state

isSwallowKeys

public boolean isSwallowKeys()
Returns true if key presses are being swallowed.

Returns:
the swallow key state

isUpdateEl

public boolean isUpdateEl()
Returns true if the inner HTML of the bound element is updated when the update is complete.

Returns:
the update element state

postProcessValue

public java.lang.Object postProcessValue(java.lang.Object value)
Called after the editor completes an edit.

Parameters:
value - the value from the editor
Returns:
the updated value

preProcessValue

public java.lang.Object preProcessValue(java.lang.Object value)
Called before the editor sets the value on the wrapped field.

Parameters:
value - the editor value
Returns:
the updated value

realign

public void realign()
Realigns the editor to the bound field based on the current alignment config value.


setAlignment

public void setAlignment(java.lang.String alignment)
The position to align to (see El.alignTo(com.google.gwt.user.client.Element, java.lang.String, int[]) for more details, defaults to "c-c?").

Parameters:
alignment - the alignment

setAllowBlur

public void setAllowBlur(boolean allowBlur)
Sets whether editing should be cancelled when the field is blurred (defaults to false).

Parameters:
allowBlur - true to allow blur

setAutoSizeMode

public void setAutoSizeMode(Style.AutoSizeMode autoSizeMode)
Sets the mode the editor gets sized by (defaults to AutoSizeMode.BOTH).

Parameters:
autoSizeMode - the autoSizeMode to set

setCancelOnEsc

public void setCancelOnEsc(boolean cancelOnEsc)
True to cancel the edit when the escape key is pressed (defaults to false).

Parameters:
cancelOnEsc - true to cancel on escape

setCancelOnInvalid

public void setCancelOnInvalid(boolean cancelOnInvalid)
Deprecated. duplicate method see setRevertInvalid(boolean)

True to automatically revert the field value and cancel the edit when the user completes an edit and the field validation fails (defaults to true).

Parameters:
cancelOnInvalid - true to cancel on invalid

setCompleteOnEnter

public void setCompleteOnEnter(boolean completeOnEnter)
True to complete the edit when the enter key is pressed (defaults to false).

Parameters:
completeOnEnter - true to complete on enter

setConstrain

public void setConstrain(boolean constrain)
True to constrain the editor to the viewport.

Parameters:
constrain - true to constrain

setRevertInvalid

public void setRevertInvalid(boolean revertInvalid)
True to automatically revert the field value and cancel the edit when the user completes an edit and the field validation fails (defaults to true).

Parameters:
revertInvalid - true to revert

setSwallowKeys

public void setSwallowKeys(boolean swallowKeys)
Handle the keypress events so they don't propagate (defaults to true).

Parameters:
swallowKeys - true to swallow key press events.

setUpdateEl

public void setUpdateEl(boolean updateEl)
True to update the innerHTML of the bound element when the update completes (defaults to false).

Parameters:
updateEl - true to update the inner HTML

setValue

public void setValue(java.lang.Object value)
Sets the data value of the editor

Parameters:
value - any valid value supported by the underlying field

startEdit

public void startEdit(com.google.gwt.user.client.Element el,
                      java.lang.Object value)
Starts the editing process and shows the editor.

Parameters:
el - the element to edit

cancelEdit

protected void cancelEdit(boolean remainVisible,
                          boolean revertInvalid)

completeEdit

protected void completeEdit(boolean remainVisible)

doAttachChildren

protected void doAttachChildren()
Overrides:
doAttachChildren in class Component

doAutoSize

protected void doAutoSize()

doDetachChildren

protected void doDetachChildren()
Overrides:
doDetachChildren in class Component

onBlur

protected void onBlur(FieldEvent fe)

onDisable

protected void onDisable()
Overrides:
onDisable in class Component

onEnable

protected void onEnable()
Overrides:
onEnable in class Component

onHide

protected void onHide()
Overrides:
onHide in class BoxComponent

onRender

protected void onRender(com.google.gwt.user.client.Element target,
                        int index)
Description copied from class: Component
Subclasses must override and ensure setElement is called for lazy rendered components.

Overrides:
onRender in class Component
Parameters:
target - the target element
index - the insert location

onResize

protected void onResize(int width,
                        int height)
Description copied from class: BoxComponent
Called after the component is resized, this method is empty by default but can be implemented by any subclass that needs to perform custom logic after a resize occurs.

Overrides:
onResize in class BoxComponent
Parameters:
width - the width
height - the height

onShow

protected void onShow()
Overrides:
onShow in class BoxComponent

onSpecialKey

protected void onSpecialKey(FieldEvent fe)

triggerBlur

protected void triggerBlur(TriggerField field)