Package muntjac :: Package ui :: Module abstract_text_field :: Class AbstractTextField
[hide private]
[frames] | no frames]

Class AbstractTextField

source code

                            object --+                    
                                     |                    
                   util.IEventListener --+                
                                         |                
             terminal.paintable.IPaintable --+            
                                             |            
                                object --+   |            
                                         |   |            
    terminal.variable_owner.IVariableOwner --+            
                                             |            
                                object --+   |            
                                         |   |            
               terminal.sizeable.ISizeable --+            
                                             |            
                          component.IComponent --+        
                                                 |        
                                    object --+   |        
                                             |   |        
  event.method_event_source.IMethodEventSource --+        
                                                 |        
              abstract_component.AbstractComponent --+    
                                                     |    
                                object --+           |    
                                         |           |    
                   data.buffered.IBuffered --+       |    
                                             |       |    
                                object --+   |       |    
                                         |   |       |    
             data.validatable.IValidatable --+       |    
                                             |       |    
            data.buffered.IBufferedValidatable --+   |    
                                                 |   |    
                                    object --+   |   |    
                                             |   |   |    
            data.property.IValueChangeNotifier --+   |    
                                                 |   |    
                                    object --+   |   |    
                                             |   |   |    
            data.property.IValueChangeListener --+   |    
                                                 |   |    
                                object --+       |   |    
                                         |       |   |    
                     data.property.IViewer --+   |   |    
                                             |   |   |    
                         data.property.IEditor --+   |    
                                                 |   |    
                        object --+               |   |    
                                 |               |   |    
               util.IEventListener --+           |   |    
                                     |           |   |    
         terminal.paintable.IPaintable --+       |   |    
                                         |       |   |    
                            object --+   |       |   |    
                                     |   |       |   |    
terminal.variable_owner.IVariableOwner --+       |   |    
                                         |       |   |    
                            object --+   |       |   |    
                                     |   |       |   |    
           terminal.sizeable.ISizeable --+       |   |    
                                         |       |   |    
                      component.IComponent --+   |   |    
                                             |   |   |    
                          component.IFocusable --+   |    
                                                 |   |    
                                      field.IField --+    
                                                     |    
                                        object --+   |    
                                                 |   |    
                    event.action.IShortcutNotifier --+    
                                                     |    
                                        object --+   |    
                                                 |   |    
       data.property.IReadOnlyStatusChangeNotifier --+    
                                                     |    
                                        object --+   |    
                                                 |   |    
       data.property.IReadOnlyStatusChangeListener --+    
                                                     |    
                          abstract_field.AbstractField --+
                                                         |
                                            object --+   |
                                                     |   |
                      event.field_events.IBlurNotifier --+
                                                         |
                                            object --+   |
                                                     |   |
                     event.field_events.IFocusNotifier --+
                                                         |
                                            object --+   |
                                                     |   |
                event.field_events.ITextChangeNotifier --+
                                                         |
                                                        AbstractTextField
Known Subclasses:

Instance Methods [hide private]
 
__init__(self)
Constructs a new IComponent.
source code
 
paintContent(self, target)
Paints any needed component-specific things to the given UIDL stream.
source code
 
getFormattedValue(self)
Gets the formatted string value.
source code
 
getValue(self)
Gets the current value of the field.
source code
 
changeVariables(self, source, variables)
Called when one or more variables handled by the implementing class are changed.
source code
 
getType(self) source code
 
getNullRepresentation(self)
Gets the null-string representation.
source code
 
isNullSettingAllowed(self)
Is setting nulls with null-string representation allowed.
source code
 
setNullRepresentation(self, nullRepresentation)
Sets the null-string representation.
source code
 
setNullSettingAllowed(self, nullSettingAllowed)
Sets the null conversion mode.
source code
 
getFormat(self)
Gets the value formatter of TextField.
source code
 
setFormat(self, fmt)
Gets the value formatter of TextField.
source code
 
isEmpty(self)
Is the field empty?
source code
 
getMaxLength(self)
Returns the maximum number of characters in the field.
source code
 
setMaxLength(self, maxLength)
Sets the maximum number of characters in the field.
source code
 
getColumns(self)
Gets the number of columns in the editor.
source code
 
setColumns(self, columns)
Sets the number of columns in the editor.
source code
 
getInputPrompt(self)
Gets the current input prompt.
source code
 
setInputPrompt(self, inputPrompt)
Sets the input prompt - a textual prompt that is displayed when the field would otherwise be empty, to prompt the user for input.
source code
 
firePendingTextChangeEvent(self) source code
 
setInternalValue(self, newValue)
Sets the internal field value.
source code
 
setValue(self, newValue, repaintIsNotNeeded=None)
Sets the value of the field.
source code
 
handleInputEventTextChange(self, variables) source code
 
setTextChangeEventMode(self, inputEventMode)
Sets the mode how the TextField triggers TextChangeEvents.
source code
 
getTextChangeEventMode(self)
Returns: the mode used to trigger TextChangeEvents.
source code
 
addListener(self, listener, iface=None)
Registers a new (generic) component event listener for the component:
source code
 
addCallback(self, callback, eventType=None, *args) source code
 
removeListener(self, listener, iface=None)
Removes a previously registered component event listener from this component.
source code
 
removeCallback(self, callback, eventType=None) source code
 
setTextChangeTimeout(self, timeout)
The text change timeout modifies how often text change events are communicated to the application when getTextChangeEventMode is TextChangeEventMode.LAZY or TextChangeEventMode.TIMEOUT.
source code
 
getTextChangeTimeout(self)
Gets the timeout used to fire TextChangeEvents when the getTextChangeEventMode is TextChangeEventMode.LAZY or TextChangeEventMode.TIMEOUT.
source code
 
getCurrentTextContent(self)
Gets the current (or the last known) text content in the field.
source code
 
selectAll(self)
Selects all text in the field.
source code
 
setSelectionRange(self, pos, length)
Sets the range of text to be selected.
source code
 
setCursorPosition(self, pos)
Sets the cursor position in the field.
source code
 
getCursorPosition(self)
Returns the last known cursor position of the field.
source code

Inherited from abstract_field.AbstractField: __str__, addShortcutListener, addValidator, attach, commit, detach, discard, fireReadOnlyStatusChange, fireValueChange, focus, getActionManager, getErrorMessage, getPropertyDataSource, getRequiredError, getTabIndex, getValidators, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isReadThrough, isRequired, isValid, isValidationVisible, isWriteThrough, readOnlyStatusChange, readValueFromProperty, removeShortcutListener, removeValidator, setCurrentBufferedSourceException, setInvalidAllowed, setInvalidCommitted, setPropertyDataSource, setReadOnly, setReadThrough, setRequired, setRequiredError, setTabIndex, setValidationVisible, setWriteThrough, shouldHideErrors, validate, valueChange

Inherited from abstract_component.AbstractComponent: __getstate__, __setstate__, addStyleName, childRequestedRepaint, fireComponentErrorEvent, fireComponentEvent, fireEvent, fireRequestRepaintEvent, getApplication, getCSSHeight, getCSSWidth, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getHeight, getHeightUnits, getIcon, getListeners, getLocale, getParent, getStyle, getStyleName, getWidth, getWidthUnits, getWindow, handleError, hasListeners, isEnabled, isImmediate, isVisible, paint, parseStringSize, registerCallback, registerListener, removeStyleName, requestRepaint, requestRepaintRequests, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setErrorHandler, setHeight, setHeightUnits, setIcon, setImmediate, setLocale, setParent, setSizeFull, setSizeUndefined, setStyle, setStyleName, setVisible, setWidth, setWidthUnits, withdrawCallback, withdrawListener

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Class Methods [hide private]

Inherited from abstract_field.AbstractField: constructField

Class Variables [hide private]

Inherited from abstract_component.AbstractComponent: SIZE_PATTERN

Inherited from terminal.sizeable.ISizeable: SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS, UNIT_SYMBOLS

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self)
(Constructor)

source code 

Constructs a new IComponent.

Overrides: object.__init__
(inherited documentation)

paintContent(self, target)

source code 

Paints any needed component-specific things to the given UIDL stream. The more general paint method handles all general attributes common to all components, and it calls this method to paint any component-specific attributes to the UIDL stream.

Parameters:
  • target - the target UIDL stream where the component should paint itself to
Raises:
Overrides: abstract_component.AbstractComponent.paintContent
(inherited documentation)

getFormattedValue(self)

source code 

Gets the formatted string value. Sets the field value by using the assigned format.

Returns:
the Formatted value.

See Also: setFormat

Deprecated:  

getValue(self)

source code 

Gets the current value of the field.

This is the visible, modified and possible invalid value the user have entered to the field. In the read-through mode, the abstract buffer is also updated and validation is performed.

Note that the object returned is compatible with getType(). For example, if the type is String, this returns Strings even when the underlying datasource is of some other type. In order to access the datasources native type, use getPropertyDatasource().getValue() instead.

Note that when you extend AbstractField, you must reimplement this method if datasource.getValue() is not assignable to class returned by getType() AND getType() is not String. In case of Strings, getValue() calls datasource.toString() instead of datasource.getValue().

Returns:
the current value of the field.
Overrides: abstract_field.AbstractField.getValue
(inherited documentation)

changeVariables(self, source, variables)

source code 

Called when one or more variables handled by the implementing class are changed.

Parameters:
  • source - the Source of the variable change. This is the origin of the event. For example in Web Adapter this is the request.
  • variables - the Mapping from variable names to new variable values.
Overrides: terminal.variable_owner.IVariableOwner.changeVariables
(inherited documentation)

getType(self)

source code 
Overrides: abstract_field.AbstractField.getType

getNullRepresentation(self)

source code 

Gets the null-string representation.

The null-valued strings are represented on the user interface by replacing the null value with this string. If the null representation is set null (not 'null' string), painting null value throws exception.

The default value is string 'null'.

Returns:
the textual string representation for null strings.

See Also: TextField.isNullSettingAllowed

isNullSettingAllowed(self)

source code 

Is setting nulls with null-string representation allowed.

If this property is true, writing null-representation string to text field always sets the field value to real null. If this property is false, null setting is not made, but the null values are maintained. Maintenance of null-values is made by only converting the textfield contents to real null, if the text field matches the null-string representation and the current value of the field is null.

By default this setting is false

Returns:
Should the null-string represenation be always converted to null-values.

See Also: TextField.getNullRepresentation

setNullRepresentation(self, nullRepresentation)

source code 

Sets the null-string representation.

The null-valued strings are represented on the user interface by replacing the null value with this string. If the null representation is set null (not 'null' string), painting null value throws exception.

The default value is string 'null'

Parameters:
  • nullRepresentation - Textual representation for null strings.

See Also: TextField.setNullSettingAllowed

setNullSettingAllowed(self, nullSettingAllowed)

source code 

Sets the null conversion mode.

If this property is true, writing null-representation string to text field always sets the field value to real null. If this property is false, null setting is not made, but the null values are maintained. Maintenance of null-values is made by only converting the textfield contents to real null, if the text field matches the null-string representation and the current value of the field is null.

By default this setting is false.

Parameters:
  • nullSettingAllowed - Should the null-string representation always be converted to null-values.

See Also: TextField.getNullRepresentation

getFormat(self)

source code 

Gets the value formatter of TextField.

Returns:
the format used to format the value.

Deprecated: replaced by PropertyFormatter

setFormat(self, fmt)

source code 

Gets the value formatter of TextField.

Parameters:
  • fmt - the Format used to format the value. Null disables the formatting.

Deprecated: replaced by PropertyFormatter

isEmpty(self)

source code 

Is the field empty?

In general, "empty" state is same as null. As an exception, TextField also treats empty string as "empty".

Overrides: abstract_field.AbstractField.isEmpty
(inherited documentation)

getMaxLength(self)

source code 

Returns the maximum number of characters in the field. Value -1 is considered unlimited. Terminal may however have some technical limits.

Returns:
the maxLength

setMaxLength(self, maxLength)

source code 

Sets the maximum number of characters in the field. Value -1 is considered unlimited. Terminal may however have some technical limits.

Parameters:
  • maxLength - the maxLength to set

getColumns(self)

source code 

Gets the number of columns in the editor. If the number of columns is set 0, the actual number of displayed columns is determined implicitly by the adapter.

Returns:
the number of columns in the editor.

setColumns(self, columns)

source code 

Sets the number of columns in the editor. If the number of columns is set 0, the actual number of displayed columns is determined implicitly by the adapter.

Parameters:
  • columns - the number of columns to set.

getInputPrompt(self)

source code 

Gets the current input prompt.

Returns:
the current input prompt, or null if not enabled

See Also: setInputPrompt

setInternalValue(self, newValue)

source code 

Sets the internal field value. This is purely used by AbstractField to change the internal IField value. It does not trigger valuechange events. It can be overridden by the inheriting classes to update all dependent variables.

Parameters:
  • newValue - the new value to be set.
Overrides: abstract_field.AbstractField.setInternalValue
(inherited documentation)

setValue(self, newValue, repaintIsNotNeeded=None)

source code 

Sets the value of the field.

Parameters:
  • newValue - the new value of the field.
  • repaintIsNotNeeded - True iff caller is sure that repaint is not needed.
Raises:
Overrides: abstract_field.AbstractField.setValue
(inherited documentation)

setTextChangeEventMode(self, inputEventMode)

source code 

Sets the mode how the TextField triggers TextChangeEvents.

Parameters:
  • inputEventMode - the new mode

getTextChangeEventMode(self)

source code 
Returns:
the mode used to trigger TextChangeEvents.

addListener(self, listener, iface=None)

source code 

Registers a new (generic) component event listener for the component:

 class Listening(CustomComponent, IListener):

     # Stored for determining the source of an event
     ok = None

     status = None  # For displaying info about the event

     def __init__(self):
         layout = VerticalLayout()

         # Some miscellaneous component
         name = TextField("Say it all here")
         name.addListener(self)
         name.setImmediate(true)
         layout.addComponent(name)

         # Handle button clicks as generic events instead
         # of Button.ClickEvent events
         ok = new Button("OK")
         ok.addListener(self)
         layout.addComponent(ok)

         # For displaying information about an event
         status = new Label("")
         layout.addComponent(status)

         setCompositionRoot(layout)


     def componentEvent(event):
         # Act according to the source of the event
         if (event.getSource() == ok):
             getWindow().showNotification("Click!")

         status.setValue("Event from " +
                 event.getSource().__class__.__name__
                 + ": " + event.__class__.__name__)


 listening = Listening()
 layout.addComponent(listening)
Parameters:
  • listener - the new IListener to be registered.
Raises:
  • ValueError - unless method has a match in object
Overrides: event.field_events.ITextChangeNotifier.addListener

addCallback(self, callback, eventType=None, *args)

source code 
Overrides: event.field_events.ITextChangeNotifier.addCallback

removeListener(self, listener, iface=None)

source code 

Removes a previously registered component event listener from this component.

Parameters:
  • listener - the listener to be removed.
Overrides: event.field_events.ITextChangeNotifier.removeListener

removeCallback(self, callback, eventType=None)

source code 
Overrides: event.field_events.ITextChangeNotifier.removeCallback

setTextChangeTimeout(self, timeout)

source code 

The text change timeout modifies how often text change events are communicated to the application when getTextChangeEventMode is TextChangeEventMode.LAZY or TextChangeEventMode.TIMEOUT.

Parameters:
  • timeout - the timeout in milliseconds

getTextChangeTimeout(self)

source code 

Gets the timeout used to fire TextChangeEvents when the getTextChangeEventMode is TextChangeEventMode.LAZY or TextChangeEventMode.TIMEOUT.

Returns:
the timeout value in milliseconds

getCurrentTextContent(self)

source code 

Gets the current (or the last known) text content in the field.

Note the text returned by this method is not necessary the same that is returned by the getValue method. The value is updated when the terminal fires a value change event via e.g. blurring the field or by pressing enter. The value returned by this method is updated also on TextChangeEvents. Due to this high dependency to the terminal implementation this method is (at least at this point) not published.

Returns:
the text which is currently displayed in the field.

setSelectionRange(self, pos, length)

source code 

Sets the range of text to be selected.

As a side effect the field will become focused.

Parameters:
  • pos - the position of the first character to be selected
  • length - the number of characters to be selected

setCursorPosition(self, pos)

source code 

Sets the cursor position in the field. As a side effect the field will become focused.

Parameters:
  • pos - the position for the cursor

getCursorPosition(self)

source code 

Returns the last known cursor position of the field.

Note that due to the client server nature or the GWT terminal, Muntjac cannot provide the exact value of the cursor position in most situations. The value is updated only when the client side terminal communicates to TextField, like on ValueChangeEvents and TextChangeEvents. This may change later if a deep push integration is built to Muntjac.

Returns:
the cursor position