ARoad0.Gui2
Class TreeManager

java.lang.Object
  extended by ARoad0.Gui2.TreeManager
All Implemented Interfaces:
MVC_Model, StaticClass

public class TreeManager
extends java.lang.Object
implements MVC_Model, StaticClass

This class is responsible for managing viewable trees for an ACS or a view, and more precisely the TreeBaseListeners associated to these trees, and for managing the Explorer tree creation. It does not handle the creation of the global structure tree, but manages its tree listener. It is invoked by several Action classes. All methods are static, following the StaticClass pattern.


Field Summary
static java.lang.String DENYING_RIGHTS
           
static javax.swing.tree.DefaultMutableTreeNode EMPTY_TREE_NODE
           
static java.lang.String FULL_VIEWS
           
static java.lang.String GRANTING_RIGHTS
           
private static int INITIAL_CAPACITY
           
private static java.util.List l_treeBaseListener__
           
static java.util.Map M_EXPLORER_UPPER_NODES
           
static java.lang.String META_RIGHTS
           
static java.lang.String NOTHAN_VIEWS
           
static java.lang.String OPEN_ACS
           
static java.lang.String OPEN_ENTITIES
           
static java.lang.String OPEN_VIEWS
           
static Name STRUCTURE_ROOT_NAME
           
 
Constructor Summary
private TreeManager()
          only one private constructor
 
Method Summary
static void addTreeBaseListener(TreeBaseListener _listener)
          Adds a listener to the list of baseListeners associated to JTrees in the GUI.
static java.lang.Object[] analyzeSelectedNodeInExplorer()
          Analyzes the selected node in the explorer to get the main information.
static javax.swing.tree.DefaultMutableTreeNode analyzeSelectedNodeInStructure()
          Analyzes the selected node in the global structure, if any.
static javax.swing.JTree createExplorer()
          Creates a graphical tree of open objects for the explorer.
static javax.swing.JTree createStructureTree()
          Creates a new graphical tree for the IS structure of all the information systems, even the closed ones.
static java.util.List getL_TreeBaseListener()
          Gets the list of baseListeners associated to JTrees in the GUI.
static javax.swing.tree.DefaultMutableTreeNode getTreeNodeInNamingTree(ImmutableName _ancestorName, javax.swing.tree.DefaultMutableTreeNode _rootNode, ImmutableName _name)
          Gets the TreeNode for a Name through the tree path of Strings from a ancestor node which has to be an ancestor of the result.
static java.lang.Object getTrueUserObjectInTreeExplorer(javax.swing.tree.DefaultMutableTreeNode _node)
          Gets the true user object in the explorer, managing all the possible cases.
static ImmutableName getTrueUserObjectNameInStructureTree(javax.swing.tree.DefaultMutableTreeNode _node)
          Since the element in the IS structure is not the user object of the node, gets the element through the tree path of Strings from the IS node.
static boolean haveAtLeastOneTreeBaseListener(ImmutableName _sourceName)
          Detect an ACSRun or ViewInBase that has at least one tree base listener.
static void removeACSMainTreeBaseListener(ImmutableName _name)
          Removes the BaseListener associated to a main ACS JTree, defined as the JTree which displays all the ACS in a specific frame, to complete the Explorer displaying.
static void removeAllTreeBaseListenerFor(ImmutableName _sourceName)
          Removes in the list of baseListeners all those associated to a specified event source.
static void removeTreeBaseListener(ImmutableName _sourceName, javax.swing.tree.TreeModel _model)
          Removes the baseListener associated to a JTree in the GUI.
static int selectNodeInExplorer(BaseObject _selectedObject)
          Selects the object node if it exists and return +1, or return -1 if it is not found.
 
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

l_treeBaseListener__

private static java.util.List l_treeBaseListener__

OPEN_ENTITIES

public static final java.lang.String OPEN_ENTITIES
See Also:
Constant Field Values

OPEN_ACS

public static final java.lang.String OPEN_ACS
See Also:
Constant Field Values

OPEN_VIEWS

public static final java.lang.String OPEN_VIEWS
See Also:
Constant Field Values

FULL_VIEWS

public static final java.lang.String FULL_VIEWS
See Also:
Constant Field Values

NOTHAN_VIEWS

public static final java.lang.String NOTHAN_VIEWS
See Also:
Constant Field Values

META_RIGHTS

public static final java.lang.String META_RIGHTS
See Also:
Constant Field Values

GRANTING_RIGHTS

public static final java.lang.String GRANTING_RIGHTS
See Also:
Constant Field Values

DENYING_RIGHTS

public static final java.lang.String DENYING_RIGHTS
See Also:
Constant Field Values

M_EXPLORER_UPPER_NODES

public static final java.util.Map M_EXPLORER_UPPER_NODES

STRUCTURE_ROOT_NAME

public static final Name STRUCTURE_ROOT_NAME

EMPTY_TREE_NODE

public static final javax.swing.tree.DefaultMutableTreeNode EMPTY_TREE_NODE
Constructor Detail

TreeManager

private TreeManager()
only one private constructor

Method Detail

createExplorer

public static final javax.swing.JTree createExplorer()
                                              throws BaseError
Creates a graphical tree of open objects for the explorer. The display order is open ACS, then open Views, then Metarights which are always opened. Calls ACSTree.createACSExplorer() and ViewTree.createViewExplorer(). Called by InternalFrame.openExplorer().

Returns:
JTree of open objects in the base
Throws:
BaseError - if an ACS in the base is null

createStructureTree

public static final javax.swing.JTree createStructureTree()
                                                   throws ProcessError
Creates a new graphical tree for the IS structure of all the information systems, even the closed ones. They are get from gBase.BaseManagerImpl. It is a tree of DefaultMutableTreeNodes with Strings as user objects. The root user object is STRUCTURE_ROOT_NAME. Creates the tree listener and registers it. Called by gDMak.ActionOpenGlobalStructure.openFrame(). Calls BaseManagerImpl.getL_IS(). Calls ISTree.createISnodeTree() to create the IS subtree following the order of BaseManagerImpl.getL_IS(), and this is important to display the ACS in the same order in ActionOpenACSyst.displayOneACS().

Returns:
JTree of names in the base
Throws:
ProcessError

addTreeBaseListener

public static final void addTreeBaseListener(TreeBaseListener _listener)
Adds a listener to the list of baseListeners associated to JTrees in the GUI. TreeBaseListeners assume PropertyChangeEvents from the base objects. Called by ACSTree and ViewTree.

Parameters:
_listener - TreeBaseListener

getL_TreeBaseListener

public static final java.util.List getL_TreeBaseListener()
Gets the list of baseListeners associated to JTrees in the GUI. BaseListeners handle PropertyChangeEvents from the base objects.

Returns:
unmodifiableList of treeBaseListeners

haveAtLeastOneTreeBaseListener

public static final boolean haveAtLeastOneTreeBaseListener(ImmutableName _sourceName)
Detect an ACSRun or ViewInBase that has at least one tree base listener. Uses listener.getEorMainEventSource() to find the right listener. Called by gWork.RightsMediatorImpl.propertyChange().

Parameters:
_sourceName - of an ACSRun or ViewInBase
Returns:
true if _sourceName is the source name of a registered listener
Since:
0.7.0

removeACSMainTreeBaseListener

public static final void removeACSMainTreeBaseListener(ImmutableName _name)
                                                throws SmallError
Removes the BaseListener associated to a main ACS JTree, defined as the JTree which displays all the ACS in a specific frame, to complete the Explorer displaying. To detect the right baseListener, tests if the ACS tree root is the ACS name, as do the main ACS tree only. Called by the Gui1.InternalFrame inner class for ACS frame closing. The associated JTree may be still visible; this is not controlled here.

Parameters:
_name - the last components (last 4, generally) of the name for the ACSRun which is associated to the baseListener as the main source event
Throws:
SmallError - if the baseListener is unknown
See Also:
ActionClose

removeTreeBaseListener

public static final void removeTreeBaseListener(ImmutableName _sourceName,
                                                javax.swing.tree.TreeModel _model)
                                         throws SmallError
Removes the baseListener associated to a JTree in the GUI. Called by removeAllTreeBaseListenerFor(). The associated JTree may be updated or still visible; this is not controlled.

Parameters:
_sourceName - of the ACSRun or ViewInBase associated to the baseListener as the main source event
_model - (usually DefaultTreeModel) associated to the JTree displaying _source
Throws:
SmallError - if the baseListener is unknown

removeAllTreeBaseListenerFor

public static final void removeAllTreeBaseListenerFor(ImmutableName _sourceName)
                                               throws SmallError
Removes in the list of baseListeners all those associated to a specified event source. Called by gDMak.ActionClose and ActionNewACSyst. The associated JTrees may be updated or still visible; this is not controlled.

Parameters:
_sourceName - of the BaseManager, ACSRun or ViewInBase associated to the baseListener as the main event source
Throws:
SmallError - if the baseListener is unknown

analyzeSelectedNodeInExplorer

public static final java.lang.Object[] analyzeSelectedNodeInExplorer()
Analyzes the selected node in the explorer to get the main information. The returned array has the format:

0- String type of the selected base object:

- possible values are "acs", "acsrun", "resource", "actor", "groupid", "userid",

"aclentry", "view", "metaright", "acsright", "virtualfolder", "privilege",

or "" if it is an another selected node

- is null if there is no selected object in the explorer

1- ImmutableName of the base object - may be null. If it is an AclEntry or a Privilege, the name is not the detailled name

2- JInternalFrame open main frame of the base object - may be null

Called by ActionUtilities, ActionOpenBeamer and ActionOpenSketcher.

Returns:
Object[] of three objects:

Returns {null,null,null} if no frame is selected, or a no-workable frame, or if the selected node in the explorer is a main or a second node ('OPEN_ACS' node, or '' under RESOURCES for instance).


selectNodeInExplorer

public static final int selectNodeInExplorer(BaseObject _selectedObject)
Selects the object node if it exists and return +1, or return -1 if it is not found. Does not select the standard nodes like 'Open Entities'. Calls ACSTreeUtilities.getDetailledNameNodeInExplorer() and getCurrentObjectNode().

Parameters:
_selectedObject - displayed in the explorer and to select
Returns:
+1 if found and -1 otherwise

getTrueUserObjectInTreeExplorer

public static final java.lang.Object getTrueUserObjectInTreeExplorer(javax.swing.tree.DefaultMutableTreeNode _node)
Gets the true user object in the explorer, managing all the possible cases. For resources in the acs resource tree, the resource is returned after its name has been rebuilt up. For the DetailledNames of AclEntries and Privileges, the getACSObjectFromDetailledName method of ACS_Facade is called. For the Names of external entities of an acs, the entity is returned. For main nodes in an acs tree, the title of the node is returned. For other nodes, the BaseObject is the node user object. Called by DialogBox.valueChanged().

Parameters:
_node - of the tree explorer or of an acs main frame.
Returns:
the user object, which may be a String (main nodes) or a BaseObject. May ne null.

analyzeSelectedNodeInStructure

public static final javax.swing.tree.DefaultMutableTreeNode analyzeSelectedNodeInStructure()
Analyzes the selected node in the global structure, if any. Called by ActionOpenGlobalStructure.valueChanged().

Returns:
DefaultMutableTreeNode selected node in the structure. May be null.

getTrueUserObjectNameInStructureTree

public static final ImmutableName getTrueUserObjectNameInStructureTree(javax.swing.tree.DefaultMutableTreeNode _node)
Since the element in the IS structure is not the user object of the node, gets the element through the tree path of Strings from the IS node. Called by ActionOpenGlobalStructure.valueChanged() and ISTreeCellRenderer.getTreeCellRendererComponent().

Parameters:
_node - is in the IS structure tree
Returns:
the element name. May be the IS name. May be null, mainly if _node is not under the IS node or if an argument is null.

getTreeNodeInNamingTree

public static final javax.swing.tree.DefaultMutableTreeNode getTreeNodeInNamingTree(ImmutableName _ancestorName,
                                                                                    javax.swing.tree.DefaultMutableTreeNode _rootNode,
                                                                                    ImmutableName _name)
Gets the TreeNode for a Name through the tree path of Strings from a ancestor node which has to be an ancestor of the result. A naming tree is used in the subtree of resources for an ACS in the explorer, and also in the IS structure tree. The element in the naming tree is not the user object of the node, but it is a Name for which each component is in a TreeNode to set a tree path. This is the inverse method of getTrueUserObjectNameInStructureTree(). Called by ACSTreeUtilities.getCurrentObjectNode() and ISTree.

Parameters:
_ancestorName - is the name of the ACS or the IS which owns _name
_rootNode - is the root of the naming tree. It is associated to the resources node for an ACS in the explorer, or to the IS.
_name - for which the TreeNode under _ancestorNode is returned
Returns:
the TreeNode in the tree for _name. May be null.