p3j.gui.panels.projections
Class ProjectionTreeNode<E>

java.lang.Object
  extended by javax.swing.tree.DefaultMutableTreeNode
      extended by p3j.gui.panels.projections.ProjectionTreeNode<E>
Type Parameters:
E - type of the represented entity
All Implemented Interfaces:
Serializable, Cloneable, MutableTreeNode, TreeNode
Direct Known Subclasses:
DatabaseNode, GenerationNode, OverviewProjectionNode, ParameterAssignmentNode, ParameterInstanceNode, PopulationNode, ProjectionNode, ResultTreeNode, ResultTreeRoot, SetNode, SetTypeNode

public class ProjectionTreeNode<E>
extends DefaultMutableTreeNode

Super class of all nodes representing PPPM entities in the projection tree. Created: August 24, 2008

Author:
Christina Bohk, Roland Ewald
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
ProjectionTreeNode(E pppmEntity, String name)
          Default constructor.
 
Method Summary
 void deselected()
          Method that is called by the TreeSelectionListener when this node gets de-selected.
 List<ProjectionTreeNode<?>> getChilds()
          Retrieves list of child nodes.
<X> List<ProjectionTreeNode<X>>
getChildsByType(Class<X> entityType)
          Retrieves all children of a given type.
protected
<X> List<ProjectionTreeNode<X>>
getChildsByType(List<ProjectionTreeNode<X>> list, Class<X> entityType)
           
 ProjectionTreeNode<?> getChildWithEntity(Object childEntity)
          Looks for a certain object associated with a child node of type ProjectionTreeNode.
 JPanel getContentPanel()
           
 E getEntity()
           
 Class<?> getEntityClass()
           
 String getEntityLabel()
          Gets the user object string.
<T> T
getProjectionEntity(Class<T> targetClass)
          Traverses current JTree towards its root.
<T> T
getProjectionEntity(Class<T> targetClass, ProjectionTreeNode<?> sourceNode)
          Traverses a JTree towards its root.
<T> T
getProjectionTreeNodeOnPath(Class<T> targetClass)
          Gets a projection tree node of a specific type, which is on the path.
protected  void refreshRecursively(DefaultTreeModel treeModel)
          Refreshes nodes and all of its children recursively, by invoking refreshRepresentation().
protected  void refreshRepresentation()
          This is called when the node's representation might have changed.
 JPanel selected(TreePath selectionPath, IProjectionTree projTree)
          Method that is called by ProjectionTreeNode#selected(TreePath, JPanel, DefaultTreeModel, javax.swing.JTree) originally.
 void selected(TreePath selectionPath, JPanel generalPanel, IProjectionTree projTree)
          Method that is called by the TreeSelectionListener when this node gets selected.
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getChildCount, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getLevel, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProjectionTreeNode

public ProjectionTreeNode(E pppmEntity,
                          String name)
Default constructor.

Parameters:
pppmEntity - the PPPM entity to be represented
name - the name to be displayed
Method Detail

getEntity

public E getEntity()

selected

public void selected(TreePath selectionPath,
                     JPanel generalPanel,
                     IProjectionTree projTree)
Method that is called by the TreeSelectionListener when this node gets selected.

Parameters:
selectionPath - the path containing all ancestors
generalPanel - the general panel to put the content on
projTree - the projection tree

selected

public JPanel selected(TreePath selectionPath,
                       IProjectionTree projTree)
Method that is called by ProjectionTreeNode#selected(TreePath, JPanel, DefaultTreeModel, javax.swing.JTree) originally. Implementations of ProjectionTreeNode might override either of the 'selected' methods, this one is more convenient as it stores the generated panel in an auxiliary variable and does not require to add the panel manually, it just needs to be returned.

Parameters:
selectionPath - the path containing all ancestors
projTree - the projection tree
Returns:
panel with a node summary

refreshRepresentation

protected void refreshRepresentation()
This is called when the node's representation might have changed. A reason for this could be changes from the outside. Default implementation is empty. This should simple re-invoke DefaultMutableTreeNode.setUserObject(Object).


deselected

public void deselected()
Method that is called by the TreeSelectionListener when this node gets de-selected.


getEntityClass

public Class<?> getEntityClass()

getContentPanel

public JPanel getContentPanel()

getProjectionEntity

public <T> T getProjectionEntity(Class<T> targetClass)
Traverses current JTree towards its root. See getProjectionEntity(Class, ProjectionTreeNode), which is called with this.

Type Parameters:
T - required type
Parameters:
targetClass - class of required type
Returns:
found entity, or null

getProjectionEntity

public <T> T getProjectionEntity(Class<T> targetClass,
                                 ProjectionTreeNode<?> sourceNode)
Traverses a JTree towards its root. Returns first entity of a given type that is found. Requires that all nodes are of type ProjectionTreeNode, returns null when encountering another class.

Type Parameters:
T - the type of the required entity
Parameters:
targetClass - the class of the required entity
sourceNode - the node from where to start searching upwards
Returns:
first entity of requested type on path towards root, or null if not found

getProjectionTreeNodeOnPath

public <T> T getProjectionTreeNodeOnPath(Class<T> targetClass)
Gets a projection tree node of a specific type, which is on the path.

Type Parameters:
T - the type of the target
Parameters:
targetClass - the target class
Returns:
the projection tree node on path

getChildWithEntity

public ProjectionTreeNode<?> getChildWithEntity(Object childEntity)
Looks for a certain object associated with a child node of type ProjectionTreeNode.

Parameters:
childEntity - the target entity
Returns:
the child node associated with this entity

getChildsByType

public <X> List<ProjectionTreeNode<X>> getChildsByType(Class<X> entityType)
Retrieves all children of a given type. Traverses the tree in preorder.

Type Parameters:
X - the type of the entity
Parameters:
entityType - the type of the entity
Returns:
list of child nodes representing such entities (which have to be non-null)

getChildsByType

protected <X> List<ProjectionTreeNode<X>> getChildsByType(List<ProjectionTreeNode<X>> list,
                                                          Class<X> entityType)

refreshRecursively

protected void refreshRecursively(DefaultTreeModel treeModel)
Refreshes nodes and all of its children recursively, by invoking refreshRepresentation().

Parameters:
treeModel - the tree model to be notified

getChilds

public List<ProjectionTreeNode<?>> getChilds()
Retrieves list of child nodes.

Returns:
list of child nodes

getEntityLabel

public String getEntityLabel()
Gets the user object string.

Returns:
the object string


Copyright © 2012. All Rights Reserved.