Class MiniTable

  • All Implemented Interfaces:
    ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, RowSorterListener, TableColumnModelListener, TableModelListener, Scrollable, IMiniTable
    Direct Known Subclasses:
    PosTable

    public class MiniTable
    extends CTable
    implements IMiniTable
    Mini Table. Default Read Only Table for Boolean, String, Number, Timestamp values

    After initializing the Table Model, you need to call setColumnClass, add columns via addColumn or in one go prepare the table. MiniTable mt = new MiniTable(); String sql = mt.prepareTable(..); // table defined // add where to the sql statement ResultSet rs = .. mt.loadTable(rs); rs.close();

    Version:
    $Id: MiniTable.java,v 1.3 2006/07/30 00:51:28 jjanke Exp $
    Author:
    Jorg Janke, Teo Sarca, SC ARHIPAC SERVICE SRL
  • BF [ 1891082 ] NPE on MiniTable when you hide some columns
  • FR [ 1974299 ] Add MiniTable.getSelectedKeys method
  • FR [ 2847295 ] MiniTable multiselection checkboxes not working https://sourceforge.net/tracker/?func=detail&atid=879335&aid=2847295&group_id=176962, Teo Sarca, teo.sarca@gmail.com
  • BF [ 2876895 ] MiniTable.loadTable: NPE if column is null https://sourceforge.net/tracker/?func=detail&aid=2876895&group_id=176962&atid=879332
  • See Also:
    Serialized Form
    • Constructor Detail

      • MiniTable

        public MiniTable()
        Default Constructor
    • Method Detail

      • isAutoResize

        public boolean isAutoResize()
      • setAutoResize

        public void setAutoResize​(boolean autoResize)
      • getColumn

        public TableColumn getColumn​(int col)
        Gets the swing column of given index. No index checking is done.
        Parameters:
        col -
        Returns:
      • autoSize

        public void autoSize()
        Size Columns. Uses Mimimum Column Size
        Specified by:
        autoSize in interface IMiniTable
      • isCellEditable

        public boolean isCellEditable​(int row,
                                      int column)
        Is Cell Editable
        Specified by:
        isCellEditable in interface IMiniTable
        Overrides:
        isCellEditable in class JTable
        Parameters:
        row - row
        column - column
        Returns:
        true if editable
      • setColumnReadOnly

        public void setColumnReadOnly​(int column,
                                      boolean readOnly)
        Set Column to ReadOnly
        Specified by:
        setColumnReadOnly in interface IMiniTable
        Parameters:
        column - column
        readOnly - read only
      • prepareTable

        public String prepareTable​(ColumnInfo[] layout,
                                   String from,
                                   String where,
                                   boolean multiSelection,
                                   String tableName)
        Prepare Table and return SQL
        Specified by:
        prepareTable in interface IMiniTable
        Parameters:
        layout - array of column info
        from - SQL FROM content
        where - SQL WHERE content
        multiSelection - multiple selections
        tableName - table name
        Returns:
        SQL
      • addColumn

        public void addColumn​(String header)
        Add Table Column. after adding a column, you need to set the column classes again (DefaultTableModel fires TableStructureChanged, which calls JTable.tableChanged .. createDefaultColumnsFromModel
        Specified by:
        addColumn in interface IMiniTable
        Parameters:
        header - header
      • setColumnClass

        public void setColumnClass​(int index,
                                   Class<?> c,
                                   boolean readOnly)
        Set Column Editor & Renderer to Class. (after all columns were added)
        Specified by:
        setColumnClass in interface IMiniTable
        Parameters:
        index - column index
        c - class of column - determines renderere
        readOnly - read only flag
      • setColumnClass

        public void setColumnClass​(int index,
                                   Class<?> c,
                                   boolean readOnly,
                                   String header)
        Set Column Editor & Renderer to Class (after all columns were added) Lauout of IDColumn depemds on multiSelection
        Specified by:
        setColumnClass in interface IMiniTable
        Parameters:
        index - column index
        c - class of column - determines renderere/editors supported: IDColumn, Boolean, Double (Quantity), BigDecimal (Amount), Integer, Timestamp, String (default)
        readOnly - read only flag
        header - optional header value
      • setRowCount

        public void setRowCount​(int no)
        Clear Table Content
        Specified by:
        setRowCount in interface IMiniTable
        Parameters:
        no - number of rows
      • loadTable

        public void loadTable​(ResultSet rs)
        Load Table from ResultSet - The ResultSet is not closed
        Specified by:
        loadTable in interface IMiniTable
        Parameters:
        rs - ResultSet with the column layout defined in prepareTable
      • loadTable

        public void loadTable​(PO[] pos)
        Load Table from Object Array
        Specified by:
        loadTable in interface IMiniTable
        Parameters:
        pos - array of POs
      • getSelectedRowKey

        public Integer getSelectedRowKey()
        Get the key of currently selected row based on layout defined in prepareTable
        Specified by:
        getSelectedRowKey in interface IMiniTable
        Returns:
        ID if key
      • getSelectedKeys

        public Collection<Integer> getSelectedKeys()
        Returns:
        collection of selected IDs
      • setMultiSelection

        public void setMultiSelection​(boolean multiSelection)
        Set Single Selection
        Specified by:
        setMultiSelection in interface IMiniTable
        Parameters:
        multiSelection - multiple selections
      • isMultiSelection

        public boolean isMultiSelection()
        Single Selection Table
        Specified by:
        isMultiSelection in interface IMiniTable
        Returns:
        true if multiple rows can be selected
      • setColorColumn

        public void setColorColumn​(int modelIndex)
        Set the Column to determine the color of the row (based on model index)
        Parameters:
        modelIndex - model index
      • setColorCompare

        public void setColorCompare​(Object dataCompare)
        Set ColorColumn comparison criteria
        Specified by:
        setColorCompare in interface IMiniTable
        Parameters:
        dataCompare - data
      • getColorCode

        public int getColorCode​(int row)
        Get ColorCode for Row.
                If numerical value in compare column is
                        negative = -1,
              positive = 1,
              otherwise = 0
          If Timestamp
          
        Specified by:
        getColorCode in interface IMiniTable
        Parameters:
        row - row
        Returns:
        color code
      • setShowTotals

        public void setShowTotals​(boolean show)
        Set if Totals is Show
        Specified by:
        setShowTotals in interface IMiniTable
        Parameters:
        boolean - Show
      • getShowTotals

        public boolean getShowTotals()
        get if Totals is Show
        Parameters:
        boolean - Show
      • addTotals

        public void addTotals​(ColumnInfo[] layout)
        Adding a new row with the totals
      • addTotals

        public void addTotals​(Info_Column[] layout)
        Adding a new row with the totals