org.vostok.vaadin.addon.button.spin
Class CalendarModel

java.lang.Object
  extended by org.vostok.vaadin.addon.button.spin.CalendarModel
All Implemented Interfaces:
com.vaadin.data.Property<java.util.Date>, java.io.Serializable, SpinButton.Editable<java.util.Date>, SpinButton.Model<java.util.Date>

public class CalendarModel
extends java.lang.Object
implements SpinButton.Model<java.util.Date>, SpinButton.Editable<java.util.Date>

A model to work on date / time.
though NumberModel can deal with date and time, this one provides finer control on date fields.

Since:
1.1 : implement SpinButton.Editable
Author:
levreau.jerome@vostoksystem.eu
See Also:
for format output, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.vaadin.data.Property
com.vaadin.data.Property.Editor, com.vaadin.data.Property.ReadOnlyException, com.vaadin.data.Property.ReadOnlyStatusChangeEvent, com.vaadin.data.Property.ReadOnlyStatusChangeListener, com.vaadin.data.Property.ReadOnlyStatusChangeNotifier, com.vaadin.data.Property.Transactional<T>, com.vaadin.data.Property.ValueChangeEvent, com.vaadin.data.Property.ValueChangeListener, com.vaadin.data.Property.ValueChangeNotifier, com.vaadin.data.Property.Viewer
 
Constructor Summary
CalendarModel(java.util.Calendar start)
          create a date model with no limit and a step of 1 day, default format to NumberModel.FORMAT_SIMPLEDATE
CalendarModel(java.util.Calendar start, java.util.Calendar max, java.util.Calendar min, int field, int step, java.lang.String format)
          create a new date model with boundaries
CalendarModel(java.util.Calendar start, int field, int step, java.lang.String format)
          create a date model increase of step on Calendar's field field
 
Method Summary
protected  java.lang.String format(java.util.Calendar value)
           
 com.vaadin.data.util.converter.Converter<java.lang.String,java.util.Date> getConverter()
          calendarModel provide converter support but not logic. return null, must be overrided
 java.lang.String getHint()
          return hint to dispay while in edition mode.
 java.lang.Object getRawValue()
          return value for GetValue return internal data, for exemple index x while getRawValue return the actual value y for index x
 java.lang.Class<? extends java.util.Date> getType()
           
 java.util.Date getValue()
           
 java.util.Date init()
          Called from contructor
 boolean isReadOnly()
           
 java.util.Date next()
          return next value but do not set current one.
 java.util.Date prev()
          return previous value but do not set current one.
 void setLocale(java.util.Locale locale)
          Locale for toObject formating.
 void setReadOnly(boolean newStatus)
           
 void setValue(java.util.Date newValue)
           
 java.lang.Object toObject()
          return a human formated representation of the current value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CalendarModel

public CalendarModel(java.util.Calendar start)
create a date model with no limit and a step of 1 day, default format to NumberModel.FORMAT_SIMPLEDATE

Parameters:
start - starting date
See Also:
NumberModel

CalendarModel

public CalendarModel(java.util.Calendar start,
                     int field,
                     int step,
                     java.lang.String format)
create a date model increase of step on Calendar's field field

Parameters:
start - starting date
field - Calendar field as Calendar fields
step - step into field
format - output fomat, can be null. can use format from numberModel
See Also:
NumberModel, Calendar

CalendarModel

public CalendarModel(java.util.Calendar start,
                     java.util.Calendar max,
                     java.util.Calendar min,
                     int field,
                     int step,
                     java.lang.String format)
create a new date model with boundaries

Parameters:
start - starting date
max - maximum allowed date, null for none
min - minium allowed data, null for none
field - Calendar field as Calendar fields
step - step into field
format - output fomat, can be null. can use format from numberModel
See Also:
NumberModel, Calendar
Method Detail

setLocale

public void setLocale(java.util.Locale locale)
Locale for toObject formating. Default to user's locale

Parameters:
locale -

init

public java.util.Date init()
Description copied from interface: SpinButton.Model
Called from contructor

Specified by:
init in interface SpinButton.Model<java.util.Date>
Returns:
initial value .

next

public java.util.Date next()
Description copied from interface: SpinButton.Model
return next value but do not set current one.

Specified by:
next in interface SpinButton.Model<java.util.Date>
Returns:
next valid value or null if none

prev

public java.util.Date prev()
Description copied from interface: SpinButton.Model
return previous value but do not set current one.

Specified by:
prev in interface SpinButton.Model<java.util.Date>
Returns:
previous value or null if none

format

protected java.lang.String format(java.util.Calendar value)
Parameters:
value -
Returns:
String date formated according to locale

getValue

public java.util.Date getValue()
Specified by:
getValue in interface com.vaadin.data.Property<java.util.Date>

setValue

public void setValue(java.util.Date newValue)
              throws com.vaadin.data.Property.ReadOnlyException
Specified by:
setValue in interface com.vaadin.data.Property<java.util.Date>
Throws:
com.vaadin.data.Property.ReadOnlyException

getType

public java.lang.Class<? extends java.util.Date> getType()
Specified by:
getType in interface com.vaadin.data.Property<java.util.Date>

isReadOnly

public boolean isReadOnly()
Specified by:
isReadOnly in interface com.vaadin.data.Property<java.util.Date>

setReadOnly

public void setReadOnly(boolean newStatus)
Specified by:
setReadOnly in interface com.vaadin.data.Property<java.util.Date>

toObject

public java.lang.Object toObject()
Description copied from interface: SpinButton.Model
return a human formated representation of the current value.

Specified by:
toObject in interface SpinButton.Model<java.util.Date>
Returns:
Component to direclty pack or String which will be display as a TextField through toString() method

getRawValue

public java.lang.Object getRawValue()
Description copied from interface: SpinButton.Model
return value for GetValue return internal data, for exemple index x while getRawValue return the actual value y for index x

Specified by:
getRawValue in interface SpinButton.Model<java.util.Date>
Returns:
raw value from model

getConverter

public com.vaadin.data.util.converter.Converter<java.lang.String,java.util.Date> getConverter()
calendarModel provide converter support but not logic. return null, must be overrided

Specified by:
getConverter in interface SpinButton.Editable<java.util.Date>
Returns:
nullalways null. Must be overrided
Since:
1.1

getHint

public java.lang.String getHint()
Description copied from interface: SpinButton.Editable
return hint to dispay while in edition mode.

Specified by:
getHint in interface SpinButton.Editable<java.util.Date>
Returns:
Since:
1.1