echopoint.table
Class SortableTableHeaderRenderer

java.lang.Object
  extended by nextapp.echo.AbstractComponent
      extended by nextapp.echo.AbstractButton
          extended by nextapp.echo.Button
              extended by echopoint.table.SortableTableHeaderRenderer
All Implemented Interfaces:
ReflectionSetter, java.io.Serializable, java.util.EventListener, Component, ActionListener, TableCellRenderer, ToolTipSupport
Direct Known Subclasses:
MySortableTableHeaderRenderer, NonSortableTableHeaderRenderer

public class SortableTableHeaderRenderer
extends Button
implements TableCellRenderer, ActionListener, java.io.Serializable, ReflectionSetter

Renders the table header cells for a table with a SortableTableModel. The header cells are buttons that can be pressed to sort a particular table column.

See Also:
Serialized Form

Nested Class Summary
static class SortableTableHeaderRenderer.NestedStyleInfo
          Nested public static StyleInfo class.
 
Field Summary
static Color DEFAULT_HEADER_BACKGROUND
          Default Header Background Color
static ImageReference defaultDownIcon
           
static ImageReference defaultUpIcon
           
static java.lang.String DOWN_ICON_CHANGED_PROPERTY
           
protected  SortableTableModel sortableTableModel
           
protected  java.util.BitSet sortColumnBitSet
           
static java.lang.String STYLE_DOWN_ICON
          Down Icon Property
static java.lang.String STYLE_UP_ICON
          Up Icon Property
static ImageReference transparentIcon
           
static java.lang.String UP_ICON_CHANGED_PROPERTY
           
 
Fields inherited from class nextapp.echo.AbstractButton
ACTION_COMMAND_CHANGED_PROPERTY, CSS_CLASS_CHANGED_PROPERTY, DISABLED_CSS_CLASS_CHANGED_PROPERTY, HORIZONTAL_ALIGNMENT_CHANGED_PROPERTY, HORIZONTAL_TEXT_POSITION_CHANGED_PROPERTY, ICON_CHANGED_PROPERTY, ICON_TEXT_MARGIN_CHANGED_PROPERTY, MODEL_CHANGED_PROPERTY, NOTABSTOP_CHANGED_PROPERTY, ROLLOVER_BACKGROUND_CHANGED_PROPERTY, ROLLOVER_ENABLED_CHANGED_PROPERTY, ROLLOVER_FONT_CHANGED_PROPERTY, ROLLOVER_FOREGROUND_CHANGED_PROPERTY, ROLLOVER_ICON_CHANGED_PROPERTY, ROLLOVER_SELECTED_ICON_CHANGED_PROPERTY, SELECTED_CHANGED_PROPERTY, SELECTED_ICON_CHANGED_PROPERTY, STYLE_HORIZONTAL_ALIGNMENT, STYLE_HORIZONTAL_TEXT_POSITION, STYLE_ICON_TEXT_MARGIN, STYLE_ROLLOVER_BACKGROUND, STYLE_ROLLOVER_ENABLED, STYLE_ROLLOVER_FONT, STYLE_ROLLOVER_FOREGROUND, STYLE_VERTICAL_ALIGNMENT, STYLE_VERTICAL_TEXT_POSITION, TEXT_CHANGED_PROPERTY, VERTICAL_ALIGNMENT_CHANGED_PROPERTY, VERTICAL_TEXT_POSITION_CHANGED_PROPERTY
 
Fields inherited from interface nextapp.echo.ToolTipSupport
TOOL_TIP_TEXT_CHANGED_PROPERTY
 
Fields inherited from interface nextapp.echo.Component
BACKGROUND_CHANGED_PROPERTY, CHILDREN_CHANGED_PROPERTY, ENABLED_CHANGED_PROPERTY, FONT_CHANGED_PROPERTY, FOREGROUND_CHANGED_PROPERTY, IDENTIFIER_CHANGED_PROPERTY, LOCALE_CHANGED_PROPERTY, SELECTABLE_CHANGED_PROPERTY, STYLE_BACKGROUND, STYLE_FONT, STYLE_FOREGROUND, UPDATE_PROPERTY, VISIBLE_CHANGED_PROPERTY
 
Constructor Summary
SortableTableHeaderRenderer(SortableTableModel sortableTableModel)
          Constructs a SortableTableHeaderRenderer
 
Method Summary
 void actionPerformed(ActionEvent e)
          Invoked when an action occurs.
 void applyStyle(Style style)
          Applies the provided style to the component.
 ImageReference getDownIcon()
          Returns the Icon used for the decending sort order
 SortableTableModel getSortableTableModel()
          Returns the SortableTableModel in use.
 Component getTableCellRendererComponent(Table table, java.lang.Object value, int column, int row)
          Returns a component that will be rendered at the given coordinate.
 ImageReference getUpIcon()
          Returns the Icon used for the ascending sort order
 boolean isColumnSorted(int columnIndex)
          Returns true if the specified column is sortable.
 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 setColumnSorted(int columnIndex, boolean isSorted)
          Controls whether a Column in the TableModel is sortable.
 void setDownIcon(ImageReference newDownIcon)
          Sets the Icon used for the decending sort order
 void setSortableTableModel(SortableTableModel newModel)
          Sets the SortableTableModel to use.
 void setUpIcon(ImageReference newUpIcon)
          Sets the Icon used for the ascending sort order
 
Methods inherited from class nextapp.echo.AbstractButton
addActionListener, addChangeListener, addItemListener, doAction, fireActionPerformed, fireItemStateChanged, fireStateChanged, getActionCommand, getCssClass, getCssClassDisabled, getHorizontalAlignment, getHorizontalTextPosition, getIcon, getIconTextMargin, getModel, getRolloverBackground, getRolloverFont, getRolloverForeground, getRolloverIcon, getRolloverSelectedIcon, getSelectedIcon, getText, getToolTipText, getVerticalAlignment, getVerticalTextPosition, hasActionListeners, isAsync, isNoTabStop, isRolloverEnabled, isSelected, removeActionListener, removeChangeListener, removeItemListener, setActionCommand, setAsync, setCssClass, setCssClassDisabled, setHorizontalAlignment, setHorizontalTextPosition, setIcon, setIconTextMargin, setModel, setNoTabStop, setRolloverBackground, setRolloverEnabled, setRolloverFont, setRolloverForeground, setRolloverIcon, setRolloverSelectedIcon, setSelected, setSelectedIcon, setText, setToolTipText, setVerticalAlignment, setVerticalTextPosition
 
Methods inherited from class nextapp.echo.AbstractComponent
add, add, addHierarchyListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getClientId, getComponent, getComponentCount, getComponents, getEchoInstance, getFont, getForeground, getIdentifier, getListenerList, getLocale, getParent, indexOf, init, isAncestorOf, isDifferent, isEnabled, isFocused, isRecursivelyVisible, isRegistered, isSelectableForScriptRecorder, isShowing, isVisible, processHierarchyEvent, remove, remove, removeAll, removeHierarchyListener, removePropertyChangeListener, setBackground, setClientId, setEnabled, setFocused, setFont, setForeground, setIdentifier, setLocale, setParent, setRegistered, setSelectableForScriptRecorder, setVisible, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

defaultUpIcon

public static final ImageReference defaultUpIcon

defaultDownIcon

public static final ImageReference defaultDownIcon

transparentIcon

public static final ImageReference transparentIcon

STYLE_UP_ICON

public static final java.lang.String STYLE_UP_ICON
Up Icon Property

See Also:
Constant Field Values

UP_ICON_CHANGED_PROPERTY

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

STYLE_DOWN_ICON

public static final java.lang.String STYLE_DOWN_ICON
Down Icon Property

See Also:
Constant Field Values

DOWN_ICON_CHANGED_PROPERTY

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

DEFAULT_HEADER_BACKGROUND

public static final Color DEFAULT_HEADER_BACKGROUND
Default Header Background Color


sortableTableModel

protected SortableTableModel sortableTableModel

sortColumnBitSet

protected java.util.BitSet sortColumnBitSet
Constructor Detail

SortableTableHeaderRenderer

public SortableTableHeaderRenderer(SortableTableModel sortableTableModel)
Constructs a SortableTableHeaderRenderer

Method Detail

actionPerformed

public void actionPerformed(ActionEvent e)
Invoked when an action occurs.

Specified by:
actionPerformed in interface ActionListener
Parameters:
e - The event describing the action.

applyStyle

public void applyStyle(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 Component
Overrides:
applyStyle in class AbstractButton
Parameters:
style - The style object from which to retrieve properties for this Component.
See Also:
Component.applyStyle(Style)

getDownIcon

public ImageReference getDownIcon()
Returns the Icon used for the decending sort order

Returns:
nextapp.echo.ImageReference

getTableCellRendererComponent

public Component getTableCellRendererComponent(Table table,
                                               java.lang.Object value,
                                               int column,
                                               int row)
Returns a component that will be rendered at the given coordinate. This is a button that is built using the current parameters of the cell renderer, which is itself a button.

Specified by:
getTableCellRendererComponent in interface TableCellRenderer
Parameters:
table - The table for which the component is to be generated.
value - The value for which to generate a component.
column - The column coordinate of the value in the table.
row - The row coordinate of the value in the table.
Returns:
A component representation of the value. This component must be unique. Returning a single instance of a component across multiple calls to this method will result in undefined behavior.

getUpIcon

public ImageReference getUpIcon()
Returns the Icon used for the ascending sort order

Returns:
nextapp.echo.ImageReference

setDownIcon

public void setDownIcon(ImageReference newDownIcon)
Sets the Icon used for the decending sort order

Parameters:
newDownIcon - nextapp.echo.ImageReference

setUpIcon

public void setUpIcon(ImageReference newUpIcon)
Sets the Icon used for the ascending sort order

Parameters:
newUpIcon - nextapp.echo.ImageReference

isColumnSorted

public boolean isColumnSorted(int columnIndex)
Returns true if the specified column is sortable.

Parameters:
columnIndex -
Returns:
true if the specified column is sortable.

setColumnSorted

public void setColumnSorted(int columnIndex,
                            boolean isSorted)
Controls whether a Column in the TableModel is sortable. Initially all columns are sortable. This can be changed by this method.

Parameters:
columnIndex - - the column in question
isSorted - - true if the column is sortable.

getSortableTableModel

public SortableTableModel getSortableTableModel()
Returns the SortableTableModel in use.

Returns:
the SortableTableModel in use.

setSortableTableModel

public void setSortableTableModel(SortableTableModel newModel)
Sets the SortableTableModel to use. NOTE: this resets the sortable state of each column to be true.

Parameters:
newModel - - a new sortable table model

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.IllegalAccessException
java.lang.IllegalArgumentException
java.lang.NullPointerException
java.lang.Exception
See Also:
ReflectionSetter.set(Field, Object)