***  This class is subject to change.  ***

com.sas.swing.models
Class OLAPTableModelAdapter

com.sas.swing.models.OLAPTableModelAdapter
All Implemented Interfaces:
com.sas.beans.PropertyChangeSource, com.sas.collection.ContentsChangedListener, com.sas.swing.models.OLAPDataSetInterfaceProvider, ViewDefaultModel, com.sas.table.StaticRowLabelInterface, java.beans.PropertyChangeListener, java.io.Serializable, java.util.EventListener, javax.swing.table.TableModel

public class OLAPTableModelAdapter
implements com.sas.swing.models.OLAPDataSetInterfaceProvider, com.sas.beans.PropertyChangeSource, ViewDefaultModel, com.sas.table.StaticRowLabelInterface, com.sas.collection.ContentsChangedListener, java.beans.PropertyChangeListener

The TableModelAdapter is an adapter to allow a com.sas.table.ResultSetInterface object to be used in a javax.swing.JTable object. Any object that implements the com.sas.table.ResultSetInterface 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.

See Also:
Serialized Form

Field Summary
protected  int currentRowCount
           
protected  boolean defaultModelAttached
           
protected  OLAPDataSetInterface model
           
protected  com.sas.beans.PropertyChangeSupport propertyChangeSupport
           
 
Constructor Summary
OLAPTableModelAdapter()
          Default constructor.
OLAPTableModelAdapter(OLAPDataSetInterface table)
          Constructor that sets the model of the adapter.
 
Method Summary
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Add a PropertyChangeListener to the adapter.
 void contentsChanged(com.sas.collection.ContentsChangedEvent event)
          ContentsChangedListener method to listen for events sent by the model and to refresh the row and column axis.
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 fireTableStructureChanged()
          Overridden to recalculate the rowCount.
 AxisInterface getColumnAxis()
           
 int getColumnCount()
          Get the number of columns in the model.
 java.lang.String getColumnName(int columnIndex)
          Get the column name for the specified column index.
static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
          Returns information used by the com.sas.beans.Introspector to augment the automatically introspected information about this OLAPTableModelAdapter.
 OLAPDataSetInterface getModel()
          Get the model used by the adapter.
 OLAPDataSetInterface getOLAPDataSetInterface()
          Get the model used by the adapter.
 AxisInterface getRowAxis()
           
 int getRowCount()
          Get the known rowCount.
 java.lang.Object getRowLabel(int row)
           
 java.lang.Object[] getRowLabels(int startIndex, int count)
           
 AxisInterface getSlicerAxis()
           
 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.
 boolean isCellEditable(int rowIndex, int columnIndex)
          Determine if the cell at the specified row and column is editable.
 boolean isDefaultModelAttached()
          returns true is the component is using a default internal model.
 boolean isRowLabelsSupported()
           
 boolean isRowsLabelSupported()
           
protected  OLAPDataSetInterface newDefaultModel()
          Create a new default model.
 void propertyChange(java.beans.PropertyChangeEvent event)
           
protected  void recalculateRowCount()
          Recalculates the known rowCount.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Remove a PropertyChangeListener from the adapter.
protected  void setDefaultModelAttached(boolean defaultModelUsed)
           
 void setModel(OLAPDataSetInterface table)
          Set the model used by the adapter to delegate all table calls.
 void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
          Set the value of the model at the specified row and column indices.
 

Field Detail

defaultModelAttached

protected boolean defaultModelAttached

propertyChangeSupport

protected com.sas.beans.PropertyChangeSupport propertyChangeSupport

model

protected OLAPDataSetInterface model

currentRowCount

protected int currentRowCount
Constructor Detail

OLAPTableModelAdapter

public OLAPTableModelAdapter()
Default constructor. The adapter is initialized using initTable(). Sets the model to that returned by the newDefaultModel() method.


OLAPTableModelAdapter

public OLAPTableModelAdapter(OLAPDataSetInterface table)
Constructor that sets the model of the adapter. The adapter is initialized using initTable().

Parameters:
table - the model used as a delegate for the adapter
Method Detail

getExtendedBeanInfo

public static com.sas.beans.ExtendedBeanInfo getExtendedBeanInfo()
Returns information used by the com.sas.beans.Introspector to augment the automatically introspected information about this OLAPTableModelAdapter.

Returns:
the ExtendedBeanInfo for this class

initTable

protected void initTable()
Initialize the tables internal fields.


newDefaultModel

protected OLAPDataSetInterface newDefaultModel()
Create a new default model.


addPropertyChangeListener

public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a PropertyChangeListener to the adapter.

Specified by:
addPropertyChangeListener in interface com.sas.beans.PropertyChangeSource
Parameters:
listener - the PropertyChangeListener to be notified when a PropertyChangeEvent occurs

removePropertyChangeListener

public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener from the adapter.

Specified by:
removePropertyChangeListener in interface com.sas.beans.PropertyChangeSource
Parameters:
listener - the PropertyChangeListener to stop being notified when a PropertyChangeEvent occurs

firePropertyChange

protected void firePropertyChange(java.beans.PropertyChangeEvent evt)
Send a PropertyChangeEvent to any listeners added to the adapter.


firePropertyChange

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.


propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Specified by:
propertyChange in interface java.beans.PropertyChangeListener

getOLAPDataSetInterface

public OLAPDataSetInterface getOLAPDataSetInterface()
Get the model used by the adapter.

Specified by:
getOLAPDataSetInterface in interface com.sas.swing.models.OLAPDataSetInterfaceProvider
Returns:
an instance of an OLAPDataSetInterface

getModel

public OLAPDataSetInterface getModel()
Get the model used by the adapter.


isDefaultModelAttached

public boolean isDefaultModelAttached()
Description copied from interface: ViewDefaultModel
returns true is the component is using a default internal model.

Specified by:
isDefaultModelAttached in interface ViewDefaultModel

setDefaultModelAttached

protected void setDefaultModelAttached(boolean defaultModelUsed)

setModel

public void setModel(OLAPDataSetInterface table)
Set the model used by the adapter to delegate all table calls. The adapter is added as a ContentsChangedListener if the model implements the ContentsChangedSource interface. Setting this property will cause the tableStructure to be changed.


contentsChanged

public void contentsChanged(com.sas.collection.ContentsChangedEvent event)
ContentsChangedListener method to listen for events sent by the model and to refresh the row and column axis. Does not fire any TableModelEvent though, a subclass can override this method to change the behavior if wanted. All this does is cause the row and column axes to refresh.

Specified by:
contentsChanged in interface com.sas.collection.ContentsChangedListener

getColumnCount

public int getColumnCount()
Get the number of columns in the model.

Specified by:
getColumnCount in interface javax.swing.table.TableModel

getColumnName

public java.lang.String getColumnName(int columnIndex)
Get the column name for the specified column index. If the model delegate implements the com.sas.table.StaticColumnLabelInterface, the getColumnLabel(int) is used to find the column name. Otherwise, the super.getColumnName(int) method is used.

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Parameters:
columnIndex - the index of the column to find the name for
Returns:
the name of the column at the specified index

fireTableStructureChanged

public void fireTableStructureChanged()
Overridden to recalculate the rowCount.

Overrides:
fireTableStructureChanged in class javax.swing.table.AbstractTableModel

getRowCount

public int getRowCount()
Get the known rowCount. If the rowCount is unknown, the last known rowCount is stored and when the first value on that row is requested, the rowCount is expanded again until the final rowCount is known.

Specified by:
getRowCount in interface javax.swing.table.TableModel

recalculateRowCount

protected void recalculateRowCount()
Recalculates the known rowCount. If the rowCount is unknown, the last known rowCount is stored and when the first value on that row is requested, the rowCount is expanded again until the final rowCount is known.


getValueAt

public java.lang.Object getValueAt(int rowIndex,
                                   int columnIndex)
Get the value at the specified row and column index. If the model is an instance of the FormattedDataInterface, the getFormattedCell(int,int) method is used to find the value. Otherwise the getCell(int,int) method is used. If the row index is the same as the last known row index, expandRowCount is used to attempt to determine the true row count.

Specified by:
getValueAt in interface javax.swing.table.TableModel

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Determine if the cell at the specified row and column is editable. This checks the value of isTableEditable() first. If the table is editable and the model implements the com.sas.table.TableInterface, then the value of the isCellsModifiable() method is returned. Otherwise, the cell is not considered editable.

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int rowIndex,
                       int columnIndex)
Set the value of the model at the specified row and column indices. If the model is an instance of com.sas.table.FormattedDataInterface then the setFormattedCell(int,int,String) method is used to set the value. Otherwise if the model is an instance of the TableInterface, the setCell(int,int,Object) method is used. If an error occurs when setting the value, a ComponentException is thrown.

Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel

getRowLabel

public java.lang.Object getRowLabel(int row)
Specified by:
getRowLabel in interface com.sas.table.StaticRowLabelInterface

getRowLabels

public java.lang.Object[] getRowLabels(int startIndex,
                                       int count)
Specified by:
getRowLabels in interface com.sas.table.StaticRowLabelInterface

isRowLabelsSupported

public boolean isRowLabelsSupported()
Specified by:
isRowLabelsSupported in interface com.sas.table.StaticRowLabelInterface

isRowsLabelSupported

public boolean isRowsLabelSupported()
Specified by:
isRowsLabelSupported in interface com.sas.table.StaticRowLabelInterface

getColumnAxis

public AxisInterface getColumnAxis()

getRowAxis

public AxisInterface getRowAxis()

getSlicerAxis

public AxisInterface getSlicerAxis()

***  This class is subject to change.  ***




Copyright © 2009 SAS Institute Inc. All Rights Reserved.