|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.swing.models.TableModelAdapter
public class TableModelAdapter
The TableModelAdapter is an adapter to allow a com.sas.table.StaticTableInterface object to be used in a javax.swing.JTable object. Any object that implements the com.sas.table.StaticTableInterface can be set as the model for this adapter. The adapter extends from AbstractTableModel and can be set as the model for a JTable. The default model delegate used by this adapter is a com.sas.table.SimpleTable object. If the model implements the com.sas.collection.ContentsChangedSource interface, the adapter will add itself as a listener to the model for changes that occur on it. The adapter does not allow editing by default. This is because a remote SAS object connected to a shared dataset will throw exceptions if cells are locked by one user and another user attempts to edit the cells.
Field Summary | |
---|---|
protected java.util.Hashtable |
columnDisplayTransforms
|
protected int |
currentMaxCount
|
protected int |
currentRowCount
|
protected boolean |
defaultModelAttached
|
protected com.sas.util.transforms.TransformInterface |
displayTransform
|
protected boolean |
distinctValues
|
protected boolean |
formattedDataUsed
|
protected int |
lastRowIndex
|
protected int |
maxRowCount
|
protected StaticTableInterface |
model
|
protected com.sas.beans.PropertyChangeSupport |
propertyChangeSupport
|
protected boolean |
sortAllowed
|
protected boolean |
tableEditable
|
Fields inherited from interface com.sas.table.InsertRowInterface |
---|
DEFAULT_INDEX |
Fields inherited from interface com.sas.util.SortDirectionInterface |
---|
ASCENDING, DESCENDING, NOT_SORTED |
Constructor Summary | |
---|---|
TableModelAdapter()
Default constructor. |
|
TableModelAdapter(StaticTableInterface table)
Constructor that sets the model of the adapter. |
Method Summary | |
---|---|
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener to the adapter. |
void |
cancelUncommittedRow()
Removes the "fake" row from the model, effectively performing a cancel. |
void |
commitUncommittedRow()
Commits the data in the row to the underlying model. |
void |
contentsChanged(com.sas.collection.ContentsChangedEvent event)
ContentsChangedListener method to listen for events sent by the model and fire the appropriate table changed events. |
void |
deleteRow(int rowIndex)
Deletes a row. |
protected void |
expandRowCount()
Expand the row count by using the countRows(int) method on the model and passing in either the maxRowCount or the last known rowCount incremented by the maxRowCount amount. |
protected void |
firePropertyChange(java.beans.PropertyChangeEvent evt)
Send a PropertyChangeEvent to any listeners added to the adapter. |
protected void |
firePropertyChange(java.lang.String propName,
java.lang.Object oldValue,
java.lang.Object newValue)
Send a PropertyChangeEvent to any listeners added to the adapter. |
void |
fireTableChanged(javax.swing.event.TableModelEvent evt)
Overridden to reset the rowCount if an INSERT or a DELETE TableModelEvent is sent. |
void |
fireTableStructureChanged()
Overridden to recalculate the rowCount. |
java.lang.Class |
getColumnClass(int columnIndex)
Get the class for the specified columnIndex. |
int |
getColumnCount()
Get the number of columns in the model. |
com.sas.util.transforms.TransformInterface |
getColumnDisplayTransform(java.lang.String columnName)
Return the current transform on the given column, which can be null |
java.lang.Object |
getColumnInfo(int index,
java.lang.String columnInfoName)
Returns the named information for a column. |
java.lang.String[] |
getColumnInfoNames()
Returns an array of the named information that can be returned for the columns. |
java.lang.String |
getColumnInfoUsed()
Returns the column information that is currently being returned as the column label. |
java.lang.String |
getColumnName(int columnIndex)
Get the column name for the specified column index. |
java.util.Enumeration |
getColumnNamesWithDisplayTransform()
Returns an enumeration of all the column names that have a display transform applied to them. |
com.sas.util.transforms.TransformInterface |
getDisplayTransform()
Return current transform, which can be null |
static com.sas.beans.ExtendedBeanInfo |
getExtendedBeanInfo()
Returns information used by the com.sas.beans.Introspector to
augment the automatically introspected information about this BaseBorder. |
java.lang.String |
getFormat(int columnIndex)
Returns the format that is being used for the given column in the model. |
java.lang.String |
getFormattedValueAt(int rowIndex,
int columnIndex)
Returns the formatted data for the given cell coordinates. |
int |
getMaxRowCount()
Get the max row count used when the row count is unknown by the model. |
StaticTableInterface |
getModel()
Get the model used by the adapter. |
int |
getRowCount()
Get the known rowCount. |
java.lang.Object |
getRowLabel(int row)
|
java.lang.Object[] |
getRowLabels(int startIndex,
int count)
|
java.lang.String[] |
getSortedColumns()
Returns an array of strings that are the column names that have been sorted. |
int[] |
getSortedDirections()
Returns an array of ints that indicate which direction each column in the sortedColumns array has been sorted. |
int |
getUncommittedRowNumber()
Returns the index of the "fake" row. |
java.lang.Class |
getUnformattedColumnClass(int columnIndex)
Get the class of the unformatted data for the specified columnIndex. |
java.lang.Object |
getUnformattedValueAt(int rowIndex,
int columnIndex)
Returns the unformatted data for the given cell coordinates |
java.lang.Object |
getValueAt(int rowIndex,
int columnIndex)
Get the value at the specified row and column index. |
protected void |
initTable()
Initialize the tables internal fields. |
void |
insertUncommittedRow(int rowIndex)
Adds a "fake" row to the table model at the specified location. |
boolean |
isAccurateRowCountAvailable()
Indicates whether an accurate row count is available. |
boolean |
isCellEditable(int rowIndex,
int columnIndex)
Determine if the cell at the specified row and column is editable. |
boolean |
isColumnSortable(java.lang.String columnName)
Returns a boolean indicating whether the columnName is allowed to be sorted. |
boolean |
isDefaultModelAttached()
returns true is the component is using a default internal model. |
boolean |
isDistinctValues()
Returns a boolean indicating whether the sorted columns should return only distinct values. |
boolean |
isFormattedDataUsed()
Returns whether the model is using formatted data or just the raw data. |
boolean |
isRowDeletionAllowed()
Indicates whether rows can be deleted. |
boolean |
isRowInsertionAllowed()
Indicates whether rows can be inserted into the existing table. |
boolean |
isRowLabelsSupported()
|
boolean |
isRowsLabelSupported()
|
boolean |
isRowUpdateAllowed()
Indicates whether rows can be updated. |
boolean |
isSortAllowed()
Returns a boolean indicating whether sorting is allowed. |
boolean |
isTableEditable()
Determine if the table is editable. |
boolean |
isTableExtendOnly()
Indicates whether rows can only be inserted at the default location (usually at the end) of the existing table. |
boolean |
isUncommittedRowPresent()
Returns true if the "fake" row exists. |
protected StaticTableInterface |
newDefaultModel()
Create a new default model. |
protected void |
recalculateRowCount()
Recalculates the known rowCount. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener from the adapter. |
protected void |
resetRowCount()
Reset the row count fields to -1. |
void |
setColumnDisplayTransform(java.lang.String columnName,
com.sas.util.transforms.TransformInterface newTransform)
Sets the display transform on the given column. |
void |
setColumnInfoUsed(java.lang.String columnInfoUsed)
Sets the column information that is currently being returned as the column label. |
protected void |
setDefaultModelAttached(boolean defaultModelUsed)
|
void |
setDisplayTransform(com.sas.util.transforms.TransformInterface newTransform)
Set transform to given transform, which can be null |
void |
setDistinctValues(boolean distinct)
Sets whether the sorted columns should return only distinct values. |
void |
setFormattedDataUsed(boolean useFormattedData)
Sets whether the model is using formatted data or just the raw data. |
void |
setMaxRowCount(int rc)
The max row count to be used when the row count is unknown by the model. |
void |
setModel(StaticTableInterface table)
Set the model used by the adapter to delegate all table calls. |
void |
setSortAllowed(boolean allowSorting)
Sets whether sorting is enabled or not, by default it is. |
void |
setTableEditable(boolean editable)
Set the table to editable. |
void |
setValueAt(java.lang.Object aValue,
int rowIndex,
int columnIndex)
Set the value of the model at the specified row and column indices. |
void |
sort(java.lang.String[] columnNames,
int[] direction)
Each columnName must have a matching direction. |
protected void |
updateRowCount(int firstRow,
int lastRow)
Calls the super.fireTableChanged(TableModelEvent) method to notify the table that the row count has been updated. |
Field Detail |
---|
protected boolean defaultModelAttached
protected com.sas.beans.PropertyChangeSupport propertyChangeSupport
protected StaticTableInterface model
protected int maxRowCount
protected int currentMaxCount
protected int lastRowIndex
protected boolean tableEditable
protected com.sas.util.transforms.TransformInterface displayTransform
protected java.util.Hashtable columnDisplayTransforms
protected int currentRowCount
protected boolean formattedDataUsed
protected boolean sortAllowed
protected boolean distinctValues
Constructor Detail |
---|
public TableModelAdapter()
public TableModelAdapter(StaticTableInterface table)
table
- the model used as a delegate for the adapterMethod Detail |
---|
public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
com.sas.beans.Introspector
to
augment the automatically introspected information about this BaseBorder.
protected void initTable()
protected StaticTableInterface newDefaultModel()
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener
in interface com.sas.beans.PropertyChangeSource
listener
- the PropertyChangeListener to be notified when a PropertyChangeEvent occurspublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener
in interface com.sas.beans.PropertyChangeSource
listener
- the PropertyChangeListener to stop being notified when a PropertyChangeEvent occursprotected void firePropertyChange(java.beans.PropertyChangeEvent evt)
protected void firePropertyChange(java.lang.String propName, java.lang.Object oldValue, java.lang.Object newValue)
public StaticTableInterface getModel()
public boolean isDefaultModelAttached()
ViewDefaultModel
isDefaultModelAttached
in interface ViewDefaultModel
protected void setDefaultModelAttached(boolean defaultModelUsed)
public void setModel(StaticTableInterface table)
public com.sas.util.transforms.TransformInterface getDisplayTransform()
getDisplayTransform
in interface com.sas.util.transforms.DisplayTransformInterface
public void setDisplayTransform(com.sas.util.transforms.TransformInterface newTransform)
setDisplayTransform
in interface com.sas.util.transforms.DisplayTransformInterface
newTransform
- transform to be setpublic com.sas.util.transforms.TransformInterface getColumnDisplayTransform(java.lang.String columnName)
public void setColumnDisplayTransform(java.lang.String columnName, com.sas.util.transforms.TransformInterface newTransform)
columnName
- the name of the column to set the transform onnewTransform
- transform to be set on the column, null to remove the transformpublic java.util.Enumeration getColumnNamesWithDisplayTransform()
public void contentsChanged(com.sas.collection.ContentsChangedEvent event)
contentsChanged
in interface com.sas.collection.ContentsChangedListener
public java.lang.Class getColumnClass(int columnIndex)
getColumnClass
in interface javax.swing.table.TableModel
getColumnClass
in class javax.swing.table.AbstractTableModel
columnIndex
- the index of the column to return the type of
public java.lang.Class getUnformattedColumnClass(int columnIndex)
getUnformattedColumnClass
in interface com.sas.table.FormattedInterface
columnIndex
- the index of the column to return the unformatted type of
public int getColumnCount()
getColumnCount
in interface javax.swing.table.TableModel
public java.lang.String getColumnName(int columnIndex)
getColumnName
in interface javax.swing.table.TableModel
getColumnName
in class javax.swing.table.AbstractTableModel
columnIndex
- the index of the column to find the name for
public void setMaxRowCount(int rc)
public int getMaxRowCount()
setMaxRowCount(int)
public void fireTableChanged(javax.swing.event.TableModelEvent evt)
fireTableChanged
in class javax.swing.table.AbstractTableModel
public void fireTableStructureChanged()
fireTableStructureChanged
in class javax.swing.table.AbstractTableModel
protected void updateRowCount(int firstRow, int lastRow)
protected void resetRowCount()
protected void expandRowCount()
public int getRowCount()
getRowCount
in interface javax.swing.table.TableModel
protected void recalculateRowCount()
public java.lang.Object getValueAt(int rowIndex, int columnIndex)
getValueAt
in interface javax.swing.table.TableModel
public java.lang.Object getUnformattedValueAt(int rowIndex, int columnIndex)
getUnformattedValueAt
in interface com.sas.table.FormattedInterface
rowIndex
- the row whose value is to be queriedcolumnIndex
- the column whose value is to be queried
public boolean isCellEditable(int rowIndex, int columnIndex)
isCellEditable
in interface javax.swing.table.TableModel
isCellEditable
in class javax.swing.table.AbstractTableModel
public boolean isTableEditable()
public void setTableEditable(boolean editable)
isTableEditable()
public void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
setValueAt
in interface javax.swing.table.TableModel
setValueAt
in class javax.swing.table.AbstractTableModel
public java.lang.Object getRowLabel(int row)
getRowLabel
in interface com.sas.table.StaticRowLabelInterface
public java.lang.Object[] getRowLabels(int startIndex, int count)
getRowLabels
in interface com.sas.table.StaticRowLabelInterface
public boolean isRowLabelsSupported()
isRowLabelsSupported
in interface com.sas.table.StaticRowLabelInterface
public boolean isRowsLabelSupported()
isRowsLabelSupported
in interface com.sas.table.StaticRowLabelInterface
public void insertUncommittedRow(int rowIndex) throws com.sas.util.UncheckedException
InsertRowInterface
insertUncommittedRow
in interface InsertRowInterface
rowIndex
- The row to add the "fake" row before.
com.sas.util.UncheckedException
- Provides a catch-all for all Exceptions.public void commitUncommittedRow() throws com.sas.util.UncheckedException
InsertRowInterface
commitUncommittedRow
in interface InsertRowInterface
com.sas.util.UncheckedException
- Provides a catch-all for all Exceptions.public void cancelUncommittedRow() throws com.sas.util.UncheckedException
InsertRowInterface
cancelUncommittedRow
in interface InsertRowInterface
com.sas.util.UncheckedException
- Provides a catch-all for all Exceptions.public boolean isUncommittedRowPresent()
InsertRowInterface
isUncommittedRowPresent
in interface InsertRowInterface
public int getUncommittedRowNumber()
InsertRowInterface
getUncommittedRowNumber
in interface InsertRowInterface
public boolean isRowInsertionAllowed()
InsertRowInterface
isRowInsertionAllowed
in interface InsertRowInterface
public boolean isTableExtendOnly()
InsertRowInterface
isTableExtendOnly
in interface InsertRowInterface
public boolean isRowUpdateAllowed()
UpdateRowInterface
isRowUpdateAllowed
in interface UpdateRowInterface
public void deleteRow(int rowIndex)
DeleteRowInterface
Some implementations may not allow rows to be deleted. This can be determined through isRowDeletionAllowed().
deleteRow
in interface DeleteRowInterface
rowIndex
- A zero-based index that identifies the row.public boolean isRowDeletionAllowed()
DeleteRowInterface
isRowDeletionAllowed
in interface DeleteRowInterface
public boolean isAccurateRowCountAvailable()
AccurateRowCountInterface
isAccurateRowCountAvailable
in interface AccurateRowCountInterface
public void sort(java.lang.String[] columnNames, int[] direction)
sort
in interface com.sas.table.SortableInterface
columnNames
- The names of the columns in the order that the columns will be sorted.direction
- The direction in which to sort the columns. Valid values are
SortControllerInterface.ASCENDING and SortControllerInterface.DESCENDING.
// * @param removeDuplicates Sets if dupicate rows are to be removed after the data is sorted.
// * @param sortInPlace Sets if the data is to be sorted in place or in a temporary location.
// * @param outputLocation The name of the location to store the sorted data.
outputLocation is ignored if sortInPlace is true.public boolean isColumnSortable(java.lang.String columnName)
isColumnSortable
in interface com.sas.table.SortableInterface
columnName
- The name of the column to query about whether it is allowed to be
sorted.
public boolean isSortAllowed()
isSortAllowed
in interface com.sas.table.SortableInterface
public void setSortAllowed(boolean allowSorting)
setSortAllowed
in interface com.sas.table.SortableInterface
allowSorting
- true to enable sorting, false otherwise.isSortAllowed()
public java.lang.String[] getSortedColumns()
getSortedColumns
in interface com.sas.table.SortableInterface
public int[] getSortedDirections()
getSortedDirections
in interface com.sas.table.SortableInterface
public boolean isDistinctValues()
isDistinctValues
in interface com.sas.table.SortDistinctValuesInterface
public void setDistinctValues(boolean distinct)
setDistinctValues
in interface com.sas.table.SortDistinctValuesInterface
distinct
- true if only distinct values should be return for the
sorted columnspublic java.lang.String getColumnInfoUsed()
RemoteDataSetInterface
,
setColumnInfoUsed(java.lang.String)
public void setColumnInfoUsed(java.lang.String columnInfoUsed) throws com.sas.util.UncheckedException
columnInfoUsed
- A String indicating the type of information to use as the column label.
Case does not matter. The valid values are :
RemoteDataSetInterface.NAME, RemoteDataSetInterface.LENGTH,
RemoteDataSetInterface.TYPE, RemoteDataSetInterface.LABEL,
RemoteDataSetInterface.FORMAT, and RemoteDataSetInterface.INFORMAT.
com.sas.table.TableException
- if the column information cannot be retrieved.
com.sas.util.UncheckedException
RemoteDataSetInterface
,
getColumnInfoUsed()
public java.lang.String getFormat(int columnIndex) throws com.sas.util.UncheckedException
getFormat
in interface com.sas.table.FormattedInterface
columnIndex
- the column index in the model that the format is to be returned for
com.sas.util.UncheckedException
public java.lang.String getFormattedValueAt(int rowIndex, int columnIndex)
getFormattedValueAt
in interface com.sas.table.FormattedInterface
rowIndex
- the row whose value is to be queriedcolumnIndex
- the column whose value is to be queried
public void setFormattedDataUsed(boolean useFormattedData)
setFormattedDataUsed
in interface com.sas.table.FormattedInterface
useFormattedData
- whether to use formatted data by default versus raw dataisFormattedDataUsed()
public boolean isFormattedDataUsed()
isFormattedDataUsed
in interface com.sas.table.FormattedInterface
setFormattedDataUsed(boolean)
public java.lang.Object getColumnInfo(int index, java.lang.String columnInfoName) throws com.sas.util.UncheckedException
getColumnInfo
in interface com.sas.table.StaticColumnInfoInterface
index
- the index the identifies the column, needs to be one-basedcolumnInfoName
- the name of the information a user wants to query for, the valid values are
whatever values are returned from a call to getColumnInfoNames().
com.sas.util.UncheckedException
- thrown if a call to the model yields an exceptiongetColumnInfoNames()
,
StaticColumnInfoInterface
public java.lang.String[] getColumnInfoNames() throws com.sas.util.UncheckedException
getColumnInfoNames
in interface com.sas.table.StaticColumnInfoInterface
com.sas.util.UncheckedException
- thrown if a call to the model yields an exception
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |