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

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

public class ListModel
extends java.lang.Object
implements SpinButton.Model<java.lang.Integer>, SpinButton.Editable<java.lang.Integer>

a model to display list of items.
Value refers to index into the list.
getValue / setValue refers to list's index, getRawValue refers to list[value], toObject refers to list[value]. You can retur n your own return object by overriding toObject method.

Author:
levreau.jerome@vostoksystem.eu
See Also:
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
ListModel(java.lang.Object[] list)
          create a new list model with index = 0 and loop = true
ListModel(java.lang.Object[] list, int start, boolean loop)
          create a new list model.
 
Method Summary
 com.vaadin.data.util.converter.Converter<java.lang.String,java.lang.Integer> getConverter()
          ListModel 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.lang.Integer> getType()
           
 java.lang.Integer getValue()
           
 java.lang.Integer init()
          Called from contructor
 boolean isReadOnly()
           
 java.lang.Integer next()
          return next value but do not set current one.
 java.lang.Integer prev()
          return previous value but do not set current one.
 void setReadOnly(boolean newStatus)
           
 void setValue(java.lang.Integer 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

ListModel

public ListModel(java.lang.Object[] list,
                 int start,
                 boolean loop)
          throws java.lang.Exception
create a new list model.

Parameters:
list - list of item to display ; cannot be null
start - start index ; must be lower than list.length and at least 0
loop - true if must loop through data, false to stop at boundaries
Throws:
java.lang.Exception - on bad argument

ListModel

public ListModel(java.lang.Object[] list)
          throws java.lang.Exception
create a new list model with index = 0 and loop = true

Parameters:
list -
Throws:
java.lang.Exception
Method Detail

init

public java.lang.Integer init()
Description copied from interface: SpinButton.Model
Called from contructor

Specified by:
init in interface SpinButton.Model<java.lang.Integer>
Returns:
initial value .

next

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

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

prev

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

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

getValue

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

setValue

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

getType

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

isReadOnly

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

setReadOnly

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

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.lang.Integer>
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.lang.Integer>
Returns:
raw value from model

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.lang.Integer>
Returns:
Since:
1.1

getConverter

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

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