org.openbp.jaspira.propertybrowser.nodes
Class AbstractNode

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

public abstract class AbstractNode
extends java.lang.Object
implements TreeTableNode, java.lang.Cloneable, Copyable

Base class for all nodes of the property browser tree.

Author:
Erich Lauterbach

Field Summary
protected  java.util.Vector children
          Vector containing all the sibling nodes.
protected  java.lang.Object object
          The object for which this node will display a property.
protected  AbstractNode parentNode
          The parent node to this node.
protected  PropertyBrowserImpl propertyBrowser
          Property browser
 
Fields inherited from interface org.openbp.common.generic.Copyable
COPY_DEEP, COPY_FIRST_LEVEL, COPY_SHALLOW
 
Constructor Summary
AbstractNode()
          Default Constructor
 
Method Summary
protected  void add(AbstractNode node)
          Adds a new AbstractNode to the receiver node.
protected  void add(int index, AbstractNode node)
          Adds a new AbstractNode to the receiver node.
 java.util.Enumeration children()
          Returns the children of the receiver as an Enumeration.
 java.lang.Object clone()
          Clones this node and all its child nodes, thus performing a deep clone.
 void copyFrom(java.lang.Object source, int copyMode)
          Copies the values of the source object to this object.
 void filterPropertyNodes(java.lang.String[] visibleMembers)
          Filters out (removes) all property nodes from the property nodes below this node that do not match one of the specified properties.
 AbstractNode findNodeForProperty(java.lang.String propertyName)
          Finds the specified node.
 boolean getAllowsChildren()
          Returns true if the receiver allows children.
 CollectionNode getAssociatedCollectionNode()
          Gets the collection descriptor node that is directly associated with this node.
 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 getIndex(javax.swing.tree.TreeNode node)
          Returns the index of node in the receivers children.
 int getLastHeight()
          Gets the height used last by the JTreeTable for this node.
 java.lang.Object getObject()
          Gets the object containing the values for the property.
 ObjectNode getObjectNode()
          Gets the parent object descriptor node of this node.
 javax.swing.tree.TreeNode getParent()
          Returns the parent TreeNode of the receiver.
 java.awt.Dimension getPreferredSize()
          Gets the preferred height of the node in the tree.
 PropertyBrowser getPropertyBrowser()
          Gets the property browser that owns the node.
 java.util.Iterator getPropertyNodes()
          Creates an iteration over all property nodes below this node.
 boolean isLeaf()
          Returns true if the receiver is a leaf.
 void reload()
          Reloads the content of this node.
 void reloadProperty(java.lang.String propertyName)
          Forces a reload of a particular property from the modified object and redisplays the specified property.
 void remove()
          Removes this node from the structure.
 boolean representsProperty(java.lang.String propertyName)
          Checks if this node represents the given property.
 void setLastHeight(int height)
          Sets the current height being used by the JTreeTable for later use.
 void setObject(java.lang.Object object)
          Sets the object containing the values for the porperty.
 void setParent(AbstractNode node)
          Sets the parent tree node of this node.
 void setPropertyBrowser(PropertyBrowserImpl propertyBrowser)
          Sets the property browser that owns the node.
 boolean shouldExpand()
          Checks if the node node should be expanded on initial display.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.openbp.swing.components.treetable.TreeTableNode
getColumnValue, getNodeText
 

Field Detail

children

protected java.util.Vector children
Vector containing all the sibling nodes.


parentNode

protected AbstractNode parentNode
The parent node to this node.


object

protected java.lang.Object object
The object for which this node will display a property.


propertyBrowser

protected PropertyBrowserImpl propertyBrowser
Property browser

Constructor Detail

AbstractNode

public AbstractNode()
Default Constructor

Method Detail

clone

public java.lang.Object clone()
                       throws java.lang.CloneNotSupportedException
Clones this node and all its child nodes, thus performing a deep clone.

Specified by:
clone in interface Copyable
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException

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
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.


representsProperty

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

Parameters:
propertyName - Name of the property to check

remove

public void remove()
Removes this node from the structure. Also removes the parent node if empty.


findNodeForProperty

public AbstractNode findNodeForProperty(java.lang.String propertyName)
Finds the specified node. The method will perform a recursive search, starting at this node.

Parameters:
propertyName - This may specifiy:
- The property name of a PropertyNode
- The associated property name of a CollectionNode
- The associated property name of a ObjectNode
Returns:
The node or null if no such property has been found

reloadProperty

public void reloadProperty(java.lang.String propertyName)
Forces a reload of a particular property from the modified object and redisplays the specified property. This method can be used by validators to redisplay properties they have changed.

Parameters:
propertyName - Property name

filterPropertyNodes

public void filterPropertyNodes(java.lang.String[] visibleMembers)
Filters out (removes) all property nodes from the property nodes below this node that do not match one of the specified properties. This method can be used to reduce the number of properties of an object that are displayed if there are many object properties.

Parameters:
visibleMembers - Array of allowed property names

getLastHeight

public int getLastHeight()
Gets the height used last by the JTreeTable for this node.

Specified by:
getLastHeight in interface TreeTableNode
Returns:
The last height used

setLastHeight

public void setLastHeight(int height)
Sets the current height being used by the JTreeTable for later use.

Specified by:
setLastHeight in interface TreeTableNode
Parameters:
height - The height being used

getPreferredSize

public java.awt.Dimension getPreferredSize()
Gets the preferred height of the node in the tree.

Specified by:
getPreferredSize in interface TreeTableNode
Returns:
The height as an int in pixels

isLeaf

public boolean isLeaf()
Returns true if the receiver is a leaf.

Specified by:
isLeaf in interface javax.swing.tree.TreeNode

getChildAt

public javax.swing.tree.TreeNode getChildAt(int childIndex)
Returns the child TreeNode at index childIndex.

Specified by:
getChildAt in interface javax.swing.tree.TreeNode

getChildCount

public int getChildCount()
Returns the number of children TreeNodes the receiver contains.

Specified by:
getChildCount in interface javax.swing.tree.TreeNode

getParent

public javax.swing.tree.TreeNode getParent()
Returns the parent TreeNode of the receiver.

Specified by:
getParent in interface javax.swing.tree.TreeNode

getIndex

public int getIndex(javax.swing.tree.TreeNode node)
Returns the index of node in the receivers children. If the receiver does not contain node, -1 will be returned.

Specified by:
getIndex in interface javax.swing.tree.TreeNode

getAllowsChildren

public boolean getAllowsChildren()
Returns true if the receiver allows children.

Specified by:
getAllowsChildren in interface javax.swing.tree.TreeNode

children

public java.util.Enumeration children()
Returns the children of the receiver as an Enumeration.

Specified by:
children in interface javax.swing.tree.TreeNode

getPropertyNodes

public java.util.Iterator getPropertyNodes()
Creates an iteration over all property nodes below this node.

Returns:
An iterator of PropertyNode and CollectionNode objects
Note that the iterator does not contain the properties of subordinate ObjectNode elements.

add

protected void add(AbstractNode node)
Adds a new AbstractNode to the receiver node. This method is used internaly and does not determine if the node is allowed to be added. It also force the receriver node to be set as the parent node of the node that is being added.

Parameters:
node - The node to be added

add

protected void add(int index,
                   AbstractNode node)
Adds a new AbstractNode to the receiver node. This method is used internaly and does not determine if the node is allowed to be added. It also force the receriver node to be set as the parent node of the node that is being added.

Parameters:
node - The node to be added
index - The index where the node is to be added

setParent

public void setParent(AbstractNode node)
Sets the parent tree node of this node.

Parameters:
node - The new parent

shouldExpand

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

Returns:
true If the node should be expanded
false If the node should be collapsed

getObjectNode

public ObjectNode getObjectNode()
Gets the parent object descriptor node of this node.

Returns:
The node or null

getAssociatedCollectionNode

public CollectionNode getAssociatedCollectionNode()
Gets the collection descriptor node that is directly associated with this node. If this node is a collection descriptor node itself, it is returned. Otherwise, if the parent of this node is one, it will be returned.

Returns:
The collection descriptor node or null if this node is not directly associated with a collection.

setObject

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

Parameters:
object - The object to be set

getObject

public java.lang.Object getObject()
Gets the object containing the values for the property.

Returns:
The object

setPropertyBrowser

public void setPropertyBrowser(PropertyBrowserImpl propertyBrowser)
Sets the property browser that owns the node.

Parameters:
propertyBrowser - The object to be set

getPropertyBrowser

public PropertyBrowser getPropertyBrowser()
Gets the property browser that owns the node.



Copyright © 2011. All Rights Reserved.