org.jdesktop.dataset
Class DataRelationTable

java.lang.Object
  extended by org.jdesktop.dataset.DataTable
      extended by org.jdesktop.dataset.DataRelationTable

public class DataRelationTable
extends DataTable

Author:
rbair

Field Summary
 
Fields inherited from class org.jdesktop.dataset.DataTable
classComparators, columnComparators, columns, DEFAULT_NAME_PREFIX, rows, selectors
 
Constructor Summary
DataRelationTable(DataSet ds)
          Creates a new instance of DataRelationTable
DataRelationTable(DataSet ds, java.lang.String name)
           
 
Method Summary
 DataRow appendRow()
          Appends a row to the child table, retrieved by relation.getChildColumn().getTable().
 DataColumn getColumn(java.lang.String colName)
          Overridden so that it will defer to the child Table first.
 java.util.List<DataColumn> getColumns()
           
 DataSelector getParentSelector()
           
 DataTable getParentTable()
           
 DataRelation getRelation()
           
 void refresh()
          Removes all of the rows from this DataRelationTable, and reloads it with the proper rows from the DataRelation using the parentSelector DataSelector.
 void save()
          This method makes no sense for a DataRelationTable.
 void setDataProvider(DataProvider dataProvider)
          This method makes no sense for a DataRelationTable.
 void setParentSelector(DataSelector selector)
          Sets the selector for this DataRelationTable.
 void setParentTable(DataTable parent)
           
 void setRelation(DataRelation relation)
          Set the relation that this DataRelationTable uses
 
Methods inherited from class org.jdesktop.dataset.DataTable
addDataTableListener, addPropertyChangeListener, addPropertyChangeListener, appendRowNoEvent, clear, createColumn, createColumn, createColumns, createSelector, createSelector, deleteRow, deleteRow, discardRow, discardRow, dropColumn, dropSelector, dropSelector, fireDataTableChanged, fireRowChanged, getClassComparator, getColumnComparator, getDataProvider, getDataSet, getName, getRow, getRowCount, getRows, getSelector, getSelectors, getValue, getValue, hasClassComparator, hasColumnComparator, indexOfRow, isAppendRowSupported, isDeleteRowSupported, isIdentityComparisonEnabled, load, loadAndWait, refreshAndWait, removeClassComparator, removeColumnComparator, removeDataTableListener, removePropertyChangeListener, removePropertyChangeListener, saveAndWait, setAppendRowSupported, setClassComparator, setColumnComparator, setDeleteRowSupported, setIdentityComparisonEnabled, setName, setValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DataRelationTable

public DataRelationTable(DataSet ds)
Creates a new instance of DataRelationTable


DataRelationTable

public DataRelationTable(DataSet ds,
                         java.lang.String name)
Method Detail

setRelation

public void setRelation(DataRelation relation)
Set the relation that this DataRelationTable uses

Parameters:
relation - the DataRelation to use

getRelation

public DataRelation getRelation()
Returns:
the relation used to populate this DataRelationTable

setParentSelector

public void setParentSelector(DataSelector selector)
Sets the selector for this DataRelationTable. This selector is used to retrieve the currently selected rows from the parent table so that the proper child rows can be retrieved from the child table using the relation.

Parameters:
selector - The selector on the parent table. The selector must belong to the same table as the relation's parentColumn

getParentSelector

public DataSelector getParentSelector()
Returns:
the DataSelector used to retrieve rows from the DataRelation

setParentTable

public void setParentTable(DataTable parent)

getParentTable

public DataTable getParentTable()

setDataProvider

public void setDataProvider(DataProvider dataProvider)
This method makes no sense for a DataRelationTable. A cleaner refactoring might remove the need to override this method. Nothing bad happens if this method is called, it just doesn't make sense. A Warning is logged if this method is called.

Overrides:
setDataProvider in class DataTable
Parameters:
dataProvider - the DataProvider for this DataTable. This may be null.

save

public void save()
This method makes no sense for a DataRelationTable. A cleaner refactoring might remove the need to override this method. Nothing bad happens if this method is called, it just doesn't make sense. A Warning is logged if this method is called

Overrides:
save in class DataTable

appendRow

public DataRow appendRow()
Appends a row to the child table, retrieved by relation.getChildColumn().getTable(). If the DataTable doesn't exist, null is returned

Overrides:
appendRow in class DataTable
Returns:
The newly added DataRow, or null if no DataRow was added.

refresh

public void refresh()
Removes all of the rows from this DataRelationTable, and reloads it with the proper rows from the DataRelation using the parentSelector DataSelector. When rows are removed from a DataRelationTable, they still exist in the child DataTable, hence it is always safe to call this method without losing any data.
This method attempts to reset all of its selectors to the same rows, where possible. It does this by remembering all of the values for the rows key fields, and looking for them again after the refresh. If the row cannot be found, it is no longer selected
TODO This code for remembering the selected rows and trying to locate them again after refresh is horrible and needs to be rewritten.

Overrides:
refresh in class DataTable

getColumn

public DataColumn getColumn(java.lang.String colName)
Overridden so that it will defer to the child Table first. A DataRelationTable contains all of the columns in the child Table, but may also contain its own set of calculated columns as well. This method must therefore check the child table for a given column before checking its own set of columns.

Overrides:
getColumn in class DataTable
Parameters:
colName - The String name for the column to retrieve.
Returns:
The DataColumn identified by the given name.

getColumns

public java.util.List<DataColumn> getColumns()
Overrides:
getColumns in class DataTable
Returns:
the set of columns that comprise this DataRelationTable. This is the union of the child tables columns, and any native columns to this DataRelationTable


Copyright © 2005 Sun Microsystems All Rights Reserved.