uk.ac.kcl.cch.jb.pliny.containmentView.model
Class ContainmentSet

java.lang.Object
  extended byuk.ac.kcl.cch.rdb2java.dynData.PropertyChangeObject
      extended byuk.ac.kcl.cch.jb.pliny.containmentView.model.ContainmentSet
All Implemented Interfaces:
EventListener, IPropertyChangeObject, PropertyChangeListener

public class ContainmentSet
extends PropertyChangeObject
implements PropertyChangeListener

this model class for the ContainmentView represents the top level object for the a view page. Each view page is centered on a single Resource, so this object contains that starting Resource and manages the ContainmentItems and ContainmentLinks that it needs to generate the display.

This class implements PropertyChangeObject, and so can so can be listened to. It raises an event ITEMSCHANGED_EVENT each time an ContainmentItem is added or removed from the set. The UI part of the the ContainmentView subscribes to this service to that it can update itself at the time the user makes a change to the underlying data.

Author:
John Bradley
See Also:
ContainmentItem, ContainmentLink

Field Summary
static String ITEMSCHANGED_EVENT
           
 
Constructor Summary
ContainmentSet(Resource startingResource, IncludedTypeManager typeManager)
          this constructor creates an instance of this object that is meant to be centered on the startingResource.
 
Method Summary
 void addUndisplayedLinkableObject(LinkableObject lo)
           
 void dispose()
           
 void excludeType(LOType theType)
          convenience method to ask the IncludedTypeManager to exclude links of the given type.
 void extendItems(Vector items, boolean showParents, boolean showChildren)
          extends the ContainmentItems in items by adding either their parents or children or both to the set.
 Map getExpandedResources()
           
 ContainmentItem getItem(Resource r)
          returns a ContainmentItem that corresponds to the given Resource.
 ContainmentLink getLink(ContainmentItem from, ContainmentItem to)
           
 Vector getMyItems()
          returns the ContainmentItems that this set is currently holding.
 boolean hasLink(Resource from, Resource to)
           
 void includeType(LOType theType)
          convenience method to ask the IncludedTypeManager to include links of the given type.
 boolean isChildExpanded(Resource r)
           
 boolean isIncluded(LOType theType)
          convenience method to ask the IncludedTypeManager to ask if the given type is currently to be included or not.
 boolean isParentExpanded(Resource r)
           
 void propertyChange(PropertyChangeEvent arg0)
           
 void recordChildExpand(Resource r)
           
 void recordParentExpand(Resource r)
           
 void refresh()
          completely regenerates the model for the existing Resource.
 void removeItem(ContainmentItem theItem)
           
 void removeLink(ContainmentLink theLink)
           
 void updateResource(Resource newResource)
          refocuses this ContainmentSet so that it is centered on a new Resource.
 
Methods inherited from class uk.ac.kcl.cch.rdb2java.dynData.PropertyChangeObject
addPropertyChangeListener, firePropertyChange, firePropertyChange, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ITEMSCHANGED_EVENT

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

ContainmentSet

public ContainmentSet(Resource startingResource,
                      IncludedTypeManager typeManager)
this constructor creates an instance of this object that is meant to be centered on the startingResource.

Parameters:
startingResource - Resource that this ContainmentSet refers to -- corresponds to the Resource the current ContainmentView page is for.
typeManager -
Method Detail

getMyItems

public Vector getMyItems()
returns the ContainmentItems that this set is currently holding.

Returns:
Vector containing ContainmentItems.

getExpandedResources

public Map getExpandedResources()

getItem

public ContainmentItem getItem(Resource r)
returns a ContainmentItem that corresponds to the given Resource. If the ContainmentItem does not exist at the time, it is created and stored so that the same one can be returned the next time the one for the same resource is requested.

This method is used internally within the ContainmentView's classes, and it is not expected to need to be called by others.

Parameters:
r - Resource the ContainmentItem is for.
Returns:
the corresponding ContainmentItem.

getLink

public ContainmentLink getLink(ContainmentItem from,
                               ContainmentItem to)

hasLink

public boolean hasLink(Resource from,
                       Resource to)

removeLink

public void removeLink(ContainmentLink theLink)

removeItem

public void removeItem(ContainmentItem theItem)

extendItems

public void extendItems(Vector items,
                        boolean showParents,
                        boolean showChildren)
extends the ContainmentItems in items by adding either their parents or children or both to the set.

Parameters:
items - Vector containing ContainmentItems
showParents - boolean if true, add parent items
showChildren - boolean if true, add children items

dispose

public void dispose()

propertyChange

public void propertyChange(PropertyChangeEvent arg0)
Specified by:
propertyChange in interface PropertyChangeListener

updateResource

public void updateResource(Resource newResource)
refocuses this ContainmentSet so that it is centered on a new Resource. This is needed when the View is driven by an Editor in which the resource being worked on can change. The code here cleans up the old data for the old Resource, rebuilds the model for the new resource, and fires a property change to announce that the items have changed.

Parameters:
newResource - Resource to replace old Resource.

refresh

public void refresh()
completely regenerates the model for the existing Resource. The code here cleans up the old data built previously, rebuilds the model for the resource completely, and fires a property change to announce that the items have changed.

Even though most of the data in the ContainmentSet is thrown away the set saves data that indicates whether or not a ContainmentSet for each Resource was expanded by showing its parents/children or not, so that after the refresh the display shows the same amount of child/parent data as it did before.


includeType

public void includeType(LOType theType)
convenience method to ask the IncludedTypeManager to include links of the given type.

Parameters:
theType - LOType type to include

excludeType

public void excludeType(LOType theType)
convenience method to ask the IncludedTypeManager to exclude links of the given type.

Parameters:
theType - LOType type to exclude

isIncluded

public boolean isIncluded(LOType theType)
convenience method to ask the IncludedTypeManager to ask if the given type is currently to be included or not.

Parameters:
theType - LOType type to exclude
Returns:
boolean is true is the manager says data of this type should be included.

recordParentExpand

public void recordParentExpand(Resource r)

recordChildExpand

public void recordChildExpand(Resource r)

isParentExpanded

public boolean isParentExpanded(Resource r)

isChildExpanded

public boolean isChildExpanded(Resource r)

addUndisplayedLinkableObject

public void addUndisplayedLinkableObject(LinkableObject lo)