Adempiere 3.5.2a

org.compiere.minigrid
Class MiniTable

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JTable
                  extended by org.compiere.swing.CTable
                      extended by org.compiere.minigrid.MiniTable
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, EventListener, Accessible, CellEditorListener, ListSelectionListener, RowSorterListener, TableColumnModelListener, TableModelListener, Scrollable

public class MiniTable
extends CTable

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
  • See Also:
    Serialized Form

    Nested Class Summary
     
    Nested classes/interfaces inherited from class javax.swing.JTable
    JTable.AccessibleJTable, JTable.DropLocation, JTable.PrintMode
     
    Nested classes/interfaces inherited from class javax.swing.JComponent
    JComponent.AccessibleJComponent
     
    Nested classes/interfaces inherited from class java.awt.Container
    Container.AccessibleAWTContainer
     
    Nested classes/interfaces inherited from class java.awt.Component
    Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
     
    Field Summary
     
    Fields inherited from class org.compiere.swing.CTable
    p_asc, p_keyColumnIndex, p_lastSortIndex, sorting
     
    Fields inherited from class javax.swing.JTable
    AUTO_RESIZE_ALL_COLUMNS, AUTO_RESIZE_LAST_COLUMN, AUTO_RESIZE_NEXT_COLUMN, AUTO_RESIZE_OFF, AUTO_RESIZE_SUBSEQUENT_COLUMNS, autoCreateColumnsFromModel, autoResizeMode, cellEditor, cellSelectionEnabled, columnModel, dataModel, defaultEditorsByColumnClass, defaultRenderersByColumnClass, editingColumn, editingRow, editorComp, gridColor, preferredViewportSize, rowHeight, rowMargin, rowSelectionAllowed, selectionBackground, selectionForeground, selectionModel, showHorizontalLines, showVerticalLines, tableHeader
     
    Fields inherited from class javax.swing.JComponent
    accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
     
    Fields inherited from class java.awt.Component
    BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
     
    Fields inherited from interface java.awt.image.ImageObserver
    ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
     
    Constructor Summary
    MiniTable()
              Default Constructor
     
    Method Summary
     void addColumn(String header)
              Add Table Column.
     void addTotals(ColumnInfo[] layout)
              Adding a new row with the totals
     void addTotals(Info_Column[] layout)
              Adding a new row with the totals
     void autoSize()
              Size Columns.
     int getColorCode(int row)
              Get ColorCode for Row.
     ColumnInfo[] getLayoutInfo()
              Get Layout
     Integer getSelectedRowKey()
              Get the key of currently selected row based on layout defined in prepareTable
     boolean getShowTotals()
              get if Totals is Show
     boolean isCellEditable(int row, int column)
              Is Cell Editable
     boolean isMultiSelection()
              Single Selection Table
     void loadTable(PO[] pos)
              Load Table from Object Array
     void loadTable(ResultSet rs)
              Load Table from ResultSet - The ResultSet is not closed
     String prepareTable(ColumnInfo[] layout, String from, String where, boolean multiSelection, String tableName)
              Prepare Table and return SQL
     void setColorColumn(int modelIndex)
              Set the Column to determine the color of the row (based on model index)
     void setColorCompare(Object dataCompare)
              Set ColorColumn comparison criteria
     void setColumnClass(int index, Class c, boolean readOnly)
              Set Column Editor & Renderer to Class.
     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
     void setColumnReadOnly(int column, boolean readOnly)
              Set Column to ReadOnly
     void setMultiSelection(boolean multiSelection)
              Set Single Selection
     void setRowCount(int no)
              Clear Table Content
     void setShowTotals(boolean show)
              Set if Totals is Show
     
    Methods inherited from class org.compiere.swing.CTable
    autoSize, configureColumnControl, createDefaultColumnControl, getColumnControl, getKeyColumnIndex, getSelectedKeyColumnValue, getSelectedValue, getSortColumn, isColumnControlVisible, isColumnVisible, isSortAscending, packColumn, setColumnControlVisible, setColumnVisibility, setFont, setKeyColumnIndex, sort, stopEditor, tableChanged, toString
     
    Methods inherited from class javax.swing.JTable
    addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, changeSelection, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, createDefaultTableHeader, createScrollPaneForTable, doLayout, editCellAt, editCellAt, editingCanceled, editingStopped, getAccessibleContext, getAutoCreateColumnsFromModel, getAutoCreateRowSorter, getAutoResizeMode, getCellEditor, getCellEditor, getCellRect, getCellRenderer, getCellSelectionEnabled, getColumn, getColumnClass, getColumnCount, getColumnModel, getColumnName, getColumnSelectionAllowed, getDefaultEditor, getDefaultRenderer, getDragEnabled, getDropLocation, getDropMode, getEditingColumn, getEditingRow, getEditorComponent, getFillsViewportHeight, getGridColor, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getPrintable, getRowCount, getRowHeight, getRowHeight, getRowMargin, getRowSelectionAllowed, getRowSorter, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRow, getSelectedRowCount, getSelectedRows, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getUpdateSelectionOnSort, getValueAt, initializeLocalVars, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, print, print, print, print, print, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, rowAtPoint, selectAll, setAutoCreateColumnsFromModel, setAutoCreateRowSorter, setAutoResizeMode, setCellEditor, setCellSelectionEnabled, setColumnModel, setColumnSelectionAllowed, setColumnSelectionInterval, setDefaultEditor, setDefaultRenderer, setDragEnabled, setDropMode, setEditingColumn, setEditingRow, setFillsViewportHeight, setGridColor, setIntercellSpacing, setModel, setPreferredScrollableViewportSize, setRowHeight, setRowHeight, setRowMargin, setRowSelectionAllowed, setRowSelectionInterval, setRowSorter, setSelectionBackground, setSelectionForeground, setSelectionMode, setSelectionModel, setShowGrid, setShowHorizontalLines, setShowVerticalLines, setSurrendersFocusOnKeystroke, setTableHeader, setUI, setUpdateSelectionOnSort, setValueAt, sizeColumnsToFit, sizeColumnsToFit, sorterChanged, unconfigureEnclosingScrollPane, updateUI, valueChanged
     
    Methods inherited from class javax.swing.JComponent
    addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
     
    Methods inherited from class java.awt.Container
    add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree
     
    Methods inherited from class java.awt.Component
    action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusUpCycle
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
     

    Constructor Detail

    MiniTable

    public MiniTable()
    Default Constructor

    Method Detail

    autoSize

    public void autoSize()
    Size Columns. Uses Mimimum Column Size


    isCellEditable

    public boolean isCellEditable(int row,
                                  int column)
    Is Cell Editable

    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

    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

    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

    Parameters:
    header - header

    setColumnClass

    public void setColumnClass(int index,
                               Class c,
                               boolean readOnly)
    Set Column Editor & Renderer to Class. (after all columns were added)

    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

    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

    Parameters:
    no - number of rows

    loadTable

    public void loadTable(ResultSet rs)
    Load Table from ResultSet - The ResultSet is not closed

    Parameters:
    rs - ResultSet with the column layout defined in prepareTable

    loadTable

    public void loadTable(PO[] pos)
    Load Table from Object Array

    Parameters:
    pos - array of POs

    getSelectedRowKey

    public Integer getSelectedRowKey()
    Get the key of currently selected row based on layout defined in prepareTable

    Returns:
    ID if key

    getLayoutInfo

    public ColumnInfo[] getLayoutInfo()
    Get Layout

    Returns:
    Array of ColumnInfo

    setMultiSelection

    public void setMultiSelection(boolean multiSelection)
    Set Single Selection

    Parameters:
    multiSelection - multiple selections

    isMultiSelection

    public boolean isMultiSelection()
    Single Selection Table

    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

    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
      

    Parameters:
    row - row
    Returns:
    color code

    setShowTotals

    public void setShowTotals(boolean show)
    Set if Totals is Show

    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


    Adempiere 3.5.2a

    Adempiere® is a registered trademark of ADempiere Business Inc. ©2004-2008 HumanFlash.com All rights reserved.