EchoPoint
1.0

echopoint
Class SelectableTable

java.lang.Object
  extended bynextapp.echo.Component
      extended bynextapp.echo.Table
          extended byechopoint.SortableTable
              extended byechopoint.SelectableTable
All Implemented Interfaces:
ReflectionSetter, Scrollable, java.io.Serializable

public class SelectableTable
extends SortableTable
implements ReflectionSetter

The SelectableTable is a SortableTable component that allows the table rows to be selected, much like a a ListBox. In fact it uses the same ListSelectionModel interface to track which rows have been selected.

And like a ListBox, the SelectableTable has two selection modes : single and multiple row selection.

A SelectableTable is derived from SortableTable and hence all its sorting funcitonality is available.

The isServerSide property controls whether ActionEvents will be raised back on the server when a row in the table is selected. If this property is false, then no server side ActionEvent will be raised when a table row is selected.

One thing to be aware of is that the "selection model" tracks the selection of table model rows not visual rows. So if the user re-sorts the table contents the originally selected "table model row" will be tracked, not is visual position ie. how it used to appear on the screen before sorting.

See Also:
Serialized Form

Nested Class Summary
static class SelectableTable.NestedStyleInfo
          Nested public static StyleInfo class.
 
Field Summary
static java.lang.String ACTION_COMMAND_CHANGED_PROPERTY
           
static nextapp.echo.Color DEFAULT_ROLLOVER_BACKGROUND
           
static nextapp.echo.Color DEFAULT_ROLLOVER_FOREGROUND
           
static nextapp.echo.Color DEFAULT_SELECTION_BACKGOUND
          The Selection Colors
static nextapp.echo.Color DEFAULT_SELECTION_FOREGROUND
           
static java.lang.String LIST_SELECTION_CHANGED_PROPERTY
          This propery will be changed when the table row selection changes
static int MULTIPLE_SELECTION
          MULTIPLE_SELECTION is convieniently added for ListSelectionModel.MULTIPLE_SELECTION
static int NO_SELECTION
          NO_SELECTION means no selection is possible
static java.lang.String ROLLOVER_BACKGROUND_CHANGED_PROPERTY
           
static java.lang.String ROLLOVER_ENABLED_CHANGED_PROPERTY
           
static java.lang.String ROLLOVER_FOREGROUND_CHANGED_PROPERTY
           
static java.lang.String ROW_CLICK_SELECTION_CHANGED_PROPERTY
           
static java.lang.String SELECTION_BACKGROUND_CHANGED_PROPERTY
           
static java.lang.String SELECTION_FOREGROUND_CHANGED_PROPERTY
           
static java.lang.String SELECTION_HANDLES_SHOWN_CHANGED_PROPERTY
           
static java.lang.String SELECTION_MODEL_CHANGED_PROPERTY
          The ListSelectionModel is used to track what rows are selected
static java.lang.String SERVER_SIDE_CHANGED_PROPERTY
           
static int SINGLE_SELECTION
          SINGLE_SELECTION is convieniently added for ListSelectionModel.SINGLE_SELECTION
static java.lang.String STYLE_ROLLOVER_BACKGROUND
           
static java.lang.String STYLE_ROLLOVER_ENABLED
           
static java.lang.String STYLE_ROLLOVER_FOREGROUND
           
static java.lang.String STYLE_SELECTION_BACKGROUND
           
static java.lang.String STYLE_SELECTION_FOREGROUND
           
 
Fields inherited from class echopoint.SortableTable
DEFAULT_BORDER_COLOR, SCROLL_BAR_X_CHANGED_PROPERTY, SCROLL_BAR_Y_CHANGED_PROPERTY, WRAP_ALLOWED_CHANGED_PROPERTY
 
Fields inherited from class nextapp.echo.Table
AUTO_CREATE_COLUMNS_FROM_MODEL_CHANGED_PROPERTY, BORDER_COLOR_CHANGED_PROPERTY, BORDER_SIZE_CHANGED_PROPERTY, CELL_MARGIN_CHANGED_PROPERTY, DEFAULT_TABLE_CELL_RENDERER, HEIGHT_CHANGED_PROPERTY, HEIGHT_UNITS_CHANGED_PROPERTY, PERCENT_INDIVIDUAL_PIXEL_TOTAL_UNITS, PERCENT_UNITS, PIXEL_UNITS, ROW_HEIGHT_CHANGED_PROPERTY, STYLE_BORDER_COLOR, STYLE_BORDER_SIZE, STYLE_CELL_MARGIN, STYLE_COLUMN_WIDTHS, STYLE_HEIGHT, STYLE_HEIGHT_UNITS, STYLE_ROW_HEIGHTS, STYLE_WIDTH, STYLE_WIDTH_UNITS, TABLE_COLUMN_MODEL_CHANGED_PROPERTY, TABLE_HEADER_CHANGED_PROPERTY, WIDTH_CHANGED_PROPERTY, WIDTH_UNITS_CHANGED_PROPERTY
 
Fields inherited from class nextapp.echo.Component
BACKGROUND_CHANGED_PROPERTY, CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FONT_CHANGED_PROPERTY, FOREGROUND_CHANGED_PROPERTY, IDENTIFIER_CHANGED_PROPERTY, listenerList, LOCALE_CHANGED_PROPERTY, MODEL_CHANGED_PROPERTY, STYLE_BACKGROUND, STYLE_FONT, STYLE_FOREGROUND, UPDATE_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Fields inherited from interface echopoint.positionable.Scrollable
HEIGHT_CHANGED_PROPERTY, SCROLLBAR_POLICY_CHANGED_PROPERTY, SCROLLBARS_ALWAYS, SCROLLBARS_AUTO, SCROLLBARS_CLIPHIDE, SCROLLBARS_NEVER, STYLE_HEIGHT, STYLE_SCROLL_BAR_POLICY, STYLE_WIDTH, UNDEFINED, undefinedSymbolic, WIDTH_CHANGED_PROPERTY
 
Constructor Summary
SelectableTable()
          SelectableTable constructor.
SelectableTable(int columns, int rows)
          SelectableTable constructor.
SelectableTable(nextapp.echo.table.TableModel model)
          SelectableTable constructor comment.
SelectableTable(nextapp.echo.table.TableModel model, nextapp.echo.table.TableColumnModel columnModel)
          Constructs the SelectableTable
 
Method Summary
 void addActionListener(nextapp.echo.event.ActionListener l)
          Adds an ActionListener to the SelectableTable.
 void addListSelectionListener(nextapp.echo.event.ListSelectionListener l)
          Adds a ListSelectionListener to the underlying selection model
 void applyStyle(nextapp.echo.Style style)
          Applies the provided style to the component.
 void fireActionPerformed(nextapp.echo.event.ActionEvent e)
          Notifies all listeners that have registered for this event type.
 java.lang.String getActionCommand()
          Returns the action command for this SelectableTable.
 int getMaxSelectedIndex()
          Returns the maximum selected table row.
 int getMinSelectedIndex()
          Returns the minimum selected table row.
 nextapp.echo.Color getRolloverBackground()
          Returns the rollover background color
 nextapp.echo.Color getRolloverForeground()
          Returns the rollover foreground color
 int getSelectedIndex()
          Returns the selected table row.
 int[] getSelectedIndices()
          Returns all selected table rows.
 nextapp.echo.Color getSelectionBackground()
          Returns the selection background color
 nextapp.echo.Color getSelectionForeground()
          Returns the selection foreground color
 int getSelectionMode()
          Returns the selection mode.
 nextapp.echo.ListSelectionModel getSelectionModel()
          Returns the selection model.
 boolean isRolloverEnabled()
          Returns whether rollovers are enabled.
 boolean isRowClickSelection()
          Returns true if rows can be selected by clicking anywhere in the table row.
 boolean isSelectedIndex(int rowIndex)
          Determines whether an table row is selected.
 boolean isSelectionHandlesShown()
          Returns true if the selection handles should be shown
 boolean isServerSide()
          Returns true if the SelectableTable should raise selection events on the server.
 void removeActionListener(nextapp.echo.event.ActionListener l)
          Removes an ActionListener from the SelectableTable.
 void removeListSelectionListener(nextapp.echo.event.ListSelectionListener l)
          Removes a ListSelectionListener from the underlying selection model
 java.lang.Object set(java.lang.reflect.Field field, java.lang.Object newValue)
          Called to save the old value of a field, set in a new value and return the old value of a field.
 void setActionCommand(java.lang.String newValue)
          Sets the SelectableTable's action command.
 void setModel(nextapp.echo.table.TableModel newValue)
          Sets the TableModel the Table is visualizing.
 void setRolloverBackground(nextapp.echo.Color newRolloverBackground)
          Sets the rollover background color
 void setRolloverEnabled(boolean newValue)
          Sets whether rollovers are enabled.
 void setRolloverForeground(nextapp.echo.Color newRolloverForeground)
          Sets the rollover foreground color
 void setRowClickSelection(boolean newValue)
          Sets whether the user is able to select a table row by clicking anywhere ins the row.
 void setSelectedIndex(int rowIndex)
          Selects only the given table row.
 void setSelectedIndex(int rowIndex, boolean selected)
          Sets the selection state of the given table row.
 void setSelectedIndices(int[] rowIndices)
          Selects an array of table rows.
 void setSelectionBackground(nextapp.echo.Color newSelectionBackground)
          Sets the selection background color
 void setSelectionForeground(nextapp.echo.Color newSelectionForeground)
          Sets the selection foreground color
 void setSelectionHandlesShown(boolean newValue)
          Sets whether selection handles will be shown when the table is rendered.
 void setSelectionMode(int newValue)
          Sets the selection mode.
 void setSelectionModel(nextapp.echo.ListSelectionModel newValue)
          Sets the selection model.
 void setServerSide(boolean newValue)
          If set to true then the SelectableTable will raise selection events on the server.
 
Methods inherited from class echopoint.SortableTable
getHeight, getScrollBarPolicy, getScrollBarX, getScrollBarY, isWrapAllowed, setColumnModel, setHeaderCellRender, setHeight, setScrollBarPolicy, setScrollBarX, setScrollBarY, setWrapAllowed, sortByColumn, sortByColumn
 
Methods inherited from class nextapp.echo.Table
createDefaultColumnsFromModel, getBorderColor, getBorderSize, getCellMargin, getColumnCount, getColumnModel, getComponent, getDefaultRenderer, getHeightUnits, getModel, getRowCount, getRowHeight, getTableHeader, getWidth, getWidthUnits, invalidate, isAutoCreateColumnsFromModel, setAutoCreateColumnsFromModel, setBorderColor, setBorderSize, setCellMargin, setDefaultRenderer, setHeightUnits, setRowHeight, setTableHeader, setWidth, setWidthUnits, validate
 
Methods inherited from class nextapp.echo.Component
add, add, addHierarchyListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getComponent, getComponentCount, getComponents, getEchoInstance, getFont, getForeground, getIdentifier, getLocale, getParent, indexOf, init, isAncestorOf, isEnabled, isRegistered, isShowing, isVisible, remove, remove, removeAll, removeHierarchyListener, removePropertyChangeListener, setBackground, setEnabled, setFont, setForeground, setIdentifier, setLocale, setVisible, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface echopoint.positionable.Scrollable
getWidth, setWidth
 

Field Detail

MULTIPLE_SELECTION

public static final int MULTIPLE_SELECTION
MULTIPLE_SELECTION is convieniently added for ListSelectionModel.MULTIPLE_SELECTION

See Also:
Constant Field Values

SINGLE_SELECTION

public static final int SINGLE_SELECTION
SINGLE_SELECTION is convieniently added for ListSelectionModel.SINGLE_SELECTION

See Also:
Constant Field Values

NO_SELECTION

public static final int NO_SELECTION
NO_SELECTION means no selection is possible

See Also:
Constant Field Values

LIST_SELECTION_CHANGED_PROPERTY

public static final java.lang.String LIST_SELECTION_CHANGED_PROPERTY
This propery will be changed when the table row selection changes

See Also:
Constant Field Values

SELECTION_MODEL_CHANGED_PROPERTY

public static final java.lang.String SELECTION_MODEL_CHANGED_PROPERTY
The ListSelectionModel is used to track what rows are selected

See Also:
Constant Field Values

DEFAULT_SELECTION_BACKGOUND

public static final nextapp.echo.Color DEFAULT_SELECTION_BACKGOUND
The Selection Colors


DEFAULT_ROLLOVER_BACKGROUND

public static final nextapp.echo.Color DEFAULT_ROLLOVER_BACKGROUND

DEFAULT_SELECTION_FOREGROUND

public static final nextapp.echo.Color DEFAULT_SELECTION_FOREGROUND

DEFAULT_ROLLOVER_FOREGROUND

public static final nextapp.echo.Color DEFAULT_ROLLOVER_FOREGROUND

SELECTION_BACKGROUND_CHANGED_PROPERTY

public static final java.lang.String SELECTION_BACKGROUND_CHANGED_PROPERTY
See Also:
Constant Field Values

STYLE_SELECTION_BACKGROUND

public static final java.lang.String STYLE_SELECTION_BACKGROUND
See Also:
Constant Field Values

SELECTION_FOREGROUND_CHANGED_PROPERTY

public static final java.lang.String SELECTION_FOREGROUND_CHANGED_PROPERTY
See Also:
Constant Field Values

STYLE_SELECTION_FOREGROUND

public static final java.lang.String STYLE_SELECTION_FOREGROUND
See Also:
Constant Field Values

ROLLOVER_BACKGROUND_CHANGED_PROPERTY

public static final java.lang.String ROLLOVER_BACKGROUND_CHANGED_PROPERTY
See Also:
Constant Field Values

STYLE_ROLLOVER_BACKGROUND

public static final java.lang.String STYLE_ROLLOVER_BACKGROUND
See Also:
Constant Field Values

ROLLOVER_FOREGROUND_CHANGED_PROPERTY

public static final java.lang.String ROLLOVER_FOREGROUND_CHANGED_PROPERTY
See Also:
Constant Field Values

STYLE_ROLLOVER_FOREGROUND

public static final java.lang.String STYLE_ROLLOVER_FOREGROUND
See Also:
Constant Field Values

STYLE_ROLLOVER_ENABLED

public static final java.lang.String STYLE_ROLLOVER_ENABLED
See Also:
Constant Field Values

ROLLOVER_ENABLED_CHANGED_PROPERTY

public static final java.lang.String ROLLOVER_ENABLED_CHANGED_PROPERTY
See Also:
Constant Field Values

ACTION_COMMAND_CHANGED_PROPERTY

public static final java.lang.String ACTION_COMMAND_CHANGED_PROPERTY
See Also:
Constant Field Values

SERVER_SIDE_CHANGED_PROPERTY

public static final java.lang.String SERVER_SIDE_CHANGED_PROPERTY
See Also:
Constant Field Values

SELECTION_HANDLES_SHOWN_CHANGED_PROPERTY

public static final java.lang.String SELECTION_HANDLES_SHOWN_CHANGED_PROPERTY
See Also:
Constant Field Values

ROW_CLICK_SELECTION_CHANGED_PROPERTY

public static final java.lang.String ROW_CLICK_SELECTION_CHANGED_PROPERTY
See Also:
Constant Field Values
Constructor Detail

SelectableTable

public SelectableTable()
SelectableTable constructor.


SelectableTable

public SelectableTable(int columns,
                       int rows)
SelectableTable constructor.

Parameters:
columns - int
rows - int

SelectableTable

public SelectableTable(nextapp.echo.table.TableModel model)
SelectableTable constructor comment.

Parameters:
model - nextapp.echo.table.TableModel

SelectableTable

public SelectableTable(nextapp.echo.table.TableModel model,
                       nextapp.echo.table.TableColumnModel columnModel)
Constructs the SelectableTable

Parameters:
model - nextapp.echo.table.TableModel
columnModel - nextapp.echo.table.TableColumnModel
Method Detail

applyStyle

public void applyStyle(nextapp.echo.Style style)
Applies the provided style to the component. The base nextapp.echo.Component style names can be used as well.

Specified by:
applyStyle in interface Scrollable
Overrides:
applyStyle in class SortableTable

getMaxSelectedIndex

public int getMaxSelectedIndex()
Returns the maximum selected table row.

NOTE : the row Index is of the underlying table model, not how the rows are visually drawn. A sorted table model may appear visually in a different order to the table model.

Returns:
the maximum selected table row.

getMinSelectedIndex

public int getMinSelectedIndex()
Returns the minimum selected table row.

NOTE : the row Index is of the underlying table model, not how the rows are visually drawn. A sorted table model may appear visually in a different order to the table model.

Returns:
The minimum selected table row.

getSelectedIndex

public int getSelectedIndex()
Returns the selected table row. This method is used for SelectableTables where the selectionMode property is set to ListSelectionModel.SINGLE_SELECT. In the event multiple selection is enabled, this method will return the lowest selected table row.

NOTE : the row Index is of the underlying table model, not how the rows are visually drawn. A sorted table model may appear visually in a different order to the table model.

Returns:
The selected index.

getSelectedIndices

public int[] getSelectedIndices()
Returns all selected table rows.

NOTE : the row Indices are of the underlying table model, not how the rows are visually drawn. A sorted table model may appear visually in a different order to the table model.

Returns:
An array of all selected table rows.

getSelectionBackground

public nextapp.echo.Color getSelectionBackground()
Returns the selection background color

Returns:
nextapp.echo.Color

getSelectionForeground

public nextapp.echo.Color getSelectionForeground()
Returns the selection foreground color

Returns:
nextapp.echo.Color

getRolloverBackground

public nextapp.echo.Color getRolloverBackground()
Returns the rollover background color

Returns:
nextapp.echo.Color

getRolloverForeground

public nextapp.echo.Color getRolloverForeground()
Returns the rollover foreground color

Returns:
nextapp.echo.Color

getSelectionMode

public int getSelectionMode()
Returns the selection mode.

Returns:
The selection mode, one of the following values:
  • MULTIPLE_SELECTION: multiple table rows may be selected.
  • NO_SELECTION: no table rows may be selected.

getSelectionModel

public nextapp.echo.ListSelectionModel getSelectionModel()
Returns the selection model.

Returns:
The selection model.

isSelectedIndex

public boolean isSelectedIndex(int rowIndex)
Determines whether an table row is selected.

NOTE : the rowIndex is of the underlying table model, not how the rows are visually drawn. A sorted table model may appear visually in a different order to the table model.

Parameters:
rowIndex - The table row index to test for selection.
Returns:
True if the given table row is selected.

setSelectedIndex

public void setSelectedIndex(int rowIndex)
Selects only the given table row.

NOTE : the rowIndex is of the underlying table model, not how the rows are visually drawn. A sorted table model may appear visually in a different order to the table model.

Parameters:
rowIndex - The table row index to select.

setSelectedIndex

public void setSelectedIndex(int rowIndex,
                             boolean selected)
Sets the selection state of the given table row.

NOTE : the rowIndex is of the underlying table model, not how the rows are visually drawn. A sorted table model may appear visually in a different order to the table model.

Parameters:
rowIndex - The table row index to select.
selected - The state of the new selection

setSelectedIndices

public void setSelectedIndices(int[] rowIndices)
Selects an array of table rows.

NOTE : the row Indices are of the underlying table model, not how the rows are visually drawn. A sorted table model may appear visually in a different order to the table model.

Parameters:
rowIndices - The table rows to be selected.

setSelectionBackground

public void setSelectionBackground(nextapp.echo.Color newSelectionBackground)
Sets the selection background color

Parameters:
newSelectionBackground - nextapp.echo.Color

setSelectionForeground

public void setSelectionForeground(nextapp.echo.Color newSelectionForeground)
Sets the selection foreground color

Parameters:
newSelectionForeground - nextapp.echo.Color

setRolloverBackground

public void setRolloverBackground(nextapp.echo.Color newRolloverBackground)
Sets the rollover background color

Parameters:
newRolloverBackground - nextapp.echo.Color

setRolloverForeground

public void setRolloverForeground(nextapp.echo.Color newRolloverForeground)
Sets the rollover foreground color

Parameters:
newRolloverForeground - nextapp.echo.Color

setSelectionMode

public void setSelectionMode(int newValue)
Sets the selection mode.

Parameters:
newValue - The selection mode, one of the following values:
  • SINGLE_SELECTION: only one list element may be selected.
  • MULTIPLE_SELECTION: multiple list elements may be selected.
  • NO_SELECTION: no table rows may be selected.

setSelectionModel

public void setSelectionModel(nextapp.echo.ListSelectionModel newValue)
Sets the selection model.

Parameters:
newValue - The new selection model.

addActionListener

public void addActionListener(nextapp.echo.event.ActionListener l)
Adds an ActionListener to the SelectableTable.

Parameters:
l - The ActionListener to be added.

fireActionPerformed

public void fireActionPerformed(nextapp.echo.event.ActionEvent e)
Notifies all listeners that have registered for this event type.

Parameters:
e - The ActionEvent to send.

isRolloverEnabled

public boolean isRolloverEnabled()
Returns whether rollovers are enabled.

Returns:
True if rollovers are enabled.

removeActionListener

public void removeActionListener(nextapp.echo.event.ActionListener l)
Removes an ActionListener from the SelectableTable.

Parameters:
l - The ActionListener to be removed.

setActionCommand

public void setActionCommand(java.lang.String newValue)
Sets the SelectableTable's action command.

Parameters:
newValue - The new action command for this SelectableTable.

setRolloverEnabled

public void setRolloverEnabled(boolean newValue)
Sets whether rollovers are enabled.

Parameters:
newValue - True if rollovers should be enabled.

getActionCommand

public java.lang.String getActionCommand()
Returns the action command for this SelectableTable.

Returns:
The action command for this SelectableTable.

isServerSide

public boolean isServerSide()
Returns true if the SelectableTable should raise selection events on the server.

Returns:
boolean

setServerSide

public void setServerSide(boolean newValue)
If set to true then the SelectableTable will raise selection events on the server.


addListSelectionListener

public void addListSelectionListener(nextapp.echo.event.ListSelectionListener l)
Adds a ListSelectionListener to the underlying selection model

Parameters:
l - - listener

removeListSelectionListener

public void removeListSelectionListener(nextapp.echo.event.ListSelectionListener l)
Removes a ListSelectionListener from the underlying selection model

Parameters:
l - - listener

isSelectionHandlesShown

public boolean isSelectionHandlesShown()
Returns true if the selection handles should be shown

Returns:
boolean

setSelectionHandlesShown

public void setSelectionHandlesShown(boolean newValue)
Sets whether selection handles will be shown when the table is rendered.

Parameters:
newValue - - the boolean flag

isRowClickSelection

public boolean isRowClickSelection()
Returns true if rows can be selected by clicking anywhere in the table row.

Returns:
true if rows can be selected by clicking

setRowClickSelection

public void setRowClickSelection(boolean newValue)
Sets whether the user is able to select a table row by clicking anywhere ins the row. By default this is true, however on some clients, this may interfere with clicking on other components within the table row. This allows you to turn off such row selection and instead use the standard selection handles.

Parameters:
newValue -

setModel

public void setModel(nextapp.echo.table.TableModel newValue)
Sets the TableModel the Table is visualizing.

Overrides:
setModel in class SortableTable
Parameters:
newValue - The new TableModel.

set

public java.lang.Object set(java.lang.reflect.Field field,
                            java.lang.Object newValue)
                     throws java.lang.Exception
Description copied from interface: ReflectionSetter
Called to save the old value of a field, set in a new value and return the old value of a field. This interface allows a field set operation to be "delegated" back into the class that has permission to perform the field set.

 public Object set(Field f, Object newValue) throws Exception {
      Object oldValue = f.get(this);
      f.set(this,newValue);
      return oldValue;
 }
 

Specified by:
set in interface ReflectionSetter
Overrides:
set in class SortableTable
Throws:
java.lang.Exception
See Also:
ReflectionSetter.set(Field, Object)

EchoPoint
1.0