Class EntityEditComponentPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
EntityEditPanel

public class EntityEditComponentPanel extends JPanel
A base class for entity edit panels, providing components for editing entities.
See Also:
  • Field Details

  • Constructor Details

    • EntityEditComponentPanel

      protected EntityEditComponentPanel(SwingEntityEditModel editModel)
      Instantiates a new EntityEditComponentPanel
      Parameters:
      editModel - the edit model
    • EntityEditComponentPanel

      protected EntityEditComponentPanel(SwingEntityEditModel editModel, EntityComponents entityComponents)
      Instantiates a new EntityEditComponentPanel
      Parameters:
      editModel - the edit model
      entityComponents - the entity components to use when creating components
      Throws:
      IllegalArgumentException - in case the edit model and entity components entityTypes don't match
  • Method Details

    • editModel

      public final <T extends SwingEntityEditModel> T editModel()
      Type Parameters:
      T - the edit model type
      Returns:
      the edit model this panel is based on
    • attributes

      public final Collection<Attribute<?>> attributes()
      Returns:
      an unmodifiable view of the attributes that have associated components.
    • component

      public final JComponent component(Attribute<?> attribute)
      Parameters:
      attribute - the attribute
      Returns:
      the component associated with the given attribute
      Throws:
      IllegalArgumentException - in case no component or component builder has been associated with the given attribute
    • attribute

      public final <T> Attribute<T> attribute(JComponent component)
      Type Parameters:
      T - the attribute type
      Parameters:
      component - the component
      Returns:
      the attribute the given component is associated with
      Throws:
      IllegalArgumentException - in case no attribute is associated with the given component
    • initialFocusComponent

      public final Value<JComponent> initialFocusComponent()
      Sets the component that should receive the focus when the UI is cleared or activated. Overrides the value set via initialFocusAttribute()
      Returns:
      the Value controlling the initial focus component
    • initialFocusAttribute

      public final Value<Attribute<?>> initialFocusAttribute()
      Sets the component associated with the given attribute as the component that should receive the initial focus in this edit panel. This is overridden by initialFocusComponent().
      Returns:
      the Value controlling the initial focus attribute
      See Also:
    • afterInsertFocusComponent

      public final Value<JComponent> afterInsertFocusComponent()
      Sets the component that should receive the focus after an insert has been performed. Overrides the value set via afterInsertFocusAttribute()
      Returns:
      the Value controlling the after insert focus component
    • afterInsertFocusAttribute

      public final Value<Attribute<?>> afterInsertFocusAttribute()
      Sets the component associated with the given attribute as the component that should receive the focus after an insert is performed in this edit panel. This is overridden by afterInsertFocusComponent().
      Returns:
      the Value controlling the after insert focus attribute
      See Also:
    • requestInitialFocus

      public final void requestInitialFocus()
      Sets the initial focus, if an initial focus component or component attribute has been set that component receives the focus, if not, or if that component is not focusable, this panel receives the focus. Note that if this panel is not visible then calling this method has no effect.
      See Also:
    • requestComponentFocus

      public final void requestComponentFocus(Attribute<?> attribute)
      Request focus for the component associated with the given attribute. If no component is associated with the attribute calling this method has no effect.
      Parameters:
      attribute - the attribute of the component to select
    • selectInputComponent

      public final void selectInputComponent()
      Displays a dialog allowing the user the select an input component which should receive the keyboard focus, if only one input component is available then that component is selected automatically.
      See Also:
    • selectComponentAttributes

      public final Collection<Attribute<?>> selectComponentAttributes()
      Returns:
      an unmodifiable view of the attributes to present when selecting an input component in this panel, this returns all (non-excluded) attributes that have an associated component in this panel that is enabled, displayable, visible and focusable.
      See Also:
    • excludeComponentsFromSelection

      public final void excludeComponentsFromSelection(Attribute<?>... attributes)
      Specifies that the given attributes should be excluded when presenting a component selection list.
      Parameters:
      attributes - the attributes to exclude from selection
      See Also:
    • onException

      protected void onException(Throwable exception)
      Handles the given exception, simply displays the error message to the user by default.
      Parameters:
      exception - the exception to handle
      See Also:
    • displayException

      protected final void displayException(Throwable exception)
      Displays the exception in a dialog
      Parameters:
      exception - the exception to display
    • setUseModifiedIndicator

      protected final void setUseModifiedIndicator(boolean useModifiedIndicator)
      If set to true then component labels will indicate that the value is modified. This applies to all components created by this edit component panel as well as components set via setComponent(Attribute, JComponent) as long as the component has a JLabel associated with its 'labeledBy' client property. Note that this has no effect on components that have already been created.
      Parameters:
      useModifiedIndicator - the new value
      See Also:
    • setTransferFocusOnEnter

      protected final void setTransferFocusOnEnter(boolean transferFocusOnEnter)
      If set to true then components created subsequently will transfer focus on enter, otherwise not. Note that this has no effect on components that have already been created.
      Parameters:
      transferFocusOnEnter - the new value
      See Also:
    • setDefaultTextFieldColumns

      protected final void setDefaultTextFieldColumns(int defaultTextFieldColumns)
      Sets the default number of text field columns
      Parameters:
      defaultTextFieldColumns - the default text field columns
      See Also:
    • setComponent

      protected final void setComponent(Attribute<?> attribute, JComponent component)
      Associates the given input component with the given attribute.
      Parameters:
      attribute - the attribute
      component - the input component
    • addInputPanel

      protected final void addInputPanel(Attribute<?> attribute)
      Adds a panel for the given attribute to this panel
      Parameters:
      attribute - the attribute
      See Also:
    • addInputPanel

      protected final void addInputPanel(Attribute<?> attribute, Object constraints)
      Adds a panel for the given attribute to this panel using the given layout constraints
      Parameters:
      attribute - the attribute
      constraints - the layout constraints
      See Also:
    • addInputPanel

      protected final void addInputPanel(Attribute<?> attribute, JComponent inputComponent)
      Adds a panel for the given attribute to this panel
      Parameters:
      attribute - the attribute
      inputComponent - a component bound to attribute
      See Also:
    • addInputPanel

      protected final void addInputPanel(Attribute<?> attribute, JComponent inputComponent, Object constraints)
      Adds a panel for the given attribute to this panel using the given layout constraints
      Parameters:
      attribute - the attribute
      inputComponent - a component bound to attribute
      constraints - the layout constraints
      See Also:
    • createInputPanel

      protected final JPanel createInputPanel(Attribute<?> attribute)
      Creates a panel containing a label and the component associated with the given attribute. The label text is the caption defined for attribute. The default layout of the resulting panel is with the label on top and inputComponent below.
      Parameters:
      attribute - the attribute from which definition to retrieve the label caption
      Returns:
      a panel containing a label and a component
      Throws:
      IllegalArgumentException - in case no component has been associated with the given attribute
    • createInputPanel

      protected final JPanel createInputPanel(Attribute<?> attribute, JComponent inputComponent)
      Creates a panel containing a label and the component associated with the given attribute. The label text is the caption defined for attribute. The default layout of the resulting panel is with the label on top and inputComponent below.
      Parameters:
      attribute - the attribute from which definition to retrieve the label caption
      inputComponent - a component bound to the value of attribute
      Returns:
      a panel containing a label and a component
    • createInputPanel

      protected final JPanel createInputPanel(Attribute<?> attribute, JComponent inputComponent, String labelBorderLayoutConstraints)
      Creates a panel containing a label and the component associated with the given attribute. The label text is the caption defined for on attribute.
      Parameters:
      attribute - the attribute from which definition to retrieve the label caption
      inputComponent - a component bound to the value of attribute
      labelBorderLayoutConstraints - BorderLayout.NORTH, BorderLayout.SOUTH, BorderLayout.EAST or BorderLayout.WEST
      Returns:
      a panel containing a label and a component
    • createInputPanel

      protected final JPanel createInputPanel(Attribute<?> attribute, JComponent inputComponent, String labelBorderLayoutConstraints, int labelAlignment)
      Creates a panel containing a label and the given component. The label text is the caption of attribute.
      Parameters:
      attribute - the attribute from which definition to retrieve the label caption
      inputComponent - a component bound to the value of attribute
      labelBorderLayoutConstraints - BorderLayout.NORTH, BorderLayout.SOUTH, BorderLayout.EAST or BorderLayout.WEST
      labelAlignment - the label alignment
      Returns:
      a panel containing a label and a component
    • createInputPanel

      protected final JPanel createInputPanel(JComponent labelComponent, JComponent inputComponent)
      Creates a panel containing a label component and the inputComponent with the label component positioned above the input component.
      Parameters:
      labelComponent - the label component
      inputComponent - a input component
      Returns:
      a panel containing a label and a component
    • createInputPanel

      protected final JPanel createInputPanel(JComponent labelComponent, JComponent inputComponent, String labelBorderLayoutConstraints)
      Creates a panel with a BorderLayout, with the inputComponent at BorderLayout.CENTER and the labelComponent at a specified location.
      Parameters:
      labelComponent - the label component
      inputComponent - a input component
      labelBorderLayoutConstraints - BorderLayout.NORTH, BorderLayout.SOUTH, BorderLayout.EAST or BorderLayout.WEST
      Returns:
      a panel containing a label and a component
    • createTextArea

      protected final TextAreaBuilder createTextArea(Attribute<String> attribute)
      Creates a builder for text areas.
      Parameters:
      attribute - the attribute for which to build a text area
      Returns:
      a text area builder
    • createTextFieldPanel

      protected final TextFieldPanel.Builder createTextFieldPanel(Attribute<String> attribute)
      Creates a builder for text field panels.
      Parameters:
      attribute - the attribute for which to build a text field panel
      Returns:
      a text field panel builder
    • createTemporalFieldPanel

      protected final <T extends Temporal> TemporalFieldPanel.Builder<T> createTemporalFieldPanel(Attribute<T> attribute)
      Creates a builder for temporal field panels.
      Type Parameters:
      T - the temporal type
      Parameters:
      attribute - the attribute for which to build a temporal field panel
      Returns:
      a text area builder
    • createTemporalFieldPanel

      protected final <T extends Temporal> TemporalFieldPanel.Builder<T> createTemporalFieldPanel(Attribute<T> attribute, String dateTimePattern)
      Creates a builder for temporal field panels.
      Type Parameters:
      T - the temporal type
      Parameters:
      attribute - the attribute for which to build a temporal field panel
      dateTimePattern - the date time pattern
      Returns:
      a text area builder
    • createTextField

      protected final <T, C extends JTextField, B extends TextFieldBuilder<T, C, B>> TextFieldBuilder<T,C,B> createTextField(Attribute<T> attribute)
      Creates a builder for text fields.
      Type Parameters:
      T - the value type
      C - the text field type
      B - the builder type
      Parameters:
      attribute - the attribute for which to build a text field
      Returns:
      a text field builder
    • createTemporalField

      protected final <T extends Temporal> TemporalField.Builder<T> createTemporalField(Attribute<T> attribute)
      Creates a builder for temporal fields.
      Type Parameters:
      T - the temporal type
      Parameters:
      attribute - the attribute for which to build a temporal field
      Returns:
      an offset date time field builder
    • createTemporalField

      protected final <T extends Temporal> TemporalField.Builder<T> createTemporalField(Attribute<T> attribute, String dateTimePattern)
      Creates a builder for temporal fields.
      Type Parameters:
      T - the temporal type
      Parameters:
      attribute - the attribute for which to build a temporal field
      dateTimePattern - the date time pattern
      Returns:
      an offset date time field builder
    • createSlider

      protected final SliderBuilder createSlider(Attribute<Integer> attribute)
      Creates a builder for a slider
      Parameters:
      attribute - the attribute
      Returns:
      a slider builder
    • createIntegerSpinner

      protected final NumberSpinnerBuilder<Integer> createIntegerSpinner(Attribute<Integer> attribute)
      Creates a builder for a spinner
      Parameters:
      attribute - the attribute
      Returns:
      a spinner builder
    • createDoubleSpinner

      protected final NumberSpinnerBuilder<Double> createDoubleSpinner(Attribute<Double> attribute)
      Creates a builder for a spinner
      Parameters:
      attribute - the attribute
      Returns:
      a spinner builder
    • createListSpinner

      protected final <T> ListSpinnerBuilder<T> createListSpinner(Attribute<T> attribute, SpinnerListModel spinnerListModel)
      Creates a builder for a list spinner
      Type Parameters:
      T - the value type
      Parameters:
      attribute - the attribute
      spinnerListModel - the spinner model
      Returns:
      a spinner builder
    • createItemSpinner

      protected final <T> ItemSpinnerBuilder<T> createItemSpinner(Attribute<T> attribute)
      Creates a builder for a list spinner
      Type Parameters:
      T - the value type
      Parameters:
      attribute - the attribute
      Returns:
      a spinner builder
    • createIntegerField

      protected final NumberField.Builder<Integer> createIntegerField(Attribute<Integer> attribute)
      Creates a builder for integer fields.
      Parameters:
      attribute - the attribute for which to build a text field
      Returns:
      a integer field builder
    • createLongField

      protected final NumberField.Builder<Long> createLongField(Attribute<Long> attribute)
      Creates a builder for long fields.
      Parameters:
      attribute - the attribute for which to build a text field
      Returns:
      a long field builder
    • createDoubleField

      protected final NumberField.Builder<Double> createDoubleField(Attribute<Double> attribute)
      Creates a builder for double fields.
      Parameters:
      attribute - the attribute for which to build a text field
      Returns:
      a double field builder
    • createBigDecimalField

      protected final NumberField.Builder<BigDecimal> createBigDecimalField(Attribute<BigDecimal> attribute)
      Creates a builder for big decimal fields.
      Parameters:
      attribute - the attribute for which to build a text field
      Returns:
      a big decimal field builder
    • createMaskedTextField

      protected final MaskedTextFieldBuilder createMaskedTextField(Attribute<String> attribute)
      Creates a builder for formatted text fields.
      Parameters:
      attribute - the attribute for which to build a formatted text field
      Returns:
      a formatted text field builder
    • createCheckBox

      protected final CheckBoxBuilder createCheckBox(Attribute<Boolean> attribute)
      Creates a builder for check boxes. If CheckBoxBuilder.nullable(boolean) is set to true, a NullableCheckBox is built.
      Parameters:
      attribute - the attribute for which to build a check-box
      Returns:
      a check-box builder
    • createBooleanComboBox

      protected final ItemComboBoxBuilder<Boolean> createBooleanComboBox(Attribute<Boolean> attribute)
      Creates a builder for boolean combo boxes.
      Parameters:
      attribute - the attribute for which to build boolean combo box
      Returns:
      a boolean combo box builder
    • createComboBox

      protected final <T, C extends JComboBox<T>, B extends ComboBoxBuilder<T, C, B>> ComboBoxBuilder<T,C,B> createComboBox(Attribute<T> attribute, ComboBoxModel<T> comboBoxModel)
      Creates a builder for combo boxes.
      Type Parameters:
      T - the value type
      C - the component type
      B - the builder type
      Parameters:
      attribute - the attribute for which to build combo box
      comboBoxModel - the combo box model
      Returns:
      a combo box builder
    • createItemComboBox

      protected final <T> ItemComboBoxBuilder<T> createItemComboBox(Attribute<T> attribute)
      Creates a builder for value item list combo boxes.
      Type Parameters:
      T - the value type
      Parameters:
      attribute - the attribute for which to build a value list combo box
      Returns:
      a value item list combo box builder
    • createComboBox

      protected final <T, C extends JComboBox<T>, B extends ComboBoxBuilder<T, C, B>> ComboBoxBuilder<T,C,B> createComboBox(Column<T> column)
      Creates a builder for a combo boxe, containing the values of the given column.
      Type Parameters:
      T - the value type
      C - the component type
      B - the builder type
      Parameters:
      column - the column for which to build a combo box
      Returns:
      a combo box builder
    • createForeignKeyComboBox

      protected final <B extends ComboBoxBuilder<Entity, EntityComboBox, B>> ComboBoxBuilder<Entity,EntityComboBox,B> createForeignKeyComboBox(ForeignKey foreignKey)
      Creates a builder for foreign key combo boxes.
      Type Parameters:
      B - the builder type
      Parameters:
      foreignKey - the foreign key for which to build a combo box
      Returns:
      a foreign key combo box builder
    • createForeignKeyComboBoxPanel

      protected final EntityComboBoxPanel.Builder createForeignKeyComboBoxPanel(ForeignKey foreignKey, Supplier<EntityEditPanel> editPanelSupplier)
      Creates a builder for a foreign key combo box panel with optional buttons for adding and editing items.
      Parameters:
      foreignKey - the foreign key
      editPanelSupplier - the edit panel supplier to use for the add and/or edit buttons
      Returns:
      a foreign key combo box panel builder
    • createForeignKeySearchField

      protected final EntitySearchField.Builder createForeignKeySearchField(ForeignKey foreignKey)
      Creates a builder for foreign key search fields.
      Parameters:
      foreignKey - the foreign key for which to build a search field
      Returns:
      a foreign key search field builder
    • createForeignKeySearchFieldPanel

      protected final EntitySearchFieldPanel.Builder createForeignKeySearchFieldPanel(ForeignKey foreignKey, Supplier<EntityEditPanel> editPanelSupplier)
      Creates a builder for a foreign key search field panel with optional buttons for adding and editing items.
      Parameters:
      foreignKey - the foreign key
      editPanelSupplier - the edit panel supplier to use for the add and/or edit buttons
      Returns:
      a foreign key combo box panel builder
    • createForeignKeyTextField

      protected final <B extends TextFieldBuilder<Entity, JTextField, B>> TextFieldBuilder<Entity,JTextField,B> createForeignKeyTextField(ForeignKey foreignKey)
      Creates a builder for a read-only, non-focusable foreign key text field.
      Type Parameters:
      B - the builder type
      Parameters:
      foreignKey - the foreign key for which to build a text field
      Returns:
      a foreign key text field builder
    • createForeignKeyLabel

      protected final LabelBuilder<Entity> createForeignKeyLabel(ForeignKey foreignKey)
      Creates a builder for a read-only foreign key label.
      Parameters:
      foreignKey - the foreign key for which to build a label
      Returns:
      a foreign key label builder
    • createLabel

      protected final <T> LabelBuilder<T> createLabel(Attribute<T> attribute)
      Creates a builder for a label using the caption and mnemonic associated with attribute. If an input component exists for the given attribute the label is associated with it via JLabel.setLabelFor(Component).
      Type Parameters:
      T - the attribute type
      Parameters:
      attribute - the attribute from which to retrieve the caption
      Returns:
      a label builder for the given attribute
    • getInitialFocusComponent

      protected JComponent getInitialFocusComponent()
      Returns:
      the component that should get the initial focus when the UI is initialized
    • getAfterInsertFocusComponent

      protected JComponent getAfterInsertFocusComponent()
      Returns:
      the component that should receive the focus when the UI is initialized after insert
    • requestAfterInsertFocus

      protected final void requestAfterInsertFocus()
    • requestAfterUpdateFocus

      protected final void requestAfterUpdateFocus()