CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.cubetwister.doc
Class EntityModel

java.lang.Object
  extended by javax.swing.tree.DefaultMutableTreeNode
      extended by ch.randelshofer.cubetwister.doc.EntityModel
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.event.UndoableEditListener, javax.swing.tree.MutableTreeNode, javax.swing.tree.TreeNode
Direct Known Subclasses:
CubeColorsModel, CubePartModel, CubeStickerModel, InfoModel

public class EntityModel
extends javax.swing.tree.DefaultMutableTreeNode
implements java.lang.Cloneable, javax.swing.event.UndoableEditListener

Holds an entity which can be managed by a DocumentModel.

Requires that the root node of the tree managed by DocumentModel is an Entity Model and that its UserObject is the DocumentMdel. This is used to ensure proper listener notifications for object insertion and removal.

Version:
1.1 2006-09-24 Revised.
1.0 2001-10-05
Author:
werni
See Also:
Serialized Form

Field Summary
static java.lang.String PROP_CHILD_COUNT
           
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
EntityModel()
          Creates a new EntityModel.
EntityModel(java.lang.Object userObject, boolean allowsChildren)
          Creates a new EntityModel.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 java.util.Enumeration children()
          Enumerates the children of this entity.
 java.lang.Object clone()
          Returns a shallow copy of this model.
 void dispose()
           
 void fireNodeChanged()
           
 void fireNodeStructureChanged()
           
protected  void firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)
           
protected  void firePropertyChange(java.lang.String propertyName, int oldValue, int newValue)
           
protected  void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
           
protected  void fireUndoableEditHappened(javax.swing.undo.UndoableEdit edit)
          Notify all listeners that have registered interest at the DocumentModel for notification on this event type.
 DocumentModel getDocument()
          Returns the DocumentMdel which holds this model or null if this EntityModel is not part of a document.
protected  boolean hasPropertyListeners()
           
 void insert(javax.swing.tree.MutableTreeNode newChild, int childIndex)
           
 boolean isDefaultCube()
           
 boolean isDefaultNotation()
           
 boolean isRemovable()
          Returns true if the node may be removed from its parent.
 void remove(int childIndex)
           
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void setRemovable(boolean b)
          Sets the 'removable' property.
 java.lang.String toString()
           
 void undoableEditHappened(javax.swing.event.UndoableEditEvent e)
           
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, 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, isLeaf, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PROP_CHILD_COUNT

public static final java.lang.String PROP_CHILD_COUNT
See Also:
Constant Field Values
Constructor Detail

EntityModel

public EntityModel()
Creates a new EntityModel.


EntityModel

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

Method Detail

addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)

firePropertyChange

protected void firePropertyChange(java.lang.String propertyName,
                                  boolean oldValue,
                                  boolean newValue)

firePropertyChange

protected void firePropertyChange(java.lang.String propertyName,
                                  int oldValue,
                                  int newValue)

firePropertyChange

protected void firePropertyChange(java.lang.String propertyName,
                                  java.lang.Object oldValue,
                                  java.lang.Object newValue)

hasPropertyListeners

protected boolean hasPropertyListeners()

getDocument

public DocumentModel getDocument()
Returns the DocumentMdel which holds this model or null if this EntityModel is not part of a document. Assumes that the root node of the tree is an instance of EntityModel and that its user object is the DocumentModel.


fireUndoableEditHappened

protected void fireUndoableEditHappened(javax.swing.undo.UndoableEdit edit)
Notify all listeners that have registered interest at the DocumentModel for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.


fireNodeStructureChanged

public void fireNodeStructureChanged()

fireNodeChanged

public void fireNodeChanged()

clone

public java.lang.Object clone()
Returns a shallow copy of this model. All references to other entitys, are maintained. The new model has no parent but it has all the the children that are required to hold the properties of the entity. The new model has no PropertyChangeListener's.

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

children

public java.util.Enumeration children()
Enumerates the children of this entity.

Specified by:
children in interface javax.swing.tree.TreeNode
Overrides:
children in class javax.swing.tree.DefaultMutableTreeNode

isRemovable

public boolean isRemovable()
Returns true if the node may be removed from its parent.


setRemovable

public void setRemovable(boolean b)
Sets the 'removable' property.

See Also:
isRemovable()

toString

public java.lang.String toString()
Overrides:
toString in class javax.swing.tree.DefaultMutableTreeNode

undoableEditHappened

public void undoableEditHappened(javax.swing.event.UndoableEditEvent e)
Specified by:
undoableEditHappened in interface javax.swing.event.UndoableEditListener

dispose

public void dispose()

insert

public void insert(javax.swing.tree.MutableTreeNode newChild,
                   int childIndex)
Specified by:
insert in interface javax.swing.tree.MutableTreeNode
Overrides:
insert in class javax.swing.tree.DefaultMutableTreeNode

remove

public void remove(int childIndex)
Specified by:
remove in interface javax.swing.tree.MutableTreeNode
Overrides:
remove in class javax.swing.tree.DefaultMutableTreeNode

isDefaultCube

public boolean isDefaultCube()

isDefaultNotation

public boolean isDefaultNotation()

(c) Werner Randelshofer.
All rights reserved.