org.openbp.jaspira.propertybrowser.nodes
Class CollectionNode

java.lang.Object
  extended by org.openbp.jaspira.propertybrowser.nodes.AbstractNode
      extended by org.openbp.jaspira.propertybrowser.nodes.CollectionNode
All Implemented Interfaces:
java.lang.Cloneable, javax.swing.tree.TreeNode, Copyable, TreeTableNode

public class CollectionNode
extends AbstractNode

Property browser tree node that implements the parent node of a collection member of the object.

Author:
Erich Lauterbach

Field Summary
 
Fields inherited from class org.openbp.jaspira.propertybrowser.nodes.AbstractNode
children, object, parentNode, propertyBrowser
 
Fields inherited from interface org.openbp.common.generic.Copyable
COPY_DEEP, COPY_FIRST_LEVEL, COPY_SHALLOW
 
Constructor Summary
CollectionNode(PropertyDescriptor propertyDescriptor)
          Default Constructor
 
Method Summary
 AbstractNode addNewNodeAfter(AbstractNode posNode, java.lang.Object instance)
          Adds a new node of the same type as the exisiting child nodes and inserts it into the child list at the given position.
 boolean allowedToDrag()
          Defines if a receiver node may be dragged into another position.
 boolean allowsNodeAddition()
          Determines if node addition is allowed.
 boolean allowsNodeRemoval()
          Determinces if a node removal is allowed.
 boolean allowsNodeReordering()
          Determinces if a node reordering is allowed.
 void copyFrom(java.lang.Object source, int copyMode)
          Copies the values of the source object to this object.
protected  java.lang.Object createNewMember()
          Creates a new member node to be added to the list.
 boolean getAllowsChildren()
          Returns true if the receiver allows children.
 javax.swing.tree.TreeNode getChildAt(int childIndex)
          Returns the child TreeNode at index childIndex.
 int getChildCount()
          Returns the number of children TreeNodes the receiver contains.
 int getChildIndex(AbstractNode node)
          Gets the child index of the given node.
 CollectionDescriptor getCollectionDescriptor()
          Gets the CollectionDescriptor associated with this node..
 java.lang.Object getColumnValue(int columnIndex)
           
 java.lang.String getNodeText()
           
 PropertyDescriptor getPropertyDescriptor()
          Gets the PropertyDescriptor that contains the CollectionDescriptor for this node..
 boolean isLeaf()
          Returns true if the receiver is a leaf.
 void moveNodeDown(AbstractNode node)
          Moves the given node one position down in the child node list.
 void moveNodeUp(AbstractNode node)
          Moves the given node one position up in the child node list.
protected  void populateChildren()
          Populates the children vector with ObjectNode 's, from the objects contained in the list.
 void reload()
          Reloads the content of this node.
 void removeAllNodes()
          Removes all nodes from the collection.
 AbstractNode removeNode(AbstractNode node)
          Removes a sepcified node from the collection.
 boolean representsProperty(java.lang.String propertyName)
          Checks if this node represents the given property.
protected  void saveList()
          Saves the list with the modified objects back into the object.
 void setObject(java.lang.Object object)
          Sets the object containing the values for the property.
 boolean shouldExpand()
          Checks if the node node should be expanded on initial display.
 java.lang.String toString()
          Returns a string representation of this object.
 
Methods inherited from class org.openbp.jaspira.propertybrowser.nodes.AbstractNode
add, add, children, clone, filterPropertyNodes, findNodeForProperty, getAssociatedCollectionNode, getIndex, getLastHeight, getObject, getObjectNode, getParent, getPreferredSize, getPropertyBrowser, getPropertyNodes, reloadProperty, remove, setLastHeight, setParent, setPropertyBrowser
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CollectionNode

public CollectionNode(PropertyDescriptor propertyDescriptor)
Default Constructor

Parameters:
propertyDescriptor - The PropertyDescriptor that contains the CollectionDescriptor
Method Detail

toString

public java.lang.String toString()
Returns a string representation of this object.

Overrides:
toString in class java.lang.Object

copyFrom

public void copyFrom(java.lang.Object source,
                     int copyMode)
              throws java.lang.CloneNotSupportedException
Copies the values of the source object to this object.

Specified by:
copyFrom in interface Copyable
Overrides:
copyFrom in class AbstractNode
Parameters:
source - The source object. Must be of the same type as this object.
copyMode - Determines if a deep copy, a first level copy or a shallow copy is to be performed. See the constants of the org.openbp.common.generic.description.Copyable class.
Throws:
java.lang.CloneNotSupportedException - If the cloning of one of the contained objects failed

reload

public void reload()
Reloads the content of this node.

Overrides:
reload in class AbstractNode

representsProperty

public boolean representsProperty(java.lang.String propertyName)
Checks if this node represents the given property.

Overrides:
representsProperty in class AbstractNode
Parameters:
propertyName - Name of the property to check

getPropertyDescriptor

public PropertyDescriptor getPropertyDescriptor()
Gets the PropertyDescriptor that contains the CollectionDescriptor for this node..


getCollectionDescriptor

public CollectionDescriptor getCollectionDescriptor()
Gets the CollectionDescriptor associated with this node..


getColumnValue

public java.lang.Object getColumnValue(int columnIndex)

getNodeText

public java.lang.String getNodeText()

getAllowsChildren

public boolean getAllowsChildren()
Description copied from class: AbstractNode
Returns true if the receiver allows children.

Specified by:
getAllowsChildren in interface javax.swing.tree.TreeNode
Overrides:
getAllowsChildren in class AbstractNode

getChildAt

public javax.swing.tree.TreeNode getChildAt(int childIndex)
Description copied from class: AbstractNode
Returns the child TreeNode at index childIndex.

Specified by:
getChildAt in interface javax.swing.tree.TreeNode
Overrides:
getChildAt in class AbstractNode

getChildCount

public int getChildCount()
Description copied from class: AbstractNode
Returns the number of children TreeNodes the receiver contains.

Specified by:
getChildCount in interface javax.swing.tree.TreeNode
Overrides:
getChildCount in class AbstractNode

isLeaf

public boolean isLeaf()
Description copied from class: AbstractNode
Returns true if the receiver is a leaf.

Specified by:
isLeaf in interface javax.swing.tree.TreeNode
Overrides:
isLeaf in class AbstractNode

shouldExpand

public boolean shouldExpand()
Checks if the node node should be expanded on initial display.

Overrides:
shouldExpand in class AbstractNode
Returns:
true If the node should be expanded
false If the node should be collapsed

setObject

public void setObject(java.lang.Object object)
Sets the object containing the values for the property.

Overrides:
setObject in class AbstractNode
Parameters:
object - The object to be set

addNewNodeAfter

public AbstractNode addNewNodeAfter(AbstractNode posNode,
                                    java.lang.Object instance)
Adds a new node of the same type as the exisiting child nodes and inserts it into the child list at the given position.

Parameters:
posNode - Node that determines the position of the new node in the collection
If this is null or the collection node itself, the new node will be added at the end of the list. Otherwise, if this node is a member of the collection, the new node will be inserted after the given node.
instance - Object instance to be added or null to create a new instance
Returns:
The new node or null if no node may/could be added

removeNode

public AbstractNode removeNode(AbstractNode node)
Removes a sepcified node from the collection.

Parameters:
node - The node to be removed
Returns:
The node that should become the current node after removal of this node
This is the node that succeeds the current node in the collection or - if not present - the node that preceeds the current node or - if the list is empty - the collection node itself (or null if not removal has taken place).

removeAllNodes

public void removeAllNodes()
Removes all nodes from the collection.


moveNodeUp

public void moveNodeUp(AbstractNode node)
Moves the given node one position up in the child node list.

Parameters:
node - Node to move

moveNodeDown

public void moveNodeDown(AbstractNode node)
Moves the given node one position down in the child node list.

Parameters:
node - Node to move

allowedToDrag

public boolean allowedToDrag()
Defines if a receiver node may be dragged into another position.

Returns:
true if the node may be dragged
false otherwise.

allowsNodeAddition

public boolean allowsNodeAddition()
Determines if node addition is allowed.

Returns:
true if node addition is allowed
false if no node addition is allowed.

allowsNodeRemoval

public boolean allowsNodeRemoval()
Determinces if a node removal is allowed.

Returns:
true if nodes may be removed.
false is nodes may not be removed.

allowsNodeReordering

public boolean allowsNodeReordering()
Determinces if a node reordering is allowed.

Returns:
true if nodes may be reordered.
false is nodes may not be reordered.

populateChildren

protected void populateChildren()
Populates the children vector with ObjectNode 's, from the objects contained in the list.


getChildIndex

public int getChildIndex(AbstractNode node)
Gets the child index of the given node.

Parameters:
node - Node to search
Returns:
The child index or -1 if not found

saveList

protected void saveList()
Saves the list with the modified objects back into the object.


createNewMember

protected java.lang.Object createNewMember()
Creates a new member node to be added to the list.

Returns:
The new member instance or null if the cretion failed


Copyright © 2011. All Rights Reserved.