to.etc.domui.component.tbl
Class DataTable<T>

java.lang.Object
  extended by to.etc.domui.dom.css.CssBase
      extended by to.etc.domui.dom.html.NodeBase
          extended by to.etc.domui.dom.html.NodeContainer
              extended by to.etc.domui.dom.html.Div
                  extended by to.etc.domui.component.tbl.TableModelTableBase<T>
                      extended by to.etc.domui.component.tbl.TabularComponentBase<T>
                          extended by to.etc.domui.component.tbl.DataTable<T>
All Implemented Interfaces:
java.lang.Iterable<NodeBase>, IModelBinding, ISelectableTableComponent<T>, ISelectionListener<T>, ITableModelListener<T>, INodeErrorDelegate, IDraggable, IDropTargetable
Direct Known Subclasses:
CheckBoxDataTable, MultipleSelectionDataTable

public class DataTable<T>
extends TabularComponentBase<T>
implements ISelectionListener<T>, ISelectableTableComponent<T>

POC for a datatable based on the live dom code.

Author:
Frits Jalvingh Created on Jun 1, 2008

Field Summary
 
Fields inherited from class to.etc.domui.component.tbl.TabularComponentBase
m_eix, m_six
 
Constructor Summary
DataTable(ITableModel<T> m)
           
DataTable(ITableModel<T> m, IRowRenderer<T> r)
           
 
Method Summary
 void createContent()
           
protected  TBody getDataBody()
           
 int getPageSize()
          Return the page size: the #of records to show.
 IRowRenderer<T> getRowRenderer()
           
 ISelectionAllHandler getSelectionAllHandler()
          If this component has a way to execute "select all", it should return a thing that does that.
 ISelectionModel<T> getSelectionModel()
          Return the model used for table selections, if applicable.
protected  Table getTable()
          Return the backing table for this data browser.
 boolean isMultiSelectionVisible()
           
 boolean isShowSelectionAlways()
          When T and a selection model in multiselect mode is present, this causes the checkboxes to be rendered initially even when no selection is made.
 void modelChanged(ITableModel<T> model)
          Called when there are sweeping changes to the model.
protected  void onForceRebuild()
          Called when forceRebuild is done on this node.
 void rowAdded(ITableModel<T> model, int index, T value)
          Row add.
 void rowDeleted(ITableModel<T> model, int index, T value)
          Delete the row specified.
 void rowModified(ITableModel<T> model, int index, T value)
          Merely force a full redraw of the appropriate row.
 void selectionAllChanged()
          Called when a selection cleared event fires.
 void selectionChanged(T row, boolean on)
          Called when a selection event fires.
protected  void setDataBody(TBody dataBody)
          UNSTABLE INTERFACE - UNDER CONSIDERATION.
 void setPageSize(int pageSize)
          Set the page size: the #of records to show.
 void setRowRenderer(IRowRenderer<T> rowRenderer)
           
 void setSelectionAllHandler(ISelectionAllHandler selectionAllHandler)
           
 void setSelectionModel(ISelectionModel<T> selectionModel)
          Set the model to maintain selections, if this table allows selections.
 void setShowSelection(boolean showSelectionAlways)
          When T and a selection model in multiselect mode is present, this causes the checkboxes to be rendered initially even when no selection is made.
 void setTableWidth(java.lang.String w)
           
 
Methods inherited from class to.etc.domui.component.tbl.TabularComponentBase
addChangeListener, calcIndices, fireModelChanged, firePageChanged, fireSelectionUIChanged, getCurrentPage, getPageCount, getPageItems, getTruncatedCount, removeChangeListener, setCurrentPage
 
Methods inherited from class to.etc.domui.component.tbl.TableModelTableBase
getModel, getModelItem, onRefresh, onShelve, onUnshelve, setModel
 
Methods inherited from class to.etc.domui.dom.html.Div
afterCreateContent, componentHandleWebAction, fadeIn, fadeOut, getCustomUpdatesCallJS, getDragHandler, getDropBody, getDropHandler, getDropMode, getReturnPressed, setDragHandler, setDropBody, setDropHandler, setReturnPressed, slideDown, slideUp, tb, visit
 
Methods inherited from class to.etc.domui.dom.html.NodeContainer
add, add, add, addTable, canContain, delegateTo, findChildIndex, forceRebuild, getChild, getChildCount, getChildren, getDeepChild, getDeepChildren, getErrorFence, internalCheckNotDirty, internalClearDelta, internalClearDeltaFully, internalGetOldChildren, internalShelve, internalUnshelve, iterator, moveControlToModel, moveModelToControl, removeAllChildren, removeChild, removeChild, replaceChild, setControlsEnabled, setErrorFence, setErrorFence, setText, setValue
 
Methods inherited from class to.etc.domui.dom.html.NodeBase
$, acceptRequestParameter, addCssClass, addGlobalMessage, appendAfterMe, appendBeforeMe, appendCreateJS, appendJavascript, build, changed, clearFocusRequested, clearGlobalMessage, clearGlobalMessage, clearGlobalMessage, clearMessage, findComponentBundle, getActualID, getAllocationTracepoint, getClicked, getComponentBundle, getCreateJS, getCssClass, getErrorDelegate, getErrorLocation, getMessage, getOnClickJS, getOnMouseDownJS, getPage, getParent, getParent, getParent, getSharedContext, getSpecialAttribute, getSpecialAttributeList, getTag, getTestID, getTitle, getUserObject, handleDrop, hasCssClass, hasError, internalGetOldParent, internalHasChangedAttributes, internalNeedClickHandler, internalOnClicked, internalOnValueChanged, internalSetHasChangedAttributes, internalSetHasChangedAttributes, internalSetLogAllocations, internalSetTag, isBuilt, isFocusRequested, isStretchHeight, onAddedToPage, onBeforeFullRender, onHeaderContributors, onRemoveFromPage, refresh, remove, removeCssClass, renderJavascriptState, replaceWith, setClicked, setComponentBundle, setCssClass, setErrorDelegate, setErrorLocation, setFocus, setMessage, setOnClickJS, setOnMouseDownJS, setSpecialAttribute, setStretchHeight, setTestID, setTitle, setUserObject, toString
 
Methods inherited from class to.etc.domui.dom.css.CssBase
getBackgroundAttachment, getBackgroundColor, getBackgroundImage, getBackgroundPosition, getBackgroundRepeat, getBorderBottomColor, getBorderBottomStyle, getBorderBottomWidth, getBorderLeftColor, getBorderLeftStyle, getBorderLeftWidth, getBorderRightColor, getBorderRightStyle, getBorderRightWidth, getBorderTopColor, getBorderTopStyle, getBorderTopWidth, getBottom, getCachedStyle, getClear, getColor, getDisplay, getFloat, getFontFamily, getFontSize, getFontSizeAdjust, getFontStyle, getFontVariant, getFontWeight, getHeight, getLeft, getLineHeight, getMarginBottom, getMarginLeft, getMarginRight, getMarginTop, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOverflow, getPosition, getRight, getTextAlign, getTop, getTransform, getVerticalAlign, getVisibility, getWidth, getZIndex, internalSetDisplay, setBackgroundAttachment, setBackgroundColor, setBackgroundImage, setBackgroundPosition, setBackgroundRepeat, setBorder, setBorder, setBorderBottomColor, setBorderBottomStyle, setBorderBottomWidth, setBorderColor, setBorderLeftColor, setBorderLeftStyle, setBorderLeftWidth, setBorderRightColor, setBorderRightStyle, setBorderRightWidth, setBorderStyle, setBorderTopColor, setBorderTopStyle, setBorderTopWidth, setBorderWidth, setBottom, setBottom, setCachedStyle, setClear, setColor, setDisplay, setFloat, setFontFamily, setFontSize, setFontSizeAdjust, setFontStyle, setFontVariant, setFontWeight, setHeight, setLeft, setLeft, setLineHeight, setMargin, setMarginBottom, setMarginLeft, setMarginRight, setMarginTop, setMaxHeight, setMaxWidth, setMinHeight, setMinWidth, setOverflow, setPosition, setRight, setRight, setTextAlign, setTop, setTop, setTransform, setVerticalAlign, setVisibility, setWidth, setZIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface to.etc.domui.component.tbl.ISelectableTableComponent
getModel
 

Constructor Detail

DataTable

public DataTable(@Nonnull
                 ITableModel<T> m,
                 @Nonnull
                 IRowRenderer<T> r)

DataTable

public DataTable(@Nonnull
                 ITableModel<T> m)
Method Detail

getTable

@Nullable
protected Table getTable()
Return the backing table for this data browser. For component extension only - DO NOT MAKE PUBLIC.

Returns:

setDataBody

protected void setDataBody(@Nullable
                           TBody dataBody)
UNSTABLE INTERFACE - UNDER CONSIDERATION.

Parameters:
dataBody -

getDataBody

@Nullable
protected TBody getDataBody()

createContent

public void createContent()
                   throws java.lang.Exception
Overrides:
createContent in class NodeBase
Throws:
java.lang.Exception

isShowSelectionAlways

public boolean isShowSelectionAlways()
When T and a selection model in multiselect mode is present, this causes the checkboxes to be rendered initially even when no selection is made.

Returns:

isMultiSelectionVisible

public boolean isMultiSelectionVisible()
Specified by:
isMultiSelectionVisible in interface ISelectableTableComponent<T>

setShowSelection

public void setShowSelection(boolean showSelectionAlways)
                      throws java.lang.Exception
When T and a selection model in multiselect mode is present, this causes the checkboxes to be rendered initially even when no selection is made.

Specified by:
setShowSelection in interface ISelectableTableComponent<T>
Parameters:
showSelectionAlways -
Throws:
java.lang.Exception

getPageSize

public int getPageSize()
Return the page size: the #of records to show. If <= 0 all records are shown.


setPageSize

public void setPageSize(int pageSize)
Set the page size: the #of records to show. If <= 0 all records are shown.

Parameters:
pageSize -

modelChanged

public void modelChanged(@Nullable
                         ITableModel<T> model)
Called when there are sweeping changes to the model. It forces a complete re-render of the table.

Specified by:
modelChanged in interface ITableModelListener<T>

rowAdded

public void rowAdded(@Nonnull
                     ITableModel<T> model,
                     int index,
                     @Nullable
                     T value)
              throws java.lang.Exception
Row add. Determine if the row is within the paged-in indexes. If not we ignore the request. If it IS within the paged content we insert the new TR. Since this adds a new row to the visible set we check if the resulting rowset is not bigger than the page size; if it is we delete the last node. After all this the renderer will render the correct result. When called the actual insert has already taken place in the model.

Specified by:
rowAdded in interface ITableModelListener<T>
Throws:
java.lang.Exception
See Also:
ITableModelListener.rowAdded(to.etc.domui.component.tbl.ITableModel, int, java.lang.Object)

rowDeleted

public void rowDeleted(@Nonnull
                       ITableModel<T> model,
                       int index,
                       @Nullable
                       T value)
                throws java.lang.Exception
Delete the row specified. If it is not visible we do nothing. If it is visible we delete the row. This causes one less row to be shown, so we check if we have a pagesize set; if so we add a new row at the end IF it is available.

Specified by:
rowDeleted in interface ITableModelListener<T>
index - The index of the deleted row in the table.
value - The deleted value.
Throws:
java.lang.Exception
See Also:
ITableModelListener.rowDeleted(to.etc.domui.component.tbl.ITableModel, int, java.lang.Object)

rowModified

public void rowModified(@Nonnull
                        ITableModel<T> model,
                        int index,
                        @Nullable
                        T value)
                 throws java.lang.Exception
Merely force a full redraw of the appropriate row.

Specified by:
rowModified in interface ITableModelListener<T>
Throws:
java.lang.Exception
See Also:
ITableModelListener.rowModified(to.etc.domui.component.tbl.ITableModel, int, java.lang.Object)

setTableWidth

public void setTableWidth(@Nullable
                          java.lang.String w)

getRowRenderer

@Nonnull
public IRowRenderer<T> getRowRenderer()

setRowRenderer

public void setRowRenderer(@Nonnull
                           IRowRenderer<T> rowRenderer)

onForceRebuild

protected void onForceRebuild()
Description copied from class: NodeBase
Called when forceRebuild is done on this node.

Overrides:
onForceRebuild in class NodeBase

selectionChanged

public void selectionChanged(T row,
                             boolean on)
                      throws java.lang.Exception
Called when a selection event fires. The underlying model has already been changed. It tries to see if the row is currently paged in, and if so asks the row renderer to update it's selection presentation.

Specified by:
selectionChanged in interface ISelectionListener<T>
Throws:
java.lang.Exception
See Also:
ISelectionListener.selectionChanged(java.lang.Object, boolean)

getSelectionAllHandler

@Nullable
public ISelectionAllHandler getSelectionAllHandler()
Description copied from interface: ISelectableTableComponent
If this component has a way to execute "select all", it should return a thing that does that. If it does not know it should return null.

Specified by:
getSelectionAllHandler in interface ISelectableTableComponent<T>
Returns:

setSelectionAllHandler

public void setSelectionAllHandler(@Nullable
                                   ISelectionAllHandler selectionAllHandler)

getSelectionModel

@Nullable
public ISelectionModel<T> getSelectionModel()
Return the model used for table selections, if applicable.

Specified by:
getSelectionModel in interface ISelectableTableComponent<T>
Returns:

setSelectionModel

public void setSelectionModel(@Nullable
                              ISelectionModel<T> selectionModel)
Set the model to maintain selections, if this table allows selections.

Parameters:
selectionModel -

selectionAllChanged

public void selectionAllChanged()
                         throws java.lang.Exception
Called when a selection cleared event fires. The underlying model has already been changed. It tries to see if the row is currently paged in, and if so asks the row renderer to update it's selection presentation.

Specified by:
selectionAllChanged in interface ISelectionListener<T>
Throws:
java.lang.Exception
See Also:
to.etc.domui.component.tbl.ISelectionListener#selectionCleared(java.lang.Object, boolean)