com.wewebu.ow.server.ui
Class OwTreeView

java.lang.Object
  extended by com.wewebu.ow.server.ui.OwEventTarget
      extended by com.wewebu.ow.server.ui.OwView
          extended by com.wewebu.ow.server.ui.OwTreeView
All Implemented Interfaces:
OwBaseView, OwUpdateTarget
Direct Known Subclasses:
OwObjectClassTreeView, OwObjectTreeView

public abstract class OwTreeView
extends OwView

Generic Tree View base class. Implements a template pattern to render arbitrary object tree structures. Just overwrite the getName and getDisplayName functions to render your special object nodes.

To be implemented for the tree objects.

Alfresco Workdesk
Copyright (c) Alfresco Software, Inc.
All rights reserved.

For licensing information read the license.txt file or
go to: http://wiki.alfresco.com


Nested Class Summary
static interface OwTreeView.OwTreeViewEventListner
           Base class for event listeners to OwTreeView.
 class OwTreeView.OwTreeViewNode
           
 
Field Summary
protected  OwSort childrenSort
          The children sort criteria.
static int DISPLAY_MODE_REGISTER_NODES
          display mode for rendering of the treenodes
static int DISPLAY_MODE_TREE_NODES
          display mode for rendering of the treenodes (default)
protected  OwTreeView.OwTreeViewEventListner m_eventlistner
          eventlistener for the tree view
protected  OwTreeView.OwTreeViewNode m_focusNode
          currently focus node of null if nothing is focused
protected  Map m_nodeMap
          map containing all nodes mapped by their ID
protected  OwTreeView.OwTreeViewNode m_root
          root node
protected  OwTreeView.OwTreeViewNode m_selectedNode
          currently selected node of null if nothing is selected
protected  String m_strDesignURL
          URL to the design dir
protected  String m_strPath
          current navigated path
protected static String NODE_ID_KEY
           
static String PATH_DELIMITER
          delimiter used to build the path
 
Fields inherited from class com.wewebu.ow.server.ui.OwView
CURRENT_MODULE_KEY, FORMULAR_PLACEHOLDER_END_DELIMITER, FORMULAR_PLACEHOLDER_START_DELIMITER, m_externalFormEventTarget
 
Fields inherited from interface com.wewebu.ow.server.ui.OwBaseView
EMPTY_STRING
 
Constructor Summary
OwTreeView()
           
 
Method Summary
 void addNode(OwTreeView.OwTreeViewNode node_p)
          add a node to the node map for fast access
 boolean canNavigate()
          check if tree has been initialized with objects and can be browsed
 void clearSelection()
          (overridable) Reset the current selection.
protected abstract  List createChildObjects(Object obj_p)
          Create a list of child objects to the given object.
Must be implemented by derived classes.
protected  OwTreeView.OwTreeViewNode createTreeViewNode(OwTreeView treeView_p, Object obj_p)
          overridable factory method check of node has subnodes to be overwritten by the derived class
protected abstract  void expandParents(Object theObject_p)
          Expand the parents of the current object
 OwSort getChildrenSort()
          Get the currently set children sort criteria
 String getClientSideId()
          Get the id used for client side scripts for calculate the height of the tree.
protected  String getCloseIconURL(Object obj_p, OwTreeView.OwTreeViewNode node_p)
          Get an URL for the close icon.
Should be implemented by the derived class.
 OwTreeView.OwTreeViewNode getCurrentNode()
          get the currently selected node
protected  String getDisplayHTML(Object obj_p, OwTreeView.OwTreeViewNode node_p)
          Returns HTML code to be used to display a node.
If you override this method, you have to make sure that the HTML code is properly encoded!
protected  int getDisplayMode()
          get the display mode of the view
protected  String getDisplayName(Object obj_p, OwTreeView.OwTreeViewNode node_p)
          Returns the text to be displayed as the name of the node.
This text will be properly encoded before used.
protected abstract  String getName(Object obj_p, OwTreeView.OwTreeViewNode node_p)
          get the name for an object, used to build paths to be implemented by the derived class
protected  OwTreeView.OwTreeViewNode getNodeForObject(Object theObject_p)
           
protected  OwTreeView.OwTreeViewNode getNodeFromID(String strID_p)
          get node from node ID
protected  String getOpenIconURL(Object obj_p, OwTreeView.OwTreeViewNode node_p)
          get a URL to the open icon to be implemented by the derived class
protected  String getRegisterItemStyle()
          get the style for the tree item
protected  String getSelectedRegisterItemStyle()
          get the style for the selected tree item
protected  String getSelectedTreeItemStyle()
          get the style for the selected tree item
protected  String getTreeItemStyle()
          get the style for the tree item
protected  boolean hasPlusMinusIcon(Object obj_p, OwTreeView.OwTreeViewNode node_p)
          (overridable) check of node has subnodes to be overwritten by the derived class
protected  void init()
          init the target after the context is set.
 boolean isEmpty()
          check if tree view contains any node
 boolean isEnabled(Object obj_p, OwTreeView.OwTreeViewNode node_p)
          check if node is enabled, i.e.
 boolean isFocused(OwTreeView.OwTreeViewNode node_p)
          check if given node is focused
 boolean isSelected(OwTreeView.OwTreeViewNode node_p)
          check if given node is selected
 void navigate(Object obj_p, String strPath_p)
          init the tree and set the root object
 void navigate(String strPath_p)
          navigate to the specified path NOTE: the tree must have already been initialized with the two parameter form of navigate
 void navigateToChild(Object theObject_p)
          Navigate to an object that is already in the tree view.
 void navigateToId(String nodeId_p)
          Navigate to the specific node id
 void navigateUp()
          navigate up to the parent
 void onClickLabel(javax.servlet.http.HttpServletRequest request_p)
          handles the navigate event i.e.
 void onClickPlusMinus(javax.servlet.http.HttpServletRequest request_p)
          handles the navigate event i.e.
protected  void onRender(Writer w_p)
          called when the view should create its HTML content to be displayed
 void openNode(OwTreeView.OwTreeViewNode node_p)
          open the node content
 void refreshCurrentNode()
          refresh the current node, i.e.
 void refreshNodeForObject(Object param_p)
          Tries to find the node for the given object and then refresh it.
protected  void renderFolderIconLink(StringWriter nodeBuffer_p, OwTreeView.OwTreeViewNode node_p)
          Writes the link and icon for a folder tree node to a StringWriter
protected  void renderMinusIconLink(StringWriter nodeBuffer_p, OwTreeView.OwTreeViewNode node_p)
          Writes the link and icon for collapsing a sub tree (a.k.a.
 void renderNode(Writer writer_p, OwTreeView.OwTreeViewNode node_p, int depth_p)
          render a treenode as node
protected  void renderNodeLink(StringWriter nodeBuffer_p, OwTreeView.OwTreeViewNode node_p)
          Writes the link for a tree node to a StringWriter
protected  void renderPlusIconLink(StringWriter nodeBuffer_p, OwTreeView.OwTreeViewNode node_p)
          Writes the link and icon for expanding a sub tree (a.k.a.
 void renderRegister(Writer writer_p, OwTreeView.OwTreeViewNode node_p, int depth_p)
          render a treenode as register
 void setChildrenSort(OwSort childrenSort_p)
          Set the children sort criteria.
 void setDisplayMode(int iMode_p)
          set the display mode of the view
 void setEventListner(OwTreeView.OwTreeViewEventListner listner_p)
          set an eventlistener for the tree view
protected  boolean useFormEventUrls()
          use form event url's instead of get method's used to submit a neighbor form
protected  void writeTooltip(StringWriter nodeBuffer_p, String tooltip_p)
          Utility method for writing tooltip.
 
Methods inherited from class com.wewebu.ow.server.ui.OwView
activate, addView, detach, getBreadcrumbPart, getDocument, getExternalFormEventTarget, getFormName, getFormTarget, getIcon, getIterator, getMaximizeView, getParent, getRenderedNamedRegion, getRenderedRegion, getTitle, getViewList, isFormTargetExternal, isNamedRegion, isRegion, isShowMaximized, isShowMinimized, isShowNormal, onActivate, onUpdate, render, renderHTMLFormular, renderNamedRegion, renderRegion, serverSideDesignInclude, serverSideInclude, setDocument, setExternalFormTarget, setMaximizeView, setParent, showMaximized, showMinimized, showNormal, usesFormWithAttributes
 
Methods inherited from class com.wewebu.ow.server.ui.OwEventTarget
attach, disableRequestListener, enableRequestListener, getAjaxEventURL, getContext, getEventURL, getFormEventFunction, getFormEventURL, getID, onExternalRequest, onFormEvent, onRequest, updateExternalFormTarget
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PATH_DELIMITER

public static final String PATH_DELIMITER
delimiter used to build the path

See Also:
Constant Field Values

m_eventlistner

protected OwTreeView.OwTreeViewEventListner m_eventlistner
eventlistener for the tree view


m_strDesignURL

protected String m_strDesignURL
URL to the design dir


m_root

protected OwTreeView.OwTreeViewNode m_root
root node


m_selectedNode

protected OwTreeView.OwTreeViewNode m_selectedNode
currently selected node of null if nothing is selected


m_focusNode

protected OwTreeView.OwTreeViewNode m_focusNode
currently focus node of null if nothing is focused


m_strPath

protected String m_strPath
current navigated path


childrenSort

protected OwSort childrenSort
The children sort criteria. Can be null.

Since:
3.2.0.0

NODE_ID_KEY

protected static final String NODE_ID_KEY
See Also:
Constant Field Values

DISPLAY_MODE_TREE_NODES

public static final int DISPLAY_MODE_TREE_NODES
display mode for rendering of the treenodes (default)

See Also:
Constant Field Values

DISPLAY_MODE_REGISTER_NODES

public static final int DISPLAY_MODE_REGISTER_NODES
display mode for rendering of the treenodes

See Also:
Constant Field Values

m_nodeMap

protected Map m_nodeMap
map containing all nodes mapped by their ID

Constructor Detail

OwTreeView

public OwTreeView()
Method Detail

useFormEventUrls

protected boolean useFormEventUrls()
use form event url's instead of get method's used to submit a neighbor form


refreshCurrentNode

public void refreshCurrentNode()
                        throws Exception
refresh the current node, i.e. recreate the children

Throws:
Exception

getCurrentNode

public OwTreeView.OwTreeViewNode getCurrentNode()
get the currently selected node

Returns:
an OwTreeView.OwTreeViewNode

navigateUp

public void navigateUp()
                throws Exception
navigate up to the parent

Throws:
Exception

navigate

public void navigate(String strPath_p)
              throws Exception
navigate to the specified path NOTE: the tree must have already been initialized with the two parameter form of navigate

Parameters:
strPath_p - String representing a path
Throws:
Exception

navigateToId

public void navigateToId(String nodeId_p)
                  throws Exception
Navigate to the specific node id

Parameters:
nodeId_p - String representing id of the node
Throws:
Exception
Since:
3.1.0.0

canNavigate

public boolean canNavigate()
check if tree has been initialized with objects and can be browsed

Returns:
boolean

navigate

public void navigate(Object obj_p,
                     String strPath_p)
              throws Exception
init the tree and set the root object

Parameters:
obj_p - Root Object to be managed by the tree
strPath_p - String representing path
Throws:
Exception

isEmpty

public boolean isEmpty()
check if tree view contains any node

Returns:
true = treeview is empty, false = otherwise

setEventListner

public void setEventListner(OwTreeView.OwTreeViewEventListner listner_p)
set an eventlistener for the tree view

Parameters:
listner_p - OwTreeView.OwTreeViewEventListner

onRender

protected void onRender(Writer w_p)
                 throws Exception
called when the view should create its HTML content to be displayed

Overrides:
onRender in class OwView
Parameters:
w_p - Writer object to write HTML to
Throws:
Exception

createChildObjects

protected abstract List createChildObjects(Object obj_p)
                                    throws Exception
Create a list of child objects to the given object.
Must be implemented by derived classes.

Parameters:
obj_p - Object which is managed by the tree view
Returns:
List of Objects which are child to the given object
Throws:
Exception

getCloseIconURL

protected String getCloseIconURL(Object obj_p,
                                 OwTreeView.OwTreeViewNode node_p)
                          throws Exception
Get an URL for the close icon.
Should be implemented by the derived class.

Parameters:
obj_p - Object which is managed by the tree view
node_p - OwTreeViewNode
Returns:
String URL to the close icon
Throws:
Exception

getOpenIconURL

protected String getOpenIconURL(Object obj_p,
                                OwTreeView.OwTreeViewNode node_p)
                         throws Exception
get a URL to the open icon to be implemented by the derived class

Parameters:
obj_p - Object which is managed by the tree view
node_p - OwTreeViewNode
Returns:
String URL to the close icon
Throws:
Exception

getDisplayName

protected String getDisplayName(Object obj_p,
                                OwTreeView.OwTreeViewNode node_p)
                         throws Exception
Returns the text to be displayed as the name of the node.
This text will be properly encoded before used.

Parameters:
obj_p - Object which is managed by the tree view
node_p - the node to return the text for
Returns:
the text to be displayed as the name of the node.
Throws:
Exception

getDisplayHTML

protected String getDisplayHTML(Object obj_p,
                                OwTreeView.OwTreeViewNode node_p)
                         throws Exception
Returns HTML code to be used to display a node.
If you override this method, you have to make sure that the HTML code is properly encoded!

Parameters:
obj_p - Object which is managed by the tree view
node_p - the node to return the text for
Returns:
HTML code to be used to display a node
Throws:
Exception
Since:
2.5.3.0

isEnabled

public boolean isEnabled(Object obj_p,
                         OwTreeView.OwTreeViewNode node_p)
                  throws Exception
check if node is enabled, i.e. can open the folder to be implemented by the derived class

Parameters:
obj_p - Object which is managed by the tree view
Returns:
true = enabled, false = disabled
Throws:
Exception

getName

protected abstract String getName(Object obj_p,
                                  OwTreeView.OwTreeViewNode node_p)
                           throws Exception
get the name for an object, used to build paths to be implemented by the derived class

Parameters:
obj_p - Object which is managed by the tree view
Returns:
the name for an object
Throws:
Exception

hasPlusMinusIcon

protected boolean hasPlusMinusIcon(Object obj_p,
                                   OwTreeView.OwTreeViewNode node_p)
                            throws Exception
(overridable) check of node has subnodes to be overwritten by the derived class

Parameters:
obj_p - Object which is managed by the tree view
Returns:
true if plus minus icon should be displayed to open subnodes
Throws:
Exception

createTreeViewNode

protected OwTreeView.OwTreeViewNode createTreeViewNode(OwTreeView treeView_p,
                                                       Object obj_p)
overridable factory method check of node has subnodes to be overwritten by the derived class

Parameters:
treeView_p - OwTreeView
obj_p - template Object which is managed by the tree node

init

protected void init()
             throws Exception
init the target after the context is set.

Overrides:
init in class OwView
Throws:
Exception

setDisplayMode

public void setDisplayMode(int iMode_p)
set the display mode of the view

Parameters:
iMode_p - int mode as defined in DISPLAY_MODE_...

getDisplayMode

protected int getDisplayMode()
get the display mode of the view

Returns:
int mode as defined in DISPLAY_MODE_...

renderRegister

public void renderRegister(Writer writer_p,
                           OwTreeView.OwTreeViewNode node_p,
                           int depth_p)
                    throws Exception
render a treenode as register

Parameters:
writer_p - Writer Object
node_p - OwTreeNode Node to render
depth_p - iterator depth
Throws:
Exception

getSelectedTreeItemStyle

protected String getSelectedTreeItemStyle()
get the style for the selected tree item


getTreeItemStyle

protected String getTreeItemStyle()
get the style for the tree item


getSelectedRegisterItemStyle

protected String getSelectedRegisterItemStyle()
get the style for the selected tree item


getRegisterItemStyle

protected String getRegisterItemStyle()
get the style for the tree item


isSelected

public boolean isSelected(OwTreeView.OwTreeViewNode node_p)
check if given node is selected

Parameters:
node_p - OwTreeViewNode
Returns:
true if node is eqauls selected node, else false

isFocused

public boolean isFocused(OwTreeView.OwTreeViewNode node_p)
check if given node is focused

Parameters:
node_p - OwTreeViewNode to check
Returns:
true if given node is focused, else false

renderNode

public void renderNode(Writer writer_p,
                       OwTreeView.OwTreeViewNode node_p,
                       int depth_p)
                throws Exception
render a treenode as node

Parameters:
writer_p - Writer Object
node_p - OwTreeNode Node to render
depth_p - int iterator depth
Throws:
Exception

renderMinusIconLink

protected void renderMinusIconLink(StringWriter nodeBuffer_p,
                                   OwTreeView.OwTreeViewNode node_p)
                            throws Exception
Writes the link and icon for collapsing a sub tree (a.k.a. minus icon) to a StringWriter.

Parameters:
nodeBuffer_p - StringWriter to write the link and icon to
node_p - OwTreeViewNode to write the collapse link for
Throws:
Exception
Since:
2.5.3.0

writeTooltip

protected void writeTooltip(StringWriter nodeBuffer_p,
                            String tooltip_p)
Utility method for writing tooltip.

Parameters:
nodeBuffer_p - StringWriter object
tooltip_p - String text to use as the tooltip
Since:
3.0.0.0

renderPlusIconLink

protected void renderPlusIconLink(StringWriter nodeBuffer_p,
                                  OwTreeView.OwTreeViewNode node_p)
                           throws Exception
Writes the link and icon for expanding a sub tree (a.k.a. plus icon) to a StringWriter.

Parameters:
nodeBuffer_p - StringWriter to write the link and icon to
node_p - OwTreeViewNode to write the expand link for
Throws:
Exception
Since:
2.5.3.0

renderFolderIconLink

protected void renderFolderIconLink(StringWriter nodeBuffer_p,
                                    OwTreeView.OwTreeViewNode node_p)
                             throws Exception
Writes the link and icon for a folder tree node to a StringWriter

Parameters:
nodeBuffer_p - StringWriter to write the link and icon to
node_p - OwTreeViewNode to write the link for
Throws:
Exception
Since:
2.5.3.0

renderNodeLink

protected void renderNodeLink(StringWriter nodeBuffer_p,
                              OwTreeView.OwTreeViewNode node_p)
                       throws Exception
Writes the link for a tree node to a StringWriter

Parameters:
nodeBuffer_p - the StringWriter to write the link and icon to
node_p - the the OwTreeViewNode to write the link for
Throws:
Exception
Since:
2.5.3.0

getNodeFromID

protected OwTreeView.OwTreeViewNode getNodeFromID(String strID_p)
get node from node ID

Parameters:
strID_p - String node ID from OwTreeViewNode.getID()
Returns:
OwTreeViewNode for given ID

addNode

public void addNode(OwTreeView.OwTreeViewNode node_p)
add a node to the node map for fast access

Parameters:
node_p - OwTreeViewNode to add

onClickPlusMinus

public void onClickPlusMinus(javax.servlet.http.HttpServletRequest request_p)
                      throws Exception
handles the navigate event i.e. a user has clicked a tree icon

Parameters:
request_p -
Throws:
Exception

onClickLabel

public void onClickLabel(javax.servlet.http.HttpServletRequest request_p)
                  throws Exception
handles the navigate event i.e. a user has clicked a tree icon

Parameters:
request_p -
Throws:
Exception

openNode

public void openNode(OwTreeView.OwTreeViewNode node_p)
              throws Exception
open the node content

Parameters:
node_p - OwTreeViewNode whose content is to be shown
Throws:
Exception

getClientSideId

public String getClientSideId()
Get the id used for client side scripts for calculate the height of the tree.

Returns:
the client side id.

navigateToChild

public void navigateToChild(Object theObject_p)
                     throws Exception
Navigate to an object that is already in the tree view.

Parameters:
theObject_p -
Throws:
Exception
Since:
3.1.0.0

expandParents

protected abstract void expandParents(Object theObject_p)
                               throws Exception
Expand the parents of the current object

Parameters:
theObject_p -
Throws:
Exception
Since:
3.1.0.0

getNodeForObject

protected OwTreeView.OwTreeViewNode getNodeForObject(Object theObject_p)

clearSelection

public void clearSelection()
(overridable) Reset the current selection.

Since:
3.1.0.0

setChildrenSort

public void setChildrenSort(OwSort childrenSort_p)
Set the children sort criteria.

Parameters:
childrenSort_p - - the OwSort criteria.
Since:
3.2.0.0

getChildrenSort

public OwSort getChildrenSort()
Get the currently set children sort criteria

Returns:
the OwSort children criteria.
Since:
3.2.0.0

refreshNodeForObject

public void refreshNodeForObject(Object param_p)
                          throws Exception
Tries to find the node for the given object and then refresh it.

Parameters:
param_p -
Throws:
Exception
Since:
4.0.0.0


Copyright © 2013 Alfresco Business Solutions. All Rights Reserved.