ARoad0.Gui2
Class ACSTreeBaseListenerImpl

java.lang.Object
  extended by ARoad0.Gui2.ACSTreeBaseListenerImpl
All Implemented Interfaces:
BaseListener, TreeBaseListener, MVC_Controller, java.beans.PropertyChangeListener, java.util.EventListener

public class ACSTreeBaseListenerImpl
extends java.lang.Object
implements TreeBaseListener

This class is responsible for listening the events fired by one ACSRun - and also the events fired by the ACSRun objects - for updating the unique JTree which is associated to this TreeBaseListener, and which displays the ACSRun objects. Called by Gui2.ACSTree for the explorer and the own acs tree frame. Handles 'OneResource', 'OneEligibleParty', 'OneExternalEligibleParty', 'OneExternalResource', 'l_Members', 'AclEntry', 'OneAcsRight', 'OnePrivilege', 'OneResourceVirtualFolder', 'OneEPVirtualFolder', 'OneBaseObjectInFolder', 'OneTypedPrivilege', 'OneLinkedPrivilege', 'OneLinkedPrivilegeSource', 'OneLinkedPrivilegeTarget' events from the base. When the ACSRun is a partial ACSFactory, only 'OneAcsRight' is operational. If two event changes are fired for the same removing event, this class produces a NullPointException in ACSTreeUtilities. It is a good way to detect bugs!

The creation of a new Resource which is a Directory child produces 2 events 'OneResource' and 'Children'. These 2 events are fired in any order. This is depending on the constructor or the copy method which is used, and 'Children' is asynchronously used by the CollectionPropertyEditor. It is the same logic with 'OneResourceVirtualFolder' and 'OneEPVirtualFolder', which may be associated to 'Children' events when the virtual folder is deleted or created.

Each event source is registered only once. The ACSRun closing operations are not managed, since these operations are handled in Gui1/Gui2, in the gDMak classes ActionClose and ActionOpen, and by TreeManager in Gui2. The ACSRun opening and closing operations are indirectly listened if it adds or removes some external oriented AclEntry.


Field Summary
private  ACSRun acs_
          ACS associated to the JTree
static ACSTreeBaseListenerImpl EMPTY_INSTANCE
          A reusable empty instance for initialization, to avoid the use of 'new' for temporary values.
private static int INITIAL_CAPACITY
           
private  boolean isExplorer_
           
private  java.util.List l_eventSources_
          list of ACSObjects firing PropertyChangeEvents
private  boolean listenEvents_
           
private static int PRIME
           
private  javax.swing.tree.DefaultMutableTreeNode root_
          root node of the JTree
private  javax.swing.JTree tree_
          the JTree
private  javax.swing.tree.DefaultTreeModel treeModel_
          tree model of the JTree
 
Constructor Summary
ACSTreeBaseListenerImpl()
          Public constructor.
ACSTreeBaseListenerImpl(ACSRun _source, javax.swing.JTree _tree, javax.swing.tree.MutableTreeNode _root)
          With this constructor, the ACSTreeBaseListenerImpl is registered as a listener for an ACSRun firing PropertyChangeEvents, and is associated to one JTree.
 
Method Summary
private  void changeExternalEligibleParty(java.beans.PropertyChangeEvent _evt)
          Processes event from ACS about 'OneExternalEligibleParty' updatings for objects which belong to another ACS than acs_.
private  void changeExternalResource(java.beans.PropertyChangeEvent _evt)
          Processes event from ACS about 'OneExternalResource' updatings for objects which belong to another ACS than acs_.
private  void changeGroupIDMembers(java.beans.PropertyChangeEvent _evt)
          Processes event from ACSRun about 'l_Members' updates for one GroupID.
private  void changeOneAclEntry(java.beans.PropertyChangeEvent _evt)
          Processes event from ACSRun about 'AclEntry' updates.
private  void changeOneAcsRight(java.beans.PropertyChangeEvent _evt)
          Processes event from ACSRun about 'OneAcsRight' updates.
private  void changeOneBaseObjectInFolder(java.beans.PropertyChangeEvent _evt)
          Processes event from VirtualFolder about 'OneBaseObjectInFolder' updates.
private  void changeOneEligibleParty(java.beans.PropertyChangeEvent _evt)
          Processes event from ACSRun about 'OneEligibleParty' updates.
private  void changeOneEPVirtualFolder(java.beans.PropertyChangeEvent _evt)
          Processes event from ACS about 'OneEPVirtualFolder' updates.
private  void changeOneOwnActor(ImmutableActor _ep, boolean _toInsert)
          Updates the ACS tree when one actor is created or removed.
private  void changeOnePrivilege(java.beans.PropertyChangeEvent _evt)
          Processes an event from ACSRun about 'OneTypedPrivilege' and 'OneLinkedPrivilege' updates.
private  void changeOneResource(java.beans.PropertyChangeEvent _evt)
          Processes event from ACSRun about 'OneResource' updates.
private  void changeOneResourceVirtualFolder(java.beans.PropertyChangeEvent _evt)
          Processes event from ACS about 'OneResourceVirtualFolder' updates.
private  void changeOpenACS(java.beans.PropertyChangeEvent _evt)
          Processes events from BaseManagerImpl about 'openACS' updates only for ACS closings.
private  void changeOwnEPasMemberOfGroupIDs(ImmutableEligibleParty _ep, boolean _toInsert)
          Updates the ACS tree when one userID or groupID is created or removed, and when it is a direct member of one or several groupIDs.
 void finalizeForUser()
          Unregisters the instance as a listener for all registered sources.
 ImmutableName getEorMainEventSource()
          Gets the main event source associated to the instance in its construction.
 javax.swing.tree.MutableTreeNode getEorRoot()
          Gets the TreeModel root associated to the instance in its construction.
 javax.swing.tree.DefaultTreeModel getEorTreeModel()
          Gets the TreeModel associated to the ACS tree instance in its construction.
private  void modifyExternalEpInTree(ImmutableEligibleParty _ep, boolean _toInsert)
          Inserts ou removes an external EligibleParty in treeModel_, under the 3 subtrees which handle the external eligible parties.
private  void modifyExternalResourceInTree(ImmutableResource _res, boolean _toInsert)
          Inserts ou removes an external Resource in treeModel_, under the 5 subtrees which handle it the external resources.
private  void modifyGroupIDMembers(ImmutableGroupID _grp)
          Updates the ACS tree when a groupID has members, through the selection of the first node that has the argument as user object.
 void propertyChange(java.beans.PropertyChangeEvent _evt)
          Receives the source events about property changes on 'OneExternalEligibleParty', 'OneExternalResource', 'OneResource', 'OneEligibleParty', 'l_Members', 'AclEntry', 'OneAcsRight', 'OnePrivilege', 'OneResourceVirtualFolder', 'OneEPVirtualFolder', 'OneBaseObjectInFolder', 'OneTypedPrivilege', 'OneLinkedPrivilege', 'OneLinkedPrivilegeSource', 'OneLinkedPrivilegeTarget'.
 boolean setListenEvents(boolean _listen)
          To listen or not the events in propertyChange().
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ARoad0.Gui2.BaseListener
hashCode
 

Field Detail

PRIME

private static final int PRIME
See Also:
Constant Field Values

INITIAL_CAPACITY

private static final int INITIAL_CAPACITY
See Also:
Constant Field Values

l_eventSources_

private java.util.List l_eventSources_
list of ACSObjects firing PropertyChangeEvents


acs_

private ACSRun acs_
ACS associated to the JTree


tree_

private javax.swing.JTree tree_
the JTree


treeModel_

private javax.swing.tree.DefaultTreeModel treeModel_
tree model of the JTree


root_

private javax.swing.tree.DefaultMutableTreeNode root_
root node of the JTree


isExplorer_

private boolean isExplorer_

listenEvents_

private boolean listenEvents_

EMPTY_INSTANCE

public static final ACSTreeBaseListenerImpl EMPTY_INSTANCE
A reusable empty instance for initialization, to avoid the use of 'new' for temporary values. Caution: never change the state of the returned instance.

Constructor Detail

ACSTreeBaseListenerImpl

public ACSTreeBaseListenerImpl()
Public constructor.


ACSTreeBaseListenerImpl

public ACSTreeBaseListenerImpl(ACSRun _source,
                               javax.swing.JTree _tree,
                               javax.swing.tree.MutableTreeNode _root)
                        throws ProcessError
With this constructor, the ACSTreeBaseListenerImpl is registered as a listener for an ACSRun firing PropertyChangeEvents, and is associated to one JTree. For each GroupID, registers this instance as a listener of the member changes. For each VirtualFolder, listens the 'OneBaseObjectInFolder' events. For each Privilege, listens 'OneTypedPrivilege', 'OneLinkedPrivilege', 'OneLinkedPrivilegeSource' and 'OneLinkedPrivilegeTarget' events.

Parameters:
_source - of PropertyChangeEvents; an ACS or a partial ACSFactory
_tree - associated to the instance
_root - associated to _source in _tree
Throws:
ProcessError - if _source is null
Method Detail

getEorMainEventSource

public ImmutableName getEorMainEventSource()
Gets the main event source associated to the instance in its construction.

Specified by:
getEorMainEventSource in interface BaseListener
Returns:
name of the main source for PropertyChangeEvents. May be null.

setListenEvents

public boolean setListenEvents(boolean _listen)
To listen or not the events in propertyChange(). No use.

Specified by:
setListenEvents in interface BaseListener
Parameters:
_listen - true to listen the events in this instance, through propertyChange()
Returns:
true if the previous value was different to this argument

getEorTreeModel

public javax.swing.tree.DefaultTreeModel getEorTreeModel()
Gets the TreeModel associated to the ACS tree instance in its construction.

Specified by:
getEorTreeModel in interface TreeBaseListener
Returns:
DefaultTreeModel associated to the instance and to a JTree

getEorRoot

public javax.swing.tree.MutableTreeNode getEorRoot()
Gets the TreeModel root associated to the instance in its construction.

Specified by:
getEorRoot in interface TreeBaseListener
Returns:
MutableTreeNode associated to the instance in the TreeModel

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent _evt)
Receives the source events about property changes on 'OneExternalEligibleParty', 'OneExternalResource', 'OneResource', 'OneEligibleParty', 'l_Members', 'AclEntry', 'OneAcsRight', 'OnePrivilege', 'OneResourceVirtualFolder', 'OneEPVirtualFolder', 'OneBaseObjectInFolder', 'OneTypedPrivilege', 'OneLinkedPrivilege', 'OneLinkedPrivilegeSource', 'OneLinkedPrivilegeTarget'. Throw InternalError if both the old and the new values are non null, or if the two are null. Calls the appropriate private method.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
_evt - PropertyChangeEvent

changeExternalEligibleParty

private void changeExternalEligibleParty(java.beans.PropertyChangeEvent _evt)
Processes event from ACS about 'OneExternalEligibleParty' updatings for objects which belong to another ACS than acs_.

Parameters:
_evt - PropertyChangeEvent

changeExternalResource

private void changeExternalResource(java.beans.PropertyChangeEvent _evt)
Processes event from ACS about 'OneExternalResource' updatings for objects which belong to another ACS than acs_.

Parameters:
_evt - PropertyChangeEvent

changeOneResource

private void changeOneResource(java.beans.PropertyChangeEvent _evt)
Processes event from ACSRun about 'OneResource' updates. Doesn't control the new value. Processes actor creation, but do not process actor deletion which is the responsability of changeOneEligibleParty(), before this method call. Does not process the external resource updates, which is processed through the 'ExternalOrientedAclEntry' event.

Parameters:
_evt - PropertyChangeEvent
See Also:
changeOneEligibleParty(java.beans.PropertyChangeEvent), ACSTreeUtilities

changeOneEligibleParty

private void changeOneEligibleParty(java.beans.PropertyChangeEvent _evt)
Processes event from ACSRun about 'OneEligibleParty' updates. Doesn't control the new value. Processes also Actors updates, but does not process the external EligibleParty updatings. If it is a GroupID to delete, unregisters this instance as a listener of member changes. The registration is done by ActionNewEligibleParty. If it is a to-display typed GroupID, manages its position under the right second node. When the EligibleParty ep is an userID or a groupID to delete or to add, this method used ep.getEorL_GroupID() to define the groups to update, then calls changeOwnEPasMemberOfGroupIDs() which removes all these groups in the EligibleParty. No action if a relevant main node (as ACSTree.GROUPS) is not displayed.

Parameters:
_evt - about an 'OneEligibleParty' update
See Also:
changeOneResource(java.beans.PropertyChangeEvent)

changeOneOwnActor

private void changeOneOwnActor(ImmutableActor _ep,
                               boolean _toInsert)
Updates the ACS tree when one actor is created or removed. The update for a creation in the 'Resources' node has already be done through a 'OneResource' event. The actor can't be a direct member of several groupIDs. Called by changeOneEligibleParty(). No action if ACSTree.RESOURCES and ACSTree.ACTORS are not displayed. For this method, acs_ may be cast as ImmutableACS.

Parameters:
_ep - the instance created or removed.
_toInsert - true if the instance is created

changeOneAclEntry

private void changeOneAclEntry(java.beans.PropertyChangeEvent _evt)
Processes event from ACSRun about 'AclEntry' updates. May be an internal or an external-oriented AclEntry. Doesn't control the value of a new AclEntry. No action if it is not an acs_ AclEntry. For removing, the AclEntry in _evt is a clone of the AclEntry to remove.

Parameters:
_evt - PropertyChangeEvent

changeOneAcsRight

private void changeOneAcsRight(java.beans.PropertyChangeEvent _evt)
Processes event from ACSRun about 'OneAcsRight' updates. Doesn't control the new value. No action if a relevant main node (as ACSTree.ACSRIGHTS) is not displayed.

Parameters:
_evt - PropertyChangeEvent
See Also:
changeOneResource(java.beans.PropertyChangeEvent)

changeOwnEPasMemberOfGroupIDs

private void changeOwnEPasMemberOfGroupIDs(ImmutableEligibleParty _ep,
                                           boolean _toInsert)
Updates the ACS tree when one userID or groupID is created or removed, and when it is a direct member of one or several groupIDs. Each of these groupIDs may be associated to several nodes in the tree, so they are all removed then built up. Called by the changeOneEligibleParty method. Calls ACSTreeUtilities.buildUpGroupTree(). No action if ACSTree.GROUPS is not displayed.

Parameters:
_ep - the instance created or removed
_toInsert - true if the instance is created

changeOpenACS

private void changeOpenACS(java.beans.PropertyChangeEvent _evt)
Processes events from BaseManagerImpl about 'openACS' updates only for ACS closings. Used if there is some ACS closings after an user command to close an ancestor ACS.

Parameters:
_evt - PropertyChangeEvent

modifyExternalEpInTree

private void modifyExternalEpInTree(ImmutableEligibleParty _ep,
                                    boolean _toInsert)
Inserts ou removes an external EligibleParty in treeModel_, under the 3 subtrees which handle the external eligible parties. Does not modify the flat list of AclEntries or Privileges in the tree. No operation under a subtree if the 'External Eligible Parties' subtree is not displayed. Called by changeExternalEligibleParty().

Parameters:
_ep - to insert or to remove
_toInsert - true to insert, false to remove

modifyExternalResourceInTree

private void modifyExternalResourceInTree(ImmutableResource _res,
                                          boolean _toInsert)
Inserts ou removes an external Resource in treeModel_, under the 5 subtrees which handle it the external resources. Does not modify the flat list of AclEntries or Privileges in the tree. No operation under a subtree if the 'External Controlled Resources' subtree is not displayed in the ACS tree. Called by changeExternalResource().

Parameters:
_res - external resource to insert or to remove
_toInsert - true to insert, false to remove

changeGroupIDMembers

private void changeGroupIDMembers(java.beans.PropertyChangeEvent _evt)
Processes event from ACSRun about 'l_Members' updates for one GroupID. Calls modifyGroupIDMembers(). No action if a relevant main node (as ACSTree.GROUPS) is not displayed.

Parameters:
_evt - PropertyChangeEvent
See Also:
changeOneResource(java.beans.PropertyChangeEvent)

modifyGroupIDMembers

private void modifyGroupIDMembers(ImmutableGroupID _grp)
Updates the ACS tree when a groupID has members, through the selection of the first node that has the argument as user object. Does not process all the groupID tree under the node that is associated to _grp. If it is a to-display typed GroupID, manage its position under the right second node. Called by changeGroupIDMembers(). Calls ACSTreeUtilities.getACSTreeMainNode() and buildUpGroupTree(). No action if ACSTree.GROUPS is not displayed.

Parameters:
_grp - the instance with some members

changeOnePrivilege

private void changeOnePrivilege(java.beans.PropertyChangeEvent _evt)
Processes an event from ACSRun about 'OneTypedPrivilege' and 'OneLinkedPrivilege' updates. Doesn't control the new value. No action if a relevant main node (as ACSTree.PRIVILEGES) is not displayed.

Parameters:
_evt - PropertyChangeEvent

changeOneResourceVirtualFolder

private void changeOneResourceVirtualFolder(java.beans.PropertyChangeEvent _evt)
Processes event from ACS about 'OneResourceVirtualFolder' updates. Doesn't control the new value. Builds up the member nodes if necessary. Manage the VirtualFolders tree. No action if a relevant main node (as ACSTree.ACSRIGHTS) is not displayed.

Parameters:
_evt - PropertyChangeEvent
See Also:
changeOneResource(java.beans.PropertyChangeEvent)

changeOneEPVirtualFolder

private void changeOneEPVirtualFolder(java.beans.PropertyChangeEvent _evt)
Processes event from ACS about 'OneEPVirtualFolder' updates. Doesn't control the new value. Builds up the member nodes if necessary. Manage the VirtualFolders tree. No action if a relevant main node (as ACSTree.ACSRIGHTS) is not displayed.

Parameters:
_evt - PropertyChangeEvent
See Also:
changeOneResource(java.beans.PropertyChangeEvent)

changeOneBaseObjectInFolder

private void changeOneBaseObjectInFolder(java.beans.PropertyChangeEvent _evt)
Processes event from VirtualFolder about 'OneBaseObjectInFolder' updates. Doesn't control the new value. No action if a relevant main node (as ACSTree.ACSRIGHTS) is not displayed.

Parameters:
_evt - PropertyChangeEvent
See Also:
changeOneResource(java.beans.PropertyChangeEvent)

finalizeForUser

public void finalizeForUser()
Unregisters the instance as a listener for all registered sources. Sets the variables to null.

Specified by:
finalizeForUser in interface BaseListener

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
String