|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.table.AbstractTableModel | +--edu.uiuc.cs.net.DPRPManager.DPRPLeaseTableModel
This class represents my custom model for the lease management table. Because I want the data in the table to be dynamic, I had to create a model that understood DPRP. The table itself is actually just a view on this model. Thus, it is important to understand how the model gets its data. I decided to simply make the model a DPRPLeaseListener. This means, that whenever a DPRPClient instance fires a lease event, it will flow both into the main GUI code (for displaying any appropriate dialogs), but also into this code, which will update the table.
TODO: column text alignment & fonts.
Field Summary | |
private static int |
COL_EXTERNAL_IP
External IP address column index. |
private static int |
COL_FLAGS
The column index for the flags. |
private static int |
COL_PORT
Reservation External Port column index. |
private static int |
COL_PROTOCOL
Reservation protocol column index. |
private static int |
COL_RENEWALS
The column index for the number of renewals. |
private static int |
COL_STOP_TIME
The halt time for the reservation, column index. |
private java.lang.String[] |
columnNames
Human-readable text descriptions for each column. |
private java.util.Vector |
leaseData
A list of all of the leases in the table. |
private int |
nextIndex
The next index in the list to use (I'm sort of using this Vector like an array, so as to make the JTable happy). |
Fields inherited from class javax.swing.table.AbstractTableModel |
listenerList |
Fields inherited from interface edu.uiuc.cs.net.DPRPManager.DPRPLeaseListenerConstants |
NEW_LEASE_EVENT, REMOVE_LEASE_EVENT, UPDATE_LEASE_EVENT |
Constructor Summary | |
DPRPLeaseTableModel()
Default constructor. |
Method Summary | |
java.lang.Class |
getColumnClass(int c)
Gets the class of the column headers. |
int |
getColumnCount()
Returns the number of columns in the table. |
java.lang.String |
getColumnName(int col)
Gets the name of a specific column. |
DPRPLease |
getLeaseAt(int row)
Fetches the DPRPLease object that backs a given row. |
int |
getRowCount()
Returns the number of rows in the table. |
private java.lang.Object |
getTableData(DPRPLease lea,
int column)
Returns the data, in the appropriate format, for the given column in the given lease. |
java.lang.Object |
getValueAt(int row,
int column)
Gets the specific object behind a specific cell. |
void |
receiveLease(DPRPLeaseEvent ple)
This method represnts a rather interesting design decision. |
Methods inherited from class javax.swing.table.AbstractTableModel |
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, isCellEditable, removeTableModelListener, setValueAt |
Methods inherited from class java.lang.Object |
|
Field Detail |
private static final int COL_EXTERNAL_IP
private static final int COL_PORT
private static final int COL_PROTOCOL
private static final int COL_STOP_TIME
private static final int COL_RENEWALS
private static final int COL_FLAGS
private final java.lang.String[] columnNames
private java.util.Vector leaseData
private int nextIndex
Constructor Detail |
public DPRPLeaseTableModel()
nextIndex
to zero.Method Detail |
public int getRowCount()
getRowCount
in class javax.swing.table.AbstractTableModel
public int getColumnCount()
getColumnCount
in class javax.swing.table.AbstractTableModel
public java.lang.String getColumnName(int col)
getColumnName
in class javax.swing.table.AbstractTableModel
col
- The column number to lookup.public java.lang.Class getColumnClass(int c)
getColumnClass
in class javax.swing.table.AbstractTableModel
public java.lang.Object getValueAt(int row, int column)
getValueAt
in class javax.swing.table.AbstractTableModel
public DPRPLease getLeaseAt(int row)
private java.lang.Object getTableData(DPRPLease lea, int column)
COL_EXTERNAL_IP -- String COL_PORT -- Integer COL_PROTOCOL -- String COL_STOP_TIME -- String, format varies depending upon date distance. COL_RENEWALS -- Integer COL_FLAGS -- HexString
public void receiveLease(DPRPLeaseEvent ple)
DPRPLeaseListener
,
it can intercept lease events directly. This means that the table
will be updated without any direct intervention from the GUI code.
The alternative would have been to simply have the
receiveLease()
handler in the GUI simply call methods
on this model. But, that would have required making the model
reference class-global, and also, it wouldn't have been anywhere
near as slick as this!receiveLease
in interface DPRPLeaseListener
ple
- A DPRPLeaseEvent, representing some sort
of event that must be noted in the table.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |