com.sage.swt.client.widget
Class AbstractSwtTextBox

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Composite
              extended by com.sage.swt.client.widget.AbstractSwtWidget
                  extended by com.sage.swt.client.widget.AbstractSwtDataWidget
                      extended by com.sage.swt.client.widget.AbstractSwtTextBox
All Implemented Interfaces:
com.google.gwt.event.dom.client.BlurHandler, com.google.gwt.event.dom.client.FocusHandler, com.google.gwt.event.dom.client.HasAllKeyHandlers, com.google.gwt.event.dom.client.HasAllMouseHandlers, com.google.gwt.event.dom.client.HasBlurHandlers, com.google.gwt.event.dom.client.HasClickHandlers, com.google.gwt.event.dom.client.HasFocusHandlers, com.google.gwt.event.dom.client.HasKeyDownHandlers, com.google.gwt.event.dom.client.HasKeyPressHandlers, com.google.gwt.event.dom.client.HasKeyUpHandlers, com.google.gwt.event.dom.client.HasMouseDownHandlers, com.google.gwt.event.dom.client.HasMouseMoveHandlers, com.google.gwt.event.dom.client.HasMouseOutHandlers, com.google.gwt.event.dom.client.HasMouseOverHandlers, com.google.gwt.event.dom.client.HasMouseUpHandlers, com.google.gwt.event.dom.client.HasMouseWheelHandlers, com.google.gwt.event.logical.shared.HasAttachHandlers, com.google.gwt.event.shared.EventHandler, com.google.gwt.event.shared.HasHandlers, com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.Focusable, com.google.gwt.user.client.ui.HasName, com.google.gwt.user.client.ui.IsWidget, HasPropertyChangeHandlers, PropertyBag, BehavesAsFocusWidget, BehavesAsTextBox, SwtEventSource, HasAfterWidgetKeyChangedHandlers, HasBeforeWidgetKeyChangedHandlers, HasCancellableFocusHandlers, HasHint, HasReadOnly, HasSwtChangeHandlers, Resizeable, SwtDataWidget, SwtSimpleBindableWidget, SwtSimpleDataWidget, SwtWidget
Direct Known Subclasses:
SwtPasswordTextBox, SwtTextArea, SwtTextBox

public abstract class AbstractSwtTextBox
extends AbstractSwtDataWidget
implements BehavesAsTextBox, Resizeable, com.google.gwt.user.client.ui.HasName, HasHint, com.google.gwt.event.dom.client.FocusHandler, com.google.gwt.event.dom.client.BlurHandler

The "SWT-ized" version of TextBoxBase, but with formatting support added. This base class provides convenience implementations of methods, many of which just delegate to the underlying TextBoxBase widget (provided by implementing class), underlying formatter (provided by the implementing class), or other members created by this class.


Nested Class Summary
protected  class AbstractSwtTextBox.FormattableTextBoxBlurHandler
          Focus handler for a formattable text box.
protected  class AbstractSwtTextBox.HintBlurHandler
          Blur handler for a text box.
protected  class AbstractSwtTextBox.HintClickHandler
          HintClickHandler when the user clicks on the textBox, if a hint exists in the box, then the cursor position must be on the first position.
protected  class AbstractSwtTextBox.HintFocusHandler
          Focus handler for a text box.
protected  class AbstractSwtTextBox.HintKeyDownHandler
          Keyboard handler for a text box.
 
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.sage.swt.client.widget.AbstractSwtDataWidget
PIXEL_FACTOR
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Fields inherited from interface com.sage.swt.client.widget.BehavesAsTextBox
ALIGN_CENTER, ALIGN_JUSTIFY, ALIGN_LEFT, ALIGN_RIGHT
 
Constructor Summary
AbstractSwtTextBox()
          Default constructor.
AbstractSwtTextBox(WidgetKey widgetKey, SwtErrorStack errorStack)
          Constructor.
 
Method Summary
 com.google.gwt.event.shared.HandlerRegistration addBeforeFocusHandler(BeforeFocusHandler handler)
          Adds a handler to receive BeforeFocus events.
 com.google.gwt.event.shared.HandlerRegistration addBlurHandler(com.google.gwt.event.dom.client.BlurHandler handler)
          
 com.google.gwt.event.shared.HandlerRegistration addClickHandler(com.google.gwt.event.dom.client.ClickHandler handler)
          
 com.google.gwt.event.shared.HandlerRegistration addFocusHandler(com.google.gwt.event.dom.client.FocusHandler handler)
          
 com.google.gwt.event.shared.HandlerRegistration addKeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler handler)
          
 com.google.gwt.event.shared.HandlerRegistration addKeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler handler)
          
 com.google.gwt.event.shared.HandlerRegistration addKeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler handler)
          
 void cancelKey()
          If a keyboard event is currently being handled on this text box, calling this method will suppress it.
 int getCursorPos()
          Gets the current position of the cursor (this also serves as the beginning of the text selection).
protected static java.util.Collection<Property> getDefaultProperties()
          Make it static so widgets can do static initializers of their properties (for efficiency).
protected abstract  Formatter getFormatter()
          Returns the formatter associated with this (composite) widget.
 java.lang.String getHintText()
          Get hint text
 java.lang.String getName()
          
protected abstract  PatternFormatter getPatternFormatter()
           
 java.util.Collection<Property> getProperties()
          Gets the collection of properties contained in this bag.
 java.lang.String getSelectedText()
          Gets the text currently selected within this text box.
 int getSelectionLength()
          Gets the length of the current text selection.
 int getTabIndex()
          
 java.lang.String getText()
          Get the text in the text box
protected abstract  com.google.gwt.user.client.ui.TextBoxBase getTextBox()
          Returns the text entry (TextBoxBase) widget that is being wrapped by this composite class.
 java.lang.Object getValue()
          Gets the widget's value.
protected  com.google.gwt.user.client.ui.Widget getWidget()
          Gets the topmost underlying widget that is being wrapped by this SWT widget.
 int getWidth()
          Return the width set by the width property or the auto size property
 boolean isReadOnly()
          Determines whether or not the widget is read-only.
 void onBlur(com.google.gwt.event.dom.client.BlurEvent event)
           
 void onFocus(com.google.gwt.event.dom.client.FocusEvent event)
          
 void refreshFormattedValue()
          Re-format the value based on the format information.
 void selectAll()
          Selects all of the text in the box.
 void setAccessKey(char key)
          
 void setAutoSizeLayout(AutoSizeLayoutInfo info)
          Set the width via the auto size property
 void setCursorPos(int pos)
          Sets the cursor position.
protected  boolean setDefaultPropertyValue(Property property, java.lang.Object newValue)
          Sets the value of one of the wrapped widget's default properties.
 void setFocus(boolean focused)
          
 void setFormatError(boolean error)
          Sets or removes the format error style ("formatError" style name).
 void setHeight(int height)
          Sets the object's height.
 void setHintText(java.lang.String hintText)
          Set hint text
 void setName(java.lang.String name)
          
 void setReadOnly(boolean readOnly)
          Turns read-only mode on or off.
 void setSelectionRange(int pos, int length)
          Sets the range of text to be selected.
 void setTabIndex(int index)
          
 void setText(java.lang.String text)
          Set the text in the text box
 void setTextAlignment(com.google.gwt.user.client.ui.ValueBoxBase.TextAlignment alignment)
          Sets the alignment of the text in the text box.
 void setupDefaultSizeProperties()
          This method will setup the Height and Width properties that are stored for a widget - so that a subsequent call to getPropertyValue will return a non-null value.
protected  void setupPropertyDefaultValues()
          Stores the current value of the widget properties as the default values.
 void setValue(java.lang.Object value)
           Sets the value of the widget.
 void setWidth(int width)
          Sets the object's width.
 
Methods inherited from class com.sage.swt.client.widget.AbstractSwtDataWidget
addChangeHandler, fireChangeEvent, fireChangeEvent, getDataPropertyBinding, getDataType, getEvent, getEvents, getFormatPattern, getFractionDigits, getMaxLength, getNumberDomain, getTotalDigits, integerOf, refreshValue, saveValueToDataSource, setDataPropertyBinding, setDataType, setFormatPattern, setFractionDigits, setMaxLength, setNumberDomain, setTotalDigits, setValue
 
Methods inherited from class com.sage.swt.client.widget.AbstractSwtWidget
addAfterWidgetKeyChangedHandler, addBeforeWidgetKeyChangedHandler, addMouseDownHandler, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler, addPropertyChangeHandler, changeAlignmentInParent, forceBrowserRepaint, getDatasourceID, getDesignerCategory, getDesignerTooltip, getDesignerTypeName, getErrorStack, getHelpID, getHorizontalAlignmentInParent, getInstanceContext, getPreferenceBinding, getPreferenceStoreID, getPropertyDefaultValue, getPropertyValue, getSymbolID, getTitle, getVerticalAlignmentInParent, getWidgetHelper, getWidgetKey, isEnabled, isVisible, setClientProperty, setDatasourceID, setElementID, setEnabled, setHelpID, setHorizontalAlignmentInParent, setInstanceContext, setPreferenceBinding, setPreferenceStoreID, setPropertyDefaultValue, setSymbolID, setTitle, setupAlignmentInParentProperties, setupDefaultAlignmentInParentProperties, setupDefaultHeightProperty, setupDefaultWidthProperty, setVerticalAlignmentInParent, setVisible, setWidgetKey
 
Methods inherited from class com.google.gwt.user.client.ui.Composite
initWidget, isAttached, onAttach, onBrowserEvent, onDetach, setWidget
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, doAttachChildren, doDetachChildren, fireEvent, getHandlerCount, getLayoutData, getParent, isOrWasAttached, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setVisible, setWidth, sinkBitlessEvent, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.sage.swt.client.widget.BehavesAsFocusWidget
isEnabled, setEnabled
 
Methods inherited from interface com.google.gwt.event.shared.HasHandlers
fireEvent
 
Methods inherited from interface com.sage.swt.client.widget.SwtWidget
getDatasourceID, getErrorStack, getHelpID, getHorizontalAlignmentInParent, getInstanceContext, getPreferenceBinding, getPreferenceStoreID, getVerticalAlignmentInParent, getWidgetKey, isEnabled, isVisible, setClientProperty, setDatasourceID, setEnabled, setHelpID, setHorizontalAlignmentInParent, setInstanceContext, setPreferenceBinding, setPreferenceStoreID, setupAlignmentInParentProperties, setupDefaultAlignmentInParentProperties, setVerticalAlignmentInParent, setVisible, setWidgetKey
 
Methods inherited from interface com.sage.swt.client.widget.HasBeforeWidgetKeyChangedHandlers
addBeforeWidgetKeyChangedHandler
 
Methods inherited from interface com.sage.swt.client.widget.HasAfterWidgetKeyChangedHandlers
addAfterWidgetKeyChangedHandler
 
Methods inherited from interface com.sage.swt.client.customization.PropertyBag
setPropertyValue
 

Constructor Detail

AbstractSwtTextBox

public AbstractSwtTextBox()
Default constructor.


AbstractSwtTextBox

public AbstractSwtTextBox(WidgetKey widgetKey,
                          SwtErrorStack errorStack)
Constructor.

Parameters:
widgetKey - The WidgetKey for the widget.
errorStack - The SwtErrorStack that stores the list of UI errors.
Method Detail

getWidget

protected com.google.gwt.user.client.ui.Widget getWidget()
Gets the topmost underlying widget that is being wrapped by this SWT widget.

Specified by:
getWidget in class AbstractSwtWidget
Returns:
The topmost underlying widget that is being wrapped by this SWT widget.

getTextBox

protected abstract com.google.gwt.user.client.ui.TextBoxBase getTextBox()
Returns the text entry (TextBoxBase) widget that is being wrapped by this composite class.

Returns:
?

getFormatter

protected abstract Formatter getFormatter()
Returns the formatter associated with this (composite) widget.

Returns:
?

getPatternFormatter

protected abstract PatternFormatter getPatternFormatter()
Returns:
?

getValue

public java.lang.Object getValue()
Gets the widget's value.

Specified by:
getValue in interface SwtSimpleDataWidget
Returns:
the widget's value.

setValue

public void setValue(java.lang.Object value)

Sets the value of the widget.

Specified by:
setValue in interface SwtSimpleBindableWidget
Parameters:
value - The value to set in this widget.

refreshFormattedValue

public void refreshFormattedValue()
Re-format the value based on the format information. Default implementation doing nothing.

Specified by:
refreshFormattedValue in interface SwtSimpleDataWidget
Overrides:
refreshFormattedValue in class AbstractSwtDataWidget

isReadOnly

public boolean isReadOnly()
Determines whether or not the widget is read-only.

Specified by:
isReadOnly in interface HasReadOnly
Returns:
true if the widget is currently read-only, false if the widget is currently editable

setReadOnly

public void setReadOnly(boolean readOnly)
Turns read-only mode on or off.

Specified by:
setReadOnly in interface HasReadOnly
Parameters:
readOnly - if true, the widget becomes read-only; if false the widget becomes editable

setHeight

public void setHeight(int height)
Sets the object's height. This height does not include decorations such as border, margin, and padding.

Specified by:
setHeight in interface Resizeable
Parameters:
height - the object's new height in pixels

getWidth

public int getWidth()
Return the width set by the width property or the auto size property

Returns:
width value

setWidth

public void setWidth(int width)
Sets the object's width. This width does not include decorations such as border, margin, and padding.

Specified by:
setWidth in interface Resizeable
Parameters:
width - the object's new width in pixels

setAutoSizeLayout

public void setAutoSizeLayout(AutoSizeLayoutInfo info)
Set the width via the auto size property

Parameters:
info - the auto size information

getProperties

public java.util.Collection<Property> getProperties()
Gets the collection of properties contained in this bag.

Specified by:
getProperties in interface PropertyBag
Overrides:
getProperties in class AbstractSwtDataWidget
Returns:
The collection of properties contained in this bag. Implementors should make sure that this collection is unmodifiable.

setupDefaultSizeProperties

public void setupDefaultSizeProperties()
This method will setup the Height and Width properties that are stored for a widget - so that a subsequent call to getPropertyValue will return a non-null value. This would be called by apps such as the UI Designer, that display the properties to the user. This should only be called after the widget has been added to the DOM (e.g. added to its parent widget on the form) - because otherwise its height and width properties are not yet set in the DOM.

Specified by:
setupDefaultSizeProperties in interface Resizeable

setDefaultPropertyValue

protected boolean setDefaultPropertyValue(Property property,
                                          java.lang.Object newValue)
Sets the value of one of the wrapped widget's default properties.

Overrides:
setDefaultPropertyValue in class AbstractSwtDataWidget
Parameters:
property - The default property whose value is to be set.
newValue - The new value of the default property.
Returns:
True if the specified property is one of the default properties; otherwise false.

setupPropertyDefaultValues

protected void setupPropertyDefaultValues()
Stores the current value of the widget properties as the default values. This information is then used when saving the declarative layout to determine whether or not the user has changed the value of that property to something other than the default (if they haven't - then the property is not saved). If there is no default value for a property - and the user changes it to a non-null, non-blank value, then the property will be saved.

The "default value" concept is only applicable for those properties that have an initial (i.e. non-null, non-blank) value. This value can be set automatically by the DOM or by code within the widget.

Properties that are not set to an initial value by the DOM or GWT or the widget programmer, do not belong in this function.

For example: when a widget is first created in the DOM - it has an intrinsic value for the Enabled property (true). Therefore, the Enabled property has a default value of true. The Title property on the other hand does not have an initial value in the DOM - so it does not have a default value, and should not be included in this method.

Note: This function should be called immediately after your widget has been created and its initial properties have been set. Only properties that are not set by parameters in your widget's constructor should be specified here (i.e. optional properties).

Overrides:
setupPropertyDefaultValues in class AbstractSwtDataWidget

getDefaultProperties

protected static java.util.Collection<Property> getDefaultProperties()
Make it static so widgets can do static initializers of their properties (for efficiency).

Returns:
Collection of Property

setFormatError

public void setFormatError(boolean error)
Sets or removes the format error style ("formatError" style name).

Parameters:
error - true to set the style, false to remove it.

cancelKey

public void cancelKey()
If a keyboard event is currently being handled on this text box, calling this method will suppress it. This allows handlers to easily filter keyboard input.

Specified by:
cancelKey in interface BehavesAsTextBox

getCursorPos

public int getCursorPos()
Gets the current position of the cursor (this also serves as the beginning of the text selection).

Specified by:
getCursorPos in interface BehavesAsTextBox
Returns:
the cursor's position

getSelectedText

public java.lang.String getSelectedText()
Gets the text currently selected within this text box.

Specified by:
getSelectedText in interface BehavesAsTextBox
Returns:
the selected text, or an empty string if none is selected

getSelectionLength

public int getSelectionLength()
Gets the length of the current text selection.

Specified by:
getSelectionLength in interface BehavesAsTextBox
Returns:
the text selection length

selectAll

public void selectAll()
Selects all of the text in the box. This will only work when the widget is attached to the document.

Specified by:
selectAll in interface BehavesAsTextBox

setCursorPos

public void setCursorPos(int pos)
Sets the cursor position.

Specified by:
setCursorPos in interface BehavesAsTextBox
Parameters:
pos - the new cursor position

setSelectionRange

public void setSelectionRange(int pos,
                              int length)
Sets the range of text to be selected. This will only work when the widget is attached to the document.

Specified by:
setSelectionRange in interface BehavesAsTextBox
Parameters:
pos - the position of the first character to be selected
length - the number of characters to be selected

setTextAlignment

public void setTextAlignment(com.google.gwt.user.client.ui.ValueBoxBase.TextAlignment alignment)
Sets the alignment of the text in the text box.

Specified by:
setTextAlignment in interface BehavesAsTextBox
Parameters:
alignment - the text alignment (as specified by BehavesAsTextBox.ALIGN_CENTER, BehavesAsTextBox.ALIGN_JUSTIFY, BehavesAsTextBox.ALIGN_LEFT, and BehavesAsTextBox.ALIGN_RIGHT)

addClickHandler

public com.google.gwt.event.shared.HandlerRegistration addClickHandler(com.google.gwt.event.dom.client.ClickHandler handler)

Specified by:
addClickHandler in interface com.google.gwt.event.dom.client.HasClickHandlers

addFocusHandler

public com.google.gwt.event.shared.HandlerRegistration addFocusHandler(com.google.gwt.event.dom.client.FocusHandler handler)

Specified by:
addFocusHandler in interface com.google.gwt.event.dom.client.HasFocusHandlers

addBlurHandler

public com.google.gwt.event.shared.HandlerRegistration addBlurHandler(com.google.gwt.event.dom.client.BlurHandler handler)

Specified by:
addBlurHandler in interface com.google.gwt.event.dom.client.HasBlurHandlers

addBeforeFocusHandler

public com.google.gwt.event.shared.HandlerRegistration addBeforeFocusHandler(BeforeFocusHandler handler)
Adds a handler to receive BeforeFocus events.

Specified by:
addBeforeFocusHandler in interface HasCancellableFocusHandlers
Parameters:
handler - the handler
Returns:
the handler registration

getTabIndex

public int getTabIndex()

Specified by:
getTabIndex in interface com.google.gwt.user.client.ui.Focusable

setAccessKey

public void setAccessKey(char key)

Specified by:
setAccessKey in interface com.google.gwt.user.client.ui.Focusable

setFocus

public void setFocus(boolean focused)

Specified by:
setFocus in interface com.google.gwt.user.client.ui.Focusable

setTabIndex

public void setTabIndex(int index)

Specified by:
setTabIndex in interface com.google.gwt.user.client.ui.Focusable

addKeyPressHandler

public com.google.gwt.event.shared.HandlerRegistration addKeyPressHandler(com.google.gwt.event.dom.client.KeyPressHandler handler)

Specified by:
addKeyPressHandler in interface com.google.gwt.event.dom.client.HasKeyPressHandlers

addKeyDownHandler

public com.google.gwt.event.shared.HandlerRegistration addKeyDownHandler(com.google.gwt.event.dom.client.KeyDownHandler handler)

Specified by:
addKeyDownHandler in interface com.google.gwt.event.dom.client.HasKeyDownHandlers

addKeyUpHandler

public com.google.gwt.event.shared.HandlerRegistration addKeyUpHandler(com.google.gwt.event.dom.client.KeyUpHandler handler)

Specified by:
addKeyUpHandler in interface com.google.gwt.event.dom.client.HasKeyUpHandlers

onFocus

public void onFocus(com.google.gwt.event.dom.client.FocusEvent event)

Specified by:
onFocus in interface com.google.gwt.event.dom.client.FocusHandler

onBlur

public void onBlur(com.google.gwt.event.dom.client.BlurEvent event)
Specified by:
onBlur in interface com.google.gwt.event.dom.client.BlurHandler

getName

public java.lang.String getName()

Specified by:
getName in interface com.google.gwt.user.client.ui.HasName

setName

public void setName(java.lang.String name)

Specified by:
setName in interface com.google.gwt.user.client.ui.HasName

getText

public java.lang.String getText()
Get the text in the text box

Returns:
the text in the text box

setText

public void setText(java.lang.String text)
Set the text in the text box

Parameters:
text - the text in the text box

getHintText

public java.lang.String getHintText()
Get hint text

Specified by:
getHintText in interface HasHint
Returns:
The hint text of the widget.

setHintText

public void setHintText(java.lang.String hintText)
Set hint text

Specified by:
setHintText in interface HasHint
Parameters:
hintText - The hint text of the widget.


Copyright © 2011 Sage Software, Inc. All rights reserved.