org.efaps.ui.wicket.models.objects
Class UIStructurBrowser

java.lang.Object
  extended by org.efaps.ui.wicket.models.AbstractInstanceObject
      extended by org.efaps.ui.wicket.models.objects.AbstractUIObject
          extended by org.efaps.ui.wicket.models.objects.AbstractUIPageObject
              extended by org.efaps.ui.wicket.models.objects.UIStructurBrowser
All Implemented Interfaces:
Serializable, org.apache.wicket.IClusterable
Direct Known Subclasses:
UIFieldStructurBrowser

public class UIStructurBrowser
extends AbstractUIPageObject

This class is used to provide the Model for the StructurBrowser for eFpas.
It is used in tow different cases. In one case it is a TreeTable, where the Table will be provided with additional information in columns. In the other case a Tree only.
The concept of this class is to provide a Model which connects through the eFaps-kernel to the eFaps-DataBase and turn it to a Standard TreeModel from javax.swing.tree. which will be used from the Component to render the Tree and the Table. This leads to a very similar behavior of the WebApp GUI to a swing GUI.
This model works asyncron. That means only the actually in the GUI rendered Nodes (and Columns) will be retrieved from the eFaps-DataBase. The next level in a tree will be retrieved on the expand of a TreeNode. To achieve this and to be able to render expand-links for every node it will only be checked if it is a potential parent (if it has children). In the case of expanding this Node the children will be retrieved and rendered.
To access the eFaps-Database a esjp is used, which will be used in five different cases. To distinguish the use of the esjp some extra Parameters will be passed to the esjp when calling it.

Version:
$Id: UIStructurBrowser.java 6302 2011-03-08 21:01:00Z jan@moxter.net $
Author:
The eFaps Team
See Also:
Serialized Form

Nested Class Summary
 class UIStructurBrowser.BogusNode
          This class is used to add a ChildNode under a ParentNode, if the ParentNode actually has some children.
static class UIStructurBrowser.ExecutionStatus
          Enum is used to set for this UIStructurBrowser which status of execution it is in.
 
Field Summary
static String USERSESSIONKEY
          Static part of the key to get the Information stored in the session in relation to this StruturBrowser.
 
Constructor Summary
  UIStructurBrowser(org.apache.wicket.PageParameters _parameters)
          Constructor.
  UIStructurBrowser(UUID _commandUUID, String _instanceKey)
          Standard constructor, if called this StructurBrowserModel will be defined as root.
protected UIStructurBrowser(UUID _commandUUID, String _instanceKey, boolean _root, org.efaps.admin.ui.AbstractCommand.SortDirection _sortdirection)
          Internal constructor, it is used to set that this StructurBrowserModel is not a root.
 
Method Summary
 void addBogusNode(DefaultMutableTreeNode _parent)
          Method to add a new BogusNode to the given Node.
 void addChildren(DefaultMutableTreeNode _parent)
          This method should be called to add children to a Node in the Tree.
e.g.
protected  boolean checkForAllowChilds(org.efaps.db.Instance _instance)
          This method is used to check if a node has potential children.
 boolean checkForAllowItems(org.efaps.db.Instance _instance)
          This method is used to check if a node has potential children.
protected  boolean checkForChildren(org.efaps.db.Instance _instance)
          This method is used to check if a node has potential children.
 void checkHideColumn4Row()
          Method is called from the StructurBrowser in edit mode before rendering the columns for row to be able to hide the columns for different rows by setting the cell model to hide.
 void execute()
          This method should be called to actually execute this StructurBrowserModel, that means to retrieve the values from the eFaps-DataBase, create the TreeModel etc.
 void executeListener(UIStructurBrowser.ExecutionStatus _status, Map<String,String> _uiID2Oid)
          This method is used to execute a listener with a specific event.
protected  void executeTree(Map<org.efaps.db.Instance,Boolean> _map, boolean _expand)
          This method is called in case of a Tree from the execute()method to fill this StructurBrowserModel with live.
protected  void executeTreeTable(Map<org.efaps.db.Instance,Boolean> _map, boolean _expand)
          This method is called in case of a TreeTable from the execute() method to fill this StructurBrowserModel with live.
protected  void expand(boolean _expand)
          Expand the tree with the information from the Session.
 int getBrowserFieldIndex()
          Getter method for the instance variable browserFieldIndex.
 String getBrowserFieldName()
          This is the getter method for the instance variable browserFieldName.
 String getCacheKey()
          This method generates the Key for a UserAttribute by using the UUID of the Command and the given static part, so that for every StruturBrowser a unique key for expand etc, is created.
 List<UIStructurBrowser> getChilds()
          Getter method for instance variable childs.
 UIStructurBrowser getClone4New()
           
 List<UIStructurBrowserTableCell> getColumns()
          This is the getter method for the instance variable columns.
 UIStructurBrowserTableCell getColumnValue(int _index)
          Get the Value of a Column identified by the index of the Column.
 Boolean getDirection()
          This is the getter method for the instance variable direction.
 UIStructurBrowser.ExecutionStatus getExecutionStatus()
          Getter method for instance variable executionStatus.
 List<UITableHeader> getHeaders()
          This is the getter method for the instance variable headers.
 String getImage()
          This is the getter method for the instance variable image.
protected  String getJavaScript4Target(Map<String,String[]> _parameters)
          Method is called from the StructurBrowser in edit mode from setValuesFromUI(Map, DefaultMutableTreeNode) to get additional JavaScript to be appended to the AjaxTarget.
 String getLabel()
          Getter method for instance variable label.
protected  UIStructurBrowser getNewStructurBrowser(org.efaps.db.Instance _instance, UIStructurBrowser _strucBrwsr)
          Internal method to call a constructor, it is used to set that this StructurBrowserModel is not a root.
protected  org.efaps.admin.AbstractAdminObject getObject4Event()
          Get the Admin Object that contains the events that must be executed.
 org.efaps.admin.ui.AbstractCommand.SortDirection getSortDirection()
          Getter method for instance variable sortDirection.
 org.efaps.admin.ui.Table getTable()
          This is the getter method for the instance variable #table.
 TreeModel getTreeModel()
          Get the TreeModel used in the Component to construct the actual tree.
protected  org.efaps.admin.datamodel.Type getTypeFromEvent()
          Method used to evaluate the type for this table from the connected events.
 boolean hasChilds()
          Has this StructurBrowserModel childs.
protected  void initialise()
          Method used to initialize this StructurBrowserModel.
 boolean isAllowChilds()
          Getter method for the instance variable allowChilds.
 boolean isAllowItems()
          Getter method for the instance variable allowItems.
 boolean isEditable()
          In create or edit mode this StructurBrowser is editable.
 boolean isExpanded()
          Getter method for instance variable expanded.
 boolean isForceExpanded()
          Getter method for the instance variable forceExpanded.
 boolean isRoot()
          Getter method for the instance variable root.
 boolean isShowCheckBoxes()
           
 void requeryLabel()
          This method is updating the Label, by querying the eFaps-DataBase.
 void resetModel()
          Method to reset the Model.
 void setAllowChilds(boolean _allowChilds)
          Setter method for instance variable allowChilds.
 void setAllowItems(boolean _allowItems)
          Setter method for instance variable allowItems.
protected  void setBrowserFieldIndex(int _browserFieldIndex)
          Setter method for instance variable browserFieldIndex.
protected  void setBrowserFieldName(String _browserFieldName)
          Setter method for instance variable browserFieldName.
 void setDirection(Boolean _direction)
          This is the setter method for the instance variable direction.
protected  void setExecutionStatus(UIStructurBrowser.ExecutionStatus _executionStatus)
          Setter method for instance variable executionStatus.
 void setExpanded(boolean _expanded)
          Setter method for instance variable expanded.
protected  void setForceExpanded(boolean _forceExpanded)
          Setter method for instance variable forceExpanded.
 void setParent(boolean _parent)
          This is the setter method for the instance variable parent.
protected  void setShowCheckBoxes(boolean _showCheckBoxes)
          Setter method for instance variable showCheckBoxes.
 void setSortDirection(org.efaps.admin.ui.AbstractCommand.SortDirection _sortDirection)
          Setter method for instance variable sortDirection and for all children also.
protected  void setTableuuid(UUID _tableuuid)
          Setter method for instance variable tableuuid.
 String setValuesFromUI(Map<String,String[]> _parameters, DefaultMutableTreeNode _node)
           
 void sort()
          Method to sort this model and all child models.
protected  void sortModel()
          Method to sort the data of this model.
 String toString()
          (non-Javadoc).
 
Methods inherited from class org.efaps.ui.wicket.models.objects.AbstractUIPageObject
addHidden, checkAccessToInstances, getAccessMap, getHelpTarget, getHiddenCells, getNewRandom, getTargetCmd, getTargetCmdUUID, getUiID2Oid, getValue4Wizard, getWizard, hasTargetCmd, isPartOfWizardCall, isRenderRevise, isTargetCmdRevise, isTargetShowFile, setPartOfWizardCall, setRenderRevise, setTargetCmdRevise, setTargetCmdUUID, setWizard
 
Methods inherited from class org.efaps.ui.wicket.models.objects.AbstractUIObject
addEventObject, executeEvents, getCallingCommand, getCallingCommandUUID, getCommand, getCommand, getCommandUUID, getInstanceFromManager, getMenuTreeKey, getMode, getOpenerId, getTarget, getTitle, hasInstanceManager, isCreateMode, isEditMode, isInitialized, isPicker, isPrintMode, isSearchMode, isSubmit, isViewMode, setCallingCommandUUID, setCommandUUID, setInitialized, setMode, setOpenerId, setSubmit, validate
 
Methods inherited from class org.efaps.ui.wicket.models.AbstractInstanceObject
getInstance, getInstanceKey, setInstanceKey
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

USERSESSIONKEY

public static final String USERSESSIONKEY
Static part of the key to get the Information stored in the session in relation to this StruturBrowser.

See Also:
Constant Field Values
Constructor Detail

UIStructurBrowser

public UIStructurBrowser(org.apache.wicket.PageParameters _parameters)
                  throws org.efaps.util.EFapsException
Constructor.

Parameters:
_parameters - Page parameters
Throws:
org.efaps.util.EFapsException - on error

UIStructurBrowser

public UIStructurBrowser(UUID _commandUUID,
                         String _instanceKey)
                  throws org.efaps.util.EFapsException
Standard constructor, if called this StructurBrowserModel will be defined as root.

Parameters:
_commandUUID - UUID of the calling command
_instanceKey - oid
Throws:
org.efaps.util.EFapsException - on error

UIStructurBrowser

protected UIStructurBrowser(UUID _commandUUID,
                            String _instanceKey,
                            boolean _root,
                            org.efaps.admin.ui.AbstractCommand.SortDirection _sortdirection)
                     throws org.efaps.util.EFapsException
Internal constructor, it is used to set that this StructurBrowserModel is not a root.

Parameters:
_commandUUID - UUID of the command
_instanceKey - OID
_root - is this STrtucturbrowser the root
_sortdirection - sort direction
Throws:
org.efaps.util.EFapsException - on error
Method Detail

getNewStructurBrowser

protected UIStructurBrowser getNewStructurBrowser(org.efaps.db.Instance _instance,
                                                  UIStructurBrowser _strucBrwsr)
                                           throws org.efaps.util.EFapsException
Internal method to call a constructor, it is used to set that this StructurBrowserModel is not a root.

Parameters:
_instance - Instance
_strucBrwsr - StructurBrowser the values will be copied from
Returns:
UIStructurBrowser
Throws:
org.efaps.util.EFapsException - on error

initialise

protected void initialise()
                   throws org.efaps.util.EFapsException
Method used to initialize this StructurBrowserModel.

Throws:
org.efaps.util.EFapsException - on error

execute

public void execute()
This method should be called to actually execute this StructurBrowserModel, that means to retrieve the values from the eFaps-DataBase, create the TreeModel etc. This method actually calls depending if we have a Tree or a TreeTabel the Methodes #executeTree(List) or #executeTreeTable(List)

Specified by:
execute in class AbstractUIObject
See Also:
#executeTree(List), #executeTreeTable(List)

executeTree

protected void executeTree(Map<org.efaps.db.Instance,Boolean> _map,
                           boolean _expand)
This method is called in case of a Tree from the execute()method to fill this StructurBrowserModel with live.

Parameters:
_map - List of Object
_expand - inside an expand

executeTreeTable

protected void executeTreeTable(Map<org.efaps.db.Instance,Boolean> _map,
                                boolean _expand)
This method is called in case of a TreeTable from the execute() method to fill this StructurBrowserModel with live.

Parameters:
_map - List of Objects
_expand - inside an expand

expand

protected void expand(boolean _expand)
Expand the tree with the information from the Session.

Parameters:
_expand - is this inside an expand

sortModel

protected void sortModel()
Method to sort the data of this model. It calls an esjp for sorting.


sort

public void sort()
Method to sort this model and all child models.


getClone4New

public UIStructurBrowser getClone4New()
                               throws org.efaps.util.EFapsException
Returns:
UIStructurBrowser
Throws:
org.efaps.util.EFapsException - on error

isForceExpanded

public boolean isForceExpanded()
Getter method for the instance variable forceExpanded.

Returns:
value of instance variable forceExpanded

setForceExpanded

protected void setForceExpanded(boolean _forceExpanded)
Setter method for instance variable forceExpanded.

Parameters:
_forceExpanded - value for instance variable forceExpanded

isAllowChilds

public boolean isAllowChilds()
Getter method for the instance variable allowChilds.

Returns:
value of instance variable allowChilds

setAllowChilds

public void setAllowChilds(boolean _allowChilds)
Setter method for instance variable allowChilds.

Parameters:
_allowChilds - value for instance variable allowChilds

isAllowItems

public boolean isAllowItems()
Getter method for the instance variable allowItems.

Returns:
value of instance variable allowItems

setAllowItems

public void setAllowItems(boolean _allowItems)
Setter method for instance variable allowItems.

Parameters:
_allowItems - value for instance variable allowItems

getTypeFromEvent

protected org.efaps.admin.datamodel.Type getTypeFromEvent()
                                                   throws org.efaps.util.EFapsException
Method used to evaluate the type for this table from the connected events.

Returns:
type if found
Throws:
org.efaps.util.EFapsException - on error

checkHideColumn4Row

public void checkHideColumn4Row()
Method is called from the StructurBrowser in edit mode before rendering the columns for row to be able to hide the columns for different rows by setting the cell model to hide.


addChildren

public void addChildren(DefaultMutableTreeNode _parent)
This method should be called to add children to a Node in the Tree.
e.g. in a standard implementation the children would be added to the Tree on the expand-Event of the tree. The children a retrieved from an esjp with the EventType UI_TABLE_EVALUATE.

Parameters:
_parent - the DefaultMutableTreeNode the new children should be added

checkForAllowChilds

protected boolean checkForAllowChilds(org.efaps.db.Instance _instance)
This method is used to check if a node has potential children.

Parameters:
_instance - Instance of a Node to be checked
Returns:
true if this Node has children, else false

executeListener

public void executeListener(UIStructurBrowser.ExecutionStatus _status,
                            Map<String,String> _uiID2Oid)
This method is used to execute a listener with a specific event.

Parameters:
_status - status to be executed
_uiID2Oid - UI Id 2 Oid mapping

checkForAllowItems

public boolean checkForAllowItems(org.efaps.db.Instance _instance)
This method is used to check if a node has potential children.

Parameters:
_instance - Instance of a Node to be checked
Returns:
true if this Node has children, else false

checkForChildren

protected boolean checkForChildren(org.efaps.db.Instance _instance)
This method is used to check if a node has potential children.

Parameters:
_instance - Instance of a Node to be checked
Returns:
true if this Node has children, else false

getJavaScript4Target

protected String getJavaScript4Target(Map<String,String[]> _parameters)
Method is called from the StructurBrowser in edit mode from setValuesFromUI(Map, DefaultMutableTreeNode) to get additional JavaScript to be appended to the AjaxTarget.

Parameters:
_parameters - Parameter as send from the UserInterface
Returns:
JavaScript for the UserInterface

setParent

public void setParent(boolean _parent)
This is the setter method for the instance variable parent.

Parameters:
_parent - the parent to set

resetModel

public void resetModel()
Method to reset the Model.

Specified by:
resetModel in class AbstractUIObject
See Also:
org.efaps.ui.wicket.models.AbstractModel#resetModel()

getTable

public org.efaps.admin.ui.Table getTable()
This is the getter method for the instance variable #table.

Returns:
value of instance variable #table
See Also:
#table

hasChilds

public boolean hasChilds()
Has this StructurBrowserModel childs.

Returns:
true if has children, else false

getTreeModel

public TreeModel getTreeModel()
Get the TreeModel used in the Component to construct the actual tree.

Returns:
TreeModel of this StructurBrowseModel
See Also:
addNode(DefaultMutableTreeNode, List)

setValuesFromUI

public String setValuesFromUI(Map<String,String[]> _parameters,
                              DefaultMutableTreeNode _node)
                       throws org.efaps.util.EFapsException
Parameters:
_parameters - Parameter as send from the UserInterface
_node - Node the _parameters were send from
Returns:
JavaScript for the UserInterface
Throws:
org.efaps.util.EFapsException - on error

getColumnValue

public UIStructurBrowserTableCell getColumnValue(int _index)
Get the Value of a Column identified by the index of the Column.

Parameters:
_index - index of the Column
Returns:
String with the Value of the Column

getColumns

public List<UIStructurBrowserTableCell> getColumns()
This is the getter method for the instance variable columns.

Returns:
value of instance variable columns

setBrowserFieldName

protected void setBrowserFieldName(String _browserFieldName)
Setter method for instance variable browserFieldName.

Parameters:
_browserFieldName - value for instance variable browserFieldName

setTableuuid

protected void setTableuuid(UUID _tableuuid)
Setter method for instance variable tableuuid.

Parameters:
_tableuuid - value for instance variable tableuuid

setBrowserFieldIndex

protected void setBrowserFieldIndex(int _browserFieldIndex)
Setter method for instance variable browserFieldIndex.

Parameters:
_browserFieldIndex - value for instance variable browserFieldIndex

getBrowserFieldIndex

public int getBrowserFieldIndex()
Getter method for the instance variable browserFieldIndex.

Returns:
value of instance variable browserFieldIndex

getBrowserFieldName

public String getBrowserFieldName()
This is the getter method for the instance variable browserFieldName.

Returns:
value of instance variable browserFieldName

getHeaders

public List<UITableHeader> getHeaders()
This is the getter method for the instance variable headers.

Returns:
value of instance variable headers

getImage

public String getImage()
This is the getter method for the instance variable image.

Returns:
value of instance variable image

getDirection

public Boolean getDirection()
This is the getter method for the instance variable direction.

Returns:
value of instance variable direction

setDirection

public void setDirection(Boolean _direction)
This is the setter method for the instance variable direction.

Parameters:
_direction - the direction to set

getExecutionStatus

public UIStructurBrowser.ExecutionStatus getExecutionStatus()
Getter method for instance variable executionStatus.

Returns:
value of instance variable executionStatus

requeryLabel

public void requeryLabel()
This method is updating the Label, by querying the eFaps-DataBase.


addBogusNode

public void addBogusNode(DefaultMutableTreeNode _parent)
Method to add a new BogusNode to the given Node.

Parameters:
_parent - Parent a BogusNode should be added

getChilds

public List<UIStructurBrowser> getChilds()
Getter method for instance variable childs.

Returns:
value of instance variable childs

getLabel

public String getLabel()
Getter method for instance variable label.

Returns:
value of instance variable label

getSortDirection

public org.efaps.admin.ui.AbstractCommand.SortDirection getSortDirection()
Getter method for instance variable sortDirection.

Returns:
value of instance variable sortDirection

setSortDirection

public void setSortDirection(org.efaps.admin.ui.AbstractCommand.SortDirection _sortDirection)
Setter method for instance variable sortDirection and for all children also.

Parameters:
_sortDirection - value for instance variable sortDirection

isExpanded

public boolean isExpanded()
Getter method for instance variable expanded.

Returns:
value of instance variable expanded

setExpanded

public void setExpanded(boolean _expanded)
Setter method for instance variable expanded.

Parameters:
_expanded - value for instance variable expanded

getCacheKey

public String getCacheKey()
This method generates the Key for a UserAttribute by using the UUID of the Command and the given static part, so that for every StruturBrowser a unique key for expand etc, is created.

Returns:
String with the key

setExecutionStatus

protected void setExecutionStatus(UIStructurBrowser.ExecutionStatus _executionStatus)
Setter method for instance variable executionStatus.

Parameters:
_executionStatus - value for instance variable executionStatus

getObject4Event

protected org.efaps.admin.AbstractAdminObject getObject4Event()
Get the Admin Object that contains the events that must be executed.

Returns:
the Admin Object that contains the events to be executed

isRoot

public boolean isRoot()
Getter method for the instance variable root.

Returns:
value of instance variable root

isShowCheckBoxes

public boolean isShowCheckBoxes()
Returns:
true if the check boxes must be shown, other false is returned.
See Also:
showCheckBoxes

setShowCheckBoxes

protected void setShowCheckBoxes(boolean _showCheckBoxes)
Setter method for instance variable showCheckBoxes.

Parameters:
_showCheckBoxes - value for instance variable showCheckBoxes

isEditable

public boolean isEditable()
In create or edit mode this StructurBrowser is editable.

Returns:
is this StructurBrowser editable.

toString

public String toString()
(non-Javadoc).

Overrides:
toString in class Object
Returns:
label
See Also:
Model.toString()


Copyright © 2003-2011 The eFaps Team. All Rights Reserved.