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.shared.HasHandlers, com.google.gwt.user.client.EventListener
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.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.
 void completeEdit()
          Ends the editing process, persists the changed value to the underlying field, and hides the editor.
 java.lang.String getAlignment()
          Returns the editor's alignment.
 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 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.
 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 setCancelOnEsc(boolean cancelOnEsc)
          True to cancel the edit when the escape key is pressed (defaults to false).
 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 revert to start value on invalid value (defaults to true).
 void setSize(int width, int height)
          Sets the width and height of the component.
 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.
 
Methods inherited from class com.extjs.gxt.ui.client.widget.BoxComponent
getBounds, getHeight, getHeight, getPosition, getShadow, getShadowOffset, getShadowPosition, getSize, getWidth, getWidth, isAutoHeight, isAutoWidth, isDeferHeight, isShim, setAutoHeight, setAutoWidth, setBounds, setBounds, setDeferHeight, setHeight, setHeight, setPagePosition, setPagePosition, setPixelSize, setPosition, setShadow, setShadowOffset, setShadowPosition, setShim, setSize, setWidth, setWidth, sync, syncSize
 
Methods inherited from class com.extjs.gxt.ui.client.widget.Component
addListener, addPlugin, addStyleName, addWidgetListener, clearState, disable, disableEvents, disableTextSelection, el, enable, enableEvents, fireEvent, fireEvent, fireEvent, fly, focus, getBaseStyle, getBorders, getContextMenu, getData, getElement, getHideMode, getId, getItemId, getListeners, getModel, getState, getStateId, getToolTip, hasListeners, hasListeners, hide, hideToolTip, isDisabledEvents, isEnabled, isRendered, isStateful, isVisible, mask, mask, mask, onBrowserEvent, onComponentEvent, recalculate, removeAllListeners, removeFromParent, removeListener, removeStyleName, removeSwallow, removeToolTip, removeWidgetListener, render, render, repaint, saveState, setBorders, setContextMenu, setData, setElement, setEnabled, setHideMode, setId, setIntStyleAttribute, setItemId, setStateful, setStateId, setStyleAttribute, setStyleName, setTitle, setToolTip, setToolTip, setVisible, setZIndex, show, sinkEvents, swallowEvent, swallowEvent, toString, unmask
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
fireEvent, getParent, isAttached
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getOffsetHeight, getOffsetWidth, getStyleName, getStylePrimaryName, getTitle, isVisible, removeStyleDependentName, setStylePrimaryName, setVisible, unsinkEvents
 
Methods inherited from class java.lang.Object
equals, 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

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

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

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

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 revert to start value on invalid value (defaults to true).

Parameters:
revertInvalid - true to revert

setSize

public void setSize(int width,
                    int height)
Description copied from class: BoxComponent
Sets the width and height of the component. This method fires the Resize event.

Overrides:
setSize in class BoxComponent
Parameters:
width - the new width to set
height - the new height to set

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