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:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
TermTable

public abstract class AbstractCRUDTable<T> extends JPanel
See Also:
  • Field Details

  • Constructor Details

    • 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 Details

    • 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 class JComponent
    • getNoun

      protected abstract String getNoun()
      Return the noun that describes the item being manipulated.
    • initColumns

      protected abstract void initColumns(List<AbstractCRUDTable<T>.Column<?>> columns)
      Add your columns to the list
    • initModel

      protected AbstractCRUDTable<T>.CRUDModel initModel(List<AbstractCRUDTable<T>.Column<?>> columns)
    • initTable

      protected TouchscreenTable initTable(TableModel model)
    • initScrollPane

      protected JScrollPane initScrollPane(JTable table)
    • getAddIcon

      protected Icon getAddIcon()
    • getEditIcon

      protected Icon getEditIcon()
    • getDeleteIcon

      protected Icon getDeleteIcon()
    • getUpIcon

      protected Icon getUpIcon()
    • getDownIcon

      protected Icon getDownIcon()
    • initActions

      protected void initActions()
      Create the addAction, editAction, and deleteAction
    • updateAddText

      protected void updateAddText(String message)
    • updateEditText

      protected void updateEditText(String message)
    • updateDeleteText

      protected void updateDeleteText(String message)
    • updateUpText

      protected void updateUpText(String message)
    • updateDownText

      protected void updateDownText(String message)
    • updateDeleteConfirm

      protected void updateDeleteConfirm(String message, String yesText, String noText, LoggerEx log)
    • createToolbarButton

      protected JButton createToolbarButton(Action action)
    • initLayout

      protected void initLayout()
    • migInsets

      protected String migInsets()
    • setFont

      public void setFont(Font font)
      Overrides:
      setFont in class JComponent
    • setWindowBackground

      public void setWindowBackground(Color color)
      Sets the background color of the window to the passed Color.
      Parameters:
      color - the Color the window is to be set to. Must not be null.
    • setWindowForeground

      public void setWindowForeground(Color color)
      Sets the text color of the window to the passed Color.
      Parameters:
      color - the Color the windows text is to be set to. Must not be null.
    • setHeaderBackground

      public void setHeaderBackground(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(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(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(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 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 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 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 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 List<T> getSelected()
      Returns a list of the selected items
    • getItems

      public 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(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(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 Collection<T> items() throws 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:
      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(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 JTable getTable()
      Getter for the internal JTable
      Returns:
      The internal JTable