EchoPoint
1.0

echopoint
Class SortableTable

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

public class SortableTable
extends nextapp.echo.Table
implements Scrollable, ReflectionSetter

A Table derived class that can be sorted by clicking on a given column header.

This class uses the SortableTableModel to allow sorting of a TableModel by shadowing the model and sorting an array of indexes to the underlying data.

This Table implementation also uses a ComponentTableCellRenderer that allows table cells to contain Component objects. It uses a new ComponentTableCellRenderer as the cell renderer for each column in the TableColumnModel. It will use this Component firendly rendererer if you have noty already set in a TableCellRenderer for each contained TableColumn.

The SortableTable differs from its parent in that it implements Scrollable. This allows a height value to be set (in pixels) and the table contents will be scrolled within that height. If the table has a header row, then the header row is no scrolled and it will always be present at the top of the table.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class echopoint.positionable.Scrollable
Scrollable.NestedStyleInfo
 
Field Summary
static nextapp.echo.Color DEFAULT_BORDER_COLOR
          The default border color
static java.lang.String SCROLL_BAR_X_CHANGED_PROPERTY
          This property name is fired when the scolling bar X value changes
static java.lang.String SCROLL_BAR_Y_CHANGED_PROPERTY
          This property name is fired when the scolling bar Y value changes
static java.lang.String WRAP_ALLOWED_CHANGED_PROPERTY
          This property name is fired when the wrapAllowed property changes
 
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
SortableTable()
          SortableTable constructor.
SortableTable(int columns, int rows)
          SortableTable constructor.
SortableTable(nextapp.echo.table.TableModel model)
          SortableTable constructor.
SortableTable(nextapp.echo.table.TableModel model, nextapp.echo.table.TableColumnModel columnModel)
          SortableTable constructor.
 
Method Summary
 void applyStyle(nextapp.echo.Style style)
          Applies the provided style to the component.
 int getHeight()
          Returns the overall height of the table.
 int getScrollBarPolicy()
          Returns the ScrollBarPolicy in place This can be one of : SCOLLBARS_NONE SCOLLBARS_ALWAYS SCOLLBARS_AUTO
 int getScrollBarX()
          Returns the position of the horizontal scroll bar, in pixels offset from the left of the component.
 int getScrollBarY()
          Returns the position of the vertical scroll bar, in pixels offset from the top the component.
 boolean isWrapAllowed()
          Returns whether table cell wrapping is in place.
 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 setColumnModel(nextapp.echo.table.TableColumnModel newValue)
          Sets the column model for this table.
 void setHeaderCellRender(SortableTableHeaderRenderer newRenderer)
          Sets a new SortableTableHeaderRenderer for each of the columns in the table's TableColumnModel.
 void setHeight(int newValue)
          Sets the overall height of the table.
 void setModel(nextapp.echo.table.TableModel newModel)
          This sets the model for the SortableTable.
 void setScrollBarPolicy(int newScrollBarPolicy)
          This sets the scroll bar policy to use.
 void setScrollBarX(int newValue)
          Sets the position of the horizontal scroll bar, in pixels offset from the left of the component.
 void setScrollBarY(int newValue)
          Sets the position of the vertical scroll bar, in pixels offset from the top of the component.
 void setWrapAllowed(boolean newValue)
          Returns whether table cell wrapping is in place.
 void sortByColumn(int column)
          Sorts the underlying table model via the given column in ascending order
 void sortByColumn(int column, boolean ascending)
          Sorts the underlying table model via the given column in the specified order.
 
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

DEFAULT_BORDER_COLOR

public static final nextapp.echo.Color DEFAULT_BORDER_COLOR
The default border color


SCROLL_BAR_X_CHANGED_PROPERTY

public static final java.lang.String SCROLL_BAR_X_CHANGED_PROPERTY
This property name is fired when the scolling bar X value changes

See Also:
Constant Field Values

SCROLL_BAR_Y_CHANGED_PROPERTY

public static final java.lang.String SCROLL_BAR_Y_CHANGED_PROPERTY
This property name is fired when the scolling bar Y value changes

See Also:
Constant Field Values

WRAP_ALLOWED_CHANGED_PROPERTY

public static final java.lang.String WRAP_ALLOWED_CHANGED_PROPERTY
This property name is fired when the wrapAllowed property changes

See Also:
Constant Field Values
Constructor Detail

SortableTable

public SortableTable()
SortableTable constructor.


SortableTable

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

Parameters:
columns - int
rows - int

SortableTable

public SortableTable(nextapp.echo.table.TableModel model)
SortableTable constructor. If the new TableModel is not derived from SortableTableModel, then it will be wrapped in one.

Parameters:
model - nextapp.echo.table.TableModel

SortableTable

public SortableTable(nextapp.echo.table.TableModel model,
                     nextapp.echo.table.TableColumnModel columnModel)
SortableTable constructor. If the new TableModel is not derived from SortableTableModel, then it will be wrapped in one.

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

getHeight

public int getHeight()
Returns the overall height of the table.

This property differs in behaviour the parent Table class. If the height units are pixels, then this property will be used to set up a scrollable table area of 'n' pixels.

Specified by:
getHeight in interface Scrollable
Returns:
The height of the table. If the height is not defined, EchoConstants.UNDEFINED_SIZE is returned.

getScrollBarPolicy

public int getScrollBarPolicy()
Returns the ScrollBarPolicy in place This can be one of :

Specified by:
getScrollBarPolicy in interface Scrollable

getScrollBarX

public int getScrollBarX()
Returns the position of the horizontal scroll bar, in pixels offset from the left of the component.

Specified by:
getScrollBarX in interface Scrollable
Returns:
The position of the horizontal scroll bar.

getScrollBarY

public int getScrollBarY()
Returns the position of the vertical scroll bar, in pixels offset from the top the component.

Specified by:
getScrollBarY in interface Scrollable
Returns:
The position of the vertical scroll bar.

isWrapAllowed

public boolean isWrapAllowed()
Returns whether table cell wrapping is in place.

If this property is true then the contents of the table cells MAY be wrapped to fit in the smallest possible space.

Returns:
boolean

setHeaderCellRender

public void setHeaderCellRender(SortableTableHeaderRenderer newRenderer)
Sets a new SortableTableHeaderRenderer for each of the columns in the table's TableColumnModel. The SortableTableModel of the new SortableTableHeaderRenderer will be set to the current table model.


setHeight

public void setHeight(int newValue)
Sets the overall height of the table.

This property differs in behaviour the parent Table class. If the height units are pixels, then this property will be used to set up a scrollable table area of 'n' pixels.

Specified by:
setHeight in interface Scrollable
Parameters:
newValue - The new height of the table. To set the height to be undefined, use the EchoConstants.UNDEFINED_SIZE constant.

setModel

public void setModel(nextapp.echo.table.TableModel newModel)
This sets the model for the SortableTable. If the new model is not derived from SortableTableModel, it will be wrapped in one, and hence allow sorting.


setColumnModel

public void setColumnModel(nextapp.echo.table.TableColumnModel newValue)
Sets the column model for this table.

Parameters:
newValue - The new column model for this table.

setScrollBarPolicy

public void setScrollBarPolicy(int newScrollBarPolicy)
This sets the scroll bar policy to use. This can be one of :

Specified by:
setScrollBarPolicy in interface Scrollable

setScrollBarX

public void setScrollBarX(int newValue)
Sets the position of the horizontal scroll bar, in pixels offset from the left of the component.

Specified by:
setScrollBarX in interface Scrollable
Parameters:
newValue - The new position of the horizontal scroll bar, in pixels.

setScrollBarY

public void setScrollBarY(int newValue)
Sets the position of the vertical scroll bar, in pixels offset from the top of the component.

Specified by:
setScrollBarY in interface Scrollable
Parameters:
newValue - The new position of the vertical scroll bar, in pixels.

setWrapAllowed

public void setWrapAllowed(boolean newValue)
Returns whether table cell wrapping is in place.

If this property is true then the contents of the table cells MAY be wrapped to fit in the smallest possible space.

Parameters:
newValue - boolean - the wrap flag

sortByColumn

public void sortByColumn(int column)
Sorts the underlying table model via the given column in ascending order


sortByColumn

public void sortByColumn(int column,
                         boolean ascending)
Sorts the underlying table model via the given column in the specified order.


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
Parameters:
field - - the field to be set
newValue - - the new value to be set
Returns:
the oldValue of the field
Throws:
java.lang.Exception
See Also:
ReflectionSetter.set(Field, Object)

EchoPoint
1.0