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

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.HoverGrid
All Implemented Interfaces:
com.google.gwt.user.client.EventListener, com.google.gwt.user.client.ui.HasWidgets, com.google.gwt.user.client.ui.SourcesTableEvents, HasColumns
Direct Known Subclasses:
FixedWidthGrid

public class HoverGrid
extends Grid

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


Nested Class Summary
 class HoverGrid.HoverGridRowFormatter
          This class contains methods used to format a table's rows.
 
Nested classes/interfaces inherited from class com.google.gwt.widgetideas.table.client.overrides.HTMLTable
HTMLTable.CellFormatter, HTMLTable.ColumnFormatter, HTMLTable.RowFormatter, HTMLTable.WidgetMapper
 
Field Summary
static int HOVERING_POLICY_CELL
          Enable hovering of a cell.
static int HOVERING_POLICY_DISABLED
          Disable hovering.
static int HOVERING_POLICY_ROW
          Enable hovering of a row.
static int SELECTION_POLICY_DISABLED
          Disable row selection.
static int SELECTION_POLICY_MULTI_ROW
          Allow multiple rows to be selected.
static int SELECTION_POLICY_ONE_ROW
          Allow only one row to be selected at a time.
 
Fields inherited from class com.google.gwt.widgetideas.table.client.overrides.Grid
numColumns, numRows
 
Constructor Summary
HoverGrid()
          Constructor.
HoverGrid(int rows, int columns)
          Constructs a HoverGrid with the requested size.
 
Method Summary
 void addHoverGridListener(HoverGridListener listener)
          Add a listener to this grid.
 void deselectRow(int row)
          Deselect a row in the data table.
 void deselectRows()
          Deselect all selected rows in the data table.
 int getHoveringPolicy()
          Returns the current hovering policy.
protected  int getRowIndex(com.google.gwt.user.client.Element rowElem)
          Get the index of a row given the row element.
 java.util.Set getSelectedRows()
          Returns a Set of selected row indexes.
protected  java.util.Map getSelectedRowsMap()
          Returns a HashMap of selected rows.
 int getSelectionPolicy()
          Returns the current selection policy.
protected  void hoverCell(com.google.gwt.user.client.Element cellElem, com.google.gwt.user.client.Element rowElem)
          Set the current hovering cell.
protected  void hoverRow(com.google.gwt.user.client.Element rowElem)
          Set the current hovering row.
protected  int insertRow(int beforeRow)
          Inserts a new row into the table, deselecting all selected rows.
 boolean isRowSelected(int row)
          Returns true if the row is currently selected.
 void onBrowserEvent(com.google.gwt.user.client.Event event)
          Method to process events generated from the browser.
 void onCellClicked(int row, int cell)
          Handle cell click events.
 void removeHoverGridListener(HoverGridListener listener)
          Remove one of the grid listeners.
 void removeRow(int row)
          Removes the specified row from the table.
 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 setHoveringPolicy(int hoveringPolicy)
          Set the hovering policy.
 void setMinHoverRow(int minRow)
          Set the index of the first row that can be hovered or selected.
 void setSelectionPolicy(int selectionPolicy)
          Set the selection policy, which determines if the user can select zero, one, or multiple rows.
protected  void unhover()
          Unhighlight the currently hovering row or cell.
 
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, getHTML, getRowFormatter, getText, getWidget, getWidgetMap, insertCell, insertCells, internalClearCell, isCellPresent, iterator, remove, removeCell, removeTableListener, setBodyElement, setBorderWidth, setCellFormatter, setCellPadding, setCellSpacing, setClearText, setColumnFormatter, 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, getAbsoluteLeft, getAbsoluteTop, getElement, getOffsetHeight, getOffsetWidth, getStyleElement, getStyleName, getStyleName, getStylePrimaryName, getStylePrimaryName, getTitle, isVisible, isVisible, 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
 
Methods inherited from interface com.google.gwt.widgetideas.table.client.HasColumns
getElement, getOffsetWidth, setStyleName
 

Field Detail

HOVERING_POLICY_CELL

public static final int HOVERING_POLICY_CELL
Enable hovering of a cell.

See Also:
Constant Field Values

HOVERING_POLICY_DISABLED

public static final int HOVERING_POLICY_DISABLED
Disable hovering.

See Also:
Constant Field Values

HOVERING_POLICY_ROW

public static final int HOVERING_POLICY_ROW
Enable hovering of a row.

See Also:
Constant Field Values

SELECTION_POLICY_DISABLED

public static final int SELECTION_POLICY_DISABLED
Disable row selection.

See Also:
Constant Field Values

SELECTION_POLICY_MULTI_ROW

public static final int SELECTION_POLICY_MULTI_ROW
Allow multiple rows to be selected.

See Also:
Constant Field Values

SELECTION_POLICY_ONE_ROW

public static final int SELECTION_POLICY_ONE_ROW
Allow only one row to be selected at a time.

See Also:
Constant Field Values
Constructor Detail

HoverGrid

public HoverGrid()
Constructor.


HoverGrid

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

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

addHoverGridListener

public void addHoverGridListener(HoverGridListener listener)
Add a listener to this grid.

Parameters:
listener - the listener

deselectRow

public void deselectRow(int row)
Deselect a row in the data table.

Parameters:
row - the row index

deselectRows

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


getHoveringPolicy

public int getHoveringPolicy()
Returns the current hovering policy.

Returns:
the hovering policy.

getSelectedRows

public java.util.Set getSelectedRows()
Returns a Set of selected row indexes.

Returns:
the selected rows

getSelectionPolicy

public int getSelectionPolicy()
Returns the current selection policy.

Returns:
the selection policy

isRowSelected

public boolean isRowSelected(int row)
Returns true if the row is currently selected.

Parameters:
row - the row index
Returns:
true if the row is selected

onBrowserEvent

public void onBrowserEvent(com.google.gwt.user.client.Event event)
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

onCellClicked

public void onCellClicked(int row,
                          int cell)
Handle cell click events.

Parameters:
row - the row index
cell - the cell index

removeHoverGridListener

public void removeHoverGridListener(HoverGridListener listener)
Remove one of the grid listeners.

Parameters:
listener - the listener to remove

removeRow

public void removeRow(int row)
Removes the specified row from the table.

Overrides:
removeRow in class HTMLTable
Parameters:
row - the index of the row to be removed
Throws:
java.lang.IndexOutOfBoundsException

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

setHoveringPolicy

public void setHoveringPolicy(int hoveringPolicy)
Set the hovering policy.

Parameters:
hoveringPolicy - the hovering policy to use

setMinHoverRow

public void setMinHoverRow(int minRow)
Set the index of the first row that can be hovered or selected. Use this option if the first one or more rows of your Grid are used as headers.

Parameters:
minRow - the min row that can be hovered

setSelectionPolicy

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

Parameters:
selectionPolicy - the selection policy

getRowIndex

protected int getRowIndex(com.google.gwt.user.client.Element rowElem)
Get the index of a row given the row element.


getSelectedRowsMap

protected java.util.Map getSelectedRowsMap()
Returns a HashMap of selected rows.

Returns:
the selected rows

hoverCell

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

Parameters:
cellElem - the cell element

hoverRow

protected void hoverRow(com.google.gwt.user.client.Element rowElem)
Set the current hovering row.

Parameters:
rowElem - the row element

insertRow

protected int insertRow(int beforeRow)
Inserts a new row into the table, deselecting all selected rows.

Overrides:
insertRow in class HTMLTable
Parameters:
beforeRow - the index before which the new row will be inserted
Returns:
the index of the newly-created row
Throws:
java.lang.IndexOutOfBoundsException

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

unhover

protected void unhover()
Unhighlight the currently hovering row or cell.