com.arsdigita.formbuilder.util
Class PersistentContainerHelper

java.lang.Object
  extended bycom.arsdigita.formbuilder.util.PersistentContainerHelper
All Implemented Interfaces:
PersistentContainer

public class PersistentContainerHelper
extends Object
implements PersistentContainer

This class is used internally by PersistentFormSection and PersistentOptionGroup to manage the associations to the Component children of these containers.

Version:
$Id: //core-platform/dev/src/com/arsdigita/formbuilder/util/PersistentContainerHelper.java#9 $
Author:
Peter Marklund

Field Summary
static String versionId
           
 
Constructor Summary
PersistentContainerHelper(PersistentComponentFactory factory)
           
 
Method Summary
 void addComponent(PersistentComponentFactory componentFactory)
          Add a component after the already added components (in the last position).
 void addComponent(PersistentComponentFactory componentFactory, boolean selected)
          Add a component after the already added components (in the last position).
 void addComponent(PersistentComponentFactory componentFactory, int position)
          Add a child component of the container.
 void addComponent(PersistentComponentFactory componentFactory, int position, boolean isSelected)
          Add a child component of the container.
protected  void assertPositionInAddRange(int position)
          Assert that the position is valid for adding a component at.
protected  void assertPositionInCurrentRange(int position)
          Assert that the position is within the current range of component positions.
protected  void assertPositionInRange(int position, int upperLimit)
          Assert that the position is between 1 and the given upper limit
 void clearComponents()
          Delete all component associations from this container
protected  void decrementNumberOfComponents()
           
protected  void executeAddComponent(BigDecimal componentID, int position, boolean isSelected)
          Map a component with a certain position to the container.
protected  void executeClearComponents()
          Remove all component associations from the container
protected  void executeRemoveComponent(BigDecimal componentID)
          Remove a component-container mapping.
protected  void executeSetComponentSelected(BigDecimal componentID, boolean selected)
           
 Collection getComponents()
          Return all children components represented by their PersistentComponentFactory objects.
protected  int getNumberOfComponents()
           
 List getSelectedComponents()
          Can be invoked after getComponents() has been invoked to fetch the components that are selected.
protected  void incrementNumberOfComponents()
           
 void moveComponent(PersistentComponentFactory componentFactory, int toPosition)
          Move component to new position.
 void removeComponent(PersistentComponentFactory componentFactory)
          Remove a component from the container.
 void setComponentSelected(PersistentComponentFactory componentFactory, boolean selected)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Constructor Detail

PersistentContainerHelper

public PersistentContainerHelper(PersistentComponentFactory factory)
Method Detail

addComponent

public void addComponent(PersistentComponentFactory componentFactory)
Add a component after the already added components (in the last position). If this domain object has not been saved (with save()) before you invoke this method it will be saved by this method. The component will not be selected.

Specified by:
addComponent in interface PersistentContainer

addComponent

public void addComponent(PersistentComponentFactory componentFactory,
                         boolean selected)
Add a component after the already added components (in the last position). If this domain object has not been saved (with save()) before you invoke this method it will be saved by this method.


addComponent

public void addComponent(PersistentComponentFactory componentFactory,
                         int position)
Add a child component of the container. If this domain object has not been saved (with save()) before you invoke this method it will be saved by this method. The component will not be selected.

Specified by:
addComponent in interface PersistentContainer
Parameters:
position - The count of this component starting with 1 (i.e. if it's the third component to be added to the container this value would be 3)

addComponent

public void addComponent(PersistentComponentFactory componentFactory,
                         int position,
                         boolean isSelected)
Add a child component of the container. If this domain object has not been saved (with save()) before you invoke this method it will be saved by this method.

Parameters:
position - The count of this component starting with 1 (i.e. if it's the third component to be added to the container this value would be 3)

removeComponent

public void removeComponent(PersistentComponentFactory componentFactory)
Remove a component from the container. If this domain object has not been saved (with save()) before you invoke this method it will be saved by this method.

Specified by:
removeComponent in interface PersistentContainer

moveComponent

public void moveComponent(PersistentComponentFactory componentFactory,
                          int toPosition)
Move component to new position.

Specified by:
moveComponent in interface PersistentContainer
Parameters:
toPosition - The position to move the component to. Positions start with 1.

clearComponents

public void clearComponents()
Description copied from interface: PersistentContainer
Delete all component associations from this container

Specified by:
clearComponents in interface PersistentContainer

setComponentSelected

public void setComponentSelected(PersistentComponentFactory componentFactory,
                                 boolean selected)

getComponents

public Collection getComponents()
Return all children components represented by their PersistentComponentFactory objects.


getSelectedComponents

public List getSelectedComponents()
Can be invoked after getComponents() has been invoked to fetch the components that are selected. Returns a list of PersistentComponentFactory objects corresponding to the selected components.


executeAddComponent

protected void executeAddComponent(BigDecimal componentID,
                                   int position,
                                   boolean isSelected)
Map a component with a certain position to the container.


executeRemoveComponent

protected void executeRemoveComponent(BigDecimal componentID)
Remove a component-container mapping. Note that this does not remove the component


executeClearComponents

protected void executeClearComponents()
Remove all component associations from the container


executeSetComponentSelected

protected void executeSetComponentSelected(BigDecimal componentID,
                                           boolean selected)

assertPositionInAddRange

protected void assertPositionInAddRange(int position)
Assert that the position is valid for adding a component at.


assertPositionInCurrentRange

protected void assertPositionInCurrentRange(int position)
Assert that the position is within the current range of component positions.


assertPositionInRange

protected void assertPositionInRange(int position,
                                     int upperLimit)
Assert that the position is between 1 and the given upper limit


getNumberOfComponents

protected int getNumberOfComponents()

incrementNumberOfComponents

protected void incrementNumberOfComponents()

decrementNumberOfComponents

protected void decrementNumberOfComponents()


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 20 2004:2337 UTC