|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
com.sas.swing.visuals.tableview.DefaultTableRowModel
public class DefaultTableRowModel
Field Summary | |
---|---|
protected javax.swing.event.ChangeEvent |
changeEvent
Change event (only one needed) |
protected javax.swing.event.EventListenerList |
listenerList
List of TableRowModelListener |
protected int |
rowMargin
Height margin between each row |
protected boolean |
rowSelectionAllowed
Row selection allowed in this row model |
protected javax.swing.ListSelectionModel |
selectionModel
Model for keeping track of row selections |
protected java.util.List |
tableRows
List of Integers representing the rows in this model |
Constructor Summary | |
---|---|
DefaultTableRowModel(TableView table)
Creates a default table row model. |
Method Summary | |
---|---|
void |
addRowModelListener(TableRowModelListener x)
Adds a listener for table row model events. |
void |
clearRowMoves()
This will reset the row indexes back to their original values, before any calls to moveRow were made, that is unless a row is held. |
int |
convertRowIndexToModel(int viewRowIndex)
Maps the index of the row in the view at viewRowIndex to the index of the row
in the table model. |
int |
convertRowIndexToView(int modelRowIndex)
Maps the index of the row in the table model at modelRowIndex to the index of the row
in the view. |
protected javax.swing.ListSelectionModel |
createSelectionModel()
Creates a new default list selection model. |
protected void |
fireRowMarginChanged()
Notifies all listeners that have registered interest for notification on this event type. |
protected void |
fireRowMoved(TableRowModelEvent e)
Notifies all listeners that have registered interest for notification on this event type. |
protected void |
fireRowSelectionChanged(javax.swing.event.ListSelectionEvent e)
Notifies all listeners that have registered interest for notification on this event type. |
java.util.EventListener[] |
getListeners(java.lang.Class listenerType)
Returns an array of all the objects currently registered as FooListener s
upon this model. |
int |
getRowCount()
Returns the number of rows in the tableRows array. |
int |
getRowMargin()
Returns the Height margin for TableRow . |
TableRowModelListener[] |
getRowModelListeners()
Returns an array of all the row model listeners registered on this model. |
boolean |
getRowSelectionAllowed()
Returns true if row selection is allowed, otherwise false. |
int |
getSelectedRowCount()
Returns the number of rows selected. |
int[] |
getSelectedRows()
Returns an array of selected rows. |
javax.swing.ListSelectionModel |
getSelectionModel()
Returns the ListSelectionModel that is used to
maintain row selection state. |
TableView |
getTable()
Returns the TableView associated with the row model |
void |
moveRow(int rowIndex,
int newIndex)
Moves the row and heading at rowIndex to
newIndex . |
void |
propertyChange(java.beans.PropertyChangeEvent evt)
Property Change Listener change method. |
void |
removeRowModelListener(TableRowModelListener x)
Removes a listener for table row model events. |
void |
setRowMargin(int newMargin)
Sets the row margin to newMargin . |
void |
setRowSelectionAllowed(boolean flag)
Sets whether row selection is allowed. |
void |
setSelectionModel(javax.swing.ListSelectionModel newModel)
Sets the selection model for this TableRowModel
to newModel
and registers for listener notifications from the new selection
model. |
void |
setTable(TableView newTable)
Sets the TableView associated with this row model, should not be null. |
void |
tableChanged(javax.swing.event.TableModelEvent e)
Invoked when this table's TableModel generates
a TableModelEvent . |
protected void |
tableRowsDeleted(javax.swing.event.TableModelEvent e)
|
protected void |
tableRowsInserted(javax.swing.event.TableModelEvent e)
|
void |
valueChanged(javax.swing.event.ListSelectionEvent e)
A ListSelectionListener that forwards
ListSelectionEvents when there is a row
selection change. |
Field Detail |
---|
protected java.util.List tableRows
protected javax.swing.ListSelectionModel selectionModel
protected int rowMargin
protected javax.swing.event.EventListenerList listenerList
protected transient javax.swing.event.ChangeEvent changeEvent
protected boolean rowSelectionAllowed
Constructor Detail |
---|
public DefaultTableRowModel(TableView table)
Method Detail |
---|
public TableView getTable()
setTable(TableView)
public void setTable(TableView newTable)
newTable
- the new TableView associated with this row modelgetTable()
public void moveRow(int rowIndex, int newIndex)
rowIndex
to
newIndex
. The old row at rowIndex
will now be found at newIndex
. The row
that used to be at newIndex
is shifted
left or right to make room. This will not move any rows if
rowIndex
equals newIndex
. This method
also posts a rowMoved
event to its listeners.
moveRow
in interface TableRowModel
rowIndex
- the index of row to be movednewIndex
- new index to move the row
java.lang.IllegalArgumentException
- if row
or
newIndex
are not in the valid rangepublic void clearRowMoves()
clearRowMoves
in interface TableRowModel
public int convertRowIndexToModel(int viewRowIndex)
viewRowIndex
to the index of the row
in the table model. Returns the index of the corresponding
row in the model. If viewRowIndex
is less than zero, returns viewRowIndex
.
convertRowIndexToModel
in interface TableRowModel
viewRowIndex
- the index of the row in the view
convertRowIndexToView(int)
public int convertRowIndexToView(int modelRowIndex)
modelRowIndex
to the index of the row
in the view. Returns the index of the
corresponding row in the view; returns -1 if this row is not
being displayed. If modelRowIndex
is less than zero,
returns modelRowIndex
.
convertRowIndexToView
in interface TableRowModel
modelRowIndex
- the index of the row in the model
convertRowIndexToModel(int)
public void setRowMargin(int newMargin)
newMargin
. This method
also posts a rowMarginChanged
event to its
listeners.
setRowMargin
in interface TableRowModel
newMargin
- the new margin Height, in pixelsgetRowMargin()
public int getRowCount()
tableRows
array.
getRowCount
in interface TableRowModel
tableRows
arraypublic int getRowMargin()
TableRow
.
The default rowMargin
is 1.
getRowMargin
in interface TableRowModel
TableRow
setRowMargin(int)
public void setSelectionModel(javax.swing.ListSelectionModel newModel)
TableRowModel
to newModel
and registers for listener notifications from the new selection
model. If newModel
is null
,
an exception is thrown.
setSelectionModel
in interface TableRowModel
newModel
- the new selection model
java.lang.IllegalArgumentException
- if newModel
is null
getSelectionModel()
public javax.swing.ListSelectionModel getSelectionModel()
ListSelectionModel
that is used to
maintain row selection state.
getSelectionModel
in interface TableRowModel
null
if row selection is not allowed.setSelectionModel(javax.swing.ListSelectionModel)
public void setRowSelectionAllowed(boolean flag)
setRowSelectionAllowed
in interface TableRowModel
true
- if row selection will be allowed, false otherwiseTableRowModel.getRowSelectionAllowed()
public boolean getRowSelectionAllowed()
getRowSelectionAllowed
in interface TableRowModel
rowSelectionAllowed
propertyTableRowModel.setRowSelectionAllowed(boolean)
public int[] getSelectedRows()
selectionModel
is null
, returns an empty array.
getSelectedRows
in interface TableRowModel
selectionModel
is
null
public int getSelectedRowCount()
getSelectedRowCount
in interface TableRowModel
public void addRowModelListener(TableRowModelListener x)
addRowModelListener
in interface TableRowModel
x
- a TableRowModelListener
objectpublic void removeRowModelListener(TableRowModelListener x)
removeRowModelListener
in interface TableRowModel
x
- a TableRowModelListener
objectpublic TableRowModelListener[] getRowModelListeners()
RowModelListener
s
or an empty
array if no row model listeners are currently registeredaddRowModelListener(com.sas.swing.visuals.tableview.TableRowModelListener)
,
removeRowModelListener(com.sas.swing.visuals.tableview.TableRowModelListener)
protected void fireRowMoved(TableRowModelEvent e)
e
- the event receivedEventListenerList
protected void fireRowSelectionChanged(javax.swing.event.ListSelectionEvent e)
e
- the event receivedEventListenerList
protected void fireRowMarginChanged()
e
- the event receivedEventListenerList
public java.util.EventListener[] getListeners(java.lang.Class listenerType)
FooListener
s
upon this model.
FooListener
s are registered using the
addFooListener
method.
You can specify the listenerType
argument
with a class literal,
such as
FooListener.class
.
For example, you can query a
DefaultTableRowModel
m
for its row model listeners with the following code:
RowModelListener[] cmls = (RowModelListener[])(m.getListeners(RowModelListener.class));If no such listeners exist, this method returns an empty array.
listenerType
- the type of listeners requested; this parameter
should specify an interface that descends from
java.util.EventListener
FooListener
s on this model,
or an empty array if no such
listeners have been added
java.lang.ClassCastException
- if listenerType
doesn't specify a class or interface that implements
java.util.EventListener
getRowModelListeners()
public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange
in interface java.beans.PropertyChangeListener
evt
- PropertyChangeEvent
public void tableChanged(javax.swing.event.TableModelEvent e)
TableModel
generates
a TableModelEvent
.
The TableModelEvent
should be constructed in the
coordinate system of the model; the appropriate mapping to the
view coordinate system is performed by this TableView
when it receives the event.
Application code will not use these methods explicitly, they
are used internally by TableView
.
tableChanged
in interface javax.swing.event.TableModelListener
protected void tableRowsInserted(javax.swing.event.TableModelEvent e)
protected void tableRowsDeleted(javax.swing.event.TableModelEvent e)
public void valueChanged(javax.swing.event.ListSelectionEvent e)
ListSelectionListener
that forwards
ListSelectionEvents
when there is a row
selection change.
valueChanged
in interface javax.swing.event.ListSelectionListener
e
- the change eventprotected javax.swing.ListSelectionModel createSelectionModel()
|
Components |
|
| |||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |