com.google.gwt.widgetideas.table.client
Class SelectionGrid

java.lang.Object
  extended by com.google.gwt.user.client.ui.UIObject
      extended by com.google.gwt.user.client.ui.Widget
          extended by com.google.gwt.user.client.ui.Panel
              extended by com.google.gwt.widgetideas.table.client.overrides.HTMLTable
                  extended by com.google.gwt.widgetideas.table.client.overrides.Grid
                      extended by com.google.gwt.widgetideas.table.client.SelectionGrid
All Implemented Interfaces:
com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasWidgets, com.google.gwt.user.client.ui.SourcesTableEvents, SourceTableSelectionEvents
Direct Known Subclasses:
SortableGrid

public class SelectionGrid
extends Grid
implements SourceTableSelectionEvents

A variation of the Grid that supports row or cell hovering and row selection.

CSS Style Rules


Nested Class Summary
 class SelectionGrid.SelectionGridCellFormatter
          This class contains methods used to format a table's cells.
 class SelectionGrid.SelectionGridRowFormatter
          This class contains methods used to format a table's rows.
static class SelectionGrid.SelectionPolicy
          Selection policies.
 
Nested classes/interfaces inherited from class com.google.gwt.widgetideas.table.client.overrides.HTMLTable
HTMLTable.CellFormatter, HTMLTable.ColumnFormatter, HTMLTable.RowFormatter, HTMLTable.WidgetMapper
 
Nested classes/interfaces inherited from class com.google.gwt.user.client.ui.UIObject
com.google.gwt.user.client.ui.UIObject.DebugIdImpl, com.google.gwt.user.client.ui.UIObject.DebugIdImplEnabled
 
Field Summary
 
Fields inherited from class com.google.gwt.widgetideas.table.client.overrides.Grid
numColumns, numRows
 
Fields inherited from class com.google.gwt.user.client.ui.UIObject
DEBUG_ID_PREFIX
 
Constructor Summary
SelectionGrid()
          Constructor.
SelectionGrid(int rows, int columns)
          Constructs a SelectionGrid with the requested size.
 
Method Summary
 void addTableSelectionListener(TableSelectionListener listener)
          Add a TableSelectionListener.
 void deselectRow(int row)
          Deselect a row in the grid.
 void deselectRows()
          Deselect all selected rows in the data table.
 java.util.Set<java.lang.Integer> getSelectedRows()
           
protected  java.util.Map<java.lang.Integer,com.google.gwt.user.client.Element> getSelectedRowsMap()
           
 SelectionGrid.SelectionGridCellFormatter getSelectionGridCellFormatter()
          Explicitly gets the SelectionGrid.SelectionGridCellFormatter.
 SelectionGrid.SelectionGridRowFormatter getSelectionGridRowFormatter()
          Explicitly gets the SelectionGrid.SelectionGridRowFormatter.
 SelectionGrid.SelectionPolicy getSelectionPolicy()
           
protected  void hoverCell(com.google.gwt.user.client.Element cellElem)
          Set the current hovering cell.
protected  int insertRow(int beforeRow)
          Inserts a new row into the table.
 boolean isRowSelected(int row)
           
 void onBrowserEvent(com.google.gwt.user.client.Event event)
          Method to process events generated from the browser.
protected  void removeRow(int row)
          Removes the specified row from the table.
 void removeTableSelectionListener(TableSelectionListener listener)
          Remove a TableSelectionListener.
 void selectRow(int row, boolean unselectAll)
          Select a row in the data table.
 void selectRow(int row, boolean ctrlKey, boolean shiftKey)
          Select a row in the data table.
protected  void selectRow(int row, com.google.gwt.user.client.Element rowElem, boolean unselectAll, boolean fireEvent)
          Select a row in the data table.
 void setSelectionPolicy(SelectionGrid.SelectionPolicy selectionPolicy)
          Set the selection policy, which determines if the user can select zero, one, or multiple rows.
 
Methods inherited from class com.google.gwt.widgetideas.table.client.overrides.Grid
createCell, getCellCount, getColumnCount, getRowCount, prepareCell, prepareColumn, prepareRow, resize, resizeColumns, resizeRows
 
Methods inherited from class com.google.gwt.widgetideas.table.client.overrides.HTMLTable
addTableListener, checkCellBounds, checkRowBounds, cleanCell, clear, clearAll, clearCell, getBodyElement, getCellContainer, getCellContainer, getCellFormatter, getCellPadding, getCellSpacing, getColumnFormatter, getDOMCellCount, getDOMCellCount, getDOMRowCount, getDOMRowCount, getEventTargetCell, getEventTargetRow, getHTML, getRowFormatter, getRowIndex, getText, getWidget, getWidgetMap, insertCell, insertCells, internalClearCell, isCellPresent, iterator, remove, removeCell, removeTableListener, setBodyElement, setBorderWidth, setCellFormatter, setCellPadding, setCellSpacing, setClearText, setColumnFormatter, setElement, setHTML, setRowFormatter, setText, setWidget
 
Methods inherited from class com.google.gwt.user.client.ui.Panel
add, adopt, adopt, disown, doAttachChildren, doDetachChildren, onLoad, onUnload, orphan
 
Methods inherited from class com.google.gwt.user.client.ui.Widget
getParent, isAttached, onAttach, onDetach, removeFromParent, setElement
 
Methods inherited from class com.google.gwt.user.client.ui.UIObject
addStyleDependentName, addStyleName, ensureDebugId, ensureDebugId, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, onEnsureDebugId, removeStyleDependentName, removeStyleName, setHeight, setPixelSize, setSize, setStyleName, setStyleName, setStyleName, setStylePrimaryName, setStylePrimaryName, setTitle, setVisible, setVisible, setWidth, sinkEvents, toString, unsinkEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SelectionGrid

public SelectionGrid()
Constructor.


SelectionGrid

public SelectionGrid(int rows,
                     int columns)
Constructs a SelectionGrid with the requested size.

Parameters:
rows - the number of rows
columns - the number of columns
Throws:
java.lang.IndexOutOfBoundsException
Method Detail

addTableSelectionListener

public void addTableSelectionListener(TableSelectionListener listener)
Add a TableSelectionListener.

Specified by:
addTableSelectionListener in interface SourceTableSelectionEvents
Parameters:
listener - the listener

deselectRow

public void deselectRow(int row)
Deselect a row in the grid. This method is safe to call even if the row is not selected, or doesn't exist (out of bounds).

Parameters:
row - the row index

deselectRows

public void deselectRows()
Deselect all selected rows in the data table.


getSelectedRows

public java.util.Set<java.lang.Integer> getSelectedRows()
Returns:
the set of selected row indexes

getSelectionGridCellFormatter

public SelectionGrid.SelectionGridCellFormatter getSelectionGridCellFormatter()
Explicitly gets the SelectionGrid.SelectionGridCellFormatter. The results of HTMLTable.getCellFormatter() may also be downcast to a SelectionGrid.SelectionGridCellFormatter.

Returns:
the FlexTable's cell formatter

getSelectionGridRowFormatter

public SelectionGrid.SelectionGridRowFormatter getSelectionGridRowFormatter()
Explicitly gets the SelectionGrid.SelectionGridRowFormatter. The results of HTMLTable.getRowFormatter() may also be downcast to a SelectionGrid.SelectionGridRowFormatter.

Returns:
the FlexTable's cell formatter

getSelectionPolicy

public SelectionGrid.SelectionPolicy getSelectionPolicy()
Returns:
the selection policy

isRowSelected

public boolean isRowSelected(int row)
Parameters:
row - the row index
Returns:
true if the row is selected, false if not

onBrowserEvent

public void onBrowserEvent(com.google.gwt.user.client.Event event)
Description copied from class: HTMLTable
Method to process events generated from the browser.

Specified by:
onBrowserEvent in interface com.google.gwt.user.client.EventListener
Overrides:
onBrowserEvent in class HTMLTable
Parameters:
event - the generated event
See Also:
HTMLTable

removeTableSelectionListener

public void removeTableSelectionListener(TableSelectionListener listener)
Remove a TableSelectionListener.

Specified by:
removeTableSelectionListener in interface SourceTableSelectionEvents
Parameters:
listener - the listener to remove

selectRow

public void selectRow(int row,
                      boolean unselectAll)
Select a row in the data table.

Parameters:
row - the row index
unselectAll - unselect all other rows first
Throws:
java.lang.IndexOutOfBoundsException

selectRow

public void selectRow(int row,
                      boolean ctrlKey,
                      boolean shiftKey)
Select a row in the data table. Simulate the effect of a shift click and/or control click. This method ignores the selection policy, which only applies to user selection via mouse events.

Parameters:
row - the row index
ctrlKey - true to simulate a control click
shiftKey - true to simulate a shift selection
Throws:
java.lang.IndexOutOfBoundsException

setSelectionPolicy

public void setSelectionPolicy(SelectionGrid.SelectionPolicy selectionPolicy)
Set the selection policy, which determines if the user can select zero, one, or multiple rows.

Parameters:
selectionPolicy - the selection policy

getSelectedRowsMap

protected java.util.Map<java.lang.Integer,com.google.gwt.user.client.Element> getSelectedRowsMap()
Returns:
a map or selected row indexes to their elements

hoverCell

protected void hoverCell(com.google.gwt.user.client.Element cellElem)
Set the current hovering cell.

Parameters:
cellElem - the cell element

insertRow

protected int insertRow(int beforeRow)
Description copied from class: HTMLTable
Inserts a new row into the table.

Overrides:
insertRow in class Grid
Parameters:
beforeRow - the index before which the new row will be inserted
Returns:
the index of the newly-created row
See Also:
HTMLTable

removeRow

protected void removeRow(int row)
Description copied from class: HTMLTable
Removes the specified row from the table.

Overrides:
removeRow in class Grid
Parameters:
row - the index of the row to be removed
See Also:
HTMLTable

selectRow

protected void selectRow(int row,
                         com.google.gwt.user.client.Element rowElem,
                         boolean unselectAll,
                         boolean fireEvent)
Select a row in the data table.

Parameters:
row - the row index, or -1 if unknown
rowElem - the row element
unselectAll - true to unselect all currently selected rows
fireEvent - true to fire the select event to listeners