ARoad0.Gui2
Class ACSTreeUtilities

java.lang.Object
  extended by ARoad0.Gui2.ACSTreeUtilities
All Implemented Interfaces:
StaticClass

public class ACSTreeUtilities
extends java.lang.Object
implements StaticClass

This class is responsible for providing useful methods for updating the ACS trees when a base object changes. All methods are static methods.


Field Summary
private static javax.swing.tree.DefaultTreeModel acsTreeModel__
           
private static javax.swing.tree.DefaultMutableTreeNode currentACSNode__
           
private static int INITIAL_CAPACITY
           
private static java.lang.String lineSepar__
           
 
Constructor Summary
private ACSTreeUtilities()
          only one private constructor
 
Method Summary
static javax.swing.tree.DefaultTreeModel addDetailledNameUnderNode(javax.swing.tree.DefaultTreeModel _treeModel, javax.swing.tree.DefaultMutableTreeNode _parentNode, DetailledName _obj, ACS _acs)
          Inserts a detailledName in a DefaultTreeModel, in a flat list under a node, following the natural order of the argument class.
static javax.swing.tree.DefaultTreeModel buildUpGroupTree(ACS _acs, javax.swing.tree.DefaultTreeModel _treeModel, javax.swing.tree.DefaultMutableTreeNode _node, GroupID _group)
          Builds up a subtree for a GroupID.
static javax.swing.tree.DefaultTreeModel buildUpVirtualFolderMembers(javax.swing.tree.DefaultTreeModel _treeModel, javax.swing.tree.DefaultMutableTreeNode _node)
          Builds up the member nodes for a virtual folder.
static javax.swing.tree.DefaultTreeModel buildUpVirtualFolderTree(ACS _acs, javax.swing.tree.DefaultTreeModel _treeModel, javax.swing.tree.DefaultMutableTreeNode _node, ImmutableVirtualFolder _vf)
          Builds up a subtree for a virtual folder, including both the children abd the members.
static javax.swing.tree.DefaultMutableTreeNode getACSTreeMainNode(javax.swing.tree.DefaultTreeModel _treeModel, ACSRun _acs, java.lang.String _title, boolean _forExplorer)
          Gets one of the main nodes in an ACS tree, in the explorer or an another ACS tree.
static javax.swing.tree.DefaultMutableTreeNode getCurrentObjectNode(javax.swing.tree.DefaultMutableTreeNode _rootNode, java.lang.Object _object)
          Gets the first tree node associated to a BaseObject (excepting for a view) in a subtree from a node (in the explorer or another tree).
static javax.swing.tree.DefaultMutableTreeNode getCurrentParent(javax.swing.tree.DefaultMutableTreeNode _rootNode, BaseObject _object)
          Gets the unique parent node associated to a base object (NOT an ACS or a view) in a subtree from a node (in the explorer or another tree).
static javax.swing.tree.DefaultMutableTreeNode getCurrentParentOfVirtualFolderInTree(javax.swing.tree.DefaultMutableTreeNode _rootNode, ImmutableVirtualFolder _vf)
          Gets the parent node of a VirtualFolder in a tree, in the explorer or another ACS tree.
static javax.swing.tree.DefaultMutableTreeNode getDetailledNameNodeInExplorer(DetailledName _object, ImmutableName _aCSname)
          Gets the first tree node associated to a detailled name object in a subtree from a node (in the explorer or another tree).
static javax.swing.tree.DefaultMutableTreeNode getParentOfResource(ImmutableACS _acs, javax.swing.tree.DefaultTreeModel _treeModel, ImmutableResource _resource, boolean _isExplorer)
          Gets the unique parent node to associate to a resource in a subtree from the ACSTree.RESOURCES node (in the explorer or another tree).
static javax.swing.tree.DefaultMutableTreeNode getParentOfSubOrTreeTypedGroupID(javax.swing.tree.DefaultMutableTreeNode _rootNode, ImmutableGroupID _grp)
          Gets the parent node associated to a sub-or-tree-typed group in the explorer or another ACS tree.
static ImmutableName getResourceInTree(ImmutableName _acsName, javax.swing.tree.DefaultMutableTreeNode _node)
          Since the resource in an ACS tree is not the user object of the node, gets the resource through the sequence of Strings from the node 'RESOURCES' which defines the resource name.
protected static boolean isInResourceTree(javax.swing.tree.DefaultMutableTreeNode _node)
          Says if a node in a subtree belongs to the resources tree of an acs, in the explorer or another tree.
static javax.swing.tree.DefaultTreeModel modifyObjectUnderNode(javax.swing.tree.DefaultTreeModel _treeModel, javax.swing.tree.DefaultMutableTreeNode _parentNode, java.lang.Object _obj, boolean _toInsert)
          Inserts or removes a base object in a DefaultTreeModel.
static void removeACSorViewNode(ImmutableName _objectName)
          Removes the node associated to an ACS or a view in the explorer.
static void removeAllChildren(javax.swing.tree.DefaultTreeModel _treeModel, javax.swing.tree.DefaultMutableTreeNode _rootNode)
          Removes all the children of a node in a tree, since DefaultMutableTreeNode.removeAllChildren() does not work.
private static boolean[] setGraphicalGroupIDMembers(GroupID _grp)
          Creates or analyzes the non-null and non-empty members as TreeNodes in a graphical tree, to return the members which have no associated nodes in the ACS tree.
private static boolean[] setGraphicalVirtualFolderChildren(ImmutableVirtualFolder _vf)
          Creates the non-null children as TreeNodes in a graphical tree.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_CAPACITY

private static final int INITIAL_CAPACITY
See Also:
Constant Field Values

lineSepar__

private static java.lang.String lineSepar__

currentACSNode__

private static javax.swing.tree.DefaultMutableTreeNode currentACSNode__

acsTreeModel__

private static javax.swing.tree.DefaultTreeModel acsTreeModel__
Constructor Detail

ACSTreeUtilities

private ACSTreeUtilities()
only one private constructor

Method Detail

removeACSorViewNode

public static final void removeACSorViewNode(ImmutableName _objectName)
Removes the node associated to an ACS or a view in the explorer. Used by ActionClose. Bug sometimes for view removing.

Parameters:
_objectName - of the ACS or the view

removeAllChildren

public static final void removeAllChildren(javax.swing.tree.DefaultTreeModel _treeModel,
                                           javax.swing.tree.DefaultMutableTreeNode _rootNode)
Removes all the children of a node in a tree, since DefaultMutableTreeNode.removeAllChildren() does not work.

Parameters:
_treeModel - of the tree
_rootNode - for which the children have to be removed

modifyObjectUnderNode

public static final javax.swing.tree.DefaultTreeModel modifyObjectUnderNode(javax.swing.tree.DefaultTreeModel _treeModel,
                                                                            javax.swing.tree.DefaultMutableTreeNode _parentNode,
                                                                            java.lang.Object _obj,
                                                                            boolean _toInsert)
Inserts or removes a base object in a DefaultTreeModel. No exception if the objet to remove does not exist. If it is a tree of resources, and to avoid any direct link between the resources in the base and the tree model (to allow lazy loading of resources), the user object in the DefaultMutableTreeNode is the last component of the user object name. Otherwise, the user object is the base object. The detection of the object to insert or to remove uses equals( getName().lastComponent() ) for the resources tree, and otherwise it uses directly equals() to compare it to every object in the tree. If the object to insert is a node (Directory, VirtualFolder) or a group, it sets a new DefaultMutableTreeNode allowing children. Else, no child is allowed. Called by ACSTreeBaseListenerImpl and ActionClose.

Parameters:
_treeModel - of the objects tree
_parentNode - under which the user object is removed or inserted at the end of the list
_obj - to insert or to remove. Never null. Must be a BaseObject if _treeModel is a RESOURCES tree, that is isInResourceTree(_parentNode) returns true.
_toInsert - true to insert, false to remove
Returns:
the updated tree model
See Also:
isInResourceTree(javax.swing.tree.DefaultMutableTreeNode)

addDetailledNameUnderNode

public static final javax.swing.tree.DefaultTreeModel addDetailledNameUnderNode(javax.swing.tree.DefaultTreeModel _treeModel,
                                                                                javax.swing.tree.DefaultMutableTreeNode _parentNode,
                                                                                DetailledName _obj,
                                                                                ACS _acs)
Inserts a detailledName in a DefaultTreeModel, in a flat list under a node, following the natural order of the argument class. The argument is an AclEntry or a Privilege. The method uses compareTo() on the object to insert it at the right place into the current list of children. Then, the same ordering logic is applied at the opening of the ACS and at each adding of a DetailledName, for displaying thelist in the ACS tree. This means the detailled name sorting is not applied, while the user object node is the argument detailled name. Called by ACSTreeBaseListenerImpl.

Parameters:
_treeModel - of the objects tree
_parentNode - under which the user object is removed or inserted at the end of the list
_obj - to insert. Never null.
_acs - ACS of _obj. Never null.
Returns:
the updated tree model
Throws:
java.lang.InternalError - if the argument _obj, or the user object of a _parentNode child, is not a Comparable

getCurrentParent

public static final javax.swing.tree.DefaultMutableTreeNode getCurrentParent(javax.swing.tree.DefaultMutableTreeNode _rootNode,
                                                                             BaseObject _object)
Gets the unique parent node associated to a base object (NOT an ACS or a view) in a subtree from a node (in the explorer or another tree). Used by ACSTreeBaseListenerImpl.changeOneResource and changeOneEligibleParty methods.

Parameters:
_rootNode - in the tree which defines the subtree
_object - displayed only once in the subtree from _rootNode
Returns:
the parent node under _rootNode, or null

getCurrentObjectNode

public static final javax.swing.tree.DefaultMutableTreeNode getCurrentObjectNode(javax.swing.tree.DefaultMutableTreeNode _rootNode,
                                                                                 java.lang.Object _object)
Gets the first tree node associated to a BaseObject (excepting for a view) in a subtree from a node (in the explorer or another tree). If the base object exists more than one time, the result is the FIRST selection through _rootNode.breadthFirstEnumeration(). For exemple, when _rootNode is the root of the explorer and when _object is a resource, the returned node is in the ACS resource tree in the explorer. Does not use object methods from the base, to work after the _object deletion. Used by getCurrentParent(), TreeManager.selectNodeInExplorer(), SimplePropertyEditor, CollectionPropertyEditor, BeamerManager. Calls TreeManager.getTreeNodeInNamingTree().

Parameters:
_rootNode - in the tree which defines the subtree
_object - displayed in the subtree from _rootNode
Returns:
the node for _object, or null

getDetailledNameNodeInExplorer

public static final javax.swing.tree.DefaultMutableTreeNode getDetailledNameNodeInExplorer(DetailledName _object,
                                                                                           ImmutableName _aCSname)
Gets the first tree node associated to a detailled name object in a subtree from a node (in the explorer or another tree). The detailled name does not contains the ACS name, and so it may exist two identical viewable names for two different objects in the tree. When the object exists more than one time, the result is get with the selection of the right ACS, and through an enumeration of all the relevant children in the tree. Used by TreeManager, CollectionPropertyEditor and BeamerManager. Calls getACSTreeMainNode().

Parameters:
_object - is a DetailledName object displayed in the explorer
_aCSname - is the name of the ACS that manages _object
Returns:
the node for _object, or null

getParentOfResource

public static final javax.swing.tree.DefaultMutableTreeNode getParentOfResource(ImmutableACS _acs,
                                                                                javax.swing.tree.DefaultTreeModel _treeModel,
                                                                                ImmutableResource _resource,
                                                                                boolean _isExplorer)
Gets the unique parent node to associate to a resource in a subtree from the ACSTree.RESOURCES node (in the explorer or another tree). Used by ACSTreeBaseListenerImpl.changeOneResource(). Does not use the getEorParent() method of _resource, since the resource is not always fully initialized, but uses the _resource name components to find the parent path in the tree.

Parameters:
_acs - displayed in the ACS tree
_treeModel - of the objects tree
_resource - displayed only once in the subtree from the ACSTree.RESOURCES node
_isExplorer - true if it is in the explorer tree, false if it is in the ACS main frame tree
Returns:
the right future parent node, or null
Throws:
java.lang.InternalError - if the search is aborted

getACSTreeMainNode

public static final javax.swing.tree.DefaultMutableTreeNode getACSTreeMainNode(javax.swing.tree.DefaultTreeModel _treeModel,
                                                                               ACSRun _acs,
                                                                               java.lang.String _title,
                                                                               boolean _forExplorer)
Gets one of the main nodes in an ACS tree, in the explorer or an another ACS tree. The main nodes are defined by ACSTree.M_ACS_TREE_UPPER_NODES. Creates the node before if necessary, and if the ACS displays the main node. Called by ACSTreeBaseListenerImpl methods, ACSTree.createACSExplorer(), getCurrentObjectNode() and getDetailledNameNodeInExplorer().

Parameters:
_treeModel - the explorer tree model, or the ACS tree model if it is for an ACS main frame
_acs - is an ACS or a partial ACSFactoryImpl which is displayed in the acs tree
_title - title or user string, of the required node; it has to be defined in ACSTree.M_ACS_TREE_UPPER_NODES
_forExplorer - true if it is in the explorer tree, false if it is in the ACS main frame tree
Returns:
the required node in the ACS tree. May be null.
See Also:
for the main nodes definitions

buildUpGroupTree

public static final javax.swing.tree.DefaultTreeModel buildUpGroupTree(ACS _acs,
                                                                       javax.swing.tree.DefaultTreeModel _treeModel,
                                                                       javax.swing.tree.DefaultMutableTreeNode _node,
                                                                       GroupID _group)
Builds up a subtree for a GroupID. It is a top-down searching, from the first to the last member of each node. It is rather complex because two trees are managed: the groupIDmember tree from ARoad0.gBase and the TreeNode tree from java.swing. On the contrary of ACSTree.createOwnResourceGraphicalTree(), one groupID object may there be associated to several TreeNodes of the group tree. An another difference is the searching for parent. Here, the Resource.parent_ cannot be used, and TreeNode.parent_ replaces it. Called by ACSTree.createOwnGroupGraphicalTree(),

ACSTree.createExtEligPartyGraphicalTree(),

ACSTreeBaseListenerImpl.changeGroupIDMember().

Calls setGraphicalGroupIDMembers(). When the group is new, it has only an empty member which is not displayed. If the number of levels in the tree exceeds 15, it is probably a bug. In that case, the process stops, the tree is uncomplete and an error message is displayed to the user.

Parameters:
_acs - which owns _group
_treeModel - which owns _node
_node - having children to update
_group - in _acs, associated to _node in _treeModel
Returns:
_treeModel with a subtree of nodes under _node

getResourceInTree

public static final ImmutableName getResourceInTree(ImmutableName _acsName,
                                                    javax.swing.tree.DefaultMutableTreeNode _node)
Since the resource in an ACS tree is not the user object of the node, gets the resource through the sequence of Strings from the node 'RESOURCES' which defines the resource name. Used by ACSTree.createOwnResourceGraphicalTree(), and TreeManager.getTrueUserObjectInTreeExplorer().

Parameters:
_acsName - is the name of the acs which owned the resource
_node - of the resource in the tree
Returns:
the resource name. May be null.

getParentOfSubOrTreeTypedGroupID

public static final javax.swing.tree.DefaultMutableTreeNode getParentOfSubOrTreeTypedGroupID(javax.swing.tree.DefaultMutableTreeNode _rootNode,
                                                                                             ImmutableGroupID _grp)
Gets the parent node associated to a sub-or-tree-typed group in the explorer or another ACS tree. A sub-or-tree-typed group has its type which starts with ' xxx'. It has to be put directly under a TreeNode where the user object has the format '' or ''. Otherwise, the group TreeNode is put directly under _rootNode by other methods. Called by ACSTreeBaseListenerImpl.changeOneEligibleParty() and modifyGroupIDMembers(), ACSTree.createOwnGroupGraphicalTree().

Parameters:
_rootNode - TreeNode to which all the ACS groups are added.
_grp - is a sub-or-tree-typed GroupID to put at the second level of groups in the ACS tree
Returns:
the parent node of the _grp TreeeNode is under _rootNode, or null if _grp is not a typed group

getCurrentParentOfVirtualFolderInTree

public static final javax.swing.tree.DefaultMutableTreeNode getCurrentParentOfVirtualFolderInTree(javax.swing.tree.DefaultMutableTreeNode _rootNode,
                                                                                                  ImmutableVirtualFolder _vf)
Gets the parent node of a VirtualFolder in a tree, in the explorer or another ACS tree. Called by ACSTreeBaseListenerImpl.changeOneEPVirtualFolder(), changeOneResourceVirtualFolder() and changeOneBaseObjectInFolder().

Parameters:
_rootNode - root of one of the two VirtualFolders tree in an ACS tree
_vf - to put in or to remove from the VirtualFolder tree
Returns:
the parent node of the _vf TreeeNode under _rootNode, or null

buildUpVirtualFolderMembers

public static final javax.swing.tree.DefaultTreeModel buildUpVirtualFolderMembers(javax.swing.tree.DefaultTreeModel _treeModel,
                                                                                  javax.swing.tree.DefaultMutableTreeNode _node)
Builds up the member nodes for a virtual folder. Members are not children. Called by ACSTree.createOwnResourceVirtualFolderGraphicalTree(), createOwnEligiblePartyVirtualFolderGraphicalTree(), and ACSTreeListenerImpl.changeOneResource/EPVirtualFolder().

Parameters:
_treeModel - which owns _node; updated by this method
_node - has a VirtualFolder as object, which may have members, and _node has no child for the moment
Returns:
_treeModel updated with the VirtualFolder members under _node

buildUpVirtualFolderTree

public static final javax.swing.tree.DefaultTreeModel buildUpVirtualFolderTree(ACS _acs,
                                                                               javax.swing.tree.DefaultTreeModel _treeModel,
                                                                               javax.swing.tree.DefaultMutableTreeNode _node,
                                                                               ImmutableVirtualFolder _vf)
Builds up a subtree for a virtual folder, including both the children abd the members. It is a top-down searching, from the first to the last member of each node. It is rather complex because two trees and a list are managed:

- the virtual folder subtree from ARoad0.gBase,

- the TreeNode tree from java.swing,

- the virtual folder members as a list from ARoad0.gBase.

Like in ACSTree.createOwnResourceGraphicalTree(), one virtual folder cannot be associated to several TreeNodes in the tree. Called by ACSTree.createOwnResourceVirtualFolderGraphicalTree() and createOwnEligiblePartyVirtualFolderGraphicalTree().

Calls setGraphicalVirtualFolderChildren() and buildUpVirtualFolderMembers() which update acsTreeModel__. This method should not be called if _node has no child (a child is not a folder element).

Parameters:
_acs - which owns _vf
_treeModel - which owns _node; updated by this method
_node - having children to update
_vf - in _acs, user object of _node in _treeModel, and without parent
Returns:
_treeModel updated with a subtree of nodes under _node

isInResourceTree

protected static final boolean isInResourceTree(javax.swing.tree.DefaultMutableTreeNode _node)
Says if a node in a subtree belongs to the resources tree of an acs, in the explorer or another tree. Called by ACSTree.createResourceGraphicalTree(), and TreeManager.analyzeSelectedNodeInExplorer().

Parameters:
_node - in an ACS tree. Never null. May be the RESOURCES node.
Returns:
true if the node is in a resources tree

setGraphicalGroupIDMembers

private static final boolean[] setGraphicalGroupIDMembers(GroupID _grp)
Creates or analyzes the non-null and non-empty members as TreeNodes in a graphical tree, to return the members which have no associated nodes in the ACS tree. This method may be called several times, and it detects if it is the first call or not, to adapt the process. Called by the buildUpGroupTree(). At the return, the static variable currentACSNode__ is the TreeNode associated to the first GroupID in this loop which has not an associated node, if it exists, or else, it is associated to _grp (that is, it is not changed).

Parameters:
_grp - already created as graphical tree node in acsTreeModel__
Returns:
boolean[] that indicates where there is a groupID as _grp member which has no associated node. The array index is that of _grp.getEorL_Members(), not that of the associated currentACSNode__, when null members are removed.

setGraphicalVirtualFolderChildren

private static final boolean[] setGraphicalVirtualFolderChildren(ImmutableVirtualFolder _vf)
Creates the non-null children as TreeNodes in a graphical tree. Called by buildUpVirtualFolderTree(), with strong links through the updating of acsTreeModel__ and currentACSNode__. Caution: at the calling, acsTreeModel__ has to be the right model, currentACSNode__ has to be the node of _vf, and at the end of the method, currentACSNode__ is the node of the first child having children, if any.

Parameters:
_vf - already created as graphical tree node in acsTreeModel__
Returns:
boolean[] that indicates where there are folders with children as _dir children. The array index is from _vf.getEorL_Children(), not from the associated currentACSNode__, where null children are removed. Is null if there is no children.