Class ValidatedTablePanel<T>
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- io.github.jonestimd.swing.component.MenuActionPanel
-
- io.github.jonestimd.swing.component.ValidatedPanel
-
- io.github.jonestimd.swing.component.ValidatedTablePanel<T>
-
- Type Parameters:
T
- class of the beans in theValidatedBeanListTableModel
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
public abstract class ValidatedTablePanel<T> extends ValidatedPanel
AValidatedPanel
that displays aDecoratedTable
(for aValidatedBeanListTableModel
) and aTableSummaryPanel
. The following actions are added to a toolbar on the frame's menu bar. The actions are initialized using the specified resources from the resource bundle.Action Description Resource Bundle Keys Add add a new row to the table resourceGroup.action.new.mnemonicAndName resourceGroup.action.new.iconImage resourceGroup.action.new.accelerator (optional) Delete mark a row as pending deletion resourceGroup.action.delete.mnemonicAndName resourceGroup.action.delete.iconImage resourceGroup.action.delete.accelerator (optional) Save save pending changes Reload reload the table data and discard pending changes resourceGroup.action.reload.mnemonicAndName resourceGroup.action.reload.iconImage resourceGroup.action.reload.accelerator (optional) resourceGroup.action.reload.status.initialize (optional) If the resource bundle contains the key resourceGroup.menu.mnemonicAndName then the actions are also added to the specified menu on the frame's menu bar.
This panel includes a table model listener that enables/disables the save action and that notifies an ancestor container that implements
UnsavedChangesIndicator
(e.g. aStatusFrame
).- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.ResourceBundle
bundle
protected java.lang.String
resourceGroup
-
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
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
ValidatedTablePanel(java.util.ResourceBundle bundle, DecoratedTable<T,? extends ValidatedBeanListTableModel<T>> table, java.lang.String resourceGroup)
Constructs a newValidatedTablePanel
using resources frombundle
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addActions(javax.swing.JMenu menu)
Adds theadd
,delete
,save
andreload
actions to the menu.protected void
addActions(javax.swing.JToolBar toolbar)
Adds theadd
,delete
,save
andreload
actions to the toolbar.void
addSummaries(TableSummary tableSummary)
Add an item to the summary panel.protected abstract java.util.List<T>
confirmDelete(java.util.List<T> items)
Override to confirm deleting items from the table.protected abstract javax.swing.Action
createSaveAction()
protected javax.swing.JToolBar
createToolBar()
Creates the toolbar to add to the frame's menu bar.protected ChangeBuffer
getChangeBuffer()
protected javax.swing.table.TableRowSorter<ValidatedBeanListTableModel<T>>
getRowSorter()
T
getSelectedBean()
protected java.util.List<T>
getSelectionMinusPendingDeletes()
protected DecoratedTable<T,? extends ValidatedBeanListTableModel<T>>
getTable()
protected abstract java.util.List<T>
getTableData()
Override to return the table data.ValidatedBeanListTableModel<T>
getTableModel()
protected void
initializeMenu(javax.swing.JMenuBar menuBar)
Adds a menu and toolbar to the frame's menu bar.protected boolean
isDeleteEnabled(java.util.List<T> selectionMinusPendingDeletes)
protected boolean
isSingleRowSelected()
protected abstract T
newBean()
Override to create a bean for a new row in the table.protected void
tableSelectionChanged()
Updates the enabled state of actions.-
Methods inherited from class io.github.jonestimd.swing.component.ValidatedPanel
addNotify, confirmClose
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
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, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, 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
-
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, 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
-
-
-
-
Constructor Detail
-
ValidatedTablePanel
protected ValidatedTablePanel(java.util.ResourceBundle bundle, DecoratedTable<T,? extends ValidatedBeanListTableModel<T>> table, java.lang.String resourceGroup)
Constructs a newValidatedTablePanel
using resources frombundle
.- Parameters:
bundle
- the resource bundle to use for UI componentstable
- the table to include on the panelresourceGroup
- a string used to look up component resources
-
-
Method Detail
-
createSaveAction
protected abstract javax.swing.Action createSaveAction()
-
getRowSorter
protected javax.swing.table.TableRowSorter<ValidatedBeanListTableModel<T>> getRowSorter()
-
addSummaries
public void addSummaries(TableSummary tableSummary)
Add an item to the summary panel.- Parameters:
tableSummary
- the summary item
-
getTableModel
public ValidatedBeanListTableModel<T> getTableModel()
-
getTable
protected DecoratedTable<T,? extends ValidatedBeanListTableModel<T>> getTable()
-
newBean
protected abstract T newBean()
Override to create a bean for a new row in the table.- Returns:
- the new bean
-
confirmDelete
protected abstract java.util.List<T> confirmDelete(java.util.List<T> items)
Override to confirm deleting items from the table. The input list can be modified and used as the return value. Only items in the returned list will actually be deleted.- Parameters:
items
- the items selected for deletion.- Returns:
- the items that have been confirmed for deletion
-
isDeleteEnabled
protected boolean isDeleteEnabled(java.util.List<T> selectionMinusPendingDeletes)
-
getSelectionMinusPendingDeletes
protected java.util.List<T> getSelectionMinusPendingDeletes()
-
initializeMenu
protected void initializeMenu(javax.swing.JMenuBar menuBar)
Adds a menu and toolbar to the frame's menu bar.- Specified by:
initializeMenu
in classMenuActionPanel
- Parameters:
menuBar
- the frame's menu bar- See Also:
addActions(JMenu)
,addActions(JToolBar)
-
createToolBar
protected javax.swing.JToolBar createToolBar()
Creates the toolbar to add to the frame's menu bar.- Returns:
- the new toolbar
- See Also:
addActions(JToolBar)
-
addActions
protected void addActions(javax.swing.JToolBar toolbar)
Adds theadd
,delete
,save
andreload
actions to the toolbar.- Parameters:
toolbar
- the toolbar on the frame's menu bar
-
addActions
protected void addActions(javax.swing.JMenu menu)
Adds theadd
,delete
,save
andreload
actions to the menu.- Parameters:
menu
- the menu from the frame's menu bar
-
getChangeBuffer
protected ChangeBuffer getChangeBuffer()
- Specified by:
getChangeBuffer
in classValidatedPanel
-
isSingleRowSelected
protected boolean isSingleRowSelected()
-
getSelectedBean
public T getSelectedBean()
-
getTableData
protected abstract java.util.List<T> getTableData()
Override to return the table data.
-
tableSelectionChanged
protected void tableSelectionChanged()
Updates the enabled state of actions. May be overridden to handle changes to table selection.
-
-