public class EditableGrid<T extends Editable> extends SimpleGrid implements AdvancedWidget
SimpleGrid.ResizeListener, SimpleGrid.ResizeTimer
AdvancedFlexTable.AdvancedWidgetIterator, AdvancedFlexTable.ClickTimer, AdvancedFlexTable.RowsScrollPanel
com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter
com.google.gwt.user.client.ui.HTMLTable.Cell, com.google.gwt.user.client.ui.HTMLTable.CellFormatter, com.google.gwt.user.client.ui.HTMLTable.ColumnFormatter, com.google.gwt.user.client.ui.HTMLTable.RowFormatter
Constructor and Description |
---|
EditableGrid(String[] headers,
Class[] columnWidgetClasses)
Creates a new instance of this class.
|
EditableGrid(String[] headers,
Class[] columnWidgetClasses,
boolean resizable)
Creates a new instance of this class.
|
Modifier and Type | Method and Description |
---|---|
void |
activateCell(int row,
int column,
boolean active)
This method activates / passivate the specified cell.
|
void |
addEditCellListener(EditCellListener listener)
Adds a new edit cell listener.
|
void |
addGridDecorator(GridDecorator decorator)
This method adds a new grid decorator to the grid.
|
void |
addGridListener(GridListener listener)
This method adds a new grid listener to be invoked on grid events.
|
void |
addInvisibleColumn(int column)
This method adds an invisible column in the internal list.
|
protected void |
addListeners()
This method adds grid specific listeners into the current widget.
|
void |
addRow()
This method adds a new empty row into the grid.
|
protected void |
addRow(int row,
Object[] data)
This method adds the row into the grid.
|
void |
addSelectRowListener(SelectRowListener selectRowListener)
This method adds a selected row listener into the list.
|
protected void |
deleteRow(EditableModelEvent event)
Removes the grid row finding it by the model row number that was deleted.
|
void |
deselectCell(int row,
int column)
This method deselects the specified cell.
|
protected void |
detectCurrentSortColumn()
This method looks for the sort column in the header list.
|
void |
display()
Deprecated.
don't use this method anymore since it does nothing
|
protected void |
drawCell(EditableModelEvent event)
This method draws a concrete cell.
|
protected void |
drawColumn(int column)
This method draws a column getting data from the data model
If the data model is not specified it does nothing.
|
protected void |
drawContent()
This method draws a content of the grid.
|
protected void |
drawHeaders()
This method draws header cells.
|
protected void |
drawRow(EditableModelEvent event)
This method adds a new row into the grid end of the current page if the model row has been added.
|
protected void |
dropSelection()
This method drops cell selection.
|
protected boolean |
fireAfterDrawEvent(int row,
int pageSize,
Object[] data)
This method fires row drawing event after the row is drawn.
|
protected boolean |
fireBeforeDrawEvent(int row,
int pageSize,
Object[] data)
This method fires row drawing event before the row is drawn.
|
boolean |
fireFinishEdit(GridCell cell,
Object newValue)
This method fires the end edit event.
|
void |
fireSort(HeaderCell header)
This method fires the sort event
|
boolean |
fireStartEdit(GridCell cell)
This method fires the start edit event.
|
protected GridCell |
getActiveCell()
Gets a cell that is active, i.e. a cell that is chosen by a user to edit data.
|
protected com.google.gwt.user.client.Element |
getBodyElement()
Overrides this method to make it accessible for this package and server side renderers.
|
protected Comparator<Object> |
getCellComparator()
This method returns a cell comparator.
|
int |
getColumnByModelColumn(int modelColumn)
Gets a grid column number by a model column index.
|
Class[] |
getColumnWidgetClasses()
Getter for property 'columnWidgetClasses'.
|
int |
getCurrentColumn()
Getter for property 'currentColumn'.
|
GridRow |
getCurrentGridRow()
Gets a currently selected grid row.
|
GridRow[] |
getCurrentGridRows()
Gets a list of selected grid rows.
|
int |
getCurrentRow()
Gets a currently selected row number
If there are several rows selected it returns only the first row number.
|
int[] |
getCurrentRows()
Gets a list of selected row numbers.
|
HeaderCell |
getCurrentSortColumn()
Getter for property 'currentSortColumn'.
|
protected List<GridDecorator> |
getDecorators()
Getter for property 'decorators'.
|
int |
getDefaultSelectedRow()
Getter for property 'defaultSelectedRow'.
|
protected List<EditCellListener> |
getEditCellListeners()
Getter for property 'editCellListeners'.
|
GridCellFactory |
getGridCellFactory()
Getter for property 'gridCellFactory'.
|
GridColumn |
getGridColumn(int index)
Gets a grid row column specified by the index.
|
GridColumn |
getGridColumn(String name)
This method gets a grid column by its name.
|
GridColumn[] |
getGridColumns()
gets a list of grid columns currently exisiting in the model (including invisible ones).
|
GridPanel |
getGridPanel()
Getter for property 'gridPanel'.
|
GridRenderer |
getGridRenderer()
Getter for property 'gridRenderer'.
|
GridRow |
getGridRow(int index)
Gets a grid row specified by the index.
|
GridRow |
getGridRowByRowNumber(int row)
Gets a grid row by a row number in the displayed page.
|
GridRow[] |
getGridRows()
Gets a list of grid rows currently loaded into the model.
|
HeaderCell |
getHeaderCell(int column)
This method returns a header cell widget.
|
String[] |
getHeaders()
Getter for property 'headers'.
|
protected List<Integer> |
getInvisibleColumns()
Getter for property 'invisibleColumns'.
|
T |
getModel()
Getter for property 'model'.
|
int |
getModelColumn(int column)
This method returns a column number taking into account invisible columns.
|
int |
getModelRow(int gridRow)
This metod calculates a row number in the model.
|
protected com.google.gwt.user.client.ui.Widget |
getOriginalWidget(int row,
int column)
Invokes the
getWidget() method of the FlexTable . |
protected Map<Integer,Boolean> |
getReadOnlyColumns()
Getter for property 'readOnlyColumns'.
|
int |
getRowByModelRow(EditableModelEvent event)
Gets a grid row number on the displayed page by a model row number.
|
GridRowDrawCallbackHandler |
getRowDrawHandler()
This method returns a row draw handler instance.
|
GridRowSelectDataModel |
getSelectionModel()
Gets a selection model.
|
protected List<SelectRowListener> |
getSelectRowListeners()
This method retuns a list of select row listeners.
|
protected Map<Integer,Boolean> |
getSortableHeaders()
Getter for property 'sortableHeaders'.
|
int |
getSortColumn()
This method returns a sort column number.
|
com.google.gwt.user.client.ui.Widget |
getWidget(int row,
int column)
Overrides the super method to emulate grid cell presence.
|
protected boolean |
hasActiveCell()
Checks whether the grid has an activated cell.
|
protected void |
increaseRowNumbers(int startRow,
int step)
This method increases row numbers in the cells.
|
boolean |
isAscending(int column)
This method checks whether the specified column is sorted asceding.
|
protected boolean |
isClientSortEnabled()
This method checks whether client sorting is enabled.
|
protected boolean |
isLocked()
Getter for property 'locked'.
|
boolean |
isMultiRowModeEnabled()
Checks whether the multi-row selection mode enabled for this grid.
|
boolean |
isReadOnly(int column)
This method checks whether the specified column is read only.
|
boolean |
isSelected(int row)
This method checks whether the specified row is selected.
|
boolean |
isSortable(int column)
This method checks whether the specified column is sortable.
|
boolean |
isSorted(int column)
This method checks whether the specified column is sorted.
|
boolean |
isVisible(int column)
This method detects whether the specified column is visible.
|
protected void |
refreshAll()
This method refreshes all the content and headers.
|
protected void |
removeColumn(int column)
This method removes the specified column from the grid
Note that it doesn't remove the column from the data model.
|
protected void |
removeContent()
This method removes all content from the grid.
|
void |
removeEditCellListener(EditCellListener listener)
This method removes the edit cell listener from the internal list.
|
void |
removeGridDecorator(GridDecorator decorator)
This method removes the grid decorator from the grid.
|
void |
removeGridListener(GridListener listener)
This method removes the specified grid listener.
|
void |
removeInvisibleColumn(int column)
This method removes the specified column form the list of invisible columns.
|
protected void |
removeRow()
This method removes the currently selected row or several rows if the multi row selection mode enabled.
|
void |
removeSelectRowListener(SelectRowListener selectRowListener)
This method removes a selected row listener from the list.
|
protected void |
runDecorators()
This method runs all attached decorators in the same order they have been added.
|
void |
selectRow(int row)
This method marks the specified row as selected.
|
void |
selectRows(int toRow)
This method selects the rows between the currently selected row and the specified one including both of them
into the selection.
|
void |
setAscending(boolean ascending)
This method sets the order of sorting and redisplays the grid.
|
void |
setCellComparator(Comparator<Object> cellComparator)
This method sets custom cell comparator.
|
void |
setCurrentCell(int row,
int column)
Sets a current column number and activates the cell that belong to this
column and
the current row . |
void |
setCurrentRow(int currentRow)
Setter for property 'currentRow'.
|
void |
setDefaultSelectedRow(int defaultSelectedRow)
Setter for property 'defaultSelectedRow'.
|
void |
setFocus(boolean focus)
This method sets focus to the grid.
|
void |
setGridCellfactory(GridCellFactory gridCellFactory)
Setter for property 'gridCellFactory'.
|
protected void |
setGridPanel(GridPanel gridPanel)
Setter for property 'gridPanel'.
|
void |
setGridRenderer(GridRenderer gridRenderer)
Setter for property 'gridRenderer'.
|
protected void |
setLocked(boolean locked)
Setter for property 'locked'.
|
void |
setModel(T model)
Setter for property 'model'.
|
void |
setMultiRowModeEnabled(boolean multiRowModeEnabled)
Enables or disbales the multi-row selection mode.
|
void |
setReadOnly(int column,
boolean readOnly)
This method makes a column to be read only.
|
void |
setRowDrawHandler(GridRowDrawCallbackHandler rowDrawHandler)
This method sets a row draw handler for this grid.
|
void |
setSelectionModel(GridRowSelectDataModel selectionModel)
Sets the selection model.
|
void |
setSortable(int column,
boolean sortable)
This method makes a column to be sortable.
|
void |
setSortColumn(int column)
This method sets the sort column and redisplays the grid.
|
protected void |
sortOnClient()
This method performs client sorting.
|
protected void |
synchronizeDataModel()
This method invokes the data model handler to synchronize the model and persistence
storage or redraws content if the model is not lazily loadable.
|
protected void |
synchronizeView(EditableModelEvent event)
This method draws a content on the specified model event.
|
protected void |
updateModel(GridCell cell,
Object newValue)
This method updates the model with the new value of the cell on finish edit event.
|
addCell, addClickHandler, addDoubleClickListener, addHeaderCells, checkCellBounds, checkRowBounds, clear, clear, clearCell, createCell, enableVerticalScrolling, getBodyTable, getCellCount, getCellForEvent, getCellFormatter, getCellPadding, getCellSpacing, getColumnFormatter, getDOMCellCount, getDOMCellCount, getDOMRowCount, getDOMRowCount, getEventTargetCell, getFlexCellFormatter, getFooterTable, getFooterTdElement, getFooterWidgets, getHeaderTable, getHeaderWidgets, getHTML, getRowCount, getRowFormatter, getScrollPanel, getTableHeight, getTableWidth, getText, getTFootElement, getTHeadElement, getThElement, getThElementWidth, insertCell, insertCells, insertHeaderCell, insertRow, internalClearCell, isCellPresent, isColumnResizingAllowed, isResizable, makeResizable, onBrowserEvent, prepareCell, prepareColumn, prepareFooterCell, prepareHeaderCell, prepareRow, prepareScrolling, remove, removeAllRows, removeCell, removeCells, removeDoubleClickListener, removeFooterWidget, removeHeaderWidget, removeRow, resize, setBodyHeight, setBodyWidth, setBorderWidth, setCellPadding, setCellSpacing, setColumnResizingAllowed, setColumnWidth, setFooterWidget, setHeaderHeight, setHeaderWidget, setHeaderWidth, setHTML, setResizable, setText, setWidget, wrapContent
addFooterCells, fireClickEvent, fireDoubleClickEvent, getCellClicked, getCellElement, getClickCount, getClickTimer, getDoubleClickListeners, getHandlerManager, isScrollable, iterator, setCellClicked, setCellFormatter, setClickCount, setClickTimer, setColumnFormatter, setDoubleClikcListeners, setHandlerManager, setRowFormatter, setScrollable
addDoubleClickHandler, addDragEndHandler, addDragEnterHandler, addDragHandler, addDragLeaveHandler, addDragOverHandler, addDragStartHandler, addDropHandler, addTableListener, onEnsureDebugId, removeTableListener, setHTML, setWidget
add, add, adopt, adopt, disown, doAttachChildren, doDetachChildren, orphan, remove
addAttachHandler, addBitlessDomHandler, addDomHandler, addHandler, asWidget, asWidgetOrNull, createHandlerManager, delegateEvent, fireEvent, getHandlerCount, getLayoutData, getParent, isAttached, isOrWasAttached, onAttach, onDetach, onLoad, onUnload, removeFromParent, setLayoutData, sinkEvents
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, removeStyleDependentName, removeStyleName, resolvePotentialElement, setElement, setElement, setHeight, setPixelSize, setSize, setStyleDependentName, setStyleName, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkBitlessEvent, toString, unsinkEvents
public EditableGrid(String[] headers, Class[] columnWidgetClasses)
headers
- is a list of header labels (including invisible).columnWidgetClasses
- is a list of column widget classes.public EditableGrid(String[] headers, Class[] columnWidgetClasses, boolean resizable)
headers
- is a list of header labels (including invisible).columnWidgetClasses
- is a list of column widget classes.resizable
- is a flag that means columns resizability (by default is true
).public GridCellFactory getGridCellFactory()
public Class[] getColumnWidgetClasses()
public String[] getHeaders()
public void setGridCellfactory(GridCellFactory gridCellFactory)
gridCellFactory
- Value to set for property 'gridCellFactory'.public void setModel(T model)
model
- Value to set for property 'model'.public void setCellComparator(Comparator<Object> cellComparator)
cellComparator
- is a cell comparator.public void addEditCellListener(EditCellListener listener)
Use this method to add validators.
listener
- is a listener instance.public void removeEditCellListener(EditCellListener listener)
listener
- is a listener to be removed.public void addInvisibleColumn(int column)
column
- is a data model column number.protected void removeColumn(int column)
column
- is a column number to remove.public void removeInvisibleColumn(int column)
column
- is an invisible column number.protected void drawColumn(int column)
column
- is a column number.public void addGridDecorator(GridDecorator decorator)
decorator
- is a grid decorator instance.public void removeGridDecorator(GridDecorator decorator)
decorator
- is a grid decorator instance.public boolean isReadOnly(int column)
column
- is a column to check.true
if the column is read only.public boolean isSortable(int column)
column
- is a column to check.true
if the column is sortable.public boolean isAscending(int column)
column
- is a column to check.true
if the column is sorted ascending.public boolean isSorted(int column)
column
- is a column to check.true
if the column is sorted.public void setReadOnly(int column, boolean readOnly)
column
- is a column to be read only.readOnly
- is a read only flag value.public void setSortable(int column, boolean sortable)
column
- is a column to be sortable.sortable
- is a sortable flag value.public boolean isVisible(int column)
column
- is a column number.true
if the column is visible.public int getCurrentRow()
public GridRow getCurrentGridRow()
public int[] getCurrentRows()
public GridRow[] getCurrentGridRows()
public void setCurrentRow(int currentRow)
currentRow
- Value to set for property 'currentRow'.public void selectRow(int row)
setCurrentRow(int)
method but doesn't clear a previous selection.
If the multiple rows selection is disabled it checks whether there is at least one selected row and if no
it makes selection. Otherwise it does nothing.
If multiple mode is enabled it always selects a row.row
- is a row number to make selected.public void deselectCell(int row, int column)
row
- is a row number in the grid.column
- is a column number in the grid.public boolean isSelected(int row)
row
- is a row number in the grid.true
if the row is selected.public GridRow getGridRowByRowNumber(int row)
row
- is a row number.public void selectRows(int toRow)
toRow
- is a right border (a row number that will the end of selection).public GridPanel getGridPanel()
public void addSelectRowListener(SelectRowListener selectRowListener)
selectRowListener
- is a select row listener to be added.public void removeSelectRowListener(SelectRowListener selectRowListener)
selectRowListener
- a select row listener to be removed.public GridRowDrawCallbackHandler getRowDrawHandler()
public void setRowDrawHandler(GridRowDrawCallbackHandler rowDrawHandler)
rowDrawHandler
- a row draw handler instance.public GridRowSelectDataModel getSelectionModel()
public void setSelectionModel(GridRowSelectDataModel selectionModel)
selectionModel
- is a row selection model.public boolean isMultiRowModeEnabled()
true
if this mode has been enabled.public void setMultiRowModeEnabled(boolean multiRowModeEnabled)
multiRowModeEnabled
- true
means that this grid will allow multiple row selection.public void display()
display
in interface AdvancedWidget
public void addGridListener(GridListener listener)
listener
- is a listener to add.public void removeGridListener(GridListener listener)
listener
- is a listener to remove.public boolean fireStartEdit(GridCell cell)
cell
- is a cell to be edited.true
if all listeners allow the edit operation.public boolean fireFinishEdit(GridCell cell, Object newValue)
cell
- is a cell to be edited.newValue
- is a new value to be applied.true
if all listeners allow finishing edit.public int getSortColumn()
public void setSortColumn(int column)
column
- is a column to be sorted.public void setAscending(boolean ascending)
ascending
- is the order of sorting. true
means ascending.public void fireSort(HeaderCell header)
header
- is a header cell of the sortable column.public T getModel()
public GridRenderer getGridRenderer()
public void setGridRenderer(GridRenderer gridRenderer)
gridRenderer
- Value to set for property 'gridRenderer'.public com.google.gwt.user.client.ui.Widget getWidget(int row, int column)
getWidget
in class SimpleGrid
row
- is a row number.column
- is a column number.public int getDefaultSelectedRow()
public void setDefaultSelectedRow(int defaultSelectedRow)
defaultSelectedRow
- Value to set for property 'defaultSelectedRow'.public GridRow getGridRow(int index)
index
- is a number of the row in the data model.public GridRow[] getGridRows()
public GridColumn getGridColumn(int index)
index
- is a column number.public GridColumn getGridColumn(String name)
name
- is a name of the column.public GridColumn[] getGridColumns()
public int getModelColumn(int column)
column
- is a column number of the grid.public int getColumnByModelColumn(int modelColumn)
modelColumn
- is a model column index.protected com.google.gwt.user.client.ui.Widget getOriginalWidget(int row, int column)
getWidget()
method of the FlexTable
.row
- is a row number.column
- is a column number.protected void runDecorators()
protected void addRow(int row, Object[] data)
row
- is a row number.data
- is a row data set.protected void refreshAll()
protected boolean isLocked()
protected void setLocked(boolean locked)
locked
- Value to set for property 'locked'.public int getCurrentColumn()
public void setFocus(boolean focus)
focus
- is a focus value.public void setCurrentCell(int row, int column)
the current row
.row
- Value to set for property 'currentRow'.column
- Value to set for property 'currentColumn'.protected void updateModel(GridCell cell, Object newValue)
cell
- is a cell that produced the event.newValue
- is a new value of the cell.protected void dropSelection()
protected List<EditCellListener> getEditCellListeners()
protected Map<Integer,Boolean> getReadOnlyColumns()
protected Map<Integer,Boolean> getSortableHeaders()
protected boolean isClientSortEnabled()
true
if sorting is enabled.public HeaderCell getCurrentSortColumn()
public HeaderCell getHeaderCell(int column)
column
- is a column number.public void addRow()
protected void drawRow(EditableModelEvent event)
event
- is a model event containing a row number value.protected void drawCell(EditableModelEvent event)
event
- is an event on which cell must be drawn.protected void removeRow()
protected void deleteRow(EditableModelEvent event)
event
- is a model event containing a row number value.protected void synchronizeView(EditableModelEvent event)
event
- is a model event.protected void synchronizeDataModel()
protected void removeContent()
public int getModelRow(int gridRow)
gridRow
- is a grid row.public int getRowByModelRow(EditableModelEvent event)
event
- is a model event containing a row number value.protected Comparator<Object> getCellComparator()
protected void drawContent()
protected boolean fireBeforeDrawEvent(int row, int pageSize, Object[] data)
row
- is a row number.pageSize
- is a page size.data
- is row data.true
if the row must be drawn.protected boolean fireAfterDrawEvent(int row, int pageSize, Object[] data)
row
- is a row number.pageSize
- is a page size.data
- is row data.true
if drawing must be continued.protected void drawHeaders()
protected void sortOnClient()
protected void detectCurrentSortColumn()
The method is invoked by the
drawHeaders()
.
protected boolean hasActiveCell()
protected GridCell getActiveCell()
public void activateCell(int row, int column, boolean active)
row
- is a row of the cell.column
- is a column of the cell.active
- is an activation flag.protected void addListeners()
protected void increaseRowNumbers(int startRow, int step)
startRow
- is a start row number.step
- is an increase step.protected List<Integer> getInvisibleColumns()
protected List<GridDecorator> getDecorators()
protected void setGridPanel(GridPanel gridPanel)
gridPanel
- Value to set for property 'gridPanel'.protected List<SelectRowListener> getSelectRowListeners()
protected com.google.gwt.user.client.Element getBodyElement()
getBodyElement
in class AdvancedFlexTable
Copyright © 2008–2013. All rights reserved.