ilog.cpl.table
Class IlpTableColumnModel

java.lang.Object
  extended by javax.swing.table.DefaultTableColumnModel
      extended by ilog.cpl.table.IlpTableColumnModel
All Implemented Interfaces:
IlpAbstractTableColumnModel, PropertyChangeListener, Serializable, EventListener, ListSelectionListener, TableColumnModel

public class IlpTableColumnModel
extends DefaultTableColumnModel
implements IlpAbstractTableColumnModel

A table column model with fixed columns and free columns. This is the default table model for an IlpTableView. The IlpTableColumnModel uses two submodels: one for fixed columns and one for free columns. Each of these two models configures a JTable inside the IlpTableView.

Since:
JTGO 3.0
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.DefaultTableColumnModel
changeEvent, columnMargin, columnSelectionAllowed, listenerList, selectionModel, tableColumns, totalColumnWidth
 
Constructor Summary
IlpTableColumnModel(TableColumnModel fixedColumnModel, TableColumnModel freeColumnModel)
          Creates a table column model from the column model that displays the fixed columns and the column model that displays the free columns in an IlpTableView.
 
Method Summary
 void addColumn(TableColumn aColumn)
          Appends aColumn to the end of the free columns.
 void addNewColumn(int modelIndex, Object headerValue)
          Adds a new column in the column model with the following index and header value.
 TableColumn getColumn(int columnIndex)
          Returns the TableColumn at index columnIndex.
 int getColumnCount()
          Returns the number of TableColumn objects in this column model.
 int getColumnIndex(IlpAttribute attribute)
          Returns the column index of the specified attribute.
 int getColumnIndex(Object columnIdentifier)
          Returns the index of the first column whose identifier is equal to identifier, when compared using equals.
 int getColumnIndexAtX(int xPosition)
          Returns the index of the column at position xPosition, or -1 if no column covers this point.
 int getColumnMargin()
          Returns the margin width for TableColumn.
 Enumeration getColumns()
          Returns an Enumeration of all the columns in the model.
 int getFixedColumnCount()
          Retrieves the number of fixed columns in the column model.
 int getTotalColumnWidth()
          Returns the total combined width of all columns.
 boolean isColumnFixed(int columnIndex)
          Returns whether the specified column is fixed.
 boolean isColumnFixed(TableColumn aColumn)
          Returns whether the specified column is fixed.
 void moveColumn(int columnIndex, int newIndex)
          Moves the column and heading at columnIndex to newIndex.
 void removeAllColumns()
          Removes the columns from the column model.
 void removeColumn(int modelIndex)
          Removes a column of index modelIndex
 void removeColumn(TableColumn column)
          Deletes the specified column from the tableColumns array.
 void setColumnIndex(IlpAttribute attribute, int index)
          Moves the column of the specified attribute to the specified index.
 void setColumnMargin(int newMargin)
          Sets the column margin to newMargin.
 void setColumnPreferredWidth(IlpAttribute attribute, int columnWidth)
          Sets the preferred width for the column defined by this attribute
 void setFixedColumnCount(int nbColsToFix)
          Sets the number of fixed columns in the model.
 void setFixedColumnModel(TableColumnModel fixedColumnModel)
          Sets the column model containing fixed columns.
 void setFreeColumnModel(TableColumnModel freeColumnModel)
          Sets the column model containing free columns.
 
Methods inherited from class javax.swing.table.DefaultTableColumnModel
addColumnModelListener, createSelectionModel, fireColumnAdded, fireColumnMarginChanged, fireColumnMoved, fireColumnRemoved, fireColumnSelectionChanged, getColumnModelListeners, getColumnSelectionAllowed, getListeners, getSelectedColumnCount, getSelectedColumns, getSelectionModel, propertyChange, recalcWidthCache, removeColumnModelListener, setColumnSelectionAllowed, setSelectionModel, valueChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IlpTableColumnModel

public IlpTableColumnModel(TableColumnModel fixedColumnModel,
                           TableColumnModel freeColumnModel)
Creates a table column model from the column model that displays the fixed columns and the column model that displays the free columns in an IlpTableView.

Parameters:
fixedColumnModel - The column model used to display fixed columns in an IlpTableView.
freeColumnModel - The column model used to display free columns in an IlpTableView.
Method Detail

setFixedColumnModel

public void setFixedColumnModel(TableColumnModel fixedColumnModel)
Sets the column model containing fixed columns.

Parameters:
fixedColumnModel - The fixed column model to use; cannot be null.
Throws:
IllegalArgumentException - if the given column model is null.

setFreeColumnModel

public void setFreeColumnModel(TableColumnModel freeColumnModel)
Sets the column model containing free columns.

Parameters:
freeColumnModel - The free column model to use; cannot be null.
Throws:
IllegalArgumentException - if the given column model is null.

setColumnMargin

public void setColumnMargin(int newMargin)
Sets the column margin to newMargin. This method also posts a columnMarginChanged event to its listeners.

Specified by:
setColumnMargin in interface TableColumnModel
Overrides:
setColumnMargin in class DefaultTableColumnModel
Parameters:
newMargin - The new margin width in pixels.
See Also:
getColumnMargin(), getTotalColumnWidth()

getColumnMargin

public int getColumnMargin()
Returns the margin width for TableColumn. The default columnMargin is 1.

Specified by:
getColumnMargin in interface TableColumnModel
Overrides:
getColumnMargin in class DefaultTableColumnModel
Returns:
The maximum width for the TableColumn.
See Also:
setColumnMargin(int)

setFixedColumnCount

public void setFixedColumnCount(int nbColsToFix)
Sets the number of fixed columns in the model. If nbColsToFix is 0, none of the columns will be fixed. All the columns will be fixed if nbColsToFix is greater than the number of columns. A number of columns less than 0 has no effect.

Note: Calling this method does not fire any event with this column model as source.

Parameters:
nbColsToFix - The number of fixed columns in the table; it may be 0.
See Also:
getFixedColumnCount()

getFixedColumnCount

public int getFixedColumnCount()
Retrieves the number of fixed columns in the column model.

Returns:
The number of fixed columns.
See Also:
setFixedColumnCount(int)

isColumnFixed

public boolean isColumnFixed(int columnIndex)
Returns whether the specified column is fixed. Returns false if the column index is out of bounds.

Parameters:
columnIndex - The index of the column to check.
Returns:
true if the column specified by columnIndex is a fixed one.

isColumnFixed

public boolean isColumnFixed(TableColumn aColumn)
Returns whether the specified column is fixed.

Parameters:
aColumn - The column to check.
Returns:
true if the column specified by aColumn is a fixed one.

addColumn

public void addColumn(TableColumn aColumn)
Appends aColumn to the end of the free columns. This method also posts the columnAdded event to its listeners.

Specified by:
addColumn in interface TableColumnModel
Overrides:
addColumn in class DefaultTableColumnModel
Parameters:
aColumn - The TableColumn to be added.
Throws:
IllegalArgumentException - if aColumn is null.
See Also:
removeColumn(javax.swing.table.TableColumn)

removeColumn

public void removeColumn(TableColumn column)
Deletes the specified column from the tableColumns array. This method will do nothing if column is not in the list of the table's columns. This method also posts a columnRemoved event to its listeners.

Specified by:
removeColumn in interface TableColumnModel
Overrides:
removeColumn in class DefaultTableColumnModel
Parameters:
column - The TableColumn to be removed.
See Also:
addColumn(javax.swing.table.TableColumn)

removeColumn

public void removeColumn(int modelIndex)
Description copied from interface: IlpAbstractTableColumnModel
Removes a column of index modelIndex

Specified by:
removeColumn in interface IlpAbstractTableColumnModel
Parameters:
modelIndex - index of the column to be removed

moveColumn

public void moveColumn(int columnIndex,
                       int newIndex)
Moves the column and heading at columnIndex to newIndex. The old column at columnIndex will now be found at newIndex. The column that used to be at newIndex is shifted left or right to make room. This will not move any columns if columnIndex equals newIndex. This method also posts a columnMoved event to its listeners.

Specified by:
moveColumn in interface TableColumnModel
Overrides:
moveColumn in class DefaultTableColumnModel
Parameters:
columnIndex - The index of the column to be moved.
newIndex - New index to move the column to.
Throws:
IllegalArgumentException - if columnIndex or newIndex is not in the valid range.

getColumnCount

public int getColumnCount()
Returns the number of TableColumn objects in this column model.

Specified by:
getColumnCount in interface TableColumnModel
Overrides:
getColumnCount in class DefaultTableColumnModel
Returns:
The number of TableColumn objects in this column model.

getColumns

public Enumeration getColumns()
Returns an Enumeration of all the columns in the model.

Specified by:
getColumns in interface TableColumnModel
Overrides:
getColumns in class DefaultTableColumnModel
Returns:
An Enumeration of the columns in the model.

getColumn

public TableColumn getColumn(int columnIndex)
Returns the TableColumn at index columnIndex.

Specified by:
getColumn in interface TableColumnModel
Overrides:
getColumn in class DefaultTableColumnModel
Returns:
The TableColumn at the given index.

getColumnIndex

public int getColumnIndex(Object columnIdentifier)
Returns the index of the first column whose identifier is equal to identifier, when compared using equals.

Specified by:
getColumnIndex in interface TableColumnModel
Overrides:
getColumnIndex in class DefaultTableColumnModel
Parameters:
columnIdentifier - The identifier object.
Returns:
The index of the first column whose identifier is equal to columnIdentifier.
Throws:
IllegalArgumentException - if columnIdentifier is null, or if no TableColumn has this identifier.
See Also:
getColumn(int)

getColumnIndexAtX

public int getColumnIndexAtX(int xPosition)
Returns the index of the column at position xPosition, or -1 if no column covers this point.

Specified by:
getColumnIndexAtX in interface TableColumnModel
Overrides:
getColumnIndexAtX in class DefaultTableColumnModel
Parameters:
xPosition - The horizontal location of interest.
Returns:
The index of the column or -1 if no column is found.

getTotalColumnWidth

public int getTotalColumnWidth()
Returns the total combined width of all columns.

Specified by:
getTotalColumnWidth in interface TableColumnModel
Overrides:
getTotalColumnWidth in class DefaultTableColumnModel
Returns:
The total combined width of all columns.

setColumnIndex

public void setColumnIndex(IlpAttribute attribute,
                           int index)
Description copied from interface: IlpAbstractTableColumnModel
Moves the column of the specified attribute to the specified index.

Specified by:
setColumnIndex in interface IlpAbstractTableColumnModel
Parameters:
attribute - The attribute corresponding to the column which has to be moved.
index - The new index for the column.

getColumnIndex

public int getColumnIndex(IlpAttribute attribute)
Description copied from interface: IlpAbstractTableColumnModel
Returns the column index of the specified attribute.

Specified by:
getColumnIndex in interface IlpAbstractTableColumnModel
Parameters:
attribute - The attribute whose column index is to be returned.
Returns:
-1 if the given attribute does not correspond to a visible column in the table view.

removeAllColumns

public void removeAllColumns()
Description copied from interface: IlpAbstractTableColumnModel
Removes the columns from the column model.

Specified by:
removeAllColumns in interface IlpAbstractTableColumnModel

addNewColumn

public void addNewColumn(int modelIndex,
                         Object headerValue)
Description copied from interface: IlpAbstractTableColumnModel
Adds a new column in the column model with the following index and header value.

Specified by:
addNewColumn in interface IlpAbstractTableColumnModel

setColumnPreferredWidth

public void setColumnPreferredWidth(IlpAttribute attribute,
                                    int columnWidth)
Description copied from interface: IlpAbstractTableColumnModel
Sets the preferred width for the column defined by this attribute

Specified by:
setColumnPreferredWidth in interface IlpAbstractTableColumnModel


Copyright © 1996-2007 ILOG S.A. All rights reserved.   Documentation homepage.   . All Rights Reserved.