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
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:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested 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_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH -
Constructor Summary
ConstructorsConstructorDescriptionGTrable(GTrableRowModel<T> rowModel, GTrableColumnModel<T> columnModel) Constructor -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener to be notified if the user clicks on a cell in the GTrable.voidaddSelectedRowConsumer(Consumer<Integer> consumer) Adds a consumer to be notified when the selected row changes.voidDeselects any selected rowvoidCollapses all rows.voidcollapseRow(int rowIndex) Collapse the row (remove any of its descendants) at the given row index.voidExpands all rows fully.voidexpandRow(int rowIndex) Expands the row at the given index.voidexpandRowRecursively(int rowIndex) Fully expands the given row and all its descendants.intintReturns the height of a row in the trable..intReturns the amount the view is scrolled such that the first line is not fully visible..intgetScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) booleanbooleanintgetScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) intReturns the currently selected row or -1 if not row is selected..Returns the selection background color.Returns the selection foreground color.Returns the range of visible row indices..voidvoidRemoves a cell clicked listener.voidremoveSelectedRowConsumer(Consumer<Integer> consumer) Removes the consumer to be notified when the selected row changes.voidScrolls the view to make the currently selected row visible.voidsetBounds(int x, int y, int width, int height) voidsetColumnModel(GTrableColumnModel<T> columnModel) Sets a new column model.voidsetPreferredVisibleRowCount(int minVisibleRows, int maxVisibleRows) Sets the preferred number of visible rows to be displayed in the scrollable area.voidsetRowModel(GTrableRowModel<T> newRowModel) Sets a new row model.voidsetSelectedRow(int rowIndex) Sets the selected row to the given row indexvoidNotification that the row model changedMethods 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, updateUIMethods 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, validateTreeMethods 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
-
Constructor Details
-
GTrable
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
Sets a new row model.- Parameters:
newRowModel- the new row model to use
-
setColumnModel
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
Adds a listener to be notified if the user clicks on a cell in the GTrable.- Parameters:
listener- the listener to be notified
-
removeCellClickedListener
Removes a cell clicked listener.- Parameters:
listener- the listener to be removed
-
addSelectedRowConsumer
Adds a consumer to be notified when the selected row changes.- Parameters:
consumer- the consumer to be notified when the selected row changes
-
removeSelectedRowConsumer
Removes the consumer to be notified when the selected row changes.- Parameters:
consumer- the consumer to be removed
-
getPreferredSize
- Overrides:
getPreferredSizein classJComponent
-
paint
- Overrides:
paintin classJComponent
-
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
Returns the selection foreground color.- Returns:
- the selection foreground 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
- Specified by:
getPreferredScrollableViewportSizein interfaceScrollable
-
getScrollableUnitIncrement
- Specified by:
getScrollableUnitIncrementin interfaceScrollable
-
getScrollableBlockIncrement
- Specified by:
getScrollableBlockIncrementin interfaceScrollable
-
getScrollableTracksViewportWidth
public boolean getScrollableTracksViewportWidth()- Specified by:
getScrollableTracksViewportWidthin interfaceScrollable
-
getScrollableTracksViewportHeight
public boolean getScrollableTracksViewportHeight()- Specified by:
getScrollableTracksViewportHeightin interfaceScrollable
-
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:GTrableModeRowlListenerNotification that the row model changed- Specified by:
trableChangedin interfaceGTrableModeRowlListener
-
setBounds
public void setBounds(int x, int y, int width, int height) -
getRow
-