ch.elca.dependency.gui
Class DependencyTableModel

java.lang.Object
  |
  +--javax.swing.table.AbstractTableModel
        |
        +--ch.elca.dependency.gui.DependencyTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel

public class DependencyTableModel
extends javax.swing.table.AbstractTableModel

This class is the data model for the dependency list table in the DependencyDialog. It is responsible for managing the table entries.

Version:
1.0-beta
Author:
Christoph Trutmann
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
DependencyTableModel()
          Constructor
 
Method Summary
 void addDependency(java.lang.String name, java.lang.String type, java.lang.String to)
          Adds the dependency to the list.
 void clear()
          Clears the whole table model that means all the rows are deleted.
 java.lang.Class getColumnClass(int columnIndex)
          Returns the most specific superclass for all the cell values in the column.
 int getColumnCount()
          Returns the number of columns in this data table.
 java.lang.String getColumnName(int col)
          Returns the column name.
 int getRowCount()
          Returns the number of rows in this data table.
 java.lang.Object getValueAt(int row, int col)
          Returns an attribute value for the cell at row and column.
 boolean isCellEditable(int rowIndex, int columnIndex)
          Returns false for all cells except the first which is the check box for marking a filter entry.
 void setValueAt(java.lang.Object aValue, int rowIndex, int columnIndex)
          Sets the value in the cell at columnIndex and rowIndex to aValue.
 void sortAllRowsBy(int colIndex, boolean ascending)
          Sorts all the rows of the JTable in the specified order.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DependencyTableModel

public DependencyTableModel()
Constructor

Method Detail

getColumnCount

public int getColumnCount()
Returns the number of columns in this data table.

Returns:
the number of columns in the model

getRowCount

public int getRowCount()
Returns the number of rows in this data table.

Returns:
the number of rows in the model

getValueAt

public java.lang.Object getValueAt(int row,
                                   int col)
Returns an attribute value for the cell at row and column.

Parameters:
row - the row whose value is to be queried
Returns:
the value Object at the specified cell
Throws:
java.lang.ArrayIndexOutOfBoundsException - if an invalid row or column was given

getColumnName

public java.lang.String getColumnName(int col)
Returns the column name.

Specified by:
getColumnName in interface javax.swing.table.TableModel
Overrides:
getColumnName in class javax.swing.table.AbstractTableModel
Returns:
A name for this column using the string value of the appropriate member. If the value is null or does not have an entry for this index, returns the default name provided by the superclass.

getColumnClass

public java.lang.Class getColumnClass(int columnIndex)
Returns the most specific superclass for all the cell values in the column. This is used by the JTable to set up a default renderer and editor for the column.

Specified by:
getColumnClass in interface javax.swing.table.TableModel
Overrides:
getColumnClass in class javax.swing.table.AbstractTableModel
Parameters:
columnIndex - the index of the column
Returns:
the common ancestor class of the object values in the model.

setValueAt

public void setValueAt(java.lang.Object aValue,
                       int rowIndex,
                       int columnIndex)
Sets the value in the cell at columnIndex and rowIndex to aValue.

Specified by:
setValueAt in interface javax.swing.table.TableModel
Overrides:
setValueAt in class javax.swing.table.AbstractTableModel
Parameters:
aValue - the new value
rowIndex - the row whose value is to be changed
columnIndex - the column whose value is to be changed
See Also:
getValueAt(int, int), isCellEditable(int, int)

addDependency

public void addDependency(java.lang.String name,
                          java.lang.String type,
                          java.lang.String to)
Adds the dependency to the list.

Parameters:
name - Name of the added class.
to - Name of the class where the dependency goes to.

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Returns false for all cells except the first which is the check box for marking a filter entry.

Specified by:
isCellEditable in interface javax.swing.table.TableModel
Overrides:
isCellEditable in class javax.swing.table.AbstractTableModel
Parameters:
rowIndex - the row being queried
columnIndex - the column being queried
Returns:
false for all the cells except the first one.

clear

public void clear()
Clears the whole table model that means all the rows are deleted.


sortAllRowsBy

public void sortAllRowsBy(int colIndex,
                          boolean ascending)
Sorts all the rows of the JTable in the specified order. The sort is done in order to the specified column. Null values alvays appear last.

Parameters:
colIndex - Column index which counts for the sort of the rows.
ascending - Flag specifying the order of the sort.


Copyright © 2003 ELCA Informatique SA. All Rights Reserved.