Class AbstractCRUDTable<T>
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- com.inductiveautomation.ignition.client.util.gui.AbstractCRUDTable<T>
-
- All Implemented Interfaces:
java.awt.image.ImageObserver
,java.awt.MenuContainer
,java.io.Serializable
,javax.accessibility.Accessible
- Direct Known Subclasses:
TermTable
public abstract class AbstractCRUDTable<T> extends javax.swing.JPanel
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
AbstractCRUDTable.Column<C>
protected class
AbstractCRUDTable.CRUDModel
-
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.List<javax.swing.JButton>
actions
protected javax.swing.Action
addAction
protected javax.swing.Action
deleteAction
protected com.inductiveautomation.ignition.client.util.gui.AbstractCRUDTable.DeleteConfirm
deleteConfirmPanel
protected javax.swing.Action
downAction
protected javax.swing.Action
editAction
protected LoadingIcon
loadingIcon
protected javax.swing.JLabel
loadingOverlay
protected LoggerEx
log
protected AbstractCRUDTable.CRUDModel
model
protected boolean
requireConfirmOnDelete
protected javax.swing.JScrollPane
scrollPane
protected TouchscreenTable
table
protected java.util.List<AbstractCRUDTable.Column<?>>
tableColumns
protected javax.swing.Action
upAction
protected java.beans.PropertyChangeListener
updatePCL
A property change listener that simply calls update()-
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
AbstractCRUDTable()
protected
AbstractCRUDTable(boolean initialize)
If initialize is false, the sub class must make sure to call initialize() in order to actually build the component.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected boolean
canAdd()
protected boolean
canDelete()
protected boolean
canEdit()
protected javax.swing.JButton
createToolbarButton(javax.swing.Action action)
protected javax.swing.Icon
getAddIcon()
protected javax.swing.Icon
getDeleteIcon()
protected javax.swing.Icon
getDownIcon()
protected javax.swing.Icon
getEditIcon()
java.awt.Color
getHeaderBackground()
Gets the table's header background color.java.awt.Color
getHeaderTextColor()
Gets the table's header text color.java.util.List<T>
getItems()
protected abstract java.lang.String
getNoun()
Return the noun that describes the item being manipulated.java.util.List<T>
getSelected()
Returns a list of the selected itemsjavax.swing.JTable
getTable()
Getter for the internalJTable
java.awt.Color
getTableBackground()
Gets the table's background color.java.awt.Color
getTableForeground()
Gets the table's text color.protected javax.swing.Icon
getUpIcon()
protected void
handleLoadingError(java.lang.Exception ex)
Called on the EDT if items() throws an exceptionprotected void
initActions()
Create the addAction, editAction, and deleteActionprotected abstract void
initColumns(java.util.List<AbstractCRUDTable.Column<?>> columns)
Add your columns to the listprotected void
initialize(boolean callUpdate)
This sets up the UI.protected void
initLayout()
protected LoggerEx
initLogger()
protected AbstractCRUDTable.CRUDModel
initModel(java.util.List<AbstractCRUDTable.Column<?>> columns)
protected javax.swing.JScrollPane
initScrollPane(javax.swing.JTable table)
protected TouchscreenTable
initTable(javax.swing.table.TableModel model)
protected abstract java.util.Collection<T>
items()
Load the available items.protected java.lang.String
migInsets()
protected abstract void
onAdd()
Callback when the add action is pressed.protected void
onAfterLoad()
Called on the EDT after the table has re-loaded rows.protected void
onBeforeLoad()
Called on the EDT before the table re-loads its rowsprotected abstract void
onDelete(java.util.List<T> toDelete)
Callback when the delete action is pressed.protected void
onDoubleClick()
By default, simply calls onEdit if editing is allowedprotected abstract void
onEdit(java.util.List<T> toEdit)
Callback when the edit action is pressed.protected void
onMoveDown(T toMove)
protected void
onMoveUp(T toMove)
protected boolean
ordered()
Override this to have up and down arrowsvoid
setEnabled(boolean enabled)
void
setFont(java.awt.Font font)
void
setHeaderBackground(java.awt.Color color)
Sets the header background to this table.void
setHeaderTextColor(java.awt.Color color)
Sets the header text color to this table.void
setRowHeight(int height)
Sets the height of the rows of the child tablevoid
setTableBackground(java.awt.Color color)
Sets the background to this table.void
setTableForeground(java.awt.Color color)
Sets the text color to this table.void
setWindowBackground(java.awt.Color color)
Sets the background color of the window to the passedColor
.void
setWindowForeground(java.awt.Color color)
Sets the text color of the window to the passedColor
.void
update()
Call this when the item list has changed and needs to be reloadedprotected void
updateAddText(java.lang.String message)
void
updateColumns()
Call this if you have altered the columns (for example, changing visibility)protected void
updateDeleteConfirm(java.lang.String message, java.lang.String yesText, java.lang.String noText, LoggerEx log)
protected void
updateDeleteText(java.lang.String message)
protected void
updateDownText(java.lang.String message)
protected void
updateEditText(java.lang.String message)
void
updateEnabled()
Call to update the enabled-ness of the button actions.void
updateModel()
Rebuilds the columns and the model.protected void
updateUpText(java.lang.String message)
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI
-
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, 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, 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, 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
-
-
-
-
Field Detail
-
model
protected AbstractCRUDTable.CRUDModel model
-
scrollPane
protected javax.swing.JScrollPane scrollPane
-
table
protected TouchscreenTable table
-
tableColumns
protected java.util.List<AbstractCRUDTable.Column<?>> tableColumns
-
loadingIcon
protected LoadingIcon loadingIcon
-
loadingOverlay
protected javax.swing.JLabel loadingOverlay
-
deleteConfirmPanel
protected com.inductiveautomation.ignition.client.util.gui.AbstractCRUDTable.DeleteConfirm deleteConfirmPanel
-
addAction
protected javax.swing.Action addAction
-
editAction
protected javax.swing.Action editAction
-
deleteAction
protected javax.swing.Action deleteAction
-
upAction
protected javax.swing.Action upAction
-
downAction
protected javax.swing.Action downAction
-
requireConfirmOnDelete
protected boolean requireConfirmOnDelete
-
actions
protected java.util.List<javax.swing.JButton> actions
-
log
protected LoggerEx log
-
updatePCL
protected java.beans.PropertyChangeListener updatePCL
A property change listener that simply calls update()
-
-
Constructor Detail
-
AbstractCRUDTable
protected AbstractCRUDTable()
-
AbstractCRUDTable
protected AbstractCRUDTable(boolean initialize)
If initialize is false, the sub class must make sure to call initialize() in order to actually build the component.On a side note, if the subclass does not want "update" to be called immediately, it must pass false to this function, and then manually call initialize, passing in "false" for the "call update" argument.
-
-
Method Detail
-
initialize
protected void initialize(boolean callUpdate)
This sets up the UI. Only call it once.
-
initLogger
protected LoggerEx initLogger()
-
updateEnabled
public void updateEnabled()
Call to update the enabled-ness of the button actions. Automatically called when the selection changes.
-
setEnabled
public void setEnabled(boolean enabled)
- Overrides:
setEnabled
in classjavax.swing.JComponent
-
getNoun
protected abstract java.lang.String getNoun()
Return the noun that describes the item being manipulated.
-
initColumns
protected abstract void initColumns(java.util.List<AbstractCRUDTable.Column<?>> columns)
Add your columns to the list
-
initModel
protected AbstractCRUDTable.CRUDModel initModel(java.util.List<AbstractCRUDTable.Column<?>> columns)
-
initTable
protected TouchscreenTable initTable(javax.swing.table.TableModel model)
-
initScrollPane
protected javax.swing.JScrollPane initScrollPane(javax.swing.JTable table)
-
getAddIcon
protected javax.swing.Icon getAddIcon()
-
getEditIcon
protected javax.swing.Icon getEditIcon()
-
getDeleteIcon
protected javax.swing.Icon getDeleteIcon()
-
getUpIcon
protected javax.swing.Icon getUpIcon()
-
getDownIcon
protected javax.swing.Icon getDownIcon()
-
initActions
protected void initActions()
Create the addAction, editAction, and deleteAction
-
updateAddText
protected void updateAddText(java.lang.String message)
-
updateEditText
protected void updateEditText(java.lang.String message)
-
updateDeleteText
protected void updateDeleteText(java.lang.String message)
-
updateUpText
protected void updateUpText(java.lang.String message)
-
updateDownText
protected void updateDownText(java.lang.String message)
-
updateDeleteConfirm
protected void updateDeleteConfirm(java.lang.String message, java.lang.String yesText, java.lang.String noText, LoggerEx log)
-
createToolbarButton
protected javax.swing.JButton createToolbarButton(javax.swing.Action action)
-
initLayout
protected void initLayout()
-
migInsets
protected java.lang.String migInsets()
-
setFont
public void setFont(java.awt.Font font)
- Overrides:
setFont
in classjavax.swing.JComponent
-
setWindowBackground
public void setWindowBackground(java.awt.Color color)
Sets the background color of the window to the passedColor
.- Parameters:
color
- theColor
the window is to be set to. Must not be null.
-
setWindowForeground
public void setWindowForeground(java.awt.Color color)
Sets the text color of the window to the passedColor
.- Parameters:
color
- theColor
the windows text is to be set to. Must not be null.
-
setHeaderBackground
public void setHeaderBackground(java.awt.Color color)
Sets the header background to this table. This is here for setting this components color via a property.- Parameters:
color
- the specified color. Must not be null
-
setHeaderTextColor
public void setHeaderTextColor(java.awt.Color color)
Sets the header text color to this table. This is here for setting this components color via a property.- Parameters:
color
- the specified color. Must not be null
-
setTableBackground
public void setTableBackground(java.awt.Color color)
Sets the background to this table. This is here for setting this components color via a property.- Parameters:
color
- the specified color. Must not be null
-
setTableForeground
public void setTableForeground(java.awt.Color color)
Sets the text color to this table. This is here for setting this components color via a property.- Parameters:
color
- the specified color. Must not be null
-
getHeaderBackground
public java.awt.Color getHeaderBackground()
Gets the table's header background color. This is here for setting this components color via a property.- Returns:
- the table's header background color. Will not be null
-
getHeaderTextColor
public java.awt.Color getHeaderTextColor()
Gets the table's header text color. This is here for setting this components color via a property.- Returns:
- the table's header text color. Will not be null
-
getTableBackground
public java.awt.Color getTableBackground()
Gets the table's background color. This is here for setting this components color via a property.- Returns:
- the table's background color. Will not be null
-
getTableForeground
public java.awt.Color getTableForeground()
Gets the table's text color. This is here for setting this components color via a property.- Returns:
- the table's text color. Will not be null
-
getSelected
public java.util.List<T> getSelected()
Returns a list of the selected items
-
getItems
public java.util.List<T> getItems()
-
canAdd
protected boolean canAdd()
- Returns:
- if adding an item is currently available
-
canEdit
protected boolean canEdit()
- Returns:
- if editing an item is currently available
-
canDelete
protected boolean canDelete()
- Returns:
- if deleting an item is currently available
-
ordered
protected boolean ordered()
Override this to have up and down arrows
-
onAdd
protected abstract void onAdd()
Callback when the add action is pressed. Take some action to add an item, and later call update()
-
onEdit
protected abstract void onEdit(java.util.List<T> toEdit)
Callback when the edit action is pressed. Take some action to edit the item(s), and later call update()
-
onDelete
protected abstract void onDelete(java.util.List<T> toDelete)
Callback when the delete action is pressed. Take some action to edit the item(s), and later call update()
-
onDoubleClick
protected void onDoubleClick()
By default, simply calls onEdit if editing is allowed
-
onMoveUp
protected void onMoveUp(T toMove)
-
onMoveDown
protected void onMoveDown(T toMove)
-
onAfterLoad
protected void onAfterLoad()
Called on the EDT after the table has re-loaded rows.
-
onBeforeLoad
protected void onBeforeLoad()
Called on the EDT before the table re-loads its rows
-
items
protected abstract java.util.Collection<T> items() throws java.lang.Exception
Load the available items. Note that this is always called OFF the EDT so it is safe to do network access here if need be. (but it is NOT safe to interact with the UI)- Throws:
java.lang.Exception
-
updateColumns
public void updateColumns()
Call this if you have altered the columns (for example, changing visibility)
-
update
public void update()
Call this when the item list has changed and needs to be reloaded
-
updateModel
public void updateModel()
Rebuilds the columns and the model.
-
handleLoadingError
protected void handleLoadingError(java.lang.Exception ex)
Called on the EDT if items() throws an exception
-
setRowHeight
public void setRowHeight(int height)
Sets the height of the rows of the child table
-
getTable
public javax.swing.JTable getTable()
Getter for the internalJTable
- Returns:
- The internal
JTable
-
-