javatools.swing.tree
Class IndexedTypedTreeNode

java.lang.Object
  |
  +--javax.swing.tree.DefaultMutableTreeNode
        |
        +--javatools.swing.tree.IndexedTypedTreeNode
All Implemented Interfaces:
Clippable, java.lang.Cloneable, javax.swing.tree.MutableTreeNode, java.io.Serializable, javax.swing.tree.TreeNode
Direct Known Subclasses:
MediTreeNode

public class IndexedTypedTreeNode
extends javax.swing.tree.DefaultMutableTreeNode
implements Clippable

It is a node that is both typed (with a "type") and indexed (with an index).

See Also:
Serialized Form

Field Summary
protected  boolean beingCut
          true: the node is being cut; false: otherwise.
protected  boolean deleteWhenCut
          true: this node deletes itself (removes itself from its parent) when cut; false: the opposite.
protected  boolean dupWhenClipped
          true: the node duplicates itself when clipped (cut or copied); false: the node returns itself.
protected  boolean expanded
          true: the node is expanded; false: the node is not expanded.
protected  java.lang.Object[] ID
          The ID of this node.
protected  javax.swing.JTree tree
          The tree in which the node is contained.
protected  java.lang.String type
          The type of this node.
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
IndexedTypedTreeNode()
          Creates a new instance of IndexedTypedTreeNode
IndexedTypedTreeNode(javax.swing.JTree pTree, java.lang.Object userObject)
          Creates a new IndexedTypedTreeNode.
IndexedTypedTreeNode(javax.swing.JTree pTree, java.lang.Object userObject, boolean allowsChildren)
          Creates a new IndexedTypedTreeNode.
IndexedTypedTreeNode(java.lang.Object userObject)
          Creates a new instance of IndexedTypedTreeNode
IndexedTypedTreeNode(java.lang.Object userObject, boolean allowsChildren)
          Creates a new IndexedTypedTreeNode.
 
Method Summary
 void add(IndexedTypedTreeNode newChild)
          Adds a child to the node.
 void attach(Clippable newSon)
          Attaches an object to this one.
 boolean canBeAttached(Clippable newSon)
          Checks whether an object can be attached to this one.
 boolean canBeCopied()
          Checks whether this object can be copied or not.
 boolean canBeCut()
          Checks whether this object can be cut or not.
protected  void conditionalSetPlace(javax.swing.tree.TreeNode node, java.lang.Object place)
          Sets a node's tree if it is really a JTree.
 Clippable copy()
          Copies this object into the clipboard.
 Clippable cut()
          Cuts this object into the clipboard.
 Clippable duplicate()
          Duplicates (clones) this object.
 void expand()
          Expands the node.
 boolean getDeleteWhenCut()
          Checks whether the node will be deleted when cut.
 boolean getDuplicateWhenClipped()
          Checks whether the node will be duplicated when clipped.
 java.lang.Object[] getID()
          Returns the ID.
 java.lang.Object getPlace()
          Returns the tree that contains the node.
 java.lang.String getType()
          Returns the type of the node.
 java.lang.Object getValue()
          Returns the value of this object.
 void insert(IndexedTypedTreeNode newChild, int childIndex)
          Inserts a child to the node.
 boolean isExpanded()
          Returns the expanded flag.
 void paste(Clippable newFather)
          Pastes this object into another.
 void reload()
          Reloads the node.
 void remove(IndexedTypedTreeNode aChild)
          Removes a specified child.
 void remove(int childIndex)
          Removes a child.
 void removeAllChildren()
          Removes all children from this node.
 void removeFromParent()
          Removes this node from his parent node.
 void setDeleteWhenCut(boolean value)
          Sets the property for "deleting when cut".
 void setDuplicateWhenClipped(boolean value)
          Sets the "duplicate when clipped" property.
 void setExpanded(boolean value)
          Sets the expanded flag.
 void setID(java.lang.Object[] pID)
          Sets the ID for the node.
 void setPlace(java.lang.Object place)
          Sets the tree that contains the node (and all of his subnodes).
protected  void setPlaceForChildren(java.lang.Object place)
          Sets the tree for all children of this node.
 void setType(java.lang.String pType)
          Sets the type of node.
 void unclip()
          Resets the status of this object.
 
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, setAllowsChildren, setParent, setUserObject, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

expanded

protected boolean expanded
true: the node is expanded; false: the node is not expanded.


deleteWhenCut

protected boolean deleteWhenCut
true: this node deletes itself (removes itself from its parent) when cut; false: the opposite.


dupWhenClipped

protected boolean dupWhenClipped
true: the node duplicates itself when clipped (cut or copied); false: the node returns itself.


beingCut

protected boolean beingCut
true: the node is being cut; false: otherwise.


ID

protected java.lang.Object[] ID
The ID of this node.


type

protected java.lang.String type
The type of this node.


tree

protected javax.swing.JTree tree
The tree in which the node is contained.

Constructor Detail

IndexedTypedTreeNode

public IndexedTypedTreeNode()
Creates a new instance of IndexedTypedTreeNode


IndexedTypedTreeNode

public IndexedTypedTreeNode(java.lang.Object userObject)
Creates a new instance of IndexedTypedTreeNode

Parameters:
userObject - The string to be displayed in the tree.

IndexedTypedTreeNode

public IndexedTypedTreeNode(java.lang.Object userObject,
                            boolean allowsChildren)
Creates a new IndexedTypedTreeNode.

Parameters:
userObject - The object to use.
allowsChildren - true: allows children; false: does not allow children.

IndexedTypedTreeNode

public IndexedTypedTreeNode(javax.swing.JTree pTree,
                            java.lang.Object userObject)
Creates a new IndexedTypedTreeNode.

Parameters:
pTree - The tree that contains the node.
userObject - The string to be displayed in the tree.

IndexedTypedTreeNode

public IndexedTypedTreeNode(javax.swing.JTree pTree,
                            java.lang.Object userObject,
                            boolean allowsChildren)
Creates a new IndexedTypedTreeNode.

Parameters:
pTree - The tree that contains the node.
userObject - The string to be displayed in the tree.
allowsChildren - true: allows children; false: does not allow children.
Method Detail

setExpanded

public void setExpanded(boolean value)
Sets the expanded flag.

Parameters:
value - The value.

isExpanded

public boolean isExpanded()
Returns the expanded flag.

Returns:
The flag.

setID

public void setID(java.lang.Object[] pID)
Sets the ID for the node.

Parameters:
pID - An array of object representing the ID.

getID

public java.lang.Object[] getID()
Returns the ID.

Returns:
An array of objects representing the ID.

setType

public void setType(java.lang.String pType)
Sets the type of node.

Parameters:
pType - The type.

getType

public java.lang.String getType()
Returns the type of the node.

Specified by:
getType in interface Clippable
Returns:
The type.

attach

public void attach(Clippable newSon)
Attaches an object to this one.

Specified by:
attach in interface Clippable
Parameters:
newSon - The object to be attached.

copy

public Clippable copy()
Copies this object into the clipboard.

Specified by:
copy in interface Clippable
Returns:
The object to be copied.

cut

public Clippable cut()
Cuts this object into the clipboard.

Specified by:
cut in interface Clippable
Returns:
The object to be cut.

getValue

public java.lang.Object getValue()
Returns the value of this object.

Specified by:
getValue in interface Clippable
Returns:
The value of this object (i.e. the printed string).

paste

public void paste(Clippable newFather)
Pastes this object into another.

Specified by:
paste in interface Clippable
Parameters:
newFather - The object to paste this object into.

canBeAttached

public boolean canBeAttached(Clippable newSon)
Checks whether an object can be attached to this one.

Specified by:
canBeAttached in interface Clippable
Parameters:
newSon - The object that is going to be attached to this one.
Returns:
true: the object can be attached; false: otherwise.

duplicate

public Clippable duplicate()
Duplicates (clones) this object.

Specified by:
duplicate in interface Clippable
Returns:
The newly created object.

unclip

public void unclip()
Resets the status of this object.

Specified by:
unclip in interface Clippable

canBeCut

public boolean canBeCut()
Checks whether this object can be cut or not.

Specified by:
canBeCut in interface Clippable
Returns:
true: the object can be cut; false: otherwise.

canBeCopied

public boolean canBeCopied()
Checks whether this object can be copied or not.

Specified by:
canBeCopied in interface Clippable
Returns:
true: the object can be copied; false: otherwise.

setDeleteWhenCut

public void setDeleteWhenCut(boolean value)
Sets the property for "deleting when cut".

Parameters:
value - true: this node deletes itself (removes itself from its parent) when cut; false: the opposite.

getDeleteWhenCut

public boolean getDeleteWhenCut()
Checks whether the node will be deleted when cut.

Returns:
true: this node deletes itself (removes itself from its parent) when cut; false: the opposite.

setDuplicateWhenClipped

public void setDuplicateWhenClipped(boolean value)
Sets the "duplicate when clipped" property.

Parameters:
value - true: the node duplicates itself when clipped (cut or copied); false: the node returns itself.

getDuplicateWhenClipped

public boolean getDuplicateWhenClipped()
Checks whether the node will be duplicated when clipped.

Returns:
true: the node duplicates itself when clipped (cut or copied); false: the node returns itself.

getPlace

public java.lang.Object getPlace()
Returns the tree that contains the node.

Specified by:
getPlace in interface Clippable
Returns:
The object representing the tree containing the node.

setPlace

public void setPlace(java.lang.Object place)
Sets the tree that contains the node (and all of his subnodes).

Specified by:
setPlace in interface Clippable
Parameters:
place - The tree that contains the node.

add

public void add(IndexedTypedTreeNode newChild)
Adds a child to the node.

Parameters:
newChild - The node to add.

insert

public void insert(IndexedTypedTreeNode newChild,
                   int childIndex)
Inserts a child to the node.

Parameters:
newChild - The child to be added.
childIndex - The position in the child list.

remove

public void remove(int childIndex)
Removes a child.

Specified by:
remove in interface javax.swing.tree.MutableTreeNode
Overrides:
remove in class javax.swing.tree.DefaultMutableTreeNode
Parameters:
childIndex - The index of the child to remove.

remove

public void remove(IndexedTypedTreeNode aChild)
Removes a specified child.

Parameters:
aChild - The child to remove.

removeAllChildren

public void removeAllChildren()
Removes all children from this node.

Overrides:
removeAllChildren in class javax.swing.tree.DefaultMutableTreeNode

removeFromParent

public void removeFromParent()
Removes this node from his parent node.

Specified by:
removeFromParent in interface javax.swing.tree.MutableTreeNode
Overrides:
removeFromParent in class javax.swing.tree.DefaultMutableTreeNode

reload

public void reload()
Reloads the node.


expand

public void expand()
Expands the node.


conditionalSetPlace

protected void conditionalSetPlace(javax.swing.tree.TreeNode node,
                                   java.lang.Object place)
Sets a node's tree if it is really a JTree. Otherwise it does nothing.

Parameters:
node - The node to modify.
place - The new tree.

setPlaceForChildren

protected void setPlaceForChildren(java.lang.Object place)
Sets the tree for all children of this node.

Parameters:
place - The tree to be set.