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, managing the components used for editing entities.
See Also:
  • Field Details

  • Constructor Details

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

      Returns:
      the EntityEditComponentPanel.InputFocus instance, managing the input focus
    • onException

      protected void onException(Exception exception)
      Handles the given exception, simply displays the error message to the user by default. Note that this method does nothing in case of a CancelException.
      Parameters:
      exception - the exception to handle
      See Also:
    • component

      protected final Value<JComponent> component(Attribute<?> attribute)
      Parameters:
      attribute - the attribute
      Returns:
      the Value containing the component associated with the given attribute
    • displayException

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

      protected final EntityEditComponentPanel.Defaults defaults()
      Returns:
      the EntityEditComponentPanel.Defaults instance for this edit component panel
    • modifiedIndicator

      protected final State modifiedIndicator()
      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 component(Attribute) as long as the component has a JLabel associated with its 'labeledBy' client property. Note that changing this has no effect on components that have already been created.
      Returns:
      the State controlling whether components display an indicator if the value is modified
      See Also:
    • 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
    • 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
    • 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
    • createComboBox

      protected final EntityComboBox.Builder createComboBox(ForeignKey foreignKey)
      Creates a builder for foreign key combo boxes.
      Parameters:
      foreignKey - the foreign key for which to build a combo box
      Returns:
      a foreign key combo box builder
    • createComboBoxPanel

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

      protected final EntitySearchField.SingleSelectionBuilder createSearchField(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
    • createSearchFieldPanel

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

      protected final <B extends TextFieldBuilder<Entity, JTextField, B>> TextFieldBuilder<Entity,JTextField,B> createTextField(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
    • createList

      protected final <T> EntityEditComponentPanel.ListBuilderFactory<T> createList(ListModel<T> listModel)
      Creates a list builder factory
      Type Parameters:
      T - the value type
      Parameters:
      listModel - the list model to base the list on
      Returns:
      a list builder factory
    • 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
    • addValidator

      protected final <T> void addValidator(Attribute<T> attribute, JTextComponent textComponent)
      Adds a validator to the given text component
      Type Parameters:
      T - the value type
      Parameters:
      attribute - the attribute of the value to validate
      textComponent - the text component
    • addValidator

      protected final <T> void addValidator(Attribute<T> attribute, JComboBox<?> comboBox)
      Adds a validator to the given combo box
      Type Parameters:
      T - the value type
      Parameters:
      attribute - the attribute of the value to validate
      comboBox - the combo box
    • components

      protected final Map<Attribute<?>,Value<JComponent>> components()