com.vaadin.ui.components.grid
Class EditorRow

java.lang.Object
  extended by com.vaadin.ui.components.grid.EditorRow
All Implemented Interfaces:
java.io.Serializable

public class EditorRow
extends java.lang.Object
implements java.io.Serializable

A class for configuring the editor row in a grid.

Since:
Author:
Vaadin Ltd
See Also:
Grid, Serialized Form

Method Summary
 void bind(java.lang.Object propertyId, Field<?> field)
          Binds the field with the given propertyId from the current item.
<T extends Field<?>>
T
buildAndBind(java.lang.Object propertyId, java.lang.Class<T> fieldComponent)
          Builds a field using the given caption and binds it to the given property id using the field binder.
 void cancel()
          Cancels the currently active edit if any.
 void commit()
          Commits all changes done to the bound fields.
 void discard()
          Discards all changes done to the bound fields.
 void editItem(java.lang.Object itemId)
          Sets an item as editable.
 java.lang.Object getEditedItemId()
          Gets the id of the item that is currently being edited.
 Field<?> getField(java.lang.Object propertyId)
          Gets the field component that represents a property.
 FieldGroup getFieldGroup()
          Gets the field group that is backing this editor row.
protected  void internalCancel()
           
protected  void internalEditItem(java.lang.Object itemId)
           
 boolean isEditing()
          Returns whether this editor row is currently editing an item.
 boolean isEnabled()
          Checks whether the editor row feature is enabled for the grid or not.
 boolean isPropertyEditable(java.lang.Object propertyId)
          Checks whether a property is uneditable or not.
 void setEnabled(boolean isEnabled)
          Sets whether or not the editor row feature is enabled for the grid.
 void setFieldFactory(FieldGroupFieldFactory factory)
          Sets the field factory for the FieldGroup.
 void setFieldGroup(FieldGroup fieldGroup)
          Sets the field group that is backing this editor row.
 void setPropertyEditable(java.lang.Object propertyId, boolean editable)
          Sets a property editable or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isEnabled

public boolean isEnabled()
Checks whether the editor row feature is enabled for the grid or not.

Returns:
true iff the editor row feature is enabled for the grid
See Also:
getEditedItemId()

setEnabled

public void setEnabled(boolean isEnabled)
                throws java.lang.IllegalStateException
Sets whether or not the editor row feature is enabled for the grid.

Parameters:
isEnabled - true to enable the feature, false otherwise
Throws:
java.lang.IllegalStateException - if an item is currently being edited
See Also:
getEditedItemId()

getFieldGroup

public FieldGroup getFieldGroup()
Gets the field group that is backing this editor row.

Returns:
the backing field group

setFieldGroup

public void setFieldGroup(FieldGroup fieldGroup)
Sets the field group that is backing this editor row.

Parameters:
fieldGroup - the backing field group

buildAndBind

public <T extends Field<?>> T buildAndBind(java.lang.Object propertyId,
                                           java.lang.Class<T> fieldComponent)
                                throws FieldGroup.BindException
Builds a field using the given caption and binds it to the given property id using the field binder. Ensures the new field is of the given type.

Note: This is a pass-through call to the backing field group.

Parameters:
propertyId - The property id to bind to. Must be present in the field finder
fieldType - The type of field that we want to create
Returns:
The created and bound field. Can be any type of Field.
Throws:
FieldGroup.BindException - If the field could not be created

bind

public void bind(java.lang.Object propertyId,
                 Field<?> field)
          throws FieldGroup.BindException
Binds the field with the given propertyId from the current item. If an item has not been set then the binding is postponed until the item is set using editItem(Object).

This method also adds validators when applicable.

Note: This is a pass-through call to the backing field group.

Parameters:
field - The field to bind
propertyId - The propertyId to bind to the field
Throws:
FieldGroup.BindException - If the property id is already bound to another field by this field binder

setFieldFactory

public void setFieldFactory(FieldGroupFieldFactory factory)
Sets the field factory for the FieldGroup. The field factory is only used when FieldGroup creates a new field.

Note: This is a pass-through call to the backing field group.

Parameters:
fieldFactory - The field factory to use

getField

public Field<?> getField(java.lang.Object propertyId)
Gets the field component that represents a property. If the property is not yet bound to a field, null is returned.

When editItem is called, fields are automatically created and bound to any unbound properties.

Parameters:
propertyId - the property id of the property for which to find the field
Returns:
the bound field or null if not bound
See Also:
#setPropertyUneditable(Object)

setPropertyEditable

public void setPropertyEditable(java.lang.Object propertyId,
                                boolean editable)
Sets a property editable or not.

In order for a user to edit a particular value with a Field, it needs to be both non-readonly and editable.

The difference between read-only and uneditable is that the read-only state is propagated back into the property, while the editable property is internal metadata for the editor row.

Parameters:
propertyId - the id of the property to set as editable state
editable - whether or not propertyId chould be editable

isPropertyEditable

public boolean isPropertyEditable(java.lang.Object propertyId)
Checks whether a property is uneditable or not.

This only checks whether the property is configured as uneditable in this editor row. The property's or field's readonly status will ultimately decide whether the value can be edited or not.

Parameters:
propertyId - the id of the property to check for editable status
Returns:
true iff the property is editable according to this editor row

commit

public void commit()
            throws FieldGroup.CommitException
Commits all changes done to the bound fields.

Note: This is a pass-through call to the backing field group.

Throws:
FieldGroup.CommitException - If the commit was aborted

discard

public void discard()
Discards all changes done to the bound fields.

Note: This is a pass-through call to the backing field group.


editItem

public void editItem(java.lang.Object itemId)
              throws java.lang.IllegalStateException,
                     java.lang.IllegalArgumentException
Sets an item as editable.

Parameters:
itemId - the id of the item to edit
Throws:
java.lang.IllegalStateException - if the editor row is not enabled
java.lang.IllegalArgumentException - if the itemId is not in the backing container
See Also:
setEnabled(boolean)

internalEditItem

protected void internalEditItem(java.lang.Object itemId)

cancel

public void cancel()
Cancels the currently active edit if any.


internalCancel

protected void internalCancel()

isEditing

public boolean isEditing()
Returns whether this editor row is currently editing an item.

Returns:
true iff this editor row is editing an item

getEditedItemId

public java.lang.Object getEditedItemId()
Gets the id of the item that is currently being edited.

Returns:
the id of the item that is currently being edited, or null if no item is being edited at the moment


Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.