ca.sqlpower.wabit
Class WabitContainer<T extends WabitItem>

java.lang.Object
  extended by ca.sqlpower.wabit.AbstractWabitObject
      extended by ca.sqlpower.wabit.WabitContainer<T>
All Implemented Interfaces:
WabitObject
Direct Known Subclasses:
WabitConstantsContainer, WabitTableContainer

public abstract class WabitContainer<T extends WabitItem>
extends AbstractWabitObject

This container wraps any other kind of Container to allow attaching WabitListeners that will be notified appropriately when events happen on the container.


Field Summary
protected  java.util.List<T> children
          This is a list of WabitItems that mimics the items in the delegate.
 
Constructor Summary
WabitContainer(ca.sqlpower.query.Container delegate)
           
WabitContainer(ca.sqlpower.query.Container delegate, boolean createItemWrappers)
          Creates a WabitObject that wraps any Container object.
 
Method Summary
protected  void addChildImpl(WabitObject child, int index)
          This is the object specific implementation of #addChild(WabitObject).
 boolean allowsChildren()
          Returns true if this object may contain children.
 int childPositionOffset(java.lang.Class<? extends WabitObject> childType)
          Returns the position in the list that would be returned by getChildren() that the first object of type childClass is, or where it would be if there were any children of that type.
 CleanupExceptions cleanup()
          Default cleanup method that does nothing.
protected abstract  T createWabitItemChild(ca.sqlpower.query.Item item)
          Creates a child of the type this class contains
 java.lang.String getAlias()
           
protected abstract  java.lang.Class<T> getChildClass()
          Returns the class type of the children this container contains.
 java.util.List<? extends WabitObject> getChildren()
          Returns an unmodifiable list of the children in this WabitObject.
 ca.sqlpower.query.Container getDelegate()
           
 java.util.List<WabitObject> getDependencies()
          Returns a list of all WabitObjects that this Wabit object is dependent on.
 java.awt.geom.Point2D getPosition()
           
protected  boolean removeChildImpl(WabitObject child)
          This is the object specific implementation of removeChild.
 void removeDependency(WabitObject dependency)
          Removes the given object as a dependency of this object.
 void setAlias(java.lang.String alias)
           
 void setPosition(java.awt.geom.Point2D position)
           
 
Methods inherited from class ca.sqlpower.wabit.AbstractWabitObject
addChild, addWabitListener, begin, beginTransaction, commit, commitTransaction, equals, fireChildAdded, fireChildRemoved, firePropertyChange, firePropertyChange, firePropertyChange, fireTransactionEnded, fireTransactionRollback, fireTransactionStarted, generateNewUUID, getChildren, getName, getParent, getSession, getUUID, isForegroundThread, removeChild, removeWabitListener, rollback, rollbackTransaction, runInBackground, runInForeground, setName, setParent, setUUID, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

children

protected final java.util.List<T extends WabitItem> children
This is a list of WabitItems that mimics the items in the delegate. Items should be added to and removed from this list as they are added to and removed from the delegate. These children will also be returned instead of the delegate's children when they are requested. The children of the delegate contain a parent pointer to the delegate and the WabitItems point to this container instead.

Constructor Detail

WabitContainer

public WabitContainer(ca.sqlpower.query.Container delegate)

WabitContainer

public WabitContainer(ca.sqlpower.query.Container delegate,
                      boolean createItemWrappers)
Creates a WabitObject that wraps any Container object.

Parameters:
delegate - The Container to wrap.
createItemWrappers - If true the children of the container will be wrapped to start. If false there will be no WabitObject children to this container.
Method Detail

createWabitItemChild

protected abstract T createWabitItemChild(ca.sqlpower.query.Item item)
Creates a child of the type this class contains

Parameters:
item - The item to wrap in a WabitItem.
Returns:
A new WabitItem that is the correct sub-type for this class.

getChildClass

protected abstract java.lang.Class<T> getChildClass()
Returns the class type of the children this container contains.


cleanup

public CleanupExceptions cleanup()
Description copied from class: AbstractWabitObject
Default cleanup method that does nothing. Override and implement this method if cleanup is necessary.

Specified by:
cleanup in interface WabitObject
Overrides:
cleanup in class AbstractWabitObject
Returns:
A collection of exceptions and errors that occurred during cleanup if any occurred.

getDelegate

public ca.sqlpower.query.Container getDelegate()

removeChildImpl

protected boolean removeChildImpl(WabitObject child)
Description copied from class: AbstractWabitObject
This is the object specific implementation of removeChild. There are checks in the removeChild method to ensure the child being removed has no dependencies and is a child of this object.

Specified by:
removeChildImpl in class AbstractWabitObject
See Also:
AbstractWabitObject.removeChild(WabitObject)

addChildImpl

protected void addChildImpl(WabitObject child,
                            int index)
Description copied from class: AbstractWabitObject
This is the object specific implementation of #addChild(WabitObject). There are checks in the #addChild(WabitObject) method to ensure that the object given here is a valid child type of this object.

This method should be overwritten if children are allowed.

Overrides:
addChildImpl in class AbstractWabitObject
Parameters:
child - The child to add to this object.
index - The index to add the child at.

allowsChildren

public boolean allowsChildren()
Description copied from interface: WabitObject
Returns true if this object may contain children. Not all types of WabitObjects can be a child to any WabitObject.

See Also:
WabitObject.childPositionOffset(Class)

childPositionOffset

public int childPositionOffset(java.lang.Class<? extends WabitObject> childType)
Description copied from interface: WabitObject
Returns the position in the list that would be returned by getChildren() that the first object of type childClass is, or where it would be if there were any children of that type.


getChildren

public java.util.List<? extends WabitObject> getChildren()
Description copied from interface: WabitObject
Returns an unmodifiable list of the children in this WabitObject. If there are no children in this WabitObject an empty list should be returned.


getDependencies

public java.util.List<WabitObject> getDependencies()
Description copied from interface: WabitObject
Returns a list of all WabitObjects that this Wabit object is dependent on. Children of a WabitObject are not dependencies and will not be returned in this list. If there are no objects this Wabit object is dependent on an empty list should be returned. These are only the immediate dependencies of this object. If you want to find the dependencies of this object's dependencies as well it may be useful to look at WorkspaceGraphModel to make a full graph of all of the dependencies.


removeDependency

public void removeDependency(WabitObject dependency)
Description copied from interface: WabitObject
Removes the given object as a dependency of this object. For this object to no longer be dependent on the given dependency all of its children must also not be dependent on the given dependency when this method returns. This may remove this object from its parent if necessary.


getAlias

public java.lang.String getAlias()

setAlias

public void setAlias(java.lang.String alias)

getPosition

public java.awt.geom.Point2D getPosition()

setPosition

public void setPosition(java.awt.geom.Point2D position)


Copyright © 2009. All Rights Reserved.