Package org.openbravo.erpCommon.utility
Class GenericTree
- java.lang.Object
-
- org.openbravo.erpCommon.utility.GenericTree
-
- Direct Known Subclasses:
ModuleTree
public abstract class GenericTree extends Object
Manages a generic tree, this class is abstract, for concrete trees subclasses are needed. It is able to show a HTML component with the tree, to expand nodes Ajax calls are used, these calls are managed by GenericTreeServlet.
Usage
This class cannot be directly used, instead a subclass implementing the abstract method must be used. The purpose is to set the toHml directly in the HTML where the tree is going to be displayed, additionally genericTree.js must be imported in that page. These java classes will show the tree and manage the ajax requests.
To take into account
-data is a FieldProvider that must have the following fields: -nodeID : It is the unique identifier for the node -name : It is the short name for the node (it will be displayed in the tree) -display : It indicates whether the node has child elements in order to show or not the expand/collapse button, the values it can contain are: -block: To show the button -none : Not to show it -linkname : In case this element is passed a link will appear next to the node name, linkname is the text to display in this link. -linkclick: Is the onclick action that will have the link. -levelno : It is the deep level for the current node -icon : It is the css class to display the main icon for the node -icon2 : It is another css class to display another icon over the main icon Additionally to these fields that must be populated by the subclasses, some helper methods that can be passed as empty String and because will be caculated by the super class are needed, they are: -leveltree: It is a set of divs to move the current node depending on its deep. -endline: Is a div at the end of the dotted line -position: It is the node position relative to the tree in order to allow keyboard navigation -It is necessary to implement in subclasses apart of the abstract method a constructor without parameters, this constructor is used by GenericTreeServlet.
-
-
Field Summary
Fields Modifier and Type Field Description protected ConnectionProvider
conn
protected FieldProvider[]
data
protected String
lang
protected XmlEngine
xmlEngine
-
Constructor Summary
Constructors Constructor Description GenericTree()
Default constructor without parameters.GenericTree(HttpBaseServlet base)
This constructor receives a HttpBaseServlet object to set the infrastructure parametersGenericTree(HttpBaseServlet base, boolean bSmall)
This constructor receives a HttpBaseServlet object to set the infrastructure parameters
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description String
descriptionToHtml()
FieldProvider[]
getData()
abstract String
getHTMLDescription(String node)
This method returns a String with the description for the nodeprotected abstract String
getNodePosition(String nodeID)
Returns the position relative to the rest of nodes at the same levelprotected abstract String
getParent(String node)
Returns the node id for the parent of the passed nodeprotected abstract boolean
isLastLevelNode(String nodeID)
Returns true in case the node is the last one at its levelprotected void
setIsSubTree(boolean value)
Sets the isSubTree variable to the passed value.void
setLanguage(String lang)
Sets the languageprotected void
setLevel(int l)
Set the deep level for the current set of nodesvoid
setNotifications(String notifications)
Sets information for the notifications area.void
setParameters(HttpBaseServlet base)
Sets the infrastructure parameters from the HttpBaseServlet object passed.protected abstract void
setRootTree()
This method will assign to data the root nodes for the treeprotected abstract void
setSubTree(String nodeId, String level)
This method will assign to data the child nodes (just one level) for the nodeIdvoid
showNotifications(boolean notif)
String
toHtml()
-
-
-
Field Detail
-
xmlEngine
protected XmlEngine xmlEngine
-
conn
protected ConnectionProvider conn
-
data
protected FieldProvider[] data
-
lang
protected String lang
-
-
Constructor Detail
-
GenericTree
public GenericTree()
Default constructor without parameters. It is needed to be able to create instances by GenericTreeServlet, it must be implemented also by subclases.
-
GenericTree
public GenericTree(HttpBaseServlet base)
This constructor receives a HttpBaseServlet object to set the infrastructure parameters- Parameters:
base
-
-
GenericTree
public GenericTree(HttpBaseServlet base, boolean bSmall)
This constructor receives a HttpBaseServlet object to set the infrastructure parameters- Parameters:
base
-bSmall
- Normal size or small size (true)
-
-
Method Detail
-
setRootTree
protected abstract void setRootTree()
This method will assign to data the root nodes for the tree
-
setSubTree
protected abstract void setSubTree(String nodeId, String level)
This method will assign to data the child nodes (just one level) for the nodeId- Parameters:
nodeId
- Root node for the subtree
-
getHTMLDescription
public abstract String getHTMLDescription(String node)
This method returns a String with the description for the node- Parameters:
node
- Node ID to retrieve description- Returns:
- The String with the HTML for the description
-
isLastLevelNode
protected abstract boolean isLastLevelNode(String nodeID)
Returns true in case the node is the last one at its level- Parameters:
nodeID
-- Returns:
- true in case the node is the last one at its level
-
getNodePosition
protected abstract String getNodePosition(String nodeID)
Returns the position relative to the rest of nodes at the same level- Parameters:
nodeID
-- Returns:
- the position relative to the rest of nodes at the same level
-
getParent
protected abstract String getParent(String node)
Returns the node id for the parent of the passed node- Parameters:
node
-- Returns:
- the node id for the parent of the passed node
-
setParameters
public void setParameters(HttpBaseServlet base)
Sets the infrastructure parameters from the HttpBaseServlet object passed.- Parameters:
base
- HttpBaseServlet object to obtain the parameters from
-
setIsSubTree
protected void setIsSubTree(boolean value)
Sets the isSubTree variable to the passed value. Subtrees have different treatment in interface.- Parameters:
value
-
-
toHtml
public String toHtml()
- Returns:
- a String with the HTML with all the structure for the tree.
-
setLanguage
public void setLanguage(String lang)
Sets the language- Parameters:
lang
-
-
descriptionToHtml
public String descriptionToHtml()
-
setLevel
protected void setLevel(int l)
Set the deep level for the current set of nodes- Parameters:
l
-
-
setNotifications
public void setNotifications(String notifications)
Sets information for the notifications area.- Parameters:
notifications
- HTML string with the text and link
-
getData
public FieldProvider[] getData()
- Returns:
- the data
-
showNotifications
public void showNotifications(boolean notif)
-
-