public class TreeGridDataModel extends Object implements Composite
Modifier and Type | Class and Description |
---|---|
protected class |
TreeGridDataModel.DelegateEditableGridDataModel
This class extends original editable model to support
TreeGridRow s creation. |
Modifier | Constructor and Description |
---|---|
protected |
TreeGridDataModel(DataModelCallbackHandler<Editable> handler)
Creates an instance of this class and loads data using the specified handler.
|
|
TreeGridDataModel(Object[][] data)
Creates an instance of this class and initializes internal fields.
|
Modifier and Type | Method and Description |
---|---|
void |
addColumn(int beforeColumn,
Object[] column)
This method adds a column into the model.
|
void |
addColumn(int beforeColumn,
String name,
Object[] column)
This method adds a column into the model.
|
void |
addListener(EditableModelListener listener)
This method registers the specified listener to receive model events.
|
void |
addRow(int beforeRow,
Object[] row)
This method adds a row into the model.
|
int |
addRow(TreeGridRow parent,
Object[] child)
Adds a child row.
|
void |
clearRemovedRows()
This method clears removed rows from the model history
|
void |
clearRemovedRows(TreeGridRow parent)
Cleans the list of removed rows.
|
protected void |
fireRowEvent(EditableModelEvent.EventType eventType,
TreeGridRow parent,
int row)
This method fires the
CompositeModelEvent . |
protected List<TreeGridRow> |
getChildrenList(TreeGridRow parent)
Gets a list of children of the specified parent or creates if it doesn't exist.
|
String[] |
getColumnNames()
This method gets a list of column names.
|
GridColumn[] |
getColumns()
Gets an array of all model columns.
|
int |
getCurrentPageNumber()
This method gets a current page number.
|
int |
getCurrentPageNumber(TreeGridRow parent)
This method gets a current page number in the subtree.
|
Object[][] |
getData()
This method returns all the data contained in the model.
|
protected EditableGridDataModel |
getDelegate()
Getter for property 'delegate'.
|
int |
getDisplayedPages()
This method gets the number of pages links to be displayed.
|
int |
getDisplayedPages(TreeGridRow parent)
This method gets the number of pages links to be displayed in the subtree.
|
int |
getEndPage()
This method returns an end page number.
|
int |
getEndPage(TreeGridRow parent)
This method returns an end page number in the subtree.
|
int |
getEndRow()
This method returns an end row number.
|
int |
getEndRow(TreeGridRow parent)
Returns an end row number of the subgrid.
|
int |
getExpandableColumn()
Gets an index of the expandable column.
|
GridColumn |
getGridColumn(int index)
Gets a grid column by index.
|
DataModelCallbackHandler<Editable> |
getHandler()
This method returns a callback handler instance.
|
int |
getPageSize()
This method returns a page size.
|
int |
getPageSize(TreeGridRow parent)
Gets a page size of the subtree.
|
protected Map<TreeGridRow,Boolean> |
getPagingFlags()
Getter for property 'pagingFlags'.
|
Object[][] |
getRemovedRows()
This method returns removed rows.
|
Object[][] |
getRemovedRows(TreeGridRow parent)
Gets an array of removed rows data.
|
protected List<TreeGridRow> |
getRemovedRowsList(TreeGridRow parent)
Gets a list of removed rows for the specified parent row or creates a new one if it doesn't exist.
|
protected Map<TreeGridRow,List<TreeGridRow>> |
getRemovedRowsMap() |
protected TreeGridRow[] |
getRootRows()
Gets a list of root rows.
|
GridRow |
getRow(int index)
Gets a grid row by index.
|
TreeGridRow |
getRow(TreeGridRow parent,
int index)
Gets a grid row of the subtree by index.
|
Object[] |
getRowData(int rowNumber)
This method returns row data by the specified row number.
|
GridRow[] |
getRows()
This method returns all rows of the model.
|
TreeGridRow[] |
getRows(TreeGridRow parent)
Gets a list of child rows.
|
int |
getSortColumn()
This method returns a sorted column number.
|
int |
getStartPage()
This method returns a start page number.
|
int |
getStartPage(TreeGridRow parent)
This method returns a start page number in the subtree.
|
int |
getStartRow()
This method returns a start row number.
|
int |
getStartRow(TreeGridRow parent)
Returns a subgrid start row number.
|
protected Map<TreeGridRow,List<TreeGridRow>> |
getSubRows()
Getter for property 'subRows'.
|
protected Composite |
getThisModel()
This method returns this instance.
|
int |
getTotalColumnCount()
This method returns a total row count.
|
int |
getTotalPagesNumber()
This method returns a number of existing pages.
|
int |
getTotalPagesNumber(TreeGridRow parent)
This method returns a number of existing pages in the subtree.
|
int |
getTotalRowCount()
This method returns total row count value.
|
int |
getTotalRowCount(TreeGridRow parent)
This method gets a total row count for the specified subtree.
|
boolean |
isAscending()
This method defines sorting direction.
|
boolean |
isEmpty()
This method checks whether the data model is empty.
|
boolean |
isSubtreePagingEnabled(TreeGridRow parent)
Checks whether subtree paging is enabled.
|
protected void |
remapIndexes(TreeGridRow parent)
This method remaps indexes in the subtree.
|
void |
removeAll()
This method removes all rows from the model.
|
void |
removeAll(TreeGridRow parent)
Removes all the children of the specified row.
|
void |
removeColumn(int columnNumber)
This method removes a column from the model.
|
void |
removeColumn(String name)
This method removes a column from the model.
|
void |
removeListener(EditableModelListener listener)
This method unregisters the specified listener to stop model events receiving.
|
void |
removeRow(int rowNumber)
This method removes a row from the model.
|
void |
removeRow(TreeGridRow parent,
int row)
Removes the child row.
|
void |
setAscending(boolean ascending)
This method sets sort direction.
|
void |
setColumNames(String[] names)
This method sets a list of column names
This list must be in the same order like the data array columns (see
Editable.update(Object[][]) for details. |
void |
setCurrentPageNumber(int currentPageNumber)
This method sets the current page number.
|
void |
setCurrentPageNumber(TreeGridRow parent,
int currentPageNumber)
This method sets the current page number in the subtree.
|
protected void |
setDelegate(EditableGridDataModel delegate)
Setter for property 'delegate'.
|
void |
setDisplayedPages(int displayedPages)
This method sets the number of pages links to be displayed.
|
void |
setDisplayedPages(TreeGridRow parent,
int displayedPages)
This method sets the number of pages links to be displayed in the subtree.
|
void |
setExpandableColumn(int index)
Sets the expandable column using its index.
|
void |
setExpandableColumn(String name)
Sets the exapandbale column by its name.
|
void |
setHandler(DataModelCallbackHandler<Editable> handler)
This method sets a callback handler.
|
void |
setPageSize(int pageSize)
This method sets a page size.
|
void |
setPageSize(TreeGridRow parent,
int size)
Sets a page size value.
|
protected void |
setPagingFlags(Map<TreeGridRow,Boolean> pagingFlags)
Setter for property 'pagingFlags'.
|
void |
setParent(TreeGridRow parent,
TreeGridRow child)
Links the child row to the parent.
|
void |
setSortColumn(int sortColumn)
This method sets a number of sort column.
|
void |
setSortColumn(int sortColumn,
Comparator<Object> comparator)
This method sets a sort column and uses the specified comparator.
|
void |
setSortColumn(TreeGridRow parent,
int column,
Comparator<Object> comparator)
This method sets the sort column of the model and sorts the data in the subtree using the specified comparator.
|
protected void |
setSubRows(Map<TreeGridRow,List<TreeGridRow>> subRows)
Setter for property 'subRows'.
|
void |
setSubtreePagingEnabled(TreeGridRow parent,
boolean enabled)
Sets subtree paging enabled or disabled.
|
void |
update(int row,
int column,
Object data)
This method updates the specified cell with the value.
|
void |
update(Object[][] data)
This method updates data in the model using the specified value.
|
void |
update(TreeGridRow parent,
int row,
int column,
Object data)
Updates the specified cell of the subtree with a new value.
|
void |
update(TreeGridRow parent,
Object[][] children)
Adds a list of child rows.
|
void |
updateColumn(int columnNumber,
Object[] column)
This method updates a column with the specified data set.
|
void |
updateColumn(String name,
Object[] column)
This method updates a column with the specified data set.
|
void |
updateRow(int rowNumber,
Object[] row)
This method updates a row with the specified data set.
|
void |
updateRow(TreeGridRow parent,
int rowNumber,
Object[] row)
This method updates a row with the specified data set.
|
public TreeGridDataModel(Object[][] data)
data
- is a data array to be placed into the model.protected TreeGridDataModel(DataModelCallbackHandler<Editable> handler)
handler
- is a handler instance to load data.public int getTotalRowCount(TreeGridRow parent)
getTotalRowCount
in interface Composite
parent
- is a parent row.public TreeGridRow[] getRows(TreeGridRow parent)
public int addRow(TreeGridRow parent, Object[] child)
public void update(TreeGridRow parent, Object[][] children)
public void update(TreeGridRow parent, int row, int column, Object data)
public void removeRow(TreeGridRow parent, int row)
public void removeAll(TreeGridRow parent)
public void setCurrentPageNumber(TreeGridRow parent, int currentPageNumber) throws IllegalArgumentException
setCurrentPageNumber
in interface Composite
parent
- is a parent row.currentPageNumber
- is a current page number.IllegalArgumentException
public int getTotalPagesNumber(TreeGridRow parent)
getTotalPagesNumber
in interface Composite
parent
- is a parent row.public int getStartPage(TreeGridRow parent)
getStartPage
in interface Composite
parent
- is a parent row.public int getEndPage(TreeGridRow parent)
getEndPage
in interface Composite
parent
- is a parent row.public int getDisplayedPages(TreeGridRow parent)
getDisplayedPages
in interface Composite
parent
- is a parent row.public void setDisplayedPages(TreeGridRow parent, int displayedPages)
setDisplayedPages
in interface Composite
parent
- is a parent row.displayedPages
- is a number of pages.public int getCurrentPageNumber(TreeGridRow parent)
getCurrentPageNumber
in interface Composite
parent
- is a parent row.public int getPageSize(TreeGridRow parent)
getPageSize
in interface Composite
parent
- is a parent row.public void setPageSize(TreeGridRow parent, int size)
setPageSize
in interface Composite
parent
- is a parent row.size
- is a page size.public void setSubtreePagingEnabled(TreeGridRow parent, boolean enabled)
setSubtreePagingEnabled
in interface Composite
parent
- is a parent row.enabled
- is a flag value, true
enables paging.public boolean isSubtreePagingEnabled(TreeGridRow parent)
isSubtreePagingEnabled
in interface Composite
parent
- is a parent row.true
if paging is enabled.public Object[][] getRemovedRows(TreeGridRow parent)
getRemovedRows
in interface Composite
parent
- is a parent row.public void clearRemovedRows(TreeGridRow parent)
clearRemovedRows
in interface Composite
parent
- is a parent row.public TreeGridRow getRow(TreeGridRow parent, int index)
public void setExpandableColumn(int index)
setExpandableColumn
in interface Composite
index
- is an index value.public int getExpandableColumn()
getExpandableColumn
in interface Composite
public void setExpandableColumn(String name)
setExpandableColumn
in interface Composite
name
- is a name pf the expandable column.public void setSortColumn(TreeGridRow parent, int column, Comparator<Object> comparator)
setSortColumn
in interface Composite
parent
- is a parent row of the subtree.column
- is a column number.comparator
- is a comparator instance.public void setParent(TreeGridRow parent, TreeGridRow child)
public int getStartRow(TreeGridRow parent)
getStartRow
in interface Composite
parent
- is a parent row of the subgrid.public int getEndRow(TreeGridRow parent)
public void updateRow(TreeGridRow parent, int rowNumber, Object[] row) throws IllegalArgumentException
updateRow
in interface Composite
parent
- is a parent grid row.rowNumber
- is a row number.row
- is row data.IllegalArgumentException
- if the row number is invalid.public void addRow(int beforeRow, Object[] row) throws IllegalArgumentException
addRow
in interface Editable
beforeRow
- is a row number.row
- is row data.IllegalArgumentException
- if the row number is invalid.public void updateRow(int rowNumber, Object[] row) throws IllegalArgumentException
updateRow
in interface Editable
rowNumber
- is a row number.row
- is row data.IllegalArgumentException
- if the row number is invalid.public void removeRow(int rowNumber) throws IllegalArgumentException
removeRow
in interface Editable
rowNumber
- is a row number.IllegalArgumentException
- if the row number is invalid.public void addColumn(int beforeColumn, Object[] column) throws IllegalArgumentException
addColumn
in interface Editable
beforeColumn
- a column number.column
- a column data set.IllegalArgumentException
- if the column number is invalid.public void addColumn(int beforeColumn, String name, Object[] column) throws IllegalArgumentException
addColumn
in interface Editable
beforeColumn
- a column number.name
- a column name.column
- a column data set.IllegalArgumentException
- if the column number is invalid.public void updateColumn(int columnNumber, Object[] column) throws IllegalArgumentException
updateColumn
in interface Editable
columnNumber
- a column number.column
- a column data set.IllegalArgumentException
- if the column number is invalid.public void updateColumn(String name, Object[] column)
updateColumn
in interface Editable
name
- a column name.column
- a column data set.public void removeColumn(int columnNumber) throws IllegalArgumentException
removeColumn
in interface Editable
columnNumber
- a column number.IllegalArgumentException
- if the column number is invalid.public void removeColumn(String name)
removeColumn
in interface Editable
name
- a column name.public void removeAll()
public void update(int row, int column, Object data) throws IllegalArgumentException
update
in interface Editable
row
- is a row number.column
- is a column number.data
- is a data to be applied.IllegalArgumentException
- if row and / or column number is invalid.public void setSortColumn(int sortColumn, Comparator<Object> comparator)
setSortColumn
in interface Editable
sortColumn
- is a sort column.comparator
- is a column comparator.public DataModelCallbackHandler<Editable> getHandler()
getHandler
in interface Editable
public void update(Object[][] data)
public void setHandler(DataModelCallbackHandler<Editable> handler)
setHandler
in interface Editable
handler
- a callback handler.public int getTotalColumnCount()
getTotalColumnCount
in interface Editable
public Object[][] getRemovedRows()
getRemovedRows
in interface Editable
public void clearRemovedRows()
clearRemovedRows
in interface Editable
public GridRow[] getRows()
public GridColumn[] getColumns()
getColumns
in interface Editable
public GridRow getRow(int index)
public GridColumn getGridColumn(int index)
getGridColumn
in interface Editable
index
- is an index value.public String[] getColumnNames()
getColumnNames
in interface Editable
public void setColumNames(String[] names)
Editable.update(Object[][])
for details.setColumNames
in interface Editable
names
- is a list of column names.public void addListener(EditableModelListener listener)
addListener
in interface Editable
listener
- is a model listener to register.public void removeListener(EditableModelListener listener)
removeListener
in interface Editable
listener
- is a model listener to be removed.public int getTotalRowCount()
getTotalRowCount
in interface GridDataModel
public int getStartRow()
getStartRow
in interface GridDataModel
public int getEndRow()
getEndRow
in interface GridDataModel
public int getSortColumn()
getSortColumn
in interface GridDataModel
public boolean isAscending()
It returns true
if direction is ascending.
isAscending
in interface GridDataModel
false
if sorting is descending.public Object[] getRowData(int rowNumber)
getRowData
in interface GridDataModel
rowNumber
- is a number of row to be returned.public void setSortColumn(int sortColumn)
setSortColumn
in interface GridDataModel
sortColumn
- a number of sort column.public void setAscending(boolean ascending)
setAscending
in interface GridDataModel
ascending
- sort direction.public boolean isEmpty()
isEmpty
in interface GridDataModel
true
if the model is empty.public Object[][] getData()
getData
in interface GridDataModel
public void setPageSize(int pageSize)
setPageSize
in interface Pageable
pageSize
- is a page size.public void setCurrentPageNumber(int currentPageNumber) throws IllegalArgumentException
setCurrentPageNumber
in interface Pageable
currentPageNumber
- is a current page number.IllegalArgumentException
- if current page number less then zero or greater then
actual number of pages.public int getTotalPagesNumber()
getTotalPagesNumber
in interface Pageable
public int getStartPage()
getStartPage
in interface Pageable
public int getEndPage()
getEndPage
in interface Pageable
public int getDisplayedPages()
getDisplayedPages
in interface Pageable
public void setDisplayedPages(int displayedPages)
setDisplayedPages
in interface Pageable
displayedPages
- is a number of pages.public int getPageSize()
getPageSize
in interface Pageable
public int getCurrentPageNumber()
getCurrentPageNumber
in interface Pageable
protected void remapIndexes(TreeGridRow parent)
parent
- is a parent row.protected TreeGridRow[] getRootRows()
protected List<TreeGridRow> getChildrenList(TreeGridRow parent)
parent
- is a parent row.children
.protected List<TreeGridRow> getRemovedRowsList(TreeGridRow parent)
parent
- is a parent row.protected Map<TreeGridRow,List<TreeGridRow>> getSubRows()
protected void setSubRows(Map<TreeGridRow,List<TreeGridRow>> subRows)
subRows
- Value to set for property 'subRows'.protected Map<TreeGridRow,Boolean> getPagingFlags()
protected void setPagingFlags(Map<TreeGridRow,Boolean> pagingFlags)
pagingFlags
- Value to set for property 'pagingFlags'.protected Map<TreeGridRow,List<TreeGridRow>> getRemovedRowsMap()
protected EditableGridDataModel getDelegate()
protected void setDelegate(EditableGridDataModel delegate)
delegate
- Value to set for property 'delegate'.protected Composite getThisModel()
protected void fireRowEvent(EditableModelEvent.EventType eventType, TreeGridRow parent, int row)
CompositeModelEvent
.eventType
- is a concrete event type.parent
- is a parent row.row
- is a number of the row that produced this event.Copyright © 2008–2013. All rights reserved.