Package hec.model

Class AbstractDataListTableModel

java.lang.Object
javax.swing.table.AbstractTableModel
rma.swing.table.AbstractRmaTableModel
hec.model.AbstractDataListTableModel
All Implemented Interfaces:
Serializable, TableModel, rma.swing.table.RmaTableModelInterface

public abstract class AbstractDataListTableModel extends rma.swing.table.AbstractRmaTableModel
The AbstractDataListTable model provied a default implementation to display and edit a data list in a RmaJTable/JTable. The model wraps around a datalist object. When a cell is rendered by the table, the model gets a data object from the data list and places it into a editing buffer. The contents of the buffer is not saved until the programmer calls the commit method on the model. Blank rows are displayed by DataObjects with no names. Changes to the table are as follows, (1) If the name is blank and the id is undefined, it must be a blank row. (2) If the name is filled and the id is undefined, it is a new object (3) If the name is filled and the id is defined, it is an update.
Since:
1 February 2001
See Also:
  • Field Details

    • _committingTable

      protected boolean _committingTable
    • m_dataList

      protected CommonDataList m_dataList
    • m_objects

      protected List m_objects
    • m_tempObjects

      protected List m_tempObjects
    • m_commitImmediatly

      protected boolean m_commitImmediatly
    • m_parentComponent

      protected Component m_parentComponent
    • m_currentEditRow

      protected int m_currentEditRow
  • Constructor Details

    • AbstractDataListTableModel

      public AbstractDataListTableModel()
    • AbstractDataListTableModel

      public AbstractDataListTableModel(CommonDataList dl)
    • AbstractDataListTableModel

      public AbstractDataListTableModel(DataList dl)
  • Method Details

    • getColumnCount

      public int getColumnCount()
      The method returns the number of columns in the table. This is defines by the values in the column names array (m_columnNames)
      Specified by:
      getColumnCount in interface TableModel
      Overrides:
      getColumnCount in class rma.swing.table.AbstractRmaTableModel
    • getRowCount

      public int getRowCount()
      Returns the number of rows that are in the editing buffer. If an object has not been rendered, it is represented by a NULL value in the buffer. This is included in the row count.
      Specified by:
      getRowCount in interface TableModel
      Overrides:
      getRowCount in class rma.swing.table.AbstractRmaTableModel
      Returns:
      the row count.
    • getValueAt

      public Object getValueAt(int rowIndex, int columnIndex)
      Returns the value for a particular row and column in the data model. The default implementation returns NULL. This method showl be overridden
      Specified by:
      getValueAt in interface TableModel
      Overrides:
      getValueAt in class rma.swing.table.AbstractRmaTableModel
      Parameters:
      rowIndex -
      columnIndex -
      Returns:
      NULL
    • setValueAt

      public void setValueAt(Object aValue, int rowIndex, int columnIndex)
      This does nothing. Should be overridden to provide the correct implementation.
      Specified by:
      setValueAt in interface TableModel
      Overrides:
      setValueAt in class rma.swing.table.AbstractRmaTableModel
      Parameters:
      aValue -
      rowIndex -
      columnIndex -
    • firstIndexOf

      public int firstIndexOf(String match, int index, boolean wrap, boolean wholeWord, boolean caseSensitive)
      Returns the index of an object in this list using a string match.
      Parameters:
      match - The string to match.
      index - The index to start the search at.
      wrap - When the end of the model is reached do we wrap to the front?
      wholeWord - Whether to match only whole words or not.
      caseSensitive - Is the match case sensitive?
      Returns:
      the index of the first object that matches the search criteria; returns -1 if no object matches the search criteria.
    • lastIndexOf

      public int lastIndexOf(String match, int index, boolean wholeWord, boolean caseSensitive)
      Iterating from rear to front, returns the first occurance of an object in this list using a string match.
      Parameters:
      match - The string to match.
      index - The index to start the search at.
      wholeWord - Whether to match only whole words or not.
      caseSensitive - Is the match case sensitive?
      Returns:
      the index of the last object that matches the search criteria; returns -1 if no object matches the search criteria.
    • getColumnName

      public String getColumnName(int column)
      Returns a String array of column names.
      Specified by:
      getColumnName in interface TableModel
      Overrides:
      getColumnName in class rma.swing.table.AbstractRmaTableModel
      Parameters:
      column -
    • getColumnClass

      public Class getColumnClass(int columnIndex)
      Specified by:
      getColumnClass in interface TableModel
      Overrides:
      getColumnClass in class rma.swing.table.AbstractRmaTableModel
    • isCellEditable

      public boolean isCellEditable(int rowIndex, int columnIndex)
      Returns true if the cell at rowIndex and columnIndex is editable. Otherwise, setValueAt() on the cell will not change the value of that cell.
      Specified by:
      isCellEditable in interface TableModel
      Overrides:
      isCellEditable in class rma.swing.table.AbstractRmaTableModel
      Parameters:
      rowIndex - the row whose value is to be looked up
      columnIndex - the column whose value is to be looked up
      Returns:
      true if the cell is editable.
      See Also:
    • addColumn

      public void addColumn(String str)
      Description copied from interface: rma.swing.table.RmaTableModelInterface
      add a column to the table with the header colName
      Specified by:
      addColumn in interface rma.swing.table.RmaTableModelInterface
      Overrides:
      addColumn in class rma.swing.table.AbstractRmaTableModel
    • addColumn

      public void addColumn(String colName, Vector data)
      Description copied from interface: rma.swing.table.RmaTableModelInterface
      add a column to the table with header columnName and data ColumnData
      Specified by:
      addColumn in interface rma.swing.table.RmaTableModelInterface
      Overrides:
      addColumn in class rma.swing.table.AbstractRmaTableModel
    • addRow

      public void addRow()
    • addRow

      protected void addRow(List tempList)
    • addRow

      public void addRow(Vector data)
      Description copied from interface: rma.swing.table.RmaTableModelInterface
      add a row to the table with data in the Vector newRow
      Specified by:
      addRow in interface rma.swing.table.RmaTableModelInterface
      Overrides:
      addRow in class rma.swing.table.AbstractRmaTableModel
    • setColumnNames

      public void setColumnNames(Vector colNames)
      Specified by:
      setColumnNames in interface rma.swing.table.RmaTableModelInterface
      Overrides:
      setColumnNames in class rma.swing.table.AbstractRmaTableModel
    • setColumnNames

      public void setColumnNames(String[] colNames)
      Specified by:
      setColumnNames in interface rma.swing.table.RmaTableModelInterface
      Overrides:
      setColumnNames in class rma.swing.table.AbstractRmaTableModel
    • setColumnParameters

      public void setColumnParameters(int[] params)
      Specified by:
      setColumnParameters in interface rma.swing.table.RmaTableModelInterface
      Overrides:
      setColumnParameters in class rma.swing.table.AbstractRmaTableModel
    • getColumnParameter

      public int getColumnParameter(int col)
      Description copied from class: rma.swing.table.AbstractRmaTableModel
      Returns the parameter for a given column. If no parameter is defined -1 is returned. The parameter ID returned can be decoded with the hec.data.Parameter class.
      Specified by:
      getColumnParameter in interface rma.swing.table.RmaTableModelInterface
      Overrides:
      getColumnParameter in class rma.swing.table.AbstractRmaTableModel
    • getUnitSystem

      public int getUnitSystem()
      returns the unit system for this data. The value is retrieved from the DataList which this object is wrapped around
      Specified by:
      getUnitSystem in interface rma.swing.table.RmaTableModelInterface
      Overrides:
      getUnitSystem in class rma.swing.table.AbstractRmaTableModel
    • deleteRow

      public void deleteRow(int row)
      Deletes a row from the editing buffer. If an object exists in the buffer it is deleted from the datalist. This method is called from the table, so the buffer should not have a null value because it should have been rendered
      Specified by:
      deleteRow in interface rma.swing.table.RmaTableModelInterface
      Overrides:
      deleteRow in class rma.swing.table.AbstractRmaTableModel
      Parameters:
      row -
    • setRowEnabled

      public void setRowEnabled(boolean enabled, int row)
      Description copied from interface: rma.swing.table.RmaTableModelInterface
      set the Row row enabled or disabled
      Specified by:
      setRowEnabled in interface rma.swing.table.RmaTableModelInterface
      Overrides:
      setRowEnabled in class rma.swing.table.AbstractRmaTableModel
    • setColEnabled

      public void setColEnabled(boolean enabled, int col)
      Description copied from interface: rma.swing.table.RmaTableModelInterface
      the the Column col enabled or disabled
      Specified by:
      setColEnabled in interface rma.swing.table.RmaTableModelInterface
      Overrides:
      setColEnabled in class rma.swing.table.AbstractRmaTableModel
    • setColumnClass

      public void setColumnClass(int col, Class cls)
      Description copied from interface: rma.swing.table.RmaTableModelInterface
      st the column col's class to be cls
      Specified by:
      setColumnClass in interface rma.swing.table.RmaTableModelInterface
      Overrides:
      setColumnClass in class rma.swing.table.AbstractRmaTableModel
    • clearAll

      public void clearAll()
      Description copied from interface: rma.swing.table.RmaTableModelInterface
      remove all data from the table
      Specified by:
      clearAll in interface rma.swing.table.RmaTableModelInterface
      Overrides:
      clearAll in class rma.swing.table.AbstractRmaTableModel
    • getRow

      public Vector getRow(int row)
      Description copied from interface: rma.swing.table.RmaTableModelInterface
      get the row of data at rowNum and return in a Vector
      Specified by:
      getRow in interface rma.swing.table.RmaTableModelInterface
      Overrides:
      getRow in class rma.swing.table.AbstractRmaTableModel
    • insertRow

      public void insertRow(int row, Vector data)
      Description copied from interface: rma.swing.table.RmaTableModelInterface
      insert a row in the table at Row row with data rowData
      Specified by:
      insertRow in interface rma.swing.table.RmaTableModelInterface
      Overrides:
      insertRow in class rma.swing.table.AbstractRmaTableModel
    • getDataVector

      public Vector getDataVector()
      Description copied from interface: rma.swing.table.RmaTableModelInterface
      return the table data in a vector
      Specified by:
      getDataVector in interface rma.swing.table.RmaTableModelInterface
      Overrides:
      getDataVector in class rma.swing.table.AbstractRmaTableModel
    • commitImmediatly

      public void commitImmediatly(boolean ci)
      This allows for the model to commit whenever it gets a setValueAt() call from the table. The particular implementation of the commit is left to the sub-class.
      Parameters:
      ci -
    • commitTable

      public boolean commitTable()
      Commits all objects in the editing buffer. If the object has a non-blank name but no ID it is added to the datalist. If it has a non-blank name and a valid id the object is updated.
    • commitDataObject

      public boolean commitDataObject(DataObject dobj)
      Commits a particular object to the data list.
      Parameters:
      dobj -
    • setParentComponent

      public void setParentComponent(Component c)
      Allows the user to set the parent table or any component that uses this model. It is used for displaying messages to the user to get information about transaction rules.
    • uniqueNameInEditBuffer

      public boolean uniqueNameInEditBuffer(String name)
    • isValidRecord

      public boolean isValidRecord(DataObject dobj)
      Tests to see if the data object is a valid. This method will return false if the object is either null, or its ID is undefined and its name is equal to "". Returns true if it is, other wise false.
    • clearEdits

      public void clearEdits()
      Clears all of the edits by removing everything from the edit buffer.
    • clearList

      protected void clearList(List tempList, List objectsList)