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 classAbstractCRUDTable.Column<C>protected classAbstractCRUDTable.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>actionsprotected javax.swing.ActionaddActionprotected javax.swing.ActiondeleteActionprotected com.inductiveautomation.ignition.client.util.gui.AbstractCRUDTable.DeleteConfirmdeleteConfirmPanelprotected javax.swing.ActiondownActionprotected javax.swing.ActioneditActionprotected LoadingIconloadingIconprotected javax.swing.JLabelloadingOverlayprotected LoggerExlogprotected AbstractCRUDTable.CRUDModelmodelprotected booleanrequireConfirmOnDeleteprotected javax.swing.JScrollPanescrollPaneprotected TouchscreenTabletableprotected java.util.List<AbstractCRUDTable.Column<?>>tableColumnsprotected javax.swing.ActionupActionprotected java.beans.PropertyChangeListenerupdatePCLA 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 protectedAbstractCRUDTable()protectedAbstractCRUDTable(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 booleancanAdd()protected booleancanDelete()protected booleancanEdit()protected javax.swing.JButtoncreateToolbarButton(javax.swing.Action action)protected javax.swing.IcongetAddIcon()protected javax.swing.IcongetDeleteIcon()protected javax.swing.IcongetDownIcon()protected javax.swing.IcongetEditIcon()java.awt.ColorgetHeaderBackground()Gets the table's header background color.java.awt.ColorgetHeaderTextColor()Gets the table's header text color.java.util.List<T>getItems()protected abstract java.lang.StringgetNoun()Return the noun that describes the item being manipulated.java.util.List<T>getSelected()Returns a list of the selected itemsjavax.swing.JTablegetTable()Getter for the internalJTablejava.awt.ColorgetTableBackground()Gets the table's background color.java.awt.ColorgetTableForeground()Gets the table's text color.protected javax.swing.IcongetUpIcon()protected voidhandleLoadingError(java.lang.Exception ex)Called on the EDT if items() throws an exceptionprotected voidinitActions()Create the addAction, editAction, and deleteActionprotected abstract voidinitColumns(java.util.List<AbstractCRUDTable.Column<?>> columns)Add your columns to the listprotected voidinitialize(boolean callUpdate)This sets up the UI.protected voidinitLayout()protected LoggerExinitLogger()protected AbstractCRUDTable.CRUDModelinitModel(java.util.List<AbstractCRUDTable.Column<?>> columns)protected javax.swing.JScrollPaneinitScrollPane(javax.swing.JTable table)protected TouchscreenTableinitTable(javax.swing.table.TableModel model)protected abstract java.util.Collection<T>items()Load the available items.protected java.lang.StringmigInsets()protected abstract voidonAdd()Callback when the add action is pressed.protected voidonAfterLoad()Called on the EDT after the table has re-loaded rows.protected voidonBeforeLoad()Called on the EDT before the table re-loads its rowsprotected abstract voidonDelete(java.util.List<T> toDelete)Callback when the delete action is pressed.protected voidonDoubleClick()By default, simply calls onEdit if editing is allowedprotected abstract voidonEdit(java.util.List<T> toEdit)Callback when the edit action is pressed.protected voidonMoveDown(T toMove)protected voidonMoveUp(T toMove)protected booleanordered()Override this to have up and down arrowsvoidsetEnabled(boolean enabled)voidsetFont(java.awt.Font font)voidsetHeaderBackground(java.awt.Color color)Sets the header background to this table.voidsetHeaderTextColor(java.awt.Color color)Sets the header text color to this table.voidsetRowHeight(int height)Sets the height of the rows of the child tablevoidsetTableBackground(java.awt.Color color)Sets the background to this table.voidsetTableForeground(java.awt.Color color)Sets the text color to this table.voidsetWindowBackground(java.awt.Color color)Sets the background color of the window to the passedColor.voidsetWindowForeground(java.awt.Color color)Sets the text color of the window to the passedColor.voidupdate()Call this when the item list has changed and needs to be reloadedprotected voidupdateAddText(java.lang.String message)voidupdateColumns()Call this if you have altered the columns (for example, changing visibility)protected voidupdateDeleteConfirm(java.lang.String message, java.lang.String yesText, java.lang.String noText, LoggerEx log)protected voidupdateDeleteText(java.lang.String message)protected voidupdateDownText(java.lang.String message)protected voidupdateEditText(java.lang.String message)voidupdateEnabled()Call to update the enabled-ness of the button actions.voidupdateModel()Rebuilds the columns and the model.protected voidupdateUpText(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:
setEnabledin 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:
setFontin classjavax.swing.JComponent
-
setWindowBackground
public void setWindowBackground(java.awt.Color color)
Sets the background color of the window to the passedColor.- Parameters:
color- theColorthe 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- theColorthe 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
-
-