Package com.illumon.iris.gui.table
Class GuiTable
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JTable
com.illumon.iris.gui.table.GuiTable
- All Implemented Interfaces:
Workspace
,ImageObserver
,MenuContainer
,Serializable
,EventListener
,Accessible
,CellEditorListener
,ListSelectionListener
,RowSorterListener
,TableColumnModelListener
,TableModelListener
,Scrollable
- Direct Known Subclasses:
InputOverlayTable
,InputRowsTable
,IrisTable
public class GuiTable extends JTable implements Workspace
A basic UI table backed by a
WColumnSet
and IrisTableModel
- See Also:
- Serialized Form
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GuiTable.AlertStyle
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.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
-
Field Summary
Fields Modifier and Type Field Description protected com.fishlib.dataobjects.WColumnSet
columnSet_
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
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 GuiTable(com.fishlib.io.logger.Logger log)
Create a blank GuiTable.GuiTable(com.fishlib.io.logger.Logger log, IrisTableModel model)
GuiTable(com.fishlib.io.logger.Logger log, IrisTableModel model, TableColumnModel columnModel)
-
Method Summary
Modifier and Type Method Description protected boolean
areSavedLayoutsAllowed()
void
changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend)
protected void
convertTableColumns(org.jdom2.Element tableInfo)
static HiddenColumnModel
createDefaultColumnModel(com.fishlib.dataobjects.WColumnSet wColumnSet)
protected JTableHeader
createDefaultTableHeader()
JMenu
createFilterMenu(GuiColumn column, FilterStrategyImpl filterStrategy)
Creates a menu for the Filter by...static TableColumn
createTableColumn(GuiColumn column, int modelIndex)
protected TransferHandler
createTransferHandler()
Creates the transfer handler.static String
generateToolTip(int col, TableModel model, GuiColumn column)
boolean
getAlertsPropagate()
Get if alerts should propagate up through the tabs.GuiTable.AlertStyle
getAlertStyle()
protected Set<String>
getAutoFilterColumns()
protected Set<String>
getBackColumns()
com.fishlib.dataobjects.WColumnSet
getColumnSet()
protected Set<String>
getFreezeColumns()
FreezeColumnsManager
getFreezeColumnsManager()
Gets the FreezeColumnsManager.protected Set<String>
getFrontColumns()
Color
getGridColor()
String
getHeaderToolTipText(MouseEvent e)
protected Set<String>
getHiddenColumns()
TableCellRenderer
getOriginalRenderer()
IrisTableModel
getOriginalTableModel()
int
getRowHeight()
int
getSelectedRow()
int[]
getSelectedRows()
TableBounds
getViewableCells()
org.jdom2.Element
getWorkspaceInfo()
Serialize the class into an element to be stored in the workspaceprotected void
handleUnmentionedColumns(HiddenColumnModel columnModel, Set<TableColumn> unmentionedColumns, Collection<String> initialHiddenColumns)
Handle any columns that have not been visited by the current column ordering.boolean
isAlertsOn()
Get if table changes will alert the user.boolean
isFollowingTable()
Get if the table will scroll with new items added.boolean
isOneClickOn()
Get if the table should respond to OneClick eventsprotected void
maybeAddSelectionModel()
void
paint(Graphics g)
void
processDoubleClick(int row, int col, MouseEvent e)
Process a double click.protected void
processHeaderClick(int col, MouseEvent e)
Process a header single or double click.protected void
processSingleClick(int row, int col, MouseEvent e)
Process a single click.void
resetColumns()
Reset the state of the columns (order, hidden, locked, etc) to the state defined by the query.int
rowAtPoint(Point point)
We want to make sure that if we're actually negative we can differentiate that from running off the end of the table, so instead we return -2 instead of -1 in that case.void
scrollToCenter(int row)
Scroll a specific row to the center of the view.void
scrollToRow(int row)
Scroll a specific row to the top of the view.void
setAlertsOn(boolean alertsOn)
Set if table changes should alert the user.void
setAlertsPropagate(boolean alertsPropagate)
Set if the alerts should propagate up through the tabs.void
setAlertsStyle(GuiTable.AlertStyle alertStyle)
protected void
setColumnFormatter(String columnName, org.jdom2.Element formatInfo)
Sets the column formatter from workspace info.void
setDefaultAlert(boolean defaultAlert)
void
setFollowTable(boolean followTable)
Set if the table view should follow new rows that are added.void
setFreezeColumnsManager(FreezeColumnsManager freezeColumnsManager)
Sets the FreezeColumnsManager to allow this GuiTable to support Freeze Columns.void
setModel(IrisTableModel model)
protected void
setModel(IrisTableModel model, TableColumnModel columnModel)
void
setOneClickOn(boolean oneClickOn)
Set if the table should respond to OneClick events.void
setTableDescription(String tableDescription)
void
setTableHeader(JTableHeader tableHeader)
void
setWorkspaceInfo(org.jdom2.Element workspaceInfo)
Restore the class to the state defined by the data persisted in workspaceInfoboolean
shouldSelectAlert(GuiTable.AlertStyle alertStyle)
void
tableChanged(TableModelEvent e)
void
updateColumns()
Called when the table changes in order to properly process updates to columns.protected static boolean
workspaceHasFreezeColumns(org.jdom2.Element workspaceInfo)
Indicates if a workspace element contains freeze columns.Methods inherited from class javax.swing.JTable
addColumn, addColumnSelectionInterval, addNotify, addRowSelectionInterval, clearSelection, columnAdded, columnAtPoint, columnMarginChanged, columnMoved, columnRemoved, columnSelectionChanged, configureEnclosingScrollPane, convertColumnIndexToModel, convertColumnIndexToView, convertRowIndexToModel, convertRowIndexToView, createDefaultColumnModel, createDefaultColumnsFromModel, createDefaultDataModel, createDefaultEditors, createDefaultRenderers, createDefaultSelectionModel, 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, getIntercellSpacing, getModel, getPreferredScrollableViewportSize, getPrintable, getRowCount, getRowHeight, getRowMargin, getRowSelectionAllowed, getRowSorter, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedColumn, getSelectedColumnCount, getSelectedColumns, getSelectedRowCount, getSelectionBackground, getSelectionForeground, getSelectionModel, getShowHorizontalLines, getShowVerticalLines, getSurrendersFocusOnKeystroke, getTableHeader, getToolTipText, getUI, getUIClassID, getUpdateSelectionOnSort, getValueAt, initializeLocalVars, isCellEditable, isCellSelected, isColumnSelected, isEditing, isRowSelected, moveColumn, paramString, prepareEditor, prepareRenderer, print, print, print, print, print, processKeyBinding, removeColumn, removeColumnSelectionInterval, removeEditor, removeNotify, removeRowSelectionInterval, resizeAndRepaint, 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, 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, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, 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, setFont, 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, 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, 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, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
columnSet_
protected com.fishlib.dataobjects.WColumnSet columnSet_
-
-
Constructor Details
-
GuiTable
public GuiTable(com.fishlib.io.logger.Logger log)Create a blank GuiTable. Note that users MUST callsetModel(IrisTableModel)
for it to function properly. -
GuiTable
-
GuiTable
public GuiTable(com.fishlib.io.logger.Logger log, IrisTableModel model, TableColumnModel columnModel)
-
-
Method Details
-
setModel
-
setModel
-
getOriginalRenderer
-
setFreezeColumnsManager
Sets the FreezeColumnsManager to allow this GuiTable to support Freeze Columns.- Parameters:
freezeColumnsManager
- the FreezeColumnsManager
-
getFreezeColumnsManager
Gets the FreezeColumnsManager. This will be null if the table does no support Freeze Columns.- Returns:
- the FreezeColumnsManager, null if Freeze Columns are not supported
-
createTransferHandler
Creates the transfer handler.- Returns:
- the transfer handler
-
createDefaultColumnModel
public static HiddenColumnModel createDefaultColumnModel(com.fishlib.dataobjects.WColumnSet wColumnSet) -
maybeAddSelectionModel
protected void maybeAddSelectionModel() -
changeSelection
public void changeSelection(int rowIndex, int columnIndex, boolean toggle, boolean extend)- Overrides:
changeSelection
in classJTable
-
getSelectedRow
public int getSelectedRow()- Overrides:
getSelectedRow
in classJTable
-
createDefaultTableHeader
- Overrides:
createDefaultTableHeader
in classJTable
-
getHeaderToolTipText
-
generateToolTip
-
getColumnSet
public com.fishlib.dataobjects.WColumnSet getColumnSet() -
getOriginalTableModel
-
createTableColumn
-
getGridColor
- Overrides:
getGridColor
in classJTable
-
setTableHeader
- Overrides:
setTableHeader
in classJTable
-
getRowHeight
public int getRowHeight()- Overrides:
getRowHeight
in classJTable
-
getSelectedRows
public int[] getSelectedRows()- Overrides:
getSelectedRows
in classJTable
-
getViewableCells
- Returns:
- TableBounds of the viewable cells or TableBounds.EMPTY if no viewable cells
-
rowAtPoint
We want to make sure that if we're actually negative we can differentiate that from running off the end of the table, so instead we return -2 instead of -1 in that case.- Overrides:
rowAtPoint
in classJTable
-
processSingleClick
Process a single click. The base method does nothing and may be overridden.- Parameters:
row
- The row clicked.col
- The column clicked.e
- The details of the click event.
-
processDoubleClick
Process a double click. The base method does nothing and may be overridden.- Parameters:
row
- The row clicked.col
- The column clicked.e
- The details of the click event.
-
processHeaderClick
Process a header single or double click. The base method creates aTableHeaderPopup
but may be overridden.- Parameters:
col
- The column clicked.e
- The details of the click event.
-
isAlertsOn
public boolean isAlertsOn()Get if table changes will alert the user. -
setAlertsOn
public void setAlertsOn(boolean alertsOn)Set if table changes should alert the user. -
isOneClickOn
public boolean isOneClickOn()Get if the table should respond to OneClick events -
setOneClickOn
public void setOneClickOn(boolean oneClickOn)Set if the table should respond to OneClick events. -
isFollowingTable
public boolean isFollowingTable()Get if the table will scroll with new items added. -
setFollowTable
public void setFollowTable(boolean followTable)Set if the table view should follow new rows that are added.- Parameters:
followTable
-
-
getAlertsPropagate
public boolean getAlertsPropagate()Get if alerts should propagate up through the tabs.- Returns:
-
setAlertsPropagate
public void setAlertsPropagate(boolean alertsPropagate)Set if the alerts should propagate up through the tabs.- Parameters:
alertsPropagate
-
-
getAlertStyle
-
setAlertsStyle
-
shouldSelectAlert
-
setDefaultAlert
public void setDefaultAlert(boolean defaultAlert) -
scrollToRow
public void scrollToRow(int row)Scroll a specific row to the top of the view.- Parameters:
row
- The row to scroll into view.
-
scrollToCenter
public void scrollToCenter(int row)Scroll a specific row to the center of the view.- Parameters:
row
- The roll to center.
-
tableChanged
- Specified by:
tableChanged
in interfaceTableModelListener
- Overrides:
tableChanged
in classJTable
-
updateColumns
public void updateColumns()Called when the table changes in order to properly process updates to columns.
Handles the following column updates:
- preserve current order
- keep hidden columns hidden
- add new columns to the end
- replace columns that are the "same"
- remove missing columns
- fix renderers of the wrong column typeSubclasses may override this method to add additional updates to columns. It is recommended to call super.updateColumns() before operating on columns.
-
getWorkspaceInfo
public org.jdom2.Element getWorkspaceInfo()Description copied from interface:Workspace
Serialize the class into an element to be stored in the workspace- Specified by:
getWorkspaceInfo
in interfaceWorkspace
- Returns:
- An
Element
containing the data to persist.
-
setWorkspaceInfo
public void setWorkspaceInfo(org.jdom2.Element workspaceInfo)Description copied from interface:Workspace
Restore the class to the state defined by the data persisted in workspaceInfo- Specified by:
setWorkspaceInfo
in interfaceWorkspace
- Parameters:
workspaceInfo
- AnElement
containing the persisted state.
-
workspaceHasFreezeColumns
protected static boolean workspaceHasFreezeColumns(org.jdom2.Element workspaceInfo)Indicates if a workspace element contains freeze columns.- Parameters:
workspaceInfo
- the workspace element to check- Returns:
- true if it contains freeze columns, false otherwise
-
convertTableColumns
protected void convertTableColumns(org.jdom2.Element tableInfo) -
handleUnmentionedColumns
protected void handleUnmentionedColumns(HiddenColumnModel columnModel, Set<TableColumn> unmentionedColumns, Collection<String> initialHiddenColumns)Handle any columns that have not been visited by the current column ordering. When this method is invoked all layout hints including atFront() and atBack() have been evaluated. The default implementation simply places them at the end of the current order.- Parameters:
columnModel
- The modelunmentionedColumns
- The columns that have not yet been inserted into the orderinitialHiddenColumns
- The columns which were explicitly hidden
-
setColumnFormatter
Sets the column formatter from workspace info. The default implementation does nothing but subclasses should override this method to create the correct concrete formatter.- Parameters:
columnName
- the name of the columnformatInfo
- element containing workspace info
-
resetColumns
public void resetColumns()Reset the state of the columns (order, hidden, locked, etc) to the state defined by the query. It will _not_ respect the same settings from the workspace. -
areSavedLayoutsAllowed
protected boolean areSavedLayoutsAllowed() -
getFrontColumns
-
getBackColumns
-
getAutoFilterColumns
-
getFreezeColumns
-
setTableDescription
-
getHiddenColumns
-
createFilterMenu
Creates a menu for the Filter by... option.- Parameters:
column
- the column to filterfilterStrategy
- the filter strategy for the model- Returns:
- a new filter menu
-
paint
- Overrides:
paint
in classJComponent
-