net.wotonomy.ui.swing
Class DisplayGroupNode

java.lang.Object
  extended by java.util.Observable
      extended by net.wotonomy.ui.EODisplayGroup
          extended by net.wotonomy.ui.swing.DisplayGroupNode
All Implemented Interfaces:
net.wotonomy.control.EOEditingContext.Editor, net.wotonomy.control.EOObserving
Direct Known Subclasses:
MutableDisplayGroupNode

public abstract class DisplayGroupNode
extends net.wotonomy.ui.EODisplayGroup

DisplayGroupNodes are used as nodes in the TreeModelAssociation's implementation of TreeModel, and is tightly coupled with TreeModelAssociation and MasterDetailAssociation.

Even though it is no longer package access, don't rely on this class because we want to have the option of completely replacing this approach in the future.

Version:
$Revision: 904 $
Author:
michael@mpowers.net, $Author: cgruber $

Nested Class Summary
 
Nested classes/interfaces inherited from class net.wotonomy.ui.EODisplayGroup
net.wotonomy.ui.EODisplayGroup.Delegate
 
Field Summary
protected  net.wotonomy.foundation.NSMutableDictionary childNodes
           
protected  boolean isFetched
           
protected  boolean isFetchNeeded
           
protected  TreeModelAssociation parentAssociation
           
protected  net.wotonomy.ui.EODisplayGroup parentGroup
           
protected  java.lang.Object target
           
protected  net.wotonomy.control.EODelayedObserver targetObserver
           
protected  boolean useParentOrderings
           
protected  boolean useParentQualifier
           
 
Fields inherited from class net.wotonomy.ui.EODisplayGroup
allObjects, allObjectsProxy, displayedObjects, displayedObjectsProxy, DisplayGroupWillFetchNotification, selectedIndexes, selectedObjects, selectedObjectsProxy
 
Constructor Summary
DisplayGroupNode(TreeModelAssociation aParentAssociation, net.wotonomy.ui.EODisplayGroup aParentGroup, java.lang.Object aTarget)
          Constructor for all nodes.
 
Method Summary
 java.util.Enumeration children()
           
 boolean deleteObjectAtIndex(int anIndex)
          Overridden to broadcast a tree event after super executes.
protected  void dispose()
          Perform any clean up in this method.
protected  void disposeChildNodes()
          Calls dispose() on all child nodes.
 boolean fetch()
          Overridden to set isFetched to true.
protected  void fireEventsForChanges(java.lang.Object[] oldObjects, java.lang.Object[] newObjects)
          Called by processRecentChanges to analyze the differences between the lists and broadcast the appropriate events.
 void fireNodeChanged()
          Fires a change event for this node.
protected  void fireNodesChanged(java.lang.Object[] path, int[] indexes, java.lang.Object[] objects)
          Subclasses should override this method to fire an appropriate change event.
protected  void fireNodesInserted(java.lang.Object[] path, int[] indexes, java.lang.Object[] objects)
          Subclasses should override this method to fire an appropriate insertion event.
protected  void fireNodesRemoved(java.lang.Object[] path, int[] indexes, java.lang.Object[] objects)
          Subclasses should override this method to fire an appropriate deletion event.
protected  void fireStructureChanged(java.lang.Object[] path, int[] indexes, java.lang.Object[] objects)
          Subclasses should override this method to fire an appropriate event.
 boolean getAllowsChildren()
           
 int getChildCount()
           
 DisplayGroupNode getChildNodeAt(int anIndex)
          Returns the child node that corresponds to the specified index, creating it if necessary.
protected  DisplayGroupNode getChildNodeForObject(java.lang.Object anObject)
          Returns a child node that corresponds to the specified object, returning null if not found.
 java.util.List getDescendants()
          Gets all descendants of the this node.
 int getIndex(DisplayGroupNode node)
           
 java.util.List getLoadedDescendants()
          Gets only the descendants of the this node whose children has been loaded - no fetching will occur.
 DisplayGroupNode getParentGroup()
          Returns the parent display group, or null if parent is root.
 java.lang.Object getUserObject()
          Returns the value of the displayed property in the parent display group at the index that corresponds to the index of this node.
 void insert(DisplayGroupNode aChild, int anIndex)
           
 void insertObjectAtIndex(java.lang.Object anObject, int anIndex)
          Overridden to broadcast a tree event after super executes.
protected  boolean isFetched()
          Returns whether the node should call fetch().
protected  boolean isFetchNeeded()
          Returns whether the node is in need of a refetch.
 boolean isLeaf()
           
 java.lang.Object object()
          Returns the object at the appropriate index in the parent display group.
 void objectsInvalidatedInEditingContext(net.wotonomy.foundation.NSNotification aNotification)
          Overridden to not fetch on InvalidateAllObjectsInStoreNotification unless we've already been fetched, preserving the load-on-demand functionality.
 net.wotonomy.control.EOQualifier qualifier()
          Overridden to return the parent group's qualifier if useParentQualifier is true.
 void remove(DisplayGroupNode node)
          Removes the node at the index corresponding to the index of the object.
 void remove(int index)
           
 void removeFromParent()
          Removes our object from the parent display group.
 void setDataSource(net.wotonomy.control.EODataSource aDataSource)
          Overridden to unregister as an editor of the editing context, since we don't directly present a user interface.
protected  void setFetched(boolean fetched)
          Sets whether the node should call fetch().
protected  void setFetchNeeded(boolean fetchNeeded)
          Returns whether the node should call fetch().
 void setParent(DisplayGroupNode newParent)
          Removes our object from the parent display group and adds it to the end of the specified node's children.
 void setQualifier(net.wotonomy.control.EOQualifier aQualifier)
          Overridden to set useParentQualifier to false, or true if aList is null.
 void setSortOrderings(java.util.List aList)
          Overridden to set useParentOrderings to false, or true if aList is null.
 void setTarget(java.lang.Object aTarget)
          Sets the target object and creates an registers a target observer.
 void setUserObject(java.lang.Object aValue)
          Sets the value of the displayed property in the parent display group at the index that corresponds to the index of this node.
 void setValueForKey(java.lang.Object aValue, java.lang.String aKey)
          Sets a value on the object in the parent display group at the index that corresponds to the index of this node.
 net.wotonomy.foundation.NSArray sortOrderings()
          Overridden to return the parent group's sort ordering if useParentOrderings is true.
 void targetChanged()
          Called after the target object posts a change notification.
 java.lang.String toString()
          Returns the string value of the title property on the object in the parent display group corresponding to this index.
 javax.swing.tree.TreePath treePath()
          Returns a tree path of all DisplayGroupNodes leading to this node, including the root node (but excluding the titles display group).
 void updateDisplayedObjects()
          Overridden to call to super, fire any tree events, and then call updateDisplayedObjects on all fetched child nodes.
 java.lang.Object valueForKey(java.lang.String aKey)
          Returns a value from the object in the parent display group at the index that corresponds to the index of this node.
 
Methods inherited from class net.wotonomy.ui.EODisplayGroup
allObjects, associationDidBeginEditing, associationDidEndEditing, associationFailedToValidateValue, clearSelection, contentsChanged, dataSource, defaultStringMatchFormat, defaultStringMatchOperator, delegate, deleteSelection, displayedObjects, editingAssociation, editingContextPresentErrorMessage, editingContextShouldContinueFetching, editingContextWillSaveChanges, editorHasChangesForEditingContext, enabledToSetSelectedObjectValueForKey, endEditing, enterQueryMode, equalToQueryValues, fetchesOnLoad, globalDefaultForValidatesChangesImmediately, globalDefaultStringMatchFormat, globalDefaultStringMatchOperator, greaterThanQueryValues, inQueryMode, insertedObjectDefaultValues, insertNewObjectAtIndex, lessThanQueryValues, localKeys, objectWillChange, observingAssociations, processRecentChanges, qualifierFromQueryValues, qualifyDataSource, qualifyDisplayGroup, queryBindingValues, queryOperatorValues, redisplay, selectedObject, selectedObjects, selectedObjectValueForKey, selectionChanged, selectionIndexes, selectNext, selectObject, selectObjectsIdenticalTo, selectPrevious, selectsFirstObjectAfterFetch, setDefaultStringMatchFormat, setDefaultStringMatchOperator, setDelegate, setEqualToQueryValues, setFetchesOnLoad, setGlobalDefaultForValidatesChangesImmediately, setGlobalDefaultStringMatchFormat, setGlobalDefaultStringMatchOperator, setGreaterThanQueryValues, setInQueryMode, setInsertedObjectDefaultValues, setLessThanQueryValues, setLocalKeys, setObjectArray, setQueryBindingValues, setQueryOperatorValues, setSelectedObject, setSelectedObjects, setSelectedObjectValue, setSelectionIndexes, setSelectsFirstObjectAfterFetch, setUsesOptimisticRefresh, setValidatesChangesImmediately, setValueForObject, setValueForObjectAtIndex, updatedObjectIndex, usesOptimisticRefresh, validatesChangesImmediately, valueForObject, valueForObjectAtIndex, willChange
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

parentAssociation

protected TreeModelAssociation parentAssociation

targetObserver

protected net.wotonomy.control.EODelayedObserver targetObserver

childNodes

protected net.wotonomy.foundation.NSMutableDictionary childNodes

parentGroup

protected net.wotonomy.ui.EODisplayGroup parentGroup

target

protected java.lang.Object target

isFetched

protected boolean isFetched

isFetchNeeded

protected boolean isFetchNeeded

useParentOrderings

protected boolean useParentOrderings

useParentQualifier

protected boolean useParentQualifier
Constructor Detail

DisplayGroupNode

public DisplayGroupNode(TreeModelAssociation aParentAssociation,
                        net.wotonomy.ui.EODisplayGroup aParentGroup,
                        java.lang.Object aTarget)
Constructor for all nodes. Root node must have a null target.

Method Detail

setDataSource

public void setDataSource(net.wotonomy.control.EODataSource aDataSource)
Overridden to unregister as an editor of the editing context, since we don't directly present a user interface.

Overrides:
setDataSource in class net.wotonomy.ui.EODisplayGroup

isFetched

protected boolean isFetched()
Returns whether the node should call fetch().


setFetched

protected void setFetched(boolean fetched)
Sets whether the node should call fetch().


isFetchNeeded

protected boolean isFetchNeeded()
Returns whether the node is in need of a refetch.


setFetchNeeded

protected void setFetchNeeded(boolean fetchNeeded)
Returns whether the node should call fetch().


fireNodesInserted

protected void fireNodesInserted(java.lang.Object[] path,
                                 int[] indexes,
                                 java.lang.Object[] objects)
Subclasses should override this method to fire an appropriate insertion event.


fireNodesChanged

protected void fireNodesChanged(java.lang.Object[] path,
                                int[] indexes,
                                java.lang.Object[] objects)
Subclasses should override this method to fire an appropriate change event.


fireNodesRemoved

protected void fireNodesRemoved(java.lang.Object[] path,
                                int[] indexes,
                                java.lang.Object[] objects)
Subclasses should override this method to fire an appropriate deletion event.


fireStructureChanged

protected void fireStructureChanged(java.lang.Object[] path,
                                    int[] indexes,
                                    java.lang.Object[] objects)
Subclasses should override this method to fire an appropriate event.


insertObjectAtIndex

public void insertObjectAtIndex(java.lang.Object anObject,
                                int anIndex)
Overridden to broadcast a tree event after super executes.

Overrides:
insertObjectAtIndex in class net.wotonomy.ui.EODisplayGroup

deleteObjectAtIndex

public boolean deleteObjectAtIndex(int anIndex)
Overridden to broadcast a tree event after super executes.

Overrides:
deleteObjectAtIndex in class net.wotonomy.ui.EODisplayGroup

getChildNodeAt

public DisplayGroupNode getChildNodeAt(int anIndex)
Returns the child node that corresponds to the specified index, creating it if necessary. The index must be within bounds or an exception is thrown.


getChildNodeForObject

protected DisplayGroupNode getChildNodeForObject(java.lang.Object anObject)
Returns a child node that corresponds to the specified object, returning null if not found.


treePath

public javax.swing.tree.TreePath treePath()
Returns a tree path of all DisplayGroupNodes leading to this node, including the root node (but excluding the titles display group).


sortOrderings

public net.wotonomy.foundation.NSArray sortOrderings()
Overridden to return the parent group's sort ordering if useParentOrderings is true. useParentOrderings is true by default.

Overrides:
sortOrderings in class net.wotonomy.ui.EODisplayGroup

setSortOrderings

public void setSortOrderings(java.util.List aList)
Overridden to set useParentOrderings to false, or true if aList is null.

Overrides:
setSortOrderings in class net.wotonomy.ui.EODisplayGroup

qualifier

public net.wotonomy.control.EOQualifier qualifier()
Overridden to return the parent group's qualifier if useParentQualifier is true. useParentQualifier is true by default.

Overrides:
qualifier in class net.wotonomy.ui.EODisplayGroup

setQualifier

public void setQualifier(net.wotonomy.control.EOQualifier aQualifier)
Overridden to set useParentQualifier to false, or true if aList is null.

Overrides:
setQualifier in class net.wotonomy.ui.EODisplayGroup

fetch

public boolean fetch()
Overridden to set isFetched to true.

Overrides:
fetch in class net.wotonomy.ui.EODisplayGroup

object

public java.lang.Object object()
Returns the object at the appropriate index in the parent display group.


toString

public java.lang.String toString()
Returns the string value of the title property on the object in the parent display group corresponding to this index. The tree renderer asks JTrees to call this method to retrieve a value for display.

Overrides:
toString in class net.wotonomy.ui.EODisplayGroup

getChildCount

public int getChildCount()

getIndex

public int getIndex(DisplayGroupNode node)

getAllowsChildren

public boolean getAllowsChildren()

isLeaf

public boolean isLeaf()

children

public java.util.Enumeration children()

insert

public void insert(DisplayGroupNode aChild,
                   int anIndex)

remove

public void remove(int index)

remove

public void remove(DisplayGroupNode node)
Removes the node at the index corresponding to the index of the object.


removeFromParent

public void removeFromParent()
Removes our object from the parent display group.


setParent

public void setParent(DisplayGroupNode newParent)
Removes our object from the parent display group and adds it to the end of the specified node's children.


getUserObject

public java.lang.Object getUserObject()
Returns the value of the displayed property in the parent display group at the index that corresponds to the index of this node.


setUserObject

public void setUserObject(java.lang.Object aValue)
Sets the value of the displayed property in the parent display group at the index that corresponds to the index of this node.


valueForKey

public java.lang.Object valueForKey(java.lang.String aKey)
Returns a value from the object in the parent display group at the index that corresponds to the index of this node. For the root node, if the titles key is specified, the root label is returned, otherwise null is returned.


setValueForKey

public void setValueForKey(java.lang.Object aValue,
                           java.lang.String aKey)
Sets a value on the object in the parent display group at the index that corresponds to the index of this node. For the root node, this method only works if aKey is the titlesAspect's key, otherwise does nothing.


dispose

protected void dispose()
Perform any clean up in this method. The node will not be reused after this method is called. This implementation removes itself from the parent's set of child nodes, sets target and datasource to null, and then calls disposeChildNodes().


disposeChildNodes

protected void disposeChildNodes()
Calls dispose() on all child nodes.


targetChanged

public void targetChanged()
Called after the target object posts a change notification. This implementation re-fetches which triggers updateDisplayedObjects to broadcast any tree events. This method marks the parent object as changed if: (1) this object is not registered in the editing context of the titles display group's data source (if any), AND (2) the children key is not in the list of attributes of the parent object's EOClassDescription.


fireNodeChanged

public void fireNodeChanged()
Fires a change event for this node.


updateDisplayedObjects

public void updateDisplayedObjects()
Overridden to call to super, fire any tree events, and then call updateDisplayedObjects on all fetched child nodes. This method compares this node's displayed objects against the list of child nodes, synchronizes them, and then broadcasts only the necessary events to bring the view component up to date.

Overrides:
updateDisplayedObjects in class net.wotonomy.ui.EODisplayGroup

fireEventsForChanges

protected void fireEventsForChanges(java.lang.Object[] oldObjects,
                                    java.lang.Object[] newObjects)
Called by processRecentChanges to analyze the differences between the lists and broadcast the appropriate events.


setTarget

public void setTarget(java.lang.Object aTarget)
Sets the target object and creates an registers a target observer. If target was not previously null, the existing observer is unregistered. Protected access so subclasses and TreeModelAssociation can update our target.


getParentGroup

public DisplayGroupNode getParentGroup()
Returns the parent display group, or null if parent is root.


getDescendants

public java.util.List getDescendants()
Gets all descendants of the this node.


getLoadedDescendants

public java.util.List getLoadedDescendants()
Gets only the descendants of the this node whose children has been loaded - no fetching will occur. Useful for load-on-demand trees.


objectsInvalidatedInEditingContext

public void objectsInvalidatedInEditingContext(net.wotonomy.foundation.NSNotification aNotification)
Overridden to not fetch on InvalidateAllObjectsInStoreNotification unless we've already been fetched, preserving the load-on-demand functionality.

Overrides:
objectsInvalidatedInEditingContext in class net.wotonomy.ui.EODisplayGroup


Copyright © 2006 null. All Rights Reserved.