com.sdm.quasar.client.core.dialog.services.impl
Class DefaultDialogHierarchyService

java.lang.Object
  extended bycom.sdm.quasar.client.core.dialog.services.impl.DefaultDialogHierarchyService
All Implemented Interfaces:
DialogHierarchyService, HierarchyProvider, Service

public class DefaultDialogHierarchyService
extends java.lang.Object
implements DialogHierarchyService

A default implementation of DialogHierarchyService using a HierarchyProvider.

Version:
1.$Revision$
Author:
Thomas Wolf

Constructor Summary
DefaultDialogHierarchyService(HierarchyProvider hierarchyProvider)
          Creates a new DefaultDialogHierarchyService.
 
Method Summary
 void addHierarchyProviderListener(HierarchyProviderListener listener)
          Registers a listener that observes changes in the hierarchy.
 int getChildCount(ID parentId, boolean deep, boolean leafesOnly)
          Returns the number of childs for the given parent id.
 ID[] getChildren(ID parentId)
          Returns the children of a node.
 ID getParentForChild(ID id)
          Returns the parent id of a node.
 ID[] getRoots()
          Returns the root nodes.
 boolean hasID(ID id)
          Tests whether a given ID is known in the hierarchy either as a parent or as a child.
 boolean isChild(ID id1, ID id2, boolean deep)
          Checks if id2 is a child of id1.
 void removeHierarchyProviderListener(HierarchyProviderListener listener)
          Unregisters a listener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultDialogHierarchyService

public DefaultDialogHierarchyService(HierarchyProvider hierarchyProvider)
Creates a new DefaultDialogHierarchyService.

Parameters:
hierarchyProvider - the HierarchyProvider to be used.
Method Detail

hasID

public boolean hasID(ID id)
Description copied from interface: HierarchyProvider
Tests whether a given ID is known in the hierarchy either as a parent or as a child.

Specified by:
hasID in interface HierarchyProvider
Parameters:
id - the id to be tested
Returns:
true iff the node is registered in the hierarchy
See Also:
HierarchyProvider.hasID(com.sdm.quasar.client.core.common.ID)

getChildren

public ID[] getChildren(ID parentId)
Description copied from interface: HierarchyProvider
Returns the children of a node. The returned array is a copy, any modifications made to the hierarchy will not affect the returned set.

Specified by:
getChildren in interface HierarchyProvider
Parameters:
parentId - the id of the parent node
Returns:
an array with the IDs of the children
See Also:
HierarchyProvider.getChildren(com.sdm.quasar.client.core.common.ID)

getParentForChild

public ID getParentForChild(ID id)
Description copied from interface: HierarchyProvider
Returns the parent id of a node.

Specified by:
getParentForChild in interface HierarchyProvider
Parameters:
id - the id of the child node
Returns:
the id of the parent node or null, if the child has no parent
See Also:
HierarchyProvider.getParentForChild(com.sdm.quasar.client.core.common.ID)

isChild

public boolean isChild(ID id1,
                       ID id2,
                       boolean deep)
Description copied from interface: HierarchyProvider
Checks if id2 is a child of id1. The check is done down the whole sub hierarchy of id1 if deep = true. Else only direct childs are considered.

Specified by:
isChild in interface HierarchyProvider
Parameters:
id1 - the potential parent
id2 - the potential child
deep - true: The check is done down the whole sub hierarchy false: only direct childs are considered
Returns:
true, if
See Also:
HierarchyProvider.isChild(com.sdm.quasar.client.core.common.ID, com.sdm.quasar.client.core.common.ID, boolean)

getChildCount

public int getChildCount(ID parentId,
                         boolean deep,
                         boolean leafesOnly)
Description copied from interface: HierarchyProvider
Returns the number of childs for the given parent id.

Specified by:
getChildCount in interface HierarchyProvider
Parameters:
parentId - the ID of the parent to count childs of
deep - if true, the whole subtree will be counted, if false, only direct childs are counted
leafesOnly - if true, the returned number is restricted to leafes (childs, that have no childs themselfes)
Returns:
the number of children of the specified parent node
See Also:
HierarchyProvider.getChildCount(com.sdm.quasar.client.core.common.ID, boolean, boolean)

getRoots

public ID[] getRoots()
Description copied from interface: HierarchyProvider
Returns the root nodes. The returned array is a copy, any modifications made to the hierarchy will not affect the returned value.

Specified by:
getRoots in interface HierarchyProvider
Returns:
an array with the IDs of the root nodes.
See Also:
HierarchyProvider.getRoots()

addHierarchyProviderListener

public void addHierarchyProviderListener(HierarchyProviderListener listener)
Description copied from interface: HierarchyProvider
Registers a listener that observes changes in the hierarchy.

Specified by:
addHierarchyProviderListener in interface HierarchyProvider
Parameters:
listener - the listener to be added
See Also:
HierarchyProvider.addHierarchyProviderListener(com.sdm.quasar.client.core.common.hierarchy.HierarchyProviderListener)

removeHierarchyProviderListener

public void removeHierarchyProviderListener(HierarchyProviderListener listener)
Description copied from interface: HierarchyProvider
Unregisters a listener.

Specified by:
removeHierarchyProviderListener in interface HierarchyProvider
Parameters:
listener - the listener to be removed
See Also:
HierarchyProvider.removeHierarchyProviderListener(com.sdm.quasar.client.core.common.hierarchy.HierarchyProviderListener)