Package docking.widgets.trable

# Class GTrable<T>

java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
docking.widgets.trable.GTrable<T>

Type Parameters:
  `T` - The row object type

All Implemented Interfaces:
  `GTrableModeRowlListener`, `ImageObserver`, `MenuContainer`, `Serializable`, `Scrollable`

public class GTrable<T> extends JComponent implements Scrollable, GTrableModeRowlListener
Component that combines the display of a tree and a table. Data is presented in columns like a table, but rows can have child rows like a tree which are displayed indented in the first column.

A GTrable uses two different models: a row model and a column model. The row model contains row objects that contains the data to be displayed on a given row. The column model specifies how to display the data in the row object as a series of column values.

The row model also provides information about the parent child relationship of rows. If the model reports that a row can be expanded, an expand control is show on that row. If the row is then expanded, the model will then report additional rows immediately below the parent row, pushing any existing rows further down (i.e. all rows below the row being opened have their row indexes increased by the number of rows added.)

See Also:
  - Serialized Form

- ## Nested Class Summary

  ## 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 javax.swing.JComponent

  `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

  `accessibleContext, 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

  Constructors
  Constructor
  Description
  `GTrable(GTrableRowModel<T> rowModel, GTrableColumnModel<T> columnModel)`
  Constructor

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addCellClickedListener(GTrableCellClickedListener listener)`
  Adds a listener to be notified if the user clicks on a cell in the GTrable.
  `void`
  `addSelectedRowConsumer(Consumer<Integer> consumer)`
  Adds a consumer to be notified when the selected row changes.
  `void`
  `clearSelectedRow()`
  Deselects any selected row
  `void`
  `collapseAll()`
  Collapses all rows.
  `void`
  `collapseRow(int rowIndex)`
  Collapse the row (remove any of its descendants) at the given row index.
  `void`
  `expandAll()`
  Expands all rows fully.
  `void`
  `expandRow(int rowIndex)`
  Expands the row at the given index.
  `void`
  `expandRowRecursively(int rowIndex)`
  Fully expands the given row and all its descendants.
  `Dimension`
  `getPreferredScrollableViewportSize()`
  `Dimension`
  `getPreferredSize()`
  `int`
  `getRow(Point p)`
  `int`
  `getRowHeight()`
  Returns the height of a row in the trable..
  `int`
  `getRowOffcut()`
  Returns the amount the view is scrolled such that the first line is not fully visible..
  `int`
  `getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)`
  `boolean`
  `getScrollableTracksViewportHeight()`
  `boolean`
  `getScrollableTracksViewportWidth()`
  `int`
  `getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)`
  `int`
  `getSelectedRow()`
  Returns the currently selected row or -1 if not row is selected..
  `Color`
  `getSelectionBackground()`
  Returns the selection background color.
  `Color`
  `getSelectionForeground()`
  Returns the selection foreground color.
  `Range`
  `getVisibleRows()`
  Returns the range of visible row indices..
  `void`
  `paint(Graphics g)`
  `void`
  `removeCellClickedListener(GTrableCellClickedListener listener)`
  Removes a cell clicked listener.
  `void`
  `removeSelectedRowConsumer(Consumer<Integer> consumer)`
  Removes the consumer to be notified when the selected row changes.
  `void`
  `scrollToSelectedRow()`
  Scrolls the view to make the currently selected row visible.
  `void`
  `setBounds(int x, int y, int width, int height)`
  `void`
  `setColumnModel(GTrableColumnModel<T> columnModel)`
  Sets a new column model.
  `void`
  `setPreferredVisibleRowCount(int minVisibleRows, int maxVisibleRows)`
  Sets the preferred number of visible rows to be displayed in the scrollable area.
  `void`
  `setRowModel(GTrableRowModel<T> newRowModel)`
  Sets a new row model.
  `void`
  `setSelectedRow(int rowIndex)`
  Sets the selected row to the given row index
  `void`
  `trableChanged()`
  Notification that the row model changed

  ### Methods inherited from class javax.swing.JComponent

  `addAncestorListener, addNotify, 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, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getUI, getUIClassID, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update, updateUI`

  ### Methods inherited from class java.awt.Container

  `add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, 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, 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, getAccessibleContext, 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, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- ## Constructor Details

  - ### GTrable

    public GTrable(GTrableRowModel<T> rowModel, GTrableColumnModel<T> columnModel)
    Constructor
    Parameters:
      `rowModel` - the model that provides the row data.
      `columnModel` - the model the provides the column information for displaying the data stored in the row data.

- ## Method Details

  - ### setRowModel

    public void setRowModel(GTrableRowModel<T> newRowModel)
    Sets a new row model.
    Parameters:
      `newRowModel` - the new row model to use

  - ### setColumnModel

    public void setColumnModel(GTrableColumnModel<T> columnModel)
    Sets a new column model.
    Parameters:
      `columnModel` - the new column model to use

  - ### setPreferredVisibleRowCount

    public void setPreferredVisibleRowCount(int minVisibleRows, int maxVisibleRows)
    Sets the preferred number of visible rows to be displayed in the scrollable area.
    Parameters:
      `minVisibleRows` - the minimum number of visible rows.
      `maxVisibleRows` - the maximum number of visible rows.

  - ### addCellClickedListener

    public void addCellClickedListener(GTrableCellClickedListener listener)
    Adds a listener to be notified if the user clicks on a cell in the GTrable.
    Parameters:
      `listener` - the listener to be notified

  - ### removeCellClickedListener

    public void removeCellClickedListener(GTrableCellClickedListener listener)
    Removes a cell clicked listener.
    Parameters:
      `listener` - the listener to be removed

  - ### addSelectedRowConsumer

    public void addSelectedRowConsumer(Consumer<Integer> consumer)
    Adds a consumer to be notified when the selected row changes.
    Parameters:
      `consumer` - the consumer to be notified when the selected row changes

  - ### removeSelectedRowConsumer

    public void removeSelectedRowConsumer(Consumer<Integer> consumer)
    Removes the consumer to be notified when the selected row changes.
    Parameters:
      `consumer` - the consumer to be removed

  - ### getPreferredSize

    public Dimension getPreferredSize()
    Overrides:
      `getPreferredSize` in class `JComponent`

  - ### paint

    public void paint(Graphics g)
    Overrides:
      `paint` in class `JComponent`

  - ### getVisibleRows

    public Range getVisibleRows()
    Returns the range of visible row indices..
    Returns:
      the range of visible row indices.

  - ### getSelectedRow

    public int getSelectedRow()
    Returns the currently selected row or -1 if not row is selected..
    Returns:
      the currently selected row or -1 if not row is selected.

  - ### setSelectedRow

    public void setSelectedRow(int rowIndex)
    Sets the selected row to the given row index
    Parameters:
      `rowIndex` - the row index to select

  - ### clearSelectedRow

    public void clearSelectedRow()
    Deselects any selected row

  - ### getSelectionForeground

    public Color getSelectionForeground()
    Returns the selection foreground color.
    Returns:
      the selection foreground color

  - ### getSelectionBackground

    public Color getSelectionBackground()
    Returns the selection background color.
    Returns:
      the selection background color

  - ### getRowHeight

    public int getRowHeight()
    Returns the height of a row in the trable..
    Returns:
      the height of a row in the trable.

  - ### getRowOffcut

    public int getRowOffcut()
    Returns the amount the view is scrolled such that the first line is not fully visible..
    Returns:
      the amount the view is scrolled such that the first line is not fully visible.

  - ### getPreferredScrollableViewportSize

    public Dimension getPreferredScrollableViewportSize()
    Specified by:
      `getPreferredScrollableViewportSize` in interface `Scrollable`

  - ### getScrollableUnitIncrement

    public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction)
    Specified by:
      `getScrollableUnitIncrement` in interface `Scrollable`

  - ### getScrollableBlockIncrement

    public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction)
    Specified by:
      `getScrollableBlockIncrement` in interface `Scrollable`

  - ### getScrollableTracksViewportWidth

    public boolean getScrollableTracksViewportWidth()
    Specified by:
      `getScrollableTracksViewportWidth` in interface `Scrollable`

  - ### getScrollableTracksViewportHeight

    public boolean getScrollableTracksViewportHeight()
    Specified by:
      `getScrollableTracksViewportHeight` in interface `Scrollable`

  - ### expandRow

    public void expandRow(int rowIndex)
    Expands the row at the given index.
    Parameters:
      `rowIndex` - the index of the row to expand

  - ### collapseRow

    public void collapseRow(int rowIndex)
    Collapse the row (remove any of its descendants) at the given row index.
    Parameters:
      `rowIndex` - the index of the row to collapse

  - ### expandRowRecursively

    public void expandRowRecursively(int rowIndex)
    Fully expands the given row and all its descendants.
    Parameters:
      `rowIndex` - the index of the row to fully expand

  - ### expandAll

    public void expandAll()
    Expands all rows fully.

  - ### collapseAll

    public void collapseAll()
    Collapses all rows.

  - ### scrollToSelectedRow

    public void scrollToSelectedRow()
    Scrolls the view to make the currently selected row visible.

  - ### trableChanged

    public void trableChanged()
    Description copied from interface: `GTrableModeRowlListener`
    Notification that the row model changed
    Specified by:
      `trableChanged` in interface `GTrableModeRowlListener`

  - ### setBounds

    public void setBounds(int x, int y, int width, int height)
    Overrides:
      `setBounds` in class `Component`

  - ### getRow

    public int getRow(Point p)