org.ow2.clif.scenario.isac.egui.util
Class BehaviorUtil

java.lang.Object
  extended by org.ow2.clif.scenario.isac.egui.util.BehaviorUtil

public class BehaviorUtil
extends java.lang.Object

Some util function for behaviors

Author:
Joan Chaumont, Florian Francheteau

Constructor Summary
BehaviorUtil()
           
 
Method Summary
static boolean childrenAllowed(org.w3c.dom.Element target)
          Test if the target element can have children
static boolean childrenAllowed(org.w3c.dom.Element target, org.w3c.dom.Element toDrop)
          Test if an element can be add into another one
static java.lang.String getAddText(org.eclipse.jface.viewers.IStructuredSelection sel)
          Get the add text.
static java.util.List<org.w3c.dom.Element> getSameLevelElement(java.util.List<org.w3c.dom.Element> listElement)
          If elements are on differents level, filter only element on the same level
static boolean insertElementInTree(org.w3c.dom.Element newNode, org.w3c.dom.Element selectedNode, org.w3c.dom.Element rootBehaviourNode, ActionPlacement actionPlacement)
          Insert a new node in the document dependending on the selected node and the placement required
static boolean isAllowedToMove(org.w3c.dom.Element target)
           
static boolean isParent(org.w3c.dom.Element target, java.lang.String id)
          Test if an element target is a child of an element
static boolean siblingAllowed(org.w3c.dom.Element target, org.w3c.dom.Element newNode)
          Test if the target can posses sibling
static ActionPlacement validatePlacement(org.w3c.dom.Element nodeToAdd, org.w3c.dom.Element node, ActionPlacement actionPlacement)
          Validate and change the action Placement depending on the targeted node
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BehaviorUtil

public BehaviorUtil()
Method Detail

isParent

public static boolean isParent(org.w3c.dom.Element target,
                               java.lang.String id)
Test if an element target is a child of an element

Parameters:
target - the supposed child
id - id of parent element
Returns:
true if element is a parent of target

childrenAllowed

public static boolean childrenAllowed(org.w3c.dom.Element target,
                                      org.w3c.dom.Element toDrop)
Test if an element can be add into another one

Parameters:
target - the selected element where new element will be added
toDrop - the element to add
Returns:
true if toDrop can be added to target

siblingAllowed

public static boolean siblingAllowed(org.w3c.dom.Element target,
                                     org.w3c.dom.Element newNode)
Test if the target can posses sibling

Parameters:
target - Target element to test
newNode - Node to insert
Returns:
True if it can have sibling

childrenAllowed

public static boolean childrenAllowed(org.w3c.dom.Element target)
Test if the target element can have children

Parameters:
target - element to test
Returns:
True if allowed

isAllowedToMove

public static boolean isAllowedToMove(org.w3c.dom.Element target)

getAddText

public static java.lang.String getAddText(org.eclipse.jface.viewers.IStructuredSelection sel)
Get the add text.
The text can change depending on the selected node and desactivated if there is no possibility

Parameters:
sel -
Returns:
Text of the button. "" if the button has to be disabled.

insertElementInTree

public static boolean insertElementInTree(org.w3c.dom.Element newNode,
                                          org.w3c.dom.Element selectedNode,
                                          org.w3c.dom.Element rootBehaviourNode,
                                          ActionPlacement actionPlacement)
Insert a new node in the document dependending on the selected node and the placement required

Parameters:
newNode - Node to add
selectedNode - The selected node. May be null
rootBehaviourNode - The root behavior element. Used to insert at the begin or at the end
actionPlacement - Place to insert the new node

validatePlacement

public static ActionPlacement validatePlacement(org.w3c.dom.Element nodeToAdd,
                                                org.w3c.dom.Element node,
                                                ActionPlacement actionPlacement)
Validate and change the action Placement depending on the targeted node

Parameters:
nodeToAdd - Node to insert
node - Target node
actionPlacement - Placement of the node to insert @return Valide placement to insert a new node
Returns:
Place of the insertion

getSameLevelElement

public static java.util.List<org.w3c.dom.Element> getSameLevelElement(java.util.List<org.w3c.dom.Element> listElement)
If elements are on differents level, filter only element on the same level

Parameters:
listElement - List of element to filter
Returns:
Liste of element filtered