UNICORE Resource Broker Client Plugin
1.5α1

org.eurogrid.broker.client
Class OfferTableModel

java.lang.Object
  |
  +--javax.swing.table.AbstractTableModel
        |
        +--org.eurogrid.broker.client.OfferTableModel
All Implemented Interfaces:
Serializable, TableModel

public class OfferTableModel
extends AbstractTableModel

Table Model class for the Offers returned by the Broker

Version:
$Revision: 1.12 $, $Date: 2004/02/17 11:32:40 $
Author:
Jon MacLaren
See Also:
BrokerOffer, Serialized Form

Nested Class Summary
static class OfferTableModel.Comparison
          Used in constructing broker-offer comparison policies.
 
Field Summary
static int COLUMN_COUNT
          Number of columns in the table
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
OfferTableModel()
           
OfferTableModel(Map vsiteToUsiteMap)
           
OfferTableModel(OfferTableModel.Comparison[] policy)
           
OfferTableModel(OfferTableModel.Comparison[] policy, Map vsiteToUsiteMap, String currency)
          Create the empty list of offers.
 
Method Summary
 void addCurrencyMap(Element currencyDOM)
           
 void addCurrencyMap(String currencyXML)
           
 void addCurrencyMap(String from, String to, double factor)
          Add a currency conversion factor to this class's internal map.
 void addOffer(BrokerOffer offer)
          Add a new offer to the table
 double convert(double cost, String currency)
          Convert the given cost in the given currency into the user's preferred currency.
 Class getColumnClass(int columnIndex)
          Fetch the class of a particular column
 int getColumnCount()
          Get the number of columns in the table
 String getColumnName(int column)
          Fetch the name of a particular column
 int getRowCount()
          Get the number of rows in the table
 boolean getRowValidity(int rowIndex)
          Fetch the validty of the offer stored in a particular row
 BrokerOffer getSelectedOffer()
          Return the selected offer
 String getTargetCurrency()
          Get the user's preferred currency for displaying costs.
 Object getValueAt(int rowIndex, int columnIndex)
          Fetch the value stored in a particular cell
 boolean isCellEditable(int rowIndex, int columnIndex)
          Test the editability of a given cell
 void setComparisonPolicy(OfferTableModel.Comparison[] policy)
          Set the offer comparison policy for this table model.
 void setSelectedRow(int row)
          Set the row that is selected
 void setTargetCurrency(String targetCurrency)
          Set the user's preferred currency for displaying costs.
 void sortByColumn(int column)
          Called when the user clicks on a column header to perform simple sorting by that column.
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener, setValueAt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COLUMN_COUNT

public static final int COLUMN_COUNT
Number of columns in the table

See Also:
Constant Field Values
Constructor Detail

OfferTableModel

public OfferTableModel()

OfferTableModel

public OfferTableModel(Map vsiteToUsiteMap)

OfferTableModel

public OfferTableModel(OfferTableModel.Comparison[] policy)

OfferTableModel

public OfferTableModel(OfferTableModel.Comparison[] policy,
                       Map vsiteToUsiteMap,
                       String currency)
Create the empty list of offers.

Method Detail

addCurrencyMap

public void addCurrencyMap(Element currencyDOM)

addCurrencyMap

public void addCurrencyMap(String currencyXML)

addCurrencyMap

public void addCurrencyMap(String from,
                           String to,
                           double factor)
Add a currency conversion factor to this class's internal map.

Parameters:
from - Which currency are we going from.
to - Which currency are we going to.
factor - Multiplication factor to apply when going from one to the other.

addOffer

public void addOffer(BrokerOffer offer)
Add a new offer to the table

Parameters:
offer - The new offer

convert

public double convert(double cost,
                      String currency)
Convert the given cost in the given currency into the user's preferred currency.

Parameters:
cost - Numeric cost.
currency - Units of the numeric cost.

getColumnClass

public Class getColumnClass(int columnIndex)
Fetch the class of a particular column

Specified by:
getColumnClass in interface TableModel
Overrides:
getColumnClass in class AbstractTableModel
Parameters:
columnIndex - The column of interest
Returns:
The Class object for the given column

getColumnCount

public int getColumnCount()
Get the number of columns in the table

Returns:
The number of columns

getColumnName

public String getColumnName(int column)
Fetch the name of a particular column

Specified by:
getColumnName in interface TableModel
Overrides:
getColumnName in class AbstractTableModel
Parameters:
column - The column of interest
Returns:
The name of the column

getRowCount

public int getRowCount()
Get the number of rows in the table

Returns:
The number of rows

getRowValidity

public boolean getRowValidity(int rowIndex)
Fetch the validty of the offer stored in a particular row

Parameters:
rowIndex - The row of interest
Returns:
The validity of the offer tickets in the row

getSelectedOffer

public BrokerOffer getSelectedOffer()
Return the selected offer

Returns:
The selected offer, or null if nothing is selected.

getTargetCurrency

public String getTargetCurrency()
Get the user's preferred currency for displaying costs.

Returns:
Currency string, or null if the raw costings are to be used instead.

getValueAt

public Object getValueAt(int rowIndex,
                         int columnIndex)
Fetch the value stored in a particular cell

Parameters:
rowIndex - The row of interest
columnIndex - The column of interest
Returns:
The value of the cell

isCellEditable

public boolean isCellEditable(int rowIndex,
                              int columnIndex)
Test the editability of a given cell

Specified by:
isCellEditable in interface TableModel
Overrides:
isCellEditable in class AbstractTableModel
Parameters:
rowIndex - The row of interest
columnIndex - The column of interest
Returns:
True if the cell is editable (always false)

setComparisonPolicy

public void setComparisonPolicy(OfferTableModel.Comparison[] policy)
Set the offer comparison policy for this table model. The default policy is to sort first by overall validity, then by units of cost, and then by the costs themselves.

Parameters:
policy - Array of policies to install, with comparisons being done by the policy of the first array element, and if that two elements are equal by that, comparing by the second element, and if equal by that, comparing by the third, etc.

setSelectedRow

public void setSelectedRow(int row)
Set the row that is selected

Parameters:
row - The selected row

setTargetCurrency

public void setTargetCurrency(String targetCurrency)
Set the user's preferred currency for displaying costs.

Parameters:
targetCurrency - Currency string, or null if the raw costings are to be used instead.

sortByColumn

public void sortByColumn(int column)
Called when the user clicks on a column header to perform simple sorting by that column. Works by locally altering the sorting policy to one based on just the column clicked, possibly with directional modifiers, so new results insert neatly into the sorted set of results.


UNICORE Resource Broker Client Plugin
1.5α1

Submit a bug or feature
Copyright © 2002-2004 University of Manchester, U.K. See license.terms for details.