LEONARDI Application Composer - 8.9.0.40 by W4 S.A.

leon.app.behavior
Class LyTableBehavior

java.lang.Object
  extended by leon.app.behavior.LyBehavior
      extended by leon.app.behavior.LyActionBehavior
          extended by leon.app.behavior.LyPanelBehavior
              extended by leon.app.behavior.LyTableBehavior
All Implemented Interfaces:
LyActionBehaviorInterface, LyBehaviorInterface, LyPanelBehaviorInterface, LyTableBehaviorInterface, LyGetSessionInterface
Direct Known Subclasses:
LyEditTableBehavior, LyImportTableBehavior, LySocialBehavior

public class LyTableBehavior
extends LyPanelBehavior
implements LyTableBehaviorInterface

This class implements the default behavior for a table controller.

See Also:
LyTableController, LyTableBehaviorInterface

Field Summary
static java.lang.String __VERSION
          File version
static short MAX_ROW_HEIGHT
          Max row height.
 
Constructor Summary
LyTableBehavior()
          Default constructor.
 
Method Summary
 LyComponent buildRowItem(LySimpleTableController tableController, LyObject object, LyFieldInfo fieldInfo)
          Current builder of a new cell in a row.
 void completeRow(LySimpleTableController tableController, LyRow row, LyObject object)
          Completes the given row that corresponds to specified object.
 void dragFinished(LySimpleTableController tableController, int type)
          Method called at the end of a drag-and-drop.
 void dragStart(LySimpleTableController tableController, LyObject draggedObject)
          Method invoked at the beginning of the given object drag.
 void drop(LySimpleTableController tableController, LyObject droppedObject, LyObject draggedObject)
          Method called when the given dragged object is dropped on the given dropped object.
 boolean enableGroupBy(LySimpleTableController tableController, LyFieldInfo fieldInfo)
          Enables groupBy feature on given field info.
 java.lang.String getCellImage(LySimpleTableController tableController, LyObject object, LyFieldInfo fieldInfo, java.lang.String newLabel)
          Gets the cell image representing the value of the specified field info for the given object.
 java.lang.String getCellLabel(LySimpleTableController controller, LyObject object, LyFieldInfo fieldInfo)
          Deprecated. Use LyTableBehaviorInterface.updateCell(LySimpleTableController, LyCell, LyObject, LyFieldInfo) instead.
 java.lang.String getCellLabel(LySimpleTableController controller, LyObject object, LyFieldInfo fieldInfo, java.lang.Object value)
          Gets the cell label representing the value of the given field info for the given object.
 java.lang.String getCellObjectId(LySimpleTableController controller, LyObject object, LyFieldInfo fieldInfo)
          Gets the cell object id that displays the value of the given field info for the given object.
 LyInfoList<LyFieldInfo> getChooseColumnsFieldInfos(LySimpleTableController controller)
          Gets the list of fieldinfos that may be displayed in the column chooser tool.
 double getColumnWidth(LySimpleTableController controller, LyFieldInfo fieldInfo)
          Gets the initial column width of a fieldInfo in a table.
 LyWorkSpace getContent(LyTableController tableController, LyWorkSpace context)
          Gets the content of the table corresponding of the given context.
 LySortCriterion getDefaultCriterion(LySimpleTableController tableController, LyFieldInfo fieldInfo)
          Return default criterion for a given field info.
 LyInfoList<LyFieldInfo> getDependsFieldInfos(LySimpleTableController tableController, LyAction action)
          Gets the list of fieldinfos that will be used to compute/display values for the table.
 LyFileFieldInfo getDisplayListFirstImage(LySimpleTableController tableController)
          Gives the image to display in first column in list display.
 LyInfoList<LyFieldInfo> getFields(LySimpleTableController tableController, LyInfoList<LyFieldInfo> fields)
          Gets the list of fields to display in the table from the given list.
 java.lang.String getFooterLabel(LySimpleTableController controller, LyFieldInfo fieldInfo, LyObjectList objects)
          Gets the footer label associated to the given field info for the given list of objects presented in the table.
 java.lang.String getGroupColor(LySimpleTableController tableController, LyObject object, LyFieldInfoValue value)
          Gets row color associated to the given group.
 java.lang.String getGroupLabel(LySimpleTableController tableController, LyObject object, LyFieldInfoValue value)
          Gets group name for given value on specified object.
 java.lang.String getHeaderLabel(LySimpleTableController controller, LyFieldInfo fieldInfo)
          Gets the header label representing the given field info.
 java.lang.String getHeaderTooltip(LySimpleTableController controller, LyFieldInfo fieldInfo)
          Gets the header tooltip associated to the given field info.
 java.lang.String getIndex(LySimpleTableController tableController, LyObject object)
          Gets index for object.
 java.lang.String getLabel(LySimpleTableController tableController, LyObject object)
          Gets label for object.
 LyInfoList<LyFieldInfo> getLoadedFieldInfos(LySimpleTableController controller)
          Gets the list of fieldinfos that must be loaded in the given table controller.
 java.lang.String getRowColor(LySimpleTableController controller, LyObject object)
          Gets row color associated to the given object.
 java.lang.String getRowImage(LySimpleTableController tableController, LyObject object)
          Gets the row image of the given table object used on display list mode.
 java.lang.String[] getShortLabel(LySimpleTableController controller, LyObject object, LyFieldInfo fieldInfo, java.lang.Object value)
          Gets short label of an object, for specified field info and value.
 java.lang.String getStatusImage(LySimpleTableController controller, LyInfoList<LyFieldInfo> statusFields, LyObject object)
          Gets the status image of the given object.
 java.lang.String getStatusTooltip(LySimpleTableController tableController, LyInfoList<LyFieldInfo> statusFields, LyObject object)
          Gets status image tooltip for the given object.
 void selectionChanged(LySimpleTableController controller)
          Method called when the selection has changed in the view.
 void updateCell(LySimpleTableController tableController, LyCell cell, LyObject object, LyFieldInfo fieldInfo)
          Updates the label of the given cell for the given object and fieldinfo.
 void updateRowItem(LySimpleTableController tableController, LyComponent component, LyObject object, LyFieldInfo fieldInfo)
          Updates the given component for the given object and fieldinfo.
 LySort validateSort(LySimpleTableController tableController, LySort sort)
          Method used to enable a sort.
 
Methods inherited from class leon.app.behavior.LyPanelBehavior
completePopupMenu, getPopupMenuActions, getTitle, needRefresh, validateFilter
 
Methods inherited from class leon.app.behavior.LyActionBehavior
endAction, getClientContext, getContextTitle, getHelpFile, getImage, getImageTooltip, getKeyValue, getMenuItemImage, reset, startAction
 
Methods inherited from class leon.app.behavior.LyBehavior
free, getSession, handleDemand, init
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface leon.app.behaviorinterface.LyPanelBehaviorInterface
completePopupMenu, getPopupMenuActions, needRefresh, validateFilter
 
Methods inherited from interface leon.app.behaviorinterface.LyActionBehaviorInterface
endAction, getClientContext, getContextTitle, getHelpFile, getImage, getImageTooltip, getKeyValue, getMenuItemImage, getTitle, reset, startAction
 
Methods inherited from interface leon.app.behaviorinterface.LyBehaviorInterface
free, handleDemand, init
 

Field Detail

__VERSION

public static final java.lang.String __VERSION
File version

See Also:
Constant Field Values

MAX_ROW_HEIGHT

public static short MAX_ROW_HEIGHT
Max row height.

Constructor Detail

LyTableBehavior

public LyTableBehavior()
Default constructor.

Method Detail

getFields

public LyInfoList<LyFieldInfo> getFields(LySimpleTableController tableController,
                                         LyInfoList<LyFieldInfo> fields)
Gets the list of fields to display in the table from the given list.
The default implementation does nothing and return the given list without any changes.

Specified by:
getFields in interface LyTableBehaviorInterface
Parameters:
tableController - the table controller that requires the list
fields - a list of fields from where fields to display are taken
Returns:
The list of fields to display in the table.

getStatusImage

public java.lang.String getStatusImage(LySimpleTableController controller,
                                       LyInfoList<LyFieldInfo> statusFields,
                                       LyObject object)
Gets the status image of the given object.
The default implementation returns the image if it is found or null if

Specified by:
getStatusImage in interface LyTableBehaviorInterface
Parameters:
controller - Table controller that requires the status image.
statusFields - List of field infos that have the status mark.
object - Object to which the status image is associated.
Returns:
Path to the image file or the name of an image resource if found, null otherwise.

getStatusTooltip

public java.lang.String getStatusTooltip(LySimpleTableController tableController,
                                         LyInfoList<LyFieldInfo> statusFields,
                                         LyObject object)
Gets status image tooltip for the given object.
This method is called only if the getStatusImage(LySimpleTableController, LyInfoList, LyObject) method didn't return null.
The default implementation computes a string from the given object class info name, the object name, fields name and values of the given list found in the object.

Specified by:
getStatusTooltip in interface LyTableBehaviorInterface
Parameters:
tableController - Table controller that requires the status image.
statusFields - List of field infos that have the status mark.
object - Object to which the status image is associated.
Returns:
String containing the tooltip associated to the status image.

getRowColor

public java.lang.String getRowColor(LySimpleTableController controller,
                                    LyObject object)
Gets row color associated to the given object.
The default implementation does nothing and returns null.

Specified by:
getRowColor in interface LyTableBehaviorInterface
Parameters:
controller - Table controller that requires the row color.
object - Object for which a row color is required.
Returns:
Color name or the name of a color resource if any, null otherwise.

getRowImage

public java.lang.String getRowImage(LySimpleTableController tableController,
                                    LyObject object)
Gets the row image of the given table object used on display list mode.

Specified by:
getRowImage in interface LyTableBehaviorInterface
Parameters:
tableController - Table controller that requires the row image.
object - Object to which the row image is associated.
Returns:
Path to the image file or the name of an image resource if found, null otherwise.

getHeaderLabel

public java.lang.String getHeaderLabel(LySimpleTableController controller,
                                       LyFieldInfo fieldInfo)
Gets the header label representing the given field info.
The default implementation returns the field internal alias is it is not null, else returns the field info label of type name if it is not null, else returns the field alias.

Specified by:
getHeaderLabel in interface LyTableBehaviorInterface
Parameters:
controller - Table controller that requires the header label.
fieldInfo - Field info for which a header label is required.
Returns:
Label that will be put in the table header for the given field info.

getHeaderTooltip

public java.lang.String getHeaderTooltip(LySimpleTableController controller,
                                         LyFieldInfo fieldInfo)
Gets the header tooltip associated to the given field info.
The default implementation returns the name, the field unit if any and the field tip. If the tip is null, the name is used instead.

Specified by:
getHeaderTooltip in interface LyTableBehaviorInterface
Parameters:
controller - Table controller that requires the header tooltip.
fieldInfo - Field info for which a header tooltip is required.
Returns:
Label that will be put in the table header tooltip corresponding to the given field info.

getCellLabel

public java.lang.String getCellLabel(LySimpleTableController controller,
                                     LyObject object,
                                     LyFieldInfo fieldInfo)
Deprecated. Use LyTableBehaviorInterface.updateCell(LySimpleTableController, LyCell, LyObject, LyFieldInfo) instead.

Gets the cell label representing the value of the given field info for the given object.
The default implementation returns null if the given object is null, calls getCellLabel(controller, object, fieldInfo, object.getValue(fieldInfo)) otherwise.

Specified by:
getCellLabel in interface LyTableBehaviorInterface
Parameters:
controller - Table controller that requires the cell label.
object - Object from which the field info value is represented in the table cell.
fieldInfo - Field info for which a cell label is required.
Returns:
Label that will be put in the table cell for the given object and field info (may be null).
See Also:
getCellLabel(LySimpleTableController, LyObject, LyFieldInfo, Object)

getCellLabel

public java.lang.String getCellLabel(LySimpleTableController controller,
                                     LyObject object,
                                     LyFieldInfo fieldInfo,
                                     java.lang.Object value)
Gets the cell label representing the value of the given field info for the given object.
The default implementation returns null if the given value is null, else if the given field is a choice field, builds a label from the short label) list. Else if the field is an array, builds a label with sub fields label.

Specified by:
getCellLabel in interface LyTableBehaviorInterface
Parameters:
controller - the table controller that requires the cell label
object - the object from which the field info value is represented in the table cell
fieldInfo - the field info for which a cell label is required
value - the given field value
Returns:
Label that will be put in the table cell for the given object and field info (may be null).
See Also:
LyTableBehaviorInterface.updateCell(LySimpleTableController,LyCell,LyObject,LyFieldInfo)

getShortLabel

public java.lang.String[] getShortLabel(LySimpleTableController controller,
                                        LyObject object,
                                        LyFieldInfo fieldInfo,
                                        java.lang.Object value)
Gets short label of an object, for specified field info and value.

Parameters:
controller - the table controller
object - list of Object for which a short label is required.
fieldInfo - field info.
value - the given field value
Returns:
String[] list of label as a string.

getCellObjectId

public java.lang.String getCellObjectId(LySimpleTableController controller,
                                        LyObject object,
                                        LyFieldInfo fieldInfo)
Gets the cell object id that displays the value of the given field info for the given object.

Parameters:
controller - Table controller that requires the cell.
object - Object from which the field info value is represented in the table cell.
fieldInfo - Field info for which a cell is required.
Returns:
Object id that will be put in the table cell for the given object and field info (may be null).

updateCell

public void updateCell(LySimpleTableController tableController,
                       LyCell cell,
                       LyObject object,
                       LyFieldInfo fieldInfo)
Updates the label of the given cell for the given object and fieldinfo.
The default implementation updates the given cell label if needed, the cell object id if the given field is a relation field and if the view manager manages urls. If the given field is a file field, updates the cell label, Hlink and image.

Specified by:
updateCell in interface LyTableBehaviorInterface
Parameters:
tableController - the table controller that requires the cell label
cell - the cell to update
object - the object from which the field info value is represented in the table cell
fieldInfo - the field info for which a cell label is required

getCellImage

public java.lang.String getCellImage(LySimpleTableController tableController,
                                     LyObject object,
                                     LyFieldInfo fieldInfo,
                                     java.lang.String newLabel)
Gets the cell image representing the value of the specified field info for the given object.

Parameters:
tableController - Table controller that requires the cell image.
object - Object from which the field info value is represented in the table cell.
fieldInfo - Field info for which a cell image is required.
newLabel - Value of the field info given as a string.
Returns:
Image that will be put in the table cell for the given object and field info (may be null).

getFooterLabel

public java.lang.String getFooterLabel(LySimpleTableController controller,
                                       LyFieldInfo fieldInfo,
                                       LyObjectList objects)
Gets the footer label associated to the given field info for the given list of objects presented in the table.

Specified by:
getFooterLabel in interface LyTableBehaviorInterface
Parameters:
controller - Table controller that requires the footer label.
fieldInfo - Field info for which a footer label is required.
objects - List of objects for which a footer label is computed.
Returns:
Label that will be put in the table footer that is corresponding to the given field info for the given list of objects.
See Also:
LyFieldInfo.compute(LyObjectList)

selectionChanged

public void selectionChanged(LySimpleTableController controller)
Method called when the selection has changed in the view.
The default implementation does nothing.

Specified by:
selectionChanged in interface LyTableBehaviorInterface
Parameters:
controller - the current table controller

getContent

public LyWorkSpace getContent(LyTableController tableController,
                              LyWorkSpace context)
Gets the content of the table corresponding of the given context.
The workspace must be dynamic for dynamic table updates.
If the returned workspace is null, the controller computes the content itself.
The default implementation does nothing and returns null.

Specified by:
getContent in interface LyTableBehaviorInterface
Parameters:
tableController - Table controller that requires the content.
context - Context for which the content is required.
Returns:
the table content.

getLoadedFieldInfos

public LyInfoList<LyFieldInfo> getLoadedFieldInfos(LySimpleTableController controller)
Gets the list of fieldinfos that must be loaded in the given table controller.
The default implementation returns all fieldinfos with the status mark and all fieldinfos that are displayed in the table.

Specified by:
getLoadedFieldInfos in interface LyTableBehaviorInterface
Parameters:
controller - Table controller that requires the list.
Returns:
The list of fields info to load.

getDependsFieldInfos

public LyInfoList<LyFieldInfo> getDependsFieldInfos(LySimpleTableController tableController,
                                                    LyAction action)
Gets the list of fieldinfos that will be used to compute/display values for the table.
The default implementation returns the list of loaded fields.

Specified by:
getDependsFieldInfos in interface LyTableBehaviorInterface
Parameters:
tableController - the associated table controller
action - the table action
Returns:
a list of fieldinfos
See Also:
getLoadedFieldInfos(LySimpleTableController)

getChooseColumnsFieldInfos

public LyInfoList<LyFieldInfo> getChooseColumnsFieldInfos(LySimpleTableController controller)
Gets the list of fieldinfos that may be displayed in the column chooser tool.
The default implementation does nothing and returns null.

Specified by:
getChooseColumnsFieldInfos in interface LyTableBehaviorInterface
Parameters:
controller - Table controller that requires the list.
Returns:
the list of fields to display in the column chooser tool or null to let the controller build this list.

getColumnWidth

public double getColumnWidth(LySimpleTableController controller,
                             LyFieldInfo fieldInfo)
Gets the initial column width of a fieldInfo in a table.
The default implementation returns the "_colWidth" parameter from the table action.

Specified by:
getColumnWidth in interface LyTableBehaviorInterface
Parameters:
controller - Table controller that requires the list.
fieldInfo - fieldInfo associated to this column.
Returns:
the size (unit = number of characters) of the column or -1 (default) to compute automatically

dragStart

public void dragStart(LySimpleTableController tableController,
                      LyObject draggedObject)
Method invoked at the beginning of the given object drag.
The default implementation keep in the controller session memory that the object is dragged and log a trace.

Specified by:
dragStart in interface LyTableBehaviorInterface
Parameters:
tableController - Table controller that displays the table
draggedObject - dragged object

drop

public void drop(LySimpleTableController tableController,
                 LyObject droppedObject,
                 LyObject draggedObject)
Method called when the given dragged object is dropped on the given dropped object.
The default implementation only logs a trace.

Specified by:
drop in interface LyTableBehaviorInterface
Parameters:
tableController - table controller that displays the table
droppedObject - object on where the dragged object is dropped
draggedObject - the dragged object

dragFinished

public void dragFinished(LySimpleTableController tableController,
                         int type)
Method called at the end of a drag-and-drop.
The default implementation does nothing.

Specified by:
dragFinished in interface LyTableBehaviorInterface
Parameters:
tableController - table controller that displays the tree
type - drag-and-drop type (org.eclipse.swt.dnd.DND#DROP_COPY or org.eclipse.swt.dnd.DND#DROP_MOVE)

validateSort

public LySort validateSort(LySimpleTableController tableController,
                           LySort sort)
Method used to enable a sort.

Specified by:
validateSort in interface LyTableBehaviorInterface
Parameters:
tableController - Table controller that asks for the sort.
sort - The sort that is asked.
Returns:
The enabled sort.

enableGroupBy

public boolean enableGroupBy(LySimpleTableController tableController,
                             LyFieldInfo fieldInfo)
Enables groupBy feature on given field info.

Specified by:
enableGroupBy in interface LyTableBehaviorInterface
Parameters:
tableController - the table controller
fieldInfo - Field info that is checked for groupBy feature.
Returns:
True if enabled, false otherwise.

getGroupLabel

public java.lang.String getGroupLabel(LySimpleTableController tableController,
                                      LyObject object,
                                      LyFieldInfoValue value)
Gets group name for given value on specified object.

Specified by:
getGroupLabel in interface LyTableBehaviorInterface
Parameters:
tableController - Table controller that requires the group value label.
object - Object from which the group is requested.
value - Field value for which the group is requested.
Returns:
The group label for given value.

getGroupColor

public java.lang.String getGroupColor(LySimpleTableController tableController,
                                      LyObject object,
                                      LyFieldInfoValue value)
Gets row color associated to the given group.

Specified by:
getGroupColor in interface LyTableBehaviorInterface
Parameters:
tableController - Table controller that requires the row color.
object - Group for which a row color is asked.
value - the value needed to compute the color
Returns:
Color name or the name of a color resource if any, null otherwise.

buildRowItem

public LyComponent buildRowItem(LySimpleTableController tableController,
                                LyObject object,
                                LyFieldInfo fieldInfo)
Current builder of a new cell in a row.

Specified by:
buildRowItem in interface LyTableBehaviorInterface
Parameters:
tableController - Table controller that requires the new row item.
object - object added in the contextual list, and which should set the content of row cells.
fieldInfo - field value shown in the cell content
Returns:
LyCell or LyFieldItem the new Cell description (XML description) or editable content to add in the LyRow component.

updateRowItem

public void updateRowItem(LySimpleTableController tableController,
                          LyComponent component,
                          LyObject object,
                          LyFieldInfo fieldInfo)
Updates the given component for the given object and fieldinfo.

Specified by:
updateRowItem in interface LyTableBehaviorInterface
Parameters:
tableController - the table controller that requires the update
component - the component to update.
object - the object from which the field info value is represented in the table.
fieldInfo - the field info for which a component is updated.

completeRow

public void completeRow(LySimpleTableController tableController,
                        LyRow row,
                        LyObject object)
Completes the given row that corresponds to specified object.

Specified by:
completeRow in interface LyTableBehaviorInterface
Parameters:
tableController - the table controller that requires the completion.
row - the row to be completed.
object - the object that corresponds to the row.

getDisplayListFirstImage

public LyFileFieldInfo getDisplayListFirstImage(LySimpleTableController tableController)
Gives the image to display in first column in list display.

Specified by:
getDisplayListFirstImage in interface LyTableBehaviorInterface
Parameters:
tableController - the table controller.
Returns:
a LyFileFieldInfo which contains the image else return null

getLabel

public java.lang.String getLabel(LySimpleTableController tableController,
                                 LyObject object)
Gets label for object.

Specified by:
getLabel in interface LyTableBehaviorInterface
Parameters:
tableController - the table controller.
object - Object for which the label is requested.
Returns:
The label for given object.

getIndex

public java.lang.String getIndex(LySimpleTableController tableController,
                                 LyObject object)
Gets index for object.

Specified by:
getIndex in interface LyTableBehaviorInterface
Parameters:
tableController - the table controller.
object - Object for which the index is requested.
Returns:
The index for given object.

getDefaultCriterion

public LySortCriterion getDefaultCriterion(LySimpleTableController tableController,
                                           LyFieldInfo fieldInfo)
Return default criterion for a given field info. If no default sort is defined on the class, return null.

Specified by:
getDefaultCriterion in interface LyTableBehaviorInterface
Parameters:
tableController - the table controller.
fieldInfo - the field info we want to get the criterion
Returns:
the default sort criterion for the given field info

(c) January 2013 - W4 S.A.

Website: W4 S.A., contact us: support@w4global.com