net.wotonomy.ui.swing
Class TableColumnAssociation

java.lang.Object
  extended by net.wotonomy.control.EODelayedObserver
      extended by net.wotonomy.ui.EOAssociation
          extended by net.wotonomy.ui.swing.TableColumnAssociation
All Implemented Interfaces:
java.util.Observer, net.wotonomy.control.EOObserving
Direct Known Subclasses:
TreeColumnAssociation

public class TableColumnAssociation
extends net.wotonomy.ui.EOAssociation

TableColumnAssociation binds a column of a JTable to a property of the elements of a display group. Bindings are:

Because TableColumns do not have a handle to their containing JTable, setTable() must be called before calling establishConnection(). This will add the controlled TableColumn to the specified JTable. Columns appear in the table in the order in which setTable is called on the corresponding association. The original table model index is ignored. Column names appear in the table based on the value of TableColumn.getHeaderValue().

Version:
$Revision: 904 $
Author:
michael@mpowers.net, $Author: cgruber $

Field Summary
 
Fields inherited from class net.wotonomy.ui.EOAssociation
ActionAspect, ArgumentAspect, aspectToGroup, aspectToKey, AttributeAspectSignature, AttributeToManyAspectSignature, AttributeToOneAspectSignature, AttributeToOneToManyAspectSignature, BoldAspect, ChildrenAspect, control, DestinationAspect, EditableAspect, EnabledAspect, IconAspect, IsLeafAspect, ItalicAspect, LabelAspect, NullAspectSignature, ObjectsAspect, ParentAspect, SelectedObjectAspect, SelectedTitleAspect, SourceAspect, TitlesAspect, ToManyAspectSignature, ToOneAspectSignature, ToOneToManyAspectSignature, URLAspect, ValueAspect, VisibleAspect
 
Fields inherited from class net.wotonomy.control.EODelayedObserver
ObserverNumberOfPriorities, ObserverPriorityFifth, ObserverPriorityFirst, ObserverPriorityFourth, ObserverPriorityImmediate, ObserverPriorityLater, ObserverPrioritySecond, ObserverPrioritySixth, ObserverPriorityThird
 
Constructor Summary
TableColumnAssociation(java.lang.Object anObject)
          Constructor specifying the object to be controlled by this association.
 
Method Summary
protected  void addAsListener()
           
static net.wotonomy.foundation.NSArray aspects()
          Returns a List that describes the aspects supported by this class.
static net.wotonomy.foundation.NSArray aspectSignatures()
          Returns a List of aspect signatures whose contents correspond with the aspects list.
static net.wotonomy.foundation.NSArray associationClassesSuperseded()
          Returns a List of EOAssociation subclasses that, for the objects that are usable for this association, are less suitable than this association.
 void bindAspect(java.lang.String anAspect, net.wotonomy.ui.EODisplayGroup aDisplayGroup, java.lang.String aKey)
          Binds the specified aspect of this association to the specified key on the specified display group.
 void breakConnection()
          Breaks the connection between this association and its object.
 boolean canBindAspect(java.lang.String anAspect, net.wotonomy.ui.EODisplayGroup aDisplayGroup, java.lang.String aKey)
          Returns whether this association can bind to the specified display group on the specified key for the specified aspect.
protected  void drawSortIndicator(java.awt.Rectangle aBoundingRectangle, java.awt.Graphics aGraphicsContext, java.util.List orderings)
          Called by TableAssociation to draw some indicator in the specified rectangle using the specified graphics to indicate the specified sort state.
 void establishConnection()
          Establishes a connection between this association and the controlled object.
protected  int getIndexOfMatchingOrdering(java.util.List orderings)
          Returns the one-based index of this assocation's sort ordering in the specified list of orderings.
protected static java.awt.Color getSortIndicatorColor(int index)
          Returns a color to be used by the sort indicator based on the index of the sorting column.
 net.wotonomy.control.EOSortOrdering getSortOrdering(boolean isAscending)
          Called by TableAssociation to get a EOSortOrdering suitable for the information in this column.
 TableAssociation getTableAssociation()
          Returns the table association for this table column, or null if no table has been set.
 boolean isEditableAtRow(int aRowIndex)
          Called by the TableAssociation to determine whether the value at the specified row is editable.
 boolean isSortable()
          Returns whether this column should be sorted when the user clicks on the column header.
 boolean isSortCaseSensitive()
          Returns whether this column should be sorted in a case sensitive manner.
static boolean isUsableWithObject(java.lang.Object anObject)
          Returns whether this class can control the specified object.
static net.wotonomy.foundation.NSArray objectKeysTaken()
          Returns a List of properties of the controlled object that are controlled by this class.
static java.lang.String primaryAspect()
          Returns the aspect that is considered primary or default.
protected  void removeAsListener()
           
 void setSortable(boolean isSortable)
          Sets whether this column should be sorted when the user clicks on the column header.
 void setSortCaseSensitive(boolean isCaseSensitive)
          Sets whether this column should be sorted when in a case sensitive manner.
 void setTable(javax.swing.JTable aTable)
          Sets the table to be used for this column association.
 void setValueAtIndex(java.lang.Object aValue, int aRowIndex)
          Sets a value for the specified index.
 java.lang.Object valueAtIndex(int aRowIndex)
          Returns the value to be displayed at the specified index.
 
Methods inherited from class net.wotonomy.ui.EOAssociation
associationClassesForObject, copyMatchingBindingsFromAssociation, displayGroupForAspect, displayGroupKeyForAspect, displayName, endEditing, object, setValueForAspect, setValueForAspectAtIndex, shouldEndEditing, shouldEndEditingAtIndex, subjectChanged, valueForAspect, valueForAspectAtIndex
 
Methods inherited from class net.wotonomy.control.EODelayedObserver
discardPendingNotification, objectWillChange, observerQueue, priority, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TableColumnAssociation

public TableColumnAssociation(java.lang.Object anObject)
Constructor specifying the object to be controlled by this association. Throws an exception if the object is not a TableColumn. setTable() must be called before establishing the connection.

Method Detail

setTable

public void setTable(javax.swing.JTable aTable)
Sets the table to be used for this column association. If no TableAssociation exists for the specified table, one will be created automatically. The controlled table column will be added to the table. Note that the table column's model index is ignored: table columns appear in the table in the order in which setTable is called on their corresponding associations.


getTableAssociation

public TableAssociation getTableAssociation()
Returns the table association for this table column, or null if no table has been set. This method will create the association if none exists for the table.


aspectSignatures

public static net.wotonomy.foundation.NSArray aspectSignatures()
Returns a List of aspect signatures whose contents correspond with the aspects list. Each element is a string whose characters represent a capability of the corresponding aspect. An empty signature "" means that the aspect can bind without needing a key. This implementation returns "A1M" for each element in the aspects array.


aspects

public static net.wotonomy.foundation.NSArray aspects()
Returns a List that describes the aspects supported by this class. Each element in the list is the string name of the aspect. This implementation returns an empty list.


associationClassesSuperseded

public static net.wotonomy.foundation.NSArray associationClassesSuperseded()
Returns a List of EOAssociation subclasses that, for the objects that are usable for this association, are less suitable than this association.


isUsableWithObject

public static boolean isUsableWithObject(java.lang.Object anObject)
Returns whether this class can control the specified object.


objectKeysTaken

public static net.wotonomy.foundation.NSArray objectKeysTaken()
Returns a List of properties of the controlled object that are controlled by this class. For example, "stringValue", or "selected".


primaryAspect

public static java.lang.String primaryAspect()
Returns the aspect that is considered primary or default. This is typically "value" or somesuch.


canBindAspect

public boolean canBindAspect(java.lang.String anAspect,
                             net.wotonomy.ui.EODisplayGroup aDisplayGroup,
                             java.lang.String aKey)
Returns whether this association can bind to the specified display group on the specified key for the specified aspect.

Overrides:
canBindAspect in class net.wotonomy.ui.EOAssociation

bindAspect

public void bindAspect(java.lang.String anAspect,
                       net.wotonomy.ui.EODisplayGroup aDisplayGroup,
                       java.lang.String aKey)
Binds the specified aspect of this association to the specified key on the specified display group.

Overrides:
bindAspect in class net.wotonomy.ui.EOAssociation

establishConnection

public void establishConnection()
Establishes a connection between this association and the controlled object. Subclasses should begin listening for events from their controlled object here.

Overrides:
establishConnection in class net.wotonomy.ui.EOAssociation

breakConnection

public void breakConnection()
Breaks the connection between this association and its object. Override to stop listening for events from the object.

Overrides:
breakConnection in class net.wotonomy.ui.EOAssociation

addAsListener

protected void addAsListener()

removeAsListener

protected void removeAsListener()

valueAtIndex

public java.lang.Object valueAtIndex(int aRowIndex)
Returns the value to be displayed at the specified index. This method is called by the TableAssocation to populate the table model. This implementation simply retrieves the value from the display group bound to the value aspect.


setValueAtIndex

public void setValueAtIndex(java.lang.Object aValue,
                            int aRowIndex)
Sets a value for the specified index. This method is called by the TableAssocation after a cell has been edited. This implementation simply sets the value in the display group bound to the value aspect.


isSortable

public boolean isSortable()
Returns whether this column should be sorted when the user clicks on the column header. Defaults to true.


setSortable

public void setSortable(boolean isSortable)
Sets whether this column should be sorted when the user clicks on the column header.


isSortCaseSensitive

public boolean isSortCaseSensitive()
Returns whether this column should be sorted in a case sensitive manner. Defaults to true.


setSortCaseSensitive

public void setSortCaseSensitive(boolean isCaseSensitive)
Sets whether this column should be sorted when in a case sensitive manner. If false, the column contents should be string values.


isEditableAtRow

public boolean isEditableAtRow(int aRowIndex)
Called by the TableAssociation to determine whether the value at the specified row is editable. This is determined by the binding of the Editable aspect, looking at the value of the corresponding index in that display group. Note: because the display group may not have the same number if items, the selected index is used if the editable display group is not the same as the the value display group.


getSortOrdering

public net.wotonomy.control.EOSortOrdering getSortOrdering(boolean isAscending)
Called by TableAssociation to get a EOSortOrdering suitable for the information in this column. This implementation returns a EOSortOrdering with the key equal to the value aspect's key and the appropriate selector for the specified ascending value and the case sensitivity of this column. Override to customize the sort for your column.


getIndexOfMatchingOrdering

protected int getIndexOfMatchingOrdering(java.util.List orderings)
Returns the one-based index of this assocation's sort ordering in the specified list of orderings. If the sign of the returned value is negative, the ordering is descending. If the return value is zero, no matching ordering was found.


drawSortIndicator

protected void drawSortIndicator(java.awt.Rectangle aBoundingRectangle,
                                 java.awt.Graphics aGraphicsContext,
                                 java.util.List orderings)
Called by TableAssociation to draw some indicator in the specified rectangle using the specified graphics to indicate the specified sort state. The rectangle corresponds to the bounds of the column header. This implementation draws a small transparent gray triangle at the right edge of the bounding rectangle. Override to do something different or to do nothing at all.


getSortIndicatorColor

protected static java.awt.Color getSortIndicatorColor(int index)
Returns a color to be used by the sort indicator based on the index of the sorting column. The goal of this method is to make the color appear lighter and lighter, the "less" primary the sort order for this column is. This can be acheives simply though a "transparent" color, however, during printing of the corresponding table, java print kicks into "raster" based printing when printing a component with a transparent color instead of "vector" based printing. Raster based printing can take up to 20-30 times longer to print than vector printing and consume several times the amount of memory. Raster-based printing should be avoided at all costs if the a component is to be printed (as of Java 1.3.1).

Parameters:
index - The "sort" index of the associated table column. The higher the index, the lighter the color will be. An index of 0 will return null.
Returns:
The color to use when rendering the sort indicator.


Copyright © 2006 null. All Rights Reserved.