Package muntjac :: Package ui :: Module date_field :: Class DateField
[hide private]
[frames] | no frames]

Class DateField

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 --+
                                                         |
                                                        DateField

A date editor component that can be bound to any IProperty that is compatible with datetime.

Since DateField extends AbstractField it implements the IBuffered interface.

A DateField is in write-through mode by default, so AbstractField.setWriteThrough must be called to enable buffering.


Authors:
Vaadin Ltd., Richard Lincoln

Version: 1.1.2

Instance Methods [hide private]
 
__init__(self, *args)
Constructs an new DateField.
source code
 
__getstate__(self) source code
 
__setstate__(self, d) source code
 
paintContent(self, target)
Paints any needed component-specific things to the given UIDL stream.
source code
 
shouldHideErrors(self)
Returns true if the error indicator be hidden when painting the component even when there are errors.
source code
 
changeVariables(self, source, variables)
Called when one or more variables handled by the implementing class are changed.
source code
 
handleUnparsableDateString(self, dateString)
This method is called to handle a non-empty date string from the client if the client could not parse it as a datetime.
source code
 
getType(self) source code
 
setValue(self, newValue, repaintIsNotNeeded=False)
Sets the value of the field.
source code
 
notifyFormOfValidityChange(self)
Detects if this field is used in a Form (logically) and if so, notifies it (by repainting it) that the validity of this field might have changed.
source code
 
setPropertyDataSource(self, newDataSource)
Sets the DateField datasource.
source code
 
setInternalValue(self, newValue)
Sets the internal field value.
source code
 
getResolution(self)
Gets the resolution.
source code
 
setResolution(self, resolution)
Sets the resolution of the DateField.
source code
 
getCalendar(self)
Returns new instance calendar used in Date conversions.
source code
 
setDateFormat(self, dateFormat)
Sets formatting used by some component implementations.
source code
 
getDateFormat(self)
Returns a format string used to format date value on client side or null if default formatting from IComponent.getLocale is used.
source code
 
setLenient(self, lenient)
Specifies whether or not date/time interpretation in component is to be lenient.
source code
 
isLenient(self)
Returns whether date/time interpretation is to be lenient.
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
 
isShowISOWeekNumbers(self)
Checks whether ISO 8601 week numbers are shown in the date selector.
source code
 
setShowISOWeekNumbers(self, showWeekNumbers)
Sets the visibility of ISO 8601 week numbers in the date selector.
source code
 
isValid(self)
Tests the current value against registered validators if the field is not empty.
source code
 
validate(self)
Checks the validity of the IValidatable by validating the field with all attached validators except when the field is empty.
source code
 
getParseErrorMessage(self)
Return the error message that is shown if the user inputted value can't be parsed into a datetime object.
source code
 
setParseErrorMessage(self, parsingErrorMessage)
Sets the default error message used if the DateField cannot parse the text input by user to a datetime field.
source code
 
setTimeZone(self, timeZone)
Sets the time zone used by this date field.
source code
 
getTimeZone(self)
Gets the time zone used by this field.
source code

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

Inherited from abstract_component.AbstractComponent: 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]
  CLIENT_WIDGET = None
hash(x)
  RESOLUTION_MSEC = 0
  RESOLUTION_SEC = 1
  RESOLUTION_MIN = 2
  RESOLUTION_HOUR = 3
  RESOLUTION_DAY = 4
  RESOLUTION_MONTH = 5
  RESOLUTION_YEAR = 6
  _largestModifiable = 6

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, *args)
(Constructor)

source code 

Constructs an new DateField.

Parameters:
  • args - tuple of the form
    • ()
    • (caption)
      1. the caption of the datefield.
    • (caption, dataSource)
      1. the caption string for the editor.
      2. the IProperty to be edited with this editor.
    • (dataSource)
      1. the IProperty to be edited with this editor.
    • (caption, value)
      1. the caption string for the editor.
      2. the date value.
Overrides: object.__init__

__getstate__(self)

source code 
Overrides: abstract_component.AbstractComponent.__getstate__

__setstate__(self, d)

source code 
Overrides: abstract_component.AbstractComponent.__setstate__

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)

shouldHideErrors(self)

source code 

Returns true if the error indicator be hidden when painting the component even when there are errors.

This is a mostly internal method, but can be overridden in subclasses e.g. if the error indicator should also be shown for empty fields in some cases.

Returns:
true to hide the error indicator, false to use the normal logic to show it when there are errors
Overrides: abstract_field.AbstractField.shouldHideErrors
(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)

handleUnparsableDateString(self, dateString)

source code 

This method is called to handle a non-empty date string from the client if the client could not parse it as a datetime.

By default, a ConversionException is thrown, and the current value is not modified.

This can be overridden to handle conversions, to return null (equivalent to empty input), to throw an exception or to fire an event.

Raises:

getType(self)

source code 
Overrides: abstract_field.AbstractField.getType

setValue(self, newValue, repaintIsNotNeeded=False)

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)

setPropertyDataSource(self, newDataSource)

source code 

Sets the DateField datasource. Datasource type must assignable to Date.

Parameters:
  • newDataSource - the new data source property.
Overrides: data.property.IViewer.setPropertyDataSource

See Also: Viewer.setPropertyDataSource

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)

setResolution(self, resolution)

source code 

Sets the resolution of the DateField.

Parameters:
  • resolution - the resolution to set.

getCalendar(self)

source code 

Returns new instance calendar used in Date conversions.

Returns new clone of the calendar object initialized using the the current date (if available)

If this is no calendar is assigned the calendar is used.

Returns:
the calendar

See Also: setCalendar

setDateFormat(self, dateFormat)

source code 

Sets formatting used by some component implementations.

By default it is encouraged to used default formatting defined by Locale.

Parameters:
  • dateFormat - the dateFormat to set

See Also: AbstractComponent.setLocale

getDateFormat(self)

source code 

Returns a format string used to format date value on client side or null if default formatting from IComponent.getLocale is used.

Returns:
the dateFormat

setLenient(self, lenient)

source code 

Specifies whether or not date/time interpretation in component is to be lenient.

Parameters:
  • lenient - true if the lenient mode is to be turned on; false if it is to be turned off.

See Also: isLenient

isLenient(self)

source code 

Returns whether date/time interpretation is to be lenient.

Returns:
true if the interpretation mode of this calendar is lenient; false otherwise.

See Also: setLenient

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.IFocusNotifier.addListener
(inherited documentation)

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

source code 
Overrides: event.field_events.IFocusNotifier.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.IFocusNotifier.removeListener
(inherited documentation)

removeCallback(self, callback, eventType=None)

source code 
Overrides: event.field_events.IFocusNotifier.removeCallback

isShowISOWeekNumbers(self)

source code 

Checks whether ISO 8601 week numbers are shown in the date selector.

Returns:
true if week numbers are shown, false otherwise.

setShowISOWeekNumbers(self, showWeekNumbers)

source code 

Sets the visibility of ISO 8601 week numbers in the date selector. ISO 8601 defines that a week always starts with a Monday so the week numbers are only shown if this is the case.

Parameters:
  • showWeekNumbers - true if week numbers should be shown, false otherwise.

isValid(self)

source code 

Tests the current value against registered validators if the field is not empty. Note that DateField is considered empty (value == null) and invalid if it contains text typed in by the user that couldn't be parsed into a Date value.

Returns:
True if all registered validators claim that the current value is valid or if the field is empty and not required, False otherwise.
Overrides: data.validatable.IValidatable.isValid

See Also: AbstractField.isValid

validate(self)

source code 

Checks the validity of the IValidatable by validating the field with all attached validators except when the field is empty. An empty field is invalid if it is required and valid otherwise.

The "required" validation is a built-in validation feature. If the field is required, but empty, validation will throw an EmptyValueException with the error message set with setRequiredError().

Raises:
Overrides: data.validatable.IValidatable.validate
(inherited documentation)

getParseErrorMessage(self)

source code 

Return the error message that is shown if the user inputted value can't be parsed into a datetime object. If handleUnparsableDateString is overridden and it throws a custom exception, the message returned by Exception.message will be used instead of the value returned by this method.

Returns:
the error message that the DateField uses when it can't parse the textual input from user to a Date object

setParseErrorMessage(self, parsingErrorMessage)

source code 

Sets the default error message used if the DateField cannot parse the text input by user to a datetime field. Note that if the handleUnparsableDateString method is overridden, the localized message from its exception is used.

setTimeZone(self, timeZone)

source code 

Sets the time zone used by this date field. The time zone is used to convert the absolute time in a Date object to a logical time displayed in the selector and to convert the select time back to a datetime object.

If no time zone has been set, the current default time zone returned by TimeZone.getDefault() is used.

@see getTimeZone()

Parameters:
  • timeZone - the time zone to use for time calculations.

getTimeZone(self)

source code 

Gets the time zone used by this field. The time zone is used to convert the absolute time in a Date object to a logical time displayed in the selector and to convert the select time back to a datetime object.

If {@code null} is returned, the current default time zone returned by TimeZone.getDefault() is used.

Returns:
the current time zone